]> granicus.if.org Git - python/commitdiff
bpo-36623: Clean parser headers and include files (GH-12253)
authorPablo Galindo <Pablogsal@gmail.com>
Sat, 13 Apr 2019 16:05:14 +0000 (17:05 +0100)
committerGitHub <noreply@github.com>
Sat, 13 Apr 2019 16:05:14 +0000 (17:05 +0100)
After the removal of pgen, multiple header and function prototypes that lack implementation or are unused are still lying around.

19 files changed:
Doc/whatsnew/3.8.rst
Include/bitset.h
Include/grammar.h
Include/pgenheaders.h [deleted file]
Makefile.pre.in
Misc/NEWS.d/next/Core and Builtins/2019-04-13-02-08-44.bpo-36623.HR_xhB.rst [new file with mode: 0644]
PCbuild/pythoncore.vcxproj
PCbuild/pythoncore.vcxproj.filters
Parser/acceler.c
Parser/grammar1.c
Parser/listnode.c
Parser/parser.c
Parser/parser.h
Parser/parsetok.c
Parser/pgen/grammar.py
Parser/tokenizer.c
Parser/tokenizer.h
Python/graminit.c
Python/strdup.c

index bf28e5ff4b06c2a148caf46401566d5f9ca1522e..39a0da5e61e9ff9a721321dbc01cc963a3e36a69 100644 (file)
@@ -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
 --------------------
index b22fa77815cfb8316fedbfff50c2de5074f9ed64..6a2ac9787eaba30743b053e405c90e09a6308516 100644 (file)
@@ -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
 }
index 68b928c97189244967cf4d5b9db3d7bc93057235..7a6182bb76d57cfeb409d835a797d48ab19f576f 100644 (file)
@@ -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
diff --git a/Include/pgenheaders.h b/Include/pgenheaders.h
deleted file mode 100644 (file)
index dbc5e0a..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-#ifndef Py_PGENHEADERS_H
-#define Py_PGENHEADERS_H
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/* Include files and extern declarations used by most of the parser. */
-
-#include "Python.h"
-
-PyAPI_FUNC(void) PySys_WriteStdout(const char *format, ...)
-                        Py_GCC_ATTRIBUTE((format(printf, 1, 2)));
-PyAPI_FUNC(void) PySys_WriteStderr(const char *format, ...)
-                        Py_GCC_ATTRIBUTE((format(printf, 1, 2)));
-
-#define addarc _Py_addarc
-#define addbit _Py_addbit
-#define adddfa _Py_adddfa
-#define addfirstsets _Py_addfirstsets
-#define addlabel _Py_addlabel
-#define addstate _Py_addstate
-#define delbitset _Py_delbitset
-#define dumptree _Py_dumptree
-#define findlabel _Py_findlabel
-#define freegrammar _Py_freegrammar
-#define mergebitset _Py_mergebitset
-#define meta_grammar _Py_meta_grammar
-#define newbitset _Py_newbitset
-#define newgrammar _Py_newgrammar
-#define pgen _Py_pgen
-#define printgrammar _Py_printgrammar
-#define printnonterminals _Py_printnonterminals
-#define printtree _Py_printtree
-#define samebitset _Py_samebitset
-#define showtree _Py_showtree
-#define tok_dump _Py_tok_dump
-#define translatelabels _Py_translatelabels
-
-#ifdef __cplusplus
-}
-#endif
-#endif /* !Py_PGENHEADERS_H */
index 1cb8a590d45bfc1ee471b3350d15e69e58c9650e..05c195767a8ba082419aff29ea30577f340df10c 100644 (file)
@@ -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 \
diff --git a/Misc/NEWS.d/next/Core and Builtins/2019-04-13-02-08-44.bpo-36623.HR_xhB.rst b/Misc/NEWS.d/next/Core and Builtins/2019-04-13-02-08-44.bpo-36623.HR_xhB.rst
new file mode 100644 (file)
index 0000000..cc90973
--- /dev/null
@@ -0,0 +1,2 @@
+Remove parser headers and related function declarations that lack
+implementations after the removal of pgen.
index c9ff2f88d8e09e3fab37f1857e84b937942ead67..a980799461a306006c509f921eb8692bf18cbeb1 100644 (file)
     <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" />
index 5dfa193f048a5df39c397333c841acc8f0ef1a0b..f92433e3e0c97e5381300e54f709b1a736c4e7e3 100644 (file)
     <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>
index 9b14263b461ace5d22b40a80d9bc2942978e81af..3a230c19bb9f8097f268761193a3ab8b850ef8e3 100644 (file)
@@ -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"
index 9c323911ab26a6e63d0610494b9585c9ad9dbc14..fec6d9ec0ee28161cc025b8236baa7db05936e93 100644 (file)
@@ -2,7 +2,6 @@
 /* Grammar subroutines needed by parser */
 
 #include "Python.h"
-#include "pgenheaders.h"
 #include "grammar.h"
 #include "token.h"
 
index 71300ae908ae155753da4b088633a296d390fa60..8f1a1163b63d5c137b0d0e3b01ac655339a8c73b 100644 (file)
@@ -1,7 +1,7 @@
 
 /* List a node on a file */
 
-#include "pgenheaders.h"
+#include "Python.h"
 #include "token.h"
 #include "node.h"
 
index fa4a8f011ff525193b31dd5187ace3ebc61a385b..c21b6fdf466d9984db326915c316675129005722 100644 (file)
@@ -6,7 +6,6 @@
 /* XXX To do: error recovery */
 
 #include "Python.h"
-#include "pgenheaders.h"
 #include "token.h"
 #include "grammar.h"
 #include "node.h"
index aee1c86cb044e93d5343a0802026993b53325b95..ebb06c2b1976e1b1da28baf22201801debd47495 100644 (file)
@@ -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
index ba33a9a0586f1a3d75d1a46fc5fc03102abc7a9a..31be0ebbde2d278af73b9f956a32e8645b6e5584 100644 (file)
@@ -1,7 +1,7 @@
 
 /* Parser-tokenizer link implementation */
 
-#include "pgenheaders.h"
+#include "Python.h"
 #include "tokenizer.h"
 #include "node.h"
 #include "grammar.h"
index 340bf64f6d2358c1d2a486304be7df6a65563298..1ab9434fa887a6b1d2727cb688f61a414b7bb504 100644 (file)
@@ -61,7 +61,6 @@ class Grammar:
     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")
 
index 58dd1cd30b37b94b728fd7a71c6568a37373418a..e8068f268074b1c290c0e8fb173d7b64695c8736 100644 (file)
@@ -2,7 +2,6 @@
 /* Tokenizer implementation */
 
 #include "Python.h"
-#include "pgenheaders.h"
 
 #include <ctype.h>
 #include <assert.h>
index 06c7a14b70b061d4c5497895deebd62ce44b2ef7..92669bfd8a1607fbe450ee9f904f949dac9075f4 100644 (file)
@@ -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
index 441502e90876144c80f369ca971a869ec27015ec..cd90032417004c1ff11ea04e3789d2e4b7fd41ee 100644 (file)
@@ -1,6 +1,5 @@
 /* Generated by Parser/pgen */
 
-#include "pgenheaders.h"
 #include "grammar.h"
 grammar _PyParser_Grammar;
 static arc arcs_0_0[3] = {
index 99dc77417bd6d17f34e43aaa3e74ed6e43a1e835..6ce171b21fe6c45e1ec25f145b36275789869642 100644 (file)
@@ -1,7 +1,5 @@
 /* strdup() replacement (from stdwin, if you must know) */
 
-#include "pgenheaders.h"
-
 char *
 strdup(const char *str)
 {