Exemple #1
0
    def p_binary_e(self, p):
        '''
            or_e : or_e LOR and_e
            and_e : and_e LAND compare_e
            compare_e : compare_e EQUAL rel_e
                      | compare_e NOTEQ rel_e
            rel_e : rel_e LT add_e
                  | rel_e GT add_e
                  | rel_e LE add_e
                  | rel_e GE add_e
            add_e : add_e PLUS mul_e
                  | add_e MINUS mul_e
            mul_e : mul_e TIMES sa_e
                  | mul_e DIV sa_e
                  | mul_e MOD sa_e

        '''
        p[0] = expression.binary_operator(p[2], p[1], p[3], p.lexpos(2))
Exemple #2
0
 def p_dec(self, p):
     'assign_e : IDENT DEC'
     q = expression.reference(p[1], p.lexpos(1))
     p[0] = expression.assignment(q, expression.binary_operator('-', q, expression.const(1, type.int_t, p.lexpos(2)), p.lexpos(2)), p.lexpos(2))