Fixed a reader bug that causes '#!eof not to read properly.

Used to be:
> '#!eof
Unhandled exception
 Condition components:
  1. &lexical
  2. &message: "invalid eof after quote read macro"
  3. &lexical-position:
      file-name: *stdin*
      character: 7

Now:
> '#!eof
#!eof
This commit is contained in:
Abdulaziz Ghuloum 2008-04-14 22:18:56 -04:00
parent 139ff2f33c
commit 177f6b84a7
2 changed files with 16 additions and 12 deletions

View File

@ -1239,17 +1239,21 @@
(values (cdr t)
(annotate-simple (cdr t) pos p) locs k)]
[(eq? (car t) 'macro)
(let-values ([(expr expr^ locs k)
(read-expr p locs k)])
(when (eof-object? expr)
(die/p p 'read
(format "invalid eof after ~a read macro"
(cdr t))))
(let ([x (list expr)] [x^ (list expr^)])
(values (cons (cdr t) x)
(cons (annotate-simple (cdr t) pos p) x^)
locs
(extend-k-pair x x^ expr '() k))))]
(let ([macro (cdr t)])
(define (read-macro)
(let-values ([(t pos) (tokenize/1+pos p)])
(cond
[(eof-object? t)
(die/p p 'read
(format "invalid eof after ~a read macro"
macro))]
[else (parse-token p locs k t pos)])))
(let-values ([(expr expr^ locs k) (read-macro)])
(let ([x (list expr)] [x^ (list expr^)])
(values (cons macro x)
(cons (annotate-simple macro pos p) x^)
locs
(extend-k-pair x x^ expr '() k)))))]
[(eq? (car t) 'mark)
(let ([n (cdr t)])
(let-values ([(expr expr^ locs k)

View File

@ -1 +1 @@
1448
1449