OILS / _devbuild / gen / mycpp_asdl.py View on Github | oilshell.org

1200 lines, 824 significant
1from asdl import pybase
2from mycpp import mops
3from typing import Optional, List, Tuple, Dict, Any, cast, TYPE_CHECKING
4
5from asdl import runtime # For runtime.NO_SPID
6from asdl.runtime import NewRecord, NewLeaf, TraversalState
7from _devbuild.gen.hnode_asdl import color_e, hnode, hnode_e, hnode_t, Field
8
9class mtype_t(pybase.SimpleObj):
10 pass
11
12class mtype_e(object):
13 Foo = mtype_t(1)
14
15_mtype_str = {
16 1: 'Foo',
17}
18
19def mtype_str(val, dot=True):
20 # type: (mtype_t, bool) -> str
21 v = _mtype_str[val]
22 if dot:
23 return "mtype.%s" % v
24 else:
25 return v
26
27class yaks_type_e(object):
28 NoneType = 1
29 NoReturn = 2
30 IOError_OSError = 3
31 Bool = 4
32 Int = 5
33 Float = 6
34 Str = 7
35 Class = 8
36 Callable = 9
37 Dict_ = 10
38 List_ = 11
39 Iterator = 12
40 Tuple = 13
41 Optional = 14
42 Alias = 15
43
44_yaks_type_str = {
45 1: 'NoneType',
46 2: 'NoReturn',
47 3: 'IOError_OSError',
48 4: 'Bool',
49 5: 'Int',
50 6: 'Float',
51 7: 'Str',
52 8: 'Class',
53 9: 'Callable',
54 10: 'Dict_',
55 11: 'List_',
56 12: 'Iterator',
57 13: 'Tuple',
58 14: 'Optional',
59 15: 'Alias',
60}
61
62def yaks_type_str(tag, dot=True):
63 # type: (int, bool) -> str
64 v = _yaks_type_str[tag]
65 if dot:
66 return "yaks_type.%s" % v
67 else:
68 return v
69
70class yaks_type_t(pybase.CompoundObj):
71 def tag(self):
72 # type: () -> int
73 return self._type_tag
74
75class yaks_type__NoneType(yaks_type_t):
76 _type_tag = 1
77 __slots__ = ()
78
79 def __init__(self, ):
80 # type: () -> None
81 pass
82
83 def PrettyTree(self, do_abbrev, trav=None):
84 # type: (bool, Optional[TraversalState]) -> hnode_t
85 trav = trav or TraversalState()
86 heap_id = id(self)
87 if heap_id in trav.seen:
88 return hnode.AlreadySeen(heap_id)
89 trav.seen[heap_id] = True
90
91 out_node = NewRecord('yaks_type.NoneType')
92 L = out_node.fields
93
94 return out_node
95
96class yaks_type__NoReturn(yaks_type_t):
97 _type_tag = 2
98 __slots__ = ()
99
100 def __init__(self, ):
101 # type: () -> None
102 pass
103
104 def PrettyTree(self, do_abbrev, trav=None):
105 # type: (bool, Optional[TraversalState]) -> hnode_t
106 trav = trav or TraversalState()
107 heap_id = id(self)
108 if heap_id in trav.seen:
109 return hnode.AlreadySeen(heap_id)
110 trav.seen[heap_id] = True
111
112 out_node = NewRecord('yaks_type.NoReturn')
113 L = out_node.fields
114
115 return out_node
116
117class yaks_type__IOError_OSError(yaks_type_t):
118 _type_tag = 3
119 __slots__ = ()
120
121 def __init__(self, ):
122 # type: () -> None
123 pass
124
125 def PrettyTree(self, do_abbrev, trav=None):
126 # type: (bool, Optional[TraversalState]) -> hnode_t
127 trav = trav or TraversalState()
128 heap_id = id(self)
129 if heap_id in trav.seen:
130 return hnode.AlreadySeen(heap_id)
131 trav.seen[heap_id] = True
132
133 out_node = NewRecord('yaks_type.IOError_OSError')
134 L = out_node.fields
135
136 return out_node
137
138class yaks_type__Bool(yaks_type_t):
139 _type_tag = 4
140 __slots__ = ()
141
142 def __init__(self, ):
143 # type: () -> None
144 pass
145
146 def PrettyTree(self, do_abbrev, trav=None):
147 # type: (bool, Optional[TraversalState]) -> hnode_t
148 trav = trav or TraversalState()
149 heap_id = id(self)
150 if heap_id in trav.seen:
151 return hnode.AlreadySeen(heap_id)
152 trav.seen[heap_id] = True
153
154 out_node = NewRecord('yaks_type.Bool')
155 L = out_node.fields
156
157 return out_node
158
159class yaks_type__Int(yaks_type_t):
160 _type_tag = 5
161 __slots__ = ()
162
163 def __init__(self, ):
164 # type: () -> None
165 pass
166
167 def PrettyTree(self, do_abbrev, trav=None):
168 # type: (bool, Optional[TraversalState]) -> hnode_t
169 trav = trav or TraversalState()
170 heap_id = id(self)
171 if heap_id in trav.seen:
172 return hnode.AlreadySeen(heap_id)
173 trav.seen[heap_id] = True
174
175 out_node = NewRecord('yaks_type.Int')
176 L = out_node.fields
177
178 return out_node
179
180class yaks_type__Float(yaks_type_t):
181 _type_tag = 6
182 __slots__ = ()
183
184 def __init__(self, ):
185 # type: () -> None
186 pass
187
188 def PrettyTree(self, do_abbrev, trav=None):
189 # type: (bool, Optional[TraversalState]) -> hnode_t
190 trav = trav or TraversalState()
191 heap_id = id(self)
192 if heap_id in trav.seen:
193 return hnode.AlreadySeen(heap_id)
194 trav.seen[heap_id] = True
195
196 out_node = NewRecord('yaks_type.Float')
197 L = out_node.fields
198
199 return out_node
200
201class yaks_type__Str(yaks_type_t):
202 _type_tag = 7
203 __slots__ = ()
204
205 def __init__(self, ):
206 # type: () -> None
207 pass
208
209 def PrettyTree(self, do_abbrev, trav=None):
210 # type: (bool, Optional[TraversalState]) -> hnode_t
211 trav = trav or TraversalState()
212 heap_id = id(self)
213 if heap_id in trav.seen:
214 return hnode.AlreadySeen(heap_id)
215 trav.seen[heap_id] = True
216
217 out_node = NewRecord('yaks_type.Str')
218 L = out_node.fields
219
220 return out_node
221
222class yaks_type(object):
223 NoneType = yaks_type__NoneType()
224
225 NoReturn = yaks_type__NoReturn()
226
227 IOError_OSError = yaks_type__IOError_OSError()
228
229 Bool = yaks_type__Bool()
230
231 Int = yaks_type__Int()
232
233 Float = yaks_type__Float()
234
235 Str = yaks_type__Str()
236
237 class Class(yaks_type_t):
238 _type_tag = 8
239 __slots__ = ('mod_parts', 'name')
240
241 def __init__(self, mod_parts, name):
242 # type: (List[str], str) -> None
243 self.mod_parts = mod_parts
244 self.name = name
245
246 @staticmethod
247 def CreateNull(alloc_lists=False):
248 # type: () -> yaks_type.Class
249 return yaks_type.Class([] if alloc_lists else cast('List[str]', None), '')
250
251 def PrettyTree(self, do_abbrev, trav=None):
252 # type: (bool, Optional[TraversalState]) -> hnode_t
253 trav = trav or TraversalState()
254 heap_id = id(self)
255 if heap_id in trav.seen:
256 return hnode.AlreadySeen(heap_id)
257 trav.seen[heap_id] = True
258
259 out_node = NewRecord('yaks_type.Class')
260 L = out_node.fields
261
262 if self.mod_parts is not None: # List
263 x0 = hnode.Array([])
264 for i0 in self.mod_parts:
265 x0.children.append(NewLeaf(i0, color_e.StringConst))
266 L.append(Field('mod_parts', x0))
267
268 x1 = NewLeaf(self.name, color_e.StringConst)
269 L.append(Field('name', x1))
270
271 return out_node
272
273 class Callable(yaks_type_t):
274 _type_tag = 9
275 __slots__ = ('args', 'return_')
276
277 def __init__(self, args, return_):
278 # type: (List[yaks_type_t], yaks_type_t) -> None
279 self.args = args
280 self.return_ = return_
281
282 @staticmethod
283 def CreateNull(alloc_lists=False):
284 # type: () -> yaks_type.Callable
285 return yaks_type.Callable([] if alloc_lists else cast('List[yaks_type_t]', None), cast('yaks_type_t', None))
286
287 def PrettyTree(self, do_abbrev, trav=None):
288 # type: (bool, Optional[TraversalState]) -> hnode_t
289 trav = trav or TraversalState()
290 heap_id = id(self)
291 if heap_id in trav.seen:
292 return hnode.AlreadySeen(heap_id)
293 trav.seen[heap_id] = True
294
295 out_node = NewRecord('yaks_type.Callable')
296 L = out_node.fields
297
298 if self.args is not None: # List
299 x0 = hnode.Array([])
300 for i0 in self.args:
301 h = (hnode.Leaf("_", color_e.OtherConst) if i0 is None else
302 i0.PrettyTree(do_abbrev, trav=trav))
303 x0.children.append(h)
304 L.append(Field('args', x0))
305
306 assert self.return_ is not None
307 x1 = self.return_.PrettyTree(do_abbrev, trav=trav)
308 L.append(Field('return_', x1))
309
310 return out_node
311
312 class Dict_(yaks_type_t):
313 _type_tag = 10
314 __slots__ = ('k', 'v')
315
316 def __init__(self, k, v):
317 # type: (yaks_type_t, yaks_type_t) -> None
318 self.k = k
319 self.v = v
320
321 @staticmethod
322 def CreateNull(alloc_lists=False):
323 # type: () -> yaks_type.Dict_
324 return yaks_type.Dict_(cast('yaks_type_t', None), cast('yaks_type_t', None))
325
326 def PrettyTree(self, do_abbrev, trav=None):
327 # type: (bool, Optional[TraversalState]) -> hnode_t
328 trav = trav or TraversalState()
329 heap_id = id(self)
330 if heap_id in trav.seen:
331 return hnode.AlreadySeen(heap_id)
332 trav.seen[heap_id] = True
333
334 out_node = NewRecord('yaks_type.Dict_')
335 L = out_node.fields
336
337 assert self.k is not None
338 x0 = self.k.PrettyTree(do_abbrev, trav=trav)
339 L.append(Field('k', x0))
340
341 assert self.v is not None
342 x1 = self.v.PrettyTree(do_abbrev, trav=trav)
343 L.append(Field('v', x1))
344
345 return out_node
346
347 class List_(yaks_type_t):
348 _type_tag = 11
349 __slots__ = ('t',)
350
351 def __init__(self, t):
352 # type: (yaks_type_t) -> None
353 self.t = t
354
355 @staticmethod
356 def CreateNull(alloc_lists=False):
357 # type: () -> yaks_type.List_
358 return yaks_type.List_(cast('yaks_type_t', None))
359
360 def PrettyTree(self, do_abbrev, trav=None):
361 # type: (bool, Optional[TraversalState]) -> hnode_t
362 trav = trav or TraversalState()
363 heap_id = id(self)
364 if heap_id in trav.seen:
365 return hnode.AlreadySeen(heap_id)
366 trav.seen[heap_id] = True
367
368 out_node = NewRecord('yaks_type.List_')
369 L = out_node.fields
370
371 assert self.t is not None
372 x0 = self.t.PrettyTree(do_abbrev, trav=trav)
373 L.append(Field('t', x0))
374
375 return out_node
376
377 class Iterator(yaks_type_t):
378 _type_tag = 12
379 __slots__ = ('t',)
380
381 def __init__(self, t):
382 # type: (yaks_type_t) -> None
383 self.t = t
384
385 @staticmethod
386 def CreateNull(alloc_lists=False):
387 # type: () -> yaks_type.Iterator
388 return yaks_type.Iterator(cast('yaks_type_t', None))
389
390 def PrettyTree(self, do_abbrev, trav=None):
391 # type: (bool, Optional[TraversalState]) -> hnode_t
392 trav = trav or TraversalState()
393 heap_id = id(self)
394 if heap_id in trav.seen:
395 return hnode.AlreadySeen(heap_id)
396 trav.seen[heap_id] = True
397
398 out_node = NewRecord('yaks_type.Iterator')
399 L = out_node.fields
400
401 assert self.t is not None
402 x0 = self.t.PrettyTree(do_abbrev, trav=trav)
403 L.append(Field('t', x0))
404
405 return out_node
406
407 class Tuple(yaks_type_t):
408 _type_tag = 13
409 __slots__ = ('children',)
410
411 def __init__(self, children):
412 # type: (List[yaks_type_t]) -> None
413 self.children = children
414
415 @staticmethod
416 def CreateNull(alloc_lists=False):
417 # type: () -> yaks_type.Tuple
418 return yaks_type.Tuple([] if alloc_lists else cast('List[yaks_type_t]', None))
419
420 def PrettyTree(self, do_abbrev, trav=None):
421 # type: (bool, Optional[TraversalState]) -> hnode_t
422 trav = trav or TraversalState()
423 heap_id = id(self)
424 if heap_id in trav.seen:
425 return hnode.AlreadySeen(heap_id)
426 trav.seen[heap_id] = True
427
428 out_node = NewRecord('yaks_type.Tuple')
429 L = out_node.fields
430
431 if self.children is not None: # List
432 x0 = hnode.Array([])
433 for i0 in self.children:
434 h = (hnode.Leaf("_", color_e.OtherConst) if i0 is None else
435 i0.PrettyTree(do_abbrev, trav=trav))
436 x0.children.append(h)
437 L.append(Field('children', x0))
438
439 return out_node
440
441 class Optional(yaks_type_t):
442 _type_tag = 14
443 __slots__ = ('child',)
444
445 def __init__(self, child):
446 # type: (yaks_type_t) -> None
447 self.child = child
448
449 @staticmethod
450 def CreateNull(alloc_lists=False):
451 # type: () -> yaks_type.Optional
452 return yaks_type.Optional(cast('yaks_type_t', None))
453
454 def PrettyTree(self, do_abbrev, trav=None):
455 # type: (bool, Optional[TraversalState]) -> hnode_t
456 trav = trav or TraversalState()
457 heap_id = id(self)
458 if heap_id in trav.seen:
459 return hnode.AlreadySeen(heap_id)
460 trav.seen[heap_id] = True
461
462 out_node = NewRecord('yaks_type.Optional')
463 L = out_node.fields
464
465 assert self.child is not None
466 x0 = self.child.PrettyTree(do_abbrev, trav=trav)
467 L.append(Field('child', x0))
468
469 return out_node
470
471 class Alias(yaks_type_t):
472 _type_tag = 15
473 __slots__ = ('child',)
474
475 def __init__(self, child):
476 # type: (yaks_type_t) -> None
477 self.child = child
478
479 @staticmethod
480 def CreateNull(alloc_lists=False):
481 # type: () -> yaks_type.Alias
482 return yaks_type.Alias(cast('yaks_type_t', None))
483
484 def PrettyTree(self, do_abbrev, trav=None):
485 # type: (bool, Optional[TraversalState]) -> hnode_t
486 trav = trav or TraversalState()
487 heap_id = id(self)
488 if heap_id in trav.seen:
489 return hnode.AlreadySeen(heap_id)
490 trav.seen[heap_id] = True
491
492 out_node = NewRecord('yaks_type.Alias')
493 L = out_node.fields
494
495 assert self.child is not None
496 x0 = self.child.PrettyTree(do_abbrev, trav=trav)
497 L.append(Field('child', x0))
498
499 return out_node
500
501 pass
502
503class yaks_expr_e(object):
504 BoolExpr = 1
505 IntExpr = 2
506 FloatExpr = 3
507 StrExpr = 4
508 MemberExpr = 5
509 CallExpr = 6
510 Cast = 7
511
512_yaks_expr_str = {
513 1: 'BoolExpr',
514 2: 'IntExpr',
515 3: 'FloatExpr',
516 4: 'StrExpr',
517 5: 'MemberExpr',
518 6: 'CallExpr',
519 7: 'Cast',
520}
521
522def yaks_expr_str(tag, dot=True):
523 # type: (int, bool) -> str
524 v = _yaks_expr_str[tag]
525 if dot:
526 return "yaks_expr.%s" % v
527 else:
528 return v
529
530class yaks_expr_t(pybase.CompoundObj):
531 def tag(self):
532 # type: () -> int
533 return self._type_tag
534
535class yaks_expr__MemberExpr(yaks_expr_t):
536 _type_tag = 5
537 __slots__ = ()
538
539 def __init__(self, ):
540 # type: () -> None
541 pass
542
543 def PrettyTree(self, do_abbrev, trav=None):
544 # type: (bool, Optional[TraversalState]) -> hnode_t
545 trav = trav or TraversalState()
546 heap_id = id(self)
547 if heap_id in trav.seen:
548 return hnode.AlreadySeen(heap_id)
549 trav.seen[heap_id] = True
550
551 out_node = NewRecord('yaks_expr.MemberExpr')
552 L = out_node.fields
553
554 return out_node
555
556class yaks_expr__CallExpr(yaks_expr_t):
557 _type_tag = 6
558 __slots__ = ()
559
560 def __init__(self, ):
561 # type: () -> None
562 pass
563
564 def PrettyTree(self, do_abbrev, trav=None):
565 # type: (bool, Optional[TraversalState]) -> hnode_t
566 trav = trav or TraversalState()
567 heap_id = id(self)
568 if heap_id in trav.seen:
569 return hnode.AlreadySeen(heap_id)
570 trav.seen[heap_id] = True
571
572 out_node = NewRecord('yaks_expr.CallExpr')
573 L = out_node.fields
574
575 return out_node
576
577class yaks_expr__Cast(yaks_expr_t):
578 _type_tag = 7
579 __slots__ = ()
580
581 def __init__(self, ):
582 # type: () -> None
583 pass
584
585 def PrettyTree(self, do_abbrev, trav=None):
586 # type: (bool, Optional[TraversalState]) -> hnode_t
587 trav = trav or TraversalState()
588 heap_id = id(self)
589 if heap_id in trav.seen:
590 return hnode.AlreadySeen(heap_id)
591 trav.seen[heap_id] = True
592
593 out_node = NewRecord('yaks_expr.Cast')
594 L = out_node.fields
595
596 return out_node
597
598class yaks_expr(object):
599 class BoolExpr(yaks_expr_t):
600 _type_tag = 1
601 __slots__ = ('value',)
602
603 def __init__(self, value):
604 # type: (bool) -> None
605 self.value = value
606
607 @staticmethod
608 def CreateNull(alloc_lists=False):
609 # type: () -> yaks_expr.BoolExpr
610 return yaks_expr.BoolExpr(False)
611
612 def PrettyTree(self, do_abbrev, trav=None):
613 # type: (bool, Optional[TraversalState]) -> hnode_t
614 trav = trav or TraversalState()
615 heap_id = id(self)
616 if heap_id in trav.seen:
617 return hnode.AlreadySeen(heap_id)
618 trav.seen[heap_id] = True
619
620 out_node = NewRecord('yaks_expr.BoolExpr')
621 L = out_node.fields
622
623 x0 = hnode.Leaf('T' if self.value else 'F', color_e.OtherConst)
624 L.append(Field('value', x0))
625
626 return out_node
627
628 class IntExpr(yaks_expr_t):
629 _type_tag = 2
630 __slots__ = ('value',)
631
632 def __init__(self, value):
633 # type: (int) -> None
634 self.value = value
635
636 @staticmethod
637 def CreateNull(alloc_lists=False):
638 # type: () -> yaks_expr.IntExpr
639 return yaks_expr.IntExpr(-1)
640
641 def PrettyTree(self, do_abbrev, trav=None):
642 # type: (bool, Optional[TraversalState]) -> hnode_t
643 trav = trav or TraversalState()
644 heap_id = id(self)
645 if heap_id in trav.seen:
646 return hnode.AlreadySeen(heap_id)
647 trav.seen[heap_id] = True
648
649 out_node = NewRecord('yaks_expr.IntExpr')
650 L = out_node.fields
651
652 x0 = hnode.Leaf(str(self.value), color_e.OtherConst)
653 L.append(Field('value', x0))
654
655 return out_node
656
657 class FloatExpr(yaks_expr_t):
658 _type_tag = 3
659 __slots__ = ('value',)
660
661 def __init__(self, value):
662 # type: (float) -> None
663 self.value = value
664
665 @staticmethod
666 def CreateNull(alloc_lists=False):
667 # type: () -> yaks_expr.FloatExpr
668 return yaks_expr.FloatExpr(0.0)
669
670 def PrettyTree(self, do_abbrev, trav=None):
671 # type: (bool, Optional[TraversalState]) -> hnode_t
672 trav = trav or TraversalState()
673 heap_id = id(self)
674 if heap_id in trav.seen:
675 return hnode.AlreadySeen(heap_id)
676 trav.seen[heap_id] = True
677
678 out_node = NewRecord('yaks_expr.FloatExpr')
679 L = out_node.fields
680
681 x0 = hnode.Leaf(str(self.value), color_e.OtherConst)
682 L.append(Field('value', x0))
683
684 return out_node
685
686 class StrExpr(yaks_expr_t):
687 _type_tag = 4
688 __slots__ = ('value',)
689
690 def __init__(self, value):
691 # type: (str) -> None
692 self.value = value
693
694 @staticmethod
695 def CreateNull(alloc_lists=False):
696 # type: () -> yaks_expr.StrExpr
697 return yaks_expr.StrExpr('')
698
699 def PrettyTree(self, do_abbrev, trav=None):
700 # type: (bool, Optional[TraversalState]) -> hnode_t
701 trav = trav or TraversalState()
702 heap_id = id(self)
703 if heap_id in trav.seen:
704 return hnode.AlreadySeen(heap_id)
705 trav.seen[heap_id] = True
706
707 out_node = NewRecord('yaks_expr.StrExpr')
708 L = out_node.fields
709
710 x0 = NewLeaf(self.value, color_e.StringConst)
711 L.append(Field('value', x0))
712
713 return out_node
714
715 MemberExpr = yaks_expr__MemberExpr()
716
717 CallExpr = yaks_expr__CallExpr()
718
719 Cast = yaks_expr__Cast()
720
721 pass
722
723class yaks_stmt_e(object):
724 PassStmt = 1
725 ExpressionStmt = 2
726 DelStmt = 3
727 RaiseStmt = 4
728 AssignmentStmt = 5
729 IfStmt = 6
730 ForStmt = 7
731 WhileStmt = 8
732 Break = 9
733 Continue = 10
734 Return = 11
735 WithStmt = 12
736 TryStmt = 13
737 FuncDef = 14
738 ClassDef = 15
739 ImportFrom = 16
740
741_yaks_stmt_str = {
742 1: 'PassStmt',
743 2: 'ExpressionStmt',
744 3: 'DelStmt',
745 4: 'RaiseStmt',
746 5: 'AssignmentStmt',
747 6: 'IfStmt',
748 7: 'ForStmt',
749 8: 'WhileStmt',
750 9: 'Break',
751 10: 'Continue',
752 11: 'Return',
753 12: 'WithStmt',
754 13: 'TryStmt',
755 14: 'FuncDef',
756 15: 'ClassDef',
757 16: 'ImportFrom',
758}
759
760def yaks_stmt_str(tag, dot=True):
761 # type: (int, bool) -> str
762 v = _yaks_stmt_str[tag]
763 if dot:
764 return "yaks_stmt.%s" % v
765 else:
766 return v
767
768class yaks_stmt_t(pybase.CompoundObj):
769 def tag(self):
770 # type: () -> int
771 return self._type_tag
772
773class yaks_stmt__PassStmt(yaks_stmt_t):
774 _type_tag = 1
775 __slots__ = ()
776
777 def __init__(self, ):
778 # type: () -> None
779 pass
780
781 def PrettyTree(self, do_abbrev, trav=None):
782 # type: (bool, Optional[TraversalState]) -> hnode_t
783 trav = trav or TraversalState()
784 heap_id = id(self)
785 if heap_id in trav.seen:
786 return hnode.AlreadySeen(heap_id)
787 trav.seen[heap_id] = True
788
789 out_node = NewRecord('yaks_stmt.PassStmt')
790 L = out_node.fields
791
792 return out_node
793
794class yaks_stmt__ExpressionStmt(yaks_stmt_t):
795 _type_tag = 2
796 __slots__ = ()
797
798 def __init__(self, ):
799 # type: () -> None
800 pass
801
802 def PrettyTree(self, do_abbrev, trav=None):
803 # type: (bool, Optional[TraversalState]) -> hnode_t
804 trav = trav or TraversalState()
805 heap_id = id(self)
806 if heap_id in trav.seen:
807 return hnode.AlreadySeen(heap_id)
808 trav.seen[heap_id] = True
809
810 out_node = NewRecord('yaks_stmt.ExpressionStmt')
811 L = out_node.fields
812
813 return out_node
814
815class yaks_stmt__DelStmt(yaks_stmt_t):
816 _type_tag = 3
817 __slots__ = ()
818
819 def __init__(self, ):
820 # type: () -> None
821 pass
822
823 def PrettyTree(self, do_abbrev, trav=None):
824 # type: (bool, Optional[TraversalState]) -> hnode_t
825 trav = trav or TraversalState()
826 heap_id = id(self)
827 if heap_id in trav.seen:
828 return hnode.AlreadySeen(heap_id)
829 trav.seen[heap_id] = True
830
831 out_node = NewRecord('yaks_stmt.DelStmt')
832 L = out_node.fields
833
834 return out_node
835
836class yaks_stmt__RaiseStmt(yaks_stmt_t):
837 _type_tag = 4
838 __slots__ = ()
839
840 def __init__(self, ):
841 # type: () -> None
842 pass
843
844 def PrettyTree(self, do_abbrev, trav=None):
845 # type: (bool, Optional[TraversalState]) -> hnode_t
846 trav = trav or TraversalState()
847 heap_id = id(self)
848 if heap_id in trav.seen:
849 return hnode.AlreadySeen(heap_id)
850 trav.seen[heap_id] = True
851
852 out_node = NewRecord('yaks_stmt.RaiseStmt')
853 L = out_node.fields
854
855 return out_node
856
857class yaks_stmt__AssignmentStmt(yaks_stmt_t):
858 _type_tag = 5
859 __slots__ = ()
860
861 def __init__(self, ):
862 # type: () -> None
863 pass
864
865 def PrettyTree(self, do_abbrev, trav=None):
866 # type: (bool, Optional[TraversalState]) -> hnode_t
867 trav = trav or TraversalState()
868 heap_id = id(self)
869 if heap_id in trav.seen:
870 return hnode.AlreadySeen(heap_id)
871 trav.seen[heap_id] = True
872
873 out_node = NewRecord('yaks_stmt.AssignmentStmt')
874 L = out_node.fields
875
876 return out_node
877
878class yaks_stmt__IfStmt(yaks_stmt_t):
879 _type_tag = 6
880 __slots__ = ()
881
882 def __init__(self, ):
883 # type: () -> None
884 pass
885
886 def PrettyTree(self, do_abbrev, trav=None):
887 # type: (bool, Optional[TraversalState]) -> hnode_t
888 trav = trav or TraversalState()
889 heap_id = id(self)
890 if heap_id in trav.seen:
891 return hnode.AlreadySeen(heap_id)
892 trav.seen[heap_id] = True
893
894 out_node = NewRecord('yaks_stmt.IfStmt')
895 L = out_node.fields
896
897 return out_node
898
899class yaks_stmt__ForStmt(yaks_stmt_t):
900 _type_tag = 7
901 __slots__ = ()
902
903 def __init__(self, ):
904 # type: () -> None
905 pass
906
907 def PrettyTree(self, do_abbrev, trav=None):
908 # type: (bool, Optional[TraversalState]) -> hnode_t
909 trav = trav or TraversalState()
910 heap_id = id(self)
911 if heap_id in trav.seen:
912 return hnode.AlreadySeen(heap_id)
913 trav.seen[heap_id] = True
914
915 out_node = NewRecord('yaks_stmt.ForStmt')
916 L = out_node.fields
917
918 return out_node
919
920class yaks_stmt__WhileStmt(yaks_stmt_t):
921 _type_tag = 8
922 __slots__ = ()
923
924 def __init__(self, ):
925 # type: () -> None
926 pass
927
928 def PrettyTree(self, do_abbrev, trav=None):
929 # type: (bool, Optional[TraversalState]) -> hnode_t
930 trav = trav or TraversalState()
931 heap_id = id(self)
932 if heap_id in trav.seen:
933 return hnode.AlreadySeen(heap_id)
934 trav.seen[heap_id] = True
935
936 out_node = NewRecord('yaks_stmt.WhileStmt')
937 L = out_node.fields
938
939 return out_node
940
941class yaks_stmt__Break(yaks_stmt_t):
942 _type_tag = 9
943 __slots__ = ()
944
945 def __init__(self, ):
946 # type: () -> None
947 pass
948
949 def PrettyTree(self, do_abbrev, trav=None):
950 # type: (bool, Optional[TraversalState]) -> hnode_t
951 trav = trav or TraversalState()
952 heap_id = id(self)
953 if heap_id in trav.seen:
954 return hnode.AlreadySeen(heap_id)
955 trav.seen[heap_id] = True
956
957 out_node = NewRecord('yaks_stmt.Break')
958 L = out_node.fields
959
960 return out_node
961
962class yaks_stmt__Continue(yaks_stmt_t):
963 _type_tag = 10
964 __slots__ = ()
965
966 def __init__(self, ):
967 # type: () -> None
968 pass
969
970 def PrettyTree(self, do_abbrev, trav=None):
971 # type: (bool, Optional[TraversalState]) -> hnode_t
972 trav = trav or TraversalState()
973 heap_id = id(self)
974 if heap_id in trav.seen:
975 return hnode.AlreadySeen(heap_id)
976 trav.seen[heap_id] = True
977
978 out_node = NewRecord('yaks_stmt.Continue')
979 L = out_node.fields
980
981 return out_node
982
983class yaks_stmt__WithStmt(yaks_stmt_t):
984 _type_tag = 12
985 __slots__ = ()
986
987 def __init__(self, ):
988 # type: () -> None
989 pass
990
991 def PrettyTree(self, do_abbrev, trav=None):
992 # type: (bool, Optional[TraversalState]) -> hnode_t
993 trav = trav or TraversalState()
994 heap_id = id(self)
995 if heap_id in trav.seen:
996 return hnode.AlreadySeen(heap_id)
997 trav.seen[heap_id] = True
998
999 out_node = NewRecord('yaks_stmt.WithStmt')
1000 L = out_node.fields
1001
1002 return out_node
1003
1004class yaks_stmt__TryStmt(yaks_stmt_t):
1005 _type_tag = 13
1006 __slots__ = ()
1007
1008 def __init__(self, ):
1009 # type: () -> None
1010 pass
1011
1012 def PrettyTree(self, do_abbrev, trav=None):
1013 # type: (bool, Optional[TraversalState]) -> hnode_t
1014 trav = trav or TraversalState()
1015 heap_id = id(self)
1016 if heap_id in trav.seen:
1017 return hnode.AlreadySeen(heap_id)
1018 trav.seen[heap_id] = True
1019
1020 out_node = NewRecord('yaks_stmt.TryStmt')
1021 L = out_node.fields
1022
1023 return out_node
1024
1025class yaks_stmt__ImportFrom(yaks_stmt_t):
1026 _type_tag = 16
1027 __slots__ = ()
1028
1029 def __init__(self, ):
1030 # type: () -> None
1031 pass
1032
1033 def PrettyTree(self, do_abbrev, trav=None):
1034 # type: (bool, Optional[TraversalState]) -> hnode_t
1035 trav = trav or TraversalState()
1036 heap_id = id(self)
1037 if heap_id in trav.seen:
1038 return hnode.AlreadySeen(heap_id)
1039 trav.seen[heap_id] = True
1040
1041 out_node = NewRecord('yaks_stmt.ImportFrom')
1042 L = out_node.fields
1043
1044 return out_node
1045
1046class yaks_stmt(object):
1047 PassStmt = yaks_stmt__PassStmt()
1048
1049 ExpressionStmt = yaks_stmt__ExpressionStmt()
1050
1051 DelStmt = yaks_stmt__DelStmt()
1052
1053 RaiseStmt = yaks_stmt__RaiseStmt()
1054
1055 AssignmentStmt = yaks_stmt__AssignmentStmt()
1056
1057 IfStmt = yaks_stmt__IfStmt()
1058
1059 ForStmt = yaks_stmt__ForStmt()
1060
1061 WhileStmt = yaks_stmt__WhileStmt()
1062
1063 Break = yaks_stmt__Break()
1064
1065 Continue = yaks_stmt__Continue()
1066
1067 class Return(yaks_stmt_t):
1068 _type_tag = 11
1069 __slots__ = ('val',)
1070
1071 def __init__(self, val):
1072 # type: (yaks_expr_t) -> None
1073 self.val = val
1074
1075 @staticmethod
1076 def CreateNull(alloc_lists=False):
1077 # type: () -> yaks_stmt.Return
1078 return yaks_stmt.Return(cast('yaks_expr_t', None))
1079
1080 def PrettyTree(self, do_abbrev, trav=None):
1081 # type: (bool, Optional[TraversalState]) -> hnode_t
1082 trav = trav or TraversalState()
1083 heap_id = id(self)
1084 if heap_id in trav.seen:
1085 return hnode.AlreadySeen(heap_id)
1086 trav.seen[heap_id] = True
1087
1088 out_node = NewRecord('yaks_stmt.Return')
1089 L = out_node.fields
1090
1091 assert self.val is not None
1092 x0 = self.val.PrettyTree(do_abbrev, trav=trav)
1093 L.append(Field('val', x0))
1094
1095 return out_node
1096
1097 WithStmt = yaks_stmt__WithStmt()
1098
1099 TryStmt = yaks_stmt__TryStmt()
1100
1101 class FuncDef(yaks_stmt_t):
1102 _type_tag = 14
1103 __slots__ = ('name',)
1104
1105 def __init__(self, name):
1106 # type: (str) -> None
1107 self.name = name
1108
1109 @staticmethod
1110 def CreateNull(alloc_lists=False):
1111 # type: () -> yaks_stmt.FuncDef
1112 return yaks_stmt.FuncDef('')
1113
1114 def PrettyTree(self, do_abbrev, trav=None):
1115 # type: (bool, Optional[TraversalState]) -> hnode_t
1116 trav = trav or TraversalState()
1117 heap_id = id(self)
1118 if heap_id in trav.seen:
1119 return hnode.AlreadySeen(heap_id)
1120 trav.seen[heap_id] = True
1121
1122 out_node = NewRecord('yaks_stmt.FuncDef')
1123 L = out_node.fields
1124
1125 x0 = NewLeaf(self.name, color_e.StringConst)
1126 L.append(Field('name', x0))
1127
1128 return out_node
1129
1130 class ClassDef(yaks_stmt_t):
1131 _type_tag = 15
1132 __slots__ = ('name',)
1133
1134 def __init__(self, name):
1135 # type: (str) -> None
1136 self.name = name
1137
1138 @staticmethod
1139 def CreateNull(alloc_lists=False):
1140 # type: () -> yaks_stmt.ClassDef
1141 return yaks_stmt.ClassDef('')
1142
1143 def PrettyTree(self, do_abbrev, trav=None):
1144 # type: (bool, Optional[TraversalState]) -> hnode_t
1145 trav = trav or TraversalState()
1146 heap_id = id(self)
1147 if heap_id in trav.seen:
1148 return hnode.AlreadySeen(heap_id)
1149 trav.seen[heap_id] = True
1150
1151 out_node = NewRecord('yaks_stmt.ClassDef')
1152 L = out_node.fields
1153
1154 x0 = NewLeaf(self.name, color_e.StringConst)
1155 L.append(Field('name', x0))
1156
1157 return out_node
1158
1159 ImportFrom = yaks_stmt__ImportFrom()
1160
1161 pass
1162
1163class yaks_file(pybase.CompoundObj):
1164 _type_tag = 64
1165 __slots__ = ('name', 'defs')
1166
1167 def __init__(self, name, defs):
1168 # type: (str, List[yaks_stmt_t]) -> None
1169 self.name = name
1170 self.defs = defs
1171
1172 @staticmethod
1173 def CreateNull(alloc_lists=False):
1174 # type: () -> yaks_file
1175 return yaks_file('', [] if alloc_lists else cast('List[yaks_stmt_t]', None))
1176
1177 def PrettyTree(self, do_abbrev, trav=None):
1178 # type: (bool, Optional[TraversalState]) -> hnode_t
1179 trav = trav or TraversalState()
1180 heap_id = id(self)
1181 if heap_id in trav.seen:
1182 return hnode.AlreadySeen(heap_id)
1183 trav.seen[heap_id] = True
1184
1185 out_node = NewRecord('yaks_file')
1186 L = out_node.fields
1187
1188 x0 = NewLeaf(self.name, color_e.StringConst)
1189 L.append(Field('name', x0))
1190
1191 if self.defs is not None: # List
1192 x1 = hnode.Array([])
1193 for i1 in self.defs:
1194 h = (hnode.Leaf("_", color_e.OtherConst) if i1 is None else
1195 i1.PrettyTree(do_abbrev, trav=trav))
1196 x1.children.append(h)
1197 L.append(Field('defs', x1))
1198
1199 return out_node
1200