group a number's digits with _
C23 groups them with ', which in Sex is quote, so 1'000 read as 1 and (quote 0); _ between two digits is dropped instead, and anywhere else stays part of a name.
This commit is contained in:
@@ -827,6 +827,8 @@ whitespace aside, THEN?"
|
||||
(test-assert "a float keeps its digits, which a double would round"
|
||||
(emits? (in-fn "(var x (long double) 3.14159265358979323846264338327950288L)")
|
||||
"x = 3.14159265358979323846264338327950288L;"))
|
||||
(test-assert "grouped digits reach C ungrouped"
|
||||
(emits? (in-fn "(var x float 1_000.5f)") "x = 1000.5f;"))
|
||||
(test-assert "a minus is C's own"
|
||||
(emits? (in-fn "(var n (unsigned int) -1u)") "n = -1u;"))
|
||||
(test-assert "a number too wide for long long is unsigned, and says so"
|
||||
|
||||
@@ -61,6 +61,12 @@
|
||||
;; ...and only a number: a prefix with nothing after it is a name
|
||||
(reader-test '(0x 0xg) "0x 0xg")
|
||||
|
||||
;; `_' between two digits groups them, the way C23's ' does, which in
|
||||
;; Sex is quote. Anywhere else it is part of a name
|
||||
(reader-test '(1000000 65535 165 1000.5 -1000 100000.0 32768)
|
||||
"1_000_000 0xFF_FF 0b1010_0101 1_000.5 -1_000 1e0_5 #x80_00")
|
||||
(reader-test '(_1 1_ 1__0 0x_FF 0xF_p) "_1 1_ 1__0 0x_FF 0xF_p")
|
||||
|
||||
;; Scheme reads numbers C has no literal for, and they reached C as
|
||||
;; written: 1/2 is integer division there, and +inf.0 no number at all
|
||||
(test "a ratio is not a C number"
|
||||
|
||||
Reference in New Issue
Block a user