compiler, language, runtime: Separate Parser Type From Instances
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>
This commit is contained in:
@@ -46,7 +46,7 @@ import P4Lang
|
||||
parser main_parser() {
|
||||
state start {
|
||||
true;
|
||||
transition start;
|
||||
transition accept;
|
||||
}
|
||||
};
|
||||
"""
|
||||
@@ -56,8 +56,8 @@ import P4Lang
|
||||
|
||||
#expect(parser.states.count() == 1)
|
||||
|
||||
let state = AsInstantiatedParserState((try! #require(parser.states.find(withIdentifier: Identifier(name: "start")))))
|
||||
#expect(state.state == Identifier(name: "start"))
|
||||
let state = (try! #require(parser.states.find(withIdentifier: Identifier(name: "start"))))
|
||||
#expect(state.getName() == Identifier(name: "start"))
|
||||
#expect(state.statements.count == 1)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user