def p_equality_expression_2(p): 'equality_expression : equality_expression equality_operator relational_expression' if p[2] == '==': p[0] = ast.BinOpExp(p[1], p[3], ast.BinOpExp.EQ, line_no=str(p.lineno(1) + __start_line_no - 1)) elif p[2] == '!=': p[0] = ast.BinOpExp(p[1], p[3], ast.BinOpExp.NE, line_no=str(p.lineno(1) + __start_line_no - 1)) else: err('orio.module.loop.parser internal error: unknown equality operator')
def p_additive_expression_2(p): 'additive_expression : additive_expression additive_operator multiplicative_expression' if (p[2] == '+'): p[0] = ast.BinOpExp(p[1], p[3], ast.BinOpExp.ADD, line_no=str(p.lineno(1) + __start_line_no - 1)) elif (p[2] == '-'): p[0] = ast.BinOpExp(p[1], p[3], ast.BinOpExp.SUB, line_no=str(p.lineno(1) + __start_line_no - 1)) else: err('orio.module.loop.parser internal error: unknown additive operator' )
def p_multiplicative_expression_2(p): 'multiplicative_expression : multiplicative_expression multiplicative_operator unary_expression' if (p[2] == '*'): p[0] = ast.BinOpExp(p[1], p[3], ast.BinOpExp.MUL, line_no=str(p.lineno(1) + __start_line_no - 1)) elif (p[2] == '/'): p[0] = ast.BinOpExp(p[1], p[3], ast.BinOpExp.DIV, line_no=str(p.lineno(1) + __start_line_no - 1)) elif (p[2] == '%'): p[0] = ast.BinOpExp(p[1], p[3], ast.BinOpExp.MOD, line_no=str(p.lineno(1) + __start_line_no - 1)) else: err('orio.module.loop.parser internal error: unknown multiplicative operator')
def p_relational_expression_2(p): 'relational_expression : relational_expression relational_operator additive_expression' if (p[2] == '<'): p[0] = ast.BinOpExp(p[1], p[3], ast.BinOpExp.LT, line_no=str(p.lineno(1) + __start_line_no - 1)) elif (p[2] == '>'): p[0] = ast.BinOpExp(p[1], p[3], ast.BinOpExp.GT, line_no=str(p.lineno(1) + __start_line_no - 1)) elif (p[2] == '<='): p[0] = ast.BinOpExp(p[1], p[3], ast.BinOpExp.LE, line_no=str(p.lineno(1) + __start_line_no - 1)) elif (p[2] == '>='): p[0] = ast.BinOpExp(p[1], p[3], ast.BinOpExp.GE, line_no=str(p.lineno(1) + __start_line_no - 1)) else: err('orio.module.loop.parser internal error: unknown relational operator')
def p_assignment_expression_2(p): 'assignment_expression : unary_expression assignment_operator assignment_expression' if (p[2] == '='): p[0] = ast.BinOpExp(p[1], p[3], ast.BinOpExp.EQ_ASGN, line_no=str(p.lineno(1) + __start_line_no - 1)) elif p[2] in ('*=', '/=', '%=', '+=', '-='): lhs = p[1].replicate() rhs = None if (p[2] == '*='): rhs = ast.BinOpExp(p[1], p[3], ast.BinOpExp.MUL, line_no=str(p.lineno(1) + __start_line_no - 1)) elif (p[2] == '/='): rhs = ast.BinOpExp(p[1], p[3], ast.BinOpExp.DIV, line_no=str(p.lineno(1) + __start_line_no - 1)) elif (p[2] == '%='): rhs = ast.BinOpExp(p[1], p[3], ast.BinOpExp.MOD, line_no=str(p.lineno(1) + __start_line_no - 1)) elif (p[2] == '+='): rhs = ast.BinOpExp(p[1], p[3], ast.BinOpExp.ADD, line_no=str(p.lineno(1) + __start_line_no - 1)) elif (p[2] == '-='): rhs = ast.BinOpExp(p[1], p[3], ast.BinOpExp.SUB, line_no=str(p.lineno(1) + __start_line_no - 1)) else: err('orio.module.loop.parser internal error: missing case for assignment operator') p[0] = ast.BinOpExp(lhs, rhs, ast.BinOpExp.EQ_ASGN, line_no=str(p.lineno(1) + __start_line_no - 1)) else: err('orio.module.loop.parser internal error: unknown assignment operator')
def p_logical_and_expression_2(p): 'logical_and_expression : logical_and_expression LAND equality_expression' p[0] = ast.BinOpExp(p[1], p[3], ast.BinOpExp.LAND, line_no=str(p.lineno(1) + __start_line_no - 1))
def p_logical_or_expression_2(p): 'logical_or_expression : logical_or_expression LOR logical_and_expression' p[0] = ast.BinOpExp(p[1], p[3], ast.BinOpExp.LOR, line_no=str(p.lineno(1) + __start_line_no - 1))
def p_expression_2(p): 'expression : expression COMMA assignment_expression' p[0] = ast.BinOpExp(p[1], p[3], ast.BinOpExp.COMMA, line_no=str(p.lineno(1) + __start_line_no - 1))