Skip to content

Commit f2cf1e3

Browse files
authored
bpo-36623: Clean parser headers and include files (pythonGH-12253)
After the removal of pgen, multiple header and function prototypes that lack implementation or are unused are still lying around.
1 parent f8716c8 commit f2cf1e3

19 files changed

+16
-83
lines changed

Doc/whatsnew/3.8.rst

+4
Original file line numberDiff line numberDiff line change
@@ -814,6 +814,10 @@ Changes in the Python API
814814
by the installer).
815815
(See :issue:`36085`.)
816816

817+
* The header files and functions related to pgen have been removed after its
818+
replacement by a pure Python implementation. (Contributed by Pablo Galindo
819+
in :issue:`36623`.)
820+
817821

818822
Changes in the C API
819823
--------------------

Include/bitset.h

-9
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,14 @@ extern "C" {
88
/* Bitset interface */
99

1010
#define BYTE char
11-
1211
typedef BYTE *bitset;
1312

14-
bitset newbitset(int nbits);
15-
void delbitset(bitset bs);
1613
#define testbit(ss, ibit) (((ss)[BIT2BYTE(ibit)] & BIT2MASK(ibit)) != 0)
17-
int addbit(bitset bs, int ibit); /* Returns 0 if already set */
18-
int samebitset(bitset bs1, bitset bs2, int nbits);
19-
void mergebitset(bitset bs1, bitset bs2, int nbits);
2014

2115
#define BITSPERBYTE (8*sizeof(BYTE))
22-
#define NBYTES(nbits) (((nbits) + BITSPERBYTE - 1) / BITSPERBYTE)
23-
2416
#define BIT2BYTE(ibit) ((ibit) / BITSPERBYTE)
2517
#define BIT2SHIFT(ibit) ((ibit) % BITSPERBYTE)
2618
#define BIT2MASK(ibit) (1 << BIT2SHIFT(ibit))
27-
#define BYTE2BIT(ibyte) ((ibyte) * BITSPERBYTE)
2819

2920
#ifdef __cplusplus
3021
}

Include/grammar.h

-16
Original file line numberDiff line numberDiff line change
@@ -66,27 +66,11 @@ typedef struct {
6666
} grammar;
6767

6868
/* FUNCTIONS */
69-
70-
grammar *newgrammar(int start);
71-
void freegrammar(grammar *g);
72-
dfa *adddfa(grammar *g, int type, const char *name);
73-
int addstate(dfa *d);
74-
void addarc(dfa *d, int from, int to, int lbl);
7569
dfa *PyGrammar_FindDFA(grammar *g, int type);
76-
77-
int addlabel(labellist *ll, int type, const char *str);
78-
int findlabel(labellist *ll, int type, const char *str);
7970
const char *PyGrammar_LabelRepr(label *lb);
80-
void translatelabels(grammar *g);
81-
82-
void addfirstsets(grammar *g);
83-
8471
void PyGrammar_AddAccelerators(grammar *g);
8572
void PyGrammar_RemoveAccelerators(grammar *);
8673

87-
void printgrammar(grammar *g, FILE *fp);
88-
void printnonterminals(grammar *g, FILE *fp);
89-
9074
#ifdef __cplusplus
9175
}
9276
#endif

Include/pgenheaders.h

-43
This file was deleted.

Makefile.pre.in

-1
Original file line numberDiff line numberDiff line change
@@ -1008,7 +1008,6 @@ PYTHON_HEADERS= \
10081008
$(srcdir)/Include/osdefs.h \
10091009
$(srcdir)/Include/osmodule.h \
10101010
$(srcdir)/Include/patchlevel.h \
1011-
$(srcdir)/Include/pgenheaders.h \
10121011
$(srcdir)/Include/pyarena.h \
10131012
$(srcdir)/Include/pycapsule.h \
10141013
$(srcdir)/Include/pyctype.h \
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Remove parser headers and related function declarations that lack
2+
implementations after the removal of pgen.

PCbuild/pythoncore.vcxproj

-1
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@
175175
<ClInclude Include="..\Include\osmodule.h" />
176176
<ClInclude Include="..\Include\parsetok.h" />
177177
<ClInclude Include="..\Include\patchlevel.h" />
178-
<ClInclude Include="..\Include\pgenheaders.h" />
179178
<ClInclude Include="..\Include\pyhash.h" />
180179
<ClInclude Include="..\Include\py_curses.h" />
181180
<ClInclude Include="..\Include\pyarena.h" />

PCbuild/pythoncore.vcxproj.filters

-3
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,6 @@
267267
<ClInclude Include="..\Include\patchlevel.h">
268268
<Filter>Include</Filter>
269269
</ClInclude>
270-
<ClInclude Include="..\Include\pgenheaders.h">
271-
<Filter>Include</Filter>
272-
</ClInclude>
273270
<ClInclude Include="..\Include\py_curses.h">
274271
<Filter>Include</Filter>
275272
</ClInclude>

Parser/acceler.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
are not part of the static data structure written on graminit.[ch]
1111
by the parser generator. */
1212

13-
#include "pgenheaders.h"
13+
#include "Python.h"
1414
#include "grammar.h"
1515
#include "node.h"
1616
#include "token.h"

Parser/grammar1.c

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
/* Grammar subroutines needed by parser */
33

44
#include "Python.h"
5-
#include "pgenheaders.h"
65
#include "grammar.h"
76
#include "token.h"
87

Parser/listnode.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
/* List a node on a file */
33

4-
#include "pgenheaders.h"
4+
#include "Python.h"
55
#include "token.h"
66
#include "node.h"
77

Parser/parser.c

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
/* XXX To do: error recovery */
77

88
#include "Python.h"
9-
#include "pgenheaders.h"
109
#include "token.h"
1110
#include "grammar.h"
1211
#include "node.h"

Parser/parser.h

+5
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ int PyParser_AddToken(parser_state *ps, int type, char *str,
3838
int *expected_ret);
3939
void PyGrammar_AddAccelerators(grammar *g);
4040

41+
42+
#define showtree _Py_showtree
43+
#define printtree _Py_printtree
44+
#define dumptree _Py_dumptree
45+
4146
#ifdef __cplusplus
4247
}
4348
#endif

Parser/parsetok.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
/* Parser-tokenizer link implementation */
33

4-
#include "pgenheaders.h"
4+
#include "Python.h"
55
#include "tokenizer.h"
66
#include "node.h"
77
#include "grammar.h"

Parser/pgen/grammar.py

-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ def produce_graminit_h(self, writer):
6161
def produce_graminit_c(self, writer):
6262
writer("/* Generated by Parser/pgen */\n\n")
6363

64-
writer('#include "pgenheaders.h"\n')
6564
writer('#include "grammar.h"\n')
6665
writer("grammar _PyParser_Grammar;\n")
6766

Parser/tokenizer.c

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
/* Tokenizer implementation */
33

44
#include "Python.h"
5-
#include "pgenheaders.h"
65

76
#include <ctype.h>
87
#include <assert.h>

Parser/tokenizer.h

+2
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ extern struct tok_state *PyTokenizer_FromFile(FILE *, const char*,
8080
extern void PyTokenizer_Free(struct tok_state *);
8181
extern int PyTokenizer_Get(struct tok_state *, char **, char **);
8282

83+
#define tok_dump _Py_tok_dump
84+
8385
#ifdef __cplusplus
8486
}
8587
#endif

Python/graminit.c

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/* Generated by Parser/pgen */
22

3-
#include "pgenheaders.h"
43
#include "grammar.h"
54
grammar _PyParser_Grammar;
65
static arc arcs_0_0[3] = {

Python/strdup.c

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
/* strdup() replacement (from stdwin, if you must know) */
22

3-
#include "pgenheaders.h"
4-
53
char *
64
strdup(const char *str)
75
{

0 commit comments

Comments
 (0)