For each nonterminal C, compute the set of all terminals a, such that C derives ax in zero or more steps of (rightmost) derivation where the last derivation is not an epsilon (empty) production.
assumes .mkfirstntmap() has been run and has already produced self.ntfirstmap
352: #line 517 "lalr1_parser.ipk" 353: def calc_tfirstmap(self): 354: res = {} 355: for p in self.productions: 356: if not res.has_key(p.LHS): 357: res[p.LHS] = [] 358: if p.RHS and p.RHS[0] in self.terms: 359: res[p.LHS].append(p.RHS[0]) 360: while 1: 361: foundmore = 0 362: reskeys = res.keys() 363: for nt in self.ntfirstmap.keys(): 364: arrows = self.ntfirstmap[nt] 365: for k in arrows.keys(): 366: for t in res[k]: 367: if t not in res[nt]: 368: foundmore = 1 369: res[nt].append(t) 370: if not foundmore: break 371: self.tfirstmap = res 372: 373: