From 8a61f0c0712b4553622379aa7c36a710a5701542 Mon Sep 17 00:00:00 2001 From: NerdyPepper Date: Fri, 29 Mar 2019 19:50:21 +0530 Subject: handle some more errors --- src/lex/mod.rs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src') diff --git a/src/lex/mod.rs b/src/lex/mod.rs index c0c4f84..39538ca 100644 --- a/src/lex/mod.rs +++ b/src/lex/mod.rs @@ -120,6 +120,13 @@ pub fn lexer(input: &str) -> Result, CalcError> { for letter in input.chars() { match letter { '0'...'9' | '.' => { + if char_vec.len() > 0 { + if let Some(_) = functions.get(&char_vec[..]) { + return Err(CalcError::Syntax(format!("Function '{}' expected parentheses", char_vec))) + } else { + return Err(CalcError::Syntax(format!("Unexpected character '{}'", char_vec))) + } + } num_vec.push(letter); last_char_is_op = false; }, -- cgit v1.2.3