#include #include typedef bit<48> EthernetAddress; header Ethernet_h { EthernetAddress dstAddr; EthernetAddress srcAddr; bit<16> etherType; } struct Parsed_packet { Ethernet_h ethernet; } struct mystruct1 { bit<4> a; bit<4> b; } control DeparserI(packet_out packet, in Parsed_packet hdr) { apply { packet.emit(hdr.ethernet); } } parser parserI(packet_in pkt, out Parsed_packet hdr, inout mystruct1 meta, inout standard_metadata_t stdmeta) { // This is acceptable to p4test and p4c-bm2-ss const bit<16> c0 = 0xdead; bit<16> v0; state start { // The const line below causes p4test and p4c-bm2-ss to give // an error. It doesn't seem to be an onerous restriction to // disallow const declarations inside of states, but variable // declarations are allowed here and in top level of parser, // so why not const? const bit<16> c1 = 0xdead; bit<16> v1; { pkt.extract(hdr.ethernet); } transition accept; } } control cIngress(inout Parsed_packet hdr, inout mystruct1 meta, inout standard_metadata_t stdmeta) { action foo () { } table tbl1 { key = { } actions = { foo; NoAction; } default_action = NoAction; } apply { tbl1.apply(); } } control cEgress(inout Parsed_packet hdr, inout mystruct1 meta, inout standard_metadata_t stdmeta) { apply { } } control vc(in Parsed_packet hdr, inout mystruct1 meta) { apply { } } control uc(inout Parsed_packet hdr, inout mystruct1 meta) { apply { } } V1Switch(parserI(), vc(), cIngress(), cEgress(), uc(), DeparserI()) main;