From 4eb476c2b70d3aafcc8e84fe5b799ed6e5713805 Mon Sep 17 00:00:00 2001 From: Mark Date: Mon, 27 Mar 2023 10:55:14 -0700 Subject: [PATCH] Fixed unary operators --- src/parser/treeify.rs | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/src/parser/treeify.rs b/src/parser/treeify.rs index a762ac3..f9359c9 100644 --- a/src/parser/treeify.rs +++ b/src/parser/treeify.rs @@ -1,7 +1,6 @@ use std::collections::VecDeque; use crate::tokens::Token; -use crate::tokens::Operator; use crate::tokens::LineLocation; use crate::parser::ParserError; @@ -165,17 +164,9 @@ fn treeify_unary( if prev.is_some() { if let Token::PreOperator(l, o) = prev.unwrap() { - match o { - // Left unary operators - Operator::Negative => { - let tl = *this.get_line_location(); - return Err(( - LineLocation{pos: tl.pos, len: l.pos - tl.pos + l.len}, - ParserError::Syntax - )); - }, - _ => {}, - }; + if o.is_left_associative() && left_associative { + return Err((*l, ParserError::Syntax)); + } } else { return Err(( *this.get_line_location(),