소스 검색

Improved error messages

tags/gm/2021-09-23T00Z/github.com--lark-parser-lark/0.5.1
Erez Shinan 7 년 전
부모
커밋
9ef3670ea2
1개의 변경된 파일4개의 추가작업 그리고 2개의 파일을 삭제
  1. +4
    -2
      lark/load_grammar.py

+ 4
- 2
lark/load_grammar.py 파일 보기

@@ -542,9 +542,11 @@ class GrammarLoader:
except UnexpectedInput as e:
raise GrammarError("Unexpected input %r at line %d column %d in %s" % (e.context, e.line, e.column, name))
except UnexpectedToken as e:
if '_COLON' in e.expected:
if e.expected == ['_COLON']:
raise GrammarError("Missing colon at line %s column %s" % (e.line, e.column))
elif 'literal' in e.expected:
elif e.expected == ['RULE']:
raise GrammarError("Missing alias at line %s column %s" % (e.line, e.column))
elif 'STRING' in e.expected:
raise GrammarError("Expecting a value at line %s column %s" % (e.line, e.column))
elif e.expected == ['_OR']:
raise GrammarError("Newline without starting a new option (Expecting '|') at line %s column %s" % (e.line, e.column))


불러오는 중...
취소
저장