Skip to content

Commit

Permalink
bpo-36623: Clean parser headers and include files (pythonGH-12253)
Browse files Browse the repository at this point in the history
After the removal of pgen, multiple header and function prototypes that lack implementation or are unused are still lying around.
  • Loading branch information
pablogsal authored Apr 13, 2019
1 parent f8716c8 commit f2cf1e3
Show file tree
Hide file tree
Showing 19 changed files with 16 additions and 83 deletions.
4 changes: 4 additions & 0 deletions Doc/whatsnew/3.8.rst
Original file line number Diff line number Diff line change
Expand Up @@ -814,6 +814,10 @@ Changes in the Python API
by the installer).
(See :issue:`36085`.)

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


Changes in the C API
--------------------
Expand Down
9 changes: 0 additions & 9 deletions Include/bitset.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,14 @@ extern "C" {
/* Bitset interface */

#define BYTE char

typedef BYTE *bitset;

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

#define BITSPERBYTE (8*sizeof(BYTE))
#define NBYTES(nbits) (((nbits) + BITSPERBYTE - 1) / BITSPERBYTE)

#define BIT2BYTE(ibit) ((ibit) / BITSPERBYTE)
#define BIT2SHIFT(ibit) ((ibit) % BITSPERBYTE)
#define BIT2MASK(ibit) (1 << BIT2SHIFT(ibit))
#define BYTE2BIT(ibyte) ((ibyte) * BITSPERBYTE)

#ifdef __cplusplus
}
Expand Down
16 changes: 0 additions & 16 deletions Include/grammar.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,27 +66,11 @@ typedef struct {
} grammar;

/* FUNCTIONS */

grammar *newgrammar(int start);
void freegrammar(grammar *g);
dfa *adddfa(grammar *g, int type, const char *name);
int addstate(dfa *d);
void addarc(dfa *d, int from, int to, int lbl);
dfa *PyGrammar_FindDFA(grammar *g, int type);

int addlabel(labellist *ll, int type, const char *str);
int findlabel(labellist *ll, int type, const char *str);
const char *PyGrammar_LabelRepr(label *lb);
void translatelabels(grammar *g);

void addfirstsets(grammar *g);

void PyGrammar_AddAccelerators(grammar *g);
void PyGrammar_RemoveAccelerators(grammar *);

void printgrammar(grammar *g, FILE *fp);
void printnonterminals(grammar *g, FILE *fp);

#ifdef __cplusplus
}
#endif
Expand Down
43 changes: 0 additions & 43 deletions Include/pgenheaders.h

This file was deleted.

1 change: 0 additions & 1 deletion Makefile.pre.in
Original file line number Diff line number Diff line change
Expand Up @@ -1008,7 +1008,6 @@ PYTHON_HEADERS= \
$(srcdir)/Include/osdefs.h \
$(srcdir)/Include/osmodule.h \
$(srcdir)/Include/patchlevel.h \
$(srcdir)/Include/pgenheaders.h \
$(srcdir)/Include/pyarena.h \
$(srcdir)/Include/pycapsule.h \
$(srcdir)/Include/pyctype.h \
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Remove parser headers and related function declarations that lack
implementations after the removal of pgen.
1 change: 0 additions & 1 deletion PCbuild/pythoncore.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@
<ClInclude Include="..\Include\osmodule.h" />
<ClInclude Include="..\Include\parsetok.h" />
<ClInclude Include="..\Include\patchlevel.h" />
<ClInclude Include="..\Include\pgenheaders.h" />
<ClInclude Include="..\Include\pyhash.h" />
<ClInclude Include="..\Include\py_curses.h" />
<ClInclude Include="..\Include\pyarena.h" />
Expand Down
3 changes: 0 additions & 3 deletions PCbuild/pythoncore.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -267,9 +267,6 @@
<ClInclude Include="..\Include\patchlevel.h">
<Filter>Include</Filter>
</ClInclude>
<ClInclude Include="..\Include\pgenheaders.h">
<Filter>Include</Filter>
</ClInclude>
<ClInclude Include="..\Include\py_curses.h">
<Filter>Include</Filter>
</ClInclude>
Expand Down
2 changes: 1 addition & 1 deletion Parser/acceler.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
are not part of the static data structure written on graminit.[ch]
by the parser generator. */

#include "pgenheaders.h"
#include "Python.h"
#include "grammar.h"
#include "node.h"
#include "token.h"
Expand Down
1 change: 0 additions & 1 deletion Parser/grammar1.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
/* Grammar subroutines needed by parser */

#include "Python.h"
#include "pgenheaders.h"
#include "grammar.h"
#include "token.h"

Expand Down
2 changes: 1 addition & 1 deletion Parser/listnode.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

/* List a node on a file */

#include "pgenheaders.h"
#include "Python.h"
#include "token.h"
#include "node.h"

Expand Down
1 change: 0 additions & 1 deletion Parser/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
/* XXX To do: error recovery */

#include "Python.h"
#include "pgenheaders.h"
#include "token.h"
#include "grammar.h"
#include "node.h"
Expand Down
5 changes: 5 additions & 0 deletions Parser/parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ int PyParser_AddToken(parser_state *ps, int type, char *str,
int *expected_ret);
void PyGrammar_AddAccelerators(grammar *g);


#define showtree _Py_showtree
#define printtree _Py_printtree
#define dumptree _Py_dumptree

#ifdef __cplusplus
}
#endif
Expand Down
2 changes: 1 addition & 1 deletion Parser/parsetok.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

/* Parser-tokenizer link implementation */

#include "pgenheaders.h"
#include "Python.h"
#include "tokenizer.h"
#include "node.h"
#include "grammar.h"
Expand Down
1 change: 0 additions & 1 deletion Parser/pgen/grammar.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ def produce_graminit_h(self, writer):
def produce_graminit_c(self, writer):
writer("/* Generated by Parser/pgen */\n\n")

writer('#include "pgenheaders.h"\n')
writer('#include "grammar.h"\n')
writer("grammar _PyParser_Grammar;\n")

Expand Down
1 change: 0 additions & 1 deletion Parser/tokenizer.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
/* Tokenizer implementation */

#include "Python.h"
#include "pgenheaders.h"

#include <ctype.h>
#include <assert.h>
Expand Down
2 changes: 2 additions & 0 deletions Parser/tokenizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ extern struct tok_state *PyTokenizer_FromFile(FILE *, const char*,
extern void PyTokenizer_Free(struct tok_state *);
extern int PyTokenizer_Get(struct tok_state *, char **, char **);

#define tok_dump _Py_tok_dump

#ifdef __cplusplus
}
#endif
Expand Down
1 change: 0 additions & 1 deletion Python/graminit.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/* Generated by Parser/pgen */

#include "pgenheaders.h"
#include "grammar.h"
grammar _PyParser_Grammar;
static arc arcs_0_0[3] = {
Expand Down
2 changes: 0 additions & 2 deletions Python/strdup.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/* strdup() replacement (from stdwin, if you must know) */

#include "pgenheaders.h"

char *
strdup(const char *str)
{
Expand Down

0 comments on commit f2cf1e3

Please sign in to comment.