• Home
  • Raw
  • Download

Lines Matching full:production

34 class Item(collections.namedtuple("Item", ["production", "dot", "terminal",
36 """An Item is an LR(1) Item: a production, a cursor location, and a terminal.
38 An Item represents a partially-parsed production, and a lookahead symbol. The
39 position of the dot indicates what portion of the production has been parsed.
44 production: The Production this Item covers.
45 dot: The index of the "dot" in production's rhs.
46 terminal: The terminal lookahead symbol that follows the production in the
52 return (str(self.production.lhs) + " -> " + " ".join(
53 [str(r) for r in self.production.rhs[0:self.dot] + (".",) +
54 self.production.rhs[self.dot:]]) + ", " + str(self.terminal))
64 where "symbol -> foo bar baz" will be taken as the production, the position
72 Symbols on the right-hand side of the production should be separated by
81 production, terminal = text.split(",")
85 lhs, rhs = production.split("->")
92 return make_item(parser_types.Production(lhs, tuple(handle + tail)),
96 def make_item(production, dot, symbol): argument
97 return Item(production, dot, symbol,
98 None if dot >= len(production.rhs) else production.rhs[dot])
131 ["symbol", "children", "production",
138 production: The grammar production to which this reduction corresponds.
153 production.
165 production).
169 self._seed_production = parser_types.Production(START_PRIME, (self.start,))
183 for production in self.productions:
184 self._productions_by_lhs.setdefault(production.lhs, list()).append(
185 production)
194 for production in self.productions:
195 for dot in range(len(production.rhs) + 1):
196 self._item_cache[production, dot, symbol] = make_item(
197 production, dot, symbol)
203 production. Terminal symbols are those which do not.
209 for production in self.productions:
210 self.symbols.add(production.lhs)
211 self.nonterminals.add(production.lhs)
212 for symbol in production.rhs:
248 for production in self.productions:
249 for first in self._first(production.rhs):
250 if first not in self.firsts[production.lhs]:
251 if production.lhs not in firsts_to_add:
252 firsts_to_add[production.lhs] = set()
253 firsts_to_add[production.lhs].add(first)
324 # be added for each production.
346 for production in self._productions_by_lhs.get(item.next_symbol, []):
347 for terminal in self._first(item.production.rhs[item.dot + 1:] +
349 new_items.add(self._item_cache[production, 0, terminal])
397 item = self._item_cache[item.production, item.dot + 1, item.terminal]
428 # The list of states is seeded with the marker S' production.
479 item.production != self._seed_production):
481 new_action = Reduce(item.production)
574 # matches some prefix of the production, in a place where that production
575 # might be valid), and, for each active production, how much of the
576 # production has been completed.
610 # Reduce means that there is a complete production on the stack, and
611 # that the next symbol implies that the completed production is the
612 # correct production.
615 # symbol on the rhs of the production, and then push a new state by
616 # looking up the (post-pop) current state and the lhs of the production
620 # Here, we attach a new partial parse tree, with the production lhs as