316: #line 473 "lalr1_parser.ipk" 317: def newmkntfirstmap(self): 318: res = {} 319: pi = 0 320: for p in self.productions: 321: if p.RHS and p.RHS[0] in self.nonterms: 322: if not res.has_key(p.LHS): 323: res[p.LHS] = {} 324: if not res[p.LHS].has_key(p.RHS[0]): 325: res[p.LHS][p.RHS[0]] = 1 326: 327: while 1: 328: foundmore = 0 329: reskeys = res.keys() 330: for nt in reskeys: 331: rhsdict = res[nt] 332: for rnt in rhsdict.keys(): 333: if rnt in reskeys: 334: d = res[rnt] 335: for k in d.keys(): 336: if not res[nt].has_key(k): 337: foundmore = 1 338: res[nt][k] = 1 339: if not foundmore: 340: break 341: # 342: # this part accounts for the fact that a nonterminal will 343: # produce exactly itself in zero steps 344: # 345: for p in self.productions: 346: if res.has_key(p.LHS): 347: res[p.LHS][p.LHS] = 1 348: else: 349: res[p.LHS] = {p.LHS: 1} 350: self.ntfirstmap = res 351: