...
Source file src/pkg/cmd/compile/internal/syntax/nodes.go
1
2
3
4
5 package syntax
6
7
8
9
10 type Node interface {
11
12
13
14
15
16
17
18
19 Pos() Pos
20 aNode()
21 }
22
23 type node struct {
24
25
26 pos Pos
27 }
28
29 func (n *node) Pos() Pos { return n.pos }
30 func (*node) aNode() {}
31
32
33
34
35
36 type File struct {
37 PkgName *Name
38 DeclList []Decl
39 Lines uint
40 node
41 }
42
43
44
45
46 type (
47 Decl interface {
48 Node
49 aDecl()
50 }
51
52
53
54 ImportDecl struct {
55 LocalPkgName *Name
56 Path *BasicLit
57 Group *Group
58 decl
59 }
60
61
62
63
64 ConstDecl struct {
65 NameList []*Name
66 Type Expr
67 Values Expr
68 Group *Group
69 decl
70 }
71
72
73 TypeDecl struct {
74 Name *Name
75 Alias bool
76 Type Expr
77 Group *Group
78 Pragma Pragma
79 decl
80 }
81
82
83
84
85 VarDecl struct {
86 NameList []*Name
87 Type Expr
88 Values Expr
89 Group *Group
90 decl
91 }
92
93
94
95
96
97 FuncDecl struct {
98 Attr map[string]bool
99 Recv *Field
100 Name *Name
101 Type *FuncType
102 Body *BlockStmt
103 Pragma Pragma
104 decl
105 }
106 )
107
108 type decl struct{ node }
109
110 func (*decl) aDecl() {}
111
112
113 type Group struct {
114 dummy int
115 }
116
117
118
119
120 type (
121 Expr interface {
122 Node
123 aExpr()
124 }
125
126
127
128 BadExpr struct {
129 expr
130 }
131
132
133 Name struct {
134 Value string
135 expr
136 }
137
138
139 BasicLit struct {
140 Value string
141 Kind LitKind
142 expr
143 }
144
145
146 CompositeLit struct {
147 Type Expr
148 ElemList []Expr
149 NKeys int
150 Rbrace Pos
151 expr
152 }
153
154
155 KeyValueExpr struct {
156 Key, Value Expr
157 expr
158 }
159
160
161 FuncLit struct {
162 Type *FuncType
163 Body *BlockStmt
164 expr
165 }
166
167
168 ParenExpr struct {
169 X Expr
170 expr
171 }
172
173
174 SelectorExpr struct {
175 X Expr
176 Sel *Name
177 expr
178 }
179
180
181 IndexExpr struct {
182 X Expr
183 Index Expr
184 expr
185 }
186
187
188 SliceExpr struct {
189 X Expr
190 Index [3]Expr
191
192
193
194
195 Full bool
196 expr
197 }
198
199
200 AssertExpr struct {
201 X Expr
202 Type Expr
203 expr
204 }
205
206
207
208 TypeSwitchGuard struct {
209 Lhs *Name
210 X Expr
211 expr
212 }
213
214 Operation struct {
215 Op Operator
216 X, Y Expr
217 expr
218 }
219
220
221 CallExpr struct {
222 Fun Expr
223 ArgList []Expr
224 HasDots bool
225 expr
226 }
227
228
229 ListExpr struct {
230 ElemList []Expr
231 expr
232 }
233
234
235 ArrayType struct {
236
237 Len Expr
238 Elem Expr
239 expr
240 }
241
242
243 SliceType struct {
244 Elem Expr
245 expr
246 }
247
248
249 DotsType struct {
250 Elem Expr
251 expr
252 }
253
254
255 StructType struct {
256 FieldList []*Field
257 TagList []*BasicLit
258 expr
259 }
260
261
262
263 Field struct {
264 Name *Name
265 Type Expr
266 node
267 }
268
269
270 InterfaceType struct {
271 MethodList []*Field
272 expr
273 }
274
275 FuncType struct {
276 ParamList []*Field
277 ResultList []*Field
278 expr
279 }
280
281
282 MapType struct {
283 Key, Value Expr
284 expr
285 }
286
287
288
289
290 ChanType struct {
291 Dir ChanDir
292 Elem Expr
293 expr
294 }
295 )
296
297 type expr struct{ node }
298
299 func (*expr) aExpr() {}
300
301 type ChanDir uint
302
303 const (
304 _ ChanDir = iota
305 SendOnly
306 RecvOnly
307 )
308
309
310
311
312 type (
313 Stmt interface {
314 Node
315 aStmt()
316 }
317
318 SimpleStmt interface {
319 Stmt
320 aSimpleStmt()
321 }
322
323 EmptyStmt struct {
324 simpleStmt
325 }
326
327 LabeledStmt struct {
328 Label *Name
329 Stmt Stmt
330 stmt
331 }
332
333 BlockStmt struct {
334 List []Stmt
335 Rbrace Pos
336 stmt
337 }
338
339 ExprStmt struct {
340 X Expr
341 simpleStmt
342 }
343
344 SendStmt struct {
345 Chan, Value Expr
346 simpleStmt
347 }
348
349 DeclStmt struct {
350 DeclList []Decl
351 stmt
352 }
353
354 AssignStmt struct {
355 Op Operator
356 Lhs, Rhs Expr
357 simpleStmt
358 }
359
360 BranchStmt struct {
361 Tok token
362 Label *Name
363
364
365
366
367
368 Target Stmt
369 stmt
370 }
371
372 CallStmt struct {
373 Tok token
374 Call *CallExpr
375 stmt
376 }
377
378 ReturnStmt struct {
379 Results Expr
380 stmt
381 }
382
383 IfStmt struct {
384 Init SimpleStmt
385 Cond Expr
386 Then *BlockStmt
387 Else Stmt
388 stmt
389 }
390
391 ForStmt struct {
392 Init SimpleStmt
393 Cond Expr
394 Post SimpleStmt
395 Body *BlockStmt
396 stmt
397 }
398
399 SwitchStmt struct {
400 Init SimpleStmt
401 Tag Expr
402 Body []*CaseClause
403 Rbrace Pos
404 stmt
405 }
406
407 SelectStmt struct {
408 Body []*CommClause
409 Rbrace Pos
410 stmt
411 }
412 )
413
414 type (
415 RangeClause struct {
416 Lhs Expr
417 Def bool
418 X Expr
419 simpleStmt
420 }
421
422 CaseClause struct {
423 Cases Expr
424 Body []Stmt
425 Colon Pos
426 node
427 }
428
429 CommClause struct {
430 Comm SimpleStmt
431 Body []Stmt
432 Colon Pos
433 node
434 }
435 )
436
437 type stmt struct{ node }
438
439 func (stmt) aStmt() {}
440
441 type simpleStmt struct {
442 stmt
443 }
444
445 func (simpleStmt) aSimpleStmt() {}
446
447
448
449
450
451
452 type CommentKind uint
453
454 const (
455 Above CommentKind = iota
456 Below
457 Left
458 Right
459 )
460
461 type Comment struct {
462 Kind CommentKind
463 Text string
464 Next *Comment
465 }
466
View as plain text