/* argument: ( test [comp_for] |
* test '=' test |
- * '**' expr |
- * star_expr )
+ * '**' test |
+ * '*' test )
*/
static int
validate_argument(node *tree)
if (TYPE(CHILD(tree, 0)) == DOUBLESTAR) {
res = validate_test(CHILD(tree, 1));
}
+ else if (TYPE(CHILD(tree, 0)) == STAR) {
+ res = validate_test(CHILD(tree, 1));
+ }
else if (nch == 1) {
- res = validate_test_or_star_expr(CHILD(tree, 0));
+ res = validate_test(CHILD(tree, 0));
}
else if (nch == 2) {
res = (validate_test(CHILD(tree, 0))
expr_ty e;
node *chch = CHILD(ch, 0);
if (NCH(ch) == 1) {
- if (TYPE(chch) == star_expr) {
- /* an iterable argument unpacking */
- expr_ty starred;
+ /* a positional argument */
+ if (nkeywords) {
if (ndoublestars) {
ast_error(c, chch,
- "iterable argument unpacking follows "
+ "positional argument follows "
"keyword argument unpacking");
- return NULL;
}
- e = ast_for_expr(c, CHILD(chch, 1));
- if (!e)
- return NULL;
- starred = Starred(e, Load, LINENO(chch),
- chch->n_col_offset,
- c->c_arena);
- if (!starred)
- return NULL;
- asdl_seq_SET(args, nargs++, starred);
- }
- else {
- /* a positional argument */
- if (nkeywords) {
- if (ndoublestars) {
- ast_error(c, chch,
- "positional argument follows "
- "keyword argument unpacking");
- }
- else {
- ast_error(c, chch,
- "positional argument follows "
- "keyword argument");
- }
- return NULL;
+ else {
+ ast_error(c, chch,
+ "positional argument follows "
+ "keyword argument");
}
- e = ast_for_expr(c, chch);
- if (!e)
- return NULL;
- asdl_seq_SET(args, nargs++, e);
+ return NULL;
}
+ e = ast_for_expr(c, chch);
+ if (!e)
+ return NULL;
+ asdl_seq_SET(args, nargs++, e);
+ }
+ else if (TYPE(chch) == STAR) {
+ /* an iterable argument unpacking */
+ expr_ty starred;
+ if (ndoublestars) {
+ ast_error(c, chch,
+ "iterable argument unpacking follows "
+ "keyword argument unpacking");
+ return NULL;
+ }
+ e = ast_for_expr(c, CHILD(ch, 1));
+ if (!e)
+ return NULL;
+ starred = Starred(e, Load, LINENO(chch),
+ chch->n_col_offset,
+ c->c_arena);
+ if (!starred)
+ return NULL;
+ asdl_seq_SET(args, nargs++, starred);
+
}
else if (TYPE(chch) == DOUBLESTAR) {
/* a keyword argument unpacking */