diff options
| author | nic-gaffney <gaffney_nic@protonmail.com> | 2023-04-10 23:15:02 -0500 |
|---|---|---|
| committer | nic-gaffney <gaffney_nic@protonmail.com> | 2023-04-10 23:15:02 -0500 |
| commit | b5befbb1e4b96013421458769fa95c5b53fbc03e (patch) | |
| tree | 568913d487858ea9da3eef5e1f92c084bb25b50e /crates | |
| parent | 047ce431153c3b39b22e18eac3c149d2e12a9fd6 (diff) | |
| download | sloth-b5befbb1e4b96013421458769fa95c5b53fbc03e.tar.gz | |
Stole the old code and refactored it for the new shit, gonna go and change some shit up in the future
Diffstat (limited to 'crates')
| -rw-r--r-- | crates/sloth/src/parser/ast.rs | 14 | ||||
| -rw-r--r-- | crates/sloth/src/parser/expr.rs | 7 |
2 files changed, 9 insertions, 12 deletions
diff --git a/crates/sloth/src/parser/ast.rs b/crates/sloth/src/parser/ast.rs index d472269..c008905 100644 --- a/crates/sloth/src/parser/ast.rs +++ b/crates/sloth/src/parser/ast.rs @@ -1,6 +1,5 @@ use crate::lexer::{Token, TokenType}; -#[derive(Debug)] -#[derive(PartialEq)] +#[derive(Debug, PartialEq)] pub enum BinaryOp { Add, Con, @@ -25,16 +24,14 @@ pub enum BinaryOp { LogAnd, LogOr, } -#[derive(Debug)] -#[derive(PartialEq)] +#[derive(Debug, PartialEq)] pub enum UnaryOp { Not, Neg, BWComp, } -#[derive(Debug)] -#[derive(PartialEq)] +#[derive(Debug, PartialEq)] pub enum Literal { Integer(i128), Float(f64), @@ -44,13 +41,12 @@ pub enum Literal { Regex(String), List(Vec<Expr>), // TODO: holy shit we forgor listys } -#[derive(Debug)] -#[derive(PartialEq)] +#[derive(Debug, PartialEq)] pub enum Expr { Grouping(Box<Expr>), BinaryOp { op: BinaryOp, - lhs: Box<Expr>, + lhs: Box<Expr>, rhs: Box<Expr>, }, UnaryOp { diff --git a/crates/sloth/src/parser/expr.rs b/crates/sloth/src/parser/expr.rs index 84aab31..7cce919 100644 --- a/crates/sloth/src/parser/expr.rs +++ b/crates/sloth/src/parser/expr.rs @@ -146,9 +146,10 @@ impl<'a> AstParser<'a> { #[cfg(test)] mod tests { use itertools::Itertools; - use super::{AstParser, BinaryOp, Expr, Literal}; - use crate::{lexer::{Lexer}, parser::ast::UnaryOp}; + use super::{AstParser, BinaryOp, Expr, Literal}; + use crate::lexer::Lexer; + use crate::parser::ast::UnaryOp; #[test] fn basic_expression_a() { @@ -204,4 +205,4 @@ mod tests { assert_eq!(expected_ast, generated_ast); } -}
\ No newline at end of file +} |
