Exemplo n.º 1
0
 def teardown(self, g: grammar.Grammar):
     """We have introduced new nodes, so we need
     to recalculate min tokens.
     FIXME: Increasingly min tokens looks like it shouldn't
            be part of initial grammar creation.
     """
     g._calc_min_tokens()
     g._calc_pot_tokens()
Exemplo n.º 2
0
 def teardown(self, g: grammar.Grammar):
     """Prune orphan symbols"""
     # Cannot remove start symbol!
     self.unit_symbols.discard(g.start)
     symbols = list(g.symbols.keys())
     for name in symbols:
         if g.symbols[name] in self.unit_symbols:
             del g.symbols[name]
     g._calc_min_tokens()
     g._calc_pot_tokens()