-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtoken_types.go
61 lines (52 loc) · 1.42 KB
/
token_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
package anitogo
// describes a category of token
type tokenCategory int
// describes a flags set on a token to describe it
type tokenFlags int
// tokenCategory enums
const (
tokenCategoryUnknown tokenCategory = 1 << iota
tokenCategoryBracket
tokenCategoryDelimiter
tokenCategoryIdentifier
tokenCategoryInvalid
)
// tokenFlags enums
const (
tokenFlagsNone tokenFlags = 0
tokenFlagsBracket tokenFlags = 1 << iota
tokenFlagsNotBracket
tokenFlagsDelimiter
tokenFlagsNotDelimiter
tokenFlagsIdentifier
tokenFlagsNotIdentifier
tokenFlagsUnknown
tokenFlagsNotUnknown
tokenFlagsValid
tokenFlagsNotValid
tokenFlagsEnclosed
tokenFlagsNotEnclosed
)
// tokenFlags mask enums
const (
tokenFlagsMaskCategories = tokenFlagsBracket | tokenFlagsNotBracket | tokenFlagsDelimiter | tokenFlagsNotDelimiter | tokenFlagsIdentifier | tokenFlagsNotIdentifier | tokenFlagsUnknown | tokenFlagsNotUnknown | tokenFlagsValid | tokenFlagsNotValid
toeknFlagsMaskEnclosed = tokenFlagsEnclosed | tokenFlagsNotEnclosed
)
// token describes a logical segment of a filename
type token struct {
Category tokenCategory
Flags tokenFlags
Content string
Enclosed bool
}
// tokens describes a slice of token pointers
type tokens []*token
// tokenManager describes a "manager" struct that stores token pointers
type tokenManager struct {
tokens tokens
}
// indexSet describes a pair of start and finish indexes
type indexSet struct {
Begin int
End int
}