mirror of
https://github.com/python/cpython.git
synced 2025-07-07 19:35:27 +00:00
Add tests for the C tokenizer and expose it as a private module (GH-27924)
This commit is contained in:
parent
9ed523159c
commit
a24676bedc
9 changed files with 1114 additions and 5 deletions
|
@ -680,5 +680,13 @@ def main():
|
|||
perror("unexpected error: %s" % err)
|
||||
raise
|
||||
|
||||
def _generate_tokens_from_c_tokenizer(source):
|
||||
"""Tokenize a source reading Python code as unicode strings using the internal C tokenizer"""
|
||||
import _tokenize as c_tokenizer
|
||||
for info in c_tokenizer.TokenizerIter(source):
|
||||
tok, type, lineno, end_lineno, col_off, end_col_off, line = info
|
||||
yield TokenInfo(type, tok, (lineno, col_off), (end_lineno, end_col_off), line)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue