ok/jj
1
0
Fork 0
forked from mirrors/jj

revset: reuse parse_symbol_rule_as_literal() to parse string symbol

For the same reason as the previous commit. Single-quoted string literal will
be handled there.
This commit is contained in:
Yuya Nishihara 2024-04-17 22:14:12 +09:00
parent 37bd966357
commit a74bf89df5

View file

@ -1082,10 +1082,10 @@ fn parse_string_pattern_rule(
/// Parses symbol to expression, expands aliases as needed.
fn parse_symbol_rule(
mut pairs: Pairs<Rule>,
pairs: Pairs<Rule>,
state: ParseState,
) -> Result<Rc<RevsetExpression>, RevsetParseError> {
let first = pairs.next().unwrap();
let first = pairs.peek().unwrap();
match first.as_rule() {
Rule::identifier => {
let name = first.as_str();
@ -1101,11 +1101,9 @@ fn parse_symbol_rule(
Ok(RevsetExpression::symbol(name.to_owned()))
}
}
Rule::string_literal => Ok(RevsetExpression::symbol(
STRING_LITERAL_PARSER.parse(first.into_inner()),
)),
_ => {
panic!("unexpected symbol parse rule: {:?}", first.as_str());
let text = parse_symbol_rule_as_literal(pairs);
Ok(RevsetExpression::symbol(text))
}
}
}