Minimal AST

This commit is contained in:
numzero 2025-04-11 19:14:50 +03:00
parent a8e7f57e07
commit 6e908ad4a2
2 changed files with 42 additions and 0 deletions

41
src/ast.rs Normal file
View File

@ -0,0 +1,41 @@
#[derive(Debug, Clone)]
pub enum Statement {
Assign {
target: Location,
source: Box<Expression>,
},
Call {
callee: String,
args: Vec<Expression>,
},
}
#[derive(Debug, Clone)]
pub enum Location {
Variable {
name: String,
},
Field {
table: Box<Location>,
index: Box<Expression>,
},
}
#[derive(Debug, Clone)]
pub enum Expression {
Constant(Constant),
Variable(Location),
Call {
callee: String,
args: Vec<Expression>,
},
}
#[derive(Debug, Clone, Default)]
pub enum Constant {
#[default]
Nil,
Boolean(bool),
Number(i64),
String(String),
}

View File

@ -1,2 +1,3 @@
pub mod ast;
pub mod scope; pub mod scope;
pub mod types; pub mod types;