X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ast_t.h;h=9778d367b695d84c9644c9a5791ad1a77c067677;hb=659fb8e34ebdf612319f58c3ffe67f91d24efde7;hp=97b7c8212d49b73bb23b6d87ccb2d60c4c35d45d;hpb=e8b00fcb80ff3fdcfab757444e94663f1d56c743;p=cparser diff --git a/ast_t.h b/ast_t.h index 97b7c82..9778d36 100644 --- a/ast_t.h +++ b/ast_t.h @@ -17,13 +17,24 @@ typedef enum { EXPR_CALL, EXPR_UNARY, EXPR_BINARY, + EXPR_CONDITIONAL, EXPR_SELECT, EXPR_ARRAY_ACCESS, EXPR_SIZEOF, + + EXPR_FUNCTION, + EXPR_PRETTY_FUNCTION, + EXPR_BUILTIN_SYMBOL, + EXPR_OFFSETOF, + EXPR_VA_ARG, + EXPR_STATEMENT } expresion_type_t; struct context_t { - declaration_t *declarations; + declaration_t *declarations; + compound_type_t *structs; + compound_type_t *unions; + enum_type_t *enums; }; struct expression_t { @@ -34,7 +45,10 @@ struct expression_t { struct const_t { expression_t expression; - int value; + union { + int int_value; + long double float_value; + } v; }; struct string_literal_t { @@ -42,6 +56,11 @@ struct string_literal_t { const char *value; }; +struct builtin_symbol_expression_t { + expression_t expression; + symbol_t *symbol; +}; + struct reference_expression_t { expression_t expression; symbol_t *symbol; @@ -110,7 +129,8 @@ typedef enum { BINEXPR_SHIFTRIGHT_ASSIGN, BINEXPR_BITWISE_AND_ASSIGN, BINEXPR_BITWISE_XOR_ASSIGN, - BINEXPR_BITWISE_OR_ASSIGN + BINEXPR_BITWISE_OR_ASSIGN, + BINEXPR_COMMA } binary_expression_type_t; struct binary_expression_t { @@ -137,6 +157,25 @@ struct array_access_expression_t { struct sizeof_expression_t { expression_t expression; type_t *type; + expression_t *size_expression; +}; + +struct designator_t { + symbol_t *symbol; + expression_t *array_access; + designator_t *next; +}; + +struct offsetof_expression_t { + expression_t expression; + type_t *type; + designator_t *designator; +}; + +struct va_arg_expression_t { + expression_t expression; + expression_t *arg; + type_t *type; }; struct conditional_expression_t { @@ -146,14 +185,9 @@ struct conditional_expression_t { expression_t *false_expression; }; -struct expression_list_element_t { - expression_t *expression; - expression_t *next; -}; - -struct comma_expression_t { - expression_t expression; - expression_list_element_t *expressions; +struct statement_expression_t { + expression_t expression; + statement_t *statement; }; typedef enum { @@ -162,14 +196,31 @@ typedef enum { STORAGE_CLASS_EXTERN, STORAGE_CLASS_STATIC, STORAGE_CLASS_AUTO, - STORAGE_CLASS_REGISTER + STORAGE_CLASS_REGISTER, + STORAGE_CLASS_ENUM_ENTRY } storage_class_t; +typedef enum { + INITIALIZER_VALUE, + INITIALIZER_LIST, +} initializer_type_t; + +struct initializer_t { + initializer_type_t type; + designator_t *designator; + union { + initializer_t *list; + expression_t *value; + } v; + initializer_t *next; +}; + struct declaration_t { storage_class_t storage_class; type_t *type; symbol_t *symbol; statement_t *statement; + initializer_t *initializer; source_position_t source_position; context_t context; @@ -182,10 +233,16 @@ typedef enum { STATEMENT_RETURN, STATEMENT_DECLARATION, STATEMENT_IF, + STATEMENT_SWITCH, STATEMENT_EXPRESSION, STATEMENT_CONTINUE, + STATEMENT_BREAK, STATEMENT_GOTO, - STATEMENT_LABEL + STATEMENT_LABEL, + STATEMENT_CASE_LABEL, + STATEMENT_WHILE, + STATEMENT_DO_WHILE, + STATEMENT_FOR } statement_type_t; struct statement_t { @@ -207,7 +264,8 @@ struct compound_statement_t { struct declaration_statement_t { statement_t statement; - declaration_t declaration; + declaration_t *declarations_begin; + declaration_t *declarations_end; int value_number; /**< filled in by semantic phase */ int refs; @@ -220,12 +278,23 @@ struct if_statement_t { statement_t *false_statement; }; +struct switch_statement_t { + statement_t statement; + expression_t *expression; + statement_t *body; +}; + struct goto_statement_t { statement_t statement; symbol_t *label_symbol; label_statement_t *label; }; +struct case_label_statement_t { + statement_t statement; + expression_t *expression; +}; + struct label_statement_t { statement_t statement; symbol_t *symbol; @@ -236,6 +305,27 @@ struct expression_statement_t { expression_t *expression; }; +struct while_statement_t { + statement_t statement; + expression_t *condition; + statement_t *body; +}; + +struct do_while_statement_t { + statement_t statement; + expression_t *condition; + statement_t *body; +}; + +struct for_statement_t { + statement_t statement; + expression_t *initialisation; + expression_t *condition; + expression_t *step; + statement_t *body; + context_t context; +}; + struct translation_unit_t { context_t context; };