read -NAME as the negation of NAME
The reader took -INFINITY as one symbol, and the leading dash was then mangled like any other: _INFINITY. -1 was always a number, so a name gets the same reading. Fixes #63.
This commit is contained in:
@@ -179,8 +179,17 @@
|
||||
(cond
|
||||
((string=? s ".") dot-token)
|
||||
((string->number s) => identity)
|
||||
((negated-name? s) (list '- (string->symbol (substring s 1))))
|
||||
(else (string->symbol s))))
|
||||
|
||||
;;; -INFINITY is (- INFINITY), as -1 is minus one. No name begins with
|
||||
;;; a dash, and an operator that does goes on with a non-letter: -> --
|
||||
(define (negated-name? s)
|
||||
(and (> (string-length s) 1)
|
||||
(char=? #\- (string-ref s 0))
|
||||
(let ((c (string-ref s 1)))
|
||||
(or (char-alphabetic? c) (char=? c #\_)))))
|
||||
|
||||
;;; #-dispatch: booleans, characters, vectors, block/datum comments,
|
||||
;;; feature expressions
|
||||
(define (read-hash port)
|
||||
|
||||
Reference in New Issue
Block a user