refactor(tazjin/rlox): Add Interpreter trait for switching impls
Change-Id: Iae28d64ce879014c5e5d7e145c536c1f16ad307d Reviewed-on: https://cl.tvl.fyi/c/depot/+/2418 Reviewed-by: tazjin <mail@tazj.in> Tested-by: BuildkiteCI
This commit is contained in:
parent
d6d3c12efb
commit
1ff7a2686c
8 changed files with 125 additions and 102 deletions
|
|
@ -2,13 +2,9 @@ use super::*;
|
|||
|
||||
/// Evaluate a code snippet, returning a value.
|
||||
fn parse_eval(code: &str) -> Value {
|
||||
let chars: Vec<char> = code.chars().collect();
|
||||
let tokens = scanner::scan(&chars).expect("could not scan code");
|
||||
let program = parser::parse(tokens).expect("could not parse code");
|
||||
|
||||
Interpreter::create()
|
||||
.interpret(program)
|
||||
.expect("could not eval code")
|
||||
.interpret(code.into())
|
||||
.expect("could not interpret code")
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue