diff --git a/lark/lark.py b/lark/lark.py index ae71d56..c27f534 100644 --- a/lark/lark.py +++ b/lark/lark.py @@ -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.