parser: Port to Mes.

* gash/compat.scm [mes] (the-eof-object): New variable.
[mes] (noop): New procedure.
* gash/parser.scm: Import '(gash compat)'; remove '(srfi srfi-14)'
import.
(eof-object): Remove procedure.
(make-parser): Replace 'eof-object' with 'the-eof-object'.
(call-with-backquoted-input-port): Likewise.
This commit is contained in:
Timothy Sample 2022-04-28 10:20:29 -06:00
parent e37ef0faba
commit 0c554b6b13
2 changed files with 11 additions and 9 deletions

View File

@ -85,7 +85,9 @@
make-parameter
parameterize
set-port-line!
string-every)
string-every
the-eof-object
noop)
(define-macro (define-inlinable . rest)
`(define ,@rest))
@ -113,4 +115,8 @@
#f)
(define (string-every pred str)
(every pred (string->list str))))
((@ (srfi srfi-1) every) pred (string->list str)))
(define the-eof-object (integer->char -1))
(define (noop . args) #f))

View File

@ -17,12 +17,12 @@
;;; along with Gash. If not, see <http://www.gnu.org/licenses/>.
(define-module (gash parser)
#:use-module (gash compat)
#:use-module (gash compat textual-ports)
#:use-module (gash lexer)
#:use-module (ice-9 match)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-11)
#:use-module (srfi srfi-41)
#:use-module (system base lalr)
#:export (read-sh
read-sh-all))
@ -70,10 +70,6 @@ the variable name and the second element is the value expression."
(match (assignment-name-and-value word)
((name . value) `(,name ,value))))))
;; The (ice-9 textual-ports) module does not allow instantiating
;; end-of-file objects, but (rnrs io ports) does.
(define eof-object (@ (rnrs io ports) eof-object))
(define (map+fold proc init xs)
"Apply @var{proc} to each element of @var{xs}, mapping and folding
at the same time. The procedure @var{proc} must return two values:
@ -237,7 +233,7 @@ the same number of times.)"
(linebreak complete-commands linebreak)
: (if (null? (cdr $2)) (car $2) (reverse! $2))
(linebreak)
: (eof-object))
: the-eof-object)
(complete-commands
(complete-commands newline-list complete-command)
@ -774,7 +770,7 @@ treat the double quote character as escapable."
;; get-char
(lambda ()
(match (lookahead-char port)
(#\` (eof-object))
(#\` the-eof-object)
(#\\ (begin
(get-char port)
(match (lookahead-char port)