-
Notifications
You must be signed in to change notification settings - Fork 95
/
Copy pathast.go
914 lines (782 loc) · 20.2 KB
/
ast.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
// Copyright 2018 The go-python Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package ast
// FIXME make base AstNode with position in
// also keep a list of children in the parent node to simplify walking the tree?
import (
"fmt"
"github.com/go-python/gpython/py"
)
type Identifier py.String
type String py.String
type Object py.Object
type Singleton py.Object
// Definitions originally made with python3 asdl_go.py Python.asdl then edited by hand
//
// Taking some inspiration from http://golang.org/src/pkg/go/ast/ast.go
// There are 5 main classes of Node
// ModBase - which type of thing are we parsing
// StmtBase - statements
// ExprType - expressions
// SliceBaseType - slices
// All node types implement the Ast interface
type Ast interface {
py.Object
GetLineno() int
GetColOffset() int
}
// All ModBase nodes implement the Mod interface
type Mod interface {
Ast
modNode()
}
// All StmtBase nodes implement the Stmt interface
type Stmt interface {
Ast
stmtNode()
}
// All ExprBase notes implement the Expr interface
type Expr interface {
Ast
exprNode()
}
// All SliceBase nodes implement the Slicer interface
type Slicer interface {
Ast
sliceNode()
}
// Position in the parse tree
type Pos struct {
Lineno int
ColOffset int
}
func (o *Pos) GetLineno() int { return o.Lineno }
func (o *Pos) GetColOffset() int { return o.ColOffset }
// Base AST node
type AST struct {
Pos
}
// ------------------------------------------------------------
// Constant
// ------------------------------------------------------------
type ExprContext int
const (
Load = ExprContext(iota + 1)
Store
Del
AugLoad
AugStore
Param
)
func (o ExprContext) String() string {
switch o {
case Load:
return "Load()"
case Store:
return "Store()"
case Del:
return "Del()"
case AugLoad:
return "AugLoad()"
case AugStore:
return "AugStore()"
case Param:
return "Param()"
}
return fmt.Sprintf("UnknownExprContext(%d)", o)
}
type BoolOpNumber int
const (
And = BoolOpNumber(iota + 1)
Or
)
func (o BoolOpNumber) String() string {
switch o {
case And:
return "And()"
case Or:
return "Or()"
}
return fmt.Sprintf("UnknownBoolOpNumber(%d)", o)
}
type OperatorNumber int
const (
Add = OperatorNumber(iota + 1)
Sub
Mult
Div
Modulo
Pow
LShift
RShift
BitOr
BitXor
BitAnd
FloorDiv
)
func (o OperatorNumber) String() string {
switch o {
case Add:
return "Add()"
case Sub:
return "Sub()"
case Mult:
return "Mult()"
case Div:
return "Div()"
case Modulo:
return "Mod()"
case Pow:
return "Pow()"
case LShift:
return "LShift()"
case RShift:
return "RShift()"
case BitOr:
return "BitOr()"
case BitXor:
return "BitXor()"
case BitAnd:
return "BitAnd()"
case FloorDiv:
return "FloorDiv()"
}
return fmt.Sprintf("UnknownOperatorNumber(%d)", o)
}
type UnaryOpNumber int
const (
Invert = UnaryOpNumber(iota + 1)
Not
UAdd
USub
)
func (o UnaryOpNumber) String() string {
switch o {
case Invert:
return "Invert()"
case Not:
return "Not()"
case UAdd:
return "UAdd()"
case USub:
return "USub()"
}
return fmt.Sprintf("UnknownUnaryOpNumber(%d)", o)
}
type CmpOp int
const (
Eq = CmpOp(iota + 1)
NotEq
Lt
LtE
Gt
GtE
Is
IsNot
In
NotIn
)
func (o CmpOp) String() string {
switch o {
case Eq:
return "Eq()"
case NotEq:
return "NotEq()"
case Lt:
return "Lt()"
case LtE:
return "LtE()"
case Gt:
return "Gt()"
case GtE:
return "GtE()"
case Is:
return "Is()"
case IsNot:
return "IsNot()"
case In:
return "In()"
case NotIn:
return "NotIn()"
}
return fmt.Sprintf("UnknownCmoOp(%d)", o)
}
// ------------------------------------------------------------
// Mod nodes
// ------------------------------------------------------------
type ModBase struct {
Pos
}
func (o *ModBase) modNode() {}
type Module struct {
ModBase
Body []Stmt
}
type Interactive struct {
ModBase
Body []Stmt
}
type Expression struct {
ModBase
Body Expr
}
type Suite struct {
ModBase
Body []Stmt
}
// ------------------------------------------------------------
// Statement nodes
// ------------------------------------------------------------
type StmtBase struct {
Pos
}
func (o *StmtBase) stmtNode() {}
type FunctionDef struct {
StmtBase
Name Identifier
Args *Arguments
Body []Stmt
DecoratorList []Expr
Returns Expr
}
type ClassDef struct {
StmtBase
Name Identifier
Bases []Expr
Keywords []*Keyword
Starargs Expr
Kwargs Expr
Body []Stmt
DecoratorList []Expr
}
type Return struct {
StmtBase
Value Expr
}
type Delete struct {
StmtBase
Targets []Expr
}
type Assign struct {
StmtBase
Targets []Expr
Value Expr
}
type AugAssign struct {
StmtBase
Target Expr
Op OperatorNumber
Value Expr
}
type For struct {
StmtBase
Target Expr
Iter Expr
Body []Stmt
Orelse []Stmt
}
type While struct {
StmtBase
Test Expr
Body []Stmt
Orelse []Stmt
}
type If struct {
StmtBase
Test Expr
Body []Stmt
Orelse []Stmt
}
type With struct {
StmtBase
Items []*WithItem
Body []Stmt
}
type Raise struct {
StmtBase
Exc Expr
Cause Expr
}
type Try struct {
StmtBase
Body []Stmt
Handlers []*ExceptHandler
Orelse []Stmt
Finalbody []Stmt
}
type Assert struct {
StmtBase
Test Expr
Msg Expr
}
type Import struct {
StmtBase
Names []*Alias
}
type ImportFrom struct {
StmtBase
Module Identifier
Names []*Alias
Level int
}
type Global struct {
StmtBase
Names []Identifier
}
type Nonlocal struct {
StmtBase
Names []Identifier
}
type ExprStmt struct {
StmtBase
Value Expr
}
type Pass struct {
StmtBase
}
type Break struct {
StmtBase
}
type Continue struct {
StmtBase
}
// ------------------------------------------------------------
// Expr nodes
// ------------------------------------------------------------
type ExprBase struct{ Pos }
func (o *ExprBase) exprNode() {}
type BoolOp struct {
ExprBase
Op BoolOpNumber
Values []Expr
}
type BinOp struct {
ExprBase
Left Expr
Op OperatorNumber
Right Expr
}
type UnaryOp struct {
ExprBase
Op UnaryOpNumber
Operand Expr
}
type Lambda struct {
ExprBase
Args *Arguments
Body Expr
}
type IfExp struct {
ExprBase
Test Expr
Body Expr
Orelse Expr
}
type Dict struct {
ExprBase
Keys []Expr
Values []Expr
}
type Set struct {
ExprBase
Elts []Expr
}
type ListComp struct {
ExprBase
Elt Expr
Generators []Comprehension
}
type SetComp struct {
ExprBase
Elt Expr
Generators []Comprehension
}
type DictComp struct {
ExprBase
Key Expr
Value Expr
Generators []Comprehension
}
type GeneratorExp struct {
ExprBase
Elt Expr
Generators []Comprehension
}
type Yield struct {
ExprBase
Value Expr
}
type YieldFrom struct {
ExprBase
Value Expr
}
// need sequences for compare to distinguish between
type Compare struct {
ExprBase
Left Expr
Ops []CmpOp
Comparators []Expr
}
type Call struct {
ExprBase
Func Expr
Args []Expr
Keywords []*Keyword
Starargs Expr
Kwargs Expr
}
type Num struct {
ExprBase
N Object
}
type Str struct {
ExprBase
S py.String
}
type Bytes struct {
ExprBase
S py.Bytes
}
type NameConstant struct {
ExprBase
Value Singleton
}
type Ellipsis struct {
ExprBase
}
type Attribute struct {
ExprBase
Value Expr
Attr Identifier
Ctx ExprContext
}
// ExprNodes which have a settable context implement this
type SetCtxer interface {
SetCtx(ExprContext)
}
func (o *Attribute) SetCtx(Ctx ExprContext) { o.Ctx = Ctx }
var _ = SetCtxer((*Attribute)(nil))
type Subscript struct {
ExprBase
Value Expr
Slice Slicer
Ctx ExprContext
}
func (o *Subscript) SetCtx(Ctx ExprContext) { o.Ctx = Ctx }
var _ = SetCtxer((*Subscript)(nil))
type Starred struct {
ExprBase
Value Expr
Ctx ExprContext
}
func (o *Starred) SetCtx(Ctx ExprContext) {
o.Ctx = Ctx
if setCtx, ok := o.Value.(SetCtxer); ok {
setCtx.SetCtx(Ctx)
}
}
var _ = SetCtxer((*Starred)(nil))
type Name struct {
ExprBase
Id Identifier
Ctx ExprContext
}
func (o *Name) SetCtx(Ctx ExprContext) { o.Ctx = Ctx }
var _ = SetCtxer((*Name)(nil))
type List struct {
ExprBase
Elts []Expr
Ctx ExprContext
}
func (o *List) SetCtx(Ctx ExprContext) {
o.Ctx = Ctx
for i := range o.Elts {
o.Elts[i].(SetCtxer).SetCtx(Ctx)
}
}
var _ = SetCtxer((*List)(nil))
type Tuple struct {
ExprBase
Elts []Expr
Ctx ExprContext
}
func (o *Tuple) SetCtx(Ctx ExprContext) {
o.Ctx = Ctx
for i := range o.Elts {
o.Elts[i].(SetCtxer).SetCtx(Ctx)
}
}
var _ = SetCtxer((*Tuple)(nil))
// ------------------------------------------------------------
// Slicer nodes
// ------------------------------------------------------------
type SliceBase struct {
Pos
}
func (o *SliceBase) sliceNode() {}
type Slice struct {
SliceBase
Lower Expr
Upper Expr
Step Expr
}
type ExtSlice struct {
SliceBase
Dims []Slicer
}
type Index struct {
SliceBase
Value Expr
}
type Comprehension struct {
Target Expr
Iter Expr
Ifs []Expr
}
// ------------------------------------------------------------
// Misc types - which aren't in a type heirachy
// ------------------------------------------------------------
type ExceptHandler struct {
Pos
ExprType Expr
Name Identifier
Body []Stmt
}
type Arguments struct {
Pos
Args []*Arg
Vararg *Arg
Kwonlyargs []*Arg
KwDefaults []Expr
Kwarg *Arg
Defaults []Expr
}
type Arg struct {
Pos
Arg Identifier
Annotation Expr
}
type Keyword struct {
Pos
Arg Identifier
Value Expr
}
type Alias struct {
Pos
Name Identifier
AsName Identifier
}
type WithItem struct {
Pos
ContextExpr Expr
OptionalVars Expr
}
// Check interfaces
var _ Ast = (*AST)(nil)
// Mod
var _ Mod = (*ModBase)(nil)
var _ Mod = (*Module)(nil)
var _ Mod = (*Interactive)(nil)
var _ Mod = (*Expression)(nil)
var _ Mod = (*Suite)(nil)
// Stmt
var _ Stmt = (*StmtBase)(nil)
var _ Stmt = (*FunctionDef)(nil)
var _ Stmt = (*ClassDef)(nil)
var _ Stmt = (*Return)(nil)
var _ Stmt = (*Delete)(nil)
var _ Stmt = (*Assign)(nil)
var _ Stmt = (*AugAssign)(nil)
var _ Stmt = (*For)(nil)
var _ Stmt = (*While)(nil)
var _ Stmt = (*If)(nil)
var _ Stmt = (*With)(nil)
var _ Stmt = (*Raise)(nil)
var _ Stmt = (*Try)(nil)
var _ Stmt = (*Assert)(nil)
var _ Stmt = (*Import)(nil)
var _ Stmt = (*ImportFrom)(nil)
var _ Stmt = (*Global)(nil)
var _ Stmt = (*Nonlocal)(nil)
var _ Stmt = (*ExprStmt)(nil)
var _ Stmt = (*Pass)(nil)
var _ Stmt = (*Break)(nil)
var _ Stmt = (*Continue)(nil)
// Expr
var _ Expr = (*ExprBase)(nil)
var _ Expr = (*BoolOp)(nil)
var _ Expr = (*BinOp)(nil)
var _ Expr = (*UnaryOp)(nil)
var _ Expr = (*Lambda)(nil)
var _ Expr = (*IfExp)(nil)
var _ Expr = (*Dict)(nil)
var _ Expr = (*Set)(nil)
var _ Expr = (*ListComp)(nil)
var _ Expr = (*SetComp)(nil)
var _ Expr = (*DictComp)(nil)
var _ Expr = (*GeneratorExp)(nil)
var _ Expr = (*Yield)(nil)
var _ Expr = (*YieldFrom)(nil)
var _ Expr = (*Compare)(nil)
var _ Expr = (*Call)(nil)
var _ Expr = (*Num)(nil)
var _ Expr = (*Str)(nil)
var _ Expr = (*Bytes)(nil)
var _ Expr = (*NameConstant)(nil)
var _ Expr = (*Ellipsis)(nil)
var _ Expr = (*Attribute)(nil)
var _ Expr = (*Subscript)(nil)
var _ Expr = (*Starred)(nil)
var _ Expr = (*Name)(nil)
var _ Expr = (*List)(nil)
var _ Expr = (*Tuple)(nil)
// Slice
var _ Slicer = (*SliceBase)(nil)
var _ Slicer = (*Slice)(nil)
var _ Slicer = (*ExtSlice)(nil)
var _ Slicer = (*Index)(nil)
// Misc
var _ Ast = (*ExceptHandler)(nil)
var _ Ast = (*Arguments)(nil)
var _ Ast = (*Arg)(nil)
var _ Ast = (*Keyword)(nil)
var _ Ast = (*Alias)(nil)
var _ Ast = (*WithItem)(nil)
// Python types
var ASTType = py.ObjectType.NewTypeFlags("AST", "AST Node", nil, nil, py.ObjectType.Flags|py.TPFLAGS_BASE_EXC_SUBCLASS)
// Mod
var ModBaseType = ASTType.NewType("Mod", "Mod Node", nil, nil)
var ModuleType = ModBaseType.NewType("Module", "Module Node", nil, nil)
var InteractiveType = ModBaseType.NewType("Interactive", "Interactive Node", nil, nil)
var ExpressionType = ModBaseType.NewType("Expression", "Expression Node", nil, nil)
var SuiteType = ModBaseType.NewType("Suite", "Suite Node", nil, nil)
// Stmt
var StmtBaseType = ASTType.NewType("Stmt", "Stmt Node", nil, nil)
var FunctionDefType = StmtBaseType.NewType("FunctionDef", "FunctionDef Node", nil, nil)
var ClassDefType = StmtBaseType.NewType("ClassDef", "ClassDef Node", nil, nil)
var ReturnType = StmtBaseType.NewType("Return", "Return Node", nil, nil)
var DeleteType = StmtBaseType.NewType("Delete", "Delete Node", nil, nil)
var AssignType = StmtBaseType.NewType("Assign", "Assign Node", nil, nil)
var AugAssignType = StmtBaseType.NewType("AugAssign", "AugAssign Node", nil, nil)
var ForType = StmtBaseType.NewType("For", "For Node", nil, nil)
var WhileType = StmtBaseType.NewType("While", "While Node", nil, nil)
var IfType = StmtBaseType.NewType("If", "If Node", nil, nil)
var WithType = StmtBaseType.NewType("With", "With Node", nil, nil)
var RaiseType = StmtBaseType.NewType("Raise", "Raise Node", nil, nil)
var TryType = StmtBaseType.NewType("Try", "Try Node", nil, nil)
var AssertType = StmtBaseType.NewType("Assert", "Assert Node", nil, nil)
var ImportType = StmtBaseType.NewType("Import", "Import Node", nil, nil)
var ImportFromType = StmtBaseType.NewType("ImportFrom", "ImportFrom Node", nil, nil)
var GlobalType = StmtBaseType.NewType("Global", "Global Node", nil, nil)
var NonlocalType = StmtBaseType.NewType("Nonlocal", "Nonlocal Node", nil, nil)
var ExprStmtType = StmtBaseType.NewType("ExprStmt", "ExprStmt Node", nil, nil)
var PassType = StmtBaseType.NewType("Pass", "Pass Node", nil, nil)
var BreakType = StmtBaseType.NewType("Break", "Break Node", nil, nil)
var ContinueType = StmtBaseType.NewType("Continue", "Continue Node", nil, nil)
// Expr
var ExprBaseType = ASTType.NewType("Expr", "Expr Node", nil, nil)
var BoolOpType = ExprBaseType.NewType("BoolOp", "BoolOp Node", nil, nil)
var BinOpType = ExprBaseType.NewType("BinOp", "BinOp Node", nil, nil)
var UnaryOpType = ExprBaseType.NewType("UnaryOp", "UnaryOp Node", nil, nil)
var LambdaType = ExprBaseType.NewType("Lambda", "Lambda Node", nil, nil)
var IfExpType = ExprBaseType.NewType("IfExp", "IfExp Node", nil, nil)
var DictType = ExprBaseType.NewType("Dict", "Dict Node", nil, nil)
var SetType = ExprBaseType.NewType("Set", "Set Node", nil, nil)
var ListCompType = ExprBaseType.NewType("ListComp", "ListComp Node", nil, nil)
var SetCompType = ExprBaseType.NewType("SetComp", "SetComp Node", nil, nil)
var DictCompType = ExprBaseType.NewType("DictComp", "DictComp Node", nil, nil)
var GeneratorExpType = ExprBaseType.NewType("GeneratorExp", "GeneratorExp Node", nil, nil)
var YieldType = ExprBaseType.NewType("Yield", "Yield Node", nil, nil)
var YieldFromType = ExprBaseType.NewType("YieldFrom", "YieldFrom Node", nil, nil)
var CompareType = ExprBaseType.NewType("Compare", "Compare Node", nil, nil)
var CallType = ExprBaseType.NewType("Call", "Call Node", nil, nil)
var NumType = ExprBaseType.NewType("Num", "Num Node", nil, nil)
var StrType = ExprBaseType.NewType("Str", "Str Node", nil, nil)
var BytesType = ExprBaseType.NewType("Bytes", "Bytes Node", nil, nil)
var NameConstantType = ExprBaseType.NewType("NameConstant", "NameConstant Node", nil, nil)
var EllipsisType = ExprBaseType.NewType("Ellipsis", "Ellipsis Node", nil, nil)
var AttributeType = ExprBaseType.NewType("Attribute", "Attribute Node", nil, nil)
var SubscriptType = ExprBaseType.NewType("Subscript", "Subscript Node", nil, nil)
var StarredType = ExprBaseType.NewType("Starred", "Starred Node", nil, nil)
var NameType = ExprBaseType.NewType("Name", "Name Node", nil, nil)
var ListType = ExprBaseType.NewType("List", "List Node", nil, nil)
var TupleType = ExprBaseType.NewType("Tuple", "Tuple Node", nil, nil)
var SliceBaseType = ASTType.NewType("SliceBase", "SliceBase Node", nil, nil)
// Slicer
var SliceType = SliceBaseType.NewType("Slice", "Slice Node", nil, nil)
var ExtSliceType = SliceBaseType.NewType("ExtSlice", "ExtSlice Node", nil, nil)
var IndexType = SliceBaseType.NewType("Index", "Index Node", nil, nil)
// Misc
var ExceptHandlerType = ASTType.NewType("ExceptHandler", "ExceptHandler Node", nil, nil)
var ArgumentsType = ASTType.NewType("Arguments", "Arguments Node", nil, nil)
var ArgType = ASTType.NewType("Arg", "Arg Node", nil, nil)
var KeywordType = ASTType.NewType("Keyword", "Keyword Node", nil, nil)
var AliasType = ASTType.NewType("Alias", "Alias Node", nil, nil)
var WithItemType = ASTType.NewType("WithItem", "WithItem Node", nil, nil)
// Python type definitions
func (o *AST) Type() *py.Type { return ASTType }
func (o *ModBase) Type() *py.Type { return ModBaseType }
func (o *Module) Type() *py.Type { return ModuleType }
func (o *Interactive) Type() *py.Type { return InteractiveType }
func (o *Expression) Type() *py.Type { return ExpressionType }
func (o *Suite) Type() *py.Type { return SuiteType }
func (o *StmtBase) Type() *py.Type { return StmtBaseType }
func (o *FunctionDef) Type() *py.Type { return FunctionDefType }
func (o *ClassDef) Type() *py.Type { return ClassDefType }
func (o *Return) Type() *py.Type { return ReturnType }
func (o *Delete) Type() *py.Type { return DeleteType }
func (o *Assign) Type() *py.Type { return AssignType }
func (o *AugAssign) Type() *py.Type { return AugAssignType }
func (o *For) Type() *py.Type { return ForType }
func (o *While) Type() *py.Type { return WhileType }
func (o *If) Type() *py.Type { return IfType }
func (o *With) Type() *py.Type { return WithType }
func (o *Raise) Type() *py.Type { return RaiseType }
func (o *Try) Type() *py.Type { return TryType }
func (o *Assert) Type() *py.Type { return AssertType }
func (o *Import) Type() *py.Type { return ImportType }
func (o *ImportFrom) Type() *py.Type { return ImportFromType }
func (o *Global) Type() *py.Type { return GlobalType }
func (o *Nonlocal) Type() *py.Type { return NonlocalType }
func (o *ExprStmt) Type() *py.Type { return ExprStmtType }
func (o *Pass) Type() *py.Type { return PassType }
func (o *Break) Type() *py.Type { return BreakType }
func (o *Continue) Type() *py.Type { return ContinueType }
func (o *ExprBase) Type() *py.Type { return ExprBaseType }
func (o *BoolOp) Type() *py.Type { return BoolOpType }
func (o *BinOp) Type() *py.Type { return BinOpType }
func (o *UnaryOp) Type() *py.Type { return UnaryOpType }
func (o *Lambda) Type() *py.Type { return LambdaType }
func (o *IfExp) Type() *py.Type { return IfExpType }
func (o *Dict) Type() *py.Type { return DictType }
func (o *Set) Type() *py.Type { return SetType }
func (o *ListComp) Type() *py.Type { return ListCompType }
func (o *SetComp) Type() *py.Type { return SetCompType }
func (o *DictComp) Type() *py.Type { return DictCompType }
func (o *GeneratorExp) Type() *py.Type { return GeneratorExpType }
func (o *Yield) Type() *py.Type { return YieldType }
func (o *YieldFrom) Type() *py.Type { return YieldFromType }
func (o *Compare) Type() *py.Type { return CompareType }
func (o *Call) Type() *py.Type { return CallType }
func (o *Num) Type() *py.Type { return NumType }
func (o *Str) Type() *py.Type { return StrType }
func (o *Bytes) Type() *py.Type { return BytesType }
func (o *NameConstant) Type() *py.Type { return NameConstantType }
func (o *Ellipsis) Type() *py.Type { return EllipsisType }
func (o *Attribute) Type() *py.Type { return AttributeType }
func (o *Subscript) Type() *py.Type { return SubscriptType }
func (o *Starred) Type() *py.Type { return StarredType }
func (o *Name) Type() *py.Type { return NameType }
func (o *List) Type() *py.Type { return ListType }
func (o *Tuple) Type() *py.Type { return TupleType }
func (o *SliceBase) Type() *py.Type { return SliceBaseType }
func (o *Slice) Type() *py.Type { return SliceType }
func (o *ExtSlice) Type() *py.Type { return ExtSliceType }
func (o *Index) Type() *py.Type { return IndexType }
func (o *ExceptHandler) Type() *py.Type { return ExceptHandlerType }
func (o *Arguments) Type() *py.Type { return ArgumentsType }
func (o *Arg) Type() *py.Type { return ArgType }
func (o *Keyword) Type() *py.Type { return KeywordType }
func (o *Alias) Type() *py.Type { return AliasType }
func (o *WithItem) Type() *py.Type { return WithItemType }