Debian Codegraph @

pycparser223/pycparser/c_ast.py

raw symbols SCIP
1 #-----------------------------------------------------------------
2 # ** ATTENTION **
3 # This code was automatically generated from the file:
4 # _c_ast.cfg
5 #
6 # Do not modify it directly. Modify the configuration file and
7 # run the generator again.
8 # ** ** *** ** **
9 #
10 # pycparser: c_ast.py
11 #
12 # AST Node classes.
13 #
14 # Eli Bendersky [https://eli.thegreenplace.net/]
15 # License: BSD
16 #-----------------------------------------------------------------
17
18
19 import sys
20
21 def _repr(obj):
22 """
23 Get the representation of an object, with dedicated pprint-like format for lists.
24 """
25 if isinstance(obj, list):
26 return '[' + (',\n '.join((_repr(e).replace('\n', '\n ') for e in obj))) + '\n]'
27 else:
28 return repr(obj)
29
30 class Node(object):
31 __slots__ = ()
32 """ Abstract base class for AST nodes.
33 """
34 def __repr__(self):
35 """ Generates a python representation of the current node
36 """
37 result = self.__class__.__name__ + '('
38
39 indent = ''
40 separator = ''
41 for name in self.__slots__[:-2]:
42 result += separator
43 result += indent
44 result += name + '=' + (_repr(getattr(self, name)).replace('\n', '\n ' + (' ' * (len(name) + len(self.__class__.__name__)))))
45
46 separator = ','
47 indent = '\n ' + (' ' * len(self.__class__.__name__))
48
49 result += indent + ')'
50
51 return result
52
53 def children(self):
54 """ A sequence of all children that are Nodes
55 """
56 pass
57
58 def show(self, buf=sys.stdout, offset=0, attrnames=False, nodenames=False, showcoord=False, _my_node_name=None):
59 """ Pretty print the Node and all its attributes and
60 children (recursively) to a buffer.
61
62 buf:
63 Open IO buffer into which the Node is printed.
64
65 offset:
66 Initial offset (amount of leading spaces)
67
68 attrnames:
69 True if you want to see the attribute names in
70 name=value pairs. False to only see the values.
71
72 nodenames:
73 True if you want to see the actual node names
74 within their parents.
75
76 showcoord:
77 Do you want the coordinates of each Node to be
78 displayed.
79 """
80 lead = ' ' * offset
81 if nodenames and _my_node_name is not None:
82 buf.write(lead + self.__class__.__name__+ ' <' + _my_node_name + '>: ')
83 else:
84 buf.write(lead + self.__class__.__name__+ ': ')
85
86 if self.attr_names:
87 if attrnames:
88 nvlist = [(n, getattr(self,n)) for n in self.attr_names]
89 attrstr = ', '.join('%s=%s' % nv for nv in nvlist)
90 else:
91 vlist = [getattr(self, n) for n in self.attr_names]
92 attrstr = ', '.join('%s' % v for v in vlist)
93 buf.write(attrstr)
94
95 if showcoord:
96 buf.write(' (at %s)' % self.coord)
97 buf.write('\n')
98
99 for (child_name, child) in self.children():
100 child.show(
101 buf,
102 offset=offset + 2,
103 attrnames=attrnames,
104 nodenames=nodenames,
105 showcoord=showcoord,
106 _my_node_name=child_name)
107
108
109 class NodeVisitor(object):
110 """ A base NodeVisitor class for visiting c_ast nodes.
111 Subclass it and define your own visit_XXX methods, where
112 XXX is the class name you want to visit with these
113 methods.
114
115 For example:
116
117 class ConstantVisitor(NodeVisitor):
118 def __init__(self):
119 self.values = []
120
121 def visit_Constant(self, node):
122 self.values.append(node.value)
123
124 Creates a list of values of all the constant nodes
125 encountered below the given node. To use it:
126
127 cv = ConstantVisitor()
128 cv.visit(node)
129
130 Notes:
131
132 * generic_visit() will be called for AST nodes for which
133 no visit_XXX method was defined.
134 * The children of nodes for which a visit_XXX was
135 defined will not be visited - if you need this, call
136 generic_visit() on the node.
137 You can use:
138 NodeVisitor.generic_visit(self, node)
139 * Modeled after Python's own AST visiting facilities
140 (the ast module of Python 3.0)
141 """
142
143 _method_cache = None
144
145 def visit(self, node):
146 """ Visit a node.
147 """
148
149 if self._method_cache is None:
150 self._method_cache = {}
151
152 visitor = self._method_cache.get(node.__class__.__name__, None)
153 if visitor is None:
154 method = 'visit_' + node.__class__.__name__
155 visitor = getattr(self, method, self.generic_visit)
156 self._method_cache[node.__class__.__name__] = visitor
157
158 return visitor(node)
159
160 def generic_visit(self, node):
161 """ Called if no explicit visitor function exists for a
162 node. Implements preorder visiting of the node.
163 """
164 for c in node:
165 self.visit(c)
166
167 class ArrayDecl(Node):
168 __slots__ = ('type', 'dim', 'dim_quals', 'coord', '__weakref__')
169 def __init__(self, type, dim, dim_quals, coord=None):
170 self.type = type
171 self.dim = dim
172 self.dim_quals = dim_quals
173 self.coord = coord
174
175 def children(self):
176 nodelist = []
177 if self.type is not None: nodelist.append(("type", self.type))
178 if self.dim is not None: nodelist.append(("dim", self.dim))
179 return tuple(nodelist)
180
181 def __iter__(self):
182 if self.type is not None:
183 yield self.type
184 if self.dim is not None:
185 yield self.dim
186
187 attr_names = ('dim_quals', )
188
189 class ArrayRef(Node):
190 __slots__ = ('name', 'subscript', 'coord', '__weakref__')
191 def __init__(self, name, subscript, coord=None):
192 self.name = name
193 self.subscript = subscript
194 self.coord = coord
195
196 def children(self):
197 nodelist = []
198 if self.name is not None: nodelist.append(("name", self.name))
199 if self.subscript is not None: nodelist.append(("subscript", self.subscript))
200 return tuple(nodelist)
201
202 def __iter__(self):
203 if self.name is not None:
204 yield self.name
205 if self.subscript is not None:
206 yield self.subscript
207
208 attr_names = ()
209
210 class Assignment(Node):
211 __slots__ = ('op', 'lvalue', 'rvalue', 'coord', '__weakref__')
212 def __init__(self, op, lvalue, rvalue, coord=None):
213 self.op = op
214 self.lvalue = lvalue
215 self.rvalue = rvalue
216 self.coord = coord
217
218 def children(self):
219 nodelist = []
220 if self.lvalue is not None: nodelist.append(("lvalue", self.lvalue))
221 if self.rvalue is not None: nodelist.append(("rvalue", self.rvalue))
222 return tuple(nodelist)
223
224 def __iter__(self):
225 if self.lvalue is not None:
226 yield self.lvalue
227 if self.rvalue is not None:
228 yield self.rvalue
229
230 attr_names = ('op', )
231
232 class Alignas(Node):
233 __slots__ = ('alignment', 'coord', '__weakref__')
234 def __init__(self, alignment, coord=None):
235 self.alignment = alignment
236 self.coord = coord
237
238 def children(self):
239 nodelist = []
240 if self.alignment is not None: nodelist.append(("alignment", self.alignment))
241 return tuple(nodelist)
242
243 def __iter__(self):
244 if self.alignment is not None:
245 yield self.alignment
246
247 attr_names = ()
248
249 class BinaryOp(Node):
250 __slots__ = ('op', 'left', 'right', 'coord', '__weakref__')
251 def __init__(self, op, left, right, coord=None):
252 self.op = op
253 self.left = left
254 self.right = right
255 self.coord = coord
256
257 def children(self):
258 nodelist = []
259 if self.left is not None: nodelist.append(("left", self.left))
260 if self.right is not None: nodelist.append(("right", self.right))
261 return tuple(nodelist)
262
263 def __iter__(self):
264 if self.left is not None:
265 yield self.left
266 if self.right is not None:
267 yield self.right
268
269 attr_names = ('op', )
270
271 class Break(Node):
272 __slots__ = ('coord', '__weakref__')
273 def __init__(self, coord=None):
274 self.coord = coord
275
276 def children(self):
277 return ()
278
279 def __iter__(self):
280 return
281 yield
282
283 attr_names = ()
284
285 class Case(Node):
286 __slots__ = ('expr', 'stmts', 'coord', '__weakref__')
287 def __init__(self, expr, stmts, coord=None):
288 self.expr = expr
289 self.stmts = stmts
290 self.coord = coord
291
292 def children(self):
293 nodelist = []
294 if self.expr is not None: nodelist.append(("expr", self.expr))
295 for i, child in enumerate(self.stmts or []):
296 nodelist.append(("stmts[%d]" % i, child))
297 return tuple(nodelist)
298
299 def __iter__(self):
300 if self.expr is not None:
301 yield self.expr
302 for child in (self.stmts or []):
303 yield child
304
305 attr_names = ()
306
307 class Cast(Node):
308 __slots__ = ('to_type', 'expr', 'coord', '__weakref__')
309 def __init__(self, to_type, expr, coord=None):
310 self.to_type = to_type
311 self.expr = expr
312 self.coord = coord
313
314 def children(self):
315 nodelist = []
316 if self.to_type is not None: nodelist.append(("to_type", self.to_type))
317 if self.expr is not None: nodelist.append(("expr", self.expr))
318 return tuple(nodelist)
319
320 def __iter__(self):
321 if self.to_type is not None:
322 yield self.to_type
323 if self.expr is not None:
324 yield self.expr
325
326 attr_names = ()
327
328 class Compound(Node):
329 __slots__ = ('block_items', 'coord', '__weakref__')
330 def __init__(self, block_items, coord=None):
331 self.block_items = block_items
332 self.coord = coord
333
334 def children(self):
335 nodelist = []
336 for i, child in enumerate(self.block_items or []):
337 nodelist.append(("block_items[%d]" % i, child))
338 return tuple(nodelist)
339
340 def __iter__(self):
341 for child in (self.block_items or []):
342 yield child
343
344 attr_names = ()
345
346 class CompoundLiteral(Node):
347 __slots__ = ('type', 'init', 'coord', '__weakref__')
348 def __init__(self, type, init, coord=None):
349 self.type = type
350 self.init = init
351 self.coord = coord
352
353 def children(self):
354 nodelist = []
355 if self.type is not None: nodelist.append(("type", self.type))
356 if self.init is not None: nodelist.append(("init", self.init))
357 return tuple(nodelist)
358
359 def __iter__(self):
360 if self.type is not None:
361 yield self.type
362 if self.init is not None:
363 yield self.init
364
365 attr_names = ()
366
367 class Constant(Node):
368 __slots__ = ('type', 'value', 'coord', '__weakref__')
369 def __init__(self, type, value, coord=None):
370 self.type = type
371 self.value = value
372 self.coord = coord
373
374 def children(self):
375 nodelist = []
376 return tuple(nodelist)
377
378 def __iter__(self):
379 return
380 yield
381
382 attr_names = ('type', 'value', )
383
384 class Continue(Node):
385 __slots__ = ('coord', '__weakref__')
386 def __init__(self, coord=None):
387 self.coord = coord
388
389 def children(self):
390 return ()
391
392 def __iter__(self):
393 return
394 yield
395
396 attr_names = ()
397
398 class Decl(Node):
399 __slots__ = ('name', 'quals', 'align', 'storage', 'funcspec', 'type', 'init', 'bitsize', 'coord', '__weakref__')
400 def __init__(self, name, quals, align, storage, funcspec, type, init, bitsize, coord=None):
401 self.name = name
402 self.quals = quals
403 self.align = align
404 self.storage = storage
405 self.funcspec = funcspec
406 self.type = type
407 self.init = init
408 self.bitsize = bitsize
409 self.coord = coord
410
411 def children(self):
412 nodelist = []
413 if self.type is not None: nodelist.append(("type", self.type))
414 if self.init is not None: nodelist.append(("init", self.init))
415 if self.bitsize is not None: nodelist.append(("bitsize", self.bitsize))
416 return tuple(nodelist)
417
418 def __iter__(self):
419 if self.type is not None:
420 yield self.type
421 if self.init is not None:
422 yield self.init
423 if self.bitsize is not None:
424 yield self.bitsize
425
426 attr_names = ('name', 'quals', 'align', 'storage', 'funcspec', )
427
428 class DeclList(Node):
429 __slots__ = ('decls', 'coord', '__weakref__')
430 def __init__(self, decls, coord=None):
431 self.decls = decls
432 self.coord = coord
433
434 def children(self):
435 nodelist = []
436 for i, child in enumerate(self.decls or []):
437 nodelist.append(("decls[%d]" % i, child))
438 return tuple(nodelist)
439
440 def __iter__(self):
441 for child in (self.decls or []):
442 yield child
443
444 attr_names = ()
445
446 class Default(Node):
447 __slots__ = ('stmts', 'coord', '__weakref__')
448 def __init__(self, stmts, coord=None):
449 self.stmts = stmts
450 self.coord = coord
451
452 def children(self):
453 nodelist = []
454 for i, child in enumerate(self.stmts or []):
455 nodelist.append(("stmts[%d]" % i, child))
456 return tuple(nodelist)
457
458 def __iter__(self):
459 for child in (self.stmts or []):
460 yield child
461
462 attr_names = ()
463
464 class DoWhile(Node):
465 __slots__ = ('cond', 'stmt', 'coord', '__weakref__')
466 def __init__(self, cond, stmt, coord=None):
467 self.cond = cond
468 self.stmt = stmt
469 self.coord = coord
470
471 def children(self):
472 nodelist = []
473 if self.cond is not None: nodelist.append(("cond", self.cond))
474 if self.stmt is not None: nodelist.append(("stmt", self.stmt))
475 return tuple(nodelist)
476
477 def __iter__(self):
478 if self.cond is not None:
479 yield self.cond
480 if self.stmt is not None:
481 yield self.stmt
482
483 attr_names = ()
484
485 class EllipsisParam(Node):
486 __slots__ = ('coord', '__weakref__')
487 def __init__(self, coord=None):
488 self.coord = coord
489
490 def children(self):
491 return ()
492
493 def __iter__(self):
494 return
495 yield
496
497 attr_names = ()
498
499 class EmptyStatement(Node):
500 __slots__ = ('coord', '__weakref__')
501 def __init__(self, coord=None):
502 self.coord = coord
503
504 def children(self):
505 return ()
506
507 def __iter__(self):
508 return
509 yield
510
511 attr_names = ()
512
513 class Enum(Node):
514 __slots__ = ('name', 'values', 'coord', '__weakref__')
515 def __init__(self, name, values, coord=None):
516 self.name = name
517 self.values = values
518 self.coord = coord
519
520 def children(self):
521 nodelist = []
522 if self.values is not None: nodelist.append(("values", self.values))
523 return tuple(nodelist)
524
525 def __iter__(self):
526 if self.values is not None:
527 yield self.values
528
529 attr_names = ('name', )
530
531 class Enumerator(Node):
532 __slots__ = ('name', 'value', 'coord', '__weakref__')
533 def __init__(self, name, value, coord=None):
534 self.name = name
535 self.value = value
536 self.coord = coord
537
538 def children(self):
539 nodelist = []
540 if self.value is not None: nodelist.append(("value", self.value))
541 return tuple(nodelist)
542
543 def __iter__(self):
544 if self.value is not None:
545 yield self.value
546
547 attr_names = ('name', )
548
549 class EnumeratorList(Node):
550 __slots__ = ('enumerators', 'coord', '__weakref__')
551 def __init__(self, enumerators, coord=None):
552 self.enumerators = enumerators
553 self.coord = coord
554
555 def children(self):
556 nodelist = []
557 for i, child in enumerate(self.enumerators or []):
558 nodelist.append(("enumerators[%d]" % i, child))
559 return tuple(nodelist)
560
561 def __iter__(self):
562 for child in (self.enumerators or []):
563 yield child
564
565 attr_names = ()
566
567 class ExprList(Node):
568 __slots__ = ('exprs', 'coord', '__weakref__')
569 def __init__(self, exprs, coord=None):
570 self.exprs = exprs
571 self.coord = coord
572
573 def children(self):
574 nodelist = []
575 for i, child in enumerate(self.exprs or []):
576 nodelist.append(("exprs[%d]" % i, child))
577 return tuple(nodelist)
578
579 def __iter__(self):
580 for child in (self.exprs or []):
581 yield child
582
583 attr_names = ()
584
585 class FileAST(Node):
586 __slots__ = ('ext', 'coord', '__weakref__')
587 def __init__(self, ext, coord=None):
588 self.ext = ext
589 self.coord = coord
590
591 def children(self):
592 nodelist = []
593 for i, child in enumerate(self.ext or []):
594 nodelist.append(("ext[%d]" % i, child))
595 return tuple(nodelist)
596
597 def __iter__(self):
598 for child in (self.ext or []):
599 yield child
600
601 attr_names = ()
602
603 class For(Node):
604 __slots__ = ('init', 'cond', 'next', 'stmt', 'coord', '__weakref__')
605 def __init__(self, init, cond, next, stmt, coord=None):
606 self.init = init
607 self.cond = cond
608 self.next = next
609 self.stmt = stmt
610 self.coord = coord
611
612 def children(self):
613 nodelist = []
614 if self.init is not None: nodelist.append(("init", self.init))
615 if self.cond is not None: nodelist.append(("cond", self.cond))
616 if self.next is not None: nodelist.append(("next", self.next))
617 if self.stmt is not None: nodelist.append(("stmt", self.stmt))
618 return tuple(nodelist)
619
620 def __iter__(self):
621 if self.init is not None:
622 yield self.init
623 if self.cond is not None:
624 yield self.cond
625 if self.next is not None:
626 yield self.next
627 if self.stmt is not None:
628 yield self.stmt
629
630 attr_names = ()
631
632 class FuncCall(Node):
633 __slots__ = ('name', 'args', 'coord', '__weakref__')
634 def __init__(self, name, args, coord=None):
635 self.name = name
636 self.args = args
637 self.coord = coord
638
639 def children(self):
640 nodelist = []
641 if self.name is not None: nodelist.append(("name", self.name))
642 if self.args is not None: nodelist.append(("args", self.args))
643 return tuple(nodelist)
644
645 def __iter__(self):
646 if self.name is not None:
647 yield self.name
648 if self.args is not None:
649 yield self.args
650
651 attr_names = ()
652
653 class FuncDecl(Node):
654 __slots__ = ('args', 'type', 'coord', '__weakref__')
655 def __init__(self, args, type, coord=None):
656 self.args = args
657 self.type = type
658 self.coord = coord
659
660 def children(self):
661 nodelist = []
662 if self.args is not None: nodelist.append(("args", self.args))
663 if self.type is not None: nodelist.append(("type", self.type))
664 return tuple(nodelist)
665
666 def __iter__(self):
667 if self.args is not None:
668 yield self.args
669 if self.type is not None:
670 yield self.type
671
672 attr_names = ()
673
674 class FuncDef(Node):
675 __slots__ = ('decl', 'param_decls', 'body', 'coord', '__weakref__')
676 def __init__(self, decl, param_decls, body, coord=None):
677 self.decl = decl
678 self.param_decls = param_decls
679 self.body = body
680 self.coord = coord
681
682 def children(self):
683 nodelist = []
684 if self.decl is not None: nodelist.append(("decl", self.decl))
685 if self.body is not None: nodelist.append(("body", self.body))
686 for i, child in enumerate(self.param_decls or []):
687 nodelist.append(("param_decls[%d]" % i, child))
688 return tuple(nodelist)
689
690 def __iter__(self):
691 if self.decl is not None:
692 yield self.decl
693 if self.body is not None:
694 yield self.body
695 for child in (self.param_decls or []):
696 yield child
697
698 attr_names = ()
699
700 class Goto(Node):
701 __slots__ = ('name', 'coord', '__weakref__')
702 def __init__(self, name, coord=None):
703 self.name = name
704 self.coord = coord
705
706 def children(self):
707 nodelist = []
708 return tuple(nodelist)
709
710 def __iter__(self):
711 return
712 yield
713
714 attr_names = ('name', )
715
716 class ID(Node):
717 __slots__ = ('name', 'coord', '__weakref__')
718 def __init__(self, name, coord=None):
719 self.name = name
720 self.coord = coord
721
722 def children(self):
723 nodelist = []
724 return tuple(nodelist)
725
726 def __iter__(self):
727 return
728 yield
729
730 attr_names = ('name', )
731
732 class IdentifierType(Node):
733 __slots__ = ('names', 'coord', '__weakref__')
734 def __init__(self, names, coord=None):
735 self.names = names
736 self.coord = coord
737
738 def children(self):
739 nodelist = []
740 return tuple(nodelist)
741
742 def __iter__(self):
743 return
744 yield
745
746 attr_names = ('names', )
747
748 class If(Node):
749 __slots__ = ('cond', 'iftrue', 'iffalse', 'coord', '__weakref__')
750 def __init__(self, cond, iftrue, iffalse, coord=None):
751 self.cond = cond
752 self.iftrue = iftrue
753 self.iffalse = iffalse
754 self.coord = coord
755
756 def children(self):
757 nodelist = []
758 if self.cond is not None: nodelist.append(("cond", self.cond))
759 if self.iftrue is not None: nodelist.append(("iftrue", self.iftrue))
760 if self.iffalse is not None: nodelist.append(("iffalse", self.iffalse))
761 return tuple(nodelist)
762
763 def __iter__(self):
764 if self.cond is not None:
765 yield self.cond
766 if self.iftrue is not None:
767 yield self.iftrue
768 if self.iffalse is not None:
769 yield self.iffalse
770
771 attr_names = ()
772
773 class InitList(Node):
774 __slots__ = ('exprs', 'coord', '__weakref__')
775 def __init__(self, exprs, coord=None):
776 self.exprs = exprs
777 self.coord = coord
778
779 def children(self):
780 nodelist = []
781 for i, child in enumerate(self.exprs or []):
782 nodelist.append(("exprs[%d]" % i, child))
783 return tuple(nodelist)
784
785 def __iter__(self):
786 for child in (self.exprs or []):
787 yield child
788
789 attr_names = ()
790
791 class Label(Node):
792 __slots__ = ('name', 'stmt', 'coord', '__weakref__')
793 def __init__(self, name, stmt, coord=None):
794 self.name = name
795 self.stmt = stmt
796 self.coord = coord
797
798 def children(self):
799 nodelist = []
800 if self.stmt is not None: nodelist.append(("stmt", self.stmt))
801 return tuple(nodelist)
802
803 def __iter__(self):
804 if self.stmt is not None:
805 yield self.stmt
806
807 attr_names = ('name', )
808
809 class NamedInitializer(Node):
810 __slots__ = ('name', 'expr', 'coord', '__weakref__')
811 def __init__(self, name, expr, coord=None):
812 self.name = name
813 self.expr = expr
814 self.coord = coord
815
816 def children(self):
817 nodelist = []
818 if self.expr is not None: nodelist.append(("expr", self.expr))
819 for i, child in enumerate(self.name or []):
820 nodelist.append(("name[%d]" % i, child))
821 return tuple(nodelist)
822
823 def __iter__(self):
824 if self.expr is not None:
825 yield self.expr
826 for child in (self.name or []):
827 yield child
828
829 attr_names = ()
830
831 class ParamList(Node):
832 __slots__ = ('params', 'coord', '__weakref__')
833 def __init__(self, params, coord=None):
834 self.params = params
835 self.coord = coord
836
837 def children(self):
838 nodelist = []
839 for i, child in enumerate(self.params or []):
840 nodelist.append(("params[%d]" % i, child))
841 return tuple(nodelist)
842
843 def __iter__(self):
844 for child in (self.params or []):
845 yield child
846
847 attr_names = ()
848
849 class PtrDecl(Node):
850 __slots__ = ('quals', 'type', 'coord', '__weakref__')
851 def __init__(self, quals, type, coord=None):
852 self.quals = quals
853 self.type = type
854 self.coord = coord
855
856 def children(self):
857 nodelist = []
858 if self.type is not None: nodelist.append(("type", self.type))
859 return tuple(nodelist)
860
861 def __iter__(self):
862 if self.type is not None:
863 yield self.type
864
865 attr_names = ('quals', )
866
867 class Return(Node):
868 __slots__ = ('expr', 'coord', '__weakref__')
869 def __init__(self, expr, coord=None):
870 self.expr = expr
871 self.coord = coord
872
873 def children(self):
874 nodelist = []
875 if self.expr is not None: nodelist.append(("expr", self.expr))
876 return tuple(nodelist)
877
878 def __iter__(self):
879 if self.expr is not None:
880 yield self.expr
881
882 attr_names = ()
883
884 class StaticAssert(Node):
885 __slots__ = ('cond', 'message', 'coord', '__weakref__')
886 def __init__(self, cond, message, coord=None):
887 self.cond = cond
888 self.message = message
889 self.coord = coord
890
891 def children(self):
892 nodelist = []
893 if self.cond is not None: nodelist.append(("cond", self.cond))
894 if self.message is not None: nodelist.append(("message", self.message))
895 return tuple(nodelist)
896
897 def __iter__(self):
898 if self.cond is not None:
899 yield self.cond
900 if self.message is not None:
901 yield self.message
902
903 attr_names = ()
904
905 class Struct(Node):
906 __slots__ = ('name', 'decls', 'coord', '__weakref__')
907 def __init__(self, name, decls, coord=None):
908 self.name = name
909 self.decls = decls
910 self.coord = coord
911
912 def children(self):
913 nodelist = []
914 for i, child in enumerate(self.decls or []):
915 nodelist.append(("decls[%d]" % i, child))
916 return tuple(nodelist)
917
918 def __iter__(self):
919 for child in (self.decls or []):
920 yield child
921
922 attr_names = ('name', )
923
924 class StructRef(Node):
925 __slots__ = ('name', 'type', 'field', 'coord', '__weakref__')
926 def __init__(self, name, type, field, coord=None):
927 self.name = name
928 self.type = type
929 self.field = field
930 self.coord = coord
931
932 def children(self):
933 nodelist = []
934 if self.name is not None: nodelist.append(("name", self.name))
935 if self.field is not None: nodelist.append(("field", self.field))
936 return tuple(nodelist)
937
938 def __iter__(self):
939 if self.name is not None:
940 yield self.name
941 if self.field is not None:
942 yield self.field
943
944 attr_names = ('type', )
945
946 class Switch(Node):
947 __slots__ = ('cond', 'stmt', 'coord', '__weakref__')
948 def __init__(self, cond, stmt, coord=None):
949 self.cond = cond
950 self.stmt = stmt
951 self.coord = coord
952
953 def children(self):
954 nodelist = []
955 if self.cond is not None: nodelist.append(("cond", self.cond))
956 if self.stmt is not None: nodelist.append(("stmt", self.stmt))
957 return tuple(nodelist)
958
959 def __iter__(self):
960 if self.cond is not None:
961 yield self.cond
962 if self.stmt is not None:
963 yield self.stmt
964
965 attr_names = ()
966
967 class TernaryOp(Node):
968 __slots__ = ('cond', 'iftrue', 'iffalse', 'coord', '__weakref__')
969 def __init__(self, cond, iftrue, iffalse, coord=None):
970 self.cond = cond
971 self.iftrue = iftrue
972 self.iffalse = iffalse
973 self.coord = coord
974
975 def children(self):
976 nodelist = []
977 if self.cond is not None: nodelist.append(("cond", self.cond))
978 if self.iftrue is not None: nodelist.append(("iftrue", self.iftrue))
979 if self.iffalse is not None: nodelist.append(("iffalse", self.iffalse))
980 return tuple(nodelist)
981
982 def __iter__(self):
983 if self.cond is not None:
984 yield self.cond
985 if self.iftrue is not None:
986 yield self.iftrue
987 if self.iffalse is not None:
988 yield self.iffalse
989
990 attr_names = ()
991
992 class TypeDecl(Node):
993 __slots__ = ('declname', 'quals', 'align', 'type', 'coord', '__weakref__')
994 def __init__(self, declname, quals, align, type, coord=None):
995 self.declname = declname
996 self.quals = quals
997 self.align = align
998 self.type = type
999 self.coord = coord
1000
1001 def children(self):
1002 nodelist = []
1003 if self.type is not None: nodelist.append(("type", self.type))
1004 return tuple(nodelist)
1005
1006 def __iter__(self):
1007 if self.type is not None:
1008 yield self.type
1009
1010 attr_names = ('declname', 'quals', 'align', )
1011
1012 class Typedef(Node):
1013 __slots__ = ('name', 'quals', 'storage', 'type', 'coord', '__weakref__')
1014 def __init__(self, name, quals, storage, type, coord=None):
1015 self.name = name
1016 self.quals = quals
1017 self.storage = storage
1018 self.type = type
1019 self.coord = coord
1020
1021 def children(self):
1022 nodelist = []
1023 if self.type is not None: nodelist.append(("type", self.type))
1024 return tuple(nodelist)
1025
1026 def __iter__(self):
1027 if self.type is not None:
1028 yield self.type
1029
1030 attr_names = ('name', 'quals', 'storage', )
1031
1032 class Typename(Node):
1033 __slots__ = ('name', 'quals', 'align', 'type', 'coord', '__weakref__')
1034 def __init__(self, name, quals, align, type, coord=None):
1035 self.name = name
1036 self.quals = quals
1037 self.align = align
1038 self.type = type
1039 self.coord = coord
1040
1041 def children(self):
1042 nodelist = []
1043 if self.type is not None: nodelist.append(("type", self.type))
1044 return tuple(nodelist)
1045
1046 def __iter__(self):
1047 if self.type is not None:
1048 yield self.type
1049
1050 attr_names = ('name', 'quals', 'align', )
1051
1052 class UnaryOp(Node):
1053 __slots__ = ('op', 'expr', 'coord', '__weakref__')
1054 def __init__(self, op, expr, coord=None):
1055 self.op = op
1056 self.expr = expr
1057 self.coord = coord
1058
1059 def children(self):
1060 nodelist = []
1061 if self.expr is not None: nodelist.append(("expr", self.expr))
1062 return tuple(nodelist)
1063
1064 def __iter__(self):
1065 if self.expr is not None:
1066 yield self.expr
1067
1068 attr_names = ('op', )
1069
1070 class Union(Node):
1071 __slots__ = ('name', 'decls', 'coord', '__weakref__')
1072 def __init__(self, name, decls, coord=None):
1073 self.name = name
1074 self.decls = decls
1075 self.coord = coord
1076
1077 def children(self):
1078 nodelist = []
1079 for i, child in enumerate(self.decls or []):
1080 nodelist.append(("decls[%d]" % i, child))
1081 return tuple(nodelist)
1082
1083 def __iter__(self):
1084 for child in (self.decls or []):
1085 yield child
1086
1087 attr_names = ('name', )
1088
1089 class While(Node):
1090 __slots__ = ('cond', 'stmt', 'coord', '__weakref__')
1091 def __init__(self, cond, stmt, coord=None):
1092 self.cond = cond
1093 self.stmt = stmt
1094 self.coord = coord
1095
1096 def children(self):
1097 nodelist = []
1098 if self.cond is not None: nodelist.append(("cond", self.cond))
1099 if self.stmt is not None: nodelist.append(("stmt", self.stmt))
1100 return tuple(nodelist)
1101
1102 def __iter__(self):
1103 if self.cond is not None:
1104 yield self.cond
1105 if self.stmt is not None:
1106 yield self.stmt
1107
1108 attr_names = ()
1109
1110 class Pragma(Node):
1111 __slots__ = ('string', 'coord', '__weakref__')
1112 def __init__(self, string, coord=None):
1113 self.string = string
1114 self.coord = coord
1115
1116 def children(self):
1117 nodelist = []
1118 return tuple(nodelist)
1119
1120 def __iter__(self):
1121 return
1122 yield
1123
1124 attr_names = ('string', )
1125