Просмотр исходного кода

Fix for cache

tags/gm/2021-09-23T00Z/github.com--lark-parser-lark/0.11.0
MegaIng1 4 лет назад
Родитель
Сommit
acd04442bc
1 измененных файлов: 5 добавлений и 2 удалений
  1. +5
    -2
      lark/lark.py

+ 5
- 2
lark/lark.py Просмотреть файл

@@ -236,7 +236,7 @@ class Lark(Serialize):
if FS.exists(cache_fn):
logger.debug('Loading grammar from cache: %s', cache_fn)
with FS.open(cache_fn, 'rb') as f:
self._load(f, self.options.transformer, self.options.postlex)
self._load(f, self.options)
return

if self.options.lexer == 'auto':
@@ -352,7 +352,7 @@ class Lark(Serialize):
inst = cls.__new__(cls)
return inst._load(f)

def _load(self, f, **kwargs):
def _load(self, f, temp_options=None, **kwargs):
if isinstance(f, dict):
d = f
else:
@@ -367,6 +367,9 @@ class Lark(Serialize):
raise ValueError("Some options are not allowed when loading a Parser: {}"
.format(_LOAD_BLOCKED_OPTIONS.intersection(kwargs.keys())))
options.update(kwargs)
if temp_options is not None:
for o in _LOAD_ALLOWED_OPTIONS:
options[o] = temp_options.options[o]
self.options = LarkOptions.deserialize(options, memo)
re_module = regex if self.options.regex else re
self.rules = [Rule.deserialize(r, memo) for r in data['rules']]


Загрузка…
Отмена
Сохранить