aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNerdyPepper <[email protected]>2019-03-29 14:20:21 +0000
committerNerdyPepper <[email protected]>2019-03-29 14:20:21 +0000
commit8a61f0c0712b4553622379aa7c36a710a5701542 (patch)
tree786f16715ad6a85622ed9cbf4a637de4a216fafc /src
parent0141442b04bc1a2c78e8d179b972976adf360275 (diff)
handle some more errors
Diffstat (limited to 'src')
-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 },