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