Finished up to and including chapter 16

This commit is contained in:
Moritz Gmeiner 2023-01-30 17:41:48 +01:00
commit b86985deaf
24 changed files with 1051 additions and 198 deletions

View file

@ -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,