1
2
3
4
5 package syntax
6
7 type token uint
8
9
10
11 const (
12 _ token = iota
13 _EOF
14
15
16 _Name
17 _Literal
18
19
20
21 _Operator
22 _AssignOp
23 _IncOp
24 _Assign
25 _Define
26 _Arrow
27 _Star
28
29
30 _Lparen
31 _Lbrack
32 _Lbrace
33 _Rparen
34 _Rbrack
35 _Rbrace
36 _Comma
37 _Semi
38 _Colon
39 _Dot
40 _DotDotDot
41
42
43 _Break
44 _Case
45 _Chan
46 _Const
47 _Continue
48 _Default
49 _Defer
50 _Else
51 _Fallthrough
52 _For
53 _Func
54 _Go
55 _Goto
56 _If
57 _Import
58 _Interface
59 _Map
60 _Package
61 _Range
62 _Return
63 _Select
64 _Struct
65 _Switch
66 _Type
67 _Var
68
69
70 tokenCount
71 )
72
73 const (
74
75 Break = _Break
76 Continue = _Continue
77 Fallthrough = _Fallthrough
78 Goto = _Goto
79
80
81 Go = _Go
82 Defer = _Defer
83 )
84
85
86 const _ uint64 = 1 << (tokenCount - 1)
87
88
89 func contains(tokset uint64, tok token) bool {
90 return tokset&(1<<tok) != 0
91 }
92
93 type LitKind uint8
94
95
96
97
98 const (
99 IntLit LitKind = iota
100 FloatLit
101 ImagLit
102 RuneLit
103 StringLit
104 )
105
106 type Operator uint
107
108
109
110 const (
111 _ Operator = iota
112
113
114 Def
115 Not
116 Recv
117 Tilde
118
119
120 OrOr
121
122
123 AndAnd
124
125
126 Eql
127 Neq
128 Lss
129 Leq
130 Gtr
131 Geq
132
133
134 Add
135 Sub
136 Or
137 Xor
138
139
140 Mul
141 Div
142 Rem
143 And
144 AndNot
145 Shl
146 Shr
147 )
148
149
150 const (
151 _ = iota
152 precOrOr
153 precAndAnd
154 precCmp
155 precAdd
156 precMul
157 )
158
View as plain text