mirror of
https://github.com/python/cpython.git
synced 2025-08-02 16:13:13 +00:00
Flush out support for `class B(): pass
` syntax by adding support to the
'parser' module and 'compiler' package. Closes patch #1176012. Thanks logistix.
This commit is contained in:
parent
4ebc7e3bd0
commit
f4189916e3
5 changed files with 27 additions and 8 deletions
|
@ -947,7 +947,8 @@ static int
|
|||
validate_class(node *tree)
|
||||
{
|
||||
int nch = NCH(tree);
|
||||
int res = validate_ntype(tree, classdef) && ((nch == 4) || (nch == 7));
|
||||
int res = (validate_ntype(tree, classdef) &&
|
||||
((nch == 4) || (nch == 6) || (nch == 7)));
|
||||
|
||||
if (res) {
|
||||
res = (validate_name(CHILD(tree, 0), "class")
|
||||
|
@ -955,12 +956,20 @@ validate_class(node *tree)
|
|||
&& validate_colon(CHILD(tree, nch - 2))
|
||||
&& validate_suite(CHILD(tree, nch - 1)));
|
||||
}
|
||||
else
|
||||
else {
|
||||
(void) validate_numnodes(tree, 4, "class");
|
||||
if (res && (nch == 7)) {
|
||||
res = (validate_lparen(CHILD(tree, 2))
|
||||
&& validate_testlist(CHILD(tree, 3))
|
||||
&& validate_rparen(CHILD(tree, 4)));
|
||||
}
|
||||
|
||||
if (res) {
|
||||
if (nch == 7) {
|
||||
res = ((validate_lparen(CHILD(tree, 2)) &&
|
||||
validate_testlist(CHILD(tree, 3)) &&
|
||||
validate_rparen(CHILD(tree, 4))));
|
||||
}
|
||||
else if (nch == 6) {
|
||||
res = (validate_lparen(CHILD(tree,2)) &&
|
||||
validate_rparen(CHILD(tree,3)));
|
||||
}
|
||||
}
|
||||
return (res);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue