forked from mirrors/jj
revset: rename Rule::literal_string to string_literal
This commit is contained in:
parent
274183fa66
commit
d1ae2d72c8
2 changed files with 7 additions and 7 deletions
|
@ -19,9 +19,9 @@ identifier = @{
|
||||||
}
|
}
|
||||||
symbol = {
|
symbol = {
|
||||||
identifier
|
identifier
|
||||||
| literal_string
|
| string_literal
|
||||||
}
|
}
|
||||||
literal_string = { "\"" ~ (!"\"" ~ ANY)* ~ "\"" }
|
string_literal = { "\"" ~ (!"\"" ~ ANY)* ~ "\"" }
|
||||||
whitespace = _{ " " | "\t" | "\r" | "\n" | "\x0c" }
|
whitespace = _{ " " | "\t" | "\r" | "\n" | "\x0c" }
|
||||||
|
|
||||||
at_op = { "@" }
|
at_op = { "@" }
|
||||||
|
@ -67,7 +67,7 @@ formal_parameters = {
|
||||||
| ""
|
| ""
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: change rhs to literal_string to require quoting? #2101
|
// TODO: change rhs to string_literal to require quoting? #2101
|
||||||
string_pattern = { identifier ~ pattern_kind_op ~ symbol }
|
string_pattern = { identifier ~ pattern_kind_op ~ symbol }
|
||||||
|
|
||||||
primary = {
|
primary = {
|
||||||
|
|
|
@ -97,7 +97,7 @@ impl Rule {
|
||||||
Rule::identifier_part => None,
|
Rule::identifier_part => None,
|
||||||
Rule::identifier => None,
|
Rule::identifier => None,
|
||||||
Rule::symbol => None,
|
Rule::symbol => None,
|
||||||
Rule::literal_string => None,
|
Rule::string_literal => None,
|
||||||
Rule::whitespace => None,
|
Rule::whitespace => None,
|
||||||
Rule::at_op => Some("@"),
|
Rule::at_op => Some("@"),
|
||||||
Rule::pattern_kind_op => Some(":"),
|
Rule::pattern_kind_op => Some(":"),
|
||||||
|
@ -1090,7 +1090,7 @@ fn parse_symbol_rule(
|
||||||
Ok(RevsetExpression::symbol(name.to_owned()))
|
Ok(RevsetExpression::symbol(name.to_owned()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Rule::literal_string => parse_string_literal(first).map(RevsetExpression::symbol),
|
Rule::string_literal => parse_string_literal(first).map(RevsetExpression::symbol),
|
||||||
_ => {
|
_ => {
|
||||||
panic!("unexpected symbol parse rule: {:?}", first.as_str());
|
panic!("unexpected symbol parse rule: {:?}", first.as_str());
|
||||||
}
|
}
|
||||||
|
@ -1102,7 +1102,7 @@ fn parse_symbol_rule_as_literal(mut pairs: Pairs<Rule>) -> Result<String, Revset
|
||||||
let first = pairs.next().unwrap();
|
let first = pairs.next().unwrap();
|
||||||
match first.as_rule() {
|
match first.as_rule() {
|
||||||
Rule::identifier => Ok(first.as_str().to_owned()),
|
Rule::identifier => Ok(first.as_str().to_owned()),
|
||||||
Rule::literal_string => parse_string_literal(first),
|
Rule::string_literal => parse_string_literal(first),
|
||||||
_ => {
|
_ => {
|
||||||
panic!("unexpected symbol parse rule: {:?}", first.as_str());
|
panic!("unexpected symbol parse rule: {:?}", first.as_str());
|
||||||
}
|
}
|
||||||
|
@ -1111,7 +1111,7 @@ fn parse_symbol_rule_as_literal(mut pairs: Pairs<Rule>) -> Result<String, Revset
|
||||||
|
|
||||||
// TODO: Add support for \-escape syntax
|
// TODO: Add support for \-escape syntax
|
||||||
fn parse_string_literal(pair: Pair<Rule>) -> Result<String, RevsetParseError> {
|
fn parse_string_literal(pair: Pair<Rule>) -> Result<String, RevsetParseError> {
|
||||||
assert_eq!(pair.as_rule(), Rule::literal_string);
|
assert_eq!(pair.as_rule(), Rule::string_literal);
|
||||||
Ok(pair
|
Ok(pair
|
||||||
.as_str()
|
.as_str()
|
||||||
.strip_prefix('"')
|
.strip_prefix('"')
|
||||||
|
|
Loading…
Reference in a new issue