diff --git a/src/lib/builtins/variables.rs b/src/lib/builtins/variables.rs index eaf2ac9fe87976c90c165463ff717ab89e24b612..3ef89787ad3b482ba9483d7abcd2cebff8f000a2 100644 --- a/src/lib/builtins/variables.rs +++ b/src/lib/builtins/variables.rs @@ -23,15 +23,6 @@ enum Binding { ListEntries, KeyOnly(Identifier), KeyValue(Identifier, Value), - Math(Identifier, Operator, f32), - MathInvalid(Value), -} - -enum Operator { - Plus, - Minus, - Divide, - Multiply, } /// Parses alias as a `(key, value)` tuple. @@ -42,7 +33,6 @@ fn parse_alias(args: &str) -> Binding { // Find the key and advance the iterator until the equals operator is found. let mut key = "".to_owned(); let mut found_key = false; - let mut operator = None; // Scans through characters until the key is found, then continues to scan until // the equals operator is found. @@ -50,34 +40,6 @@ fn parse_alias(args: &str) -> Binding { match character { ' ' if key.is_empty() => (), ' ' => found_key = true, - '+' => { - if char_iter.next() == Some('=') { - operator = Some(Operator::Plus); - found_key = true; - } - break; - } - '-' => { - if char_iter.next() == Some('=') { - operator = Some(Operator::Minus); - found_key = true; - } - break; - } - '*' => { - if char_iter.next() == Some('=') { - operator = Some(Operator::Multiply); - found_key = true; - } - break; - } - '/' => { - if char_iter.next() == Some('=') { - operator = Some(Operator::Divide); - found_key = true; - } - break; - } '=' => { found_key = true; break; @@ -98,13 +60,7 @@ fn parse_alias(args: &str) -> Binding { } else if !Variables::is_valid_variable_name(&key) { Binding::InvalidKey(key) } else { - match operator { - Some(operator) => match value.parse::<f32>() { - Ok(value) => Binding::Math(key, operator, value), - Err(_) => Binding::MathInvalid(value), - }, - None => Binding::KeyValue(key, value), - } + Binding::KeyValue(key, value) } } } @@ -125,10 +81,6 @@ pub(crate) fn alias(vars: &mut Variables, args: &str) -> i32 { eprintln!("ion: please provide value for alias '{}'", key); return FAILURE; } - _ => { - eprintln!("ion: invalid alias syntax"); - return FAILURE; - } } SUCCESS } diff --git a/src/lib/shell/variables/mod.rs b/src/lib/shell/variables/mod.rs index 07a84de618a7c04233de22ee426fa5c67e7dc165..8a5cc047b951d9685f8f5c4e8abdd89967a384f1 100644 --- a/src/lib/shell/variables/mod.rs +++ b/src/lib/shell/variables/mod.rs @@ -315,7 +315,7 @@ impl Variables { } pub(crate) fn is_valid_variable_character(c: char) -> bool { - c.is_alphanumeric() || c == '_' || c == '?' || c == '.' + c.is_alphanumeric() || c == '_' || c == '?' || c == '.' || c == '-' || c == '+' } pub fn variables(&self) -> impl Iterator<Item = (&SmallString, &Value)> {