Пример #1
0
 def p_logical_or_expr(self, p):
     """logical_or_expr : logical_and_expr
                        | logical_or_expr OR logical_and_expr
     """
     if len(p) == 2:
         p[0] = p[1]
     else:
         p[0] = ast.BinOp(op=p[2], left=p[1], right=p[3])
Пример #2
0
 def p_bitwise_and_expr(self, p):
     """bitwise_and_expr : equality_expr
                         | bitwise_and_expr BAND equality_expr
     """
     if len(p) == 2:
         p[0] = p[1]
     else:
         p[0] = ast.BinOp(op=p[2], left=p[1], right=p[3])
Пример #3
0
 def p_bitwise_or_expr(self, p):
     """bitwise_or_expr : bitwise_xor_expr
                        | bitwise_or_expr BOR bitwise_xor_expr
     """
     if len(p) == 2:
         p[0] = p[1]
     else:
         p[0] = ast.BinOp(op=p[2], left=p[1], right=p[3])
Пример #4
0
 def p_additive_expr(self, p):
     """additive_expr : multiplicative_expr
                      | additive_expr PLUS multiplicative_expr
                      | additive_expr MINUS multiplicative_expr
     """
     if len(p) == 2:
         p[0] = p[1]
     else:
         p[0] = ast.BinOp(op=p[2], left=p[1], right=p[3])
Пример #5
0
 def p_shift_expr(self, p):
     """shift_expr : additive_expr
                   | shift_expr LSHIFT additive_expr
                   | shift_expr RSHIFT additive_expr
                   | shift_expr URSHIFT additive_expr
     """
     if len(p) == 2:
         p[0] = p[1]
     else:
         p[0] = ast.BinOp(op=p[2], left=p[1], right=p[3])
Пример #6
0
 def p_multiplicative_expr(self, p):
     """multiplicative_expr : unary_expr
                            | multiplicative_expr MULT unary_expr
                            | multiplicative_expr DIV unary_expr
                            | multiplicative_expr MOD unary_expr
     """
     if len(p) == 2:
         p[0] = p[1]
     else:
         p[0] = ast.BinOp(op=p[2], left=p[1], right=p[3])
Пример #7
0
 def p_equality_expr(self, p):
     """equality_expr : relational_expr
                      | equality_expr EQEQ relational_expr
                      | equality_expr NE relational_expr
                      | equality_expr STREQ relational_expr
                      | equality_expr STRNEQ relational_expr
     """
     if len(p) == 2:
         p[0] = p[1]
     else:
         p[0] = ast.BinOp(op=p[2], left=p[1], right=p[3])
Пример #8
0
 def p_relational_expr(self, p):
     """relational_expr : shift_expr
                        | relational_expr LT shift_expr
                        | relational_expr GT shift_expr
                        | relational_expr LE shift_expr
                        | relational_expr GE shift_expr
                        | relational_expr INSTANCEOF shift_expr
                        | relational_expr IN shift_expr
     """
     if len(p) == 2:
         p[0] = p[1]
     else:
         p[0] = ast.BinOp(op=p[2], left=p[1], right=p[3])