Browse Source

Raise correct error when terminal is used within another terminal, by not defined

tags/gm/2021-09-23T00Z/github.com--lark-parser-lark/0.11.3
Erez Sh 3 years ago
parent
commit
e56efad1fe
1 changed files with 4 additions and 1 deletions
  1. +4
    -1
      lark/load_grammar.py

+ 4
- 1
lark/load_grammar.py View File

@@ -743,7 +743,10 @@ def resolve_term_references(term_dict):
if item.type == 'RULE': if item.type == 'RULE':
raise GrammarError("Rules aren't allowed inside terminals (%s in %s)" % (item, name)) raise GrammarError("Rules aren't allowed inside terminals (%s in %s)" % (item, name))
if item.type == 'TERMINAL': if item.type == 'TERMINAL':
term_value = term_dict[item]
try:
term_value = term_dict[item]
except KeyError:
raise GrammarError("Terminal used but not defined: %s" % item)
assert term_value is not None assert term_value is not None
exp.children[0] = term_value exp.children[0] = term_value
changed = True changed = True


Loading…
Cancel
Save