def p_elif2(p): '''elif : ELIF expr block elif | ELIF expr block else ''' p[0] =Node('IF') p[0].cond = p[2] p[0].body = p[3].body p[0].orelse = p[4]
def p_if2(p): '''if : IF expr block elif | IF expr block else ''' p[0] = Node('IF') p[0].cond = p[1] p[0].body=p[3].body p[0].orelse = p[4]
def p_if(p): """if : IF expr block""" p[0] = Node("If") p[0].cond = p[2] p[0].body = p[3]
def p_while(p): """while : WHILE LPAREN expr RPAREN block""" p[0] = Node("While") p[0].cond = p[3] p[0].body = p[5]
def p_while1(p): '''while : WHILE expr block ''' p[0] =Node('WHILE') p[0].cond = p[2] p[0].body=p[3].body
def p_elif1(p): '''elif : ELIF expr block ''' p[0] =Node('IF') p[0].cond = p[2] p[0].body = p[3].body
def p_if1(p): '''if : IF expr block ''' p[0]=Node('IF') p[0].cond = p[2] p[0].body = p[3].body