Browse Source

Re-implemented CustomLexer after regression (Issue #377)

tags/gm/2021-09-23T00Z/github.com--lark-parser-lark/0.7.2
Erez Shinan 5 years ago
parent
commit
0f9dfdd623
1 changed files with 6 additions and 5 deletions
  1. +6
    -5
      lark/parser_frontends.py

+ 6
- 5
lark/parser_frontends.py 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


Loading…
Cancel
Save