def p_shift_expr(p): '''shift_expr : arith_expr | shift_expr OP_LEFT_SHIFT arith_expr | shift_expr OP_RIGHT_SHIFT arith_expr''' if len(p) == 2: p[0] = p[1] elif len(p) == 4: item = p[1] while isinstance(item, list): item = item[0] p[0] = ast.BinOp(left=p[1], op=op_dict.get(p[2]), right=p[3], lineno=item.lineno, col_offset=item.col_offset) return
def p_term(p): '''term : term "*" factor | term "/" factor | term "%" factor | term OP_EXACT_DIVISION factor | factor ''' if len(p) == 2: p[0] = p[1] elif len(p) == 4: item = p[1] while isinstance(item, list): item = item[0] p[0] = ast.BinOp(left=p[1], op=op_dict.get(p[2]), right=p[3], lineno=item.lineno, col_offset=item.col_offset) return