[P4-dev] Slight Problem with a Boolean Expression

Peter Newman petenewm at cisco.com
Thu Aug 13 14:20:02 EDT 2015


I'm trying to express a test for a multicast IPv4 address:

if ((ipv4.dstAddr & 0xf0000000) == 0xe0000000) {
     /* do something with multicast pkt */

I receive the following error from the compiler:

parse error in file xxx.p4 at line 144 : Syntax error while parsing at 
token ) (RPAREN)
parse error in file xxx.p4 at line 144 : Invalid boolean expression
2 errors during parsing

If I remove the parenthesis the compiler accepts the expression but the 
operator precedence would be incorrect.

I am using the original public version of the compiler (so my apologies 
if this has already been fixed).

According to the BNF in the spec (version 1.0.2) I believe this to be a 
valid expression (other than the requirement to use \& for bitwise AND 
which I take to be a typo).


More information about the P4-dev mailing list