Commit 715faa24 authored by eckhart's avatar eckhart

- slight refactoring

parent c2f0a268
......@@ -304,10 +304,10 @@ class Parser:
i = 1
nd = Node(ZOMBIE_TAG, rest[:i])
rest = rest[i:]
assert error.node.children
assert error.node.children or (not error.node.result)
if error.first_throw:
node = error.node
node.result += (nd,)
node.result = node.children + (nd,)
else:
# TODO: ggf. Fehlermeldung, die sagt, wo es weitergeht anfügen
# dürfte allerdings erst an den nächsten(!) Knoten angehängt werden (wie?)
......@@ -1245,8 +1245,10 @@ class MetaParser(Parser):
assert node is None or isinstance(node, Node)
if node and node._result:
return Node(self.tag_name, node) if self.pname else node
if self.pname:
return Node(self.tag_name, ())
if self.pname: # or (node and node.errors):
nd = Node(self.tag_name, ())
# nd.errors = node.errors
return nd
else:
# avoid creation of a node object for empty nodes
return EMPTY_NODE
......
......@@ -113,11 +113,12 @@ class TestInfiLoopsAndRecursion:
log_parsing_history(parser, "test_LeftRecursion_indirect")
def test_inifinite_loops(self):
minilang = """not_forever = { // } \n"""
snippet = " "
minilang = """not_forever = /A/ { // } \n"""
snippet = "A "
parser = grammar_provider(minilang)()
syntax_tree = parser(snippet)
assert syntax_tree.error_flag
assert syntax_tree.collect_errors()[0].pos == 1
class TestFlowControl:
......
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