1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-02 04:40:29 +02:00

handle EOF correctly in parser and lexer

* module/language/elisp/lexer.scm (lex, get-lexer/1): Return a valid
  token at EOF.
* module/language/elisp/parser.scm (get-expression): Raise an error if
  EOF is reached.
  (read-elisp): If at EOF, return the EOF object instead of attempting
  to read an expression.
This commit is contained in:
Brian Templeton 2010-06-24 23:03:08 -04:00
parent 258914f320
commit c8ed3e7cef
2 changed files with 10 additions and 5 deletions

View file

@ -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)))))