Files
crafting-interpreters/rlox/src/main.rs

15 lines
397 B
Rust
Raw Normal View History

2023-03-29 20:07:31 +02:00
mod vm;
2023-03-29 20:03:16 +02:00
fn main() {
2023-03-29 20:07:31 +02:00
let mut chunk = vm::Chunk::new("TEST".to_string());
2023-03-29 21:15:41 +02:00
chunk.add_constant(vm::Value::from(3.14));
2023-03-30 20:17:00 +02:00
chunk.add_op(vm::Op::Constant { offset: 0 }, 1);
chunk.add_op(vm::Op::Negate, 1);
chunk.add_op(vm::Op::Return, 1);
2023-03-29 20:03:16 +02:00
println!("{:?}", chunk);
2023-03-30 20:17:00 +02:00
let mut interpreter = vm::VM::new();
interpreter.trace = true;
interpreter.interpret(&chunk).unwrap()
2023-03-29 20:03:16 +02:00
}