diff --git a/lib/src/revset.pest b/lib/src/revset.pest index e6395a134..f79675c5c 100644 --- a/lib/src/revset.pest +++ b/lib/src/revset.pest @@ -16,14 +16,14 @@ symbol = @{ (ASCII_ALPHANUMERIC | "@" | "/" | ".")+ } literal_string = { "\"" ~ (!"\"" ~ ANY)+ ~ "\"" } whitespace = _{ " " } -parents = { ":" } -ancestors = { "*:" } -prefix_operator = _{ parents | ancestors } +parents_op = { ":" } +ancestors_op = { "*:" } +prefix_op = _{ parents_op | ancestors_op } -union = { "|" } -intersection = { "&" } -difference = { "-" } -infix_operator = _{ union| intersection | difference } +union_op = { "|" } +intersection_op = { "&" } +difference_op = { "-" } +infix_op = _{ union_op | intersection_op | difference_op } function_name = @{ (ASCII_ALPHANUMERIC | "_")+ } // The grammar accepts a string literal or an expression for function @@ -48,10 +48,10 @@ primary = { | symbol } -prefix_expression = { prefix_operator* ~ primary } +prefix_expression = { prefix_op* ~ primary } infix_expression = { - whitespace* ~ prefix_expression ~ whitespace* ~ (infix_operator ~ whitespace* ~ prefix_expression ~ whitespace*)* + whitespace* ~ prefix_expression ~ whitespace* ~ (infix_op ~ whitespace* ~ prefix_expression ~ whitespace*)* } expression = { diff --git a/lib/src/revset.rs b/lib/src/revset.rs index eff9241de..4193183bd 100644 --- a/lib/src/revset.rs +++ b/lib/src/revset.rs @@ -136,14 +136,14 @@ fn parse_infix_expression_rule( while let Some(operator) = pairs.next() { let expression2 = parse_prefix_expression_rule(pairs.next().unwrap().into_inner())?; match operator.as_rule() { - Rule::union => { + Rule::union_op => { expression1 = RevsetExpression::Union(Box::new(expression1), Box::new(expression2)) } - Rule::intersection => { + Rule::intersection_op => { expression1 = RevsetExpression::Intersection(Box::new(expression1), Box::new(expression2)) } - Rule::difference => { + Rule::difference_op => { expression1 = RevsetExpression::Difference(Box::new(expression1), Box::new(expression2)) } @@ -164,10 +164,10 @@ fn parse_prefix_expression_rule( let first = pairs.next().unwrap(); match first.as_rule() { Rule::primary => parse_primary_rule(first.into_inner()), - Rule::parents => Ok(RevsetExpression::Parents(Box::new( + Rule::parents_op => Ok(RevsetExpression::Parents(Box::new( parse_prefix_expression_rule(pairs)?, ))), - Rule::ancestors => Ok(RevsetExpression::Ancestors(Box::new( + Rule::ancestors_op => Ok(RevsetExpression::Ancestors(Box::new( parse_prefix_expression_rule(pairs)?, ))), _ => {