-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.go
62 lines (57 loc) · 1.02 KB
/
types.go
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
package tokenizer
var Symbols = map[uint8]bool{
'{': true,
'}': true,
'(': true,
')': true,
'[': true,
']': true,
'.': true,
',': true,
';': true,
'+': true,
'-': true,
'*': true,
'/': true,
'&': true,
'|': true,
'<': true,
'>': true,
'=': true,
'~': true,
}
var Keywords = map[string]bool{
"class": true,
"constructor": true,
"function": true,
"method": true,
"field": true,
"static": true,
"var": true,
"int": true,
"char": true,
"boolean": true,
"void": true,
"true": true,
"false": true,
"null": true,
"this": true,
"let": true,
"do": true,
"if": true,
"else": true,
"while": true,
"return": true,
}
type TokenType int
const (
Keyword TokenType = iota
Symbol
Identifier
IntConst
StringConst
UnknownToken
)
func (tt TokenType) String() string {
return []string{"keyword", "symbol", "identifier", "integerConstant", "stringConstant", "unknownToken"}[tt]
}