summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorMarta Gómez Macías <mgmacias@google.com>2023-05-21 00:03:02 (GMT)
committerGitHub <noreply@github.com>2023-05-21 00:03:02 (GMT)
commit6715f91edcf6f379f666e18f57b8a0dcb724bf79 (patch)
tree25724d6eb5b8ff5e713f7bfd8f6c33e5a6d87f62 /Doc
parent3ed57e4995d9f8583083483f397ddc3131720953 (diff)
downloadcpython-6715f91edcf6f379f666e18f57b8a0dcb724bf79.zip
cpython-6715f91edcf6f379f666e18f57b8a0dcb724bf79.tar.gz
cpython-6715f91edcf6f379f666e18f57b8a0dcb724bf79.tar.bz2
gh-102856: Python tokenizer implementation for PEP 701 (#104323)
This commit replaces the Python implementation of the tokenize module with an implementation that reuses the real C tokenizer via a private extension module. The tokenize module now implements a compatibility layer that transforms tokens from the C tokenizer into Python tokenize tokens for backward compatibility. As the C tokenizer does not emit some tokens that the Python tokenizer provides (such as comments and non-semantic newlines), a new special mode has been added to the C tokenizer mode that currently is only used via the extension module that exposes it to the Python layer. This new mode forces the C tokenizer to emit these new extra tokens and add the appropriate metadata that is needed to match the old Python implementation. Co-authored-by: Pablo Galindo <pablogsal@gmail.com>
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/token-list.inc4
-rw-r--r--Doc/library/token.rst2
2 files changed, 6 insertions, 0 deletions
diff --git a/Doc/library/token-list.inc b/Doc/library/token-list.inc
index 3b34509..e885de8 100644
--- a/Doc/library/token-list.inc
+++ b/Doc/library/token-list.inc
@@ -223,6 +223,10 @@
.. data:: FSTRING_END
+.. data:: COMMENT
+
+.. data:: NL
+
.. data:: ERRORTOKEN
.. data:: N_TOKENS
diff --git a/Doc/library/token.rst b/Doc/library/token.rst
index a1aceba..903847b 100644
--- a/Doc/library/token.rst
+++ b/Doc/library/token.rst
@@ -50,11 +50,13 @@ The following token type values aren't used by the C tokenizer but are needed fo
the :mod:`tokenize` module.
.. data:: COMMENT
+ :noindex:
Token value used to indicate a comment.
.. data:: NL
+ :noindex:
Token value used to indicate a non-terminating newline. The
:data:`NEWLINE` token indicates the end of a logical line of Python code;