Minimal AST
This commit is contained in:
parent
a8e7f57e07
commit
6e908ad4a2
41
src/ast.rs
Normal file
41
src/ast.rs
Normal 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),
|
||||||
|
}
|
||||||
|
|
@ -1,2 +1,3 @@
|
||||||
|
pub mod ast;
|
||||||
pub mod scope;
|
pub mod scope;
|
||||||
pub mod types;
|
pub mod types;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user