blob: 493bf0426508fe2a610a31f30d34ba02d8040ef6 [file] [log] [blame]
Serhiy Storchaka8ac65812018-12-22 11:18:40 +02001"""Token constants."""
2# Auto-generated by Tools/scripts/generate_token.py
Guido van Rossume7b146f2000-02-04 15:28:42 +00003
Alexander Belopolskyb9d10d02010-11-11 14:07:41 +00004__all__ = ['tok_name', 'ISTERMINAL', 'ISNONTERMINAL', 'ISEOF']
5
Guido van Rossumb31c7f71993-11-11 10:31:23 +00006ENDMARKER = 0
7NAME = 1
8NUMBER = 2
9STRING = 3
10NEWLINE = 4
11INDENT = 5
12DEDENT = 6
13LPAR = 7
14RPAR = 8
15LSQB = 9
16RSQB = 10
17COLON = 11
18COMMA = 12
19SEMI = 13
20PLUS = 14
21MINUS = 15
22STAR = 16
23SLASH = 17
24VBAR = 18
25AMPER = 19
26LESS = 20
27GREATER = 21
28EQUAL = 22
29DOT = 23
30PERCENT = 24
Meador Inge33880602012-01-15 19:15:36 -060031LBRACE = 25
32RBRACE = 26
33EQEQUAL = 27
34NOTEQUAL = 28
35LESSEQUAL = 29
36GREATEREQUAL = 30
37TILDE = 31
38CIRCUMFLEX = 32
39LEFTSHIFT = 33
40RIGHTSHIFT = 34
41DOUBLESTAR = 35
42PLUSEQUAL = 36
43MINEQUAL = 37
44STAREQUAL = 38
45SLASHEQUAL = 39
46PERCENTEQUAL = 40
47AMPEREQUAL = 41
48VBAREQUAL = 42
49CIRCUMFLEXEQUAL = 43
50LEFTSHIFTEQUAL = 44
51RIGHTSHIFTEQUAL = 45
52DOUBLESTAREQUAL = 46
53DOUBLESLASH = 47
54DOUBLESLASHEQUAL = 48
55AT = 49
Benjamin Petersond51374e2014-04-09 23:55:56 -040056ATEQUAL = 50
57RARROW = 51
58ELLIPSIS = 52
Emily Morehouse8f59ee02019-01-24 16:49:56 -070059COLONEQUAL = 53
60OP = 54
Guido van Rossum495da292019-03-07 12:38:08 -080061AWAIT = 55
62ASYNC = 56
63TYPE_IGNORE = 57
64TYPE_COMMENT = 58
Albert-Jan Nijburgfc354f02017-05-31 15:00:21 +010065# These aren't used by the C tokenizer but are needed for tokenize.py
Guido van Rossum495da292019-03-07 12:38:08 -080066ERRORTOKEN = 59
67COMMENT = 60
68NL = 61
69ENCODING = 62
70N_TOKENS = 63
Albert-Jan Nijburgfc354f02017-05-31 15:00:21 +010071# Special definitions for cooperation with parser
Guido van Rossum47478871996-08-21 14:32:37 +000072NT_OFFSET = 256
Guido van Rossumb31c7f71993-11-11 10:31:23 +000073
Alexander Belopolskyb9d10d02010-11-11 14:07:41 +000074tok_name = {value: name
75 for name, value in globals().items()
Antoine Pitrouea3eb882012-05-17 18:55:59 +020076 if isinstance(value, int) and not name.startswith('_')}
Alexander Belopolskyb9d10d02010-11-11 14:07:41 +000077__all__.extend(tok_name.values())
Guido van Rossumb31c7f71993-11-11 10:31:23 +000078
Serhiy Storchaka8ac65812018-12-22 11:18:40 +020079EXACT_TOKEN_TYPES = {
80 '!=': NOTEQUAL,
81 '%': PERCENT,
82 '%=': PERCENTEQUAL,
83 '&': AMPER,
84 '&=': AMPEREQUAL,
85 '(': LPAR,
86 ')': RPAR,
87 '*': STAR,
88 '**': DOUBLESTAR,
89 '**=': DOUBLESTAREQUAL,
90 '*=': STAREQUAL,
91 '+': PLUS,
92 '+=': PLUSEQUAL,
93 ',': COMMA,
94 '-': MINUS,
95 '-=': MINEQUAL,
96 '->': RARROW,
97 '.': DOT,
98 '...': ELLIPSIS,
99 '/': SLASH,
100 '//': DOUBLESLASH,
101 '//=': DOUBLESLASHEQUAL,
102 '/=': SLASHEQUAL,
103 ':': COLON,
Emily Morehouse8f59ee02019-01-24 16:49:56 -0700104 ':=': COLONEQUAL,
Serhiy Storchaka8ac65812018-12-22 11:18:40 +0200105 ';': SEMI,
106 '<': LESS,
107 '<<': LEFTSHIFT,
108 '<<=': LEFTSHIFTEQUAL,
109 '<=': LESSEQUAL,
110 '=': EQUAL,
111 '==': EQEQUAL,
112 '>': GREATER,
113 '>=': GREATEREQUAL,
114 '>>': RIGHTSHIFT,
115 '>>=': RIGHTSHIFTEQUAL,
116 '@': AT,
117 '@=': ATEQUAL,
118 '[': LSQB,
119 ']': RSQB,
120 '^': CIRCUMFLEX,
121 '^=': CIRCUMFLEXEQUAL,
122 '{': LBRACE,
123 '|': VBAR,
124 '|=': VBAREQUAL,
125 '}': RBRACE,
126 '~': TILDE,
127}
128
Guido van Rossum154a5391996-07-21 02:17:52 +0000129def ISTERMINAL(x):
130 return x < NT_OFFSET
131
132def ISNONTERMINAL(x):
133 return x >= NT_OFFSET
134
135def ISEOF(x):
136 return x == ENDMARKER