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

View File

@ -1 +1 @@
1448 1449