1 | n/a | #! /usr/bin/env python3 |
---|
2 | n/a | |
---|
3 | n/a | """Token constants (from "token.h").""" |
---|
4 | n/a | |
---|
5 | n/a | # Taken from Python (r53757) and modified to include some tokens |
---|
6 | n/a | # originally monkeypatched in by pgen2.tokenize |
---|
7 | n/a | |
---|
8 | n/a | #--start constants-- |
---|
9 | n/a | ENDMARKER = 0 |
---|
10 | n/a | NAME = 1 |
---|
11 | n/a | NUMBER = 2 |
---|
12 | n/a | STRING = 3 |
---|
13 | n/a | NEWLINE = 4 |
---|
14 | n/a | INDENT = 5 |
---|
15 | n/a | DEDENT = 6 |
---|
16 | n/a | LPAR = 7 |
---|
17 | n/a | RPAR = 8 |
---|
18 | n/a | LSQB = 9 |
---|
19 | n/a | RSQB = 10 |
---|
20 | n/a | COLON = 11 |
---|
21 | n/a | COMMA = 12 |
---|
22 | n/a | SEMI = 13 |
---|
23 | n/a | PLUS = 14 |
---|
24 | n/a | MINUS = 15 |
---|
25 | n/a | STAR = 16 |
---|
26 | n/a | SLASH = 17 |
---|
27 | n/a | VBAR = 18 |
---|
28 | n/a | AMPER = 19 |
---|
29 | n/a | LESS = 20 |
---|
30 | n/a | GREATER = 21 |
---|
31 | n/a | EQUAL = 22 |
---|
32 | n/a | DOT = 23 |
---|
33 | n/a | PERCENT = 24 |
---|
34 | n/a | BACKQUOTE = 25 |
---|
35 | n/a | LBRACE = 26 |
---|
36 | n/a | RBRACE = 27 |
---|
37 | n/a | EQEQUAL = 28 |
---|
38 | n/a | NOTEQUAL = 29 |
---|
39 | n/a | LESSEQUAL = 30 |
---|
40 | n/a | GREATEREQUAL = 31 |
---|
41 | n/a | TILDE = 32 |
---|
42 | n/a | CIRCUMFLEX = 33 |
---|
43 | n/a | LEFTSHIFT = 34 |
---|
44 | n/a | RIGHTSHIFT = 35 |
---|
45 | n/a | DOUBLESTAR = 36 |
---|
46 | n/a | PLUSEQUAL = 37 |
---|
47 | n/a | MINEQUAL = 38 |
---|
48 | n/a | STAREQUAL = 39 |
---|
49 | n/a | SLASHEQUAL = 40 |
---|
50 | n/a | PERCENTEQUAL = 41 |
---|
51 | n/a | AMPEREQUAL = 42 |
---|
52 | n/a | VBAREQUAL = 43 |
---|
53 | n/a | CIRCUMFLEXEQUAL = 44 |
---|
54 | n/a | LEFTSHIFTEQUAL = 45 |
---|
55 | n/a | RIGHTSHIFTEQUAL = 46 |
---|
56 | n/a | DOUBLESTAREQUAL = 47 |
---|
57 | n/a | DOUBLESLASH = 48 |
---|
58 | n/a | DOUBLESLASHEQUAL = 49 |
---|
59 | n/a | AT = 50 |
---|
60 | n/a | ATEQUAL = 51 |
---|
61 | n/a | OP = 52 |
---|
62 | n/a | COMMENT = 53 |
---|
63 | n/a | NL = 54 |
---|
64 | n/a | RARROW = 55 |
---|
65 | n/a | AWAIT = 56 |
---|
66 | n/a | ASYNC = 57 |
---|
67 | n/a | ERRORTOKEN = 58 |
---|
68 | n/a | N_TOKENS = 59 |
---|
69 | n/a | NT_OFFSET = 256 |
---|
70 | n/a | #--end constants-- |
---|
71 | n/a | |
---|
72 | n/a | tok_name = {} |
---|
73 | n/a | for _name, _value in list(globals().items()): |
---|
74 | n/a | if type(_value) is type(0): |
---|
75 | n/a | tok_name[_value] = _name |
---|
76 | n/a | |
---|
77 | n/a | |
---|
78 | n/a | def ISTERMINAL(x): |
---|
79 | n/a | return x < NT_OFFSET |
---|
80 | n/a | |
---|
81 | n/a | def ISNONTERMINAL(x): |
---|
82 | n/a | return x >= NT_OFFSET |
---|
83 | n/a | |
---|
84 | n/a | def ISEOF(x): |
---|
85 | n/a | return x == ENDMARKER |
---|