* Modified the reader and writer to accept "->[subsequent]*" as an

identifier.
This commit is contained in:
Abdulaziz Ghuloum 2007-01-26 09:05:07 -05:00
parent d8f646040f
commit 8139a91a61
5 changed files with 25 additions and 7 deletions

Binary file not shown.

View File

@ -1,4 +1,4 @@
#!eof
;;; input to cogen is <Program>:
;;; <Expr> ::= (constant x)
;;; | (var)

View File

@ -5101,7 +5101,7 @@
[p (convert-closures p)]
[p (optimize-closures/lift-codes p)]
[p^ (new-cogen p)]
;[p^ (new-cogen p)]
[p (introduce-primcalls p)]
[p (simplify-operands p)]
[p (insert-stack-overflow-checks p)]

View File

@ -190,6 +190,11 @@
[($char= c #\.)
(read-char p)
(cons 'datum (tokenize-flonum/no-digits #f p))]
[($char= c #\>)
(read-char p)
(let ([ls (tokenize-identifier '() p)])
(let ([str (list->string (list* #\- #\> (reverse ls)))])
(cons 'datum (string->symbol str))))]
[else (error 'tokenize "invalid sequence -~a" c)]))))
(define tokenize-dot
(lambda (p)

View File

@ -105,13 +105,26 @@
(subsequent*? str ($fxadd1 i) n)))))
(define valid-symbol-string?
(lambda (str)
(or (let ([n ($string-length str)])
(define normal-symbol-string?
(lambda (str)
(let ([n ($string-length str)])
(and ($fx>= n 1)
(initial? ($string-ref str 0))
(subsequent*? str 1 n)))
(string=? str "+")
(string=? str "-")
(string=? str "..."))))
(subsequent*? str 1 n)))))
(define peculiar-symbol-string?
(lambda (str)
(let ([n (string-length str)])
(cond
[(fx= n 1)
(memq (string-ref str 0) '(#\+ #\-))]
[(fx>= n 2)
(or (and (char=? (string-ref str 0) #\-)
(char=? (string-ref str 1) #\>)
(subsequent*? str 2 n))
(string=? str "..."))]))))
(or (normal-symbol-string? str)
(peculiar-symbol-string? str))))
(define write-symbol-esc-loop
(lambda (x i n p)
(unless ($fx= i n)