ソースを参照

Small fix

tags/gm/2021-09-23T00Z/github.com--lark-parser-lark/0.12.0
Erez Sh 3年前
コミット
44a20c850e
1個のファイルの変更2行の追加2行の削除
  1. +2
    -2
      lark/load_grammar.py

+ 2
- 2
lark/load_grammar.py ファイルの表示

@@ -330,7 +330,7 @@ class PrepareAnonTerminals(Transformer_InPlace):
try: try:
term_name = _TERMINAL_NAMES[value] term_name = _TERMINAL_NAMES[value]
except KeyError: 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() term_name = value.upper()


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


if s == "": 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': if literal.type == 'STRING':
s = s.replace('\\\\', '\\') s = s.replace('\\\\', '\\')


読み込み中…
キャンセル
保存