diff --git a/parso/python/tokenize.py b/parso/python/tokenize.py index 11b9a85..10834b3 100644 --- a/parso/python/tokenize.py +++ b/parso/python/tokenize.py @@ -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 diff --git a/test/test_pgen2.py b/test/test_pgen2.py index fe22d5b..c83dff7 100644 --- a/test/test_pgen2.py +++ b/test/test_pgen2.py @@ -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)