Improve Parsing of P4 Parsers And Continue Runtime Implementation
1. Parsing of P4 Parsers was broken: Multiple local elements and statements were not allowed. 2. Support more functionality on scopes. 3. Refactor variable/identifier. 4. Add more tests. Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
This commit is contained in:
@@ -65,15 +65,13 @@ public struct ParserTransitionStatement: ParserStatement {
|
||||
}
|
||||
|
||||
public struct VariableDeclarationStatement: ParserStatement {
|
||||
public var id: Identifier
|
||||
public init(withIdentifier id: Identifier) {
|
||||
self.id = id
|
||||
public var variable: Variable
|
||||
public init(withVariable variable: Variable) {
|
||||
self.variable = variable
|
||||
}
|
||||
|
||||
public func evaluate(execution: ParserExecution) -> ParserExecution {
|
||||
print("Evaluating!")
|
||||
execution.scopes.scopes[0].variables.append(Variable(name: id.name, withValue: id.value, isConstant: false))
|
||||
print("Execution: \(execution)")
|
||||
execution.scopes.scopes[0].variables.append(self.variable)
|
||||
return execution
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user