#[derive(Debug, PartialEq)]
pub enum StatementNode {
Function(Function), WhileLoop(WhileLoop), Variable(Variable), If(If), Expression(ExpressionNode), Return(ExpressionNode), }
#[derive(Debug, PartialEq)]
pub struct If {
pub condition: ExpressionNode,
pub body: Vec<StatementNode>,
}
#[derive(Debug, PartialEq)]
pub enum ExpressionNode {
BinOp(Box<ExpressionNode>, BinOp, Box<ExpressionNode>),
Constant(Constant),
VariablePoint(String),
FunctionCall(FunctionCall),
}
#[derive(Debug, PartialEq)]
pub enum BinOp {
Add,
Sub,
Div,
Mul,
Power,
Mod,
IsEqual,
NotEqual,
GreaterThan,
LessThan,
LessThanOrEqual,
GreaterThanOrEqual,
PlusAssign,
SubtractAssign,
Or,
And,
}
#[derive(Debug, PartialEq)]
pub struct WhileLoop {
pub condition: ExpressionNode,
pub body: Vec<StatementNode>,
}
#[derive(Debug, PartialEq)]
pub struct FunctionCall {
pub ident: String,
pub expr_params: Vec<ExpressionNode>,
}
#[derive(Debug, PartialEq)]
pub enum Constant {
Int(i32),
Str(String),
Bool(bool),
}
#[derive(Debug, PartialEq, Clone, Copy)]
pub enum VarType {
Int,
Str,
Bool,
Void,
}
#[derive(Debug, PartialEq)]
pub struct Function {
pub ident: String,
pub params: Vec<Parameter>,
pub body: Vec<StatementNode>,
pub docs: Option<String>,
pub return_type: VarType,
}
#[derive(Debug, PartialEq)]
pub struct Parameter {
pub ident: String,
pub ty: VarType,
}
#[derive(Debug, PartialEq)]
pub struct Variable {
pub ident: String,
pub ty: VarType,
pub body: Box<ExpressionNode>,
}