From a0a7b85e117ae2eb0243a417f6d84f44e21908a2 Mon Sep 17 00:00:00 2001 From: Maaz Khokhar Date: Wed, 8 Jul 2026 22:11:06 -0500 Subject: [PATCH] ast module --- src/ast.rs | 47 +++++++++++++++++++++++++++++++++++++---------- 1 file changed, 37 insertions(+), 10 deletions(-) diff --git a/src/ast.rs b/src/ast.rs index d79b436..cefc518 100644 --- a/src/ast.rs +++ b/src/ast.rs @@ -1,11 +1,38 @@ -pub mod AST { - pub enum NodeType { - Program, - NumericLiteral, - Identifier, - BinaryExpression, - CallExperssion, - UnaryExpression, - FunctionDeclaration, - } +pub trait Stmt {} +pub trait Expr: Stmt {} + +pub enum NodeType { + Program(Program), + NumericLiteral(NumericLiteral), + Identifier(Identifier), + BinaryExpr(BinaryExpr), } + +pub struct Program { + pub body: Vec, +} + +pub struct BinaryExpr { + pub left: Box, + pub right: Box, + 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 {}