217: #line 360 "lalr1_parser.ipk"
218: def closure(self, items):
219: res = items[:]
220: todo = items[:]
221: while 1:
222: more = []
223: for (prodind, rhsind), term in todo:
224: if rhsind >= len(self.productions[prodind].RHS):
225: continue
226: for p in self.lhsprods.get(self.productions[prodind].RHS[rhsind], []):
227: try:
228: newpart = self.productions[prodind].RHS[rhsind + 1]
229: except IndexError:
230: newpart = EPS
231: stringofsyms = [newpart, term]
232: for t in self.firstofstring(stringofsyms):
233: if ((self.productions.index(p), 0), t) not in res:
234: more.append(((self.productions.index(p), 0), t))
235: if term == EOF and newpart == EPS:
236: if ((self.productions.index(p), 0), EOF) not in res:
237: more.append(((self.productions.index(p), 0), EOF))
238: if more:
239: res = res + more
240: todo = more
241: else:
242: break
243: return res
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254:
255: