tvl-depot/users/tazjin/rlox/src/bytecode/mod.rs
Vincent Ambo 0d0b43ed88 fix(users/tazjin): rustfmt code with non-default settings
rustfmt only sometimes detects path-based nested config
files (probably some kind of race?), so my users folder uses a
separate formatting check for rustfmt to avoid flaky CI. Enough flakes
around already ...

Change-Id: Ifd862f9974f071b3a256643dd8e56c019116156a
Reviewed-on: https://cl.tvl.fyi/c/depot/+/5242
Reviewed-by: tazjin <tazjin@tvl.su>
Autosubmit: tazjin <tazjin@tvl.su>
Tested-by: BuildkiteCI
2022-02-07 16:58:59 +00:00

30 lines
599 B
Rust

//! Bytecode interpreter for Lox.
//!
//! https://craftinginterpreters.com/chunks-of-bytecode.html
mod chunk;
mod compiler;
mod errors;
mod interner;
mod opcode;
mod value;
mod vm;
#[cfg(test)]
mod tests;
pub struct Interpreter {}
impl crate::Lox for Interpreter {
type Error = errors::Error;
type Value = value::Value;
fn create() -> Self {
Interpreter {}
}
fn interpret(&mut self, code: String) -> Result<Self::Value, Vec<Self::Error>> {
let (strings, chunk) = compiler::compile(&code)?;
vm::interpret(strings, chunk).map_err(|e| vec![e])
}
}