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