소스 검색

Small bugfixes in exceptions

tags/gm/2021-09-23T00Z/github.com--lark-parser-lark/0.11.2
Erez Sh 3 년 전
부모
커밋
7b6a730abc
2개의 변경된 파일6개의 추가작업 그리고 2개의 파일을 삭제
  1. +2
    -1
      lark/exceptions.py
  2. +4
    -1
      lark/lark.py

+ 2
- 1
lark/exceptions.py 파일 보기

@@ -120,7 +120,8 @@ class UnexpectedInput(LarkError):

def _format_expected(self, expected):
if self._terminals_by_name:
expected = [self._terminals_by_name[t_name].user_repr() for t_name in expected]
d = self._terminals_by_name
expected = [d[t_name].user_repr() if t_name in d else t_name for t_name in expected]
return "Expected one of: \n\t* %s\n" % '\n\t* '.join(expected)




+ 4
- 1
lark/lark.py 파일 보기

@@ -265,7 +265,10 @@ class Lark(Serialize):
for name in (set(options) - _LOAD_ALLOWED_OPTIONS):
del options[name]
with FS.open(cache_fn, 'rb') as f:
self._load(f, **options)
try:
self._load(f, **options)
except Exception:
raise RuntimeError("Failed to load Lark from cache: %r. Try to delete the file and run again." % cache_fn)
return

if self.options.lexer == 'auto':


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