diff options
| author | nic-gaffney <gaffney_nic@protonmail.com> | 2023-04-10 20:38:28 -0500 |
|---|---|---|
| committer | nic-gaffney <gaffney_nic@protonmail.com> | 2023-04-10 20:38:28 -0500 |
| commit | f0840b54cd995450b85c18ce1274f5732ae97bcf (patch) | |
| tree | 495cb5c87bb42e5bcb4b3b95f163ad5859f70d81 | |
| parent | 949acb3de2d1166a8c521af974e099a47dfd739f (diff) | |
| download | sloth-f0840b54cd995450b85c18ce1274f5732ae97bcf.tar.gz | |
ast thingy idk im new here
| -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 |
