-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathtoken.go
More file actions
105 lines (95 loc) · 2.6 KB
/
token.go
File metadata and controls
105 lines (95 loc) · 2.6 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
package bebop
type token struct {
kind tokenKind
concrete []byte
loc location
}
type tokenKind uint8
const (
tokenKindInvalid tokenKind = iota
tokenKindIdent
tokenKindIntegerLiteral
tokenKindFloatLiteral
tokenKindStringLiteral
tokenKindReadOnly
tokenKindStruct
tokenKindMessage
tokenKindEnum
tokenKindDeprecated
tokenKindOpCode
tokenKindMap
tokenKindArray
tokenKindUnion
tokenKindConst
tokenKindInf
tokenKindNegativeInf
tokenKindNaN
tokenKindTrue
tokenKindFalse
tokenKindImport
tokenKindFlags
tokenKindOpenSquare
tokenKindCloseSquare
tokenKindOpenParen
tokenKindCloseParen
tokenKindOpenCurly
tokenKindCloseCurly
tokenKindSemicolon
tokenKindComma
tokenKindEquals
tokenKindArrow
tokenKindLineComment
tokenKindBlockComment
tokenKindVerticalBar
tokenKindAmpersand
tokenKindDoubleCaretLeft
tokenKindDoubleCaretRight
tokenKindColon
tokenKindNewline
tokenKindFinal
)
var tokenStrings = map[tokenKind]string{
tokenKindInvalid: "Invalid",
tokenKindIdent: "Ident",
tokenKindIntegerLiteral: "Integer Literal",
tokenKindReadOnly: "Readonly",
tokenKindStruct: "Struct",
tokenKindMessage: "Message",
tokenKindEnum: "Enum",
tokenKindUnion: "Union",
tokenKindDeprecated: "Deprecated",
tokenKindOpCode: "OpCode",
tokenKindMap: "Map",
tokenKindArray: "Array",
tokenKindStringLiteral: "String Literal",
tokenKindOpenSquare: "Open Square",
tokenKindCloseSquare: "Close Square",
tokenKindOpenParen: "Open Paren",
tokenKindCloseParen: "Close Paren",
tokenKindSemicolon: "Semicolon",
tokenKindOpenCurly: "Open Curly",
tokenKindCloseCurly: "Close Curly",
tokenKindComma: "Comma",
tokenKindEquals: "Equals",
tokenKindArrow: "Arrow",
tokenKindLineComment: "Line Comment",
tokenKindBlockComment: "Block Comment",
tokenKindNewline: "Newline",
tokenKindConst: "Const",
tokenKindFloatLiteral: "Floating Point Literal",
tokenKindInf: "Infinity",
tokenKindNegativeInf: "Negative Infinity",
tokenKindNaN: "NaN",
tokenKindTrue: "True",
tokenKindFalse: "False",
tokenKindImport: "Import",
tokenKindFlags: "Flags",
tokenKindVerticalBar: "Vertical Bar",
tokenKindAmpersand: "Ampersand",
tokenKindDoubleCaretLeft: "Double Caret Left",
tokenKindDoubleCaretRight: "Double Caret Right",
tokenKindColon: "Colon",
}
func (tk tokenKind) String() string {
return tokenStrings[tk]
}