From 6f49283f8a8cd60b329a63fa46c7112c4e4bbb4f Mon Sep 17 00:00:00 2001 From: Rose Hogenson Date: Fri, 7 Jun 2024 09:01:40 -0700 Subject: Bring back bigint. --- src/parser.rs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'src/parser.rs') diff --git a/src/parser.rs b/src/parser.rs index 1e271a4..19e8e47 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -1,6 +1,7 @@ use crate::eval::Num; use crate::lexer::Lexer; use crate::op::{BinOp, Op, UnOp}; +use num::BigInt; use std::str::FromStr; enum Pending { @@ -54,7 +55,7 @@ impl<'a> Parser<'a> { self.result.push(Op::Num(Num::Float(f))); return Some(()); } - let Ok(i) = i128::from_str(t) else { + let Ok(i) = BigInt::from_str(t) else { return None; }; self.result.push(Op::Num(Num::Int(i))); @@ -130,10 +131,6 @@ impl<'a> Parser<'a> { self.stack.push(Pending::Un(UnOp::Round)); return true; } - if self.symbol("trunc") { - self.stack.push(Pending::Un(UnOp::Trunc)); - return true; - } if self.symbol("abs") { self.stack.push(Pending::Un(UnOp::Abs)); return true; @@ -261,8 +258,8 @@ pub fn parse(expr: &str) -> Option> { mod tests { use super::*; - fn int(i: i128) -> Op { - Op::Num(Num::Int(i)) + fn int(i: i64) -> Op { + Op::Num(Num::Int(BigInt::from(i))) } fn float(f: f64) -> Op { -- cgit v1.3.1