*
* If 'rw', verifies that 'f' is a read/write field.
*
- * 'exchange' should be true if an exchange action is being parsed. This is
- * only used to improve error message phrasing.
- *
* Returns true if successful, false if an error was encountered (in which case
* 'ctx->error' reports the particular error). */
static bool
-expand_symbol(struct expr_context *ctx, bool rw, bool exchange,
+expand_symbol(struct expr_context *ctx, bool rw,
struct expr_field *f, struct expr **prereqsp)
{
const struct expr_symbol *orig_symbol = f->symbol;
if (f->symbol->expansion && f->symbol->level != EXPR_L_ORDINAL) {
- expr_error(ctx, "Predicate symbol %s cannot be used in %s.",
- f->symbol->name, exchange ? "exchange" : "assignment");
+ expr_error(ctx, "Predicate symbol %s used where lvalue required.",
+ f->symbol->name);
return false;
}
goto exit;
}
const struct expr_symbol *orig_dst = dst.symbol;
- if (!expand_symbol(ctx, true, exchange, &dst, &prereqs)) {
+ if (!expand_symbol(ctx, true, &dst, &prereqs)) {
goto exit;
}
goto exit;
}
const struct expr_symbol *orig_src = src.symbol;
- if (!expand_symbol(ctx, exchange, exchange, &src, &prereqs)) {
+ if (!expand_symbol(ctx, exchange, &src, &prereqs)) {
goto exit;
}
inport[1] = 1; => Cannot select subfield of string field inport.
ip.proto[1] = 1; => Cannot select subfield of nominal field ip.proto.
eth.dst[40] == 1; => Syntax error at `==' expecting `='.
-ip = 1; => Predicate symbol ip cannot be used in assignment.
+ip = 1; => Predicate symbol ip used where lvalue required.
ip.proto = 6; => Field ip.proto is not modifiable.
inport = {"a", "b"}; => Assignments require a single value.
inport = {}; => Syntax error at `}' expecting constant.
bad_prereq = 123; => Error parsing expression `xyzzy' encountered as prerequisite or predicate of initial expression: Syntax error at `xyzzy' expecting field name.
self_recurse = 123; => Error parsing expression `self_recurse != 0' encountered as prerequisite or predicate of initial expression: Error parsing expression `self_recurse != 0' encountered as prerequisite or predicate of initial expression: Recursive expansion of symbol `self_recurse'.
-vlan.present = 0; => Predicate symbol vlan.present cannot be used in assignment.
-reg0[0] = vlan.present; => Predicate symbol vlan.present cannot be used in assignment.
+vlan.present = 0; => Predicate symbol vlan.present used where lvalue required.
+reg0[0] = vlan.present; => Predicate symbol vlan.present used where lvalue required.
reg0 = reg1[0..10]; => Can't assign 11-bit value to 32-bit destination.
inport = reg0; => Can't assign integer field (reg0) to string field (inport).
inport = big_string; => String fields inport and big_string are incompatible for assignment.
ip.proto = reg0[0..7]; => Field ip.proto is not modifiable.
-reg0[0] <-> vlan.present; => Predicate symbol vlan.present cannot be used in exchange.
+reg0[0] <-> vlan.present; => Predicate symbol vlan.present used where lvalue required.
reg0 <-> reg1[0..10]; => Can't exchange 32-bit field with 11-bit field.
inport <-> reg0; => Can't exchange string field (inport) with integer field (reg0).
inport <-> big_string; => String fields inport and big_string are incompatible for exchange.