[Python-checkins] python/dist/src/Python ast.c,1.1.2.47,1.1.2.48
jhylton at users.sourceforge.net
jhylton at users.sourceforge.net
Tue Apr 13 11:01:15 EDT 2004
Update of /cvsroot/python/python/dist/src/Python
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17177/Python
Modified Files:
Tag: ast-branch
ast.c
Log Message:
Fix a couple of wild writes caught by asdl seq debug macros.
Add braces in a couple of places because of debug macros.
Remove a bunch of commented out prints.
Index: ast.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/Attic/ast.c,v
retrieving revision 1.1.2.47
retrieving revision 1.1.2.48
diff -C2 -d -r1.1.2.47 -r1.1.2.48
*** ast.c 8 Apr 2004 18:08:32 -0000 1.1.2.47
--- ast.c 13 Apr 2004 15:01:12 -0000 1.1.2.48
***************
*** 506,516 ****
switch (TYPE(ch)) {
case fpdef:
! if (NCH(ch) == 3)
asdl_seq_APPEND(args,
compiler_complex_args(CHILD(ch, 1)));
! else if (TYPE(CHILD(ch, 0)) == NAME)
/* XXX check return value of Name call */
asdl_seq_APPEND(args, Name(NEW_IDENTIFIER(CHILD(ch, 0)),
Param));
/* XXX Need to worry about checking if TYPE(CHILD(n, i+1)) is
anything other than EQUAL or a comma? */
--- 506,518 ----
switch (TYPE(ch)) {
case fpdef:
! if (NCH(ch) == 3) {
asdl_seq_APPEND(args,
compiler_complex_args(CHILD(ch, 1)));
! }
! else if (TYPE(CHILD(ch, 0)) == NAME) {
/* XXX check return value of Name call */
asdl_seq_APPEND(args, Name(NEW_IDENTIFIER(CHILD(ch, 0)),
Param));
+ }
/* XXX Need to worry about checking if TYPE(CHILD(n, i+1)) is
anything other than EQUAL or a comma? */
***************
*** 671,676 ****
node *ch;
- fprintf(stderr, "listcomp at %d\n", n->n_lineno);
-
REQ(n, listmaker);
assert(NCH(n) > 1);
--- 673,676 ----
***************
*** 775,779 ****
node *ch = CHILD(n, 0);
- /* fprintf(stderr, "ast_for_atom((%d, %d))\n", TYPE(ch), NCH(ch)); */
switch (TYPE(ch)) {
case NAME:
--- 775,778 ----
***************
*** 1002,1006 ****
int i;
- /* fprintf(stderr, "ast_for_expr(%d, %d)\n", TYPE(n), NCH(n)); */
loop:
switch (TYPE(n)) {
--- 1001,1004 ----
***************
*** 1164,1168 ****
int j;
slice_ty slc;
! asdl_seq *slices = asdl_seq_new(NCH(ch) / 2);
if (!slices) {
/* XXX free(e); */
--- 1162,1166 ----
int j;
slice_ty slc;
! asdl_seq *slices = asdl_seq_new((NCH(ch) + 1) / 2);
if (!slices) {
/* XXX free(e); */
***************
*** 1240,1244 ****
nkeywords++;
}
!
args = asdl_seq_new(nargs);
if (!args)
--- 1238,1242 ----
nkeywords++;
}
!
args = asdl_seq_new(nargs);
if (!args)
***************
*** 1328,1332 ****
*/
- /* fprintf(stderr, "ast_for_expr_stmt(%d, %d)\n", TYPE(n), NCH(n)); */
if (NCH(n) == 1) {
expr_ty e = ast_for_testlist(c, CHILD(n, 0));
--- 1326,1329 ----
***************
*** 1425,1429 ****
expr_ty e;
- /* fprintf(stderr, "ast_for_exprlist(%d, %d)\n", TYPE(n), context); */
REQ(n, exprlist);
--- 1422,1425 ----
***************
*** 1756,1763 ****
asdl_seq *seq = NULL;
stmt_ty s;
! int i, total, num, pos = 0;
node *ch;
- /* fprintf(stderr, "ast_for_suite(%d) lineno=%d\n", TYPE(n), n->n_lineno); */
REQ(n, suite);
--- 1752,1758 ----
asdl_seq *seq = NULL;
stmt_ty s;
! int i, total, num, end, pos = 0;
node *ch;
REQ(n, suite);
***************
*** 1768,1773 ****
if (TYPE(CHILD(n, 0)) == simple_stmt) {
n = CHILD(n, 0);
/* loop by 2 to skip semi-colons */
! for (i = 0; i < NCH(n); i += 2) {
ch = CHILD(n, i);
s = ast_for_stmt(c, ch);
--- 1763,1774 ----
if (TYPE(CHILD(n, 0)) == simple_stmt) {
n = CHILD(n, 0);
+ /* simple_stmt always ends with a NEWLINE,
+ and may have a trailing SEMI
+ */
+ end = NCH(n) - 1;
+ if (TYPE(CHILD(n, end - 1)) == SEMI)
+ end--;
/* loop by 2 to skip semi-colons */
! for (i = 0; i < end; i += 2) {
ch = CHILD(n, i);
s = ast_for_stmt(c, ch);
***************
*** 2157,2162 ****
ast_for_stmt(struct compiling *c, const node *n)
{
- /* fprintf(stderr, "ast_for_stmt(%d) lineno=%d\n",
- TYPE(n), n->n_lineno); */
if (TYPE(n) == stmt) {
assert(NCH(n) == 1);
--- 2158,2161 ----
***************
*** 2228,2232 ****
}
-
static PyObject *
parsenumber(const char *s)
--- 2227,2230 ----
More information about the Python-checkins
mailing list