Skip to content

Commit 8c751f6

Browse files
committed
Allow unparenthesized unpacking in return and yield
1 parent 1d3082c commit 8c751f6

File tree

3 files changed

+51
-50
lines changed

3 files changed

+51
-50
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/parser/antlr/Python3.g4

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ return_stmt
676676
:
677677
'return'
678678
{ SSTNode value = null; }
679-
( testlist { value = $testlist.result; } )?
679+
( testlist_star_expr { value = $testlist_star_expr.result; } )?
680680
{ push(new ReturnSSTNode(value, getStartIndex($ctx), getLastIndex($ctx)));}
681681
;
682682

@@ -1609,7 +1609,7 @@ returns [SSTNode result]
16091609
(
16101610
'from' test {value = $test.result; isFrom = true;}
16111611
|
1612-
testlist { value = $testlist.result; }
1612+
testlist_star_expr { value = $testlist_star_expr.result; }
16131613
)?
16141614
{ $result = factory.createYieldExpressionSSTNode(value, isFrom, getStartIndex($ctx), getLastIndex($ctx)); }
16151615
;

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/parser/antlr/Python3.interp

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/parser/antlr/Python3Parser.java

Lines changed: 48 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -3050,10 +3050,10 @@ public final Flow_stmtContext flow_stmt() throws RecognitionException {
30503050
}
30513051

30523052
public static class Return_stmtContext extends ParserRuleContext {
3053-
public TestlistContext testlist;
3053+
public Testlist_star_exprContext testlist_star_expr;
30543054
public TerminalNode RETURN() { return getToken(Python3Parser.RETURN, 0); }
3055-
public TestlistContext testlist() {
3056-
return getRuleContext(TestlistContext.class,0);
3055+
public Testlist_star_exprContext testlist_star_expr() {
3056+
return getRuleContext(Testlist_star_exprContext.class,0);
30573057
}
30583058
public Return_stmtContext(ParserRuleContext parent, int invokingState) {
30593059
super(parent, invokingState);
@@ -3074,11 +3074,11 @@ public final Return_stmtContext return_stmt() throws RecognitionException {
30743074
setState(665);
30753075
_errHandler.sync(this);
30763076
_la = _input.LA(1);
3077-
if ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << STRING) | (1L << LAMBDA) | (1L << NOT) | (1L << NONE) | (1L << TRUE) | (1L << FALSE) | (1L << AWAIT) | (1L << NAME) | (1L << DECIMAL_INTEGER) | (1L << OCT_INTEGER) | (1L << HEX_INTEGER) | (1L << BIN_INTEGER) | (1L << FLOAT_NUMBER) | (1L << IMAG_NUMBER) | (1L << ELLIPSIS) | (1L << OPEN_PAREN) | (1L << OPEN_BRACK))) != 0) || ((((_la - 64)) & ~0x3f) == 0 && ((1L << (_la - 64)) & ((1L << (ADD - 64)) | (1L << (MINUS - 64)) | (1L << (NOT_OP - 64)) | (1L << (OPEN_BRACE - 64)))) != 0)) {
3077+
if ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << STRING) | (1L << LAMBDA) | (1L << NOT) | (1L << NONE) | (1L << TRUE) | (1L << FALSE) | (1L << AWAIT) | (1L << NAME) | (1L << DECIMAL_INTEGER) | (1L << OCT_INTEGER) | (1L << HEX_INTEGER) | (1L << BIN_INTEGER) | (1L << FLOAT_NUMBER) | (1L << IMAG_NUMBER) | (1L << ELLIPSIS) | (1L << STAR) | (1L << OPEN_PAREN) | (1L << OPEN_BRACK))) != 0) || ((((_la - 64)) & ~0x3f) == 0 && ((1L << (_la - 64)) & ((1L << (ADD - 64)) | (1L << (MINUS - 64)) | (1L << (NOT_OP - 64)) | (1L << (OPEN_BRACE - 64)))) != 0)) {
30783078
{
30793079
setState(662);
3080-
_localctx.testlist = testlist();
3081-
value = _localctx.testlist.result;
3080+
_localctx.testlist_star_expr = testlist_star_expr();
3081+
value = _localctx.testlist_star_expr.result;
30823082
}
30833083
}
30843084

@@ -8268,14 +8268,14 @@ public final Encoding_declContext encoding_decl() throws RecognitionException {
82688268
public static class Yield_exprContext extends ParserRuleContext {
82698269
public SSTNode result;
82708270
public TestContext test;
8271-
public TestlistContext testlist;
8271+
public Testlist_star_exprContext testlist_star_expr;
82728272
public TerminalNode YIELD() { return getToken(Python3Parser.YIELD, 0); }
82738273
public TerminalNode FROM() { return getToken(Python3Parser.FROM, 0); }
82748274
public TestContext test() {
82758275
return getRuleContext(TestContext.class,0);
82768276
}
8277-
public TestlistContext testlist() {
8278-
return getRuleContext(TestlistContext.class,0);
8277+
public Testlist_star_exprContext testlist_star_expr() {
8278+
return getRuleContext(Testlist_star_exprContext.class,0);
82798279
}
82808280
public Yield_exprContext(ParserRuleContext parent, int invokingState) {
82818281
super(parent, invokingState);
@@ -8322,6 +8322,7 @@ public final Yield_exprContext yield_expr() throws RecognitionException {
83228322
case FLOAT_NUMBER:
83238323
case IMAG_NUMBER:
83248324
case ELLIPSIS:
8325+
case STAR:
83258326
case OPEN_PAREN:
83268327
case OPEN_BRACK:
83278328
case ADD:
@@ -8330,8 +8331,8 @@ public final Yield_exprContext yield_expr() throws RecognitionException {
83308331
case OPEN_BRACE:
83318332
{
83328333
setState(1608);
8333-
_localctx.testlist = testlist();
8334-
value = _localctx.testlist.result;
8334+
_localctx.testlist_star_expr = testlist_star_expr();
8335+
value = _localctx.testlist_star_expr.result;
83358336
}
83368337
break;
83378338
case NEWLINE:
@@ -8659,23 +8660,23 @@ public final Yield_exprContext yield_expr() throws RecognitionException {
86598660
"\7#\2\2\u0290\u0295\b\32\1\2\u0291\u0295\5\64\33\2\u0292\u0295\58\35\2"+
86608661
"\u0293\u0295\5\66\34\2\u0294\u028d\3\2\2\2\u0294\u028f\3\2\2\2\u0294\u0291"+
86618662
"\3\2\2\2\u0294\u0292\3\2\2\2\u0294\u0293\3\2\2\2\u0295\63\3\2\2\2\u0296"+
8662-
"\u0297\7\5\2\2\u0297\u029b\b\33\1\2\u0298\u0299\5\u0094K\2\u0299\u029a"+
8663-
"\b\33\1\2\u029a\u029c\3\2\2\2\u029b\u0298\3\2\2\2\u029b\u029c\3\2\2\2"+
8664-
"\u029c\u029d\3\2\2\2\u029d\u029e\b\33\1\2\u029e\65\3\2\2\2\u029f\u02a0"+
8665-
"\5\u00a4S\2\u02a0\u02a1\b\34\1\2\u02a1\67\3\2\2\2\u02a2\u02a3\b\35\1\2"+
8666-
"\u02a3\u02ac\7\6\2\2\u02a4\u02a5\5f\64\2\u02a5\u02aa\b\35\1\2\u02a6\u02a7"+
8667-
"\7\7\2\2\u02a7\u02a8\5f\64\2\u02a8\u02a9\b\35\1\2\u02a9\u02ab\3\2\2\2"+
8668-
"\u02aa\u02a6\3\2\2\2\u02aa\u02ab\3\2\2\2\u02ab\u02ad\3\2\2\2\u02ac\u02a4"+
8669-
"\3\2\2\2\u02ac\u02ad\3\2\2\2\u02ad\u02ae\3\2\2\2\u02ae\u02af\b\35\1\2"+
8670-
"\u02af9\3\2\2\2\u02b0\u02b3\5<\37\2\u02b1\u02b3\5> \2\u02b2\u02b0\3\2"+
8671-
"\2\2\u02b2\u02b1\3\2\2\2\u02b3;\3\2\2\2\u02b4\u02b5\7\b\2\2\u02b5\u02b6"+
8672-
"\5H%\2\u02b6=\3\2\2\2\u02b7\u02b8\7\7\2\2\u02b8\u02cd\b \1\2\u02b9\u02ba"+
8673-
"\7\61\2\2\u02ba\u02be\b \1\2\u02bb\u02bc\7\62\2\2\u02bc\u02be\b \1\2\u02bd"+
8674-
"\u02b9\3\2\2\2\u02bd\u02bb\3\2\2\2\u02be\u02c1\3\2\2\2\u02bf\u02bd\3\2"+
8675-
"\2\2\u02bf\u02c0\3\2\2\2\u02c0\u02c2\3\2\2\2\u02c1\u02bf\3\2\2\2\u02c2"+
8676-
"\u02c3\5D#\2\u02c3\u02c4\b \1\2\u02c4\u02ce\3\2\2\2\u02c5\u02c6\7\61\2"+
8677-
"\2\u02c6\u02ca\b \1\2\u02c7\u02c8\7\62\2\2\u02c8\u02ca\b \1\2\u02c9\u02c5"+
8678-
"\3\2\2\2\u02c9\u02c7\3\2\2\2\u02ca\u02cb\3\2\2\2\u02cb\u02c9\3\2\2\2\u02cb"+
8663+
"\u0297\7\5\2\2\u0297\u029b\b\33\1\2\u0298\u0299\5,\27\2\u0299\u029a\b"+
8664+
"\33\1\2\u029a\u029c\3\2\2\2\u029b\u0298\3\2\2\2\u029b\u029c\3\2\2\2\u029c"+
8665+
"\u029d\3\2\2\2\u029d\u029e\b\33\1\2\u029e\65\3\2\2\2\u029f\u02a0\5\u00a4"+
8666+
"S\2\u02a0\u02a1\b\34\1\2\u02a1\67\3\2\2\2\u02a2\u02a3\b\35\1\2\u02a3\u02ac"+
8667+
"\7\6\2\2\u02a4\u02a5\5f\64\2\u02a5\u02aa\b\35\1\2\u02a6\u02a7\7\7\2\2"+
8668+
"\u02a7\u02a8\5f\64\2\u02a8\u02a9\b\35\1\2\u02a9\u02ab\3\2\2\2\u02aa\u02a6"+
8669+
"\3\2\2\2\u02aa\u02ab\3\2\2\2\u02ab\u02ad\3\2\2\2\u02ac\u02a4\3\2\2\2\u02ac"+
8670+
"\u02ad\3\2\2\2\u02ad\u02ae\3\2\2\2\u02ae\u02af\b\35\1\2\u02af9\3\2\2\2"+
8671+
"\u02b0\u02b3\5<\37\2\u02b1\u02b3\5> \2\u02b2\u02b0\3\2\2\2\u02b2\u02b1"+
8672+
"\3\2\2\2\u02b3;\3\2\2\2\u02b4\u02b5\7\b\2\2\u02b5\u02b6\5H%\2\u02b6=\3"+
8673+
"\2\2\2\u02b7\u02b8\7\7\2\2\u02b8\u02cd\b \1\2\u02b9\u02ba\7\61\2\2\u02ba"+
8674+
"\u02be\b \1\2\u02bb\u02bc\7\62\2\2\u02bc\u02be\b \1\2\u02bd\u02b9\3\2"+
8675+
"\2\2\u02bd\u02bb\3\2\2\2\u02be\u02c1\3\2\2\2\u02bf\u02bd\3\2\2\2\u02bf"+
8676+
"\u02c0\3\2\2\2\u02c0\u02c2\3\2\2\2\u02c1\u02bf\3\2\2\2\u02c2\u02c3\5D"+
8677+
"#\2\u02c3\u02c4\b \1\2\u02c4\u02ce\3\2\2\2\u02c5\u02c6\7\61\2\2\u02c6"+
8678+
"\u02ca\b \1\2\u02c7\u02c8\7\62\2\2\u02c8\u02ca\b \1\2\u02c9\u02c5\3\2"+
8679+
"\2\2\u02c9\u02c7\3\2\2\2\u02ca\u02cb\3\2\2\2\u02cb\u02c9\3\2\2\2\u02cb"+
86798680
"\u02cc\3\2\2\2\u02cc\u02ce\3\2\2\2\u02cd\u02bf\3\2\2\2\u02cd\u02c9\3\2"+
86808681
"\2\2\u02ce\u02cf\3\2\2\2\u02cf\u02d0\7\b\2\2\u02d0\u02da\b \1\2\u02d1"+
86818682
"\u02db\7\63\2\2\u02d2\u02d3\7\64\2\2\u02d3\u02d4\5B\"\2\u02d4\u02d5\b"+
@@ -8964,25 +8965,25 @@ public final Yield_exprContext yield_expr() throws RecognitionException {
89648965
"\2\2\u063f\u0640\3\2\2\2\u0640\u0641\bQ\1\2\u0641\u00a1\3\2\2\2\u0642"+
89658966
"\u0643\7(\2\2\u0643\u00a3\3\2\2\2\u0644\u0645\bS\1\2\u0645\u064d\7 \2"+
89668967
"\2\u0646\u0647\7\7\2\2\u0647\u0648\5f\64\2\u0648\u0649\bS\1\2\u0649\u064e"+
8967-
"\3\2\2\2\u064a\u064b\5\u0094K\2\u064b\u064c\bS\1\2\u064c\u064e\3\2\2\2"+
8968-
"\u064d\u0646\3\2\2\2\u064d\u064a\3\2\2\2\u064d\u064e\3\2\2\2\u064e\u064f"+
8969-
"\3\2\2\2\u064f\u0650\bS\1\2\u0650\u00a5\3\2\2\2\u00be\u00ad\u00b6\u00b8"+
8970-
"\u00c4\u00d3\u00dc\u00e5\u00f1\u00fb\u0105\u0111\u0114\u011c\u0122\u0124"+
8971-
"\u0126\u012a\u012c\u012e\u0130\u0137\u0140\u0146\u0148\u014a\u014e\u0150"+
8972-
"\u0152\u0159\u015f\u0161\u0163\u0167\u0169\u0171\u0177\u0183\u0185\u0190"+
8973-
"\u019a\u01a6\u01a9\u01b1\u01b7\u01b9\u01bb\u01bf\u01c1\u01c3\u01c5\u01cc"+
8974-
"\u01d5\u01db\u01dd\u01df\u01e3\u01e5\u01e7\u01ee\u01f4\u01f6\u01f8\u01fc"+
8975-
"\u01fe\u0208\u0210\u021a\u0221\u0225\u0232\u023c\u0247\u0255\u0259\u025d"+
8976-
"\u0265\u026f\u0278\u027c\u0280\u0282\u0285\u0294\u029b\u02aa\u02ac\u02b2"+
8977-
"\u02bd\u02bf\u02c9\u02cb\u02cd\u02da\u02e3\u02f0\u02f4\u02ff\u0307\u030e"+
8978-
"\u031a\u0328\u0334\u0341\u0347\u035d\u036a\u037b\u0389\u0390\u0392\u0399"+
8979-
"\u03a4\u03a6\u03b6\u03c1\u03cc\u03d0\u03dc\u03e1\u03e9\u03f0\u03fd\u040e"+
8980-
"\u0413\u041e\u0423\u042c\u0436\u043b\u0455\u0463\u046e\u0479\u0483\u048a"+
8981-
"\u0494\u049b\u04ab\u04b2\u04bc\u04c4\u04cc\u04cf\u04e0\u04e2\u04ed\u04f6"+
8982-
"\u0502\u0519\u0524\u0532\u0536\u0538\u053b\u0544\u054a\u0550\u0552\u0555"+
8983-
"\u055e\u0567\u056b\u056f\u057f\u0583\u0585\u0588\u0594\u05a3\u05b0\u05b4"+
8984-
"\u05b8\u05bc\u05c5\u05d1\u05db\u05df\u05e5\u05e9\u05f3\u0601\u0605\u0607"+
8985-
"\u0622\u0627\u0637\u063e\u064d";
8968+
"\3\2\2\2\u064a\u064b\5,\27\2\u064b\u064c\bS\1\2\u064c\u064e\3\2\2\2\u064d"+
8969+
"\u0646\3\2\2\2\u064d\u064a\3\2\2\2\u064d\u064e\3\2\2\2\u064e\u064f\3\2"+
8970+
"\2\2\u064f\u0650\bS\1\2\u0650\u00a5\3\2\2\2\u00be\u00ad\u00b6\u00b8\u00c4"+
8971+
"\u00d3\u00dc\u00e5\u00f1\u00fb\u0105\u0111\u0114\u011c\u0122\u0124\u0126"+
8972+
"\u012a\u012c\u012e\u0130\u0137\u0140\u0146\u0148\u014a\u014e\u0150\u0152"+
8973+
"\u0159\u015f\u0161\u0163\u0167\u0169\u0171\u0177\u0183\u0185\u0190\u019a"+
8974+
"\u01a6\u01a9\u01b1\u01b7\u01b9\u01bb\u01bf\u01c1\u01c3\u01c5\u01cc\u01d5"+
8975+
"\u01db\u01dd\u01df\u01e3\u01e5\u01e7\u01ee\u01f4\u01f6\u01f8\u01fc\u01fe"+
8976+
"\u0208\u0210\u021a\u0221\u0225\u0232\u023c\u0247\u0255\u0259\u025d\u0265"+
8977+
"\u026f\u0278\u027c\u0280\u0282\u0285\u0294\u029b\u02aa\u02ac\u02b2\u02bd"+
8978+
"\u02bf\u02c9\u02cb\u02cd\u02da\u02e3\u02f0\u02f4\u02ff\u0307\u030e\u031a"+
8979+
"\u0328\u0334\u0341\u0347\u035d\u036a\u037b\u0389\u0390\u0392\u0399\u03a4"+
8980+
"\u03a6\u03b6\u03c1\u03cc\u03d0\u03dc\u03e1\u03e9\u03f0\u03fd\u040e\u0413"+
8981+
"\u041e\u0423\u042c\u0436\u043b\u0455\u0463\u046e\u0479\u0483\u048a\u0494"+
8982+
"\u049b\u04ab\u04b2\u04bc\u04c4\u04cc\u04cf\u04e0\u04e2\u04ed\u04f6\u0502"+
8983+
"\u0519\u0524\u0532\u0536\u0538\u053b\u0544\u054a\u0550\u0552\u0555\u055e"+
8984+
"\u0567\u056b\u056f\u057f\u0583\u0585\u0588\u0594\u05a3\u05b0\u05b4\u05b8"+
8985+
"\u05bc\u05c5\u05d1\u05db\u05df\u05e5\u05e9\u05f3\u0601\u0605\u0607\u0622"+
8986+
"\u0627\u0637\u063e\u064d";
89868987
public static final ATN _ATN =
89878988
new ATNDeserializer().deserialize(_serializedATN.toCharArray());
89888989
static {

0 commit comments

Comments
 (0)