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:
@@ -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