Added 'edit_terminals' option (Issue #406)

This commit is contained in:
Erez Sh 2019-09-13 16:12:22 +03:00
parent 535aebab3c
commit bb57629418
1 changed files with 5 additions and 0 deletions

View File

@ -69,6 +69,7 @@ class LarkOptions(Serialize):
'propagate_positions': False,
'lexer_callbacks': {},
'maybe_placeholders': False,
'edit_terminals': None,
}
def __init__(self, options_dict):
@ -205,6 +206,10 @@ class Lark(Serialize):
# Compile the EBNF grammar into BNF
self.terminals, self.rules, self.ignore_tokens = self.grammar.compile(self.options.start)
if self.options.edit_terminals:
for t in self.terminals:
self.options.edit_terminals(t)
self._terminals_dict = {t.name:t for t in self.terminals}
# If the user asked to invert the priorities, negate them all here.