~dkuhlman/python-training-materials/Materials

« back to all changes in this revision

Viewing changes to python-3.5.1-docs-html/_sources/library/token.txt

  • Committer: Dave Kuhlman
  • Date: 2017-04-15 16:24:56 UTC
  • Revision ID: dkuhlman@davekuhlman.org-20170415162456-iav9vozzg4iwqwv3
Updated docs

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
:mod:`token` --- Constants used with Python parse trees
2
 
=======================================================
3
 
 
4
 
.. module:: token
5
 
   :synopsis: Constants representing terminal nodes of the parse tree.
6
 
.. sectionauthor:: Fred L. Drake, Jr. <fdrake@acm.org>
7
 
 
8
 
**Source code:** :source:`Lib/token.py`
9
 
 
10
 
--------------
11
 
 
12
 
This module provides constants which represent the numeric values of leaf nodes
13
 
of the parse tree (terminal tokens).  Refer to the file :file:`Grammar/Grammar`
14
 
in the Python distribution for the definitions of the names in the context of
15
 
the language grammar.  The specific numeric values which the names map to may
16
 
change between Python versions.
17
 
 
18
 
The module also provides a mapping from numeric codes to names and some
19
 
functions.  The functions mirror definitions in the Python C header files.
20
 
 
21
 
 
22
 
.. data:: tok_name
23
 
 
24
 
   Dictionary mapping the numeric values of the constants defined in this module
25
 
   back to name strings, allowing more human-readable representation of parse trees
26
 
   to be generated.
27
 
 
28
 
 
29
 
.. function:: ISTERMINAL(x)
30
 
 
31
 
   Return true for terminal token values.
32
 
 
33
 
 
34
 
.. function:: ISNONTERMINAL(x)
35
 
 
36
 
   Return true for non-terminal token values.
37
 
 
38
 
 
39
 
.. function:: ISEOF(x)
40
 
 
41
 
   Return true if *x* is the marker indicating the end of input.
42
 
 
43
 
 
44
 
The token constants are:
45
 
 
46
 
.. data:: ENDMARKER
47
 
          NAME
48
 
          NUMBER
49
 
          STRING
50
 
          NEWLINE
51
 
          INDENT
52
 
          DEDENT
53
 
          LPAR
54
 
          RPAR
55
 
          LSQB
56
 
          RSQB
57
 
          COLON
58
 
          COMMA
59
 
          SEMI
60
 
          PLUS
61
 
          MINUS
62
 
          STAR
63
 
          SLASH
64
 
          VBAR
65
 
          AMPER
66
 
          LESS
67
 
          GREATER
68
 
          EQUAL
69
 
          DOT
70
 
          PERCENT
71
 
          LBRACE
72
 
          RBRACE
73
 
          EQEQUAL
74
 
          NOTEQUAL
75
 
          LESSEQUAL
76
 
          GREATEREQUAL
77
 
          TILDE
78
 
          CIRCUMFLEX
79
 
          LEFTSHIFT
80
 
          RIGHTSHIFT
81
 
          DOUBLESTAR
82
 
          PLUSEQUAL
83
 
          MINEQUAL
84
 
          STAREQUAL
85
 
          SLASHEQUAL
86
 
          PERCENTEQUAL
87
 
          AMPEREQUAL
88
 
          VBAREQUAL
89
 
          CIRCUMFLEXEQUAL
90
 
          LEFTSHIFTEQUAL
91
 
          RIGHTSHIFTEQUAL
92
 
          DOUBLESTAREQUAL
93
 
          DOUBLESLASH
94
 
          DOUBLESLASHEQUAL
95
 
          AT
96
 
          ATEQUAL
97
 
          RARROW
98
 
          ELLIPSIS
99
 
          OP
100
 
          AWAIT
101
 
          ASYNC
102
 
          ERRORTOKEN
103
 
          N_TOKENS
104
 
          NT_OFFSET
105
 
 
106
 
   .. versionchanged:: 3.5
107
 
      Added :data:`AWAIT` and :data:`ASYNC` tokens. Starting with
108
 
      Python 3.7, "async" and "await" will be tokenized as :data:`NAME`
109
 
      tokens, and :data:`AWAIT` and :data:`ASYNC` will be removed.
110
 
 
111
 
.. seealso::
112
 
 
113
 
   Module :mod:`parser`
114
 
      The second example for the :mod:`parser` module shows how to use the
115
 
      :mod:`symbol` module.
116