From 2df47cf5e375c73917ebcd6690cd16199d57af83 Mon Sep 17 00:00:00 2001 From: Rose Hogenson Date: Tue, 28 May 2024 18:12:02 -0700 Subject: Use num crate. --- src/parser.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/parser.rs') diff --git a/src/parser.rs b/src/parser.rs index 01f0e1b..b391202 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -1,7 +1,7 @@ +use crate::eval; +use crate::eval::Num; use crate::lexer::Lexer; -use crate::num; -use crate::num::Num; -use num_bigint::BigInt; +use num::BigInt; use std::str::FromStr; enum ParseError { @@ -70,17 +70,17 @@ impl<'a> Parser<'a> { return Err(ParseError::Consumed); }; if negative { - return Ok(num::float(-f)); + return Ok(eval::float(-f)); } - return Ok(num::float(f)); + return Ok(eval::float(f)); } let Ok(i) = BigInt::from_str(t) else { return Err(ParseError::Consumed); }; if negative { - return Ok(num::int(-i)); + return Ok(eval::int(-i)); } - Ok(num::int(i)) + Ok(eval::int(i)) } fn paren_expr(&mut self) -> Result { @@ -96,10 +96,10 @@ impl<'a> Parser<'a> { fn parse_const(&mut self) -> Result { if self.symbol("e") { - return Ok(num::float(std::f64::consts::E)); + return Ok(eval::float(std::f64::consts::E)); } if self.symbol("pi") { - return Ok(num::float(std::f64::consts::PI)); + return Ok(eval::float(std::f64::consts::PI)); } Err(ParseError::Empty) } -- cgit v1.3.1