]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
bpo-35808: Retire pgen and use pgen2 to generate the parser (GH-11814)
authorPablo Galindo <Pablogsal@gmail.com>
Fri, 1 Mar 2019 23:34:44 +0000 (15:34 -0800)
committerGitHub <noreply@github.com>
Fri, 1 Mar 2019 23:34:44 +0000 (15:34 -0800)
commit1f24a719e7be5e49b876a5dc7daf21d01ee69faa
tree8f8f56cab78ef671a8cb7f54b8ec2495d9a435e6
parent7eebbbd5b3907447eddadf5cb7cb1cc9230d15b2
bpo-35808: Retire pgen and use pgen2 to generate the parser (GH-11814)

Pgen is the oldest piece of technology in the CPython repository, building it requires various #if[n]def PGEN hacks in other parts of the code and it also depends more and more on CPython internals. This commit removes the old pgen C code and replaces it for a new version implemented in pure Python. This is a modified and adapted version of lib2to3/pgen2 that can generate grammar files compatibles with the current parser.

This commit also eliminates all the #ifdef and code branches related to pgen, simplifying the code and making it more maintainable. The regen-grammar step now uses $(PYTHON_FOR_REGEN) that can be any version of the interpreter, so the new pgen code maintains compatibility with older versions of the interpreter (this also allows regenerating the grammar with the current CI solution that uses Python3.5). The new pgen Python module also makes use of the Grammar/Tokens file that holds the token specification, so is always kept in sync and avoids having to maintain duplicate token definitions.
27 files changed:
.gitignore
Include/metagrammar.h [deleted file]
Include/parsetok.h
Include/pgen.h [deleted file]
Makefile.pre.in
Misc/NEWS.d/next/Core and Builtins/2019-02-11-00-50-03.bpo-11814.M12CMH.rst [new file with mode: 0644]
Misc/coverity_model.c
PCbuild/pythoncore.vcxproj
PCbuild/pythoncore.vcxproj.filters
Parser/bitset.c [deleted file]
Parser/firstsets.c [deleted file]
Parser/grammar.c [deleted file]
Parser/metagrammar.c [deleted file]
Parser/parsetok.c
Parser/parsetok_pgen.c [deleted file]
Parser/pgen.c [deleted file]
Parser/pgen/__init__.py [new file with mode: 0644]
Parser/pgen/__main__.py [new file with mode: 0644]
Parser/pgen/grammar.py [new file with mode: 0644]
Parser/pgen/pgen.py [new file with mode: 0644]
Parser/pgen/token.py [new file with mode: 0644]
Parser/pgenmain.c [deleted file]
Parser/printgrammar.c [deleted file]
Parser/tokenizer.c
Parser/tokenizer.h
Parser/tokenizer_pgen.c [deleted file]
Python/graminit.c