Browse Source

Added 'edit_terminals' option (Issue #406)

tags/gm/2021-09-23T00Z/github.com--lark-parser-lark/0.7.7
Erez Sh 5 years ago
parent
commit
bb57629418
1 changed files with 5 additions and 0 deletions
  1. +5
    -0
      lark/lark.py

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


Loading…
Cancel
Save