feat(tazjin/rlox): Implement tree-walk interpreter of exprs
This is only a subset of the Lox spec so far. It implements the language up to the runtime error chapter on https://craftinginterpreters.com/evaluating-expressions.html Change-Id: I295dbf4b6544420d6fe80b6aaba661fb21acdea6 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2281 Reviewed-by: tazjin <mail@tazj.in> Tested-by: BuildkiteCI
This commit is contained in:
parent
e115e58f9c
commit
bc6775c318
2 changed files with 74 additions and 10 deletions
|
|
@ -12,15 +12,15 @@ use crate::scanner::{Token, TokenKind};
|
|||
|
||||
#[derive(Debug)]
|
||||
pub struct Binary<'a> {
|
||||
left: Box<Expr<'a>>,
|
||||
operator: Token<'a>,
|
||||
right: Box<Expr<'a>>,
|
||||
pub left: Box<Expr<'a>>,
|
||||
pub operator: Token<'a>,
|
||||
pub right: Box<Expr<'a>>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Grouping<'a>(Box<Expr<'a>>);
|
||||
pub struct Grouping<'a>(pub Box<Expr<'a>>);
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub enum Literal {
|
||||
Boolean(bool),
|
||||
Number(f64),
|
||||
|
|
@ -30,8 +30,8 @@ pub enum Literal {
|
|||
|
||||
#[derive(Debug)]
|
||||
pub struct Unary<'a> {
|
||||
operator: Token<'a>,
|
||||
right: Box<Expr<'a>>,
|
||||
pub operator: Token<'a>,
|
||||
pub right: Box<Expr<'a>>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue