From 384f382cfc33b10d8b85b733788cdb69972e7fa7 Mon Sep 17 00:00:00 2001 From: Amneesh Singh Date: Sun, 30 Jul 2023 16:37:12 +0530 Subject: [PATCH] ast: random changes Signed-off-by: Amneesh Singh --- src/ast.rs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/ast.rs b/src/ast.rs index b989087..837c872 100644 --- a/src/ast.rs +++ b/src/ast.rs @@ -1,6 +1,5 @@ /// A very naive AST definition using recursive enums /// See the parser for implementation - use std::rc::Rc; pub type Parent = Vec; @@ -24,7 +23,8 @@ pub struct Module { pub enum ModuleChildren { Fn(Fn), Class(Class), - Statement(Statement), + Module(Module), + Const(Let), } #[derive(Debug)] @@ -45,22 +45,22 @@ pub enum ClassChildren { #[derive(Debug)] pub struct Fn { pub name: Rc, - pub return_typ: Option, - pub params: Vec<(Rc, Primitive)>, + pub return_ty: Option, + pub params: Vec<(Rc, Ty)>, pub children: Vec, } #[derive(Debug)] pub enum Statement { + Const(Let), Let(Let), Expr(Expr), - Block(Vec), } #[derive(Debug)] pub struct Let { pub name: Rc, - pub typ: Primitive, + pub ty: Ty, pub expr: Option, } @@ -73,6 +73,7 @@ pub enum Expr { Char(char), Op(Op, Box, Option>), If(Box, Box, Option>), + Block(Vec), Loop, Break, Continue, @@ -82,7 +83,7 @@ pub enum Expr { /// /// TODO: add arrays and pointers maybe #[derive(Debug)] -pub enum Primitive { +pub enum Ty { Int, Float, Char,