mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-28 18:59:04 +08:00
Handle raw yield expressions as RHS for augmented/annotated assignments
This commit is contained in:
1 parent
9676ddb627
commit
698ae764f1
1 file changed
+9
-5
@@ -107,7 +107,7 @@ ExpressionStatement: ast::Statement = {
|
||||
}
|
||||
}
|
||||
},
|
||||
<location:@L> <target:TestOrStarExprList> <op:AugAssign> <rhs:TestList> => {
|
||||
<location:@L> <target:TestOrStarExprList> <op:AugAssign> <rhs:TestListOrYieldExpr> => {
|
||||
ast::Statement {
|
||||
location,
|
||||
node: ast::StatementType::AugAssign {
|
||||
@@ -117,23 +117,27 @@ ExpressionStatement: ast::Statement = {
|
||||
},
|
||||
}
|
||||
},
|
||||
<location:@L> <target:Test> ":" <annotation:Test> <rhs:("=" Test)?> => {
|
||||
<location:@L> <target:Test> ":" <annotation:Test> <rhs:AssignSuffix?> => {
|
||||
ast::Statement {
|
||||
location,
|
||||
node: ast::StatementType::AnnAssign {
|
||||
target: Box::new(target),
|
||||
annotation: Box::new(annotation),
|
||||
value: rhs.map(|e| e.1)
|
||||
value: rhs
|
||||
},
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
AssignSuffix: ast::Expression = {
|
||||
"=" <e:TestList> => e,
|
||||
"=" <e:YieldExpr> => e,
|
||||
"=" <e:TestListOrYieldExpr> => e
|
||||
};
|
||||
|
||||
TestListOrYieldExpr: ast::Expression = {
|
||||
TestList,
|
||||
YieldExpr
|
||||
}
|
||||
|
||||
TestOrStarExprList: ast::Expression = {
|
||||
<location:@L> <elements:OneOrMore<TestOrStarExpr>> <comma:","?> => {
|
||||
if elements.len() == 1 && comma.is_none() {
|
||||
|
||||
Reference in new issue
Block a user