diff --git a/module/language/elisp/lexer.scm b/module/language/elisp/lexer.scm index e762c3f9f..c0d25f5ae 100644 --- a/module/language/elisp/lexer.scm +++ b/module/language/elisp/lexer.scm @@ -270,7 +270,7 @@ (c (read-char port))) (cond ;; End of input must be specially marked to the parser. - ((eof-object? c) '*eoi*) + ((eof-object? c) (return 'eof c)) ;; Whitespace, just skip it. ((char-whitespace? c) (lex port)) ;; The dot is only the one for dotted lists if followed by @@ -390,7 +390,7 @@ (paren-level 0)) (lambda () (if finished - '*eoi* + (cons 'eof ((@ (rnrs io ports) eof-object))) (let ((next (lex)) (quotation #f)) (case (car next) diff --git a/module/language/elisp/parser.scm b/module/language/elisp/parser.scm index 4b411df0d..2bc41a044 100644 --- a/module/language/elisp/parser.scm +++ b/module/language/elisp/parser.scm @@ -178,6 +178,8 @@ (source-properties token))) result))) (case type + ((eof) + (parse-error token "end of file during parsing")) ((integer float symbol character string) (return (cdr token))) ((quote backquote unquote unquote-splicing) @@ -207,6 +209,9 @@ (with-fluids ((circular-definitions (make-circular-definitions))) (let* ((lexer (get-lexer port)) (lexbuf (make-lexer-buffer lexer)) - (result (get-expression lexbuf))) - (lexbuf 'finish) - result))) + (next (lexbuf 'peek))) + (if (eq? (car next) 'eof) + (cdr next) + (let ((result (get-expression lexbuf))) + (lexbuf 'finish) + result)))))