bpo-40939: Generate keyword.py using the new parser (GH-20800) · python/cpython@961edf7 · GitHub
Skip to content

Commit 961edf7

Browse files
bpo-40939: Generate keyword.py using the new parser (GH-20800)
(cherry picked from commit 9727694) Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
1 parent f6428ba commit 961edf7

6 files changed

Lines changed: 88 additions & 9 deletions

File tree

Lib/keyword.py

Lines changed: 6 additions & 4 deletions

Lib/pydoc.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1817,6 +1817,7 @@ class Helper:
18171817
'False': '',
18181818
'None': '',
18191819
'True': '',
1820+
'__new_parser__': '',
18201821
'and': 'BOOLEAN',
18211822
'as': 'with',
18221823
'assert': ('assert', ''),

Makefile.pre.in

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -895,9 +895,10 @@ regen-token:
895895

896896
.PHONY: regen-keyword
897897
regen-keyword:
898-
# Regenerate Lib/keyword.py from Grammar/Grammar and Grammar/Tokens
899-
# using Parser/pgen
900-
PYTHONPATH=$(srcdir) $(PYTHON_FOR_REGEN) -m Parser.pgen.keywordgen $(srcdir)/Grammar/Grammar \
898+
# Regenerate Lib/keyword.py from Grammar/python.gram and Grammar/Tokens
899+
# using Tools/peg_generator/pegen
900+
PYTHONPATH=$(srcdir)/Tools/peg_generator $(PYTHON_FOR_REGEN) -m pegen.keywordgen \
901+
$(srcdir)/Grammar/python.gram \
901902
$(srcdir)/Grammar/Tokens \
902903
$(srcdir)/Lib/keyword.py.new
903904
$(UPDATE_FILE) $(srcdir)/Lib/keyword.py $(srcdir)/Lib/keyword.py.new
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Use the new PEG parser when generating the stdlib :mod:`keyword` module.

PCbuild/regen.vcxproj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,9 @@
205205
<Exec Command="&quot;$(PythonExe)&quot; $(PySourcePath)Tools\scripts\generate_token.py py &quot;$(PySourcePath)Grammar\Tokens&quot; &quot;$(PySourcePath)Lib\token.py&quot;" />
206206
</Target>
207207
<Target Name="_RegenKeywords" AfterTargets="_RegenTokens">
208-
<!-- Regenerate Lib/keyword.py from Grammar/Grammar and Grammar/Tokens using Parser/pgen-->
209-
<Exec Command="&quot;$(PythonExe)&quot; -m Parser.pgen.keywordgen &quot;$(PySourcePath)Grammar\Grammar&quot; &quot;$(PySourcePath)Grammar\Tokens&quot; &quot;$(IntDir)keyword.py&quot;" />
208+
<!-- Regenerate Lib/keyword.py from Grammar/python.gram and Grammar/Tokens using Tools/peg_generator/pegen-->
209+
<SetEnv Name="PYTHONPATH" Prefix="true" Value="$(PySourcePath)Tools\peg_generator\" />
210+
<Exec Command="&quot;$(PythonExe)&quot; -m pegen.keywordgen &quot;$(PySourcePath)Grammar\python.gram&quot; &quot;$(PySourcePath)Grammar\Tokens&quot; &quot;$(IntDir)keyword.py&quot;" />
210211
<Copy SourceFiles="$(IntDir)keyword.py" DestinationFiles="$(PySourcePath)Lib\keyword.py">
211212
<Output TaskParameter="CopiedFiles" ItemName="_Updated" />
212213
</Copy>
Lines changed: 73 additions & 0 deletions

0 commit comments

Comments
 (0)