aboutsummaryrefslogtreecommitdiffstats
path: root/src/parser.rs
diff options
context:
space:
mode:
authorRose Hogenson <rosehogenson@posteo.net>2024-06-07 09:01:40 -0700
committerRose Hogenson <rosehogenson@posteo.net>2024-06-07 09:01:40 -0700
commit6f49283f8a8cd60b329a63fa46c7112c4e4bbb4f (patch)
treeec82142d7981eee19875a761370748363362154d /src/parser.rs
parentdbc36c472daeab34f7f71193d3b69edea19d9a23 (diff)
downloadqc-6f49283f8a8cd60b329a63fa46c7112c4e4bbb4f.tar.zst
Bring back bigint.
Diffstat (limited to 'src/parser.rs')
-rw-r--r--src/parser.rs11
1 files changed, 4 insertions, 7 deletions
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<Vec<Op>> {
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 {