mirror of
https://github.com/davidhalter/parso.git
synced 2025-12-06 12:54:29 +08:00
parse long number notation (#72)
* parse long number notation * parse long number notation
This commit is contained in:
@@ -151,6 +151,8 @@ def _create_token_collection(version_info):
|
||||
Octnumber = '0[oO]?[0-7]+'
|
||||
Decnumber = r'(?:0+|[1-9][0-9]*)'
|
||||
Intnumber = group(Hexnumber, Binnumber, Octnumber, Decnumber)
|
||||
if version_info[0] < 3:
|
||||
Intnumber += '[lL]?'
|
||||
Exponent = r'[eE][-+]?[0-9]+'
|
||||
Pointfloat = group(r'[0-9]+\.[0-9]*', r'\.[0-9]+') + maybe(Exponent)
|
||||
Expfloat = r'[0-9]+' + Exponent
|
||||
|
||||
@@ -190,6 +190,19 @@ def test_old_octal_notation(works_in_py2):
|
||||
works_in_py2.parse("07")
|
||||
|
||||
|
||||
def test_long_notation(works_in_py2):
|
||||
works_in_py2.parse("0xFl")
|
||||
works_in_py2.parse("0xFL")
|
||||
works_in_py2.parse("0b1l")
|
||||
works_in_py2.parse("0B1L")
|
||||
works_in_py2.parse("0o7l")
|
||||
works_in_py2.parse("0O7L")
|
||||
works_in_py2.parse("0l")
|
||||
works_in_py2.parse("0L")
|
||||
works_in_py2.parse("10l")
|
||||
works_in_py2.parse("10L")
|
||||
|
||||
|
||||
def test_new_binary_notation(each_version):
|
||||
_parse("""0b101010""", each_version)
|
||||
_invalid_syntax("""0b0101021""", each_version)
|
||||
|
||||
Reference in New Issue
Block a user