Example #1
0
def ntd(x, d):
    nt = BGF.Nonterminal()
    nt.setName(x)
    w = d()
    w.setExpr(BGF.Expression(nt))
    return BGF.Expression(w)
Example #2
0
 #		# ???
 #	else:
 #		prevline = alt[cx:]
 #		cx = len(alt)+10
 #		break
 # nonterminals
 if alt[cx] == '{':
     curly += 1
     cx += 1
     continue
 if alt[cx][0].isupper() or alt[cx][0] == '&':
     if sym:
         seq.add(sym)
     if alt[cx][-1] == '+':
         sym = BGF.Plus()
         sym.setExpr(BGF.Nonterminal())
         sym.data.setName(alt[cx][:-1])
     elif alt[cx][-1] == '*':
         sym = BGF.Star()
         sym.setExpr(BGF.Nonterminal())
         sym.data.setName(alt[cx][:-1])
     elif alt[cx][-1] == '?':
         sym = BGF.Optional()
         sym.setExpr(BGF.Nonterminal())
         sym.data.setName(alt[cx][:-1])
     elif alt[cx] in layouts:
         print 'Occurrence of layout nonterminal', alt[
             cx], 'is disregarded.'
         sym = BGF.Epsilon()
     else:
         sym = BGF.Nonterminal()