Re-implemented CustomLexer after regression (Issue #377)

This commit is contained in:
Erez Shinan 2019-05-11 09:42:16 +03:00
parent 29ef3efeb9
commit 0f9dfdd623
1 changed files with 6 additions and 5 deletions

View File

@ -65,7 +65,7 @@ class WithLexer(Serialize):
inst.parser = LALR_Parser.deserialize(inst.parser, memo, callbacks)
inst.init_lexer()
return inst
def _serialize(self, data, memo):
data['parser'] = data['parser'].serialize(memo)
@ -107,11 +107,12 @@ class LALR_ContextualLexer(LALR_WithLexer):
###}
class LALR_CustomLexer(LALR_WithLexer):
def __init__(self, lexer_cls, lexer_conf, parser_conf, options=None):
pass # TODO
def init_lexer(self):
def __init__(self, lexer_cls, lexer_conf, parser_conf, *, options=None):
self.lexer = lexer_cls(self.lexer_conf)
debug = options.debug if options else False
self.parser = LALR_Parser(parser_conf, debug=debug)
WithLexer.__init__(self, lexer_conf, parser_conf, options)
def tokenize_text(text):
line = 1