Kaynağa Gözat

Merge pull request #860 from MegaIng/fix-852

Added configurations checks for postlex+dynamic
tags/gm/2021-09-23T00Z/github.com--lark-parser-lark/0.11.3
Erez Shinan 3 yıl önce
committed by GitHub
ebeveyn
işleme
5a4430c04a
Veri tabanında bu imza için bilinen anahtar bulunamadı GPG Anahtar Kimliği: 4AEE18F83AFDEB23
2 değiştirilmiş dosya ile 9 ekleme ve 1 silme
  1. +8
    -1
      lark/lark.py
  2. +1
    -0
      lark/parser_frontends.py

+ 8
- 1
lark/lark.py Dosyayı Görüntüle

@@ -288,7 +288,12 @@ class Lark(Serialize):
if self.options.parser == 'lalr':
self.options.lexer = 'contextual'
elif self.options.parser == 'earley':
self.options.lexer = 'dynamic'
if self.options.postlex is not None:
logger.info("postlex can't be used with the dynamic lexer, so we use standard instead. "
"Consider using lalr with contextual instead of earley")
self.options.lexer = 'standard'
else:
self.options.lexer = 'dynamic'
elif self.options.parser == 'cyk':
self.options.lexer = 'standard'
else:
@@ -298,6 +303,8 @@ class Lark(Serialize):
assert issubclass(lexer, Lexer) # XXX Is this really important? Maybe just ensure interface compliance
else:
assert_config(lexer, ('standard', 'contextual', 'dynamic', 'dynamic_complete'))
if self.options.postlex is not None and 'dynamic' in lexer:
raise ConfigurationError("Can't use postlex with a dynamic lexer. Use standard or contextual instead")

if self.options.ambiguity == 'auto':
if self.options.parser == 'earley':


+ 1
- 0
lark/parser_frontends.py Dosyayı Görüntüle

@@ -83,6 +83,7 @@ class ParsingFrontend(Serialize):
lexer_type = lexer_conf.lexer_type
self.skip_lexer = False
if lexer_type in ('dynamic', 'dynamic_complete'):
assert lexer_conf.postlex is None
self.skip_lexer = True
return



Yükleniyor…
İptal
Kaydet