See also:
The cfront home page.
The cfront programmers manual.
#include <cfront/init.h>
void cfront_initialize (void)
Initializes the internal state of cfront and cpp to reasonable
defaults.
#include <cfront/init.h>
void cfront_stdclib_support(void)
This function will initialize the include path and initialize
type sizes to those specified in limits.h. The include path is
initialized to the following, in order:
#include <cfront/init.h>
void ast_cross_link (<node type>,
void *ast_node,
functionDefinition function,
statement stat,
Scope scope);
Annotates an AST element with all kinds of useful information. For
example, links
IdExpr to the Id_Decl that
declares the name, This is actually a wrapper macro around the function _ast_cross_link. It can perform the cross link decoration on any node in the AST. You should provide the type of the node as the first argument node type, it should always be a super type, for example statement not compound_statement. The node itself should be passed as the second argument. Since this is a generic decoration you have to supply some extra information, the function argument should contain the functionDefinition ast_node is in, if it's not in a functionDefinition just pass NULL. Similarly, the stat argument should contain the statement ast_node is in or NULL. The argument scope should contain the scope the ast_node is in.
Example
void
compound_prepend_statement (compound_statement parent, statement s)
{
compound_statement_body (parent) = Create_List_statement(compound_statement_body (parent), s);
ast_cross_link (statement, s, statement_function (parent), parent, statement_scope (parent);
}
#include <cfront/init.h>
void cfront_purge_namespaces (void);
Cleans the symbol table of old symbols.
The symbol table can become cluttered with old symbols due to rewrites and redecoration of the AST. This can sometime lead to problems in decorating the AST, typically links to elements that no longer exist. This function will remove the symbols obtained from earlier decorations from the symbol table.
#include <cfront/init.h>
void cfront_set_symtab_bottom (void);
Symbols defined before the call to this function will not be removed by
cfront_purge_namespaces.
#include <cfront/platform.h>
int bits_per_char;
The type char is the smallest type in C, the size of all other
types are in terms of chars. As its name suggests, with
bits_per_char you specify the number of bits in a
character, usually this will be 8. Though the ANSI-C standard
specifies that a character should be able to contain all ASCII
characters (7 bits), cfront is able to cope with character sizes of
smaller than 7. Sizes smaller than 1 give undefined behaviour.
Bool char_is_unsigned;
The signedness of char is unspecified by the ANSI-C
standard. Use this variable to specify this.
Bool unsigned_int_fits_long;
TO DO: Why does this exist? It should be obvious from the sizes of the
types.
Bool divide_rounds_to_0;
This variable specifies whether divide rounds down or to zero. This
should be set according to the behaviour of the divide machine
operation of the compilation target.
Bool signed_modulo;
If signed_modulo is set to TRUE, the modulo operator (%) can
return negative values.
Bool unsigned_bitfields;
The signedness of bitfields in structs is unspecified by the
ANSI-C standard. Use this
variable to specify this. If this variable is TRUE a bitfield of the
form int foo:1 can contain the value 0 and 1, if
unsigned_bitfields is FALSE it can contain 0 and -1.
Bool bitfields_allocated_up;
Bit fields can be allocated in an element (eg. int) starting at the
least significant bit (bit 0) and up, bitfields_allocated_up =
TRUE, or from the most significant bit down,
bitfields_allocated_up = FALSE.
Bool shr_preserves_sign;
Whether the shift right operator (>>) preserves the sign of the
left hand side is not specified by the ANSI-C standard. Use this
variable to specify this.
Bool little_endian;
This variable sets the endianness of the compilation target. A little
endian processor stores the value 0x12AB34CD in the following byte
order: 0xCD, 0x34, 0xAB, 0x12. A big endian processor stores this
value as follows: 0x12, 0xAB, 0x34, 0xCD. Both have their merits.
Bool variable_length_arrays_allowed;
This is a gcc extension. Setting this variable to TRUE allows
non-constant array size in array declarations with automatic storage
(local array variables), for example:
void foo(int c)
{
char array[c];
...
}
#include <cfront/platform.h>
void gcc_extensions(void);
Call this function after initialization to provide support for the gcc
extensions, __builtin_va_list, __builtin_va_arg, __builtin_va_end,
__builtin_va_start, __builtin_stdarg_start. These extensions are used
in, for example, the GNU libc.
There are several traversals on the root of the AST. The most used are
cfront_decorate, which annotates the
entire AST with useful information, and cfront_give_types which computes the
type for all expressions and declarators.
Input examples:
After type information has been computed using
cfront_give_types, the member
type will contain the type of the function.
Input examples:
It may seem a little bit awkward, but struct and
union definitions are also part of the declaration
specifiers. This also makes it clear that the declarator part of a
declaration can be empty, since a structure definition does not have
to coincide with a variable declaration.
You may have noticed that the grammar for
enumerator_list is a bit strange, it specifies a list of
optional enumerators. This is done this way because we cannot,
in a non-conflicting way, write down that the list may or may not be
terminated by a comma. Whether the enumeration is syntactically
correct is checked in a later traversal.
AST root
This section describes the types and functions related to the root of
the cfront AST.
cfront
Grammar:
cfront ::= { decls:
externalDeclaration }
Members:
cfront is the root node of the AST. As can be seen from the
grammar, all elements are externalDeclarations, be they
functions, global variables, typedefs, or something else. A scope is
opened for the children of cfront, so when you have several
cfront ASTs they will not interfere with each other. There are
four ways to create a cfront node, the usual way with cfront_Parse, by copying COPY_cfront,
using the "constructor", Create_cfront,
and by parsing from a string, Parse_cfront.
common members
List_externalDeclaration
decls
All elements in the source file
Create_cfront
#include <cfront/cfront.h>
Create a cfront AST node. The generic members will be
initialized to their default values.
cfront Create_cfront
(SrcInfo src_info,
List_externalDeclaration
decls);
cfront_Parse
#include <cfront/init.h>
Parses the C file specified by filename and decorates the
resulting AST. if filename is NULL input is read from
stdin. The result is the AST constructed from the input. Any source
errors are recorded by egg. The global variable
cfront_root will also contain the AST.
cfront cfront_Parse (const char *result);
cfront_decorate
#include <cfront/init.h>
This will concatenate sequences of strings into one string, call the
user defined attribute parsers, perform
ast_cross_link, and evaluates all
IntExprs.
void cfront_decorate (cfront ast);
cfront_give_types
#include <cfront/typing.h>
Adds types to all declarators and expressions in root. This
will simultaneously do the type checking, any typing errors are
recorded by egg.
Bool cfront_give_types (cfront root)
externalDeclaration
Used by: cfront
Grammar:
externalDeclaration ::=
< FuncDef
| PlainDef
| PragmaDef
| ";"
>
An externalDeclaration is an element of the AST root,
cfront. One rarely has to do anything with
this. As the name suggests function definitions are represented by the
FuncDef sub-type. All declarations are represented by the
PlainDef sub-type. A typedef is a declaration with typedef
storage-class, a
struct, union, or
enum definition is a declaration without
a declarator.
FuncDef ::= func:
functionDefinition
PlainDef ::= decl:declaration
PragmaDef ::= pragma:pragmaLine
Function
This section describes all types and functions related to examining and
modifying function declarations and definitions.
functionDefinition
Used by: externalDeclaration
Grammar:
functionDefinition ::=
Members:
head:function_header
{ old_par_decls:declaration
";" }
body:compound_statement
A functionDefinition represents a function, including its name,
result type, argument types, and the actual implementation. For "new
style" function definitions the first three are specified by a
function_header. In an "old style", or
K&R style, function definition the header does not specify the
argument types, instead they are declared in the
old_par_decls. The body of a functionDefinition
contains the implementation and is guaranteed to be a
compound_statement.
common members
statement
body
the compound statement that is the implementation of the
function
List_expression
callers
all expressions (in this file) of the kind CallExprs that
call this function
externalDeclaration
cur_external
the externalDeclaration that contains this functionDefinition
function_header
head
the declaration specifiers and declarator of the function
Bool
is_leaf
holds if this function does not call other functions
List_declaration
old_par_decls
the declarations of parameters for K&R style function
definitions
Type
stack_frame
a type constructed by [Some function] to represent
the stack frame of this function
New style:
Old style:
<functionDefinition>
<head>void main (int argc, char **argv)</head>
<body>
{
printf ("Hello world.\n");
}
</body>
</functionDefinition>
<functionDefinition>
<head>void main (argc, argv)</head>
<old_par_decls>
int argc;
char **argv;
</old_par_decls>
<body>
{
printf ("Hello world.\n");
}
</body>
</functionDefinition>
functionDefinition_decl
#include <cfront/function.h>
Returns the declarator of the header of function. This is not
necessarily a FuncDecl, for example if the
result type is a pointer type, this will be a PointerDecl.
declarator functionDefinition_decl
(functionDefinition function);
functionDefinition_type
#include <cfront/function.h>
Returns the type of function.
Type
functionDefinition_type (functionDefinition
function);
function_header
Used by: functionDefinition
Grammar:
function_header ::= spec: {
declaration_specifier }
decl:declarator
Sub types:
spec_functiondef, functiondef
Members:
A function_header describes the name, result, and arguments of
a functionDefinition. The way in
which the type of the function is defined is exactly as is done in
variable declarations. The declarator
decl will contain an Id_Decl that is the
name of the function, obtainable with get_Id_Decl, and also a
FuncDecl that will contain the declarations
for the arguments.
common members
function_header_tag
tag
Sub type specification
declarator
decl
the declarator of the
functionDefinition
Type
type
the type of the function, this is the same as the type of the
Id_Decl in the tree of decl
<function_header>
<spec>int</spec>
<decl>main (int argc, char **argv)</decl>
</function_header>
{
printf ("Hello world.\n");
}
function_header : spec_functiondef
Super type: function_header
Members:
To do: can this sub type go away?
declaration_specifiers
specs
list of declaration
specifiers for the functionDefinition
declarator : FuncDecl
Super type: declarator
Grammar:
FuncDecl ::= pre:direct_declarator
pars:parameter_list
[attrs:gnu_attr]
Members:
OldFuncDecl ::=pre:direct_declarator
pars:parameter_id_list
abstract_FuncDecl ::= decl:[abstract_direct_declarator]
pars:parameter_list
The FuncDecl is the declarator that actually declares a function. It
specifies the name and the argument types of the function. It's used
in both functionDefinition and
function declaration. The FuncDecl is the most natural element to use
when you wish to inspect functions.
declarator
pre
The name part of the function declarator. For normal
function declarations this will be an
Id_Decl, for function pointers this
will be a pointer_declarator.
parameter_list
pars
The function arguments.
gnu_attr
attrs
GNU attributes that apply to the function.
compound_statement
body
The body of the function, taken from the
functionDefinition, if
it's present in the AST.
function_has_result
#include <cfront/function.h>
Returns TRUE if the result type of function is not void.
Bool function_has_result
(FuncDecl function);
function_prepend_parameter
#include <cfront/function.h>
Add the parameter declaration par
at the front of the parameter declaration list of func.
void
function_prepend_parameter
(FuncDecl func,
declaration par);
function_append_parameter
#include <cfront/function.h>
Add the parameter declaration par
at the end of the parameter declaration list of func.
void
function_append_parameter
(FuncDecl func,
declaration par);
parameter_list
Used by: declarator : FuncDecl
Grammar:
parameter_list ::= "(" pars: [
parameter_declaration //
"," ] ")"
Members:
parameter_id_list ::= "(" pars:
( Par_Id_Decl //
",") ")"
The parameter_id_list is mapped onto the parameter_list where
the declarations have no specifiers and the
Par_Id_Decl as declarator.
common members
List_declaration
pars
The parameters of a function declaration
Variable and typedef
declaration
Used by: declarator : FuncDecl,
externalDeclaration : PlainDef
Grammar:
declaration ::= specs: {
declaration_specifier}+
decls: [ initializable_declarator
// "," ]
Members:
struct_declaration ::= specs:{
declaration_specifier}+
decls: ( structDeclarator
// "," )
parameter_declaration = < VarargsParDecl | PlainParDecl |
AbstractParDecl >
VarargsParDecl ::= "..."
PlainParDecl ::= specs: {
declaration_specifier}+
decls: declarator
AbstractParDecl ::= specs: {
declaration_specifier}+
decls: opt_abstract_declarator
A declaration is used to declare variables, types, and functions. One
declaration can declare several names. A declaration has two parts,
the declaration specifiers, and
the declarators. The specifier part can play
several roles:
common members
declaration_specifiers
specs
list of declaration specifiers
List_declarator
decls
externalDeclaration
cur_external
optional. The PlainDef that contains this declaration
The declarator part contains the names of the variable, function, or
type, in the form of an Id_Decl, aswell as
more typing, eg. for pointer, array, and function.
declaration_specifier
Used by:
declaration,
function_header : spec_functiondef
Grammar:
declaration_specifier ::=
Sub types:
< TypeId | Sign | StorageClass | TypeQual
TypeId ::= TypeIdentifier
| inline_specifier | inline_specifier1 | inline_specifier2
| Enum | StructDef
| UnionDef | StructDecl
| UnionDecl
>
Sign ::= si:
< Signed ::= "signed"
| UnSigned ::= "unsigned"
>
StorageClass ::= sc:
storage_class_specifier
TypeQual ::= qual:type_qualifier
inline_specifier ::= "inline"
inline_specifier1 ::= "__inline"
inline_specifier2 ::= "__inline__"
Enum, inline_specifier,
inline_specifier1, inline_specifier2, Sign, StorageClass,
StructDecl,
StructDef, TypeId, TypeQual,
UnionDecl, UnionDef
Members:
Declaration specifiers are used for several things. Most obvious is
the use as a type specifier, eg. int, or unsigned
long. These are a TypeId, and a Sign followed by a
TypeId. The keywords extern, static,
auto, register, and (officially for convenience)
typedef, are known as storage class specifiers. The keywords
const and volatile are known as type qualifiers.
common members
declaration_specifier_tag
tag
Sub type specification.
Type
type
Partial type for the declarators of the declaration. This
member is used during typing and is not much use anywhere
else.
declaration_specifier
definition
tag==StructDecl_kind : the StructDef that defines the members
tag==UnionDecl_kind : the UnionDef that defines the members
otherwise : NULL
declaration_specifier : StructDef
Super type: declaration_specifier
Grammar:
StructDef ::= "struct"
id: [ Idenfier ]
members:{ struct_declaration
";" }
Members:
A StructDef, or structure definition, is used to declare a tag as a
structure containing the specified members. The structure definition
is refered to by a structure declaration, or
StructDecl, with the same name.
Ident
id
The tag name of the struct
List_declaration
members
The member declarations of the struct
declaration_specifier : UnionDef
Super type: declaration_specifier
Grammar:
UnionDef ::="union"
id: [ Idenfier ]
members: { struct_declaration
";" }
Members:
A UnionDef, or union definition, is used to declare a tag as a union
containing the specified members. The union definition is refered to
by a union declaration, or UnionDecl, with
the same name.
Ident
id
The tag name of the union
List_declaration
members
The member declarations of the union
declaration_specifier : StructDecl
Super type:declaration_specifier
Grammar:
StructDecl < aggregate_specifier ::=
"struct" id:
Idenfier
Members:
A StructDecl, or structure declaration, is used to specify a structure
type. The StructDecl is also use for forward declarations of a structure definition. If the StructDecl is part
of a pointer declaration the
structure may not be defined in the module.
Ident
id
The tag name of the struct
declaration_specifier : UnionDecl
Super type:declaration_specifier
Grammar:
UnionDecl ::="union"
id:Idenfier
Members:
A UnionDecl, or union declaration, is used to specify a union
type. The UnionDecl is also use for forward declarations of a union definition. If the UnionDecl is part of a
pointer declaration the union may
not be defined in the module.
Ident
id
The tag name of the union
declaration_specifier : Enum
Super type: declaration_specifier
Grammar:
enum_specifier ::= < Enum | UntaggedEnum >
Members:
Enum ::= "enum"
id:Identifier
enums: [ "{"
enumerator_list
"}"
]
UntaggedEnum ::= "enum" "{"
enums: enumerator_list
"}"
enumerator_list = [enumerator] //
","
An Enum is used for both enum declaration and
definition.
Ident
id
The tag name of the enum
List_declarator
enums
The declarations of the names defined in this enum
declarator : enumerator
Super type: declarator
Used by: declaration_specifier : enum_specifier
Grammar:
enumerator ::= id:Identifier
[ "="
c:integral_constant_expression ]
An enumerator declares an element of an Enum. It is only allowed inside an
enum.
storage_class_specifier
Used by: declaration_specifier
Grammar:
storage_class_specifier ::=
< "auto"
| "extern"
| "register"
| "static"
| "typedef"
>
With a storage class the programmer can specify several things.
type_qualifier
Used by:
declaration_specifier,
declarator : pointer_declarator
Grammar:
type_qualifier ::=
< gnu_attr
| "const"
| "volatile"
| "restrict"
| "__const"
| "__volatile"
| "__restrict"
| "__const__"
| "__volatile__"
| "__restrict__"
>
declarator
Used by:
declaration,
function_header
Grammar:
declarator ::=
< pointer_declarator
| direct_declarator >
Sub types:
initializable_declarator =
< initDeclarator
| declarator
>
direct_declarator =
< ParenDecl
| ArrayDecl
| FuncDecl
| OldFuncDecl
| Id_Decl
>
ParenDecl ::= "(" decl:
declarator ")"
ArrayDecl : declares an array
enumerator :
an element of an enum
FuncDecl :
the name and argument list part of a function declaration
Id_Decl : the name of the variable
initDeclarator :
declares an initialized variable
pointer_declarator :
declares a pointer
Par_Id_Decl :
the parameter name of an old style function parameter
declarator : abstract_declarator
Grammar:
abstract_declarator ::=
< abstract_pointer_declarator
| abstract_direct_declarator
>
opt_abstract_direct_declarator =
< abstract_direct_declarator
| abstract_Id_Decl
>
opt_abstract_declarator ::=
< abstract_declarator
| abstract_Id_Decl
>
abstract_direct_declarator =
< abstract_ParenDecl
| abstract_ArrayDecl
| abstract_FuncDecl
| abstract_Id_Decl
>
abstract_ParenDecl ::= "("
decl:abstract_declarator ")"
declarator : Id_Decl
Super type:
declarator
Grammar:
Id_Decl ::= id:Identifier
abstract_Id_Decl ::=
declarator : pointer_declarator
Super type:
declarator
Grammar:
pointer_declarator ::= "*"
quals: { type_qualifier }
decl:declarator
abstract_pointer_declarator ::= "*"
quals: { type_qualifier }
decl:opt_abstract_declarator
declarator : ArrayDecl
Super type:
declarator
Grammar:
ArrayDecl ::= pre:direct_declarator
"[" size:
[ integral_constant_expression ]
"]"
abstract_ArrayDecl ::=
pre:opt_abstract_direct_declarator
"[" size:
[ integral_constant_expression ]
"]"
declarator : initDeclarator
Super type:
declarator
Used by: declaration
Grammar:
initDeclarator ::= decl:declarator
"="
init:initializer
attr:[ gnu_attr ]
declarator : structDeclarator
Super type: declarator
Used by: struct_declaration
Grammar:
structDeclarator ::= < DeclStruct | NoDeclStruct >
DeclStruct ::= decl:declarator [
":" bf:integral_constant_expression]
NoDeclStruct ::= ":" bf:
integral_constant_expression
declarator : Par_Id_Decl
Super type:
declarator
Used by:
parameter_id_list
Grammar:
Par_Id_Decl ::= id:Idenfier
Statement
statement
Grammar:
statement ::=
Members:
< LabeledStat
EmptyStat ::= ";"
| CaseStat
| DefaultStat
| ExprStat
| compound_statement
| IfStat
| SwitchStat
| WhileStat
| DoStat
| ForStat
| GotoStat
| ContinueStat
| BreakStat
| ReturnStat
| PragmaStat
| EmptyStat
>
functionDefinition
cur_func
The function that contains this statement
statement
parent
optional. The statement that contains this statement
expression
guard
To do: uninitialized member
statement
original
The statement that was replaced by this statement.
Filled by replace_stat
statement
previous
To do: obsolete member
statement : LabeledStat
Super type:
statement
Grammar:
LabeledStat ::= label:Identifier ":"
stat:statement
statement : CaseStat
Super type:statement
Grammar:
CaseStat ::= "case"
val:integral_constant_expression
":"
stat:statement
statement : DefaultStat
Super type:
statement
Grammar:
DefaultStat ::= "default" ":"
stat:statement
statement : ExprStat
Super type: statement
Grammar:
ExprStat ::= expr:expression
[ attr:gnu_attr ] ";"
statement : compound_statement
Super type: statement
Used by: functionDefinition
Grammar:
compound_statement ::= "{"
locdecls: { declaration
";" }
body: { statement }
"}"
statement : IfStat
Super type: statement
Grammar:
IfStat ::= "if" "("
cond:expression
")"
thn:statement
[ "else"
els:statement]
statement : SwitchStat
Super type:statement
Grammar:
SwitchStat ::= "switch" "("
sw:expression
")"
body:statement
statement : WhileStat
Super type: statement
Grammar:
WhileStat ::= "while" "("
cond:expression
")"
body:statement
statement : DoStat
Super type: statement
Grammar:
DoStat ::= "do"
body:statement
"while" "("
cond:expression
")" ";"
statement : ForStat
Super type:statement
Grammar:
ForStat ::= "for" "("
[ start:expression ]
";"
[ cond:expression ]
";"
[ step:expression ]
")"
body:statement
statement : GotoStat
Super type: statement
Grammar:
GotoStat ::= "goto"
label:Identifier ";"
statement : ContinueStat
Super type: statement
Grammar:
ContinueStat ::= "continue"
";"
statement : BreakStat
Super type: statement
Grammar:
BreakStat ::= "break"
";"
statement : ReturnStat
Super type: statement
Grammar:
ReturnStat ::= "return"
[ expr:expression ]
";"
statement : PragmaStat
Super type: statement
Grammar:
PragmaStat ::= pragma:pragmaLine
Expression
expression
Used by:
declarator : structDeclarator,
declarator : enumerator,
declarator: ArrayDecl,
statement : CaseStat,
statement : ExprStat,
statement : IfStat,
statement : SwitchStat,
statement : WhileStat,
statement : DoStat,
statement : ForStat,
statement : ReturnStat
Grammar:
expression ::= comma_expression'
Sub types:
initializer =
< [assign_expression']
| CompoundInit
| LabeledInit
>
unary_expression =
< postfix_expression
| SizeofExpr
| SizeofType
| prefix_expr
>
postfix_expression =
< primary_expression
| IndexExpr
| CallExpr
| MemberExpr
| DerefMemberExpr
| postfix_expr
>
primary_expression =
< IdExpr
| constant_expression
| ParExpr
| gnu_expr
>
constant_expression =
< NumExpr
| CharExpr
| FloatExpr
| StringExpr
>
gnu_expr ::=
< StatExpr
| CompoundLit
| LabelExpr
>
bin_expression,
CallExpr,
CastExpr,
CharExpr,
comma_expression,
CompoundInit,
CompoundLit,
CondExpr,
DerefMemberExpr,
FloatExpr,
IdExpr,
IndexExpr,
LabelExpr,
LabeledInit,
MemberExpr,
mon_expression,
NumExpr,
ParExpr,
SizeofExpr,
SizeofType,
StatExpr,
StringExpr,
TypeExpr,
WideCharExpr
expression : bin_expression
Super type: expression
Grammar:
assign_expression' =
< CondExpr'
| assign_expression
>
assign_expression ::= lhs:
unary_expression
op:assign_op rhs:assign_expression'
logical_or_expression ::= logical_and_expression //
"||"
logical_and_expression ::= inclusive_or_expression //
"&&"
inclusive_or_expression ::= exclusive_or_expression //
"|"
exclusive_or_expression ::= and_expression //
"^"
and_expression ::= equality_expression //
"&"
equality_expression ::= relational_expression //
< "=="
| "!="
>
relational_expression ::= shift_expression //
< "<"
| ">"
| "<="
| ">="
>
shift_expression ::= additive_expression //
< "<<"
| ">>"
>
additive_expression ::= multiplicative_expression //
< "+"
| "-"
>
multiplicative_expression ::= CastExpr' //
< "*"
| "/"
| "%"
>
expression : CallExpr
Super type: expression
Grammar:
argument_expression =
< TypeExpr
| assign_expression'
>
CallExpr ::= func:
postfix_expression
"("
args: [ argument_expression //
"," ]
")"
expression : CastExpr
Super type: expression
Grammar:
CastExpr' =
< CastExpr
| unary_expression
>
CastExpr ::= "(" casts:type_name
")" expr:CastExpr'
expression : CharExpr
Super type: expression
Grammar:
CharExpr ::= c:Character
expression : comma_expression
Super type: expression
Grammar:
comma_expression'=
< comma_expression
| assign_expression'
>
comma_expression ::= pre: {
assign_expression'
","
}+ last:assign_expression'
expression : CompoundInit
Grammar:
CompoundInit ::= "{"
inits: (initializer //
",")
"}"
expression : CompoundLit
Super type: expression
Grammar:
CompoundLit ::="("
"(" casts:type_name
")" expr:
CompoundInit
")"
This is a GNU extension
expression : CondExpr
Super type: expression
Grammar:
integral_constant_expression = CondExpr'
CondExpr'=
< CondExpr
| logical_or_expression
>
CondExpr ::= cond:logical_or_expression
"?"
thn:expression
":" els:CondExpr'
expression : DerefMemberExpr
Grammar:
DerefMemberExpr ::= aggr:postfix_expression
"->" member:
Identifier
expression : FloatExpr
Super type: expression
Grammar:
FloatExpr ::= f:Float
expression : IdExpr
Super type: expression
Grammar:
IdExpr ::= id_id:Identifier
expression : IndexExpr
Super type: expression
Grammar:
IndexExpr ::= array:postfix_expression
"[" index:
expression
"]"
expression : LabelExpr
Super type: expression
Grammar:
LabelExpr ::= "&&"
id:Identifier
This is a GNU extension.
expression : LabeledInit
Super type: expression
Grammar:
LabeledInit ::= label:Identifier
":" init:initializer
GNU extension
expression : MemberExpr
Super type: expression
Grammar:
MemberExpr ::= aggr:postfix_expression
"." member:
Identifier
expression : mon_expression
Super type: expression
Grammar:
monadic_operator ::=
< DerefOp ::= "*"
post_op ::=
< PostInc ::= "++"
| PostDec ::= "--"
>
| AddrOp ::= "&"
| PosOp ::= "+"
| NegOp ::= "-"
| InvOp ::= "~"
| NotOp ::= "!"
| PreInc ::= "++"
| PreDec ::= "--"
>
prefix_expr ::= op:monadic_operator
expr:CastExpr'
postfix_expr = expr:
postfix_expression
op:post_op
expression : NumExpr
Super type: expression
Grammar:
NumExpr ::= i:Num
expression : ParExpr
Super type: expression
Grammar:
ParExpr ::="("
expr:expression
[ attr:gnu_attr ] ")"
expression : SizeofExpr
Super type: expression
Grammar:
SizeofExpr ::="sizeof"
expr:unary_expression
expression : SizeofType
Super type: expression
Grammar:
SizeofType ::= "sizeof"
"(" tname:type_name
")"
expression : StatExpr
Super type: expression
Grammar:
StatExpr ::="("
stat:compound_statement
")"
This is a GNU extension.
expression : StringExpr
Super type: expression
Grammar:
StringExpr ::= s: { CString }+
expression : TypeExpr
Super type: expression
Grammar:
TypeExpr ::=typename:type_name
Required for gcc 3+ __builtin_va_arg.
expression : WideCharExpr
Super type: expression
Generic AST functions
Common members
To do
List_<type>
All List_<type> types are based on the Front_List type.
<type>
data
The element in this entry
List_<type>
next
The tail of the list
Complete grammar