feat(tazjin/rlox): Implement block parsing
Change-Id: I1b7235ed71fa36120984a36f22cd564f59581352 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2303 Reviewed-by: tazjin <mail@tazj.in> Tested-by: BuildkiteCI
This commit is contained in:
parent
3c979acdf3
commit
8915cd6fba
3 changed files with 23 additions and 6 deletions
|
|
@ -1,5 +1,5 @@
|
|||
use crate::errors::{Error, ErrorKind};
|
||||
use crate::parser::{self, Expr, Literal, Program, Statement};
|
||||
use crate::parser::{self, Block, Expr, Literal, Statement};
|
||||
use crate::scanner::{self, TokenKind};
|
||||
use std::collections::HashMap;
|
||||
use std::rc::Rc;
|
||||
|
|
@ -78,7 +78,7 @@ pub struct Interpreter {
|
|||
}
|
||||
|
||||
impl Interpreter {
|
||||
pub fn interpret<'a>(&mut self, program: &Program<'a>) -> Result<(), Error> {
|
||||
pub fn interpret<'a>(&mut self, program: &Block<'a>) -> Result<(), Error> {
|
||||
for stmt in program {
|
||||
self.interpret_stmt(stmt)?;
|
||||
}
|
||||
|
|
@ -96,6 +96,7 @@ impl Interpreter {
|
|||
println!("{:?}", result)
|
||||
}
|
||||
Statement::Var(var) => return self.interpret_var(var),
|
||||
Statement::Block(_) => unimplemented!(),
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue