PrismJS / PrismJS/prism

Add support for P4 Language

Open
#3,890 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

language-definitions new language
Dominant language
JavaScript
Stars
13k
Forks
1.4k
Avg merge
15h 36m
Merged PRs (30d)
3

Description

Language
P4, Programming Protocol-independent Packet Processors, https://p4.org
P4(Programming Protocol-independent Packet Processors) is a programming language for controlling packet forwarding planes in networking devices, such as routers and switches. In contrast to a general purpose language such as C or Python, P4 is a domain-specific language with a number of constructs optimized for network data forwarding. P4 is distributed as open-source, permissively licensed code, and is maintained by the P4 Project (formerly the P4 Language Consortium), a not-for-profit organization hosted by the Open Networking Foundation.

Additional resources
Just like the P4 language syntax highlighting provided by Github:

#include <core.p4>

typedef bit<16> etherType_t;
typedef bit<48> macAddr_t;

const etherType_t TYPE_IPV4 = 16w0x0800;

header ethernet_t {
    macAddr_t   dstAddr;
    macAddr_t   srcAddr;
    etherType_t etherType;
}

struct headers {
    ethernet_t ethernet;
}

register<bit<32>, bit<1>>(8) statistical_data;

action drop() {
    mark_to_drop(standard_metadata);
}

table ipv4_lpm {
    key = {
        hdr.ipv4.dstAddr: lpm;
    }
    actions = {
        ipv4_forward;
        drop;
        NoAction;
    }
    size = 1024;
    default_action = NoAction();
}

// ...

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No file, test, or entry point is named in the issue. Review Prism's existing language definitions and contribution guidance, then use the supplied P4 example and the p4.org link to define the scope; done means P4 code receives syntax highlighting consistent with the requested support.

Written by the indexing model from the issue text.

Assessment

Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.