Parcourir la 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 il y a 3 ans
Parent
révision
e56efad1fe
1 fichiers modifiés avec 4 ajouts et 1 suppressions
  1. +4
    -1
      lark/load_grammar.py

+ 4
- 1
lark/load_grammar.py Voir le fichier

@@ -743,7 +743,10 @@ def resolve_term_references(term_dict):
if item.type == 'RULE':
raise GrammarError("Rules aren't allowed inside terminals (%s in %s)" % (item, name))
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
exp.children[0] = term_value
changed = True


Chargement…
Annuler
Enregistrer