blob: bc5c19ef62377d73664e86762fc99b44ffc5eaa1 [file] [log] [blame]
Georg Brandl116aa622007-08-15 14:28:22 +00001: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
9This module provides constants which represent the numeric values of leaf nodes
10of the parse tree (terminal tokens). Refer to the file :file:`Grammar/Grammar`
11in the Python distribution for the definitions of the names in the context of
12the language grammar. The specific numeric values which the names map to may
13change between Python versions.
14
15This module also provides one data object and some functions. The functions
16mirror definitions in the Python C header files.
17
18
19.. data:: tok_name
20
21 Dictionary mapping the numeric values of the constants defined in this module
22 back to name strings, allowing more human-readable representation of parse trees
23 to be generated.
24
25
26.. function:: ISTERMINAL(x)
27
28 Return true for terminal token values.
29
30
31.. function:: ISNONTERMINAL(x)
32
33 Return true for non-terminal token values.
34
35
36.. function:: ISEOF(x)
37
38 Return true if *x* is the marker indicating the end of input.
39
40
41.. seealso::
42
43 Module :mod:`parser`
44 The second example for the :mod:`parser` module shows how to use the
45 :mod:`symbol` module.
46