mirror of https://git.sr.ht/~garritfra/sabre
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
797 B
37 lines
797 B
#[derive(Debug)] |
|
pub struct Program { |
|
pub func: Vec<Function>, |
|
pub globals: Vec<String>, |
|
} |
|
|
|
#[derive(Debug)] |
|
pub struct Function { |
|
pub name: String, |
|
pub arguments: Vec<Variable>, |
|
pub statements: Vec<Statement>, |
|
} |
|
|
|
#[derive(Debug, Eq, PartialEq)] |
|
pub struct Variable { |
|
pub name: String, |
|
} |
|
|
|
#[derive(Debug, Eq, PartialEq)] |
|
pub enum Statement { |
|
Declare(Variable, Option<Expression>), |
|
Return(Option<Expression>), |
|
If(Expression, Box<Statement>, Option<Box<Statement>>), |
|
While(Expression, Box<Statement>), |
|
Exp(Expression), |
|
Compound(Vec<Statement>), |
|
} |
|
|
|
#[derive(Debug, Eq, PartialEq)] |
|
pub enum Expression { |
|
Int(u32), |
|
Str(String), |
|
Char(u8), |
|
FunctionCall(String, Vec<Expression>), |
|
Variable(String), |
|
Assign(String, Box<Expression>), |
|
}
|
|
|