bpo-36623: Clean parser headers and include files (GH-12253) · python/cpython@f2cf1e3 (original) (raw)

File tree

19 files changed

lines changed

19 files changed

lines changed

Original file line number Diff line number Diff line change
@@ -814,6 +814,10 @@ Changes in the Python API
814 814 by the installer).
815 815 (See :issue:`36085`.)
816 816
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 +
817 821
818 822 Changes in the C API
819 823 --------------------
Original file line number Diff line number Diff line change
@@ -8,23 +8,14 @@ extern "C" {
8 8 /* Bitset interface */
9 9
10 10 #define BYTE char
11 -
12 11 typedef BYTE *bitset;
13 12
14 -bitset newbitset(int nbits);
15 -void delbitset(bitset bs);
16 13 #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);
20 14
21 15 #define BITSPERBYTE (8*sizeof(BYTE))
22 -#define NBYTES(nbits) (((nbits) + BITSPERBYTE - 1) / BITSPERBYTE)
23 -
24 16 #define BIT2BYTE(ibit) ((ibit) / BITSPERBYTE)
25 17 #define BIT2SHIFT(ibit) ((ibit) % BITSPERBYTE)
26 18 #define BIT2MASK(ibit) (1 << BIT2SHIFT(ibit))
27 -#define BYTE2BIT(ibyte) ((ibyte) * BITSPERBYTE)
28 19
29 20 #ifdef __cplusplus
30 21 }
Original file line number Diff line number Diff line change
@@ -66,27 +66,11 @@ typedef struct {
66 66 } grammar;
67 67
68 68 /* 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);
75 69 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);
79 70 const char *PyGrammar_LabelRepr(label *lb);
80 -void translatelabels(grammar *g);
81 -
82 -void addfirstsets(grammar *g);
83 -
84 71 void PyGrammar_AddAccelerators(grammar *g);
85 72 void PyGrammar_RemoveAccelerators(grammar *);
86 73
87 -void printgrammar(grammar *g, FILE *fp);
88 -void printnonterminals(grammar *g, FILE *fp);
89 -
90 74 #ifdef __cplusplus
91 75 }
92 76 #endif
Original file line number Diff line number Diff line change
@@ -1008,7 +1008,6 @@ PYTHON_HEADERS= \
1008 1008 $(srcdir)/Include/osdefs.h \
1009 1009 $(srcdir)/Include/osmodule.h \
1010 1010 $(srcdir)/Include/patchlevel.h \
1011 - $(srcdir)/Include/pgenheaders.h \
1012 1011 $(srcdir)/Include/pyarena.h \
1013 1012 $(srcdir)/Include/pycapsule.h \
1014 1013 $(srcdir)/Include/pyctype.h \
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
1 +Remove parser headers and related function declarations that lack
2 +implementations after the removal of pgen.
Original file line number Diff line number Diff line change
@@ -175,7 +175,6 @@
175 175 <ClInclude Include="..\Include\osmodule.h" />
176 176 <ClInclude Include="..\Include\parsetok.h" />
177 177 <ClInclude Include="..\Include\patchlevel.h" />
178 - <ClInclude Include="..\Include\pgenheaders.h" />
179 178 <ClInclude Include="..\Include\pyhash.h" />
180 179 <ClInclude Include="..\Include\py_curses.h" />
181 180 <ClInclude Include="..\Include\pyarena.h" />
Original file line number Diff line number Diff line change
@@ -267,9 +267,6 @@
267 267 <ClInclude Include="..\Include\patchlevel.h">
268 268 <Filter>Include</Filter>
269 269 </ClInclude>
270 - <ClInclude Include="..\Include\pgenheaders.h">
271 - <Filter>Include</Filter>
272 - </ClInclude>
273 270 <ClInclude Include="..\Include\py_curses.h">
274 271 <Filter>Include</Filter>
275 272 </ClInclude>
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@
10 10 are not part of the static data structure written on graminit.[ch]
11 11 by the parser generator. */
12 12
13 -#include "pgenheaders.h"
13 +#include "Python.h"
14 14 #include "grammar.h"
15 15 #include "node.h"
16 16 #include "token.h"
Original file line number Diff line number Diff line change
@@ -2,7 +2,6 @@
2 2 /* Grammar subroutines needed by parser */
3 3
4 4 #include "Python.h"
5 -#include "pgenheaders.h"
6 5 #include "grammar.h"
7 6 #include "token.h"
8 7
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
1 1
2 2 /* List a node on a file */
3 3
4 -#include "pgenheaders.h"
4 +#include "Python.h"
5 5 #include "token.h"
6 6 #include "node.h"
7 7
Original file line number Diff line number Diff line change
@@ -6,7 +6,6 @@
6 6 /* XXX To do: error recovery */
7 7
8 8 #include "Python.h"
9 -#include "pgenheaders.h"
10 9 #include "token.h"
11 10 #include "grammar.h"
12 11 #include "node.h"
Original file line number Diff line number Diff line change
@@ -38,6 +38,11 @@ int PyParser_AddToken(parser_state *ps, int type, char *str,
38 38 int *expected_ret);
39 39 void PyGrammar_AddAccelerators(grammar *g);
40 40
41 +
42 +#define showtree _Py_showtree
43 +#define printtree _Py_printtree
44 +#define dumptree _Py_dumptree
45 +
41 46 #ifdef __cplusplus
42 47 }
43 48 #endif
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
1 1
2 2 /* Parser-tokenizer link implementation */
3 3
4 -#include "pgenheaders.h"
4 +#include "Python.h"
5 5 #include "tokenizer.h"
6 6 #include "node.h"
7 7 #include "grammar.h"
Original file line number Diff line number Diff line change
@@ -61,7 +61,6 @@ def produce_graminit_h(self, writer):
61 61 def produce_graminit_c(self, writer):
62 62 writer("/* Generated by Parser/pgen */\n\n")
63 63
64 -writer('#include "pgenheaders.h"\n')
65 64 writer('#include "grammar.h"\n')
66 65 writer("grammar _PyParser_Grammar;\n")
67 66
Original file line number Diff line number Diff line change
@@ -2,7 +2,6 @@
2 2 /* Tokenizer implementation */
3 3
4 4 #include "Python.h"
5 -#include "pgenheaders.h"
6 5
7 6 #include <ctype.h>
8 7 #include <assert.h>
Original file line number Diff line number Diff line change
@@ -80,6 +80,8 @@ extern struct tok_state *PyTokenizer_FromFile(FILE *, const char*,
80 80 extern void PyTokenizer_Free(struct tok_state *);
81 81 extern int PyTokenizer_Get(struct tok_state *, char **, char **);
82 82
83 +#define tok_dump _Py_tok_dump
84 +
83 85 #ifdef __cplusplus
84 86 }
85 87 #endif
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
1 1 /* Generated by Parser/pgen */
2 2
3 -#include "pgenheaders.h"
4 3 #include "grammar.h"
5 4 grammar _PyParser_Grammar;
6 5 static arc arcs_0_0[3] = {
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
1 1 /* strdup() replacement (from stdwin, if you must know) */
2 2
3 -#include "pgenheaders.h"
4 -
5 3 char *
6 4 strdup(const char *str)
7 5 {