aboutsummaryrefslogtreecommitdiff
path: root/src/lex/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/lex/mod.rs')
-rw-r--r--src/lex/mod.rs7
1 files changed, 7 insertions, 0 deletions
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<Vec<Token>, CalcError> {
120 for letter in input.chars() { 120 for letter in input.chars() {
121 match letter { 121 match letter {
122 '0'...'9' | '.' => { 122 '0'...'9' | '.' => {
123 if char_vec.len() > 0 {
124 if let Some(_) = functions.get(&char_vec[..]) {
125 return Err(CalcError::Syntax(format!("Function '{}' expected parentheses", char_vec)))
126 } else {
127 return Err(CalcError::Syntax(format!("Unexpected character '{}'", char_vec)))
128 }
129 }
123 num_vec.push(letter); 130 num_vec.push(letter);
124 last_char_is_op = false; 131 last_char_is_op = false;
125 }, 132 },