Beispiel #1
0
 def shift(self, type: int, value: Text, newstate: int, context: Context) -> None:
     """Shift a token.  (Internal)"""
     dfa, state, node = self.stack[-1]
     rawnode: RawNode = (type, value, context, None)
     newnode = convert(self.grammar, rawnode)
     assert node[-1] is not None
     node[-1].append(newnode)
     self.stack[-1] = (dfa, newstate, node)
 def pop(self) -> None:
     """Pop a nonterminal.  (Internal)"""
     popdfa, popstate, popnode = self.stack.pop()
     newnode = convert(self.grammar, popnode)
     if self.stack:
         dfa, state, node = self.stack[-1]
         assert node[-1] is not None
         node[-1].append(newnode)
     else:
         self.rootnode = newnode
         self.rootnode.used_names = self.used_names