mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-16 00:56:23 +00:00
revset: decouple prefix/infix/postfix range operators
This unblocks the use of PrattParser, which builds an operator map keyed solely by Rule, not by (Rule, prefix/infix/postfix) pair.
This commit is contained in:
parent
f8aa6b1deb
commit
5491b5581f
2 changed files with 11 additions and 5 deletions
|
@ -28,8 +28,14 @@ parents_op = { "-" }
|
||||||
children_op = { "+" }
|
children_op = { "+" }
|
||||||
|
|
||||||
dag_range_op = { ":" }
|
dag_range_op = { ":" }
|
||||||
|
dag_range_pre_op = { ":" }
|
||||||
|
dag_range_post_op = { ":" }
|
||||||
range_op = { ".." }
|
range_op = { ".." }
|
||||||
|
range_pre_op = { ".." }
|
||||||
|
range_post_op = { ".." }
|
||||||
range_ops = _{ dag_range_op | range_op }
|
range_ops = _{ dag_range_op | range_op }
|
||||||
|
range_pre_ops = _{ dag_range_pre_op | range_pre_op }
|
||||||
|
range_post_ops = _{ dag_range_post_op | range_post_op }
|
||||||
|
|
||||||
union_op = { "|" }
|
union_op = { "|" }
|
||||||
intersection_op = { "&" }
|
intersection_op = { "&" }
|
||||||
|
@ -52,8 +58,8 @@ neighbors_expression = { primary ~ (parents_op | children_op)* }
|
||||||
|
|
||||||
range_expression = {
|
range_expression = {
|
||||||
neighbors_expression ~ range_ops ~ neighbors_expression
|
neighbors_expression ~ range_ops ~ neighbors_expression
|
||||||
| neighbors_expression ~ range_ops
|
| neighbors_expression ~ range_post_ops
|
||||||
| range_ops ~ neighbors_expression
|
| range_pre_ops ~ neighbors_expression
|
||||||
| neighbors_expression
|
| neighbors_expression
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -518,7 +518,7 @@ fn parse_range_expression_rule(
|
||||||
) -> Result<Rc<RevsetExpression>, RevsetParseError> {
|
) -> Result<Rc<RevsetExpression>, RevsetParseError> {
|
||||||
let first = pairs.next().unwrap();
|
let first = pairs.next().unwrap();
|
||||||
match first.as_rule() {
|
match first.as_rule() {
|
||||||
Rule::dag_range_op | Rule::range_op => {
|
Rule::dag_range_pre_op | Rule::range_pre_op => {
|
||||||
return Ok(parse_neighbors_expression_rule(
|
return Ok(parse_neighbors_expression_rule(
|
||||||
pairs.next().unwrap().into_inner(),
|
pairs.next().unwrap().into_inner(),
|
||||||
workspace_ctx,
|
workspace_ctx,
|
||||||
|
@ -535,7 +535,7 @@ fn parse_range_expression_rule(
|
||||||
let mut expression = parse_neighbors_expression_rule(first.into_inner(), workspace_ctx)?;
|
let mut expression = parse_neighbors_expression_rule(first.into_inner(), workspace_ctx)?;
|
||||||
if let Some(next) = pairs.next() {
|
if let Some(next) = pairs.next() {
|
||||||
match next.as_rule() {
|
match next.as_rule() {
|
||||||
Rule::dag_range_op => {
|
Rule::dag_range_op | Rule::dag_range_post_op => {
|
||||||
if let Some(heads_pair) = pairs.next() {
|
if let Some(heads_pair) = pairs.next() {
|
||||||
let heads_expression =
|
let heads_expression =
|
||||||
parse_neighbors_expression_rule(heads_pair.into_inner(), workspace_ctx)?;
|
parse_neighbors_expression_rule(heads_pair.into_inner(), workspace_ctx)?;
|
||||||
|
@ -544,7 +544,7 @@ fn parse_range_expression_rule(
|
||||||
expression = expression.descendants();
|
expression = expression.descendants();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Rule::range_op => {
|
Rule::range_op | Rule::range_post_op => {
|
||||||
if let Some(heads_pair) = pairs.next() {
|
if let Some(heads_pair) = pairs.next() {
|
||||||
let heads_expression =
|
let heads_expression =
|
||||||
parse_neighbors_expression_rule(heads_pair.into_inner(), workspace_ctx)?;
|
parse_neighbors_expression_rule(heads_pair.into_inner(), workspace_ctx)?;
|
||||||
|
|
Loading…
Reference in a new issue