Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-30455: Generate all token related code and docs from Grammar/Tokens. #10370

Merged
merged 25 commits into from
Dec 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
0b9c9c7
bpo-30455: Generate tokens related C code and docs from token.py.
serhiy-storchaka May 30, 2017
de94fde
Merge branch 'master' into regen-token
serhiy-storchaka Jun 1, 2017
3f78955
Generate regexpes from EXACT_TOKEN_TYPES.
serhiy-storchaka Jun 1, 2017
7a0a67a
Merge branch 'master' into regen-token
serhiy-storchaka Jul 3, 2017
3c10bf6
Fix generating the documentation.
serhiy-storchaka Jul 3, 2017
f116722
Add shebangs and executable bits.
serhiy-storchaka Jul 3, 2017
812fc1f
Add generated file Parser/token_names.h.
serhiy-storchaka Jul 3, 2017
8258f49
Misc other fixes and enhancements.
serhiy-storchaka Jul 3, 2017
b44aa6f
Merge branch 'master' into regen-token
serhiy-storchaka Apr 14, 2018
e26b9c8
Move symbol.py generating code into a separate file.
serhiy-storchaka Apr 14, 2018
33e3724
Fix dependencies for pgen.
serhiy-storchaka Apr 14, 2018
c9966b2
Add a hack for '<>'.
serhiy-storchaka Apr 14, 2018
72bd747
Make _PyParser_TokenNames a const array.
serhiy-storchaka Apr 14, 2018
85f37db
Fix tests.
serhiy-storchaka Apr 14, 2018
27ae82c
Merge branch 'master' into regen-token
serhiy-storchaka Oct 7, 2018
7a38bf0
Remove ASYNC and AWAIT.
serhiy-storchaka Oct 7, 2018
c917a42
Merge branch 'master' into regen-token
serhiy-storchaka Nov 6, 2018
060fda7
Generate all token related files from Grammar/Tokens.
serhiy-storchaka Nov 6, 2018
a6c5cf5
Merge branch 'master' into regen-token2
serhiy-storchaka Nov 18, 2018
063cdaa
Generate descriptions for punctuation and operators.
serhiy-storchaka Nov 18, 2018
5918b41
Add generated files to .gitattributes.
serhiy-storchaka Nov 18, 2018
ceb0eb0
Make generate_token.py compatible with Python 2.7.
serhiy-storchaka Nov 27, 2018
cf1ed31
Quote token strings and fix error handling.
serhiy-storchaka Nov 27, 2018
a01ab65
Merge branch 'master' into regen-token2
serhiy-storchaka Dec 20, 2018
34ff906
Document how to generate Lib/symbol.py.
serhiy-storchaka Dec 20, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,7 @@ Include/opcode.h linguist-generated=true
Python/opcode_targets.h linguist-generated=true
Objects/typeslots.inc linguist-generated=true
Modules/unicodedata_db.h linguist-generated=true
Doc/library/token-list.inc linguist-generated=true
Include/token.h linguist-generated=true
Lib/token.py linguist-generated=true
Parser/token.c linguist-generated=true
206 changes: 206 additions & 0 deletions Doc/library/token-list.inc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

59 changes: 1 addition & 58 deletions Doc/library/token.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,64 +44,7 @@ functions. The functions mirror definitions in the Python C header files.

The token constants are:

.. data:: ENDMARKER
NAME
NUMBER
STRING
NEWLINE
INDENT
DEDENT
LPAR
RPAR
LSQB
RSQB
COLON
COMMA
SEMI
PLUS
MINUS
STAR
SLASH
VBAR
AMPER
LESS
GREATER
EQUAL
DOT
PERCENT
LBRACE
RBRACE
EQEQUAL
NOTEQUAL
LESSEQUAL
GREATEREQUAL
TILDE
CIRCUMFLEX
LEFTSHIFT
RIGHTSHIFT
DOUBLESTAR
PLUSEQUAL
MINEQUAL
STAREQUAL
SLASHEQUAL
PERCENTEQUAL
AMPEREQUAL
VBAREQUAL
CIRCUMFLEXEQUAL
LEFTSHIFTEQUAL
RIGHTSHIFTEQUAL
DOUBLESTAREQUAL
DOUBLESLASH
DOUBLESLASHEQUAL
AT
ATEQUAL
RARROW
ELLIPSIS
OP
ERRORTOKEN
N_TOKENS
NT_OFFSET

.. include:: token-list.inc

The following token type values aren't used by the C tokenizer but are needed for
the :mod:`tokenize` module.
Expand Down
62 changes: 62 additions & 0 deletions Grammar/Tokens
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
ENDMARKER
NAME
NUMBER
STRING
NEWLINE
INDENT
DEDENT

LPAR '('
RPAR ')'
LSQB '['
RSQB ']'
COLON ':'
COMMA ','
SEMI ';'
PLUS '+'
MINUS '-'
STAR '*'
SLASH '/'
VBAR '|'
AMPER '&'
LESS '<'
GREATER '>'
EQUAL '='
DOT '.'
PERCENT '%'
LBRACE '{'
RBRACE '}'
EQEQUAL '=='
NOTEQUAL '!='
LESSEQUAL '<='
GREATEREQUAL '>='
TILDE '~'
CIRCUMFLEX '^'
LEFTSHIFT '<<'
RIGHTSHIFT '>>'
DOUBLESTAR '**'
PLUSEQUAL '+='
MINEQUAL '-='
STAREQUAL '*='
SLASHEQUAL '/='
PERCENTEQUAL '%='
AMPEREQUAL '&='
VBAREQUAL '|='
CIRCUMFLEXEQUAL '^='
LEFTSHIFTEQUAL '<<='
RIGHTSHIFTEQUAL '>>='
DOUBLESTAREQUAL '**='
DOUBLESLASH '//'
DOUBLESLASHEQUAL '//='
AT '@'
ATEQUAL '@='
RARROW '->'
ELLIPSIS '...'

OP
ERRORTOKEN

# These aren't used by the C tokenizer but are needed for tokenize.py
COMMENT
NL
ENCODING
11 changes: 3 additions & 8 deletions Include/token.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading