[3.14] gh-133555: Allow regenerating the parser with Python < 3.14 (GH-133557) (#133630)

gh-133555: Allow regenerating the parser with Python < 3.14 (GH-133557)
(cherry picked from commit b48599b801)

Co-authored-by: Alex Prengère <2138730+alexprengere@users.noreply.github.com>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
This commit is contained in:
Miss Islington (bot) 2025-05-08 03:54:42 +02:00 committed by GitHub
parent ca3e3b8a27
commit aadfc2cbc7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 0 deletions

View file

@ -1,3 +1,8 @@
# When adding new tokens, remember to update the PEG generator in
# Tools/peg_generator/pegen/parser_generator.py
# This will ensure that older versions of Python can generate a Python parser
# using "python -m pegen python <GRAMMAR FILE>".
ENDMARKER
NAME
NUMBER

View file

@ -81,6 +81,11 @@ class RuleCheckingVisitor(GrammarVisitor):
self.tokens.add("FSTRING_START")
self.tokens.add("FSTRING_END")
self.tokens.add("FSTRING_MIDDLE")
# If python < 3.14 add the virtual tstring tokens
if sys.version_info < (3, 14, 0, 'beta', 1):
self.tokens.add("TSTRING_START")
self.tokens.add("TSTRING_END")
self.tokens.add("TSTRING_MIDDLE")
def visit_NameLeaf(self, node: NameLeaf) -> None:
if node.value not in self.rules and node.value not in self.tokens: