aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/sloth/src/parser/ast.rs14
-rw-r--r--crates/sloth/src/parser/expr.rs7
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
+}