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,