runtime: Parameterize Runtime
Parameterize Runtime (nee ParserRuntime) so that it can run anything that is LibraryCallable. TODO: Refactor its API -- left mostly as it was because changing unit tests will be laborious.
This commit is contained in:
@@ -19,67 +19,61 @@ import Common
|
||||
import P4Lang
|
||||
|
||||
/// The runtime for a parser
|
||||
public struct ParserRuntime: CustomStringConvertible {
|
||||
public var parser: Parser
|
||||
public struct Runtime<U, T: LibraryCallable<U>>: CustomStringConvertible {
|
||||
public var callable: T
|
||||
|
||||
let initialValues: VarValueScopes?
|
||||
|
||||
init(parser: Parser) {
|
||||
self.parser = parser
|
||||
init(callable: T) {
|
||||
self.callable = callable
|
||||
self.initialValues = .none
|
||||
}
|
||||
|
||||
init(parser: Parser, withGlobalValues initial: VarValueScopes?) {
|
||||
self.parser = parser
|
||||
init(callable: T, withGlobalValues initial: VarValueScopes?) {
|
||||
self.callable = callable
|
||||
self.initialValues = initial
|
||||
}
|
||||
|
||||
/// Create a parser runtime from a P4 program
|
||||
public static func create(program: P4Lang.Program) -> Result<ParserRuntime> {
|
||||
return ParserRuntime.create(program: program, withGlobalValues: .none)
|
||||
public static func create(program: P4Lang.Program) -> Result<Runtime<InstantiatedParserState, Parser>> {
|
||||
return Runtime.create(program: program, withGlobalValues: .none)
|
||||
}
|
||||
|
||||
public static func create(
|
||||
program: P4Lang.Program, withGlobalValues initial: VarValueScopes?
|
||||
) -> Result<ParserRuntime> {
|
||||
) -> Result<Runtime<InstantiatedParserState, Parser>> {
|
||||
return switch program.starting_parser() {
|
||||
case .Ok(let parser):
|
||||
.Ok(P4Runtime.ParserRuntime(parser: parser, withGlobalValues: initial))
|
||||
.Ok(P4Runtime.Runtime<InstantiatedParserState, Parser>(callable: parser, withGlobalValues: initial))
|
||||
case .Error(let error): .Error(error)
|
||||
}
|
||||
}
|
||||
|
||||
public static func create(
|
||||
control: P4Lang.Control, withGlobalValues initial: VarValueScopes?
|
||||
) -> Result<Runtime<P4TableHitMissValue, Control>> {
|
||||
return .Ok(P4Runtime.Runtime<P4TableHitMissValue, Control>(callable: control, withGlobalValues: initial))
|
||||
}
|
||||
|
||||
/// Run a P4 parser with no arguments
|
||||
public func run() -> Result<(ParserState, ProgramExecution)> {
|
||||
public func run() -> Result<(U, ProgramExecution)> {
|
||||
return self.run(withArguments: ArgumentList([]))
|
||||
|
||||
}
|
||||
|
||||
public func run(withArguments arguments: ArgumentList) -> Result<(ParserState, ProgramExecution)>
|
||||
{
|
||||
let pe =
|
||||
if let initial = initialValues {
|
||||
ProgramExecution().setGlobalValues(initial)
|
||||
} else {
|
||||
ProgramExecution()
|
||||
}
|
||||
|
||||
return self.run(withArguments: arguments, inExecution: pe)
|
||||
}
|
||||
|
||||
/// Run the P4 parser on a given packet
|
||||
public func run(
|
||||
withArguments arguments: ArgumentList, inExecution pe: ProgramExecution
|
||||
) -> Result<(ParserState, ProgramExecution)> {
|
||||
withArguments arguments: ArgumentList, inExecution pe: ProgramExecution = ProgramExecution()
|
||||
) -> Result<(U, ProgramExecution)> {
|
||||
|
||||
let pe =
|
||||
let npe =
|
||||
if let globals = initialValues {
|
||||
pe.setGlobalValues(globals)
|
||||
} else {
|
||||
pe
|
||||
}
|
||||
|
||||
let (end_state, execution) = parser.call(execution: pe, arguments: arguments)
|
||||
let (end_state, execution) = callable.call(execution: npe, arguments: arguments)
|
||||
if let error = execution.getError() {
|
||||
return .Error(error)
|
||||
}
|
||||
@@ -87,6 +81,6 @@ public struct ParserRuntime: CustomStringConvertible {
|
||||
}
|
||||
|
||||
public var description: String {
|
||||
return "Runtime:\nExecution: \(parser)"
|
||||
return "Runtime:\nExecution: \(callable)"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ import TreeSitterP4
|
||||
])))
|
||||
let program = try #UseOkResult(
|
||||
Program.Compile(simple_parser_declaration, withGlobalInstances: test_declarations))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program, withGlobalValues: test_values))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program, withGlobalValues: test_values))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.accept)
|
||||
@@ -101,7 +101,7 @@ import TreeSitterP4
|
||||
])))
|
||||
let program = try #UseOkResult(
|
||||
Program.Compile(simple_parser_declaration, withGlobalInstances: test_declarations))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program, withGlobalValues: test_values))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program, withGlobalValues: test_values))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.reject)
|
||||
@@ -128,7 +128,7 @@ import TreeSitterP4
|
||||
])))
|
||||
let program = try #UseOkResult(
|
||||
Program.Compile(simple_parser_declaration, withGlobalInstances: test_declarations))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program, withGlobalValues: test_values))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program, withGlobalValues: test_values))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.accept)
|
||||
@@ -155,7 +155,7 @@ import TreeSitterP4
|
||||
])))
|
||||
let program = try #UseOkResult(
|
||||
Program.Compile(simple_parser_declaration, withGlobalInstances: test_declarations))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program, withGlobalValues: test_values))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program, withGlobalValues: test_values))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.accept)
|
||||
@@ -187,7 +187,7 @@ import TreeSitterP4
|
||||
|
||||
let program = try #UseOkResult(
|
||||
Program.Compile(simple_parser_declaration, withGlobalInstances: test_declarations))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program, withGlobalValues: test_values))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program, withGlobalValues: test_values))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.accept)
|
||||
@@ -216,7 +216,7 @@ import TreeSitterP4
|
||||
])))
|
||||
let program = try #UseOkResult(
|
||||
Program.Compile(simple_parser_declaration, withGlobalInstances: test_declarations))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program, withGlobalValues: test_values))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program, withGlobalValues: test_values))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.accept)
|
||||
@@ -249,7 +249,7 @@ import TreeSitterP4
|
||||
|
||||
let program = try #UseOkResult(
|
||||
Program.Compile(simple_parser_declaration, withGlobalInstances: test_declarations))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program, withGlobalValues: test_values))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program, withGlobalValues: test_values))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.accept)
|
||||
|
||||
@@ -42,7 +42,7 @@ import TreeSitterP4
|
||||
"""
|
||||
|
||||
let program = try #UseOkResult(Program.Compile(simple))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.accept)
|
||||
@@ -61,7 +61,7 @@ import TreeSitterP4
|
||||
"""
|
||||
|
||||
let program = try #UseOkResult(Program.Compile(simple))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.reject)
|
||||
@@ -80,7 +80,7 @@ import TreeSitterP4
|
||||
"""
|
||||
|
||||
let program = try #UseOkResult(Program.Compile(simple))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.reject)
|
||||
@@ -99,7 +99,7 @@ import TreeSitterP4
|
||||
"""
|
||||
|
||||
let program = try #UseOkResult(Program.Compile(simple))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.reject)
|
||||
@@ -118,7 +118,7 @@ import TreeSitterP4
|
||||
"""
|
||||
|
||||
let program = try #UseOkResult(Program.Compile(simple))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.accept)
|
||||
@@ -137,7 +137,7 @@ import TreeSitterP4
|
||||
"""
|
||||
|
||||
let program = try #UseOkResult(Program.Compile(simple))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.accept)
|
||||
@@ -156,7 +156,7 @@ import TreeSitterP4
|
||||
"""
|
||||
|
||||
let program = try #UseOkResult(Program.Compile(simple))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.accept)
|
||||
@@ -175,7 +175,7 @@ import TreeSitterP4
|
||||
"""
|
||||
|
||||
let program = try #UseOkResult(Program.Compile(simple))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.reject)
|
||||
@@ -194,7 +194,7 @@ import TreeSitterP4
|
||||
"""
|
||||
|
||||
let program = try #UseOkResult(Program.Compile(simple))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.accept)
|
||||
@@ -213,7 +213,7 @@ import TreeSitterP4
|
||||
"""
|
||||
|
||||
let program = try #UseOkResult(Program.Compile(simple))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.reject)
|
||||
|
||||
@@ -42,7 +42,7 @@ import TreeSitterP4
|
||||
"""
|
||||
|
||||
let program = try #UseOkResult(Program.Compile(simple))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.accept)
|
||||
@@ -61,7 +61,7 @@ import TreeSitterP4
|
||||
"""
|
||||
|
||||
let program = try #UseOkResult(Program.Compile(simple))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.reject)
|
||||
@@ -80,7 +80,7 @@ import TreeSitterP4
|
||||
"""
|
||||
|
||||
let program = try #UseOkResult(Program.Compile(simple))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.accept)
|
||||
@@ -99,7 +99,7 @@ import TreeSitterP4
|
||||
"""
|
||||
|
||||
let program = try #UseOkResult(Program.Compile(simple))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.accept)
|
||||
@@ -118,7 +118,7 @@ import TreeSitterP4
|
||||
"""
|
||||
|
||||
let program = try #UseOkResult(Program.Compile(simple))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.accept)
|
||||
@@ -137,7 +137,7 @@ import TreeSitterP4
|
||||
"""
|
||||
|
||||
let program = try #UseOkResult(Program.Compile(simple))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.accept)
|
||||
@@ -156,7 +156,7 @@ import TreeSitterP4
|
||||
"""
|
||||
|
||||
let program = try #UseOkResult(Program.Compile(simple))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.accept)
|
||||
@@ -175,7 +175,7 @@ import TreeSitterP4
|
||||
"""
|
||||
|
||||
let program = try #UseOkResult(Program.Compile(simple))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.accept)
|
||||
@@ -194,7 +194,7 @@ import TreeSitterP4
|
||||
"""
|
||||
|
||||
let program = try #UseOkResult(Program.Compile(simple))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.reject)
|
||||
@@ -213,7 +213,7 @@ import TreeSitterP4
|
||||
"""
|
||||
|
||||
let program = try #UseOkResult(Program.Compile(simple))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.reject)
|
||||
@@ -232,7 +232,7 @@ import TreeSitterP4
|
||||
"""
|
||||
|
||||
let program = try #UseOkResult(Program.Compile(simple))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.reject)
|
||||
@@ -251,7 +251,7 @@ import TreeSitterP4
|
||||
"""
|
||||
|
||||
let program = try #UseOkResult(Program.Compile(simple))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.reject)
|
||||
@@ -270,7 +270,7 @@ import TreeSitterP4
|
||||
"""
|
||||
|
||||
let program = try #UseOkResult(Program.Compile(simple))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.reject)
|
||||
@@ -289,7 +289,7 @@ import TreeSitterP4
|
||||
"""
|
||||
|
||||
let program = try #UseOkResult(Program.Compile(simple))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.reject)
|
||||
|
||||
@@ -42,7 +42,7 @@ import TreeSitterP4
|
||||
"""
|
||||
|
||||
let program = try #UseOkResult(Program.Compile(simple))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.accept)
|
||||
@@ -61,7 +61,7 @@ import TreeSitterP4
|
||||
"""
|
||||
|
||||
let program = try #UseOkResult(Program.Compile(simple))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.reject)
|
||||
@@ -80,7 +80,7 @@ import TreeSitterP4
|
||||
"""
|
||||
|
||||
let program = try #UseOkResult(Program.Compile(simple))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.accept)
|
||||
@@ -99,7 +99,7 @@ import TreeSitterP4
|
||||
"""
|
||||
|
||||
let program = try #UseOkResult(Program.Compile(simple))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.accept)
|
||||
@@ -118,7 +118,7 @@ import TreeSitterP4
|
||||
"""
|
||||
|
||||
let program = try #UseOkResult(Program.Compile(simple))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.accept)
|
||||
@@ -137,7 +137,7 @@ import TreeSitterP4
|
||||
"""
|
||||
|
||||
let program = try #UseOkResult(Program.Compile(simple))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.accept)
|
||||
@@ -156,7 +156,7 @@ import TreeSitterP4
|
||||
"""
|
||||
|
||||
let program = try #UseOkResult(Program.Compile(simple))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.accept)
|
||||
@@ -175,7 +175,7 @@ import TreeSitterP4
|
||||
"""
|
||||
|
||||
let program = try #UseOkResult(Program.Compile(simple))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.accept)
|
||||
@@ -194,7 +194,7 @@ import TreeSitterP4
|
||||
"""
|
||||
|
||||
let program = try #UseOkResult(Program.Compile(simple))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.reject)
|
||||
@@ -213,7 +213,7 @@ import TreeSitterP4
|
||||
"""
|
||||
|
||||
let program = try #UseOkResult(Program.Compile(simple))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.reject)
|
||||
@@ -232,7 +232,7 @@ import TreeSitterP4
|
||||
"""
|
||||
|
||||
let program = try #UseOkResult(Program.Compile(simple))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.reject)
|
||||
@@ -251,7 +251,7 @@ import TreeSitterP4
|
||||
"""
|
||||
|
||||
let program = try #UseOkResult(Program.Compile(simple))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.reject)
|
||||
@@ -270,7 +270,7 @@ import TreeSitterP4
|
||||
"""
|
||||
|
||||
let program = try #UseOkResult(Program.Compile(simple))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.reject)
|
||||
@@ -289,7 +289,7 @@ import TreeSitterP4
|
||||
"""
|
||||
|
||||
let program = try #UseOkResult(Program.Compile(simple))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.reject)
|
||||
@@ -311,7 +311,7 @@ import TreeSitterP4
|
||||
"""
|
||||
|
||||
let program = try #UseOkResult(Program.Compile(simple))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.accept)
|
||||
@@ -395,7 +395,7 @@ import TreeSitterP4
|
||||
"""
|
||||
|
||||
let program = try #UseOkResult(Program.Compile(simple))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.accept)
|
||||
@@ -480,7 +480,7 @@ import TreeSitterP4
|
||||
"""
|
||||
|
||||
let program = try #UseOkResult(Program.Compile(simple))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.accept)
|
||||
@@ -564,7 +564,7 @@ import TreeSitterP4
|
||||
"""
|
||||
|
||||
let program = try #UseOkResult(Program.Compile(simple))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.accept)
|
||||
|
||||
@@ -42,7 +42,7 @@ import TreeSitterP4
|
||||
"""
|
||||
|
||||
let program = try #UseOkResult(Program.Compile(simple))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.accept)
|
||||
@@ -61,7 +61,7 @@ import TreeSitterP4
|
||||
"""
|
||||
|
||||
let program = try #UseOkResult(Program.Compile(simple))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.reject)
|
||||
@@ -80,7 +80,7 @@ import TreeSitterP4
|
||||
"""
|
||||
|
||||
let program = try #UseOkResult(Program.Compile(simple))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.accept)
|
||||
@@ -99,7 +99,7 @@ import TreeSitterP4
|
||||
"""
|
||||
|
||||
let program = try #UseOkResult(Program.Compile(simple))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.accept)
|
||||
@@ -118,7 +118,7 @@ import TreeSitterP4
|
||||
"""
|
||||
|
||||
let program = try #UseOkResult(Program.Compile(simple))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.accept)
|
||||
@@ -137,7 +137,7 @@ import TreeSitterP4
|
||||
"""
|
||||
|
||||
let program = try #UseOkResult(Program.Compile(simple))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.accept)
|
||||
@@ -156,7 +156,7 @@ import TreeSitterP4
|
||||
"""
|
||||
|
||||
let program = try #UseOkResult(Program.Compile(simple))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.reject)
|
||||
@@ -175,7 +175,7 @@ import TreeSitterP4
|
||||
"""
|
||||
|
||||
let program = try #UseOkResult(Program.Compile(simple))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.reject)
|
||||
@@ -194,7 +194,7 @@ import TreeSitterP4
|
||||
"""
|
||||
|
||||
let program = try #UseOkResult(Program.Compile(simple))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.reject)
|
||||
@@ -213,7 +213,7 @@ import TreeSitterP4
|
||||
"""
|
||||
|
||||
let program = try #UseOkResult(Program.Compile(simple))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.reject)
|
||||
|
||||
@@ -52,7 +52,7 @@ import TreeSitterP4
|
||||
let program = try #UseOkResult(
|
||||
Program.Compile(simple_parser_declaration, withGlobalInstances: test_declarations, withGlobalTypes: test_types))
|
||||
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.accept)
|
||||
}
|
||||
@@ -85,7 +85,7 @@ import TreeSitterP4
|
||||
let program = try #UseOkResult(
|
||||
Program.Compile(simple_parser_declaration, withGlobalInstances: test_declarations, withGlobalTypes: test_types))
|
||||
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.reject)
|
||||
}
|
||||
@@ -119,7 +119,7 @@ import TreeSitterP4
|
||||
let program = try #UseOkResult(
|
||||
Program.Compile(simple_parser_declaration, withGlobalInstances: test_declarations, withGlobalTypes: test_types))
|
||||
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.accept)
|
||||
}
|
||||
@@ -156,7 +156,7 @@ import TreeSitterP4
|
||||
let program = try #UseOkResult(
|
||||
Program.Compile(simple_parser_declaration, withGlobalInstances: test_declarations, withGlobalTypes: test_types))
|
||||
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.accept)
|
||||
}
|
||||
@@ -193,7 +193,7 @@ import TreeSitterP4
|
||||
let program = try #UseOkResult(
|
||||
Program.Compile(simple_parser_declaration, withGlobalInstances: test_declarations, withGlobalTypes: test_types))
|
||||
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.reject)
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ import TreeSitterP4
|
||||
"""
|
||||
|
||||
let program = try #UseOkResult(Program.Compile(simple_parser_declaration))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.reject)
|
||||
@@ -74,7 +74,7 @@ import TreeSitterP4
|
||||
"""
|
||||
|
||||
let program = try #UseOkResult(Program.Compile(simple_parser_declaration))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.accept)
|
||||
|
||||
@@ -47,7 +47,7 @@ import TreeSitterP4
|
||||
"""
|
||||
let program = try #UseOkResult(
|
||||
Program.Compile(simple_parser_declaration))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.accept)
|
||||
}
|
||||
@@ -72,7 +72,7 @@ import TreeSitterP4
|
||||
"""
|
||||
let program = try #UseOkResult(
|
||||
Program.Compile(simple_parser_declaration))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.accept)
|
||||
}
|
||||
@@ -95,7 +95,7 @@ import TreeSitterP4
|
||||
"""
|
||||
let program = try #UseOkResult(
|
||||
Program.Compile(simple_parser_declaration))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.accept)
|
||||
}
|
||||
@@ -118,7 +118,7 @@ import TreeSitterP4
|
||||
"""
|
||||
let program = try #UseOkResult(
|
||||
Program.Compile(simple_parser_declaration))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.accept)
|
||||
}
|
||||
@@ -142,7 +142,7 @@ import TreeSitterP4
|
||||
"""
|
||||
let program = try #UseOkResult(
|
||||
Program.Compile(simple_parser_declaration))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.reject)
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ import TreeSitterP4
|
||||
"""
|
||||
|
||||
let program = try #UseOkResult(Program.Compile(simple_parser_declaration))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.accept)
|
||||
@@ -61,7 +61,7 @@ import TreeSitterP4
|
||||
"""
|
||||
|
||||
let program = try #UseOkResult(Program.Compile(simple_parser_declaration))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.accept)
|
||||
@@ -81,7 +81,7 @@ import TreeSitterP4
|
||||
"""
|
||||
|
||||
let program = try #UseOkResult(Program.Compile(simple_parser_declaration))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.reject)
|
||||
|
||||
@@ -46,7 +46,7 @@ import TreeSitterP4
|
||||
|
||||
let program = try #UseOkResult(Program.Compile(simple_parser_declaration))
|
||||
let parser = try #UseOkResult(program.find_parser(withName: Identifier(name: "main_parser")))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(parser.states.count() == 1)
|
||||
@@ -75,7 +75,7 @@ import TreeSitterP4
|
||||
|
||||
let program = try #UseOkResult(Program.Compile(simple_parser_declaration))
|
||||
let parser = try #UseOkResult(program.find_parser(withName: Identifier(name: "main_parser")))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(parser.states.count() == 1)
|
||||
@@ -103,7 +103,7 @@ import TreeSitterP4
|
||||
|
||||
let program = try #UseOkResult(Program.Compile(simple_parser_declaration))
|
||||
let parser = try #UseOkResult(program.find_parser(withName: Identifier(name: "main_parser")))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(parser.states.count() == 1)
|
||||
@@ -130,7 +130,7 @@ import TreeSitterP4
|
||||
|
||||
let program = try #UseOkResult(Program.Compile(simple_parser_declaration))
|
||||
let parser = try #UseOkResult(program.find_parser(withName: Identifier(name: "main_parser")))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(parser.states.count() == 1)
|
||||
@@ -156,7 +156,7 @@ import TreeSitterP4
|
||||
|
||||
let program = try #UseOkResult(Program.Compile(simple_parser_declaration))
|
||||
let parser = try #UseOkResult(program.find_parser(withName: Identifier(name: "main_parser")))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(parser.states.count() == 1)
|
||||
|
||||
@@ -41,7 +41,7 @@ import TreeSitterP4
|
||||
|
||||
let program = try #UseOkResult(Program.Compile(simple_parser_declaration))
|
||||
let parser = try #UseOkResult(program.find_parser(withName: Identifier(name: "main_parser")))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(parser.states.count() == 1)
|
||||
@@ -63,7 +63,7 @@ import TreeSitterP4
|
||||
|
||||
let program = try #UseOkResult(Program.Compile(simple_parser_declaration))
|
||||
let parser = try #UseOkResult(program.find_parser(withName: Identifier(name: "main_parser")))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(parser.states.count() == 1)
|
||||
@@ -85,7 +85,7 @@ import TreeSitterP4
|
||||
|
||||
let program = try #UseOkResult(Program.Compile(simple_parser_declaration))
|
||||
let parser = try #UseOkResult(program.find_parser(withName: Identifier(name: "main_parser")))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(parser.states.count() == 1)
|
||||
@@ -107,7 +107,7 @@ import TreeSitterP4
|
||||
"""
|
||||
let program = try #UseOkResult(Program.Compile(simple_parser_declaration))
|
||||
let parser = try #UseOkResult(program.find_parser(withName: Identifier(name: "main_parser")))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(parser.states.count() == 1)
|
||||
@@ -151,7 +151,7 @@ import TreeSitterP4
|
||||
"""
|
||||
let program = try #UseOkResult(Program.Compile(simple_parser_declaration))
|
||||
let parser = try #UseOkResult(program.find_parser(withName: Identifier(name: "main_parser")))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(parser.states.count() == 1)
|
||||
@@ -172,7 +172,7 @@ import TreeSitterP4
|
||||
};
|
||||
"""
|
||||
let program = try #UseOkResult(Program.Compile(simple_parser_declaration))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
|
||||
let args = ArgumentList([
|
||||
Argument(P4Value(P4BooleanValue(withValue: false)), atIndex: 1), Argument(P4Value(P4StringValue(withValue: "Testing")), atIndex: 2), Argument(P4Value(P4IntValue(withValue: 5)), atIndex: 3),
|
||||
@@ -193,7 +193,7 @@ import TreeSitterP4
|
||||
};
|
||||
"""
|
||||
let program = try #UseOkResult(Program.Compile(simple_parser_declaration))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
|
||||
let args = ArgumentList([
|
||||
Argument(P4Value(P4BooleanValue(withValue: false)), atIndex: 1), Argument(P4Value(P4StringValue(withValue: "Testing")), atIndex: 2), Argument(P4Value(P4IntValue(withValue: 5)), atIndex: 3),
|
||||
|
||||
@@ -89,7 +89,7 @@ public struct Return6: P4FFI {
|
||||
simple_parser_declaration, withGlobalInstances: .none, withGlobalTypes: .none,
|
||||
withFFIs: [externally]))
|
||||
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.accept)
|
||||
@@ -117,7 +117,7 @@ public struct Return6: P4FFI {
|
||||
simple_parser_declaration, withGlobalInstances: .none, withGlobalTypes: .none,
|
||||
withFFIs: [externally]))
|
||||
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.reject)
|
||||
|
||||
@@ -47,7 +47,7 @@ import TreeSitterP4
|
||||
"""
|
||||
|
||||
let program = try #UseOkResult(Program.Compile(simple_parser_declaration))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
|
||||
var statements_executed: [String] = Array()
|
||||
|
||||
@@ -86,7 +86,7 @@ import TreeSitterP4
|
||||
"""
|
||||
|
||||
let program = try #UseOkResult(Program.Compile(simple_parser_declaration))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
|
||||
var expressions_evaluated: [String] = Array()
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ import TreeSitterP4
|
||||
"""
|
||||
|
||||
let program = try #UseOkResult(Program.Compile(simple_parser_declaration))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
// We should be in the accept state.
|
||||
@@ -56,7 +56,7 @@ import TreeSitterP4
|
||||
"""
|
||||
|
||||
let program = try #UseOkResult(Program.Compile(simple_parser_declaration))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
// We should be in the accept state.
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.reject)
|
||||
@@ -73,10 +73,10 @@ import TreeSitterP4
|
||||
"""
|
||||
|
||||
let program = try #UseOkResult(Program.Compile(simple_parser_declaration))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
|
||||
#expect(
|
||||
#RequireErrorResult<(ParserState, ProgramExecution)>(
|
||||
#RequireErrorResult<(InstantiatedParserState, ProgramExecution)>(
|
||||
Error(withMessage: "Could not find the start state"),
|
||||
runtime.run()))
|
||||
}
|
||||
@@ -93,7 +93,7 @@ import TreeSitterP4
|
||||
};
|
||||
"""
|
||||
let program = try #UseOkResult(Program.Compile(simple_parser_declaration))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
|
||||
let args = ArgumentList([
|
||||
Argument(P4Value(P4BooleanValue(withValue: true)), atIndex: 1), Argument(P4Value(P4StringValue(withValue: "Testing")), atIndex: 2), Argument(P4Value(P4IntValue(withValue: 5)), atIndex: 3),
|
||||
@@ -115,14 +115,14 @@ import TreeSitterP4
|
||||
};
|
||||
"""
|
||||
let program = try #UseOkResult(Program.Compile(simple_parser_declaration))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
|
||||
let args = ArgumentList([
|
||||
Argument(P4Value(P4BooleanValue(withValue: true)), atIndex: 1), Argument(P4Value(P4BooleanValue(withValue: false)), atIndex: 2), Argument(P4Value(P4IntValue(withValue: 5)), atIndex: 3),
|
||||
])
|
||||
|
||||
#expect(
|
||||
#RequireErrorResult<(ParserState, ProgramExecution)>(
|
||||
#RequireErrorResult<(InstantiatedParserState, ProgramExecution)>(
|
||||
Error(withMessage: "Cannot call parser: Argument 2's type (Boolean) is incompatible with the parameter type (String)"),
|
||||
runtime.run(withArguments: args)))
|
||||
}
|
||||
@@ -139,14 +139,14 @@ import TreeSitterP4
|
||||
};
|
||||
"""
|
||||
let program = try #UseOkResult(Program.Compile(simple_parser_declaration))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
|
||||
let args = ArgumentList([
|
||||
Argument(P4Value(P4IntValue(withValue: 5)), atIndex: 1), Argument(P4Value(P4StringValue(withValue: "Testing")), atIndex: 2), Argument(P4Value(P4IntValue(withValue: 5)), atIndex: 3),
|
||||
])
|
||||
|
||||
#expect(
|
||||
#RequireErrorResult<(ParserState, ProgramExecution)>(
|
||||
#RequireErrorResult<(InstantiatedParserState, ProgramExecution)>(
|
||||
Error(withMessage: "Cannot call parser: Argument 1's type (Int) is incompatible with the parameter type (Boolean)"),
|
||||
runtime.run(withArguments: args)))
|
||||
}
|
||||
@@ -163,11 +163,11 @@ import TreeSitterP4
|
||||
};
|
||||
"""
|
||||
let program = try #UseOkResult(Program.Compile(simple_parser_declaration))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let args = ArgumentList([Argument(P4Value(P4BooleanValue(withValue: true)), atIndex: 0)])
|
||||
|
||||
#expect(
|
||||
#RequireErrorResult<(ParserState, ProgramExecution)>(
|
||||
#RequireErrorResult<(InstantiatedParserState, ProgramExecution)>(
|
||||
Error(withMessage: "Cannot call parser: 1 arguments found but 3 required"),
|
||||
runtime.run(withArguments: args)))
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ import TreeSitterP4
|
||||
|
||||
|
||||
let program = try #UseOkResult(Program.Compile(simple_parser_declaration))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.reject)
|
||||
@@ -69,7 +69,7 @@ import TreeSitterP4
|
||||
|
||||
|
||||
let program = try #UseOkResult(Program.Compile(simple_parser_declaration))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.accept)
|
||||
@@ -97,7 +97,7 @@ import TreeSitterP4
|
||||
|
||||
|
||||
let program = try #UseOkResult(Program.Compile(simple_parser_declaration))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.reject)
|
||||
@@ -121,7 +121,7 @@ import TreeSitterP4
|
||||
|
||||
|
||||
let program = try #UseOkResult(Program.Compile(simple_parser_declaration))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.reject)
|
||||
@@ -152,7 +152,7 @@ import TreeSitterP4
|
||||
|
||||
|
||||
let program = try #UseOkResult(Program.Compile(simple_parser_declaration))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.reject)
|
||||
|
||||
@@ -57,7 +57,7 @@ import TreeSitterP4
|
||||
|
||||
let program = try #UseOkResult(
|
||||
Program.Compile(simple_parser_declaration, withGlobalInstances: test_declarations))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program, withGlobalValues: test_values))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program, withGlobalValues: test_values))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.accept)
|
||||
}
|
||||
@@ -86,7 +86,7 @@ import TreeSitterP4
|
||||
|
||||
let program = try #UseOkResult(
|
||||
Program.Compile(simple_parser_declaration, withGlobalInstances: .none, withGlobalTypes: test_types))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.accept)
|
||||
}
|
||||
@@ -116,7 +116,7 @@ import TreeSitterP4
|
||||
|
||||
let program = try #UseOkResult(
|
||||
Program.Compile(simple_parser_declaration, withGlobalInstances: .none, withGlobalTypes: test_types))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.accept)
|
||||
}
|
||||
@@ -151,7 +151,7 @@ import TreeSitterP4
|
||||
|
||||
let program = try #UseOkResult(
|
||||
Program.Compile(simple_parser_declaration, withGlobalInstances: test_declarations))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program, withGlobalValues: test_values))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program, withGlobalValues: test_values))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.reject)
|
||||
}
|
||||
@@ -186,7 +186,7 @@ import TreeSitterP4
|
||||
|
||||
let program = try #UseOkResult(
|
||||
Program.Compile(simple_parser_declaration, withGlobalInstances: test_declarations))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program, withGlobalValues: test_values))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program, withGlobalValues: test_values))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.accept)
|
||||
}
|
||||
@@ -220,7 +220,7 @@ import TreeSitterP4
|
||||
|
||||
let program = try #UseOkResult(
|
||||
Program.Compile(simple_parser_declaration, withGlobalInstances: test_declarations))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program, withGlobalValues: test_values))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program, withGlobalValues: test_values))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.reject)
|
||||
}
|
||||
@@ -266,7 +266,7 @@ import TreeSitterP4
|
||||
])))
|
||||
let program = try #UseOkResult(
|
||||
Program.Compile(simple_parser_declaration, withGlobalInstances: test_declarations))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program, withGlobalValues: test_values))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program, withGlobalValues: test_values))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.accept)
|
||||
}
|
||||
@@ -302,7 +302,7 @@ import TreeSitterP4
|
||||
|
||||
let program = try #UseOkResult(
|
||||
Program.Compile(simple_parser_declaration, withGlobalInstances: test_declarations))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program, withGlobalValues: test_values))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program, withGlobalValues: test_values))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.accept)
|
||||
}
|
||||
@@ -375,7 +375,7 @@ import TreeSitterP4
|
||||
])))
|
||||
let program = try #UseOkResult(
|
||||
Program.Compile(simple_parser_declaration, withGlobalInstances: test_declarations))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program, withGlobalValues: test_values))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program, withGlobalValues: test_values))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.accept)
|
||||
}
|
||||
@@ -423,7 +423,7 @@ import TreeSitterP4
|
||||
])))
|
||||
let program = try #UseOkResult(
|
||||
Program.Compile(simple_parser_declaration, withGlobalInstances: test_declarations))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program, withGlobalValues: test_values))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program, withGlobalValues: test_values))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
#expect(AsInstantiatedParserState(state_result) == P4Lang.accept)
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ import TreeSitterP4
|
||||
|
||||
let program = try #UseOkResult(Program.Compile(simple_parser_declaration))
|
||||
let parser = try #UseOkResult(program.find_parser(withName: Identifier(name: "main_parser")))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(parser.states.count() == 1)
|
||||
@@ -63,7 +63,7 @@ import TreeSitterP4
|
||||
|
||||
let program = try #UseOkResult(Program.Compile(simple_parser_declaration))
|
||||
let parser = try #UseOkResult(program.find_parser(withName: Identifier(name: "main_parser")))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
#expect(parser.states.count() == 1)
|
||||
@@ -82,10 +82,10 @@ import TreeSitterP4
|
||||
"""
|
||||
|
||||
let program = try #UseOkResult(Program.Compile(simple_parser_declaration))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
|
||||
#expect(
|
||||
#RequireErrorResult<(ParserState, ProgramExecution)>(
|
||||
#RequireErrorResult<(InstantiatedParserState, ProgramExecution)>(
|
||||
Error(withMessage: "No key matched the selector"),
|
||||
runtime.run()))
|
||||
}
|
||||
@@ -141,7 +141,7 @@ import TreeSitterP4
|
||||
};
|
||||
"""
|
||||
let program = try #UseOkResult(Program.Compile(simple_parser_declaration))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
// 5 == 5 == true
|
||||
@@ -163,7 +163,7 @@ import TreeSitterP4
|
||||
};
|
||||
"""
|
||||
let program = try #UseOkResult(Program.Compile(simple_parser_declaration))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
// 5 == 5 == true
|
||||
@@ -185,7 +185,7 @@ import TreeSitterP4
|
||||
};
|
||||
"""
|
||||
let program = try #UseOkResult(Program.Compile(simple_parser_declaration))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
// 6 == 5 == true
|
||||
@@ -207,7 +207,7 @@ import TreeSitterP4
|
||||
};
|
||||
"""
|
||||
let program = try #UseOkResult(Program.Compile(simple_parser_declaration))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
// 6 == 5 == false
|
||||
@@ -229,7 +229,7 @@ import TreeSitterP4
|
||||
};
|
||||
"""
|
||||
let program = try #UseOkResult(Program.Compile(simple_parser_declaration))
|
||||
let runtime = try #UseOkResult(P4Runtime.ParserRuntime.create(program: program))
|
||||
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.Parser>.create(program: program))
|
||||
let (state_result, _) = try! #UseOkResult(runtime.run())
|
||||
|
||||
// TODO: This test should throw an error.
|
||||
|
||||
Reference in New Issue
Block a user