View on GitHub

The Lucid Language

Tutorial examples

These examples introduce most features of Lucid. Each example includes a readme.md, an annotated .dpt source file and a .json input trace for the interpreter. To run an example in the interpreter, you should be able to just run make in its project directory (Assuming you are in a local copy of the Lucid repo and have compiled it).

Basic language and interpreter features

Tutorial 1 Using the interpreter and structuring a packet processing program using events and handlers.

Tutorial 2 Using match statements and runtime-modifiable tables for sophisticated decision logic, installing match-action rules in the interpreter.

Tutorial 3 Using Lucid Arrays to track state across packets/events. Reading program state in the interpreter.

Language features for modular and re-usable code

Tutorial 4 Event serialization and deserialization with parsers.

Tutorial 5 Modules for libraries and data structures.

Tutorial 6 Polymorphism for type-safe generic functions and containers.

Tutorial 7 Vectors and statically-bounded for loops.

Compiling to the tofino

Tofino SDE Setup Setting up the Tofino SDE and environment variables.

Tutorial 1 Compiling and running a simple packet reflector program on the Tofino using Lucid-provided scripts.

Tutorial 2 Writing and running a simple script on the Tofino’s management CPU that adds a rule to a table in the program from the control plane.

Other documentation and examples

For more example applications, look at:

To see how to do specific things, look at the comprehensive details about all of Lucid’s features in the wiki.