Browse Source

Small fix

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

+ 2
- 2
lark/load_grammar.py View File

@@ -330,7 +330,7 @@ class PrepareAnonTerminals(Transformer_InPlace):
try:
term_name = _TERMINAL_NAMES[value]
except KeyError:
if is_id_continue(value) and is_id_start(value[0]) and value.upper() not in self.term_set:
if value and is_id_continue(value) and is_id_start(value[0]) and value.upper() not in self.term_set:
term_name = value.upper()

if term_name in self.term_set:
@@ -449,7 +449,7 @@ def _literal_to_pattern(literal):
s = eval_escaping(x)

if s == "":
raise GrammarError("Can't have empty terminals (offending literal: %s)" % literal.value)
raise GrammarError("Empty terminals are not allowed (%s)" % literal)

if literal.type == 'STRING':
s = s.replace('\\\\', '\\')


Loading…
Cancel
Save