From bcc3b29fc5d47aac85461427452d8d36f2a5975d Mon Sep 17 00:00:00 2001 From: Amneesh Singh Date: Sun, 30 Jul 2023 01:51:13 +0530 Subject: [PATCH] ast: rename Type to Primitive Signed-off-by: Amneesh Singh --- src/ast.rs | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/ast.rs b/src/ast.rs index f3c1a2e..b989087 100644 --- a/src/ast.rs +++ b/src/ast.rs @@ -1,16 +1,7 @@ /// A very naive AST definition using recursive enums /// See the parser for implementation -use std::rc::Rc; -/// Primitives -/// -/// TODO: add arrays and pointers maybe -#[derive(Debug)] -pub enum Type { - Int, - Float, - Char, -} +use std::rc::Rc; pub type Parent = Vec; @@ -54,9 +45,9 @@ pub enum ClassChildren { #[derive(Debug)] pub struct Fn { pub name: Rc, - pub return_typ: Option, - pub params: Vec>, - pub block: Vec, + pub return_typ: Option, + pub params: Vec<(Rc, Primitive)>, + pub children: Vec, } #[derive(Debug)] @@ -69,7 +60,7 @@ pub enum Statement { #[derive(Debug)] pub struct Let { pub name: Rc, - pub typ: Type, + pub typ: Primitive, pub expr: Option, } @@ -86,3 +77,13 @@ pub enum Expr { Break, Continue, } + +/// Primitives +/// +/// TODO: add arrays and pointers maybe +#[derive(Debug)] +pub enum Primitive { + Int, + Float, + Char, +}