def p_assign(p): """assign : store EQ expr | varDef EQ expr | varDef EQ assign | store EQ assign """ p[0] = Node("Assign") p[0].left = p[1] p[0].right = p[3]
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]
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]
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]
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]