* stars on the args -- just parse them into an ordered list */
num = 0;
for (i = 0; i < NCH(ch); i++) {
- if (TYPE(CHILD(ch, i)) == test)
+ if (TYPE(CHILD(ch, i)) == test) {
num++;
+ }
}
argtypes = _Py_asdl_seq_new(num, arena);
(i+2 == NCH(n) && (TYPE(CHILD(n, i+1)) == COMMA
|| TYPE(CHILD(n, i+1)) == TYPE_COMMENT))) {
ast_error(c, CHILD(n, i),
- "named arguments must follow bare *");
+ "named arguments must follow bare *");
return NULL;
}
ch = CHILD(n, i+1); /* tfpdef or COMMA */
if (i < NCH(n) && TYPE(CHILD(n, i)) == TYPE_COMMENT) {
ast_error(c, CHILD(n, i),
- "bare * has associated type comment");
+ "bare * has associated type comment");
return NULL;
}
/* It's a dictionary comprehension. */
if (is_dict) {
ast_error(c, n, "dict unpacking cannot be used in "
- "dict comprehension");
+ "dict comprehension");
return NULL;
}
res = ast_for_dictcomp(c, ch);
if (nkeywords) {
if (ndoublestars) {
ast_error(c, chch,
- "positional argument follows "
- "keyword argument unpacking");
+ "positional argument follows "
+ "keyword argument unpacking");
}
else {
ast_error(c, chch,
- "positional argument follows "
- "keyword argument");
+ "positional argument follows "
+ "keyword argument");
}
return NULL;
}
expr_ty starred;
if (ndoublestars) {
ast_error(c, chch,
- "iterable argument unpacking follows "
- "keyword argument unpacking");
+ "iterable argument unpacking follows "
+ "keyword argument unpacking");
return NULL;
}
e = ast_for_expr(c, CHILD(ch, 1));
if (nkeywords) {
if (ndoublestars) {
ast_error(c, chch,
- "positional argument follows "
- "keyword argument unpacking");
+ "positional argument follows "
+ "keyword argument unpacking");
}
else {
ast_error(c, chch,
- "positional argument follows "
- "keyword argument");
+ "positional argument follows "
+ "keyword argument");
}
return NULL;
}
tmp = ((keyword_ty)asdl_seq_GET(keywords, k))->arg;
if (tmp && !PyUnicode_Compare(tmp, key)) {
ast_error(c, chch,
- "keyword argument repeated");
+ "keyword argument repeated");
return NULL;
}
}
{
REQ(n, expr_stmt);
/* expr_stmt: testlist_star_expr (annassign | augassign (yield_expr|testlist) |
- ('=' (yield_expr|testlist_star_expr))* [TYPE_COMMENT])
- annassign: ':' test ['=' test]
- testlist_star_expr: (test|star_expr) (',' test|star_expr)* [',']
- augassign: '+=' | '-=' | '*=' | '@=' | '/=' | '%=' | '&=' | '|=' | '^='
- | '<<=' | '>>=' | '**=' | '//='
+ [('=' (yield_expr|testlist_star_expr))+ [TYPE_COMMENT]] )
+ annassign: ':' test ['=' (yield_expr|testlist)]
+ testlist_star_expr: (test|star_expr) (',' (test|star_expr))* [',']
+ augassign: ('+=' | '-=' | '*=' | '@=' | '/=' | '%=' | '&=' | '|=' | '^=' |
+ '<<=' | '>>=' | '**=' | '//=')
test: ... here starts the operator precedence dance
*/
int num = NCH(n);
- if (num == 1 || (num == 2 && TYPE(CHILD(n, 1)) == TYPE_COMMENT)) {
+ if (num == 1) {
expr_ty e = ast_for_testlist(c, CHILD(n, 0));
if (!e)
return NULL;
n = CHILD(n, idx);
n_children = NCH(n);
if (n_children % 2 == 0) {
- ast_error(c, n, "trailing comma not allowed without"
- " surrounding parentheses");
+ ast_error(c, n,
+ "trailing comma not allowed without"
+ " surrounding parentheses");
return NULL;
}
break;
if (ch == '\\') {
/* Error: can't include a backslash character, inside
parens or strings or not. */
- ast_error(c, n, "f-string expression part "
- "cannot include a backslash");
+ ast_error(c, n,
+ "f-string expression part "
+ "cannot include a backslash");
return -1;
}
if (quote_char) {
/* Validate the conversion. */
if (!(conversion == 's' || conversion == 'r'
|| conversion == 'a')) {
- ast_error(c, n, "f-string: invalid conversion character: "
- "expected 's', 'r', or 'a'");
+ ast_error(c, n,
+ "f-string: invalid conversion character: "
+ "expected 's', 'r', or 'a'");
return -1;
}
}
const char *ch;
for (ch = s; *ch; ch++) {
if (Py_CHARMASK(*ch) >= 0x80) {
- ast_error(c, n, "bytes can only contain ASCII "
+ ast_error(c, n,
+ "bytes can only contain ASCII "
"literal characters.");
return -1;
}