added statement parsing
This commit is contained in:
parent
a21b119e58
commit
9932c83d6f
4 changed files with 226 additions and 17 deletions
32
src/stmt.rs
Normal file
32
src/stmt.rs
Normal 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
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue