Another directory quickly renamed. · pythoncapi/cpython@86bea46 · GitHub
Skip to content

Commit 86bea46

Browse files
committed
Another directory quickly renamed.
1 parent 2b713b2 commit 86bea46

18 files changed

Lines changed: 218 additions & 205 deletions

Parser/acceler.c

Lines changed: 7 additions & 7 deletions

Parser/bitset.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ newbitset(nbits)
3939
int nbits;
4040
{
4141
int nbytes = NBYTES(nbits);
42-
bitset ss = NEW(BYTE, nbytes);
42+
bitset ss = PyMem_NEW(BYTE, nbytes);
4343

4444
if (ss == NULL)
45-
fatal("no mem for bitset");
45+
Py_FatalError("no mem for bitset");
4646

4747
ss += nbytes;
4848
while (--nbytes >= 0)
@@ -54,7 +54,7 @@ void
5454
delbitset(ss)
5555
bitset ss;
5656
{
57-
DEL(ss);
57+
PyMem_DEL(ss);
5858
}
5959

6060
int

Parser/firstsets.c

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ PERFORMANCE OF THIS SOFTWARE.
3535
#include "grammar.h"
3636
#include "token.h"
3737

38-
extern int debugging;
38+
extern int Py_DebugFlag;
3939

4040
/* Forward */
41-
static void calcfirstset PROTO((grammar *, dfa *));
41+
static void calcfirstset Py_PROTO((grammar *, dfa *));
4242

4343
void
4444
addfirstsets(g)
@@ -72,7 +72,7 @@ calcfirstset(g, d)
7272
dfa *d1;
7373
label *l0;
7474

75-
if (debugging)
75+
if (Py_DebugFlag)
7676
printf("Calculate FIRST set for '%s'\n", d->d_name);
7777

7878
if (dummy == NULL)
@@ -91,9 +91,9 @@ calcfirstset(g, d)
9191
nbits = g->g_ll.ll_nlabels;
9292
result = newbitset(nbits);
9393

94-
sym = NEW(int, 1);
94+
sym = PyMem_NEW(int, 1);
9595
if (sym == NULL)
96-
fatal("no mem for new sym in calcfirstset");
96+
Py_FatalError("no mem for new sym in calcfirstset");
9797
nsyms = 1;
9898
sym[0] = findlabel(&g->g_ll, d->d_type, (char *)NULL);
9999

@@ -105,13 +105,14 @@ calcfirstset(g, d)
105105
break;
106106
}
107107
if (j >= nsyms) { /* New label */
108-
RESIZE(sym, int, nsyms + 1);
108+
PyMem_RESIZE(sym, int, nsyms + 1);
109109
if (sym == NULL)
110-
fatal("no mem to resize sym in calcfirstset");
110+
Py_FatalError(
111+
"no mem to resize sym in calcfirstset");
111112
sym[nsyms++] = a->a_lbl;
112113
type = l0[a->a_lbl].lb_type;
113114
if (ISNONTERMINAL(type)) {
114-
d1 = finddfa(g, type);
115+
d1 = PyGrammar_FindDFA(g, type);
115116
if (d1->d_first == dummy) {
116117
fprintf(stderr,
117118
"Left-recursion below '%s'\n",
@@ -120,7 +121,8 @@ calcfirstset(g, d)
120121
else {
121122
if (d1->d_first == NULL)
122123
calcfirstset(g, d1);
123-
mergebitset(result, d1->d_first, nbits);
124+
mergebitset(result,
125+
d1->d_first, nbits);
124126
}
125127
}
126128
else if (ISTERMINAL(type)) {
@@ -129,11 +131,11 @@ calcfirstset(g, d)
129131
}
130132
}
131133
d->d_first = result;
132-
if (debugging) {
134+
if (Py_DebugFlag) {
133135
printf("FIRST set for '%s': {", d->d_name);
134136
for (i = 0; i < nbits; i++) {
135137
if (testbit(result, i))
136-
printf(" %s", labelrepr(&l0[i]));
138+
printf(" %s", PyGrammar_LabelRepr(&l0[i]));
137139
}
138140
printf(" }\n");
139141
}

Parser/grammar.c

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,17 @@ PERFORMANCE OF THIS SOFTWARE.
3939
#include "token.h"
4040
#include "grammar.h"
4141

42-
extern int debugging;
42+
extern int Py_DebugFlag;
4343

4444
grammar *
4545
newgrammar(start)
4646
int start;
4747
{
4848
grammar *g;
4949

50-
g = NEW(grammar, 1);
50+
g = PyMem_NEW(grammar, 1);
5151
if (g == NULL)
52-
fatal("no mem for new grammar");
52+
Py_FatalError("no mem for new grammar");
5353
g->g_ndfas = 0;
5454
g->g_dfa = NULL;
5555
g->g_start = start;
@@ -67,9 +67,9 @@ adddfa(g, type, name)
6767
{
6868
dfa *d;
6969

70-
RESIZE(g->g_dfa, dfa, g->g_ndfas + 1);
70+
PyMem_RESIZE(g->g_dfa, dfa, g->g_ndfas + 1);
7171
if (g->g_dfa == NULL)
72-
fatal("no mem to resize dfa in adddfa");
72+
Py_FatalError("no mem to resize dfa in adddfa");
7373
d = &g->g_dfa[g->g_ndfas++];
7474
d->d_type = type;
7575
d->d_name = name;
@@ -86,9 +86,9 @@ addstate(d)
8686
{
8787
state *s;
8888

89-
RESIZE(d->d_state, state, d->d_nstates + 1);
89+
PyMem_RESIZE(d->d_state, state, d->d_nstates + 1);
9090
if (d->d_state == NULL)
91-
fatal("no mem to resize state in addstate");
91+
Py_FatalError("no mem to resize state in addstate");
9292
s = &d->d_state[d->d_nstates++];
9393
s->s_narcs = 0;
9494
s->s_arc = NULL;
@@ -111,9 +111,9 @@ addarc(d, from, to, lbl)
111111
assert(0 <= to && to < d->d_nstates);
112112

113113
s = &d->d_state[from];
114-
RESIZE(s->s_arc, arc, s->s_narcs + 1);
114+
PyMem_RESIZE(s->s_arc, arc, s->s_narcs + 1);
115115
if (s->s_arc == NULL)
116-
fatal("no mem to resize arc list in addarc");
116+
Py_FatalError("no mem to resize arc list in addarc");
117117
a = &s->s_arc[s->s_narcs++];
118118
a->a_lbl = lbl;
119119
a->a_arrow = to;
@@ -133,9 +133,9 @@ addlabel(ll, type, str)
133133
strcmp(ll->ll_label[i].lb_str, str) == 0)
134134
return i;
135135
}
136-
RESIZE(ll->ll_label, label, ll->ll_nlabels + 1);
136+
PyMem_RESIZE(ll->ll_label, label, ll->ll_nlabels + 1);
137137
if (ll->ll_label == NULL)
138-
fatal("no mem to resize labellist in addlabel");
138+
Py_FatalError("no mem to resize labellist in addlabel");
139139
lb = &ll->ll_label[ll->ll_nlabels++];
140140
lb->lb_type = type;
141141
lb->lb_str = str; /* XXX strdup(str) ??? */
@@ -158,12 +158,12 @@ findlabel(ll, type, str)
158158
return i;
159159
}
160160
fprintf(stderr, "Label %d/'%s' not found\n", type, str);
161-
fatal("grammar.c:findlabel()");
161+
Py_FatalError("grammar.c:findlabel()");
162162
return 0; /* Make gcc -Wall happy */
163163
}
164164

165165
/* Forward */
166-
static void translabel PROTO((grammar *, label *));
166+
static void translabel Py_PROTO((grammar *, label *));
167167

168168
void
169169
translatelabels(g)
@@ -186,24 +186,25 @@ translabel(g, lb)
186186
{
187187
int i;
188188

189-
if (debugging)
190-
printf("Translating label %s ...\n", labelrepr(lb));
189+
if (Py_DebugFlag)
190+
printf("Translating label %s ...\n", PyGrammar_LabelRepr(lb));
191191

192192
if (lb->lb_type == NAME) {
193193
for (i = 0; i < g->g_ndfas; i++) {
194194
if (strcmp(lb->lb_str, g->g_dfa[i].d_name) == 0) {
195-
if (debugging)
196-
printf("Label %s is non-terminal %d.\n",
197-
lb->lb_str,
198-
g->g_dfa[i].d_type);
195+
if (Py_DebugFlag)
196+
printf(
197+
"Label %s is non-terminal %d.\n",
198+
lb->lb_str,
199+
g->g_dfa[i].d_type);
199200
lb->lb_type = g->g_dfa[i].d_type;
200201
lb->lb_str = NULL;
201202
return;
202203
}
203204
}
204205
for (i = 0; i < (int)N_TOKENS; i++) {
205-
if (strcmp(lb->lb_str, tok_name[i]) == 0) {
206-
if (debugging)
206+
if (strcmp(lb->lb_str, _PyParser_TokenNames[i]) == 0) {
207+
if (Py_DebugFlag)
207208
printf("Label %s is terminal %d.\n",
208209
lb->lb_str, i);
209210
lb->lb_type = i;
@@ -218,7 +219,7 @@ translabel(g, lb)
218219
if (lb->lb_type == STRING) {
219220
if (isalpha(lb->lb_str[1]) || lb->lb_str[1] == '_') {
220221
char *p;
221-
if (debugging)
222+
if (Py_DebugFlag)
222223
printf("Label %s is a keyword\n", lb->lb_str);
223224
lb->lb_type = NAME;
224225
lb->lb_str++;
@@ -227,7 +228,7 @@ translabel(g, lb)
227228
*p = '\0';
228229
}
229230
else if (lb->lb_str[2] == lb->lb_str[0]) {
230-
int type = (int) tok_1char(lb->lb_str[1]);
231+
int type = (int) PyToken_OneChar(lb->lb_str[1]);
231232
if (type != OP) {
232233
lb->lb_type = type;
233234
lb->lb_str = NULL;
@@ -237,7 +238,7 @@ translabel(g, lb)
237238
lb->lb_str);
238239
}
239240
else if (lb->lb_str[2] && lb->lb_str[3] == lb->lb_str[0]) {
240-
int type = (int) tok_2char(lb->lb_str[1],
241+
int type = (int) PyToken_TwoChars(lb->lb_str[1],
241242
lb->lb_str[2]);
242243
if (type != OP) {
243244
lb->lb_type = type;
@@ -252,5 +253,6 @@ translabel(g, lb)
252253
lb->lb_str);
253254
}
254255
else
255-
printf("Can't translate label '%s'\n", labelrepr(lb));
256+
printf("Can't translate label '%s'\n",
257+
PyGrammar_LabelRepr(lb));
256258
}

Parser/grammar1.c

Lines changed: 4 additions & 4 deletions

0 commit comments

Comments
 (0)