From f0840b54cd995450b85c18ce1274f5732ae97bcf Mon Sep 17 00:00:00 2001 From: nic-gaffney Date: Mon, 10 Apr 2023 20:38:28 -0500 Subject: ast thingy idk im new here --- crates/sloth/src/parser/ast.rs | 69 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) 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), // TODO: holy shit we forgor empty listys +} + pub enum Expr { BinaryOp { op: BinaryOp, @@ -30,4 +52,51 @@ pub enum Expr { op: UnaryOp, value: Box, }, + Call { + ident: Box, + args: Vec, + }, + Variable(String), + Literal(Literal), + Lambda, // TODO: Lambda bitch +} + +pub struct FuncArgs { + pub name: String, + pub typ: Option, } + +pub enum Stmt { + ExprStmt(Expr), + DefineFunction { + ident: String, + args: Vec, + body: Vec, + return_type: Option, + }, + DefineVariable { + name: String, + value: Expr, + typ: Option, + }, + DefineValue { + name: String, + value: Expr, + typ: Option, + }, + If { + expr: Vec, + body: Vec, + else_if: Vec<(Expr, Stmt)>, + els: Option>, + }, + For { + name: Expr, + iter: Expr, + body: Vec, + }, + While { + condition: Expr, + body: Vec, + }, +} \ No newline at end of file -- cgit v1.2.3