more simplifications to reader.

This commit is contained in:
Abdulaziz Ghuloum 2007-12-18 22:28:27 -05:00
parent 4393d2aab9
commit 2c98be442a
2 changed files with 18 additions and 10 deletions

View File

@ -906,8 +906,9 @@
(define tokenize/c (define tokenize/c
(lambda (c p) (lambda (c p)
(cond (cond
[(eof-object? c) (eof-object)] [(eof-object? c)
[(char-whitespace? c) (tokenize/1 p)] (error 'tokenize/c "hmmmm eof")
(eof-object)]
[($char= #\( c) 'lparen] [($char= #\( c) 'lparen]
[($char= #\) c) 'rparen] [($char= #\) c) 'rparen]
[($char= #\[ c) 'lbrack] [($char= #\[ c) 'lbrack]
@ -933,9 +934,6 @@
[($char= #\" c) [($char= #\" c)
(let ([ls (tokenize-string '() p)]) (let ([ls (tokenize-string '() p)])
(cons 'datum (list->string (reverse ls))))] (cons 'datum (list->string (reverse ls))))]
[($char= #\; c)
(skip-comment p)
(tokenize/1 p)]
[(memq c '(#\+)) [(memq c '(#\+))
(let ([c (peek-char p)]) (let ([c (peek-char p)])
(cond (cond
@ -977,7 +975,7 @@
(let ([c (read-char p)]) (let ([c (read-char p)])
(cond (cond
[(eof-object? c) (eof-object)] [(eof-object? c) (eof-object)]
[(eqv? c '#\;) [(eqv? c #\;)
(skip-comment p) (skip-comment p)
(tokenize/1 p)] (tokenize/1 p)]
[(eqv? c #\#) [(eqv? c #\#)
@ -993,24 +991,34 @@
(tokenize/1 p)] (tokenize/1 p)]
[else [else
(tokenize-hash/c c p)]))] (tokenize-hash/c c p)]))]
[(char-whitespace? c) (tokenize/1 p)]
[else (tokenize/c c p)])))) [else (tokenize/c c p)]))))
(define tokenize-script-initial (define tokenize-script-initial
(lambda (p) (lambda (p)
(let ([c (read-char p)]) (let ([c (read-char p)])
(cond (cond
[(eof-object? c) c] [(eof-object? c) c]
[($char= #\# c) [(eqv? c #\;)
(skip-comment p)
(tokenize/1 p)]
[(eqv? c #\#)
(let ([c (read-char p)]) (let ([c (read-char p)])
(cond (cond
[(eof-object? c) [(eof-object? c)
(die/p p 'tokenize "invalid eof after #")] (die/p p 'tokenize "invalid eof after #")]
[($char= #\! c) [(eqv? c #\!)
(skip-comment p) (skip-comment p)
(tokenize/1 p)] (tokenize/1 p)]
[(eqv? c #\;)
(my-read p) ; skip s-expr
(tokenize/1 p)]
[(eqv? c #\|)
(multiline-comment p)
(tokenize/1 p)]
[else [else
(tokenize-hash/c c p)]))] (tokenize-hash/c c p)]))]
[(char-whitespace? c) (tokenize/1 p)]
[else (tokenize/c c p)])))) [else (tokenize/c c p)]))))
(define-struct loc (value set?)) (define-struct loc (value set?))

View File

@ -1 +1 @@
1262 1263