[Python-checkins] python/dist/src/Python ast.c,1.1.2.1,1.1.2.2

jhylton@users.sourceforge.net jhylton@users.sourceforge.net
Fri, 23 Aug 2002 11:21:25 -0700


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

Modified Files:
      Tag: ast-branch
	ast.c 
Log Message:
Add primitive support for different kinds of compiled source.

Also handle [].


Index: ast.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/Attic/ast.c,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -C2 -d -r1.1.2.1 -r1.1.2.2
*** ast.c	7 Jul 2002 17:34:44 -0000	1.1.2.1
--- ast.c	23 Aug 2002 18:21:22 -0000	1.1.2.2
***************
*** 31,51 ****
      stmt_ty s;
  
!     REQ(n, file_input);
!     stmts = asdl_seq_new(NCH(n) / 2);
!     for (i = 0; i < NCH(n); i++) {
! 	if (TYPE(CHILD(n, i)) == stmt) {
! 	    s = ast_for_stmt(CHILD(n, i));
! 	    if (!s) {
! 		asdl_seq_free(stmts);
! 		return NULL;
! 	    }
! 	    if (asdl_seq_append(stmts, s) < 0) {
! 		return NULL;
  	    }
! 	}
! 	else
! 	    fprintf(stderr, "skipping %d\n", TYPE(CHILD(n, i)));
      }
!     return Module(stmts);
  }
  
--- 31,61 ----
      stmt_ty s;
  
!     switch (TYPE(n)) {
!     case file_input:
! 	    stmts = asdl_seq_new(NCH(n) / 2);
! 	    for (i = 0; i < NCH(n); i++) {
! 		    if (TYPE(CHILD(n, i)) == stmt) {
! 			    s = ast_for_stmt(CHILD(n, i));
! 			    if (!s) {
! 				    asdl_seq_free(stmts);
! 				    return NULL;
! 			    }
! 			    if (asdl_seq_append(stmts, s) < 0) {
! 				    return NULL;
! 			    }
! 		    }
! 		    else
! 			    fprintf(stderr, "skipping %d\n", 
! 				    TYPE(CHILD(n, i)));
  	    }
! 	    return Module(stmts);
!     case eval_input:
! 	    return Expression(ast_for_testlist(CHILD(n, 0)));
! 	    break;
!     default:
! 	    return NULL;
      }
!     /* Can't get here */
!     return NULL;
  }
  
***************
*** 443,446 ****
--- 453,458 ----
      case LSQB: /* list (or list comprehension) */
  	ch = CHILD(n, 1);
+ 	if (TYPE(ch) == RSQB)
+ 		return List(NULL, Load);
  	REQ(ch, listmaker);
  	if (NCH(ch) == 1 || TYPE(CHILD(ch, 1)) == COMMA)