Beispiel #1
0
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]
Beispiel #2
0
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]
Beispiel #3
0
def p_if(p):
    """if : IF expr block"""
    p[0] = Node("If")
    p[0].cond = p[2]
    p[0].body = p[3]
Beispiel #4
0
def p_while(p):
    """while : WHILE LPAREN expr RPAREN block"""
    p[0] = Node("While")
    p[0].cond = p[3]
    p[0].body = p[5]
Beispiel #5
0
def p_while1(p):
    '''while : WHILE expr block
    '''
    p[0] =Node('WHILE')
    p[0].cond = p[2]
    p[0].body=p[3].body
Beispiel #6
0
def p_elif1(p):
    '''elif : ELIF expr block
    '''
    p[0] =Node('IF')
    p[0].cond = p[2]
    p[0].body = p[3].body
Beispiel #7
0
def p_if1(p):
    '''if : IF expr block
    '''
    p[0]=Node('IF')
    p[0].cond = p[2]
    p[0].body = p[3].body