summaryrefslogtreecommitdiffstats
path: root/Modules/parsermodule.c
diff options
context:
space:
mode:
authorBrett Cannon <bcannon@gmail.com>2005-04-09 02:30:16 (GMT)
committerBrett Cannon <bcannon@gmail.com>2005-04-09 02:30:16 (GMT)
commitf4189916e366045a44755d453c89d30e5006f84f (patch)
treefb55a279fc5275a7403f523fb546f19baa4c6e17 /Modules/parsermodule.c
parent4ebc7e3bd0a3ed0a56b1a0e5816127c18d2ae8ae (diff)
downloadcpython-f4189916e366045a44755d453c89d30e5006f84f.zip
cpython-f4189916e366045a44755d453c89d30e5006f84f.tar.gz
cpython-f4189916e366045a44755d453c89d30e5006f84f.tar.bz2
Flush out support for ``class B(): pass`` syntax by adding support to the
'parser' module and 'compiler' package. Closes patch #1176012. Thanks logistix.
Diffstat (limited to 'Modules/parsermodule.c')
-rw-r--r--Modules/parsermodule.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/Modules/parsermodule.c b/Modules/parsermodule.c
index eb23b58..63b2cd7 100644
--- a/Modules/parsermodule.c
+++ b/Modules/parsermodule.c
@@ -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);
}