added statement parsing

This commit is contained in:
Raptorox 2026-06-17 21:02:41 +02:00
parent a21b119e58
commit 9932c83d6f
No known key found for this signature in database
GPG key ID: 8B3556FC3ED1F6D8
4 changed files with 226 additions and 17 deletions

32
src/stmt.rs Normal file
View file

@ -0,0 +1,32 @@
use crate::expr::Expr;
#[derive(Debug)]
pub enum CondOp {
Eq,
Neq,
Lt,
Gt,
Lte,
Gte
}
#[derive(Debug)]
pub struct Condition {
pub op: CondOp,
pub left: Expr,
pub right: Expr
}
#[derive(Debug)]
pub enum Stmt {
Mov { src: Expr, dst: String },
IfElse { condition: Condition, then: Vec<Stmt>, else_: Option<Vec<Stmt>> },
Loop { body: Vec<Stmt> },
While { condition: Condition, body: Vec<Stmt> },
ForRange { var: String, start: Expr, end: Expr, step: Option<Expr>, body: Vec<Stmt> },
ForIn { var: String, list: Expr, body: Vec<Stmt> },
Call { name: String, args: Vec<Expr> },
FuncDef { name: String, params: Vec<String>, body: Vec<Stmt> },
Break,
Continue
}