-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtoken_type.py
64 lines (60 loc) · 1.32 KB
/
token_type.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
from enum import Enum
class TokenType(Enum):
''' Enumeration of all token types in PyLox. Used by Scanner '''
LEFT_PAREN = 'LEFT_PAREN'
RIGHT_PAREN = 'RIGHT_PAREN'
LEFT_BRACE = 'LEFT_BRACE'
RIGHT_BRACE = 'RIGHT_BRACE'
COMMA = 'COMMA'
DOT = 'DOT'
MINUS = 'MINUS'
PLUS = 'PLUS'
SEMICOLON = 'SEMICOLON'
SLASH = 'SLASH'
STAR = 'STAR'
BANG = 'BANG'
BANG_EQUAL = 'BANG_EQUAL'
EQUAL = 'EQUAL'
EQUAL_EQUAL = 'EQUAL_EQUAL'
GREATER = 'GREATER'
GREATER_EQUAL = 'GREATER_EQUAL'
LESS = 'LESS'
LESS_EQUAL = 'LESS_EQUAL'
IDENTIFIER = 'IDENTIFIER' # used for identifying a variable or class
STRING = 'STRING'
NUMBER = 'NUMBER'
AND = 'AND'
CLASS = 'CLASS'
ELSE = 'ELSE'
FALSE = 'FALSE'
FUN = 'FUN'
FOR = 'FOR'
IF = 'IF'
NIL = 'NIL'
OR = 'OR'
PRINT = 'PRINT'
RETURN = 'RETURN'
SUPER = 'SUPER'
THIS = 'THIS'
TRUE = 'TRUE'
VAR = 'VAR'
WHILE = 'WHILE'
EOF = 'EOF'
keyword_token_map = {
'and': 'AND',
'class': 'CLASS',
'else': 'ELSE',
'false': 'FALSE',
'for': 'FOR',
'fun': 'FUN',
'if': 'IF',
'nil': 'NIL',
'or': 'OR',
'print': 'PRINT',
'return': 'RETURN',
'super': 'SUPER',
'this': 'THIS',
'true': 'TRUE',
'var': 'VAR',
'while': 'WHILE'
}