struct Symbol* exclusive_or_expression(struct ExclusiveOrExpression* node) { if (node->type == 0) return and_expression(node->andExpression); struct Symbol* symbol1 = load_symbol(exclusive_or_expression(node->exclusiveOrExpression)); struct Symbol* symbol2 = load_symbol(and_expression(node->andExpression)); return exclusive_or_symbol(symbol1, symbol2, node->type); }
int exclusive_or_expression(void) { if( and_expression() ) { } else if( exclusive_or_expression() ) { match(CARAT); and_expression(); } else { abort(); } }
// Parse a bitwise exclusive-or expression. // // exclusive-or-expression: // and-expression // exclusive-or-expression '^' and-expression // Expr& Parser::exclusive_or_expression() { Expr* e1 = &and_expression(); while (true) { if (Token tok = match_if(tk::caret_tok)) { Expr& e2 = and_expression(); e1 = &on_xor_expression(tok, *e1, e2); } else { break; } } return *e1; }
static struct block *exclusive_or_expression(struct block *block) { struct var value; block = and_expression(block); while (peek().token == '^') { consume('^'); value = block->expr; block = and_expression(block); block->expr = eval_expr(block, IR_OP_XOR, value, block->expr); } return block; }
struct Symbol* and_expression(struct AndExpression* node) { if (node->type == 0) return equality_expression(node->equalityExpression); struct Symbol* symbol1 = load_symbol(and_expression(node->andExpression)); struct Symbol* symbol2 = load_symbol(equality_expression(node->equalityExpression)); return and_symbol(symbol1, symbol2, node->type); }
int and_expression(void) { if( equality_expression() ) { } else if( and_expression() ) { match(AMP); equality_expression(); } else { abort(); } }