Skip to content

Commit

Permalink
Remove single string literal pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
dhruvmanila committed Sep 7, 2023
1 parent c631b8b commit 0f3792b
Show file tree
Hide file tree
Showing 3 changed files with 9,570 additions and 10,032 deletions.
12 changes: 3 additions & 9 deletions crates/ruff_python_parser/src/python.lalrpop
Original file line number Diff line number Diff line change
Expand Up @@ -669,11 +669,7 @@ LiteralPattern: ast::Pattern = {
value: Box::new(value.into()),
range: (location..end_location).into()
}.into(),
<location:@L> <string:StringLiteralOrFString> <end_location:@R> => ast::PatternMatchValue {
value: Box::new(string.with_range((location..end_location).into()).into()),
range: (location..end_location).into()
}.into(),
<location:@L> <strings:TwoOrMoreConsecutive<StringLiteralOrFString>> <end_location:@L> =>? Ok(ast::PatternMatchValue {
<location:@L> <strings:StringLiteralOrFString+> <end_location:@L> =>? Ok(ast::PatternMatchValue {
value: Box::new(concatenate_strings(strings, (location..end_location).into())?),
range: (location..end_location).into()
}.into()),
Expand Down Expand Up @@ -731,8 +727,7 @@ MappingKey: ast::Expr = {
value: false.into(),
range: (location..end_location).into()
}.into(),
<location:@L> <string:StringLiteralOrFString> <end_location:@R> => string.with_range((location..end_location).into()).into(),
<location:@L> <strings:TwoOrMoreConsecutive<StringLiteralOrFString>> <end_location:@L> =>? Ok(concatenate_strings(strings, (location..end_location).into())?),
<location:@L> <strings:StringLiteralOrFString+> <end_location:@L> =>? Ok(concatenate_strings(strings, (location..end_location).into())?),
}

MatchMappingEntry: (ast::Expr, ast::Pattern) = {
Expand Down Expand Up @@ -1671,8 +1666,7 @@ FStringConversion: (TextSize, ast::ConversionFlag) = {
};

Atom<Goal>: ast::ParenthesizedExpr = {
<location:@L> <string:StringLiteralOrFString> <end_location:@R> => string.with_range((location..end_location).into()).into(),
<location:@L> <strings:TwoOrMoreConsecutive<StringLiteralOrFString>> <end_location:@L> =>? Ok(concatenate_strings(strings, (location..end_location).into())?.into()),
<location:@L> <strings:StringLiteralOrFString+> <end_location:@L> =>? Ok(concatenate_strings(strings, (location..end_location).into())?.into()),
<location:@L> <value:Constant> <end_location:@R> => ast::ExprConstant {
value,
range: (location..end_location).into(),
Expand Down
Loading

0 comments on commit 0f3792b

Please sign in to comment.