Commit Graph

12 Commits

Author SHA1 Message Date
Will Hawkins 61d8f601e8 compiler, language, runtime: Separate Parser Type From Instances
Continuous Integration / Grammar Tests (push) Successful in 4m2s
Continuous Integration / Library Format Tests (push) Successful in 5m0s
Continuous Integration / Library Tests (push) Successful in 8m1s
In P4, parsers are considered types. Those parsers are instantiated.
The instantiated parsers are values. Previously, gp4 treated a parser
type and a parser value as identical. This PR makes that difference
clear _and_ sets the stage for the future.

TODO: Make the same distinction between control and action types and
values.

Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
2026-05-27 05:41:23 -04:00
Will Hawkins 5cfe5532a2 compiler, runtime: Refactor P4DataType to P4Type
Now that the old P4Type is a P4QualifiedType, it makes sense to
rename the data type back to just type.

Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
2026-05-04 07:37:48 -04:00
Will Hawkins 7c660b2b0c compiler, runtime: Refactor P4Type to P4QualifiedType
Also, refer to the different pieces of the qualified type as
qualifiers and not attributes.

Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
2026-05-04 07:29:51 -04:00
Will Hawkins f2bd53ce5f compiler, runtime, common: (Initial) Support For extern Declarations
Especially FFI

Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
2026-04-23 06:07:54 -04:00
Will Hawkins f687353326 compiler, runtime: Evaluate Expressions in Expression Statements
Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
2026-04-20 03:35:00 -04:00
Will Hawkins 94086c8e17 compiler, runtime, common, documentation: Refactor Type System
The type system (and the value system) now include attributes
for each type (things like direction, const-ness).

Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
2026-04-14 20:25:11 -04:00
Will Hawkins 35b2537754 compiler, runtime, common, testing: Support Directions on Parameters and Attributed Types
Add support for directions on parameters and attributed types. The
latter is necessary to support the former, but is not limited to
the direction use case. An attributed type is a P4 type with attributes
(like its direction, whether it is read only, etc.) Other attributes
will be added in the future.

Changes necessary to support attributed types include:
1. Global instances tracked during compilation are not attributed
types and not simply types.
2. (future) Type checking will have to make sure that a types
attributes do not affect type compatibility.

Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
2026-04-13 06:25:08 -04:00
Will Hawkins 708f65a0a9 Make Formatter Happy
Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
2026-04-06 08:50:20 -04:00
Will Hawkins 68ee5b1067 P4Lang/Program/InstancesWithTypes and TypesWithTypes
Add helper functions to fetch globally instantiated/declared
parser/controls (etc) and types in a user's P4 program.

Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
2026-04-06 08:49:35 -04:00
Will Hawkins cd26d1d22c Parse Struct Declarations
Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
2026-03-27 03:33:15 -04:00
Will Hawkins 5dbb8d3d60 Make Formatter Happy
Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
2026-02-24 00:44:04 -05:00
Will Hawkins 64a0fe4255 Refactor Parsing/Runtime
Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
2026-02-24 00:28:41 -05:00