Skip to content

Commit

Permalink
Fixup: rename attribute ContextualLexer.basic_lexer -> BasicLexer
Browse files Browse the repository at this point in the history
  • Loading branch information
erezsh committed Sep 23, 2023
1 parent 4db7629 commit d83ad87
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lark/lexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ class ContextualLexer(Lexer):
lexers: Dict[str, AbstractBasicLexer]
root_lexer: AbstractBasicLexer

basic_lexer: Type[AbstractBasicLexer] = BasicLexer
BasicLexer: Type[AbstractBasicLexer] = BasicLexer

def __init__(self, conf: 'LexerConf', states: Dict[str, Collection[str]], always_accept: Collection[str]=()) -> None:
terminals = list(conf.terminals)
Expand All @@ -649,14 +649,14 @@ def __init__(self, conf: 'LexerConf', states: Dict[str, Collection[str]], always
accepts = set(accepts) | set(conf.ignore) | set(always_accept)
lexer_conf = copy(trad_conf)
lexer_conf.terminals = [terminals_by_name[n] for n in accepts if n in terminals_by_name]
lexer = self.basic_lexer(lexer_conf, comparator)
lexer = self.BasicLexer(lexer_conf, comparator)
lexer_by_tokens[key] = lexer

self.lexers[state] = lexer

assert trad_conf.terminals is terminals
trad_conf.skip_validation = True # We don't need to verify all terminals again
self.root_lexer = self.basic_lexer(trad_conf, comparator)
self.root_lexer = self.BasicLexer(trad_conf, comparator)

def lex(self, lexer_state: LexerState, parser_state: Any) -> Iterator[Token]:
try:
Expand Down

0 comments on commit d83ad87

Please sign in to comment.