aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs
index ddad9b4..c111bf1 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -35,6 +35,7 @@ use rustyline::config::{ Builder, ColorMode, EditMode };
35 35
36 36
37fn main() { 37fn main() {
38
38 let args: Vec<String> = env::args().collect(); 39 let args: Vec<String> = env::args().collect();
39 if args.len() > 1 { 40 if args.len() > 1 {
40 let mut expr = String::new(); 41 let mut expr = String::new();
@@ -114,6 +115,9 @@ fn autobalance_parens(input: &str) -> Result<String, CalcError> {
114} 115}
115 116
116fn eval_math_expression(input: &str) -> Result<f64, CalcError> { 117fn eval_math_expression(input: &str) -> Result<f64, CalcError> {
118 if input.len() == 0 {
119 return Ok(0.)
120 }
117 let input = autobalance_parens(&input[..])?; 121 let input = autobalance_parens(&input[..])?;
118 let lexed = lexer(&input[..])?; 122 let lexed = lexer(&input[..])?;
119 let postfixed = to_postfix(lexed)?; 123 let postfixed = to_postfix(lexed)?;