Skip to content

Commit

Permalink
Combine multiple format spec lalrpop definition
Browse files Browse the repository at this point in the history
  • Loading branch information
dhruvmanila committed Nov 26, 2023
1 parent 91db375 commit 7cf4999
Show file tree
Hide file tree
Showing 2 changed files with 9,059 additions and 9,101 deletions.
8 changes: 2 additions & 6 deletions crates/ruff_python_parser/src/python.lalrpop
Original file line number Diff line number Diff line change
Expand Up @@ -1628,7 +1628,7 @@ FStringMiddlePattern: ast::FStringElement = {
};

FStringReplacementField: ast::FStringElement = {
<location:@L> "{" <value:TestListOrYieldExpr> <debug:"="?> <conversion:FStringConversion?> <format_spec:FStringFormatSpecSuffix?> "}" <end_location:@R> =>? {
<location:@L> "{" <value:TestListOrYieldExpr> <debug:"="?> <conversion:FStringConversion?> <format_spec:FStringFormatSpec?> "}" <end_location:@R> =>? {
if value.expr.is_lambda_expr() && !value.is_parenthesized() {
return Err(LexicalError {
error: LexicalErrorType::FStringError(FStringErrorType::LambdaWithoutParentheses),
Expand Down Expand Up @@ -1664,12 +1664,8 @@ FStringReplacementField: ast::FStringElement = {
}
};

FStringFormatSpecSuffix: (TextSize, Vec<ast::FStringElement>) = {
":" <format_spec:FStringFormatSpec> => format_spec
};

FStringFormatSpec: (TextSize, Vec<ast::FStringElement>) = {
<location:@L> <elements:FStringMiddlePattern*> => (location, elements),
":" <location:@L> <elements:FStringMiddlePattern*> => (location, elements)
};

FStringConversion: (TextSize, ast::ConversionFlag) = {
Expand Down
Loading

0 comments on commit 7cf4999

Please sign in to comment.