[Python-checkins] python/dist/src/Parser grammar.c,2.20,2.21 metagrammar.c,2.11,2.12 pgen.c,2.24,2.25
gvanrossum@users.sourceforge.net
gvanrossum@users.sourceforge.net
Thu, 17 Apr 2003 07:55:45 -0700
Update of /cvsroot/python/python/dist/src/Parser
In directory sc8-pr-cvs1:/tmp/cvs-serv14389/Parser
Modified Files:
grammar.c metagrammar.c pgen.c
Log Message:
Changes from Jonathan Riehl to allow his pgen extension (PEP 269) to
work. This includes some more code that used to be part of pgen in
the main parser; I'm okay with that. I'll see if the Windows build
needs work next.
Index: grammar.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Parser/grammar.c,v
retrieving revision 2.20
retrieving revision 2.21
diff -C2 -d -r2.20 -r2.21
*** grammar.c 4 Dec 2001 03:18:48 -0000 2.20
--- grammar.c 17 Apr 2003 14:55:41 -0000 2.21
***************
*** 39,43 ****
d = &g->g_dfa[g->g_ndfas++];
d->d_type = type;
! d->d_name = name;
d->d_nstates = 0;
d->d_state = NULL;
--- 39,43 ----
d = &g->g_dfa[g->g_ndfas++];
d->d_type = type;
! d->d_name = strdup(name);
d->d_nstates = 0;
d->d_state = NULL;
***************
*** 99,103 ****
lb = &ll->ll_label[ll->ll_nlabels++];
lb->lb_type = type;
! lb->lb_str = str; /* XXX strdup(str) ??? */
return lb - ll->ll_label;
}
--- 99,106 ----
lb = &ll->ll_label[ll->ll_nlabels++];
lb->lb_type = type;
! lb->lb_str = strdup(str);
! if (Py_DebugFlag)
! printf("Label @ %08x, %d: %s\n", (unsigned)ll, ll->ll_nlabels,
! PyGrammar_LabelRepr(lb));
return lb - ll->ll_label;
}
***************
*** 153,156 ****
--- 156,160 ----
g->g_dfa[i].d_type);
lb->lb_type = g->g_dfa[i].d_type;
+ free(lb->lb_str);
lb->lb_str = NULL;
return;
***************
*** 163,166 ****
--- 167,171 ----
lb->lb_str, i);
lb->lb_type = i;
+ free(lb->lb_str);
lb->lb_str = NULL;
return;
***************
*** 174,184 ****
if (isalpha((int)(lb->lb_str[1])) || lb->lb_str[1] == '_') {
char *p;
if (Py_DebugFlag)
printf("Label %s is a keyword\n", lb->lb_str);
lb->lb_type = NAME;
! lb->lb_str++;
! p = strchr(lb->lb_str, '\'');
if (p)
! *p = '\0';
}
else if (lb->lb_str[2] == lb->lb_str[0]) {
--- 179,199 ----
if (isalpha((int)(lb->lb_str[1])) || lb->lb_str[1] == '_') {
char *p;
+ char *src;
+ char *dest;
+ size_t name_len;
if (Py_DebugFlag)
printf("Label %s is a keyword\n", lb->lb_str);
lb->lb_type = NAME;
! src = lb->lb_str + 1;
! p = strchr(src, '\'');
if (p)
! name_len = p - src;
! else
! name_len = strlen(src);
! dest = malloc(name_len + 1);
! strncpy(dest, src, name_len);
! dest[name_len] = '\0';
! free(lb->lb_str);
! lb->lb_str = dest;
}
else if (lb->lb_str[2] == lb->lb_str[0]) {
***************
*** 186,189 ****
--- 201,205 ----
if (type != OP) {
lb->lb_type = type;
+ free(lb->lb_str);
lb->lb_str = NULL;
}
***************
*** 197,200 ****
--- 213,217 ----
if (type != OP) {
lb->lb_type = type;
+ free(lb->lb_str);
lb->lb_str = NULL;
}
***************
*** 209,212 ****
--- 226,230 ----
if (type != OP) {
lb->lb_type = type;
+ free(lb->lb_str);
lb->lb_str = NULL;
}
Index: metagrammar.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Parser/metagrammar.c,v
retrieving revision 2.11
retrieving revision 2.12
diff -C2 -d -r2.11 -r2.12
*** metagrammar.c 1 Sep 2000 23:29:28 -0000 2.11
--- metagrammar.c 17 Apr 2003 14:55:41 -0000 2.12
***************
*** 152,153 ****
--- 152,159 ----
return &_PyParser_Grammar;
}
+
+ grammar *
+ Py_meta_grammar(void)
+ {
+ return meta_grammar();
+ }
Index: pgen.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Parser/pgen.c,v
retrieving revision 2.24
retrieving revision 2.25
diff -C2 -d -r2.24 -r2.25
*** pgen.c 28 Feb 2003 15:27:40 -0000 2.24
--- pgen.c 17 Apr 2003 14:55:42 -0000 2.25
***************
*** 670,673 ****
--- 670,678 ----
}
+ grammar *
+ Py_pgen(node *n)
+ {
+ return pgen(n);
+ }
/*