From ee974b3eddffa47d0d16beeada6658f37a21a8d4 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Sat, 27 Feb 2021 14:18:05 +0200 Subject: feat(tazjin/rlox): Bootstrap rough shape of bytecode compiler This one necessarily has to diverge more from the book than the treewalk interpreter did, so some of this is expected to change, but I'm happy with the rough shape. Since we're reusing the old scanner, the compiler/parser struct owns an iterator over all tokens with which the pull-scanner from the bytecode chapters is simulated. Change-Id: Icfa0bd4729d9df786e08f7e49a25cba1b9989a91 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2556 Tested-by: BuildkiteCI Reviewed-by: tazjin --- users/tazjin/rlox/src/bytecode/mod.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'users/tazjin/rlox/src/bytecode/mod.rs') diff --git a/users/tazjin/rlox/src/bytecode/mod.rs b/users/tazjin/rlox/src/bytecode/mod.rs index 34ceaf28bfa4..362d8bb1252f 100644 --- a/users/tazjin/rlox/src/bytecode/mod.rs +++ b/users/tazjin/rlox/src/bytecode/mod.rs @@ -3,6 +3,7 @@ //! https://craftinginterpreters.com/chunks-of-bytecode.html mod chunk; +mod compiler; mod errors; mod opcode; mod value; @@ -20,7 +21,7 @@ impl crate::Lox for Interpreter { } fn interpret(&mut self, code: String) -> Result> { - let chunk: Chunk = Default::default(); + let chunk = compiler::compile(&code)?; vm::interpret(chunk).map_err(|e| vec![e]) } } -- cgit 1.4.1