Index: Grammar/Grammar
===================================================================
RCS file: /cvsroot/python/python/dist/src/Grammar/Grammar,v
retrieving revision 1.45
diff -c -r1.45 Grammar
*** Grammar/Grammar	15 Oct 2001 15:44:04 -0000	1.45
--- Grammar/Grammar	12 Feb 2002 16:47:05 -0000
***************
*** 28,34 ****
  file_input: (NEWLINE | stmt)* ENDMARKER
  eval_input: testlist NEWLINE* ENDMARKER
  
! funcdef: 'def' NAME parameters ':' suite
  parameters: '(' [varargslist] ')'
  varargslist: (fpdef ['=' test] ',')* ('*' NAME [',' '**' NAME] | '**' NAME) | fpdef ['=' test] (',' fpdef ['=' test])* [',']
  fpdef: NAME | '(' fplist ')'
--- 28,34 ----
  file_input: (NEWLINE | stmt)* ENDMARKER
  eval_input: testlist NEWLINE* ENDMARKER
  
! funcdef: 'def' NAME parameters ['[' exprlist ']' ] ':' suite
  parameters: '(' [varargslist] ')'
  varargslist: (fpdef ['=' test] ',')* ('*' NAME [',' '**' NAME] | '**' NAME) | fpdef ['=' test] (',' fpdef ['=' test])* [',']
  fpdef: NAME | '(' fplist ')'
Index: Python/compile.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/compile.c,v
retrieving revision 2.238
diff -c -r2.238 compile.c
*** Python/compile.c	29 Jan 2002 00:56:37 -0000	2.238
--- Python/compile.c	12 Feb 2002 16:47:05 -0000
***************
*** 548,553 ****
--- 548,554 ----
  static void symtable_node(struct symtable *, node *);
  static void symtable_funcdef(struct symtable *, node *);
  static void symtable_default_args(struct symtable *, node *);
+ static void symtable_filters(struct symtable *, node *);
  static void symtable_params(struct symtable *, node *);
  static void symtable_params_fplist(struct symtable *, node *n);
  static void symtable_global(struct symtable *, node *);
***************
*** 3514,3520 ****
  {
  	PyObject *co;
  	int ndefs;
! 	REQ(n, funcdef); /* funcdef: 'def' NAME parameters ':' suite */
  	ndefs = com_argdefs(c, n);
  	symtable_enter_scope(c->c_symtable, STR(CHILD(n, 1)), TYPE(n),
  			     n->n_lineno);
--- 3515,3522 ----
  {
  	PyObject *co;
  	int ndefs;
! 	REQ(n, funcdef); 
! 	/* funcdef: 'def' NAME parameters [ '[' NAME ']' ] ':' suite */
  	ndefs = com_argdefs(c, n);
  	symtable_enter_scope(c->c_symtable, STR(CHILD(n, 1)), TYPE(n),
  			     n->n_lineno);
***************
*** 3532,3537 ****
--- 3534,3551 ----
  		else
  			com_addoparg(c, MAKE_FUNCTION, ndefs);
  		com_pop(c, ndefs);
+ 		/* [] stuff goes here */
+ 		if (TYPE(CHILD(n, 3)) == LSQB) {
+ 			node* filters = CHILD(n, 4);
+ 			int filteri = 0;
+ 
+ 			for (; filteri < NCH(filters); filteri += 2) {
+ 				com_node(c, CHILD(filters, filteri));
+ 				com_addbyte(c, ROT_TWO);
+ 				com_addoparg(c, CALL_FUNCTION, 1);
+ 				com_pop(c, 1);
+ 			}
+ 		}
  		com_addop_varname(c, VAR_STORE, STR(CHILD(n, 1)));
  		com_pop(c, 1);
  		Py_DECREF(co);
***************
*** 3875,3883 ****
  {
  	PyObject *doc;
  	node *ch;
! 	REQ(n, funcdef); /* funcdef: 'def' NAME parameters ':' suite */
  	c->c_name = STR(CHILD(n, 1));
! 	doc = get_docstring(c, CHILD(n, 4));
  	if (doc != NULL) {
  		(void) com_addconst(c, doc);
  		Py_DECREF(doc);
--- 3889,3907 ----
  {
  	PyObject *doc;
  	node *ch;
! 	int suite_index;
! 	
! 	REQ(n, funcdef);
! 	/* funcdef: 'def' NAME parameters [ '[' NAME ']' ] ':' suite */
! 	
! 	if (TYPE(CHILD(n, 3)) == LSQB) {
! 		suite_index = 7;
! 	} else {
! 		suite_index = 4;
! 	}
! 	
  	c->c_name = STR(CHILD(n, 1));
! 	doc = get_docstring(c, CHILD(n, suite_index));
  	if (doc != NULL) {
  		(void) com_addconst(c, doc);
  		Py_DECREF(doc);
***************
*** 3889,3895 ****
  	if (TYPE(ch) == varargslist)
  		com_arglist(c, ch);
  	c->c_infunction = 1;
! 	com_node(c, CHILD(n, 4));
  	c->c_infunction = 0;
  	com_addoparg(c, LOAD_CONST, com_addconst(c, Py_None));
  	com_push(c, 1);
--- 3913,3919 ----
  	if (TYPE(ch) == varargslist)
  		com_arglist(c, ch);
  	c->c_infunction = 1;
! 	com_node(c, CHILD(n, suite_index));
  	c->c_infunction = 0;
  	com_addoparg(c, LOAD_CONST, com_addconst(c, Py_None));
  	com_push(c, 1);
***************
*** 5004,5009 ****
--- 5028,5036 ----
  		char *func_name = STR(CHILD(n, 1));
  		symtable_add_def(st, func_name, DEF_LOCAL);
  		symtable_default_args(st, CHILD(n, 2));
+ 		if (TYPE(CHILD(n, 3)) == LSQB) {
+ 			symtable_filters(st, CHILD(n, 4));
+ 		}
  		symtable_enter_scope(st, func_name, TYPE(n), n->n_lineno);
  		symtable_funcdef(st, n);
  		symtable_exit_scope(st);
***************
*** 5216,5221 ****
--- 5243,5260 ----
  		if (i > 0 && (TYPE(CHILD(n, i - 1)) == EQUAL))
  			symtable_node(st, CHILD(n, i));
  	}
+ }
+ 
+ static void
+ symtable_filters(struct symtable *st, node *n)
+ {
+ 	int i;
+ 	int len;
+ 	
+ 	REQ(n, exprlist);
+ 	len = (NCH(n) + 1) / 2;
+ 	for (i = 0; i < NCH(n); i += 2)
+ 		symtable_node(st, CHILD(n, i));
  }
  
  static void
