aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2018-12-22 11:18:40 +0200
committerGitHub <noreply@github.com>2018-12-22 11:18:40 +0200
commit8ac658114dec4964479baecfbc439fceb40eaa79 (patch)
treee66c4c3beda293a6fdf01763306697d15d0af157 /Makefile.pre.in
parent bpo-22703: IDLE: Improve Code Context and Zoom Height menu labels (GH-11214) (diff)
downloadcpython-8ac658114dec4964479baecfbc439fceb40eaa79.tar.gz
cpython-8ac658114dec4964479baecfbc439fceb40eaa79.tar.bz2
cpython-8ac658114dec4964479baecfbc439fceb40eaa79.zip
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.
Diffstat (limited to 'Makefile.pre.in')
-rw-r--r--Makefile.pre.in36
1 files changed, 34 insertions, 2 deletions
diff --git a/Makefile.pre.in b/Makefile.pre.in
index 518602b1a22..04312e1be1c 100644
--- a/Makefile.pre.in
+++ b/Makefile.pre.in
@@ -302,6 +302,7 @@ POBJS= \
Parser/metagrammar.o \
Parser/firstsets.o \
Parser/grammar.o \
+ Parser/token.o \
Parser/pgen.o
PARSER_OBJS= $(POBJS) Parser/myreadline.o Parser/parsetok.o Parser/tokenizer.o
@@ -559,7 +560,7 @@ coverage-lcov:
@echo
# Force regeneration of parser and importlib
-coverage-report: regen-grammar regen-importlib
+coverage-report: regen-grammar regen-token regen-importlib
@ # build with coverage info
$(MAKE) coverage
@ # run tests, ignore failures
@@ -741,7 +742,7 @@ regen-importlib: Programs/_freeze_importlib
# Regenerate all generated files
regen-all: regen-opcode regen-opcode-targets regen-typeslots regen-grammar \
- regen-ast regen-importlib clinic
+ regen-token regen-symbol regen-ast regen-importlib clinic
############################################################################
# Special rules for object files
@@ -849,6 +850,37 @@ regen-opcode:
$(srcdir)/Include/opcode.h.new
$(UPDATE_FILE) $(srcdir)/Include/opcode.h $(srcdir)/Include/opcode.h.new
+.PHONY: regen-token
+regen-token:
+ # Regenerate Doc/library/token-list.inc from Grammar/Tokens
+ # using Tools/scripts/generate_token.py
+ $(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/generate_token.py rst \
+ $(srcdir)/Grammar/Tokens \
+ $(srcdir)/Doc/library/token-list.inc
+ # Regenerate Include/token.h from Grammar/Tokens
+ # using Tools/scripts/generate_token.py
+ $(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/generate_token.py h \
+ $(srcdir)/Grammar/Tokens \
+ $(srcdir)/Include/token.h
+ # Regenerate Parser/token.c from Grammar/Tokens
+ # using Tools/scripts/generate_token.py
+ $(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/generate_token.py c \
+ $(srcdir)/Grammar/Tokens \
+ $(srcdir)/Parser/token.c
+ # Regenerate Lib/token.py from Grammar/Tokens
+ # using Tools/scripts/generate_token.py
+ $(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/generate_token.py py \
+ $(srcdir)/Grammar/Tokens \
+ $(srcdir)/Lib/token.py
+
+.PHONY: regen-symbol
+regen-symbol: $(srcdir)/Include/graminit.h
+ # Regenerate Lib/symbol.py from Include/graminit.h
+ # using Tools/scripts/generate_symbol_py.py
+ $(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/generate_symbol_py.py \
+ $(srcdir)/Include/graminit.h \
+ $(srcdir)/Lib/symbol.py
+
Python/compile.o Python/symtable.o Python/ast_unparse.o Python/ast.o: $(srcdir)/Include/graminit.h $(srcdir)/Include/Python-ast.h
Python/getplatform.o: $(srcdir)/Python/getplatform.c