Ejemplo n.º 1
0
def p_logical_expr1(p):
    '''logical_expr : expr AND expr
                        | expr OR  expr
                        | expr XOR expr
    '''
    p[0] = Node('COMPARE')
    p[0].left = p[1]
    p[0].op = p[2]
    p[0].right = p[3]
Ejemplo n.º 2
0
def p_arith_expr1(p):
    '''arith_expr : expr PLUS  expr
                      | expr MINUS expr
                      | expr MULT  expr
                      | expr DIV   expr
    '''
    p[0] = Node('Arith')
    p[0].left = p[1]
    p[0].op = p[2]
    p[0].right = p[3]
Ejemplo n.º 3
0
def p_comp_expr1(p):
    '''comp_expr : expr LT expr
                     | expr GT expr
                     | expr LTE expr
                     | expr GTE expr
                     | expr CEQ expr
                     | expr NEQ expr
    '''
    p[0] = Node('COMPARE')
    p[0].left = p[1]
    p[0].op = p[2]
    p[0].right = p[3]
Ejemplo n.º 4
0
def p_expr2(p):
    """expr : expr DIV expr
                | expr MULT expr
                | expr PLUS expr
                | expr MINUS expr
                | expr GT expr
                | expr LT expr
                | expr GTE expr
                | expr LTE expr
                | expr CEQ expr
                | expr AND expr
                | expr OR expr
                | expr XOR expr
                | expr IN expr
    """
    p[0] = Node("BinOp")
    p[0].left = p[1]
    p[0].right = p[3]
    p[0].op = p[2]