summaryrefslogtreecommitdiffstats
path: root/Python/compile.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1993-11-30 14:57:42 (GMT)
committerGuido van Rossum <guido@python.org>1993-11-30 14:57:42 (GMT)
commit57531fea90ca0afe9efdc70d3dce1a3eb153f03e (patch)
treec1d0923a451f6a8c28307f229ba7e5b422a3d172 /Python/compile.c
parentae3b3a33d85134b51505b3f0f3fdaf6afbffa79b (diff)
downloadcpython-57531fea90ca0afe9efdc70d3dce1a3eb153f03e.zip
cpython-57531fea90ca0afe9efdc70d3dce1a3eb153f03e.tar.gz
cpython-57531fea90ca0afe9efdc70d3dce1a3eb153f03e.tar.bz2
change syntactical position of lambdef (was an atom, now is a test)
Diffstat (limited to 'Python/compile.c')
-rw-r--r--Python/compile.c53
1 files changed, 28 insertions, 25 deletions
diff --git a/Python/compile.c b/Python/compile.c
index 77752a4..aee2585 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -659,18 +659,6 @@ com_atom(c, n)
}
com_addoparg(c, LOAD_CONST, i);
break;
- case lambdef:
- if ((v = (object *) compile(ch, c->c_filename)) == NULL) {
- c->c_errors++;
- i = 255;
- }
- else {
- i = com_addconst(c, v);
- DECREF(v);
- }
- com_addoparg(c, LOAD_CONST, i);
- com_addbyte(c, BUILD_FUNCTION);
- break;
case NAME:
com_addopname(c, LOAD_NAME, ch);
break;
@@ -1106,20 +1094,35 @@ com_test(c, n)
struct compiling *c;
node *n;
{
- int i;
- int anchor;
- REQ(n, test); /* and_test ('and' and_test)* */
- anchor = 0;
- i = 0;
- for (;;) {
- com_and_test(c, CHILD(n, i));
- if ((i += 2) >= NCH(n))
- break;
- com_addfwref(c, JUMP_IF_TRUE, &anchor);
- com_addbyte(c, POP_TOP);
+ REQ(n, test); /* and_test ('and' and_test)* | lambdef */
+ if (NCH(n) == 1 && TYPE(CHILD(n, 0)) == lambdef) {
+ object *v;
+ int i;
+ v = (object *) compile(CHILD(n, 0), c->c_filename);
+ if (v == NULL) {
+ c->c_errors++;
+ i = 255;
+ }
+ else {
+ i = com_addconst(c, v);
+ DECREF(v);
+ }
+ com_addoparg(c, LOAD_CONST, i);
+ com_addbyte(c, BUILD_FUNCTION);
+ }
+ else {
+ int anchor = 0;
+ int i = 0;
+ for (;;) {
+ com_and_test(c, CHILD(n, i));
+ if ((i += 2) >= NCH(n))
+ break;
+ com_addfwref(c, JUMP_IF_TRUE, &anchor);
+ com_addbyte(c, POP_TOP);
+ }
+ if (anchor)
+ com_backpatch(c, anchor);
}
- if (anchor)
- com_backpatch(c, anchor);
}
static void