From fde7d934187f2919a3cf08b6361885951dad6e3e Mon Sep 17 00:00:00 2001 From: Rose Hogenson Date: Thu, 30 May 2024 06:59:27 -0700 Subject: Fix unary minus. Unary minus needs to bind more closely than ^, in order to parse -2^2 correctly. --- src/parser.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/parser.rs b/src/parser.rs index 4a87fda..badf286 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -72,7 +72,7 @@ impl<'a> Parser<'a> { fn parse_fun(&mut self) -> bool { if self.symbol("-") { self.stack.push(Op::Op { - prec: 0, + prec: 3, eval: Box::new(|n| eval::int(0).sub(n)), }); return true; -- cgit v1.3.1