@@ -10,9 +10,8 @@
1010//! or := and ("or" and)*
1111//! and := not ("and" not)*
1212//! not := "not" not | compare
13−//! compare := concat (("==" | "!=" | "<" | ">" | "<=" | ">=" | "contains"
14−//! | "starts-with" | "ends-with") concat)?
15−//! concat := sum ("~" sum)*
13+//! compare := sum (("==" | "!=" | "<" | ">" | "<=" | ">=" | "contains"
14+//! | "starts-with" | "ends-with") sum)?
1615//! sum := product (("+" | "-") product)*
1716//! product := unary (("*" | "/" | "%") unary)*
1817//! unary := "-" unary | primary
@@ -112,7 +111,7 @@ impl fmt::Display for Token {
112111 }
113112}
114113
115−const OPERATORS: &[&str] = &["==", "!=", "<=", ">=", "<", ">", "+", "-", "*", "/", "%", "~"];
114+const OPERATORS: &[&str] = &["==", "!=", "<=", ">=", "<", ">", "+", "-", "*", "/", "%"];
116115
117116fn tokenize(src: &str) -> Result<Vec<Token>, String> {
118117 let chars: Vec<char> = src.chars().collect();
@@ -249,7 +248,7 @@ impl Parser<'_> {
249248 }
250249
251250 fn compare(&mut self) -> Result<Value, String> {
252− let left = self.concat()?;
251+ let left = self.sum()?;
253252 let op = if let Some(op) = self.eat_op(&["==", "!=", "<=", ">=", "<", ">"]) {
254253 op
255254 } else if self.eat_word("contains") {
@@ -261,7 +260,7 @@ impl Parser<'_> {
261260 } else {
262261 return Ok(left);
263262 };
264− let right = self.concat()?;
263+ let right = self.sum()?;
265264 let numbers = left.as_num().zip(right.as_num());
266265 let (l, r) = (left.to_string(), right.to_string());
267266 Ok(Value::Bool(match (op, numbers) {
@@ -284,15 +283,6 @@ impl Parser<'_> {
284283 }))
285284 }
286285
287− fn concat(&mut self) -> Result<Value, String> {
288− let mut left = self.sum()?;
289− while self.eat_op(&["~"]).is_some() {
290− let right = self.sum()?;
291− left = Value::Str(format!("{}{}", left, right));
292− }
293− Ok(left)
294− }
295−
296286 fn sum(&mut self) -> Result<Value, String> {
297287 let mut left = self.product()?;
298288 while let Some(op) = self.eat_op(&["+", "-"]) {
@@ -566,7 +556,6 @@ mod tests {
566556
567557 #[test]
568558 fn strings_and_if() {
569− assert_eq!(ev("\"Hello \" ~ $name").to_string(), "Hello World");
570559 assert_eq!(ev("\"Hi $name!\"").to_string(), "Hi World!");
571560 assert_eq!(ev("if($count > 2, big, small)").to_string(), "big");
572561 assert_eq!(ev("$missing").to_string(), "");