_c_ast.cfg 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. #-----------------------------------------------------------------
  2. # pycparser: _c_ast.cfg
  3. #
  4. # Defines the AST Node classes used in pycparser.
  5. # After editing, run 'make regen-ast' from the repository root to
  6. # regenerate pycparser/c_ast.py and format the code.
  7. #
  8. # Each entry is a Node sub-class name, listing the attributes
  9. # and child nodes of the class:
  10. # <name>* - a child node
  11. # <name>** - a sequence of child nodes
  12. # <name> - an attribute
  13. #
  14. # Eli Bendersky [https://eli.thegreenplace.net/]
  15. # License: BSD
  16. #-----------------------------------------------------------------
  17. # ArrayDecl is a nested declaration of an array with the given type.
  18. # dim: the dimension (for example, constant 42)
  19. # dim_quals: list of dimension qualifiers, to support C99's allowing 'const'
  20. # and 'static' within the array dimension in function declarations.
  21. ArrayDecl: [type*, dim*, dim_quals]
  22. ArrayRef: [name*, subscript*]
  23. # op: =, +=, /= etc.
  24. #
  25. Assignment: [op, lvalue*, rvalue*]
  26. Alignas: [alignment*]
  27. BinaryOp: [op, left*, right*]
  28. Break: []
  29. Case: [expr*, stmts**]
  30. Cast: [to_type*, expr*]
  31. # Compound statement in C99 is a list of block items (declarations or
  32. # statements).
  33. #
  34. Compound: [block_items**]
  35. # Compound literal (anonymous aggregate) for C99.
  36. # (type-name) {initializer_list}
  37. # type: the typename
  38. # init: InitList for the initializer list
  39. #
  40. CompoundLiteral: [type*, init*]
  41. # type: int, char, float, string, etc.
  42. # value: source spelling. A string may retain adjacent quoted fragments to
  43. # preserve escape boundaries, e.g. "\x1" "a".
  44. #
  45. Constant: [type, value]
  46. Continue: []
  47. # name: the variable being declared
  48. # quals: list of qualifiers (const, volatile)
  49. # funcspec: list function specifiers (i.e. inline in C99)
  50. # storage: list of storage specifiers (extern, register, etc.)
  51. # type: declaration type (probably nested with all the modifiers)
  52. # init: initialization value, or None
  53. # bitsize: bit field size, or None
  54. #
  55. Decl: [name, quals, align, storage, funcspec, type*, init*, bitsize*]
  56. DeclList: [decls**]
  57. Default: [stmts**]
  58. DoWhile: [cond*, stmt*]
  59. # Represents the ellipsis (...) parameter in a function
  60. # declaration
  61. #
  62. EllipsisParam: []
  63. # An empty statement (a semicolon ';' on its own)
  64. #
  65. EmptyStatement: []
  66. # Enumeration type specifier
  67. # name: an optional ID
  68. # values: an EnumeratorList
  69. #
  70. Enum: [name, values*]
  71. # A name/value pair for enumeration values
  72. #
  73. Enumerator: [name, value*]
  74. # A list of enumerators
  75. #
  76. EnumeratorList: [enumerators**]
  77. # A list of expressions separated by the comma operator.
  78. #
  79. ExprList: [exprs**]
  80. # This is the top of the AST, representing a single C file (a
  81. # translation unit in K&R jargon). It contains a list of
  82. # "external-declaration"s, which is either declarations (Decl),
  83. # Typedef or function definitions (FuncDef).
  84. #
  85. FileAST: [ext**]
  86. # for (init; cond; next) stmt
  87. #
  88. For: [init*, cond*, next*, stmt*]
  89. # name: Id
  90. # args: ExprList
  91. #
  92. FuncCall: [name*, args*]
  93. # type <decl>(args)
  94. #
  95. FuncDecl: [args*, type*]
  96. # Function definition: a declarator for the function name and
  97. # a body, which is a compound statement.
  98. # There's an optional list of parameter declarations for old
  99. # K&R-style definitions
  100. #
  101. FuncDef: [decl*, param_decls**, body*]
  102. # One association in a C11 generic selection.
  103. # type: Typename, or None for the default association
  104. # expr: the result expression for this association
  105. #
  106. GenericAssociation: [type*, expr*]
  107. # A C11 _Generic expression. All associations are preserved in source order.
  108. # expr: the controlling expression (not evaluated by C)
  109. # associations: a nonempty sequence of GenericAssociation nodes
  110. #
  111. GenericSelection: [expr*, associations**]
  112. Goto: [name]
  113. ID: [name]
  114. # Holder for types that are a simple identifier (e.g. the built
  115. # ins void, char etc. and typedef-defined types)
  116. #
  117. IdentifierType: [names]
  118. If: [cond*, iftrue*, iffalse*]
  119. # An initialization list used for compound literals.
  120. #
  121. InitList: [exprs**]
  122. Label: [name, stmt*]
  123. # A named initializer for C99.
  124. # The name of a NamedInitializer is a sequence of Nodes, because
  125. # names can be hierarchical and contain constant expressions.
  126. #
  127. NamedInitializer: [name**, expr*]
  128. # a list of comma separated function parameter declarations
  129. #
  130. ParamList: [params**]
  131. PtrDecl: [quals, type*]
  132. Return: [expr*]
  133. # A static assertion declaration. The condition is preserved without evaluation.
  134. # message: a string Constant, or None for the message-less extension
  135. #
  136. StaticAssert: [cond*, message*]
  137. # name: struct tag name
  138. # decls: declaration of members
  139. #
  140. Struct: [name, decls**]
  141. # type: . or ->
  142. # name.field or name->field
  143. #
  144. StructRef: [name*, type, field*]
  145. Switch: [cond*, stmt*]
  146. # cond ? iftrue : iffalse
  147. #
  148. TernaryOp: [cond*, iftrue*, iffalse*]
  149. # A base type declaration
  150. #
  151. TypeDecl: [declname, quals, align, type*]
  152. # A typedef declaration.
  153. # Very similar to Decl, but without some attributes
  154. #
  155. Typedef: [name, quals, storage, type*]
  156. Typename: [name, quals, align, type*]
  157. UnaryOp: [op, expr*]
  158. # name: union tag name
  159. # decls: declaration of members
  160. #
  161. Union: [name, decls**]
  162. While: [cond*, stmt*]
  163. Pragma: [string]