[Python-checkins] python/dist/src/Python ast.c,1.1.2.29,1.1.2.30

bcannon@users.sourceforge.net bcannon@users.sourceforge.net
Tue, 22 Jul 2003 12:32:42 -0700


Update of /cvsroot/python/python/dist/src/Python
In directory sc8-pr-cvs1:/tmp/cvs-serv23644/Python

Modified Files:
      Tag: ast-branch
	ast.c 
Log Message:
Back out rev. 1.1.2.29 since it does not work.  Also added note about how
default arguments for functions do not work.


Index: ast.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/Attic/ast.c,v
retrieving revision 1.1.2.29
retrieving revision 1.1.2.30
diff -C2 -d -r1.1.2.29 -r1.1.2.30
*** ast.c	1 Jul 2003 05:32:37 -0000	1.1.2.29
--- ast.c	22 Jul 2003 19:32:39 -0000	1.1.2.30
***************
*** 92,100 ****
  }
  
! /* Generate AST from concrete syntax tree
! */
! 
! mod_ty
! PyAST_FromNode(const node *n)
  {
      int i, j, num, total;
--- 92,96 ----
  }
  
! mod_ty PyAST_FromNode(const node *n)
  {
      int i, j, num, total;
***************
*** 356,362 ****
      /* XXX TO DO
         check for invalid argument lists like normal after default
-             DONE; causes bus error since calls to this function do not check
-             for possible NULL result to signal an error.
         handle nested tuple arguments
      */
  
--- 352,357 ----
      /* XXX TO DO
         check for invalid argument lists like normal after default
         handle nested tuple arguments
+        handle default arguments properly (might be problem somwhere else)
      */
  
***************
*** 369,377 ****
      identifier vararg = NULL, kwarg = NULL;
      node *ch;
-     /* Used to make sure that different kinds of arguments come in the proper
-        order */
-     enum parameter_kinds
-             {fpdef_kind=1, defaults_kind=2, vararg_kind=3, kwarg_kind=4}
-             parameter_kind = fpdef_kind;
  
      if (TYPE(n) == parameters) {
--- 364,367 ----
***************
*** 415,437 ****
  		return NULL;
  	    }
! 	    if (TYPE(CHILD(ch, 0)) == NAME) {
!                 if (parameter_kind > fpdef_kind) {
!                     fprintf(stderr, "Error in order of arg kinds\n");
!                     PyErr_Occurred();
!                     return NULL;
!                 }
!                     asdl_seq_APPEND(args, Name(NEW_IDENTIFIER(CHILD(ch, 0)),
!                                     Param));
!                     /* Don't need to set parameter_kind since that is the
!                        default */
!             }
  	    if (i + 1 < NCH(n) && TYPE(CHILD(n, i + 1)) == EQUAL) {
-                 if (parameter_kind > defaults_kind) {
-                     fprintf(stderr, "Error in order of arg kinds\n");
-                     PyErr_Occurred();
-                     return NULL;
-                 }
  		asdl_seq_APPEND(defaults, ast_for_expr(CHILD(n, i + 2)));
-                 parameter_kind = defaults_kind;
  		i += 2;
  	    }
--- 405,413 ----
  		return NULL;
  	    }
! 	    if (TYPE(CHILD(ch, 0)) == NAME)
! 		asdl_seq_APPEND(args, Name(NEW_IDENTIFIER(CHILD(ch, 0)),
! 					   Param));
  	    if (i + 1 < NCH(n) && TYPE(CHILD(n, i + 1)) == EQUAL) {
  		asdl_seq_APPEND(defaults, ast_for_expr(CHILD(n, i + 2)));
  		i += 2;
  	    }
***************
*** 439,459 ****
  	    break;
  	case STAR:
-             if (parameter_kind > vararg_kind) {
-                 fprintf(stderr, "Error in order of arg kinds\n");
-                 PyErr_Occurred();
-                 return NULL;
-             }
  	    vararg = NEW_IDENTIFIER(CHILD(n, i+1));
-             parameter_kind = vararg_kind;
  	    i += 3;
  	    break;
  	case DOUBLESTAR:
-             if (parameter_kind > kwarg_kind) {
-                 fprintf(stderr, "Error in order of arg kinds\n");
-                 PyErr_Occurred();
-                 return NULL;
-             }
  	    kwarg = NEW_IDENTIFIER(CHILD(n, i+1));
-             parameter_kind = kwarg_kind;
  	    i += 3;
  	    break;
--- 415,423 ----