PLDB
Languages Features Calendar CSV Lists Blog About Sponsor Add Language
GitHub icon

P4

P4

P4 is a pl created in 2014.

#489on PLDB 8Years Old 666Users
0Books 0Papers 574Repos

P4 is a programming language designed to allow programming of packet forwarding planes. In contrast to a general purpose language such as C or Python, P4 is a domain-specific language with a number of constructs optimized around network data forwarding. P4 is an open-source, permissively licensed language and is maintained by a non-profit organization called the P4 Language Consortium. Read more on Wikipedia...


Example from Linguist:
// Copyright 2015, Barefoot Networks, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. action set_mirror_id(session_id) { clone_ingress_pkt_to_egress(session_id); } table mirror_acl { reads { ingress_metadata.if_label : ternary; ingress_metadata.bd_label : ternary; /* ip acl */ ingress_metadata.lkp_ipv4_sa : ternary; ingress_metadata.lkp_ipv4_da : ternary; ingress_metadata.lkp_ip_proto : ternary; /* mac acl */ ingress_metadata.lkp_mac_sa : ternary; ingress_metadata.lkp_mac_da : ternary; ingress_metadata.lkp_mac_type : ternary; } actions { nop; set_mirror_id; } size : INGRESS_MIRROR_ACL_TABLE_SIZE; }

Language features

Feature Supported Example Token
MultiLine Comments
/* A comment
*/
/* */
Comments
// A comment
Line Comments
// A comment
//
Semantic Indentation ϴ
taichi.html · p4.html · beta.html

View source

PLDB - Build the next great programming language · v2022 · Day 33 · Docs · Build · Acknowledgements · Traffic Today · Traffic Trends · Mirrors · GitHub · feedback@pldb.com