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:
2026-10-09 16:05:03 +03:00
parent d41960e407
commit 566e8326a3
3 changed files with 20 additions and 0 deletions

View File

@@ -38,6 +38,15 @@
;; a `.'-prefixed symbol is an ordinary symbol, not dot-access
(reader-test '((.field obj)) "(.field obj)")
;; a leading `-' on a name is negation, the way it is on a number:
;; no name is spelled with one, and -INFINITY otherwise mangled into
;; _INFINITY. The operators that start with one are left alone
(reader-test '((- INFINITY)) "-INFINITY")
(reader-test '((var best double (- INFINITY))) "(var best double -INFINITY)")
(reader-test '((- _x)) "-_x")
(reader-test '(-1 -1.5) "-1 -1.5")
(reader-test '(- -> ->> -- -=) "- -> ->> -- -=")
;; `;' comments are preserved as (comment "...") forms
(reader-test '((comment " hi")) "; hi")
(reader-test '((comment ";; Prototypes")) ";;; Prototypes")