diff -r -c Grammar/Grammar Grammar/Grammar *** Grammar/Grammar Tue Aug 13 07:00:22 1996 --- Grammar/Grammar Tue Oct 22 01:07:23 1996 *************** *** 51,58 **** exec_stmt: 'exec' expr ['in' test [',' test]] compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt | funcdef | classdef ! if_stmt: 'if' test ':' suite ('elif' test ':' suite)* ['else' ':' suite] ! while_stmt: 'while' test ':' suite ['else' ':' suite] for_stmt: 'for' exprlist 'in' testlist ':' suite ['else' ':' suite] try_stmt: ('try' ':' suite (except_clause ':' suite)+ #diagram:break ['else' ':' suite] | 'try' ':' suite 'finally' ':' suite) --- 51,58 ---- exec_stmt: 'exec' expr ['in' test [',' test]] compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt | funcdef | classdef ! if_stmt: 'if' [test 'from'] test ':' suite ('elif' [test 'from'] test ':' suite)* ['else' ':' suite] ! while_stmt: 'while' [test 'from'] test ':' suite ['else' ':' suite] for_stmt: 'for' exprlist 'in' testlist ':' suite ['else' ':' suite] try_stmt: ('try' ':' suite (except_clause ':' suite)+ #diagram:break ['else' ':' suite] | 'try' ':' suite 'finally' ':' suite) diff -r -c Python/compile.c Python/compile.c *** Python/compile.c Sat Aug 24 16:54:27 1996 --- Python/compile.c Tue Oct 22 00:52:45 1996 *************** *** 1936,1948 **** int i; int anchor = 0; REQ(n, if_stmt); ! /*'if' test ':' suite ('elif' test ':' suite)* ['else' ':' suite] */ for (i = 0; i+3 < NCH(n); i+=4) { int a = 0; node *ch = CHILD(n, i+1); if (i > 0) com_addoparg(c, SET_LINENO, ch->n_lineno); ! com_node(c, CHILD(n, i+1)); com_addfwref(c, JUMP_IF_FALSE, &a); com_addbyte(c, POP_TOP); com_node(c, CHILD(n, i+3)); --- 1936,1958 ---- int i; int anchor = 0; REQ(n, if_stmt); ! /* 'if' [name 'from'] test ':' suite ! ('elif' [name 'from'] test ':' suite)* ['else' ':' suite] */ for (i = 0; i+3 < NCH(n); i+=4) { int a = 0; node *ch = CHILD(n, i+1); if (i > 0) com_addoparg(c, SET_LINENO, ch->n_lineno); ! ! if (TYPE(CHILD(n, i+2)) == COLON) ! com_node(c, CHILD(n, i+1)); ! else { ! i += 2; ! com_node(c, CHILD(n, i+1)); ! com_addbyte(c, DUP_TOP); ! com_assign(c, CHILD(n, i-1), OP_ASSIGN); ! } ! com_addfwref(c, JUMP_IF_FALSE, &a); com_addbyte(c, POP_TOP); com_node(c, CHILD(n, i+3)); *************** *** 1963,1978 **** int break_anchor = 0; int anchor = 0; int save_begin = c->c_begin; ! REQ(n, while_stmt); /* 'while' test ':' suite ['else' ':' suite] */ com_addfwref(c, SETUP_LOOP, &break_anchor); block_push(c, SETUP_LOOP); c->c_begin = c->c_nexti; com_addoparg(c, SET_LINENO, n->n_lineno); ! com_node(c, CHILD(n, 1)); com_addfwref(c, JUMP_IF_FALSE, &anchor); com_addbyte(c, POP_TOP); c->c_loops++; ! com_node(c, CHILD(n, 3)); c->c_loops--; com_addoparg(c, JUMP_ABSOLUTE, c->c_begin); c->c_begin = save_begin; --- 1973,2000 ---- int break_anchor = 0; int anchor = 0; int save_begin = c->c_begin; ! int testi; ! ! /* 'while' [name 'from'] test ':' suite ['else' ':' suite] */ ! REQ(n, while_stmt); ! com_addfwref(c, SETUP_LOOP, &break_anchor); block_push(c, SETUP_LOOP); c->c_begin = c->c_nexti; com_addoparg(c, SET_LINENO, n->n_lineno); ! ! if (TYPE(CHILD(n, 2)) == COLON) ! com_node(c, CHILD(n, testi=1)); ! else { ! com_node(c, CHILD(n, testi=3)); ! com_addbyte(c, DUP_TOP); ! com_assign(c, CHILD(n, 1), OP_ASSIGN); ! } ! com_addfwref(c, JUMP_IF_FALSE, &anchor); com_addbyte(c, POP_TOP); c->c_loops++; ! com_node(c, CHILD(n, testi+2)); c->c_loops--; com_addoparg(c, JUMP_ABSOLUTE, c->c_begin); c->c_begin = save_begin; *************** *** 1980,1987 **** com_addbyte(c, POP_TOP); com_addbyte(c, POP_BLOCK); block_pop(c, SETUP_LOOP); ! if (NCH(n) > 4) ! com_node(c, CHILD(n, 6)); com_backpatch(c, break_anchor); } --- 2002,2009 ---- com_addbyte(c, POP_TOP); com_addbyte(c, POP_BLOCK); block_pop(c, SETUP_LOOP); ! if (NCH(n) > testi+3) ! com_node(c, CHILD(n, testi+5)); com_backpatch(c, break_anchor); }