6.9.1.4.2. Find Nullable NonTerminals

Non-optimal!
Start python section to interscript/parsers/lalr1.py[6 /24 ] Next Prev Last
    84: #line 213 "lalr1_parser.ipk"
    85:   def calc_lhsdereps(self):
    86:     res = self.epslhs.copy()
    87:     wnts = self.nonterms - res
    88: 
    89:     converged = 0
    90:     while not converged:
    91:       converged = 1
    92:       for nt in wnts:
    93:         for p in self.lhsprods[nt]:
    94:           p_nullable = 1
    95:           for sym in p.RHS:
    96:             if not res.contains(sym):
    97:               p_nullable = 0
    98:               break
    99:           if p_nullable:
   100:             res.insert(nt)
   101:             wnts = wnts.remove(nt)
   102:             converged = 0
   103:             break
   104:         if not converged: break
   105:     self.lhsdereps = res
   106: 
   107: 
End python section to interscript/parsers/lalr1.py[6]