forked from getlantern/marionette
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtoken.go
74 lines (63 loc) · 1.07 KB
/
token.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
63
64
65
66
67
68
69
70
71
72
73
74
package mar
import "strconv"
// Token represents a lexical token type.
type Token int
const (
ILLEGAL Token = iota
EOF
COMMENT
WS
IDENT // connection
NULL // NULL
STRING // "foo"
INTEGER // 12345
FLOAT // 123.45
LPAREN // (
RPAREN // )
DOT // .
COMMA // ,
COLON // :
HASH // #
// keywords
ACTION
CLIENT
IF
END
REGEX_MATCH_INCOMING
SERVER
START
)
var tokens = [...]string{
ILLEGAL: "ILLEGAL",
EOF: "EOF",
COMMENT: "COMMENT",
WS: "WS",
IDENT: "IDENT",
NULL: "NULL",
STRING: "STRING",
INTEGER: "INTEGER",
FLOAT: "FLOAT",
LPAREN: "(",
RPAREN: ")",
DOT: ".",
COMMA: ",",
COLON: ":",
HASH: "#",
ACTION: "action",
CLIENT: "client",
IF: "if",
END: "end",
REGEX_MATCH_INCOMING: "regex_match_incoming",
SERVER: "server",
START: "start",
}
func (tok Token) String() string {
s := ""
if 0 <= tok && tok < Token(len(tokens)) {
s = tokens[tok]
}
if s == "" {
s = "token(" + strconv.Itoa(int(tok)) + ")"
}
return s
}