rat/src/stmt.rs
2026-06-17 21:02:41 +02:00

32 lines
No EOL
741 B
Rust

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
}