diff options
| -rw-r--r-- | crates/sloth/src/parser/ast.rs | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/crates/sloth/src/parser/ast.rs b/crates/sloth/src/parser/ast.rs index 85309a5..3e710d0 100644 --- a/crates/sloth/src/parser/ast.rs +++ b/crates/sloth/src/parser/ast.rs @@ -1,3 +1,5 @@ +use super::stmt; + pub enum BinaryOp { Add, Con, @@ -5,12 +7,22 @@ pub enum BinaryOp { Mul, Pow, Div, + Mod, BWSftRight, BWSftLeft, BWAnd, BWOr, BWXor, + + Lt, + Gt, + LtEq, + GtEq, + EqEq, + NotEq, + LogAnd, + LogOr, } pub enum UnaryOp { @@ -20,6 +32,16 @@ pub enum UnaryOp { BWComp, } +pub enum Literal { + Integer(i128), + Float(f64), + Bool(bool), + Char(char), + String(String), + Regex(String), + List(Vec<Expr>), // TODO: holy shit we forgor empty listys +} + pub enum Expr { BinaryOp { op: BinaryOp, @@ -30,4 +52,51 @@ pub enum Expr { op: UnaryOp, value: Box<Expr>, }, + Call { + ident: Box<Expr>, + args: Vec<Expr>, + }, + Variable(String), + Literal(Literal), + Lambda, // TODO: Lambda bitch +} + +pub struct FuncArgs { + pub name: String, + pub typ: Option<String>, } + +pub enum Stmt { + ExprStmt(Expr), + DefineFunction { + ident: String, + args: Vec<FuncArgs>, + body: Vec<Stmt>, + return_type: Option<String>, + }, + DefineVariable { + name: String, + value: Expr, + typ: Option<String>, + }, + DefineValue { + name: String, + value: Expr, + typ: Option<String>, + }, + If { + expr: Vec<Expr>, + body: Vec<Stmt>, + else_if: Vec<(Expr, Stmt)>, + els: Option<Box<Stmt>>, + }, + For { + name: Expr, + iter: Expr, + body: Vec<Stmt>, + }, + While { + condition: Expr, + body: Vec<Stmt>, + }, +}
\ No newline at end of file |
