return compound_expr_alloc(loc, EXPR_LIST);
}
+/* list is assumed to have two items at least, otherwise extend this! */
+struct expr *list_expr_to_binop(struct expr *expr)
+{
+ struct expr *first, *last, *i;
+
+ first = list_first_entry(&expr->expressions, struct expr, list);
+ i = first;
+
+ list_for_each_entry_continue(i, &expr->expressions, list) {
+ if (first) {
+ last = binop_expr_alloc(&expr->location, OP_OR, first, i);
+ first = NULL;
+ } else {
+ last = binop_expr_alloc(&expr->location, OP_OR, i, last);
+ }
+ }
+ /* zap list expressions, they have been moved to binop expression. */
+ init_list_head(&expr->expressions);
+ expr_free(expr);
+
+ return last;
+}
+
static const char *calculate_delim(const struct expr *expr, int *count,
struct output_ctx *octx)
{
}
| expr /* implicit */ basic_rhs_expr SLASH list_rhs_expr
{
- $$ = flagcmp_expr_alloc(&@$, OP_EQ, $1, $4, $2);
+ struct expr *mask = list_expr_to_binop($4);
+ struct expr *binop = binop_expr_alloc(&@$, OP_AND, $1, mask);
+
+ $$ = relational_expr_alloc(&@$, OP_IMPLICIT, binop, $2);
}
| expr /* implicit */ list_rhs_expr SLASH list_rhs_expr
{
- $$ = flagcmp_expr_alloc(&@$, OP_EQ, $1, $4, $2);
+ struct expr *value = list_expr_to_binop($2);
+ struct expr *mask = list_expr_to_binop($4);
+ struct expr *binop = binop_expr_alloc(&@$, OP_AND, $1, mask);
+
+ $$ = relational_expr_alloc(&@$, OP_IMPLICIT, binop, value);
}
| expr relational_op basic_rhs_expr SLASH list_rhs_expr
{
- $$ = flagcmp_expr_alloc(&@$, $2, $1, $5, $3);
+ struct expr *mask = list_expr_to_binop($5);
+ struct expr *binop = binop_expr_alloc(&@$, OP_AND, $1, mask);
+
+ $$ = relational_expr_alloc(&@$, $2, binop, $3);
}
| expr relational_op list_rhs_expr SLASH list_rhs_expr
{
- $$ = flagcmp_expr_alloc(&@$, $2, $1, $5, $3);
+ struct expr *value = list_expr_to_binop($3);
+ struct expr *mask = list_expr_to_binop($5);
+ struct expr *binop = binop_expr_alloc(&@$, OP_AND, $1, mask);
+
+ $$ = relational_expr_alloc(&@$, $2, binop, value);
}
| expr relational_op rhs_expr
{