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

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

1078 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 'make regen-ast' from the repository root to regenerate and format it. 

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

8# 

9# The order of generated __slots__ is significant to Node.__repr__. 

10# ruff: noqa: RUF023 

11# 

12# pycparser: c_ast.py 

13# 

14# AST Node classes. 

15# 

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

17# License: BSD 

18# ----------------------------------------------------------------- 

19 

20 

21import sys 

22from typing import IO, Any, ClassVar 

23 

24 

25def _repr(obj): 

26 """ 

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

28 """ 

29 if isinstance(obj, list): 

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

31 else: 

32 return repr(obj) 

33 

34 

35class Node: 

36 __slots__ = () 

37 """ Abstract base class for AST nodes. 

38 """ 

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

40 coord: Any | None 

41 

42 def __repr__(self): 

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

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

45 

46 indent = "" 

47 separator = "" 

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

49 result += separator 

50 result += indent 

51 result += ( 

52 name 

53 + "=" 

54 + ( 

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

56 "\n", 

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

58 ) 

59 ) 

60 ) 

61 

62 separator = "," 

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

64 

65 result += indent + ")" 

66 

67 return result 

68 

69 def children(self): 

70 """Return a tuple of (name, child) pairs for immediate child nodes. 

71 

72 Names identify the field and, for list fields, the index, such as 

73 "type" or "ext[0]". Optional children that are None are omitted. 

74 The returned tuple supports len() and indexing. Iterating over the 

75 node itself yields just the child nodes, without their names. 

76 """ 

77 

78 def show( 

79 self, 

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

81 offset: int = 0, 

82 attrnames: bool = False, 

83 showemptyattrs: bool = True, 

84 nodenames: bool = False, 

85 showcoord: bool = False, 

86 _my_node_name: str | None = None, 

87 ): 

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

89 children (recursively) to a buffer. 

90 

91 buf: 

92 Open IO buffer into which the Node is printed. 

93 

94 offset: 

95 Initial offset (amount of leading spaces) 

96 

97 attrnames: 

98 True if you want to see the attribute names in 

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

100 

101 showemptyattrs: 

102 False if you want to suppress printing empty attributes. 

103 

104 nodenames: 

105 True if you want to see the actual node names 

106 within their parents. 

107 

108 showcoord: 

109 Do you want the coordinates of each Node to be 

110 displayed. 

111 """ 

112 lead = " " * offset 

113 if nodenames and _my_node_name is not None: 

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

115 else: 

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

117 

118 if self.attr_names: 

119 

120 def is_empty(v): 

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

122 

123 nvlist = [ 

124 (n, getattr(self, n)) 

125 for n in self.attr_names 

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

127 ] 

128 if attrnames: 

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

130 else: 

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

132 buf.write(attrstr) 

133 

134 if showcoord: 

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

136 buf.write("\n") 

137 

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

139 child.show( 

140 buf, 

141 offset=offset + 2, 

142 attrnames=attrnames, 

143 showemptyattrs=showemptyattrs, 

144 nodenames=nodenames, 

145 showcoord=showcoord, 

146 _my_node_name=child_name, 

147 ) 

148 

149 

150class NodeVisitor: 

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

152 Subclass it and define your own visit_XXX methods, where 

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

154 methods. 

155 

156 For example: 

157 

158 class ConstantVisitor(NodeVisitor): 

159 def __init__(self): 

160 self.values = [] 

161 

162 def visit_Constant(self, node): 

163 self.values.append(node.value) 

164 

165 Creates a list of values of all the constant nodes 

166 encountered below the given node. To use it: 

167 

168 cv = ConstantVisitor() 

169 cv.visit(node) 

170 

171 Notes: 

172 

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

174 no visit_XXX method was defined. 

175 * The children of nodes for which a visit_XXX was 

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

177 generic_visit() on the node. 

178 You can use: 

179 NodeVisitor.generic_visit(self, node) 

180 * Modeled after Python's own AST visiting facilities 

181 (the ast module of Python 3.0) 

182 """ 

183 

184 _method_cache = None 

185 

186 def visit(self, node: Node): 

187 """Visit a node.""" 

188 

189 if self._method_cache is None: 

190 self._method_cache = {} 

191 

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

193 if visitor is None: 

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

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

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

197 

198 return visitor(node) 

199 

200 def generic_visit(self, node: Node): 

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

202 node. Implements preorder visiting of the node. 

203 """ 

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

205 self.visit(c) 

206 

207 

208class ArrayDecl(Node): 

209 __slots__ = ("type", "dim", "dim_quals", "attributes", "coord", "__weakref__") 

210 

211 def __init__(self, type, dim, dim_quals, coord=None, *, attributes=None): 

212 self.type = type 

213 self.dim = dim 

214 self.dim_quals = dim_quals 

215 self.attributes = [] if attributes is None else attributes 

216 self.coord = coord 

217 

218 def children(self): 

219 nodelist = [] 

220 if self.type is not None: 

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

222 if self.dim is not None: 

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

224 for i, child in enumerate(self.attributes or []): 

225 nodelist.append((f"attributes[{i}]", child)) 

226 return tuple(nodelist) 

227 

228 def __iter__(self): 

229 if self.type is not None: 

230 yield self.type 

231 if self.dim is not None: 

232 yield self.dim 

233 yield from self.attributes or [] 

234 

235 attr_names = ("dim_quals",) 

236 

237 

238class ArrayDesignator(Node): 

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

240 

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

242 self.expr = expr 

243 self.coord = coord 

244 

245 def children(self): 

246 nodelist = [] 

247 if self.expr is not None: 

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

249 return tuple(nodelist) 

250 

251 def __iter__(self): 

252 if self.expr is not None: 

253 yield self.expr 

254 

255 attr_names = () 

256 

257 

258class ArrayRef(Node): 

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

260 

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

262 self.name = name 

263 self.subscript = subscript 

264 self.coord = coord 

265 

266 def children(self): 

267 nodelist = [] 

268 if self.name is not None: 

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

270 if self.subscript is not None: 

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

272 return tuple(nodelist) 

273 

274 def __iter__(self): 

275 if self.name is not None: 

276 yield self.name 

277 if self.subscript is not None: 

278 yield self.subscript 

279 

280 attr_names = () 

281 

282 

283class Assignment(Node): 

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

285 

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

287 self.op = op 

288 self.lvalue = lvalue 

289 self.rvalue = rvalue 

290 self.coord = coord 

291 

292 def children(self): 

293 nodelist = [] 

294 if self.lvalue is not None: 

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

296 if self.rvalue is not None: 

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

298 return tuple(nodelist) 

299 

300 def __iter__(self): 

301 if self.lvalue is not None: 

302 yield self.lvalue 

303 if self.rvalue is not None: 

304 yield self.rvalue 

305 

306 attr_names = ("op",) 

307 

308 

309class Alignas(Node): 

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

311 

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

313 self.alignment = alignment 

314 self.coord = coord 

315 

316 def children(self): 

317 nodelist = [] 

318 if self.alignment is not None: 

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

320 return tuple(nodelist) 

321 

322 def __iter__(self): 

323 if self.alignment is not None: 

324 yield self.alignment 

325 

326 attr_names = () 

327 

328 

329class Attribute(Node): 

330 __slots__ = ("name", "namespace", "arguments", "coord", "__weakref__") 

331 

332 def __init__(self, name, namespace, arguments, coord=None): 

333 self.name = name 

334 self.namespace = namespace 

335 self.arguments = arguments 

336 self.coord = coord 

337 

338 def children(self): 

339 nodelist = [] 

340 return tuple(nodelist) 

341 

342 def __iter__(self): 

343 return 

344 yield 

345 

346 attr_names = ( 

347 "name", 

348 "namespace", 

349 "arguments", 

350 ) 

351 

352 

353class AttributeSpecifier(Node): 

354 __slots__ = ("attributes", "coord", "__weakref__") 

355 

356 def __init__(self, attributes, coord=None): 

357 self.attributes = attributes 

358 self.coord = coord 

359 

360 def children(self): 

361 nodelist = [] 

362 for i, child in enumerate(self.attributes or []): 

363 nodelist.append((f"attributes[{i}]", child)) 

364 return tuple(nodelist) 

365 

366 def __iter__(self): 

367 yield from self.attributes or [] 

368 

369 attr_names = () 

370 

371 

372class AttributeDeclaration(Node): 

373 __slots__ = ("attributes", "coord", "__weakref__") 

374 

375 def __init__(self, attributes, coord=None): 

376 self.attributes = attributes 

377 self.coord = coord 

378 

379 def children(self): 

380 nodelist = [] 

381 for i, child in enumerate(self.attributes or []): 

382 nodelist.append((f"attributes[{i}]", child)) 

383 return tuple(nodelist) 

384 

385 def __iter__(self): 

386 yield from self.attributes or [] 

387 

388 attr_names = () 

389 

390 

391class AttributedStatement(Node): 

392 __slots__ = ("attributes", "stmt", "coord", "__weakref__") 

393 

394 def __init__(self, attributes, stmt, coord=None): 

395 self.attributes = attributes 

396 self.stmt = stmt 

397 self.coord = coord 

398 

399 def children(self): 

400 nodelist = [] 

401 if self.stmt is not None: 

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

403 for i, child in enumerate(self.attributes or []): 

404 nodelist.append((f"attributes[{i}]", child)) 

405 return tuple(nodelist) 

406 

407 def __iter__(self): 

408 if self.stmt is not None: 

409 yield self.stmt 

410 yield from self.attributes or [] 

411 

412 attr_names = () 

413 

414 

415class AttributedType(Node): 

416 __slots__ = ("type", "attributes", "coord", "__weakref__") 

417 

418 def __init__(self, type, attributes, coord=None): 

419 self.type = type 

420 self.attributes = attributes 

421 self.coord = coord 

422 

423 def children(self): 

424 nodelist = [] 

425 if self.type is not None: 

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

427 for i, child in enumerate(self.attributes or []): 

428 nodelist.append((f"attributes[{i}]", child)) 

429 return tuple(nodelist) 

430 

431 def __iter__(self): 

432 if self.type is not None: 

433 yield self.type 

434 yield from self.attributes or [] 

435 

436 attr_names = () 

437 

438 

439class BinaryOp(Node): 

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

441 

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

443 self.op = op 

444 self.left = left 

445 self.right = right 

446 self.coord = coord 

447 

448 def children(self): 

449 nodelist = [] 

450 if self.left is not None: 

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

452 if self.right is not None: 

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

454 return tuple(nodelist) 

455 

456 def __iter__(self): 

457 if self.left is not None: 

458 yield self.left 

459 if self.right is not None: 

460 yield self.right 

461 

462 attr_names = ("op",) 

463 

464 

465class BitIntType(Node): 

466 __slots__ = ("width", "signedness", "coord", "__weakref__") 

467 

468 def __init__(self, width, signedness, coord=None): 

469 self.width = width 

470 self.signedness = signedness 

471 self.coord = coord 

472 

473 def children(self): 

474 nodelist = [] 

475 if self.width is not None: 

476 nodelist.append(("width", self.width)) 

477 return tuple(nodelist) 

478 

479 def __iter__(self): 

480 if self.width is not None: 

481 yield self.width 

482 

483 attr_names = ("signedness",) 

484 

485 

486class Break(Node): 

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

488 

489 def __init__(self, coord=None): 

490 self.coord = coord 

491 

492 def children(self): 

493 return () 

494 

495 def __iter__(self): 

496 return 

497 yield 

498 

499 attr_names = () 

500 

501 

502class Case(Node): 

503 __slots__ = ("expr", "stmts", "attributes", "coord", "__weakref__") 

504 

505 def __init__(self, expr, stmts, coord=None, *, attributes=None): 

506 self.expr = expr 

507 self.stmts = stmts 

508 self.attributes = [] if attributes is None else attributes 

509 self.coord = coord 

510 

511 def children(self): 

512 nodelist = [] 

513 if self.expr is not None: 

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

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

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

517 for i, child in enumerate(self.attributes or []): 

518 nodelist.append((f"attributes[{i}]", child)) 

519 return tuple(nodelist) 

520 

521 def __iter__(self): 

522 if self.expr is not None: 

523 yield self.expr 

524 yield from self.stmts or [] 

525 yield from self.attributes or [] 

526 

527 attr_names = () 

528 

529 

530class Cast(Node): 

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

532 

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

534 self.to_type = to_type 

535 self.expr = expr 

536 self.coord = coord 

537 

538 def children(self): 

539 nodelist = [] 

540 if self.to_type is not None: 

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

542 if self.expr is not None: 

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

544 return tuple(nodelist) 

545 

546 def __iter__(self): 

547 if self.to_type is not None: 

548 yield self.to_type 

549 if self.expr is not None: 

550 yield self.expr 

551 

552 attr_names = () 

553 

554 

555class Compound(Node): 

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

557 

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

559 self.block_items = block_items 

560 self.coord = coord 

561 

562 def children(self): 

563 nodelist = [] 

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

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

566 return tuple(nodelist) 

567 

568 def __iter__(self): 

569 yield from self.block_items or [] 

570 

571 attr_names = () 

572 

573 

574class CompoundLiteral(Node): 

575 __slots__ = ("type", "init", "storage", "coord", "__weakref__") 

576 

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

578 self.type = type 

579 self.init = init 

580 self.storage = storage 

581 self.coord = coord 

582 

583 def children(self): 

584 nodelist = [] 

585 if self.type is not None: 

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

587 if self.init is not None: 

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

589 return tuple(nodelist) 

590 

591 def __iter__(self): 

592 if self.type is not None: 

593 yield self.type 

594 if self.init is not None: 

595 yield self.init 

596 

597 attr_names = ("storage",) 

598 

599 

600class Constant(Node): 

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

602 

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

604 self.type = type 

605 self.value = value 

606 self.coord = coord 

607 

608 def children(self): 

609 nodelist = [] 

610 return tuple(nodelist) 

611 

612 def __iter__(self): 

613 return 

614 yield 

615 

616 attr_names = ( 

617 "type", 

618 "value", 

619 ) 

620 

621 

622class Continue(Node): 

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

624 

625 def __init__(self, coord=None): 

626 self.coord = coord 

627 

628 def children(self): 

629 return () 

630 

631 def __iter__(self): 

632 return 

633 yield 

634 

635 attr_names = () 

636 

637 

638class Decl(Node): 

639 __slots__ = ( 

640 "name", 

641 "quals", 

642 "align", 

643 "storage", 

644 "funcspec", 

645 "type", 

646 "init", 

647 "bitsize", 

648 "attributes", 

649 "coord", 

650 "__weakref__", 

651 ) 

652 

653 def __init__( 

654 self, 

655 name, 

656 quals, 

657 align, 

658 storage, 

659 funcspec, 

660 type, 

661 init, 

662 bitsize, 

663 coord=None, 

664 *, 

665 attributes=None, 

666 ): 

667 self.name = name 

668 self.quals = quals 

669 self.align = align 

670 self.storage = storage 

671 self.funcspec = funcspec 

672 self.type = type 

673 self.init = init 

674 self.bitsize = bitsize 

675 self.attributes = [] if attributes is None else attributes 

676 self.coord = coord 

677 

678 def children(self): 

679 nodelist = [] 

680 if self.type is not None: 

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

682 if self.init is not None: 

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

684 if self.bitsize is not None: 

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

686 for i, child in enumerate(self.attributes or []): 

687 nodelist.append((f"attributes[{i}]", child)) 

688 return tuple(nodelist) 

689 

690 def __iter__(self): 

691 if self.type is not None: 

692 yield self.type 

693 if self.init is not None: 

694 yield self.init 

695 if self.bitsize is not None: 

696 yield self.bitsize 

697 yield from self.attributes or [] 

698 

699 attr_names = ( 

700 "name", 

701 "quals", 

702 "align", 

703 "storage", 

704 "funcspec", 

705 ) 

706 

707 

708class DeclList(Node): 

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

710 

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

712 self.decls = decls 

713 self.coord = coord 

714 

715 def children(self): 

716 nodelist = [] 

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

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

719 return tuple(nodelist) 

720 

721 def __iter__(self): 

722 yield from self.decls or [] 

723 

724 attr_names = () 

725 

726 

727class Default(Node): 

728 __slots__ = ("stmts", "attributes", "coord", "__weakref__") 

729 

730 def __init__(self, stmts, coord=None, *, attributes=None): 

731 self.stmts = stmts 

732 self.attributes = [] if attributes is None else attributes 

733 self.coord = coord 

734 

735 def children(self): 

736 nodelist = [] 

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

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

739 for i, child in enumerate(self.attributes or []): 

740 nodelist.append((f"attributes[{i}]", child)) 

741 return tuple(nodelist) 

742 

743 def __iter__(self): 

744 yield from self.stmts or [] 

745 yield from self.attributes or [] 

746 

747 attr_names = () 

748 

749 

750class DoWhile(Node): 

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

752 

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

754 self.cond = cond 

755 self.stmt = stmt 

756 self.coord = coord 

757 

758 def children(self): 

759 nodelist = [] 

760 if self.cond is not None: 

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

762 if self.stmt is not None: 

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

764 return tuple(nodelist) 

765 

766 def __iter__(self): 

767 if self.cond is not None: 

768 yield self.cond 

769 if self.stmt is not None: 

770 yield self.stmt 

771 

772 attr_names = () 

773 

774 

775class EllipsisParam(Node): 

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

777 

778 def __init__(self, coord=None): 

779 self.coord = coord 

780 

781 def children(self): 

782 return () 

783 

784 def __iter__(self): 

785 return 

786 yield 

787 

788 attr_names = () 

789 

790 

791class EmptyStatement(Node): 

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

793 

794 def __init__(self, coord=None): 

795 self.coord = coord 

796 

797 def children(self): 

798 return () 

799 

800 def __iter__(self): 

801 return 

802 yield 

803 

804 attr_names = () 

805 

806 

807class Enum(Node): 

808 __slots__ = ( 

809 "name", 

810 "values", 

811 "underlying_type", 

812 "attributes", 

813 "coord", 

814 "__weakref__", 

815 ) 

816 

817 def __init__(self, name, values, underlying_type, coord=None, *, attributes=None): 

818 self.name = name 

819 self.values = values 

820 self.underlying_type = underlying_type 

821 self.attributes = [] if attributes is None else attributes 

822 self.coord = coord 

823 

824 def children(self): 

825 nodelist = [] 

826 if self.values is not None: 

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

828 if self.underlying_type is not None: 

829 nodelist.append(("underlying_type", self.underlying_type)) 

830 for i, child in enumerate(self.attributes or []): 

831 nodelist.append((f"attributes[{i}]", child)) 

832 return tuple(nodelist) 

833 

834 def __iter__(self): 

835 if self.values is not None: 

836 yield self.values 

837 if self.underlying_type is not None: 

838 yield self.underlying_type 

839 yield from self.attributes or [] 

840 

841 attr_names = ("name",) 

842 

843 

844class Enumerator(Node): 

845 __slots__ = ("name", "value", "attributes", "coord", "__weakref__") 

846 

847 def __init__(self, name, value, coord=None, *, attributes=None): 

848 self.name = name 

849 self.value = value 

850 self.attributes = [] if attributes is None else attributes 

851 self.coord = coord 

852 

853 def children(self): 

854 nodelist = [] 

855 if self.value is not None: 

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

857 for i, child in enumerate(self.attributes or []): 

858 nodelist.append((f"attributes[{i}]", child)) 

859 return tuple(nodelist) 

860 

861 def __iter__(self): 

862 if self.value is not None: 

863 yield self.value 

864 yield from self.attributes or [] 

865 

866 attr_names = ("name",) 

867 

868 

869class EnumeratorList(Node): 

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

871 

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

873 self.enumerators = enumerators 

874 self.coord = coord 

875 

876 def children(self): 

877 nodelist = [] 

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

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

880 return tuple(nodelist) 

881 

882 def __iter__(self): 

883 yield from self.enumerators or [] 

884 

885 attr_names = () 

886 

887 

888class ExprList(Node): 

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

890 

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

892 self.exprs = exprs 

893 self.coord = coord 

894 

895 def children(self): 

896 nodelist = [] 

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

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

899 return tuple(nodelist) 

900 

901 def __iter__(self): 

902 yield from self.exprs or [] 

903 

904 attr_names = () 

905 

906 

907class FileAST(Node): 

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

909 

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

911 self.ext = ext 

912 self.coord = coord 

913 

914 def children(self): 

915 nodelist = [] 

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

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

918 return tuple(nodelist) 

919 

920 def __iter__(self): 

921 yield from self.ext or [] 

922 

923 attr_names = () 

924 

925 

926class For(Node): 

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

928 

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

930 self.init = init 

931 self.cond = cond 

932 self.next = next 

933 self.stmt = stmt 

934 self.coord = coord 

935 

936 def children(self): 

937 nodelist = [] 

938 if self.init is not None: 

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

940 if self.cond is not None: 

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

942 if self.next is not None: 

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

944 if self.stmt is not None: 

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

946 return tuple(nodelist) 

947 

948 def __iter__(self): 

949 if self.init is not None: 

950 yield self.init 

951 if self.cond is not None: 

952 yield self.cond 

953 if self.next is not None: 

954 yield self.next 

955 if self.stmt is not None: 

956 yield self.stmt 

957 

958 attr_names = () 

959 

960 

961class FuncCall(Node): 

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

963 

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

965 self.name = name 

966 self.args = args 

967 self.coord = coord 

968 

969 def children(self): 

970 nodelist = [] 

971 if self.name is not None: 

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

973 if self.args is not None: 

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

975 return tuple(nodelist) 

976 

977 def __iter__(self): 

978 if self.name is not None: 

979 yield self.name 

980 if self.args is not None: 

981 yield self.args 

982 

983 attr_names = () 

984 

985 

986class FuncDecl(Node): 

987 __slots__ = ("args", "type", "attributes", "coord", "__weakref__") 

988 

989 def __init__(self, args, type, coord=None, *, attributes=None): 

990 self.args = args 

991 self.type = type 

992 self.attributes = [] if attributes is None else attributes 

993 self.coord = coord 

994 

995 def children(self): 

996 nodelist = [] 

997 if self.args is not None: 

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

999 if self.type is not None: 

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

1001 for i, child in enumerate(self.attributes or []): 

1002 nodelist.append((f"attributes[{i}]", child)) 

1003 return tuple(nodelist) 

1004 

1005 def __iter__(self): 

1006 if self.args is not None: 

1007 yield self.args 

1008 if self.type is not None: 

1009 yield self.type 

1010 yield from self.attributes or [] 

1011 

1012 attr_names = () 

1013 

1014 

1015class FuncDef(Node): 

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

1017 

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

1019 self.decl = decl 

1020 self.param_decls = param_decls 

1021 self.body = body 

1022 self.coord = coord 

1023 

1024 def children(self): 

1025 nodelist = [] 

1026 if self.decl is not None: 

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

1028 if self.body is not None: 

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

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

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

1032 return tuple(nodelist) 

1033 

1034 def __iter__(self): 

1035 if self.decl is not None: 

1036 yield self.decl 

1037 if self.body is not None: 

1038 yield self.body 

1039 yield from self.param_decls or [] 

1040 

1041 attr_names = () 

1042 

1043 

1044class GenericAssociation(Node): 

1045 __slots__ = ("type", "expr", "coord", "__weakref__") 

1046 

1047 def __init__(self, type, expr, coord=None): 

1048 self.type = type 

1049 self.expr = expr 

1050 self.coord = coord 

1051 

1052 def children(self): 

1053 nodelist = [] 

1054 if self.type is not None: 

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

1056 if self.expr is not None: 

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

1058 return tuple(nodelist) 

1059 

1060 def __iter__(self): 

1061 if self.type is not None: 

1062 yield self.type 

1063 if self.expr is not None: 

1064 yield self.expr 

1065 

1066 attr_names = () 

1067 

1068 

1069class GenericSelection(Node): 

1070 __slots__ = ("expr", "associations", "coord", "__weakref__") 

1071 

1072 def __init__(self, expr, associations, coord=None): 

1073 self.expr = expr 

1074 self.associations = associations 

1075 self.coord = coord 

1076 

1077 def children(self): 

1078 nodelist = [] 

1079 if self.expr is not None: 

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

1081 for i, child in enumerate(self.associations or []): 

1082 nodelist.append((f"associations[{i}]", child)) 

1083 return tuple(nodelist) 

1084 

1085 def __iter__(self): 

1086 if self.expr is not None: 

1087 yield self.expr 

1088 yield from self.associations or [] 

1089 

1090 attr_names = () 

1091 

1092 

1093class Goto(Node): 

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

1095 

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

1097 self.name = name 

1098 self.coord = coord 

1099 

1100 def children(self): 

1101 nodelist = [] 

1102 return tuple(nodelist) 

1103 

1104 def __iter__(self): 

1105 return 

1106 yield 

1107 

1108 attr_names = ("name",) 

1109 

1110 

1111class ID(Node): 

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

1113 

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

1115 self.name = name 

1116 self.coord = coord 

1117 

1118 def children(self): 

1119 nodelist = [] 

1120 return tuple(nodelist) 

1121 

1122 def __iter__(self): 

1123 return 

1124 yield 

1125 

1126 attr_names = ("name",) 

1127 

1128 

1129class IdentifierType(Node): 

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

1131 

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

1133 self.names = names 

1134 self.coord = coord 

1135 

1136 def children(self): 

1137 nodelist = [] 

1138 return tuple(nodelist) 

1139 

1140 def __iter__(self): 

1141 return 

1142 yield 

1143 

1144 attr_names = ("names",) 

1145 

1146 

1147class If(Node): 

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

1149 

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

1151 self.cond = cond 

1152 self.iftrue = iftrue 

1153 self.iffalse = iffalse 

1154 self.coord = coord 

1155 

1156 def children(self): 

1157 nodelist = [] 

1158 if self.cond is not None: 

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

1160 if self.iftrue is not None: 

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

1162 if self.iffalse is not None: 

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

1164 return tuple(nodelist) 

1165 

1166 def __iter__(self): 

1167 if self.cond is not None: 

1168 yield self.cond 

1169 if self.iftrue is not None: 

1170 yield self.iftrue 

1171 if self.iffalse is not None: 

1172 yield self.iffalse 

1173 

1174 attr_names = () 

1175 

1176 

1177class InferredType(Node): 

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

1179 

1180 def __init__(self, coord=None): 

1181 self.coord = coord 

1182 

1183 def children(self): 

1184 return () 

1185 

1186 def __iter__(self): 

1187 return 

1188 yield 

1189 

1190 attr_names = () 

1191 

1192 

1193class InitList(Node): 

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

1195 

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

1197 self.exprs = exprs 

1198 self.coord = coord 

1199 

1200 def children(self): 

1201 nodelist = [] 

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

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

1204 return tuple(nodelist) 

1205 

1206 def __iter__(self): 

1207 yield from self.exprs or [] 

1208 

1209 attr_names = () 

1210 

1211 

1212class Label(Node): 

1213 __slots__ = ("name", "stmt", "attributes", "coord", "__weakref__") 

1214 

1215 def __init__(self, name, stmt, coord=None, *, attributes=None): 

1216 self.name = name 

1217 self.stmt = stmt 

1218 self.attributes = [] if attributes is None else attributes 

1219 self.coord = coord 

1220 

1221 def children(self): 

1222 nodelist = [] 

1223 if self.stmt is not None: 

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

1225 for i, child in enumerate(self.attributes or []): 

1226 nodelist.append((f"attributes[{i}]", child)) 

1227 return tuple(nodelist) 

1228 

1229 def __iter__(self): 

1230 if self.stmt is not None: 

1231 yield self.stmt 

1232 yield from self.attributes or [] 

1233 

1234 attr_names = ("name",) 

1235 

1236 

1237class NamedInitializer(Node): 

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

1239 

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

1241 self.name = name 

1242 self.expr = expr 

1243 self.coord = coord 

1244 

1245 def children(self): 

1246 nodelist = [] 

1247 if self.expr is not None: 

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

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

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

1251 return tuple(nodelist) 

1252 

1253 def __iter__(self): 

1254 if self.expr is not None: 

1255 yield self.expr 

1256 yield from self.name or [] 

1257 

1258 attr_names = () 

1259 

1260 

1261class ParamList(Node): 

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

1263 

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

1265 self.params = params 

1266 self.coord = coord 

1267 

1268 def children(self): 

1269 nodelist = [] 

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

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

1272 return tuple(nodelist) 

1273 

1274 def __iter__(self): 

1275 yield from self.params or [] 

1276 

1277 attr_names = () 

1278 

1279 

1280class PtrDecl(Node): 

1281 __slots__ = ("quals", "type", "attributes", "coord", "__weakref__") 

1282 

1283 def __init__(self, quals, type, coord=None, *, attributes=None): 

1284 self.quals = quals 

1285 self.type = type 

1286 self.attributes = [] if attributes is None else attributes 

1287 self.coord = coord 

1288 

1289 def children(self): 

1290 nodelist = [] 

1291 if self.type is not None: 

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

1293 for i, child in enumerate(self.attributes or []): 

1294 nodelist.append((f"attributes[{i}]", child)) 

1295 return tuple(nodelist) 

1296 

1297 def __iter__(self): 

1298 if self.type is not None: 

1299 yield self.type 

1300 yield from self.attributes or [] 

1301 

1302 attr_names = ("quals",) 

1303 

1304 

1305class Return(Node): 

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

1307 

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

1309 self.expr = expr 

1310 self.coord = coord 

1311 

1312 def children(self): 

1313 nodelist = [] 

1314 if self.expr is not None: 

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

1316 return tuple(nodelist) 

1317 

1318 def __iter__(self): 

1319 if self.expr is not None: 

1320 yield self.expr 

1321 

1322 attr_names = () 

1323 

1324 

1325class StaticAssert(Node): 

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

1327 

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

1329 self.cond = cond 

1330 self.message = message 

1331 self.coord = coord 

1332 

1333 def children(self): 

1334 nodelist = [] 

1335 if self.cond is not None: 

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

1337 if self.message is not None: 

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

1339 return tuple(nodelist) 

1340 

1341 def __iter__(self): 

1342 if self.cond is not None: 

1343 yield self.cond 

1344 if self.message is not None: 

1345 yield self.message 

1346 

1347 attr_names = () 

1348 

1349 

1350class Struct(Node): 

1351 __slots__ = ("name", "decls", "attributes", "coord", "__weakref__") 

1352 

1353 def __init__(self, name, decls, coord=None, *, attributes=None): 

1354 self.name = name 

1355 self.decls = decls 

1356 self.attributes = [] if attributes is None else attributes 

1357 self.coord = coord 

1358 

1359 def children(self): 

1360 nodelist = [] 

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

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

1363 for i, child in enumerate(self.attributes or []): 

1364 nodelist.append((f"attributes[{i}]", child)) 

1365 return tuple(nodelist) 

1366 

1367 def __iter__(self): 

1368 yield from self.decls or [] 

1369 yield from self.attributes or [] 

1370 

1371 attr_names = ("name",) 

1372 

1373 

1374class StructRef(Node): 

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

1376 

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

1378 self.name = name 

1379 self.type = type 

1380 self.field = field 

1381 self.coord = coord 

1382 

1383 def children(self): 

1384 nodelist = [] 

1385 if self.name is not None: 

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

1387 if self.field is not None: 

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

1389 return tuple(nodelist) 

1390 

1391 def __iter__(self): 

1392 if self.name is not None: 

1393 yield self.name 

1394 if self.field is not None: 

1395 yield self.field 

1396 

1397 attr_names = ("type",) 

1398 

1399 

1400class Switch(Node): 

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

1402 

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

1404 self.cond = cond 

1405 self.stmt = stmt 

1406 self.coord = coord 

1407 

1408 def children(self): 

1409 nodelist = [] 

1410 if self.cond is not None: 

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

1412 if self.stmt is not None: 

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

1414 return tuple(nodelist) 

1415 

1416 def __iter__(self): 

1417 if self.cond is not None: 

1418 yield self.cond 

1419 if self.stmt is not None: 

1420 yield self.stmt 

1421 

1422 attr_names = () 

1423 

1424 

1425class TernaryOp(Node): 

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

1427 

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

1429 self.cond = cond 

1430 self.iftrue = iftrue 

1431 self.iffalse = iffalse 

1432 self.coord = coord 

1433 

1434 def children(self): 

1435 nodelist = [] 

1436 if self.cond is not None: 

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

1438 if self.iftrue is not None: 

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

1440 if self.iffalse is not None: 

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

1442 return tuple(nodelist) 

1443 

1444 def __iter__(self): 

1445 if self.cond is not None: 

1446 yield self.cond 

1447 if self.iftrue is not None: 

1448 yield self.iftrue 

1449 if self.iffalse is not None: 

1450 yield self.iffalse 

1451 

1452 attr_names = () 

1453 

1454 

1455class TypeDecl(Node): 

1456 __slots__ = ( 

1457 "declname", 

1458 "quals", 

1459 "align", 

1460 "type", 

1461 "attributes", 

1462 "coord", 

1463 "__weakref__", 

1464 ) 

1465 

1466 def __init__(self, declname, quals, align, type, coord=None, *, attributes=None): 

1467 self.declname = declname 

1468 self.quals = quals 

1469 self.align = align 

1470 self.type = type 

1471 self.attributes = [] if attributes is None else attributes 

1472 self.coord = coord 

1473 

1474 def children(self): 

1475 nodelist = [] 

1476 if self.type is not None: 

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

1478 for i, child in enumerate(self.attributes or []): 

1479 nodelist.append((f"attributes[{i}]", child)) 

1480 return tuple(nodelist) 

1481 

1482 def __iter__(self): 

1483 if self.type is not None: 

1484 yield self.type 

1485 yield from self.attributes or [] 

1486 

1487 attr_names = ( 

1488 "declname", 

1489 "quals", 

1490 "align", 

1491 ) 

1492 

1493 

1494class Typedef(Node): 

1495 __slots__ = ( 

1496 "name", 

1497 "quals", 

1498 "storage", 

1499 "type", 

1500 "attributes", 

1501 "coord", 

1502 "__weakref__", 

1503 ) 

1504 

1505 def __init__(self, name, quals, storage, type, coord=None, *, attributes=None): 

1506 self.name = name 

1507 self.quals = quals 

1508 self.storage = storage 

1509 self.type = type 

1510 self.attributes = [] if attributes is None else attributes 

1511 self.coord = coord 

1512 

1513 def children(self): 

1514 nodelist = [] 

1515 if self.type is not None: 

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

1517 for i, child in enumerate(self.attributes or []): 

1518 nodelist.append((f"attributes[{i}]", child)) 

1519 return tuple(nodelist) 

1520 

1521 def __iter__(self): 

1522 if self.type is not None: 

1523 yield self.type 

1524 yield from self.attributes or [] 

1525 

1526 attr_names = ( 

1527 "name", 

1528 "quals", 

1529 "storage", 

1530 ) 

1531 

1532 

1533class Typename(Node): 

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

1535 

1536 def __init__(self, name, quals, align, type, coord=None, *, attributes=None): 

1537 self.name = name 

1538 self.quals = quals 

1539 self.align = align 

1540 self.type = type 

1541 self.attributes = [] if attributes is None else attributes 

1542 self.coord = coord 

1543 

1544 def children(self): 

1545 nodelist = [] 

1546 if self.type is not None: 

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

1548 for i, child in enumerate(self.attributes or []): 

1549 nodelist.append((f"attributes[{i}]", child)) 

1550 return tuple(nodelist) 

1551 

1552 def __iter__(self): 

1553 if self.type is not None: 

1554 yield self.type 

1555 yield from self.attributes or [] 

1556 

1557 attr_names = ( 

1558 "name", 

1559 "quals", 

1560 "align", 

1561 ) 

1562 

1563 

1564class TypeOf(Node): 

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

1566 

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

1568 self.op = op 

1569 self.expr = expr 

1570 self.coord = coord 

1571 

1572 def children(self): 

1573 nodelist = [] 

1574 if self.expr is not None: 

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

1576 return tuple(nodelist) 

1577 

1578 def __iter__(self): 

1579 if self.expr is not None: 

1580 yield self.expr 

1581 

1582 attr_names = ("op",) 

1583 

1584 

1585class UnaryOp(Node): 

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

1587 

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

1589 self.op = op 

1590 self.expr = expr 

1591 self.coord = coord 

1592 

1593 def children(self): 

1594 nodelist = [] 

1595 if self.expr is not None: 

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

1597 return tuple(nodelist) 

1598 

1599 def __iter__(self): 

1600 if self.expr is not None: 

1601 yield self.expr 

1602 

1603 attr_names = ("op",) 

1604 

1605 

1606class Union(Node): 

1607 __slots__ = ("name", "decls", "attributes", "coord", "__weakref__") 

1608 

1609 def __init__(self, name, decls, coord=None, *, attributes=None): 

1610 self.name = name 

1611 self.decls = decls 

1612 self.attributes = [] if attributes is None else attributes 

1613 self.coord = coord 

1614 

1615 def children(self): 

1616 nodelist = [] 

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

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

1619 for i, child in enumerate(self.attributes or []): 

1620 nodelist.append((f"attributes[{i}]", child)) 

1621 return tuple(nodelist) 

1622 

1623 def __iter__(self): 

1624 yield from self.decls or [] 

1625 yield from self.attributes or [] 

1626 

1627 attr_names = ("name",) 

1628 

1629 

1630class While(Node): 

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

1632 

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

1634 self.cond = cond 

1635 self.stmt = stmt 

1636 self.coord = coord 

1637 

1638 def children(self): 

1639 nodelist = [] 

1640 if self.cond is not None: 

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

1642 if self.stmt is not None: 

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

1644 return tuple(nodelist) 

1645 

1646 def __iter__(self): 

1647 if self.cond is not None: 

1648 yield self.cond 

1649 if self.stmt is not None: 

1650 yield self.stmt 

1651 

1652 attr_names = () 

1653 

1654 

1655class Pragma(Node): 

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

1657 

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

1659 self.string = string 

1660 self.coord = coord 

1661 

1662 def children(self): 

1663 nodelist = [] 

1664 return tuple(nodelist) 

1665 

1666 def __iter__(self): 

1667 return 

1668 yield 

1669 

1670 attr_names = ("string",)