Funktionierender Prototyp des Serious Games zur Vermittlung von Wissen zu Software-Engineering-Arbeitsmodellen.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

c_ast.py 31KB

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