|
|
@@ -656,16 +656,18 @@ def resolve_term_references(term_defs): |
|
|
|
raise GrammarError("Rules aren't allowed inside terminals (%s in %s)" % (item, name)) |
|
|
|
if item.type == 'TERMINAL': |
|
|
|
term_value = term_dict[item] |
|
|
|
assert term_value is not None |
|
|
|
exp.children[0] = term_value |
|
|
|
changed = True |
|
|
|
if not changed: |
|
|
|
break |
|
|
|
|
|
|
|
for name, term in term_dict.items(): |
|
|
|
for child in term.children: |
|
|
|
ids = [id(x) for x in child.iter_subtrees()] |
|
|
|
if id(term) in ids: |
|
|
|
raise GrammarError("Recursion in terminal '%s' (recursion is only allowed in rules, not terminals)" % name) |
|
|
|
if term: # Not just declared |
|
|
|
for child in term.children: |
|
|
|
ids = [id(x) for x in child.iter_subtrees()] |
|
|
|
if id(term) in ids: |
|
|
|
raise GrammarError("Recursion in terminal '%s' (recursion is only allowed in rules, not terminals)" % name) |
|
|
|
|
|
|
|
|
|
|
|
def options_from_rule(name, *x): |
|
|
|