Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 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 | |
| 9 | This module provides constants which represent the numeric values of leaf nodes |
| 10 | of the parse tree (terminal tokens). Refer to the file :file:`Grammar/Grammar` |
| 11 | in the Python distribution for the definitions of the names in the context of |
| 12 | the language grammar. The specific numeric values which the names map to may |
| 13 | change between Python versions. |
| 14 | |
| 15 | This module also provides one data object and some functions. The functions |
| 16 | mirror 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 | |