1
0
forked from alex-eg/sex

read hex and binary literals

0x80 was not a number to string->number, so it became a symbol the
printer escaped as |0x80|, and #x was rejected outright. Both spellings
now read as the integer, which the C writes in decimal.

Fixes #47.
This commit is contained in:
2026-10-09 16:06:14 +03:00
parent cc0f7f91ec
commit f3d9c95daf
3 changed files with 44 additions and 3 deletions

View File

@@ -47,6 +47,13 @@
(reader-test '(-1 -1.5) "-1 -1.5")
(reader-test '(- -> ->> -- -=) "- -> ->> -- -=")
;; a number in another radix, spelled the way C does or the way
;; Scheme does; either is an ordinary integer from here on
(reader-test '(224 224 5 5 -16) "0xE0 0Xe0 0b101 0B101 -0x10")
(reader-test '(128 128 5 8 -16) "#x80 #X80 #b101 #o10 #x-10")
;; ...and only a number: a prefix with nothing after it is a name
(reader-test '(0x 0xg) "0x 0xg")
;; `;' comments are preserved as (comment "...") forms
(reader-test '((comment " hi")) "; hi")
(reader-test '((comment ";; Prototypes")) ";;; Prototypes")