@@ -882,9 +882,9 @@ atom[expr_ty]:
882882 | 'None' { _PyAST_Constant(Py_None, NULL, EXTRA) }
883883 | &(STRING|FSTRING_START|TSTRING_START) strings
884884 | NUMBER
885- | &'(' (tuple | group | genexp )
886- | &'[' (list | listcomp )
887- | &'{' (dict | set | dictcomp | setcomp )
885+ | &'(' ( genexp | tuple | group )
886+ | &'[' (listcomp | list )
887+ | &'{' (dictcomp | setcomp | dict | set )
888888 | '...' { _PyAST_Constant(Py_Ellipsis, NULL, EXTRA) }
889889
890890group[expr_ty]:
@@ -1327,9 +1327,9 @@ invalid_block:
13271327 | NEWLINE !INDENT { RAISE_INDENTATION_ERROR("expected an indented block") }
13281328invalid_comprehension:
13291329 | '[' a='**' b=expression for_if_clauses {
1330- RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, "dict unpacking cannot be used in list comprehension") }
1330+ RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, "cannot use dict unpacking in list comprehension") }
13311331 | '(' a='**' b=expression for_if_clauses {
1332- RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, "dict unpacking cannot be used in generator expression") }
1332+ RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, "cannot use dict unpacking in generator expression") }
13331333 | ('[' | '{') a=star_named_expression ',' b=star_named_expressions for_if_clauses {
13341334 RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, PyPegen_last_item(b, expr_ty),
13351335 "did you forget parentheses around the comprehension target?") }
@@ -1531,11 +1531,13 @@ invalid_class_def_raw:
15311531invalid_double_starred_kvpairs:
15321532 | ','.double_starred_kvpair+ ',' invalid_kvpair
15331533 | expression ':' a='*' bitwise_or { RAISE_SYNTAX_ERROR_STARTING_FROM(a, "cannot use a starred expression in a dictionary value") }
1534+ | expression ':' a='**' bitwise_or { RAISE_SYNTAX_ERROR_STARTING_FROM(a, "cannot use dict unpacking in a dictionary value") }
15341535 | expression a=':' &('}'|',') { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "expression expected after dictionary key and ':'") }
15351536invalid_kvpair:
15361537 | a=expression !(':') {
15371538 RAISE_ERROR_KNOWN_LOCATION(p, PyExc_SyntaxError, a->lineno, a->end_col_offset - 1, a->end_lineno, -1, "':' expected after dictionary key") }
15381539 | expression ':' a='*' bitwise_or { RAISE_SYNTAX_ERROR_STARTING_FROM(a, "cannot use a starred expression in a dictionary value") }
1540+ | expression ':' a='**' bitwise_or { RAISE_SYNTAX_ERROR_STARTING_FROM(a, "cannot use dict unpacking in a dictionary value") }
15391541 | expression a=':' &('}'|',') {RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "expression expected after dictionary key and ':'") }
15401542invalid_starred_expression_unpacking:
15411543 | a='*' expression '=' b=expression { RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, "cannot assign to iterable argument unpacking") }
0 commit comments