mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
bpo-30455: Generate all token related code and docs from Grammar/Tokens. (GH-10370)
"Include/token.h", "Lib/token.py" (containing now some data moved from "Lib/tokenize.py") and new files "Parser/token.c" (containing the code moved from "Parser/tokenizer.c") and "Doc/library/token-list.inc" (included in "Doc/library/token.rst") are now generated from "Grammar/Tokens" by "Tools/scripts/generate_token.py". The script overwrites files only if needed and can be used on the read-only sources tree. "Lib/symbol.py" is now generated by "Tools/scripts/generate_symbol_py.py" instead of been executable itself. Added new make targets "regen-token" and "regen-symbol" which are now dependencies of "regen-all". The documentation contains now strings for operators and punctuation tokens.
This commit is contained in:
parent
c1b4b0f616
commit
8ac658114d
18 changed files with 940 additions and 462 deletions
20
Lib/symbol.py
Executable file → Normal file
20
Lib/symbol.py
Executable file → Normal file
|
@ -1,5 +1,3 @@
|
|||
#! /usr/bin/env python3
|
||||
|
||||
"""Non-terminal symbols of Python grammar (from "graminit.h")."""
|
||||
|
||||
# This file is automatically generated; please don't muck it up!
|
||||
|
@ -7,7 +5,11 @@
|
|||
# To update the symbols in this file, 'cd' to the top directory of
|
||||
# the python source tree after building the interpreter and run:
|
||||
#
|
||||
# ./python Lib/symbol.py
|
||||
# python3 Tools/scripts/generate_symbol_py.py Include/graminit.h Lib/symbol.py
|
||||
#
|
||||
# or just
|
||||
#
|
||||
# make regen-symbol
|
||||
|
||||
#--start constants--
|
||||
single_input = 256
|
||||
|
@ -103,14 +105,4 @@ sym_name = {}
|
|||
for _name, _value in list(globals().items()):
|
||||
if type(_value) is type(0):
|
||||
sym_name[_value] = _name
|
||||
|
||||
|
||||
def _main():
|
||||
import sys
|
||||
import token
|
||||
if len(sys.argv) == 1:
|
||||
sys.argv = sys.argv + ["Include/graminit.h", "Lib/symbol.py"]
|
||||
token._main()
|
||||
|
||||
if __name__ == "__main__":
|
||||
_main()
|
||||
del _name, _value
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue