With the latest corrections:
--- Numeric Literals ---
decimal notation:
123 # int 123
0123 # int 123
123.0 # num 123.0
-123 # int -123
0_1.2_3 # ok
_01.23 # wrong
01.23_ # wrong
01_._23 # wrong
1__2 # wrong
exponential notation:
-1.23e4 # num
-1.23E4 # num (identical)
1.23_e_4 # wrong
bin/oct/hex notation:
0b0110 # bin
0c0123 # oct
0x00ff # hex
0x00fF # hex, == 0x00ff
0x00FF # hex, == 0x00ff
-0xff # ok
-0x00ff # ok
0xf_f # ok
0x_ff # wrong
0B0110 # bin?
0C0123 # oct?
0X00FF # hex?
explicit radix:
(radix 2-36)
20#1gj # base 20
20#1GJ # base 20 (identical)
20#1:G:J # base 20 (identical)
20#1_G_J # base 20 (identical)
20#1:16:19 # base 20 (identical)
20#1_16_19 # NOT identical, == 20:11619
20#1:1_6:19 # WRONG: colon form may not have underlines
20#1_G.J # w/ radix point (e.g. float)
20#1:16.19 # (identical)
-20#1GJ # base 20 (negative)
-20#1:16:19 # base 20 (negative)
(radix 37-RADIX_MAX)
256#0:253:254:255 # base 256
256#0_253_254_255 # base 256, NOT identical!
Other issues w/ literals:
- radix <= 36, alpha digits may be upper or lowercase
- radix > 36, only colon form is allowed, not alpha digits
- underlines may appear ONLY between digits
- colon form may therefore not have underlines
- radix < 2 throws error
- negative sign goes before radix, e.g. -20:1GJ.
- need to specify RADIX_MAX
- explicit radix form may have radix point, '.',
but cannot use exponential notation ('e')
- can't have runtime radix, e.g. 2**8#10, because # binds tighter.
- can't say (2**8)#10, because not a literal.
- need to verify that 0123 now is decimal, not octal.
- need to verify that 0b1, 0c1, 0x1 are still allowed.
- need to verify 0B1, 0C1, 0X1 allowed for 0b1, 0c1, 0x1.
MikeL