Commit 6c20ccf3 authored by Eckhart Arnold's avatar Eckhart Arnold

better tests for left recursion

parent 5bf393d0
......@@ -198,7 +198,7 @@ def add_parser_guard(parser_func):
# because caching would interfere with changes of variable state
if not (grammar.rollback__ and grammar.rollback__[-1][0] <= location):
parser.visited[location] = (node, rest)
grammar.last_node__ = node # store last node for Lookbehind operator
grammar.last_node__ = node # store last node for Lookbehind parser
elif location in parser.visited:
# if parser did non match but a saved result exits, assume
# left recursion and use the saved result
......@@ -1293,7 +1293,7 @@ def compile_source(source: str,
transformer (function): A transformation function that takes
the root-node of the concrete syntax tree as an argument and
transforms it (in place) into an abstract syntax tree.
compiler (function): A compiler function or compiler class
compiler (function): A compiler function or compiler class
instance
Returns (tuple):
......
......@@ -79,11 +79,11 @@ ARITHMETIC2_EBNF = """
class TestInfiLoopsAndRecursion:
def test_direct_left_recursion(self):
minilang = ARITHMETIC_EBNF
snippet = "5 + 3 * 4"
snippet = "9 + 8 + 7 + 6 + 5 + 3 * 4"
parser = parser_factory(minilang)()
assert parser
syntax_tree = parser(snippet)
assert not syntax_tree.collect_errors()
assert not syntax_tree.error_flag, str(syntax_tree.collect_errors())
assert snippet == str(syntax_tree)
if is_logging():
syntax_tree.log("test_LeftRecursion_direct.cst")
......@@ -91,7 +91,7 @@ class TestInfiLoopsAndRecursion:
def test_indirect_left_recursion(self):
minilang = ARITHMETIC2_EBNF
snippet = "5 + 3 * 4"
snippet = "9 + 8 + 7 + 6 + 5 + 3 * 4"
parser = parser_factory(minilang)()
assert parser
syntax_tree = parser(snippet)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment