#[derive(Debug, Clone, PartialEq)] pub struct Program { pub decls: Vec, } #[derive(Debug, Clone, PartialEq)] pub enum Decl { Struct(StructDecl), Fn(FnDecl), TypeAlias(String, TypeExpr), } #[derive(Debug, Clone, PartialEq)] pub struct StructDecl { pub name: String, pub fields: Vec, } #[derive(Debug, Clone, PartialEq)] pub struct FieldDecl { pub name: String, pub ty: TypeExpr, } #[derive(Debug, Clone, PartialEq)] pub struct FnDecl { pub is_pure: bool, pub is_gpu: bool, pub name: String, pub params: Vec, pub return_type: TypeExpr, pub body: Block, } #[derive(Debug, Clone, PartialEq)] pub struct Param { pub name: String, pub ty: TypeExpr, } #[derive(Debug, Clone, PartialEq)] pub struct Block { pub statements: Vec, } #[derive(Debug, Clone, PartialEq)] pub enum Stmt { Return(Expr), ExprStmt(Expr), LetBind(String, Expr), } #[derive(Debug, Clone, PartialEq)] pub enum Expr { Binary(Box, BinaryOp, Box), Literal(String), Identifier(String), } #[derive(Debug, Clone, PartialEq, Eq)] pub enum BinaryOp { Add, Sub, Mul, Div, Gt, Lt, Eq, } #[derive(Debug, Clone, PartialEq)] pub enum TypeExpr { BaseType(String), Refined(Box, String, Box), }