Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/pycparser/c_ast.py: 1%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

865 statements  

1# ----------------------------------------------------------------- 

2# ** ATTENTION ** 

3# This code was automatically generated from _c_ast.cfg 

4# 

5# Do not modify it directly. Modify the configuration file and 

6# run the generator again. 

7# ** ** *** ** ** 

8# 

9# pycparser: c_ast.py 

10# 

11# AST Node classes. 

12# 

13# Eli Bendersky [https://eli.thegreenplace.net/] 

14# License: BSD 

15# ----------------------------------------------------------------- 

16 

17 

18import sys 

19from typing import Any, ClassVar, IO, Optional 

20 

21 

22def _repr(obj): 

23 """ 

24 Get the representation of an object, with dedicated pprint-like format for lists. 

25 """ 

26 if isinstance(obj, list): 

27 return "[" + (",\n ".join((_repr(e).replace("\n", "\n ") for e in obj))) + "\n]" 

28 else: 

29 return repr(obj) 

30 

31 

32class Node: 

33 __slots__ = () 

34 """ Abstract base class for AST nodes. 

35 """ 

36 attr_names: ClassVar[tuple[str, ...]] = () 

37 coord: Optional[Any] 

38 

39 def __repr__(self): 

40 """Generates a python representation of the current node""" 

41 result = self.__class__.__name__ + "(" 

42 

43 indent = "" 

44 separator = "" 

45 for name in self.__slots__[:-2]: 

46 result += separator 

47 result += indent 

48 result += ( 

49 name 

50 + "=" 

51 + ( 

52 _repr(getattr(self, name)).replace( 

53 "\n", 

54 "\n " + (" " * (len(name) + len(self.__class__.__name__))), 

55 ) 

56 ) 

57 ) 

58 

59 separator = "," 

60 indent = "\n " + (" " * len(self.__class__.__name__)) 

61 

62 result += indent + ")" 

63 

64 return result 

65 

66 def children(self): 

67 """A sequence of all children that are Nodes""" 

68 pass 

69 

70 def show( 

71 self, 

72 buf: IO[str] = sys.stdout, 

73 offset: int = 0, 

74 attrnames: bool = False, 

75 showemptyattrs: bool = True, 

76 nodenames: bool = False, 

77 showcoord: bool = False, 

78 _my_node_name: Optional[str] = None, 

79 ): 

80 """Pretty print the Node and all its attributes and 

81 children (recursively) to a buffer. 

82 

83 buf: 

84 Open IO buffer into which the Node is printed. 

85 

86 offset: 

87 Initial offset (amount of leading spaces) 

88 

89 attrnames: 

90 True if you want to see the attribute names in 

91 name=value pairs. False to only see the values. 

92 

93 showemptyattrs: 

94 False if you want to suppress printing empty attributes. 

95 

96 nodenames: 

97 True if you want to see the actual node names 

98 within their parents. 

99 

100 showcoord: 

101 Do you want the coordinates of each Node to be 

102 displayed. 

103 """ 

104 lead = " " * offset 

105 if nodenames and _my_node_name is not None: 

106 buf.write(lead + self.__class__.__name__ + " <" + _my_node_name + ">: ") 

107 else: 

108 buf.write(lead + self.__class__.__name__ + ": ") 

109 

110 if self.attr_names: 

111 

112 def is_empty(v): 

113 v is None or (hasattr(v, "__len__") and len(v) == 0) 

114 

115 nvlist = [ 

116 (n, getattr(self, n)) 

117 for n in self.attr_names 

118 if showemptyattrs or not is_empty(getattr(self, n)) 

119 ] 

120 if attrnames: 

121 attrstr = ", ".join(f"{name}={value}" for name, value in nvlist) 

122 else: 

123 attrstr = ", ".join(f"{value}" for _, value in nvlist) 

124 buf.write(attrstr) 

125 

126 if showcoord: 

127 buf.write(f" (at {self.coord})") 

128 buf.write("\n") 

129 

130 for child_name, child in self.children(): 

131 child.show( 

132 buf, 

133 offset=offset + 2, 

134 attrnames=attrnames, 

135 showemptyattrs=showemptyattrs, 

136 nodenames=nodenames, 

137 showcoord=showcoord, 

138 _my_node_name=child_name, 

139 ) 

140 

141 

142class NodeVisitor: 

143 """A base NodeVisitor class for visiting c_ast nodes. 

144 Subclass it and define your own visit_XXX methods, where 

145 XXX is the class name you want to visit with these 

146 methods. 

147 

148 For example: 

149 

150 class ConstantVisitor(NodeVisitor): 

151 def __init__(self): 

152 self.values = [] 

153 

154 def visit_Constant(self, node): 

155 self.values.append(node.value) 

156 

157 Creates a list of values of all the constant nodes 

158 encountered below the given node. To use it: 

159 

160 cv = ConstantVisitor() 

161 cv.visit(node) 

162 

163 Notes: 

164 

165 * generic_visit() will be called for AST nodes for which 

166 no visit_XXX method was defined. 

167 * The children of nodes for which a visit_XXX was 

168 defined will not be visited - if you need this, call 

169 generic_visit() on the node. 

170 You can use: 

171 NodeVisitor.generic_visit(self, node) 

172 * Modeled after Python's own AST visiting facilities 

173 (the ast module of Python 3.0) 

174 """ 

175 

176 _method_cache = None 

177 

178 def visit(self, node: Node): 

179 """Visit a node.""" 

180 

181 if self._method_cache is None: 

182 self._method_cache = {} 

183 

184 visitor = self._method_cache.get(node.__class__.__name__, None) 

185 if visitor is None: 

186 method = "visit_" + node.__class__.__name__ 

187 visitor = getattr(self, method, self.generic_visit) 

188 self._method_cache[node.__class__.__name__] = visitor 

189 

190 return visitor(node) 

191 

192 def generic_visit(self, node: Node): 

193 """Called if no explicit visitor function exists for a 

194 node. Implements preorder visiting of the node. 

195 """ 

196 for _, c in node.children(): 

197 self.visit(c) 

198 

199 

200class ArrayDecl(Node): 

201 __slots__ = ("type", "dim", "dim_quals", "coord", "__weakref__") 

202 

203 def __init__(self, type, dim, dim_quals, coord=None): 

204 self.type = type 

205 self.dim = dim 

206 self.dim_quals = dim_quals 

207 self.coord = coord 

208 

209 def children(self): 

210 nodelist = [] 

211 if self.type is not None: 

212 nodelist.append(("type", self.type)) 

213 if self.dim is not None: 

214 nodelist.append(("dim", self.dim)) 

215 return tuple(nodelist) 

216 

217 def __iter__(self): 

218 if self.type is not None: 

219 yield self.type 

220 if self.dim is not None: 

221 yield self.dim 

222 

223 attr_names = ("dim_quals",) 

224 

225 

226class ArrayRef(Node): 

227 __slots__ = ("name", "subscript", "coord", "__weakref__") 

228 

229 def __init__(self, name, subscript, coord=None): 

230 self.name = name 

231 self.subscript = subscript 

232 self.coord = coord 

233 

234 def children(self): 

235 nodelist = [] 

236 if self.name is not None: 

237 nodelist.append(("name", self.name)) 

238 if self.subscript is not None: 

239 nodelist.append(("subscript", self.subscript)) 

240 return tuple(nodelist) 

241 

242 def __iter__(self): 

243 if self.name is not None: 

244 yield self.name 

245 if self.subscript is not None: 

246 yield self.subscript 

247 

248 attr_names = () 

249 

250 

251class Assignment(Node): 

252 __slots__ = ("op", "lvalue", "rvalue", "coord", "__weakref__") 

253 

254 def __init__(self, op, lvalue, rvalue, coord=None): 

255 self.op = op 

256 self.lvalue = lvalue 

257 self.rvalue = rvalue 

258 self.coord = coord 

259 

260 def children(self): 

261 nodelist = [] 

262 if self.lvalue is not None: 

263 nodelist.append(("lvalue", self.lvalue)) 

264 if self.rvalue is not None: 

265 nodelist.append(("rvalue", self.rvalue)) 

266 return tuple(nodelist) 

267 

268 def __iter__(self): 

269 if self.lvalue is not None: 

270 yield self.lvalue 

271 if self.rvalue is not None: 

272 yield self.rvalue 

273 

274 attr_names = ("op",) 

275 

276 

277class Alignas(Node): 

278 __slots__ = ("alignment", "coord", "__weakref__") 

279 

280 def __init__(self, alignment, coord=None): 

281 self.alignment = alignment 

282 self.coord = coord 

283 

284 def children(self): 

285 nodelist = [] 

286 if self.alignment is not None: 

287 nodelist.append(("alignment", self.alignment)) 

288 return tuple(nodelist) 

289 

290 def __iter__(self): 

291 if self.alignment is not None: 

292 yield self.alignment 

293 

294 attr_names = () 

295 

296 

297class BinaryOp(Node): 

298 __slots__ = ("op", "left", "right", "coord", "__weakref__") 

299 

300 def __init__(self, op, left, right, coord=None): 

301 self.op = op 

302 self.left = left 

303 self.right = right 

304 self.coord = coord 

305 

306 def children(self): 

307 nodelist = [] 

308 if self.left is not None: 

309 nodelist.append(("left", self.left)) 

310 if self.right is not None: 

311 nodelist.append(("right", self.right)) 

312 return tuple(nodelist) 

313 

314 def __iter__(self): 

315 if self.left is not None: 

316 yield self.left 

317 if self.right is not None: 

318 yield self.right 

319 

320 attr_names = ("op",) 

321 

322 

323class Break(Node): 

324 __slots__ = ("coord", "__weakref__") 

325 

326 def __init__(self, coord=None): 

327 self.coord = coord 

328 

329 def children(self): 

330 return () 

331 

332 def __iter__(self): 

333 return 

334 yield 

335 

336 attr_names = () 

337 

338 

339class Case(Node): 

340 __slots__ = ("expr", "stmts", "coord", "__weakref__") 

341 

342 def __init__(self, expr, stmts, coord=None): 

343 self.expr = expr 

344 self.stmts = stmts 

345 self.coord = coord 

346 

347 def children(self): 

348 nodelist = [] 

349 if self.expr is not None: 

350 nodelist.append(("expr", self.expr)) 

351 for i, child in enumerate(self.stmts or []): 

352 nodelist.append((f"stmts[{i}]", child)) 

353 return tuple(nodelist) 

354 

355 def __iter__(self): 

356 if self.expr is not None: 

357 yield self.expr 

358 for child in self.stmts or []: 

359 yield child 

360 

361 attr_names = () 

362 

363 

364class Cast(Node): 

365 __slots__ = ("to_type", "expr", "coord", "__weakref__") 

366 

367 def __init__(self, to_type, expr, coord=None): 

368 self.to_type = to_type 

369 self.expr = expr 

370 self.coord = coord 

371 

372 def children(self): 

373 nodelist = [] 

374 if self.to_type is not None: 

375 nodelist.append(("to_type", self.to_type)) 

376 if self.expr is not None: 

377 nodelist.append(("expr", self.expr)) 

378 return tuple(nodelist) 

379 

380 def __iter__(self): 

381 if self.to_type is not None: 

382 yield self.to_type 

383 if self.expr is not None: 

384 yield self.expr 

385 

386 attr_names = () 

387 

388 

389class Compound(Node): 

390 __slots__ = ("block_items", "coord", "__weakref__") 

391 

392 def __init__(self, block_items, coord=None): 

393 self.block_items = block_items 

394 self.coord = coord 

395 

396 def children(self): 

397 nodelist = [] 

398 for i, child in enumerate(self.block_items or []): 

399 nodelist.append((f"block_items[{i}]", child)) 

400 return tuple(nodelist) 

401 

402 def __iter__(self): 

403 for child in self.block_items or []: 

404 yield child 

405 

406 attr_names = () 

407 

408 

409class CompoundLiteral(Node): 

410 __slots__ = ("type", "init", "coord", "__weakref__") 

411 

412 def __init__(self, type, init, coord=None): 

413 self.type = type 

414 self.init = init 

415 self.coord = coord 

416 

417 def children(self): 

418 nodelist = [] 

419 if self.type is not None: 

420 nodelist.append(("type", self.type)) 

421 if self.init is not None: 

422 nodelist.append(("init", self.init)) 

423 return tuple(nodelist) 

424 

425 def __iter__(self): 

426 if self.type is not None: 

427 yield self.type 

428 if self.init is not None: 

429 yield self.init 

430 

431 attr_names = () 

432 

433 

434class Constant(Node): 

435 __slots__ = ("type", "value", "coord", "__weakref__") 

436 

437 def __init__(self, type, value, coord=None): 

438 self.type = type 

439 self.value = value 

440 self.coord = coord 

441 

442 def children(self): 

443 nodelist = [] 

444 return tuple(nodelist) 

445 

446 def __iter__(self): 

447 return 

448 yield 

449 

450 attr_names = ( 

451 "type", 

452 "value", 

453 ) 

454 

455 

456class Continue(Node): 

457 __slots__ = ("coord", "__weakref__") 

458 

459 def __init__(self, coord=None): 

460 self.coord = coord 

461 

462 def children(self): 

463 return () 

464 

465 def __iter__(self): 

466 return 

467 yield 

468 

469 attr_names = () 

470 

471 

472class Decl(Node): 

473 __slots__ = ( 

474 "name", 

475 "quals", 

476 "align", 

477 "storage", 

478 "funcspec", 

479 "type", 

480 "init", 

481 "bitsize", 

482 "coord", 

483 "__weakref__", 

484 ) 

485 

486 def __init__( 

487 self, name, quals, align, storage, funcspec, type, init, bitsize, coord=None 

488 ): 

489 self.name = name 

490 self.quals = quals 

491 self.align = align 

492 self.storage = storage 

493 self.funcspec = funcspec 

494 self.type = type 

495 self.init = init 

496 self.bitsize = bitsize 

497 self.coord = coord 

498 

499 def children(self): 

500 nodelist = [] 

501 if self.type is not None: 

502 nodelist.append(("type", self.type)) 

503 if self.init is not None: 

504 nodelist.append(("init", self.init)) 

505 if self.bitsize is not None: 

506 nodelist.append(("bitsize", self.bitsize)) 

507 return tuple(nodelist) 

508 

509 def __iter__(self): 

510 if self.type is not None: 

511 yield self.type 

512 if self.init is not None: 

513 yield self.init 

514 if self.bitsize is not None: 

515 yield self.bitsize 

516 

517 attr_names = ( 

518 "name", 

519 "quals", 

520 "align", 

521 "storage", 

522 "funcspec", 

523 ) 

524 

525 

526class DeclList(Node): 

527 __slots__ = ("decls", "coord", "__weakref__") 

528 

529 def __init__(self, decls, coord=None): 

530 self.decls = decls 

531 self.coord = coord 

532 

533 def children(self): 

534 nodelist = [] 

535 for i, child in enumerate(self.decls or []): 

536 nodelist.append((f"decls[{i}]", child)) 

537 return tuple(nodelist) 

538 

539 def __iter__(self): 

540 for child in self.decls or []: 

541 yield child 

542 

543 attr_names = () 

544 

545 

546class Default(Node): 

547 __slots__ = ("stmts", "coord", "__weakref__") 

548 

549 def __init__(self, stmts, coord=None): 

550 self.stmts = stmts 

551 self.coord = coord 

552 

553 def children(self): 

554 nodelist = [] 

555 for i, child in enumerate(self.stmts or []): 

556 nodelist.append((f"stmts[{i}]", child)) 

557 return tuple(nodelist) 

558 

559 def __iter__(self): 

560 for child in self.stmts or []: 

561 yield child 

562 

563 attr_names = () 

564 

565 

566class DoWhile(Node): 

567 __slots__ = ("cond", "stmt", "coord", "__weakref__") 

568 

569 def __init__(self, cond, stmt, coord=None): 

570 self.cond = cond 

571 self.stmt = stmt 

572 self.coord = coord 

573 

574 def children(self): 

575 nodelist = [] 

576 if self.cond is not None: 

577 nodelist.append(("cond", self.cond)) 

578 if self.stmt is not None: 

579 nodelist.append(("stmt", self.stmt)) 

580 return tuple(nodelist) 

581 

582 def __iter__(self): 

583 if self.cond is not None: 

584 yield self.cond 

585 if self.stmt is not None: 

586 yield self.stmt 

587 

588 attr_names = () 

589 

590 

591class EllipsisParam(Node): 

592 __slots__ = ("coord", "__weakref__") 

593 

594 def __init__(self, coord=None): 

595 self.coord = coord 

596 

597 def children(self): 

598 return () 

599 

600 def __iter__(self): 

601 return 

602 yield 

603 

604 attr_names = () 

605 

606 

607class EmptyStatement(Node): 

608 __slots__ = ("coord", "__weakref__") 

609 

610 def __init__(self, coord=None): 

611 self.coord = coord 

612 

613 def children(self): 

614 return () 

615 

616 def __iter__(self): 

617 return 

618 yield 

619 

620 attr_names = () 

621 

622 

623class Enum(Node): 

624 __slots__ = ("name", "values", "coord", "__weakref__") 

625 

626 def __init__(self, name, values, coord=None): 

627 self.name = name 

628 self.values = values 

629 self.coord = coord 

630 

631 def children(self): 

632 nodelist = [] 

633 if self.values is not None: 

634 nodelist.append(("values", self.values)) 

635 return tuple(nodelist) 

636 

637 def __iter__(self): 

638 if self.values is not None: 

639 yield self.values 

640 

641 attr_names = ("name",) 

642 

643 

644class Enumerator(Node): 

645 __slots__ = ("name", "value", "coord", "__weakref__") 

646 

647 def __init__(self, name, value, coord=None): 

648 self.name = name 

649 self.value = value 

650 self.coord = coord 

651 

652 def children(self): 

653 nodelist = [] 

654 if self.value is not None: 

655 nodelist.append(("value", self.value)) 

656 return tuple(nodelist) 

657 

658 def __iter__(self): 

659 if self.value is not None: 

660 yield self.value 

661 

662 attr_names = ("name",) 

663 

664 

665class EnumeratorList(Node): 

666 __slots__ = ("enumerators", "coord", "__weakref__") 

667 

668 def __init__(self, enumerators, coord=None): 

669 self.enumerators = enumerators 

670 self.coord = coord 

671 

672 def children(self): 

673 nodelist = [] 

674 for i, child in enumerate(self.enumerators or []): 

675 nodelist.append((f"enumerators[{i}]", child)) 

676 return tuple(nodelist) 

677 

678 def __iter__(self): 

679 for child in self.enumerators or []: 

680 yield child 

681 

682 attr_names = () 

683 

684 

685class ExprList(Node): 

686 __slots__ = ("exprs", "coord", "__weakref__") 

687 

688 def __init__(self, exprs, coord=None): 

689 self.exprs = exprs 

690 self.coord = coord 

691 

692 def children(self): 

693 nodelist = [] 

694 for i, child in enumerate(self.exprs or []): 

695 nodelist.append((f"exprs[{i}]", child)) 

696 return tuple(nodelist) 

697 

698 def __iter__(self): 

699 for child in self.exprs or []: 

700 yield child 

701 

702 attr_names = () 

703 

704 

705class FileAST(Node): 

706 __slots__ = ("ext", "coord", "__weakref__") 

707 

708 def __init__(self, ext, coord=None): 

709 self.ext = ext 

710 self.coord = coord 

711 

712 def children(self): 

713 nodelist = [] 

714 for i, child in enumerate(self.ext or []): 

715 nodelist.append((f"ext[{i}]", child)) 

716 return tuple(nodelist) 

717 

718 def __iter__(self): 

719 for child in self.ext or []: 

720 yield child 

721 

722 attr_names = () 

723 

724 

725class For(Node): 

726 __slots__ = ("init", "cond", "next", "stmt", "coord", "__weakref__") 

727 

728 def __init__(self, init, cond, next, stmt, coord=None): 

729 self.init = init 

730 self.cond = cond 

731 self.next = next 

732 self.stmt = stmt 

733 self.coord = coord 

734 

735 def children(self): 

736 nodelist = [] 

737 if self.init is not None: 

738 nodelist.append(("init", self.init)) 

739 if self.cond is not None: 

740 nodelist.append(("cond", self.cond)) 

741 if self.next is not None: 

742 nodelist.append(("next", self.next)) 

743 if self.stmt is not None: 

744 nodelist.append(("stmt", self.stmt)) 

745 return tuple(nodelist) 

746 

747 def __iter__(self): 

748 if self.init is not None: 

749 yield self.init 

750 if self.cond is not None: 

751 yield self.cond 

752 if self.next is not None: 

753 yield self.next 

754 if self.stmt is not None: 

755 yield self.stmt 

756 

757 attr_names = () 

758 

759 

760class FuncCall(Node): 

761 __slots__ = ("name", "args", "coord", "__weakref__") 

762 

763 def __init__(self, name, args, coord=None): 

764 self.name = name 

765 self.args = args 

766 self.coord = coord 

767 

768 def children(self): 

769 nodelist = [] 

770 if self.name is not None: 

771 nodelist.append(("name", self.name)) 

772 if self.args is not None: 

773 nodelist.append(("args", self.args)) 

774 return tuple(nodelist) 

775 

776 def __iter__(self): 

777 if self.name is not None: 

778 yield self.name 

779 if self.args is not None: 

780 yield self.args 

781 

782 attr_names = () 

783 

784 

785class FuncDecl(Node): 

786 __slots__ = ("args", "type", "coord", "__weakref__") 

787 

788 def __init__(self, args, type, coord=None): 

789 self.args = args 

790 self.type = type 

791 self.coord = coord 

792 

793 def children(self): 

794 nodelist = [] 

795 if self.args is not None: 

796 nodelist.append(("args", self.args)) 

797 if self.type is not None: 

798 nodelist.append(("type", self.type)) 

799 return tuple(nodelist) 

800 

801 def __iter__(self): 

802 if self.args is not None: 

803 yield self.args 

804 if self.type is not None: 

805 yield self.type 

806 

807 attr_names = () 

808 

809 

810class FuncDef(Node): 

811 __slots__ = ("decl", "param_decls", "body", "coord", "__weakref__") 

812 

813 def __init__(self, decl, param_decls, body, coord=None): 

814 self.decl = decl 

815 self.param_decls = param_decls 

816 self.body = body 

817 self.coord = coord 

818 

819 def children(self): 

820 nodelist = [] 

821 if self.decl is not None: 

822 nodelist.append(("decl", self.decl)) 

823 if self.body is not None: 

824 nodelist.append(("body", self.body)) 

825 for i, child in enumerate(self.param_decls or []): 

826 nodelist.append((f"param_decls[{i}]", child)) 

827 return tuple(nodelist) 

828 

829 def __iter__(self): 

830 if self.decl is not None: 

831 yield self.decl 

832 if self.body is not None: 

833 yield self.body 

834 for child in self.param_decls or []: 

835 yield child 

836 

837 attr_names = () 

838 

839 

840class Goto(Node): 

841 __slots__ = ("name", "coord", "__weakref__") 

842 

843 def __init__(self, name, coord=None): 

844 self.name = name 

845 self.coord = coord 

846 

847 def children(self): 

848 nodelist = [] 

849 return tuple(nodelist) 

850 

851 def __iter__(self): 

852 return 

853 yield 

854 

855 attr_names = ("name",) 

856 

857 

858class ID(Node): 

859 __slots__ = ("name", "coord", "__weakref__") 

860 

861 def __init__(self, name, coord=None): 

862 self.name = name 

863 self.coord = coord 

864 

865 def children(self): 

866 nodelist = [] 

867 return tuple(nodelist) 

868 

869 def __iter__(self): 

870 return 

871 yield 

872 

873 attr_names = ("name",) 

874 

875 

876class IdentifierType(Node): 

877 __slots__ = ("names", "coord", "__weakref__") 

878 

879 def __init__(self, names, coord=None): 

880 self.names = names 

881 self.coord = coord 

882 

883 def children(self): 

884 nodelist = [] 

885 return tuple(nodelist) 

886 

887 def __iter__(self): 

888 return 

889 yield 

890 

891 attr_names = ("names",) 

892 

893 

894class If(Node): 

895 __slots__ = ("cond", "iftrue", "iffalse", "coord", "__weakref__") 

896 

897 def __init__(self, cond, iftrue, iffalse, coord=None): 

898 self.cond = cond 

899 self.iftrue = iftrue 

900 self.iffalse = iffalse 

901 self.coord = coord 

902 

903 def children(self): 

904 nodelist = [] 

905 if self.cond is not None: 

906 nodelist.append(("cond", self.cond)) 

907 if self.iftrue is not None: 

908 nodelist.append(("iftrue", self.iftrue)) 

909 if self.iffalse is not None: 

910 nodelist.append(("iffalse", self.iffalse)) 

911 return tuple(nodelist) 

912 

913 def __iter__(self): 

914 if self.cond is not None: 

915 yield self.cond 

916 if self.iftrue is not None: 

917 yield self.iftrue 

918 if self.iffalse is not None: 

919 yield self.iffalse 

920 

921 attr_names = () 

922 

923 

924class InitList(Node): 

925 __slots__ = ("exprs", "coord", "__weakref__") 

926 

927 def __init__(self, exprs, coord=None): 

928 self.exprs = exprs 

929 self.coord = coord 

930 

931 def children(self): 

932 nodelist = [] 

933 for i, child in enumerate(self.exprs or []): 

934 nodelist.append((f"exprs[{i}]", child)) 

935 return tuple(nodelist) 

936 

937 def __iter__(self): 

938 for child in self.exprs or []: 

939 yield child 

940 

941 attr_names = () 

942 

943 

944class Label(Node): 

945 __slots__ = ("name", "stmt", "coord", "__weakref__") 

946 

947 def __init__(self, name, stmt, coord=None): 

948 self.name = name 

949 self.stmt = stmt 

950 self.coord = coord 

951 

952 def children(self): 

953 nodelist = [] 

954 if self.stmt is not None: 

955 nodelist.append(("stmt", self.stmt)) 

956 return tuple(nodelist) 

957 

958 def __iter__(self): 

959 if self.stmt is not None: 

960 yield self.stmt 

961 

962 attr_names = ("name",) 

963 

964 

965class NamedInitializer(Node): 

966 __slots__ = ("name", "expr", "coord", "__weakref__") 

967 

968 def __init__(self, name, expr, coord=None): 

969 self.name = name 

970 self.expr = expr 

971 self.coord = coord 

972 

973 def children(self): 

974 nodelist = [] 

975 if self.expr is not None: 

976 nodelist.append(("expr", self.expr)) 

977 for i, child in enumerate(self.name or []): 

978 nodelist.append((f"name[{i}]", child)) 

979 return tuple(nodelist) 

980 

981 def __iter__(self): 

982 if self.expr is not None: 

983 yield self.expr 

984 for child in self.name or []: 

985 yield child 

986 

987 attr_names = () 

988 

989 

990class ParamList(Node): 

991 __slots__ = ("params", "coord", "__weakref__") 

992 

993 def __init__(self, params, coord=None): 

994 self.params = params 

995 self.coord = coord 

996 

997 def children(self): 

998 nodelist = [] 

999 for i, child in enumerate(self.params or []): 

1000 nodelist.append((f"params[{i}]", child)) 

1001 return tuple(nodelist) 

1002 

1003 def __iter__(self): 

1004 for child in self.params or []: 

1005 yield child 

1006 

1007 attr_names = () 

1008 

1009 

1010class PtrDecl(Node): 

1011 __slots__ = ("quals", "type", "coord", "__weakref__") 

1012 

1013 def __init__(self, quals, type, coord=None): 

1014 self.quals = quals 

1015 self.type = type 

1016 self.coord = coord 

1017 

1018 def children(self): 

1019 nodelist = [] 

1020 if self.type is not None: 

1021 nodelist.append(("type", self.type)) 

1022 return tuple(nodelist) 

1023 

1024 def __iter__(self): 

1025 if self.type is not None: 

1026 yield self.type 

1027 

1028 attr_names = ("quals",) 

1029 

1030 

1031class Return(Node): 

1032 __slots__ = ("expr", "coord", "__weakref__") 

1033 

1034 def __init__(self, expr, coord=None): 

1035 self.expr = expr 

1036 self.coord = coord 

1037 

1038 def children(self): 

1039 nodelist = [] 

1040 if self.expr is not None: 

1041 nodelist.append(("expr", self.expr)) 

1042 return tuple(nodelist) 

1043 

1044 def __iter__(self): 

1045 if self.expr is not None: 

1046 yield self.expr 

1047 

1048 attr_names = () 

1049 

1050 

1051class StaticAssert(Node): 

1052 __slots__ = ("cond", "message", "coord", "__weakref__") 

1053 

1054 def __init__(self, cond, message, coord=None): 

1055 self.cond = cond 

1056 self.message = message 

1057 self.coord = coord 

1058 

1059 def children(self): 

1060 nodelist = [] 

1061 if self.cond is not None: 

1062 nodelist.append(("cond", self.cond)) 

1063 if self.message is not None: 

1064 nodelist.append(("message", self.message)) 

1065 return tuple(nodelist) 

1066 

1067 def __iter__(self): 

1068 if self.cond is not None: 

1069 yield self.cond 

1070 if self.message is not None: 

1071 yield self.message 

1072 

1073 attr_names = () 

1074 

1075 

1076class Struct(Node): 

1077 __slots__ = ("name", "decls", "coord", "__weakref__") 

1078 

1079 def __init__(self, name, decls, coord=None): 

1080 self.name = name 

1081 self.decls = decls 

1082 self.coord = coord 

1083 

1084 def children(self): 

1085 nodelist = [] 

1086 for i, child in enumerate(self.decls or []): 

1087 nodelist.append((f"decls[{i}]", child)) 

1088 return tuple(nodelist) 

1089 

1090 def __iter__(self): 

1091 for child in self.decls or []: 

1092 yield child 

1093 

1094 attr_names = ("name",) 

1095 

1096 

1097class StructRef(Node): 

1098 __slots__ = ("name", "type", "field", "coord", "__weakref__") 

1099 

1100 def __init__(self, name, type, field, coord=None): 

1101 self.name = name 

1102 self.type = type 

1103 self.field = field 

1104 self.coord = coord 

1105 

1106 def children(self): 

1107 nodelist = [] 

1108 if self.name is not None: 

1109 nodelist.append(("name", self.name)) 

1110 if self.field is not None: 

1111 nodelist.append(("field", self.field)) 

1112 return tuple(nodelist) 

1113 

1114 def __iter__(self): 

1115 if self.name is not None: 

1116 yield self.name 

1117 if self.field is not None: 

1118 yield self.field 

1119 

1120 attr_names = ("type",) 

1121 

1122 

1123class Switch(Node): 

1124 __slots__ = ("cond", "stmt", "coord", "__weakref__") 

1125 

1126 def __init__(self, cond, stmt, coord=None): 

1127 self.cond = cond 

1128 self.stmt = stmt 

1129 self.coord = coord 

1130 

1131 def children(self): 

1132 nodelist = [] 

1133 if self.cond is not None: 

1134 nodelist.append(("cond", self.cond)) 

1135 if self.stmt is not None: 

1136 nodelist.append(("stmt", self.stmt)) 

1137 return tuple(nodelist) 

1138 

1139 def __iter__(self): 

1140 if self.cond is not None: 

1141 yield self.cond 

1142 if self.stmt is not None: 

1143 yield self.stmt 

1144 

1145 attr_names = () 

1146 

1147 

1148class TernaryOp(Node): 

1149 __slots__ = ("cond", "iftrue", "iffalse", "coord", "__weakref__") 

1150 

1151 def __init__(self, cond, iftrue, iffalse, coord=None): 

1152 self.cond = cond 

1153 self.iftrue = iftrue 

1154 self.iffalse = iffalse 

1155 self.coord = coord 

1156 

1157 def children(self): 

1158 nodelist = [] 

1159 if self.cond is not None: 

1160 nodelist.append(("cond", self.cond)) 

1161 if self.iftrue is not None: 

1162 nodelist.append(("iftrue", self.iftrue)) 

1163 if self.iffalse is not None: 

1164 nodelist.append(("iffalse", self.iffalse)) 

1165 return tuple(nodelist) 

1166 

1167 def __iter__(self): 

1168 if self.cond is not None: 

1169 yield self.cond 

1170 if self.iftrue is not None: 

1171 yield self.iftrue 

1172 if self.iffalse is not None: 

1173 yield self.iffalse 

1174 

1175 attr_names = () 

1176 

1177 

1178class TypeDecl(Node): 

1179 __slots__ = ("declname", "quals", "align", "type", "coord", "__weakref__") 

1180 

1181 def __init__(self, declname, quals, align, type, coord=None): 

1182 self.declname = declname 

1183 self.quals = quals 

1184 self.align = align 

1185 self.type = type 

1186 self.coord = coord 

1187 

1188 def children(self): 

1189 nodelist = [] 

1190 if self.type is not None: 

1191 nodelist.append(("type", self.type)) 

1192 return tuple(nodelist) 

1193 

1194 def __iter__(self): 

1195 if self.type is not None: 

1196 yield self.type 

1197 

1198 attr_names = ( 

1199 "declname", 

1200 "quals", 

1201 "align", 

1202 ) 

1203 

1204 

1205class Typedef(Node): 

1206 __slots__ = ("name", "quals", "storage", "type", "coord", "__weakref__") 

1207 

1208 def __init__(self, name, quals, storage, type, coord=None): 

1209 self.name = name 

1210 self.quals = quals 

1211 self.storage = storage 

1212 self.type = type 

1213 self.coord = coord 

1214 

1215 def children(self): 

1216 nodelist = [] 

1217 if self.type is not None: 

1218 nodelist.append(("type", self.type)) 

1219 return tuple(nodelist) 

1220 

1221 def __iter__(self): 

1222 if self.type is not None: 

1223 yield self.type 

1224 

1225 attr_names = ( 

1226 "name", 

1227 "quals", 

1228 "storage", 

1229 ) 

1230 

1231 

1232class Typename(Node): 

1233 __slots__ = ("name", "quals", "align", "type", "coord", "__weakref__") 

1234 

1235 def __init__(self, name, quals, align, type, coord=None): 

1236 self.name = name 

1237 self.quals = quals 

1238 self.align = align 

1239 self.type = type 

1240 self.coord = coord 

1241 

1242 def children(self): 

1243 nodelist = [] 

1244 if self.type is not None: 

1245 nodelist.append(("type", self.type)) 

1246 return tuple(nodelist) 

1247 

1248 def __iter__(self): 

1249 if self.type is not None: 

1250 yield self.type 

1251 

1252 attr_names = ( 

1253 "name", 

1254 "quals", 

1255 "align", 

1256 ) 

1257 

1258 

1259class UnaryOp(Node): 

1260 __slots__ = ("op", "expr", "coord", "__weakref__") 

1261 

1262 def __init__(self, op, expr, coord=None): 

1263 self.op = op 

1264 self.expr = expr 

1265 self.coord = coord 

1266 

1267 def children(self): 

1268 nodelist = [] 

1269 if self.expr is not None: 

1270 nodelist.append(("expr", self.expr)) 

1271 return tuple(nodelist) 

1272 

1273 def __iter__(self): 

1274 if self.expr is not None: 

1275 yield self.expr 

1276 

1277 attr_names = ("op",) 

1278 

1279 

1280class Union(Node): 

1281 __slots__ = ("name", "decls", "coord", "__weakref__") 

1282 

1283 def __init__(self, name, decls, coord=None): 

1284 self.name = name 

1285 self.decls = decls 

1286 self.coord = coord 

1287 

1288 def children(self): 

1289 nodelist = [] 

1290 for i, child in enumerate(self.decls or []): 

1291 nodelist.append((f"decls[{i}]", child)) 

1292 return tuple(nodelist) 

1293 

1294 def __iter__(self): 

1295 for child in self.decls or []: 

1296 yield child 

1297 

1298 attr_names = ("name",) 

1299 

1300 

1301class While(Node): 

1302 __slots__ = ("cond", "stmt", "coord", "__weakref__") 

1303 

1304 def __init__(self, cond, stmt, coord=None): 

1305 self.cond = cond 

1306 self.stmt = stmt 

1307 self.coord = coord 

1308 

1309 def children(self): 

1310 nodelist = [] 

1311 if self.cond is not None: 

1312 nodelist.append(("cond", self.cond)) 

1313 if self.stmt is not None: 

1314 nodelist.append(("stmt", self.stmt)) 

1315 return tuple(nodelist) 

1316 

1317 def __iter__(self): 

1318 if self.cond is not None: 

1319 yield self.cond 

1320 if self.stmt is not None: 

1321 yield self.stmt 

1322 

1323 attr_names = () 

1324 

1325 

1326class Pragma(Node): 

1327 __slots__ = ("string", "coord", "__weakref__") 

1328 

1329 def __init__(self, string, coord=None): 

1330 self.string = string 

1331 self.coord = coord 

1332 

1333 def children(self): 

1334 nodelist = [] 

1335 return tuple(nodelist) 

1336 

1337 def __iter__(self): 

1338 return 

1339 yield 

1340 

1341 attr_names = ("string",)