[Python-checkins] python/nondist/sandbox/ast astmodule.c,1.1,1.2

jhylton@sourceforge.net jhylton@sourceforge.net
2002年4月12日 08:55:27 -0700


Update of /cvsroot/python/python/nondist/sandbox/ast
In directory usw-pr-cvs1:/tmp/cvs-serv29142
Modified Files:
	astmodule.c 
Log Message:
Enough noodling to handle "global x" but not "global x, y."
Index: astmodule.c
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/ast/astmodule.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** astmodule.c	11 Apr 2002 21:20:19 -0000	1.1
--- astmodule.c	12 Apr 2002 15:55:25 -0000	1.2
***************
*** 10,16 ****
--- 10,34 ----
 extern grammar _PyParser_Grammar; /* From graminit.c */
 
+ extern stmt_ty Global(identifier name);
+ 
+ /* XXX should be seq */
+ static stmt_ty
+ ast_for_global(node *n)
+ {
+ /* global_stmt: 'global' NAME (',' NAME)* */
+ identifier *name;
+ REQ(n, global_stmt);
+ n = CHILD(n, 1);
+ name = PyString_InternFromString(STR(n));
+ if (!name)
+ 	return NULL;
+ return Global(name);
+ }
+ 
 static stmt_ty
 ast_for_stmt(node *n)
 {
+ int i;
+ 
 REQ(n, stmt);
 assert(NCH(n) == 1);
***************
*** 19,24 ****
 	/* I'm explicitly punting on multiple statements joined by a
 	 semicolon. When I do handle it, ast_for_stmt() will have
! 	 to return a sequence of statements.
! 	 */
 	assert(NCH(n) == 2);
 	n = CHILD(n, 0);
--- 37,44 ----
 	/* I'm explicitly punting on multiple statements joined by a
 	 semicolon. When I do handle it, ast_for_stmt() will have
! 	 to return a sequence of statements. It may actually be
! 	 easier to put the check for a several small statements
! 	 joined by a semicolon in the caller. 
! 	*/
 	assert(NCH(n) == 2);
 	n = CHILD(n, 0);
***************
*** 29,32 ****
--- 49,54 ----
 	 fprintf(stderr, "expr_stmt NCH=%d\n", NCH(n));
 	 break;
+ 	case global_stmt:
+ 	 return ast_for_global(n);
 	default:
 	 fprintf(stderr, "TYPE=%d NCH=%d\n", TYPE(n), NCH(n));

AltStyle によって変換されたページ (->オリジナル) /