feat(tazjin/rlox): Wire up bytecode interpreter & print results
This makes the bytecode interpreter actually usable. Change-Id: I24afc7ce461c6673dc42581378f6e14da7aece5c Reviewed-on: https://cl.tvl.fyi/c/depot/+/2566 Reviewed-by: tazjin <mail@tazj.in> Tested-by: BuildkiteCI
This commit is contained in:
parent
0c9a7de5be
commit
995d024f03
3 changed files with 11 additions and 19 deletions
|
|
@ -11,7 +11,7 @@ mod treewalk;
|
|||
/// Trait for making the different interpreters callable in the same
|
||||
/// way.
|
||||
pub trait Lox {
|
||||
type Value;
|
||||
type Value: std::fmt::Debug;
|
||||
type Error: std::fmt::Display;
|
||||
|
||||
fn create() -> Self;
|
||||
|
|
@ -69,9 +69,12 @@ fn run_prompt<I: Lox>() {
|
|||
}
|
||||
|
||||
fn run<I: Lox>(lox: &mut I, code: String) {
|
||||
if let Err(errors) = lox.interpret(code) {
|
||||
for error in errors {
|
||||
eprintln!("{}", error);
|
||||
match lox.interpret(code) {
|
||||
Ok(result) => println!("=> {:?}", result),
|
||||
Err(errors) => {
|
||||
for error in errors {
|
||||
eprintln!("{}", error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue