mirror of
https://github.com/MorizzG/rlox.git
synced 2025-12-06 04:12:42 +00:00
Finished up to and including chapter 16
This commit is contained in:
parent
647a095a05
commit
b86985deaf
24 changed files with 1051 additions and 198 deletions
|
|
@ -55,9 +55,9 @@ pub enum Expr {
|
|||
value: Box<Expr>,
|
||||
},
|
||||
Function {
|
||||
name: Box<String>,
|
||||
param_names: Box<Vec<String>>,
|
||||
closure_vars: Box<Vec<(String, usize)>>,
|
||||
name: String,
|
||||
param_names: Vec<String>,
|
||||
closure_vars: Vec<(String, usize)>,
|
||||
body: Box<Stmt>,
|
||||
},
|
||||
Class {
|
||||
|
|
@ -137,10 +137,11 @@ impl Expr {
|
|||
}
|
||||
|
||||
pub fn function(name: String, param_names: Vec<String>, body: Stmt) -> Self {
|
||||
let name = Box::new(name);
|
||||
let param_names = Box::new(param_names);
|
||||
// let name = Box::new(name);
|
||||
// let param_names = Box::new(param_names);
|
||||
#[allow(clippy::box_default)]
|
||||
let closure_vars = Box::new(Vec::new());
|
||||
// let closure_vars = Box::new(Vec::new());
|
||||
let closure_vars = Vec::new();
|
||||
let body = Box::new(body);
|
||||
Self::Function {
|
||||
name,
|
||||
|
|
@ -258,7 +259,7 @@ impl Display for UnaryOp {
|
|||
|
||||
/*====================================================================================================================*/
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[rustfmt::skip]
|
||||
pub enum BinaryOp {
|
||||
// arithmetic
|
||||
|
|
@ -289,7 +290,7 @@ impl Display for BinaryOp {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum LogicalOp {
|
||||
Or,
|
||||
And,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue