Files
2026-11-11 14:22:02 +08:00

269 lines
7.7 KiB
INI

#-----------------------------------------------------------------
# pycparser: _c_ast.cfg
#
# Defines the AST Node classes used in pycparser.
# After editing, run 'make regen-ast' from the repository root to
# regenerate pycparser/c_ast.py and format the code.
#
# Each entry is a Node sub-class name, listing the attributes
# and child nodes of the class:
# <name>* - a child node
# <name>** - a sequence of child nodes
# <name> - an attribute
#
# Append =None or =[] to any field to give it a constructor default, e.g.:
# Example: [name, child*=None, items**=[], flags=[]]
# Defaulted fields are keyword-only arguments after coord; fields without
# defaults remain required positional-or-keyword arguments in the listed order.
# A [] default creates a fresh list when omitted or passed None, and otherwise
# keeps the supplied value. Defaults do not change slots or child traversal.
#
# Fields named attributes contain AttributeSpecifier groups. Their owning node
# determines placement: declarations/parameters and labels use prefixes, tags
# put them after struct/union/enum, and declarators put them after the
# identifier, '*', ']', or ')' that the node represents.
#
# Eli Bendersky [https://eli.thegreenplace.net/]
# License: BSD
#-----------------------------------------------------------------
# ArrayDecl is a nested declaration of an array with the given type.
# dim: the dimension (for example, constant 42)
# dim_quals: list of dimension qualifiers, to support C99's allowing 'const'
# and 'static' within the array dimension in function declarations.
ArrayDecl: [type*, dim*, dim_quals, attributes**=[]]
# An array designator [expr] in a NamedInitializer. The wrapper distinguishes
# an identifier used as an array index from a field designator such as .field.
ArrayDesignator: [expr*]
ArrayRef: [name*, subscript*]
# op: =, +=, /= etc.
#
Assignment: [op, lvalue*, rvalue*]
Alignas: [alignment*]
# Generic C23 attribute; arguments is raw text inside parentheses, or None
# when no argument clause was written. namespace is None for unprefixed names.
Attribute: [name, namespace, arguments]
# One [[...]] group; empty attribute-list entries are ignored.
AttributeSpecifier: [attributes**]
# A standalone attribute declaration, including [[fallthrough]];.
AttributeDeclaration: [attributes**]
# Attribute prefixes on statements other than labels (which have their own
# attributes field to retain the existing switch-case AST structure).
AttributedStatement: [attributes**, stmt*]
# Attributes following a declaration's type specifiers and qualifiers.
AttributedType: [type*, attributes**]
BinaryOp: [op, left*, right*]
# A C23 bit-precise integer type, used as TypeDecl.type.
# width: the constant expression specifying the bit width, left unevaluated
# signedness: 'signed', 'unsigned', or None when omitted
#
BitIntType: [width*, signedness]
Break: []
Case: [expr*, stmts**, attributes**=[]]
Cast: [to_type*, expr*]
# Compound statement in C99 is a list of block items (declarations or
# statements).
#
Compound: [block_items**]
# Compound literal (anonymous object), with optional storage specifiers in C23.
# (storage-class-specifiers? type-name) {initializer_list}
# type: the typename
# init: InitList for the initializer list
# storage: list of storage-class specifiers, empty when omitted
#
CompoundLiteral: [type*, init*, storage]
# type: int, char, float, string, etc.
# value: source spelling. A string may retain adjacent quoted fragments to
# preserve escape boundaries, e.g. "\x1" "a".
#
Constant: [type, value]
Continue: []
# name: the variable being declared
# quals: list of qualifiers (const, volatile)
# funcspec: list function specifiers (i.e. inline in C99)
# storage: list of storage specifiers (extern, register, etc.)
# type: declaration type (probably nested with all the modifiers)
# init: initialization value, or None
# bitsize: bit field size, or None
#
Decl: [name, quals, align, storage, funcspec, type*, init*, bitsize*, attributes**=[]]
# Declarations sharing specifiers, optionally followed by Pragma nodes before
# the semicolon (in a for initializer).
DeclList: [decls**]
Default: [stmts**, attributes**=[]]
DoWhile: [cond*, stmt*]
# Represents the ellipsis (...) parameter in a function
# declaration
#
EllipsisParam: []
# An empty statement (a semicolon ';' on its own)
#
EmptyStatement: []
# Enumeration type specifier
# name: an optional ID
# values: an EnumeratorList
# underlying_type: an optional Typename for a C23 fixed underlying type
#
Enum: [name, values*, underlying_type*, attributes**=[]]
# A name/value pair for enumeration values
#
Enumerator: [name, value*, attributes**=[]]
# A list of Enumerator and Pragma nodes in source order.
#
EnumeratorList: [enumerators**]
# A list of expressions separated by the comma operator.
#
ExprList: [exprs**]
# This is the top of the AST, representing a single C file (a
# translation unit in K&R jargon). It contains a list of
# "external-declaration"s, which is either declarations (Decl),
# Typedef or function definitions (FuncDef).
#
FileAST: [ext**]
# for (init; cond; next) stmt
#
For: [init*, cond*, next*, stmt*]
# name: Id
# args: ExprList
#
FuncCall: [name*, args*]
# type <decl>(args)
#
FuncDecl: [args*, type*, attributes**=[]]
# Function definition: a declarator for the function name and
# a body, which is a compound statement.
# There's an optional list of parameter declarations for old
# K&R-style definitions
#
FuncDef: [decl*, param_decls**, body*]
# One association in a C11 generic selection.
# type: Typename, or None for the default association
# expr: the result expression for this association
#
GenericAssociation: [type*, expr*]
# A C11 _Generic expression. All associations are preserved in source order.
# expr: the controlling expression (not evaluated by C)
# associations: a nonempty sequence of GenericAssociation nodes
#
GenericSelection: [expr*, associations**]
Goto: [name]
ID: [name]
# Holder for types that are a simple identifier (e.g. the built
# ins void, char etc. and typedef-defined types)
#
IdentifierType: [names]
If: [cond*, iftrue*, iffalse*]
# The unresolved type of a C23 auto declaration. Used as TypeDecl.type;
# the initializer remains on Decl and "auto" remains in Decl.storage.
#
InferredType: []
# An initialization list used for compound literals.
#
InitList: [exprs**]
Label: [name, stmt*, attributes**=[]]
# A named initializer for C99.
# name is a sequence of ID nodes for .field designators and ArrayDesignator
# nodes for [expr] designators, allowing combinations such as [i].field[j].
#
NamedInitializer: [name**, expr*]
# a list of comma separated function parameter declarations
#
ParamList: [params**]
PtrDecl: [quals, type*, attributes**=[]]
Return: [expr*]
# A static assertion declaration. The condition is preserved without evaluation.
# message: a string Constant, or None for the message-less extension
#
StaticAssert: [cond*, message*]
# name: struct tag name
# decls: declaration of members
#
Struct: [name, decls**, attributes**=[]]
# type: . or ->
# name.field or name->field
#
StructRef: [name*, type, field*]
Switch: [cond*, stmt*]
# cond ? iftrue : iffalse
#
TernaryOp: [cond*, iftrue*, iffalse*]
# A base type declaration
#
TypeDecl: [declname, quals, align, type*, attributes**=[]]
# A typedef declaration.
# Very similar to Decl, but without some attributes
#
Typedef: [name, quals, storage, type*, attributes**=[]]
Typename: [name, quals, align, type*, attributes**=[]]
# A C23 typeof specifier, used as TypeDecl.type without resolving its type.
# op: typeof or typeof_unqual
# expr: a Typename for a type operand, otherwise an expression
#
TypeOf: [op, expr*]
UnaryOp: [op, expr*]
# name: union tag name
# decls: declaration of members
#
Union: [name, decls**, attributes**=[]]
While: [cond*, stmt*]
Pragma: [string]