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

jhylton@users.sourceforge.net jhylton@users.sourceforge.net
Fri, 30 Aug 2002 13:12:10 -0700


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

Modified Files:
      Tag: ast-branch
	ast.c 
Log Message:
A large collection of improvements.

Handle a simple_stmt that contains multiple small_stmt elements.
Getting this right ends up having far-reaching changes, since callers
of ast_for_stmt() must guarantee that the node they pass contains only
a single stmt. 

Add num_stmts() helper function that counts the number of contained
statements. 

Extend PyAST_FromNode() to handle single_input.

Mark more internal functions as taking a const node *.

Add parsenumber() function from old compile.c and call it when
creating a Num() type.  XXX Not sure what this means for marshalling.

Track changes to asdl_seq_ API, removing most uses of append.

Simplify BoolOp handling by collapsing test and and_test code.

Fix handling of the power production when multiple trailers.  It still
doesn't do function calls, but it does handle repeated attribute
access and subscripting.

Fix subtle bug in If() handling that ended up creating a circular
reference instead of a properly nested if/else.




Index: ast.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/Attic/ast.c,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -C2 -d -r1.1.2.2 -r1.1.2.3
*** ast.c	23 Aug 2002 18:21:22 -0000	1.1.2.2
--- ast.c	30 Aug 2002 20:12:05 -0000	1.1.2.3
***************
*** 16,60 ****
  */
  
! static asdl_seq *seq_for_testlist(node *);
! static expr_ty ast_for_expr(node *);
! static stmt_ty ast_for_stmt(node *);
! static asdl_seq *ast_for_suite(node *);
! static asdl_seq *ast_for_exprlist(node *, int);
! static expr_ty ast_for_testlist(node *);
  
  extern grammar _PyParser_Grammar; /* From graminit.c */
[...1215 lines suppressed...]
+ 		return PyInt_FromLong(x);
+ 	}
+ 	/* XXX Huge floats may silently fail */
+ #ifndef WITHOUT_COMPLEX
+ 	if (imflag) {
+ 		c.real = 0.;
+ 		PyFPE_START_PROTECT("atof", return 0)
+ 		c.imag = atof(s);
+ 		PyFPE_END_PROTECT(c)
+ 		return PyComplex_FromCComplex(c);
+ 	}
+ 	else
+ #endif
+ 	{
+ 		PyFPE_START_PROTECT("atof", return 0)
+ 		dx = atof(s);
+ 		PyFPE_END_PROTECT(dx)
+ 		return PyFloat_FromDouble(dx);
+ 	}
+ }