Ver a proveniência

Tiny fixes

tags/gm/2021-09-23T00Z/github.com--lark-parser-lark/0.11.0
Erez Sh há 4 anos
ascendente
cometimento
f2a6feddf1
2 ficheiros alterados com 6 adições e 5 eliminações
  1. +5
    -4
      lark/lark.py
  2. +1
    -1
      lark/parser_frontends.py

+ 5
- 4
lark/lark.py Ver ficheiro

@@ -163,8 +163,8 @@ class LarkOptions(Serialize):
return cls(data)


_LOAD_ALLOWED_OPTIONS = {'postlex', 'transformer', 'use_bytes', 'debug', 'g_regex_flags', 'regex', 'propagate_positions', 'keep_all_tokens',
'tree_class'}
_LOAD_ALLOWED_OPTIONS = {'postlex', 'transformer', 'use_bytes', 'debug', 'g_regex_flags',
'regex', 'propagate_positions', 'keep_all_tokens', 'tree_class'}


class Lark(Serialize):
@@ -234,8 +234,9 @@ class Lark(Serialize):

if FS.exists(cache_fn):
logger.debug('Loading grammar from cache: %s', cache_fn)
for name in (set(LarkOptions._defaults) - _LOAD_ALLOWED_OPTIONS):
options.pop(name, None)
# Remove options that aren't relevant for loading from cache
for name in (set(options) - _LOAD_ALLOWED_OPTIONS):
del options[name]
with FS.open(cache_fn, 'rb') as f:
self._load(f, **options)
return


+ 1
- 1
lark/parser_frontends.py Ver ficheiro

@@ -96,9 +96,9 @@ class WithLexer(_ParserFrontend):
terminals = [item for item in memo.values() if isinstance(item, TerminalDef)]
inst.lexer_conf.callbacks = _get_lexer_callbacks(options.transformer, terminals)
inst.lexer_conf.re_module = regex if options.regex else re
inst.lexer_conf.skip_validation = True
inst.lexer_conf.use_bytes = options.use_bytes
inst.lexer_conf.g_regex_flags = options.g_regex_flags
inst.lexer_conf.skip_validation = True
inst.init_lexer()

return inst


Carregando…
Cancelar
Guardar