
Fixes #452 I ended up making a couple of other normalizations to numeric literals too (lowercase everything, don't allow leading or trailing . in floats, remove redundant + sign in exponent). I don't care too much about those, so I'm happy to change the behavior there. For reference, here is Python's grammar for numeric literals: https://docs.python.org/3/reference/lexical_analysis.html#numeric-literals
37 lines
511 B
Python
37 lines
511 B
Python
#!/usr/bin/env python3.6
|
|
|
|
x = 123456789
|
|
x = 123456
|
|
x = .1
|
|
x = 1.
|
|
x = 1E+1
|
|
x = 1E-1
|
|
x = 123456789.123456789
|
|
x = 123456789.123456789E123456789
|
|
x = 123456789E123456789
|
|
x = 123456789J
|
|
x = 123456789.123456789J
|
|
x = 0XB1ACC
|
|
x = 0B1011
|
|
x = 0O777
|
|
|
|
# output
|
|
|
|
|
|
#!/usr/bin/env python3.6
|
|
|
|
x = 123_456_789
|
|
x = 123456
|
|
x = 0.1
|
|
x = 1.0
|
|
x = 1e1
|
|
x = 1e-1
|
|
x = 123_456_789.123_456_789
|
|
x = 123_456_789.123_456_789e123_456_789
|
|
x = 123_456_789e123_456_789
|
|
x = 123_456_789j
|
|
x = 123_456_789.123_456_789j
|
|
x = 0xb1acc
|
|
x = 0b1011
|
|
x = 0o777
|