Make it follow the standard protocol(s). Unfortunately that means
that some additional information will have to be carried in
the compilation context. It seems like a decent tradeoff -- but
it may be revisited in the future.
Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
Ultimately, the goal is to completely separate the compilation from
the runtime to make it possible to have the interpreter/evaluator
be "just another" entity that can perform meaningful work when
given a parsed GP4 program.
Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
There were significant overlaps in the names of data structures
between the compiler and the language that made it necessary
to litter the code with P4Lang.xxxx. This refactor removes that
requirement in most places (Parser is ambiguous wherever TreeSitter
is used -- cannot avoid that!)
Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
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>
The compilation code was written as a precursor for implementation
with macros. The updates in this commit make the switch.
There is still plenty to do:
1. Comment Walker.
2. Comment Macros.
Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
Refactor the class hierarchy for parser states so that
there is a parser state that acts more like a type and
one that acts more like a value (the latter, then, serves
as the base class for the other instantiated parser states).
Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
update method will allow the creation of a new compilation context
based on the current one with new types/names.
Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
Compilation interface(s) now contain a compilation context.
The change will make it easier to expand on what each step
of the compilation process needs to know to complete its task
without having to make major changes to the interface.
Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
Do not pass around the MutableTree -- now that we are not
using queries for walking the AST, it is unnecessary.
Signed-off-by: Will Hawkins <hawkinsw@obs.cr>