@@ -32,8 +32,8 @@ nearley_grammar = r""" | |||||
NAME: /[a-zA-Z_$]\w*/ | NAME: /[a-zA-Z_$]\w*/ | ||||
COMMENT: /#[^\n]*/ | COMMENT: /#[^\n]*/ | ||||
REGEXP: /\[.*?\]/ | REGEXP: /\[.*?\]/ | ||||
STRING: /".*?"/ | |||||
%import common.ESCAPED_STRING -> STRING | |||||
%import common.WS | %import common.WS | ||||
%ignore WS | %ignore WS | ||||
%ignore COMMENT | %ignore COMMENT | ||||
@@ -75,6 +75,14 @@ class TestNearley(unittest.TestCase): | |||||
parse(u'±a') | parse(u'±a') | ||||
def test_backslash(self): | |||||
grammar = r'main -> "\""' | |||||
code = create_code_for_nearley_grammar(grammar, 'main', BUILTIN_PATH, './') | |||||
d = {} | |||||
exec (code, d) | |||||
parse = d['parse'] | |||||
parse(u'"') | |||||
def test_utf8_2(self): | def test_utf8_2(self): | ||||
fn = os.path.join(TEST_PATH, 'grammars/unicode.ne') | fn = os.path.join(TEST_PATH, 'grammars/unicode.ne') | ||||
nearley_tool_main(fn, 'x', NEARLEY_PATH) | nearley_tool_main(fn, 'x', NEARLEY_PATH) | ||||
@@ -28,7 +28,7 @@ class TestReconstructor(TestCase): | |||||
item: NL | item: NL | ||||
| rule | | rule | ||||
rule: WORD ":" NUMBER | rule: WORD ":" NUMBER | ||||
NL: /(\\r?\\n)+\s*/ | |||||
NL: /(\\r?\\n)+\\s*/ | |||||
""" + common | """ + common | ||||
code = """ | code = """ | ||||
@@ -42,7 +42,7 @@ class TestReconstructor(TestCase): | |||||
g = """ | g = """ | ||||
start: (rule | NL)* | start: (rule | NL)* | ||||
rule: WORD ":" NUMBER | rule: WORD ":" NUMBER | ||||
NL: /(\\r?\\n)+\s*/ | |||||
NL: /(\\r?\\n)+\\s*/ | |||||
""" + common | """ + common | ||||
code = """ | code = """ | ||||
@@ -59,7 +59,7 @@ class TestReconstructor(TestCase): | |||||
| rule | | rule | ||||
| "hello" -> hi | | "hello" -> hi | ||||
rule: WORD ":" NUMBER | rule: WORD ":" NUMBER | ||||
NL: /(\\r?\\n)+\s*/ | |||||
NL: /(\\r?\\n)+\\s*/ | |||||
""" + common | """ + common | ||||
code = """ | code = """ | ||||