============================================
|
|
Struct declarations
|
|
============================================
|
|
|
|
struct s1;
|
|
|
|
struct s2 {
|
|
int x;
|
|
float y : 5;
|
|
};
|
|
|
|
---
|
|
|
|
(translation_unit
|
|
(struct_specifier (identifier))
|
|
(struct_specifier (identifier)
|
|
(struct_declaration (identifier) (identifier))
|
|
(struct_declaration (identifier) (identifier) (number_literal))))
|
|
|
|
============================================
|
|
Union declarations
|
|
============================================
|
|
|
|
union u1;
|
|
|
|
union s2 {
|
|
int x;
|
|
float y;
|
|
};
|
|
|
|
---
|
|
|
|
(translation_unit
|
|
(union_specifier (identifier))
|
|
(union_specifier (identifier)
|
|
(struct_declaration (identifier) (identifier))
|
|
(struct_declaration (identifier) (identifier))))
|
|
|
|
============================================
|
|
Enum declarations
|
|
============================================
|
|
|
|
enum e1;
|
|
|
|
enum e2 {
|
|
val1,
|
|
val2 = 5,
|
|
val3
|
|
};
|
|
|
|
enum e3 {
|
|
val1,
|
|
};
|
|
|
|
---
|
|
|
|
(translation_unit
|
|
(enum_specifier (identifier))
|
|
(enum_specifier (identifier)
|
|
(enumerator (identifier))
|
|
(enumerator (identifier) (number_literal))
|
|
(enumerator (identifier)))
|
|
(enum_specifier (identifier)
|
|
(enumerator (identifier))))
|
|
|
|
============================================
|
|
Primitive-typed variable declarations
|
|
============================================
|
|
|
|
unsigned short int a;
|
|
long int b, c = 5, d;
|
|
float d, e;
|
|
|
|
---
|
|
|
|
(translation_unit
|
|
(declaration (sized_type_specifier (identifier)) (identifier))
|
|
(declaration
|
|
(sized_type_specifier (identifier))
|
|
(identifier)
|
|
(init_declarator (identifier) (number_literal))
|
|
(identifier))
|
|
(declaration (identifier) (identifier) (identifier)))
|
|
|
|
============================================
|
|
Variable storage classes
|
|
============================================
|
|
|
|
int a;
|
|
extern int b, c;
|
|
auto int d;
|
|
register int e;
|
|
static int f;
|
|
|
|
---
|
|
|
|
(translation_unit
|
|
(declaration (identifier) (identifier))
|
|
(declaration (storage_class_specifier) (identifier) (identifier) (identifier))
|
|
(declaration (storage_class_specifier) (identifier) (identifier))
|
|
(declaration (storage_class_specifier) (identifier) (identifier))
|
|
(declaration (storage_class_specifier) (identifier) (identifier)))
|
|
|
|
============================================
|
|
Composite-typed variable declarations
|
|
============================================
|
|
|
|
struct b c;
|
|
union { int e; } f;
|
|
enum { g, h } i;
|
|
|
|
---
|
|
|
|
(translation_unit
|
|
(declaration
|
|
(struct_specifier (identifier))
|
|
(identifier))
|
|
(declaration
|
|
(union_specifier (struct_declaration (identifier) (identifier)))
|
|
(identifier))
|
|
(declaration
|
|
(enum_specifier (enumerator (identifier)) (enumerator (identifier)))
|
|
(identifier)))
|
|
|
|
============================================
|
|
Pointer variable declarations
|
|
============================================
|
|
|
|
char *the_string;
|
|
const char **the_strings;
|
|
|
|
---
|
|
|
|
(translation_unit
|
|
(declaration (identifier) (pointer_declarator (identifier)))
|
|
(declaration (type_qualifier) (identifier)
|
|
(pointer_declarator (pointer_declarator (identifier)))))
|
|
|
|
============================================
|
|
Typedefs
|
|
============================================
|
|
|
|
typedef int my_int;
|
|
|
|
typedef struct {
|
|
int x;
|
|
} *a;
|
|
|
|
---
|
|
|
|
(translation_unit
|
|
(declaration (storage_class_specifier) (identifier) (identifier))
|
|
(declaration
|
|
(storage_class_specifier)
|
|
(struct_specifier (struct_declaration (identifier) (identifier)))
|
|
(pointer_declarator (identifier))))
|
|
|
|
============================================
|
|
Function declarations
|
|
============================================
|
|
|
|
int main(int argc, const char **argv);
|
|
static foo bar();
|
|
static baz quux(...);
|
|
|
|
---
|
|
|
|
(translation_unit
|
|
(declaration
|
|
(identifier)
|
|
(function_declarator
|
|
(identifier)
|
|
(parameter_type_list
|
|
(parameter_declaration (identifier) (identifier))
|
|
(parameter_declaration (type_qualifier) (identifier) (pointer_declarator (pointer_declarator (identifier)))))))
|
|
|
|
(declaration
|
|
(storage_class_specifier)
|
|
(identifier)
|
|
(function_declarator (identifier)))
|
|
|
|
(declaration
|
|
(storage_class_specifier)
|
|
(identifier)
|
|
(function_declarator
|
|
(identifier)
|
|
(parameter_type_list))))
|
|
|
|
============================================
|
|
Function definitions
|
|
============================================
|
|
|
|
void * do_stuff(int arg1) {
|
|
return 5;
|
|
}
|
|
|
|
---
|
|
|
|
(translation_unit
|
|
(function_definition
|
|
(identifier)
|
|
(pointer_declarator
|
|
(function_declarator (identifier)
|
|
(parameter_type_list
|
|
(parameter_declaration (identifier) (identifier)))))
|
|
(compound_statement (return_statement (number_literal)))))
|