diff --git a/baron/grammator.py b/baron/grammator.py index 0fdacd43..3da812f5 100644 --- a/baron/grammator.py +++ b/baron/grammator.py @@ -618,8 +618,8 @@ def testlist1(pack): @pg.production("atom : HEXA") @pg.production("atom : BINARY") @pg.production("atom : FLOAT") - @pg.production("atom : FLOAT_EXPONANT") - @pg.production("atom : FLOAT_EXPONANT_COMPLEX") + @pg.production("atom : FLOAT_EXPONENT") + @pg.production("atom : FLOAT_EXPONENT_COMPLEX") @pg.production("atom : COMPLEX") def int(pack): (int_,) = pack diff --git a/baron/render.py b/baron/render.py index 00b9ba65..d3831734 100644 --- a/baron/render.py +++ b/baron/render.py @@ -121,10 +121,10 @@ def child_by_key(node, key): "space": [("string", "value", True)], "binary": [("string", "value", True)], "complex": [("string", "value", True)], - "float_exponant": [("string", "value", True)], + "float_exponent": [("string", "value", True)], "left_parenthesis": [("string", "value", True)], "right_parenthesis": [("string", "value", True)], - "float_exponant_complex": [("string", "value", True)], + "float_exponent_complex": [("string", "value", True)], "break": [("string", "type", True)], "continue": [("string", "type", True)], diff --git a/baron/tokenizer.py b/baron/tokenizer.py index 20f28202..ccb33460 100644 --- a/baron/tokenizer.py +++ b/baron/tokenizer.py @@ -10,12 +10,12 @@ class UnknowItem(BaronError): TOKENS = ( (r'[a-zA-Z_]\w*', 'NAME'), (r'0', 'INT'), - (r'[-+]?\d+[eE][-+]?\d+[jJ]', 'FLOAT_EXPONANT_COMPLEX'), - (r'[-+]?\d+.\d?[eE][-+]?\d+[jJ]', 'FLOAT_EXPONANT_COMPLEX'), - (r'[-+]?\d?.\d+[eE][-+]?\d+[jJ]', 'FLOAT_EXPONANT_COMPLEX'), - (r'\d+[eE][-+]?\d*', 'FLOAT_EXPONANT'), - (r'\d+\.\d*[eE][-+]?\d*', 'FLOAT_EXPONANT'), - (r'\.\d+[eE][-+]?\d*', 'FLOAT_EXPONANT'), + (r'[-+]?\d+[eE][-+]?\d+[jJ]', 'FLOAT_EXPONENT_COMPLEX'), + (r'[-+]?\d+.\d?[eE][-+]?\d+[jJ]', 'FLOAT_EXPONENT_COMPLEX'), + (r'[-+]?\d?.\d+[eE][-+]?\d+[jJ]', 'FLOAT_EXPONENT_COMPLEX'), + (r'\d+[eE][-+]?\d*', 'FLOAT_EXPONENT'), + (r'\d+\.\d*[eE][-+]?\d*', 'FLOAT_EXPONENT'), + (r'\.\d+[eE][-+]?\d*', 'FLOAT_EXPONENT'), (r'\d*\.\d+[jJ]', 'COMPLEX'), (r'\d+\.[jJ]', 'COMPLEX'), (r'\d+[jJ]', 'COMPLEX'), diff --git a/tests/test_dumper.py b/tests/test_dumper.py index 6b3091ee..fc45fd11 100644 --- a/tests/test_dumper.py +++ b/tests/test_dumper.py @@ -452,7 +452,7 @@ def test_complex(): check_dumps("10j") -def test_float_exponant(): +def test_float_exponent(): check_dumps("1e9") diff --git a/tests/test_grouper.py b/tests/test_grouper.py index e42154e8..561a606d 100644 --- a/tests/test_grouper.py +++ b/tests/test_grouper.py @@ -148,7 +148,7 @@ def test_unicode_raw_string(): grouper_test("UR'pouet'", ["UR", "'pouet'"], ["UR'pouet'"]) -def test_exponant(): +def test_exponent(): grouper_test("1e+123", ['1e', '+', '123'], ['1e+123']) grouper_test("1e-123", ['1e', '-', '123'], ['1e-123']) grouper_test("1.1e+123", ['1', '.', '1e', '+', '123'], ['1.1e+123']) @@ -194,7 +194,7 @@ def test_complex(): grouper_test("1e1j", ['1e1j'], ['1e1j']) -def test_float_exponant(): +def test_float_exponent(): grouper_test("1E1", ['1E1'], ['1E1']) grouper_test("1E-2", ['1E', '-', '2'], ['1E-2']) grouper_test("1E+2", ['1E', '+', '2'], ['1E+2']) diff --git a/tests/test_tokenizer.py b/tests/test_tokenizer.py index c37edc83..ed27d084 100644 --- a/tests/test_tokenizer.py +++ b/tests/test_tokenizer.py @@ -59,25 +59,25 @@ def test_octa(): match('0O1235L', 'OCTA') -def test_float_exponant(): - match('1234e10', 'FLOAT_EXPONANT') - match('1234E10', 'FLOAT_EXPONANT') - match('1234e+10', 'FLOAT_EXPONANT') - match('1234e-10', 'FLOAT_EXPONANT') - match('1234E+10', 'FLOAT_EXPONANT') - match('1234E-10', 'FLOAT_EXPONANT') - match('1234.5678e10', 'FLOAT_EXPONANT') - match('1234.5678E10', 'FLOAT_EXPONANT') - match('1234.5678e+10', 'FLOAT_EXPONANT') - match('1234.5678e-10', 'FLOAT_EXPONANT') - match('1234.5678E+10', 'FLOAT_EXPONANT') - match('1234.5678E-10', 'FLOAT_EXPONANT') - match('.5678e10', 'FLOAT_EXPONANT') - match('.5678E10', 'FLOAT_EXPONANT') - match('.5678e+10', 'FLOAT_EXPONANT') - match('.5678e-10', 'FLOAT_EXPONANT') - match('.5678E+10', 'FLOAT_EXPONANT') - match('.5678E-10', 'FLOAT_EXPONANT') +def test_float_exponent(): + match('1234e10', 'FLOAT_EXPONENT') + match('1234E10', 'FLOAT_EXPONENT') + match('1234e+10', 'FLOAT_EXPONENT') + match('1234e-10', 'FLOAT_EXPONENT') + match('1234E+10', 'FLOAT_EXPONENT') + match('1234E-10', 'FLOAT_EXPONENT') + match('1234.5678e10', 'FLOAT_EXPONENT') + match('1234.5678E10', 'FLOAT_EXPONENT') + match('1234.5678e+10', 'FLOAT_EXPONENT') + match('1234.5678e-10', 'FLOAT_EXPONENT') + match('1234.5678E+10', 'FLOAT_EXPONENT') + match('1234.5678E-10', 'FLOAT_EXPONENT') + match('.5678e10', 'FLOAT_EXPONENT') + match('.5678E10', 'FLOAT_EXPONENT') + match('.5678e+10', 'FLOAT_EXPONENT') + match('.5678e-10', 'FLOAT_EXPONENT') + match('.5678E+10', 'FLOAT_EXPONENT') + match('.5678E-10', 'FLOAT_EXPONENT') def test_left_parenthesis(): @@ -366,17 +366,17 @@ def test_zero(): match("0", "INT") -def test_float_exponant_advanced(): - match("1E1", "FLOAT_EXPONANT") - match("1E-2", "FLOAT_EXPONANT") - match("1E+2", "FLOAT_EXPONANT") - match("1.E1", "FLOAT_EXPONANT") - match(".1E1", "FLOAT_EXPONANT") - match("1e1", "FLOAT_EXPONANT") - match("1e-2", "FLOAT_EXPONANT") - match("1e+2", "FLOAT_EXPONANT") - match("1.e1", "FLOAT_EXPONANT") - match(".1e1", "FLOAT_EXPONANT") +def test_float_exponent_advanced(): + match("1E1", "FLOAT_EXPONENT") + match("1E-2", "FLOAT_EXPONENT") + match("1E+2", "FLOAT_EXPONENT") + match("1.E1", "FLOAT_EXPONENT") + match(".1E1", "FLOAT_EXPONENT") + match("1e1", "FLOAT_EXPONENT") + match("1e-2", "FLOAT_EXPONENT") + match("1e+2", "FLOAT_EXPONENT") + match("1.e1", "FLOAT_EXPONENT") + match(".1e1", "FLOAT_EXPONENT") def test_complex(): @@ -396,90 +396,90 @@ def test_float_advanced(): match("1.1", "FLOAT") -def test_exponant_complex(): - match("1e1j", "FLOAT_EXPONANT_COMPLEX") - match("1.e1j", "FLOAT_EXPONANT_COMPLEX") - match("1.1e1j", "FLOAT_EXPONANT_COMPLEX") - match(".1e1j", "FLOAT_EXPONANT_COMPLEX") - match("-1.e1j", "FLOAT_EXPONANT_COMPLEX") - match("-1.1e1j", "FLOAT_EXPONANT_COMPLEX") - match("-.1e1j", "FLOAT_EXPONANT_COMPLEX") - match("1e-1j", "FLOAT_EXPONANT_COMPLEX") - match("1.e-1j", "FLOAT_EXPONANT_COMPLEX") - match("1.1e-1j", "FLOAT_EXPONANT_COMPLEX") - match(".1e-1j", "FLOAT_EXPONANT_COMPLEX") - match("-1.e-1j", "FLOAT_EXPONANT_COMPLEX") - match("-1.1e-1j", "FLOAT_EXPONANT_COMPLEX") - match("-.1e-1j", "FLOAT_EXPONANT_COMPLEX") - match("1e+1j", "FLOAT_EXPONANT_COMPLEX") - match("1.e+1j", "FLOAT_EXPONANT_COMPLEX") - match("1.1e+1j", "FLOAT_EXPONANT_COMPLEX") - match(".1e+1j", "FLOAT_EXPONANT_COMPLEX") - match("-1.e+1j", "FLOAT_EXPONANT_COMPLEX") - match("-1.1e+1j", "FLOAT_EXPONANT_COMPLEX") - match("-.1e+1j", "FLOAT_EXPONANT_COMPLEX") - match("1e1J", "FLOAT_EXPONANT_COMPLEX") - match("1.e1J", "FLOAT_EXPONANT_COMPLEX") - match("1.1e1J", "FLOAT_EXPONANT_COMPLEX") - match(".1e1J", "FLOAT_EXPONANT_COMPLEX") - match("-1.e1J", "FLOAT_EXPONANT_COMPLEX") - match("-1.1e1J", "FLOAT_EXPONANT_COMPLEX") - match("-.1e1J", "FLOAT_EXPONANT_COMPLEX") - match("1e-1J", "FLOAT_EXPONANT_COMPLEX") - match("1.e-1J", "FLOAT_EXPONANT_COMPLEX") - match("1.1e-1J", "FLOAT_EXPONANT_COMPLEX") - match(".1e-1J", "FLOAT_EXPONANT_COMPLEX") - match("-1.e-1J", "FLOAT_EXPONANT_COMPLEX") - match("-1.1e-1J", "FLOAT_EXPONANT_COMPLEX") - match("-.1e-1J", "FLOAT_EXPONANT_COMPLEX") - match("1e+1J", "FLOAT_EXPONANT_COMPLEX") - match("1.e+1J", "FLOAT_EXPONANT_COMPLEX") - match("1.1e+1J", "FLOAT_EXPONANT_COMPLEX") - match(".1e+1J", "FLOAT_EXPONANT_COMPLEX") - match("-1.e+1J", "FLOAT_EXPONANT_COMPLEX") - match("-1.1e+1J", "FLOAT_EXPONANT_COMPLEX") - match("-.1e+1J", "FLOAT_EXPONANT_COMPLEX") - match("1e1J", "FLOAT_EXPONANT_COMPLEX") - match("1.e1J", "FLOAT_EXPONANT_COMPLEX") - match("1.1e1J", "FLOAT_EXPONANT_COMPLEX") - match(".1e1J", "FLOAT_EXPONANT_COMPLEX") - match("-1.e1J", "FLOAT_EXPONANT_COMPLEX") - match("-1.1e1J", "FLOAT_EXPONANT_COMPLEX") - match("-.1e1J", "FLOAT_EXPONANT_COMPLEX") - match("1e-1J", "FLOAT_EXPONANT_COMPLEX") - match("1.e-1J", "FLOAT_EXPONANT_COMPLEX") - match("1.1e-1J", "FLOAT_EXPONANT_COMPLEX") - match(".1e-1J", "FLOAT_EXPONANT_COMPLEX") - match("-1.e-1J", "FLOAT_EXPONANT_COMPLEX") - match("-1.1e-1J", "FLOAT_EXPONANT_COMPLEX") - match("-.1e-1J", "FLOAT_EXPONANT_COMPLEX") - match("1e+1J", "FLOAT_EXPONANT_COMPLEX") - match("1.e+1J", "FLOAT_EXPONANT_COMPLEX") - match("1.1e+1J", "FLOAT_EXPONANT_COMPLEX") - match(".1e+1J", "FLOAT_EXPONANT_COMPLEX") - match("-1.e+1J", "FLOAT_EXPONANT_COMPLEX") - match("-1.1e+1J", "FLOAT_EXPONANT_COMPLEX") - match("-.1e+1J", "FLOAT_EXPONANT_COMPLEX") - match("1E1J", "FLOAT_EXPONANT_COMPLEX") - match("1.E1J", "FLOAT_EXPONANT_COMPLEX") - match("1.1E1J", "FLOAT_EXPONANT_COMPLEX") - match(".1E1J", "FLOAT_EXPONANT_COMPLEX") - match("-1.E1J", "FLOAT_EXPONANT_COMPLEX") - match("-1.1E1J", "FLOAT_EXPONANT_COMPLEX") - match("-.1E1J", "FLOAT_EXPONANT_COMPLEX") - match("1E-1J", "FLOAT_EXPONANT_COMPLEX") - match("1.E-1J", "FLOAT_EXPONANT_COMPLEX") - match("1.1E-1J", "FLOAT_EXPONANT_COMPLEX") - match(".1E-1J", "FLOAT_EXPONANT_COMPLEX") - match("-1.E-1J", "FLOAT_EXPONANT_COMPLEX") - match("-1.1E-1J", "FLOAT_EXPONANT_COMPLEX") - match("-.1E-1J", "FLOAT_EXPONANT_COMPLEX") - match("1E+1J", "FLOAT_EXPONANT_COMPLEX") - match("1.E+1J", "FLOAT_EXPONANT_COMPLEX") - match("1.1E+1J", "FLOAT_EXPONANT_COMPLEX") - match(".1E+1J", "FLOAT_EXPONANT_COMPLEX") - match("-1.E+1J", "FLOAT_EXPONANT_COMPLEX") - match("-1.1E+1J", "FLOAT_EXPONANT_COMPLEX") - match("-.1E+1J", "FLOAT_EXPONANT_COMPLEX") +def test_exponent_complex(): + match("1e1j", "FLOAT_EXPONENT_COMPLEX") + match("1.e1j", "FLOAT_EXPONENT_COMPLEX") + match("1.1e1j", "FLOAT_EXPONENT_COMPLEX") + match(".1e1j", "FLOAT_EXPONENT_COMPLEX") + match("-1.e1j", "FLOAT_EXPONENT_COMPLEX") + match("-1.1e1j", "FLOAT_EXPONENT_COMPLEX") + match("-.1e1j", "FLOAT_EXPONENT_COMPLEX") + match("1e-1j", "FLOAT_EXPONENT_COMPLEX") + match("1.e-1j", "FLOAT_EXPONENT_COMPLEX") + match("1.1e-1j", "FLOAT_EXPONENT_COMPLEX") + match(".1e-1j", "FLOAT_EXPONENT_COMPLEX") + match("-1.e-1j", "FLOAT_EXPONENT_COMPLEX") + match("-1.1e-1j", "FLOAT_EXPONENT_COMPLEX") + match("-.1e-1j", "FLOAT_EXPONENT_COMPLEX") + match("1e+1j", "FLOAT_EXPONENT_COMPLEX") + match("1.e+1j", "FLOAT_EXPONENT_COMPLEX") + match("1.1e+1j", "FLOAT_EXPONENT_COMPLEX") + match(".1e+1j", "FLOAT_EXPONENT_COMPLEX") + match("-1.e+1j", "FLOAT_EXPONENT_COMPLEX") + match("-1.1e+1j", "FLOAT_EXPONENT_COMPLEX") + match("-.1e+1j", "FLOAT_EXPONENT_COMPLEX") + match("1e1J", "FLOAT_EXPONENT_COMPLEX") + match("1.e1J", "FLOAT_EXPONENT_COMPLEX") + match("1.1e1J", "FLOAT_EXPONENT_COMPLEX") + match(".1e1J", "FLOAT_EXPONENT_COMPLEX") + match("-1.e1J", "FLOAT_EXPONENT_COMPLEX") + match("-1.1e1J", "FLOAT_EXPONENT_COMPLEX") + match("-.1e1J", "FLOAT_EXPONENT_COMPLEX") + match("1e-1J", "FLOAT_EXPONENT_COMPLEX") + match("1.e-1J", "FLOAT_EXPONENT_COMPLEX") + match("1.1e-1J", "FLOAT_EXPONENT_COMPLEX") + match(".1e-1J", "FLOAT_EXPONENT_COMPLEX") + match("-1.e-1J", "FLOAT_EXPONENT_COMPLEX") + match("-1.1e-1J", "FLOAT_EXPONENT_COMPLEX") + match("-.1e-1J", "FLOAT_EXPONENT_COMPLEX") + match("1e+1J", "FLOAT_EXPONENT_COMPLEX") + match("1.e+1J", "FLOAT_EXPONENT_COMPLEX") + match("1.1e+1J", "FLOAT_EXPONENT_COMPLEX") + match(".1e+1J", "FLOAT_EXPONENT_COMPLEX") + match("-1.e+1J", "FLOAT_EXPONENT_COMPLEX") + match("-1.1e+1J", "FLOAT_EXPONENT_COMPLEX") + match("-.1e+1J", "FLOAT_EXPONENT_COMPLEX") + match("1e1J", "FLOAT_EXPONENT_COMPLEX") + match("1.e1J", "FLOAT_EXPONENT_COMPLEX") + match("1.1e1J", "FLOAT_EXPONENT_COMPLEX") + match(".1e1J", "FLOAT_EXPONENT_COMPLEX") + match("-1.e1J", "FLOAT_EXPONENT_COMPLEX") + match("-1.1e1J", "FLOAT_EXPONENT_COMPLEX") + match("-.1e1J", "FLOAT_EXPONENT_COMPLEX") + match("1e-1J", "FLOAT_EXPONENT_COMPLEX") + match("1.e-1J", "FLOAT_EXPONENT_COMPLEX") + match("1.1e-1J", "FLOAT_EXPONENT_COMPLEX") + match(".1e-1J", "FLOAT_EXPONENT_COMPLEX") + match("-1.e-1J", "FLOAT_EXPONENT_COMPLEX") + match("-1.1e-1J", "FLOAT_EXPONENT_COMPLEX") + match("-.1e-1J", "FLOAT_EXPONENT_COMPLEX") + match("1e+1J", "FLOAT_EXPONENT_COMPLEX") + match("1.e+1J", "FLOAT_EXPONENT_COMPLEX") + match("1.1e+1J", "FLOAT_EXPONENT_COMPLEX") + match(".1e+1J", "FLOAT_EXPONENT_COMPLEX") + match("-1.e+1J", "FLOAT_EXPONENT_COMPLEX") + match("-1.1e+1J", "FLOAT_EXPONENT_COMPLEX") + match("-.1e+1J", "FLOAT_EXPONENT_COMPLEX") + match("1E1J", "FLOAT_EXPONENT_COMPLEX") + match("1.E1J", "FLOAT_EXPONENT_COMPLEX") + match("1.1E1J", "FLOAT_EXPONENT_COMPLEX") + match(".1E1J", "FLOAT_EXPONENT_COMPLEX") + match("-1.E1J", "FLOAT_EXPONENT_COMPLEX") + match("-1.1E1J", "FLOAT_EXPONENT_COMPLEX") + match("-.1E1J", "FLOAT_EXPONENT_COMPLEX") + match("1E-1J", "FLOAT_EXPONENT_COMPLEX") + match("1.E-1J", "FLOAT_EXPONENT_COMPLEX") + match("1.1E-1J", "FLOAT_EXPONENT_COMPLEX") + match(".1E-1J", "FLOAT_EXPONENT_COMPLEX") + match("-1.E-1J", "FLOAT_EXPONENT_COMPLEX") + match("-1.1E-1J", "FLOAT_EXPONENT_COMPLEX") + match("-.1E-1J", "FLOAT_EXPONENT_COMPLEX") + match("1E+1J", "FLOAT_EXPONENT_COMPLEX") + match("1.E+1J", "FLOAT_EXPONENT_COMPLEX") + match("1.1E+1J", "FLOAT_EXPONENT_COMPLEX") + match(".1E+1J", "FLOAT_EXPONENT_COMPLEX") + match("-1.E+1J", "FLOAT_EXPONENT_COMPLEX") + match("-1.1E+1J", "FLOAT_EXPONENT_COMPLEX") + match("-.1E+1J", "FLOAT_EXPONENT_COMPLEX") # TODO 1.1e1j