ast module

This commit is contained in:
2026-07-08 22:11:06 -05:00
parent db466bda9f
commit a0a7b85e11
+35 -8
View File
@@ -1,11 +1,38 @@
pub mod AST { pub trait Stmt {}
pub trait Expr: Stmt {}
pub enum NodeType { pub enum NodeType {
Program, Program(Program),
NumericLiteral, NumericLiteral(NumericLiteral),
Identifier, Identifier(Identifier),
BinaryExpression, BinaryExpr(BinaryExpr),
CallExperssion,
UnaryExpression,
FunctionDeclaration,
} }
pub struct Program {
pub body: Vec<NodeType>,
} }
pub struct BinaryExpr {
pub left: Box<NodeType>,
pub right: Box<NodeType>,
pub operator: String,
}
pub struct Identifier {
pub symbol: String,
}
pub struct NumericLiteral {
pub value: f64,
}
impl Stmt for Program {}
impl Stmt for NumericLiteral {}
impl Expr for NumericLiteral {}
impl Stmt for Identifier {}
impl Expr for Identifier {}
impl Stmt for BinaryExpr {}
impl Expr for BinaryExpr {}