You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

154 lines
3.1 KiB

============================================
Struct declarations
============================================
struct s1;
struct s2 {
int x;
float y;
};
---
(program
(struct_declaration (struct_type (identifier)))
(struct_declaration (struct_type (identifier)
(field (identifier) (identifier))
(field (identifier) (identifier)))))
============================================
Union declarations
============================================
union u1;
union s2 {
int x;
float y;
};
---
(program
(union_declaration (union_type (identifier)))
(union_declaration (union_type (identifier)
(field (identifier) (identifier))
(field (identifier) (identifier)))))
============================================
Enum declarations
============================================
enum e1;
enum e2 {
val1,
val2 = 5,
val3
};
---
(program
(enum_declaration (enum_type (identifier)))
(enum_declaration (enum_type (identifier)
(identifier)
(enum_value (identifier) (number))
(identifier))))
============================================
Primitive-typed variable declarations
============================================
unsigned short int a;
long int b, c = 5, d;
float d, e;
---
(program
(var_declaration (primitive_type (identifier)) (identifier))
(var_declaration (primitive_type (identifier))
(identifier)
(var_assignment (identifier) (number))
(identifier))
(var_declaration (identifier) (identifier) (identifier)))
============================================
Composite-typed variable declarations
============================================
struct b c;
union { int e; } f;
enum { g, h } i;
---
(program
(var_declaration (struct_type (identifier)) (identifier))
(var_declaration (union_type (field (identifier) (identifier))) (identifier))
(var_declaration (enum_type (identifier) (identifier)) (identifier)))
============================================
Pointer variable declarations
============================================
char *the_string;
const char **the_strings;
---
(program
(var_declaration (identifier) (pointer_type (identifier)))
(var_declaration (type (identifier))
(pointer_type (pointer_type (identifier)))))
============================================
Typedefs
============================================
typedef int my_int;
typedef struct{
int x;
} *a;
---
(program
(typedef (identifier) (identifier))
(typedef (struct_type
(field (identifier) (identifier)))
(pointer_type (identifier))))
============================================
Function declarations
============================================
int main(int argc, const char **argv);
---
(function_declaration
(identifier)
(identifier)
(formal_parameters
(field (identifier) (identifier))
(field (type (identifier)) (pointer_type (pointer_type (identifier))))))
============================================
Function definitions
============================================
void * do_stuff(int arg1) {
return 5;
}
---
(function_declaration
(identifier)
(pointer_type (identifier))
(field (identifier) (identifier))
(statement_block (return_statement (number))))