better approach towards the parsing problems
[cparser] / ast_t.h
1 /*
2  * This file is part of cparser.
3  * Copyright (C) 2007-2008 Matthias Braun <matze@braunis.de>
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
18  * 02111-1307, USA.
19  */
20 #ifndef AST_T_H
21 #define AST_T_H
22
23 #include <libfirm/firm_types.h>
24 #include <assert.h>
25
26 #include "ast.h"
27 #include "symbol.h"
28 #include "token_t.h"
29 #include "type.h"
30 #include "adt/obst.h"
31
32 /** The AST obstack contains all data that must stay in the AST. */
33 extern struct obstack ast_obstack;
34
35 /**
36  * Expression kinds.
37  */
38 typedef enum {
39         EXPR_UNKNOWN = 0,
40         EXPR_INVALID,
41         EXPR_REFERENCE,
42         EXPR_CONST,
43         EXPR_CHARACTER_CONSTANT,
44         EXPR_WIDE_CHARACTER_CONSTANT,
45         EXPR_STRING_LITERAL,
46         EXPR_WIDE_STRING_LITERAL,
47         EXPR_COMPOUND_LITERAL,
48         EXPR_CALL,
49         EXPR_CONDITIONAL,
50         EXPR_SELECT,
51         EXPR_ARRAY_ACCESS,
52         EXPR_SIZEOF,
53         EXPR_CLASSIFY_TYPE,
54         EXPR_ALIGNOF,
55
56         EXPR_FUNCNAME,
57         EXPR_BUILTIN_SYMBOL,
58         EXPR_BUILTIN_CONSTANT_P,
59         EXPR_BUILTIN_PREFETCH,
60         EXPR_OFFSETOF,
61         EXPR_VA_START,
62         EXPR_VA_ARG,
63         EXPR_STATEMENT,
64
65         EXPR_UNARY_FIRST,
66         EXPR_UNARY_NEGATE = EXPR_UNARY_FIRST,
67         EXPR_UNARY_PLUS,
68         EXPR_UNARY_BITWISE_NEGATE,
69         EXPR_UNARY_NOT,
70         EXPR_UNARY_DEREFERENCE,
71         EXPR_UNARY_TAKE_ADDRESS,
72         EXPR_UNARY_POSTFIX_INCREMENT,
73         EXPR_UNARY_POSTFIX_DECREMENT,
74         EXPR_UNARY_PREFIX_INCREMENT,
75         EXPR_UNARY_PREFIX_DECREMENT,
76         EXPR_UNARY_CAST,
77         EXPR_UNARY_CAST_IMPLICIT, /**< compiler generated cast */
78         EXPR_UNARY_ASSUME,        /**< MS __assume() */
79         EXPR_UNARY_BITFIELD_EXTRACT,
80         EXPR_UNARY_LAST = EXPR_UNARY_BITFIELD_EXTRACT,
81
82         EXPR_BINARY_FIRST,
83         EXPR_BINARY_ADD = EXPR_BINARY_FIRST,
84         EXPR_BINARY_SUB,
85         EXPR_BINARY_MUL,
86         EXPR_BINARY_DIV,
87         EXPR_BINARY_MOD,
88         EXPR_BINARY_EQUAL,
89         EXPR_BINARY_NOTEQUAL,
90         EXPR_BINARY_LESS,
91         EXPR_BINARY_LESSEQUAL,
92         EXPR_BINARY_GREATER,
93         EXPR_BINARY_GREATEREQUAL,
94         EXPR_BINARY_BITWISE_AND,
95         EXPR_BINARY_BITWISE_OR,
96         EXPR_BINARY_BITWISE_XOR,
97         EXPR_BINARY_LOGICAL_AND,
98         EXPR_BINARY_LOGICAL_OR,
99         EXPR_BINARY_SHIFTLEFT,
100         EXPR_BINARY_SHIFTRIGHT,
101         EXPR_BINARY_ASSIGN,
102         EXPR_BINARY_MUL_ASSIGN,
103         EXPR_BINARY_DIV_ASSIGN,
104         EXPR_BINARY_MOD_ASSIGN,
105         EXPR_BINARY_ADD_ASSIGN,
106         EXPR_BINARY_SUB_ASSIGN,
107         EXPR_BINARY_SHIFTLEFT_ASSIGN,
108         EXPR_BINARY_SHIFTRIGHT_ASSIGN,
109         EXPR_BINARY_BITWISE_AND_ASSIGN,
110         EXPR_BINARY_BITWISE_XOR_ASSIGN,
111         EXPR_BINARY_BITWISE_OR_ASSIGN,
112         EXPR_BINARY_COMMA,
113
114         EXPR_BINARY_BUILTIN_EXPECT,
115         EXPR_BINARY_ISGREATER,
116         EXPR_BINARY_ISGREATEREQUAL,
117         EXPR_BINARY_ISLESS,
118         EXPR_BINARY_ISLESSEQUAL,
119         EXPR_BINARY_ISLESSGREATER,
120         EXPR_BINARY_ISUNORDERED,
121         EXPR_BINARY_LAST = EXPR_BINARY_ISUNORDERED,
122 } expression_kind_t;
123
124 typedef enum {
125         FUNCNAME_FUNCTION,           /**< C99 __func__, older __FUNCTION__ */
126         FUNCNAME_PRETTY_FUNCTION,    /**< GNUC __PRETTY_FUNCTION__ */
127         FUNCNAME_FUNCSIG,            /**< MS __FUNCSIG__ */
128         FUNCNAME_FUNCDNAME           /**< MS __FUNCDNAME__ */
129 } funcname_kind_t;
130
131 /* convenience macros */
132 #define EXPR_BINARY_CASES                  \
133         case EXPR_BINARY_ADD:                  \
134         case EXPR_BINARY_SUB:                  \
135         case EXPR_BINARY_MUL:                  \
136         case EXPR_BINARY_DIV:                  \
137         case EXPR_BINARY_MOD:                  \
138         case EXPR_BINARY_EQUAL:                \
139         case EXPR_BINARY_NOTEQUAL:             \
140         case EXPR_BINARY_LESS:                 \
141         case EXPR_BINARY_LESSEQUAL:            \
142         case EXPR_BINARY_GREATER:              \
143         case EXPR_BINARY_GREATEREQUAL:         \
144         case EXPR_BINARY_BITWISE_AND:          \
145         case EXPR_BINARY_BITWISE_OR:           \
146         case EXPR_BINARY_BITWISE_XOR:          \
147         case EXPR_BINARY_LOGICAL_AND:          \
148         case EXPR_BINARY_LOGICAL_OR:           \
149         case EXPR_BINARY_SHIFTLEFT:            \
150         case EXPR_BINARY_SHIFTRIGHT:           \
151         case EXPR_BINARY_ASSIGN:               \
152         case EXPR_BINARY_MUL_ASSIGN:           \
153         case EXPR_BINARY_DIV_ASSIGN:           \
154         case EXPR_BINARY_MOD_ASSIGN:           \
155         case EXPR_BINARY_ADD_ASSIGN:           \
156         case EXPR_BINARY_SUB_ASSIGN:           \
157         case EXPR_BINARY_SHIFTLEFT_ASSIGN:     \
158         case EXPR_BINARY_SHIFTRIGHT_ASSIGN:    \
159         case EXPR_BINARY_BITWISE_AND_ASSIGN:   \
160         case EXPR_BINARY_BITWISE_XOR_ASSIGN:   \
161         case EXPR_BINARY_BITWISE_OR_ASSIGN:    \
162         case EXPR_BINARY_COMMA:                \
163         case EXPR_BINARY_BUILTIN_EXPECT:       \
164         case EXPR_BINARY_ISGREATER:            \
165         case EXPR_BINARY_ISGREATEREQUAL:       \
166         case EXPR_BINARY_ISLESS:               \
167         case EXPR_BINARY_ISLESSEQUAL:          \
168         case EXPR_BINARY_ISLESSGREATER:        \
169         case EXPR_BINARY_ISUNORDERED:
170
171 #define EXPR_UNARY_CASES                   \
172         case EXPR_UNARY_NEGATE:                \
173         case EXPR_UNARY_PLUS:                  \
174         case EXPR_UNARY_BITWISE_NEGATE:        \
175         case EXPR_UNARY_NOT:                   \
176         case EXPR_UNARY_DEREFERENCE:           \
177         case EXPR_UNARY_TAKE_ADDRESS:          \
178         case EXPR_UNARY_POSTFIX_INCREMENT:     \
179         case EXPR_UNARY_POSTFIX_DECREMENT:     \
180         case EXPR_UNARY_PREFIX_INCREMENT:      \
181         case EXPR_UNARY_PREFIX_DECREMENT:      \
182         case EXPR_UNARY_CAST:                  \
183         case EXPR_UNARY_CAST_IMPLICIT:         \
184         case EXPR_UNARY_ASSUME:                \
185         case EXPR_UNARY_BITFIELD_EXTRACT:
186
187 /**
188  * A scope containing declarations.
189  */
190 struct scope_t {
191         declaration_t *declarations;      /**< List of declarations in this scope. */
192         declaration_t *last_declaration;  /**< last declaration in this scope. */
193 };
194
195 struct expression_base_t {
196         expression_kind_t   kind;
197         type_t             *type;
198         source_position_t   source_position;
199 };
200
201 struct const_expression_t {
202         expression_base_t  base;
203         union {
204                 long long      int_value;
205                 long double    float_value;
206                 string_t       character;
207                 wide_string_t  wide_character;
208         } v;
209         bool               is_ms_noop;  /**< True, if this constant is the result
210                                              of an microsoft __noop operator */
211 };
212
213 struct string_literal_expression_t {
214         expression_base_t  base;
215         string_t           value;
216 };
217
218 struct funcname_expression_t {
219         expression_base_t  base;
220         funcname_kind_t    kind;
221         string_t           value;     /**< the value once assigned. */
222 };
223
224 struct wide_string_literal_expression_t {
225         expression_base_t  base;
226         wide_string_t      value;
227 };
228
229 struct compound_literal_expression_t {
230         expression_base_t  base;
231         type_t            *type;
232         initializer_t     *initializer;
233 };
234
235 struct builtin_symbol_expression_t {
236         expression_base_t  base;
237         symbol_t          *symbol;
238 };
239
240 struct builtin_constant_expression_t {
241         expression_base_t  base;
242         expression_t      *value;
243 };
244
245 struct builtin_prefetch_expression_t {
246         expression_base_t  base;
247         expression_t      *adr;
248         expression_t      *rw;
249         expression_t      *locality;
250 };
251
252 struct reference_expression_t {
253         expression_base_t  base;
254         declaration_t     *declaration;
255 };
256
257 struct call_argument_t {
258         expression_t    *expression;
259         call_argument_t *next;
260 };
261
262 struct call_expression_t {
263         expression_base_t  base;
264         expression_t      *function;
265         call_argument_t   *arguments;
266 };
267
268 struct unary_expression_t {
269         expression_base_t  base;
270         expression_t      *value;
271 };
272
273 struct binary_expression_t {
274         expression_base_t  base;
275         expression_t      *left;
276         expression_t      *right;
277 };
278
279 struct select_expression_t {
280         expression_base_t  base;
281         expression_t      *compound;
282         symbol_t          *symbol;
283
284         declaration_t     *compound_entry;
285 };
286
287 struct array_access_expression_t {
288         expression_base_t  base;
289         expression_t      *array_ref;
290         expression_t      *index;
291         bool               flipped; /* index/ref was written in a 5[a] way */
292 };
293
294 struct typeprop_expression_t {
295         expression_base_t  base;
296         type_t            *type;
297         expression_t      *tp_expression;
298 };
299
300 struct designator_t {
301         source_position_t  source_position;
302         symbol_t          *symbol;
303         expression_t      *array_index;
304         designator_t      *next;
305 };
306
307 struct offsetof_expression_t {
308         expression_base_t  base;
309         type_t            *type;
310         designator_t      *designator;
311 };
312
313 struct va_start_expression_t {
314         expression_base_t  base;
315         expression_t      *ap;
316         declaration_t     *parameter;
317 };
318
319 struct va_arg_expression_t {
320         expression_base_t  base;
321         expression_t      *ap;
322 };
323
324 struct conditional_expression_t {
325         expression_base_t  base;
326         expression_t      *condition;
327         expression_t      *true_expression;
328         expression_t      *false_expression;
329 };
330
331 struct statement_expression_t {
332         expression_base_t  base;
333         statement_t       *statement;
334 };
335
336 struct classify_type_expression_t {
337         expression_base_t  base;
338         expression_t      *type_expression;
339 };
340
341 union expression_t {
342         expression_kind_t                kind;
343         expression_base_t                base;
344         const_expression_t               conste;
345         funcname_expression_t            funcname;
346         string_literal_expression_t      string;
347         wide_string_literal_expression_t wide_string;
348         compound_literal_expression_t    compound_literal;
349         builtin_symbol_expression_t      builtin_symbol;
350         builtin_constant_expression_t    builtin_constant;
351         builtin_prefetch_expression_t    builtin_prefetch;
352         reference_expression_t           reference;
353         call_expression_t                call;
354         unary_expression_t               unary;
355         binary_expression_t              binary;
356         select_expression_t              select;
357         array_access_expression_t        array_access;
358         typeprop_expression_t            typeprop;
359         offsetof_expression_t            offsetofe;
360         va_start_expression_t            va_starte;
361         va_arg_expression_t              va_arge;
362         conditional_expression_t         conditional;
363         statement_expression_t           statement;
364         classify_type_expression_t       classify_type;
365 };
366
367 typedef enum {
368         STORAGE_CLASS_NONE,
369         STORAGE_CLASS_EXTERN,
370         STORAGE_CLASS_STATIC,
371         STORAGE_CLASS_TYPEDEF,
372         STORAGE_CLASS_AUTO,
373         STORAGE_CLASS_REGISTER,
374         STORAGE_CLASS_ENUM_ENTRY,
375         STORAGE_CLASS_THREAD,
376         STORAGE_CLASS_THREAD_EXTERN,
377         STORAGE_CLASS_THREAD_STATIC,
378 } storage_class_tag_t;
379
380 typedef enum {
381         NAMESPACE_NORMAL,
382         NAMESPACE_STRUCT,
383         NAMESPACE_UNION,
384         NAMESPACE_ENUM,
385         NAMESPACE_LABEL,
386 } namespace_t;
387
388 typedef enum {
389         INITIALIZER_VALUE,
390         INITIALIZER_LIST,
391         INITIALIZER_STRING,
392         INITIALIZER_WIDE_STRING,
393         INITIALIZER_DESIGNATOR
394 } initializer_kind_t;
395
396 struct initializer_base_t {
397         initializer_kind_t kind;
398 };
399
400 struct initializer_value_t {
401         initializer_base_t  base;
402         expression_t       *value;
403 };
404
405 struct initializer_list_t {
406         initializer_base_t  base;
407         size_t              len;
408         initializer_t      *initializers[];
409 };
410
411 struct initializer_string_t {
412         initializer_base_t base;
413         string_t           string;
414 };
415
416 struct initializer_wide_string_t {
417         initializer_base_t  base;
418         wide_string_t       string;
419 };
420
421 struct initializer_designator_t {
422         initializer_base_t  base;
423         designator_t       *designator;
424 };
425
426 union initializer_t {
427         initializer_kind_t        kind;
428         initializer_base_t        base;
429         initializer_value_t       value;
430         initializer_list_t        list;
431         initializer_string_t      string;
432         initializer_wide_string_t wide_string;
433         initializer_designator_t  designator;
434 };
435
436 /**
437  * GNU attributes.
438  */
439 typedef enum gnu_attribute_kind_t {
440         GNU_AK_CONST,
441         GNU_AK_VOLATILE,
442         GNU_AK_CDECL,
443         GNU_AK_STDCALL,
444         GNU_AK_FASTCALL,
445         GNU_AK_DEPRECATED,
446         GNU_AK_NOINLINE,
447         GNU_AK_NORETURN,
448         GNU_AK_NAKED,
449         GNU_AK_PURE,
450         GNU_AK_ALWAYS_INLINE,
451         GNU_AK_MALLOC,
452         GNU_AK_WEAK,
453         GNU_AK_CONSTRUCTOR,
454         GNU_AK_DESTRUCTOR,
455         GNU_AK_NOTHROW,
456         GNU_AK_TRANSPARENT_UNION,
457         GNU_AK_COMMON,
458         GNU_AK_NOCOMMON,
459         GNU_AK_PACKED,
460         GNU_AK_SHARED,
461         GNU_AK_NOTSHARED,
462         GNU_AK_USED,
463         GNU_AK_UNUSED,
464         GNU_AK_NO_INSTRUMENT_FUNCTION,
465         GNU_AK_WARN_UNUSED_RESULT,
466         GNU_AK_LONGCALL,
467         GNU_AK_SHORTCALL,
468         GNU_AK_LONG_CALL,
469         GNU_AK_SHORT_CALL,
470         GNU_AK_FUNCTION_VECTOR,
471         GNU_AK_INTERRUPT,
472         GNU_AK_INTERRUPT_HANDLER,
473         GNU_AK_NMI_HANDLER,
474         GNU_AK_NESTING,
475         GNU_AK_NEAR,
476         GNU_AK_FAR,
477         GNU_AK_SIGNAL,
478         GNU_AK_EIGTHBIT_DATA,
479         GNU_AK_TINY_DATA,
480         GNU_AK_SAVEALL,
481         GNU_AK_FLATTEN,
482         GNU_AK_SSEREGPARM,
483         GNU_AK_EXTERNALLY_VISIBLE,
484         GNU_AK_RETURN_TWICE,
485         GNU_AK_MAY_ALIAS,
486         GNU_AK_MS_STRUCT,
487         GNU_AK_GCC_STRUCT,
488         GNU_AK_DLLIMPORT,
489         GNU_AK_DLLEXPORT,
490         GNU_AK_ALIGNED,
491         GNU_AK_ALIAS,
492         GNU_AK_SECTION,
493         GNU_AK_FORMAT,
494         GNU_AK_FORMAT_ARG,
495         GNU_AK_WEAKREF,
496         GNU_AK_NONNULL,
497         GNU_AK_TLS_MODEL,
498         GNU_AK_VISIBILITY,
499         GNU_AK_REGPARM,
500         GNU_AK_MODEL,
501         GNU_AK_MODE,
502         GNU_AK_TRAP_EXIT,
503         GNU_AK_SP_SWITCH,
504         GNU_AK_SENTINEL,
505         GNU_AK_LAST
506 } gnu_attribute_kind_t;
507
508 /**
509  * Extended microsoft modifier.
510  */
511 typedef enum {
512         DM_DLLIMPORT        = (1 <<  0),
513         DM_DLLEXPORT        = (1 <<  1),
514         DM_THREAD           = (1 <<  2),
515         DM_NAKED            = (1 <<  3),
516         DM_MICROSOFT_INLINE = (1 <<  4),
517         DM_FORCEINLINE      = (1 <<  5),
518         DM_SELECTANY        = (1 <<  6),
519         DM_NOTHROW          = (1 <<  7),
520         DM_NOVTABLE         = (1 <<  8),
521         DM_NORETURN         = (1 <<  9),
522         DM_NOINLINE         = (1 << 10),
523         DM_RESTRICT         = (1 << 11),
524         DM_NOALIAS          = (1 << 12)
525 } decl_modifier_t;
526
527 typedef unsigned short decl_modifiers_t;
528
529 struct declaration_t {
530         unsigned char       namespc;
531         unsigned char       declared_storage_class;
532         unsigned char       storage_class;
533         unsigned char       alignment;          /**< Alignment of the declaration, 0 for default. */
534         decl_modifiers_t    decl_modifiers;     /**< MS __declspec modifiers. */
535         const char         *deprecated_string;  /**< MS deprecated string if any. */
536         symbol_t           *get_property_sym;   /**< MS get property. */
537         symbol_t           *put_property_sym;   /**< MS put property. */
538         unsigned int        address_taken : 1;
539         unsigned int        is_inline     : 1;
540         unsigned int        used          : 1;  /**< Set if the declaration is used. */
541         unsigned int        deprecated    : 1;  /**< Microsoft or GNU deprecated attribute. */
542         type_t             *type;
543         symbol_t           *symbol;
544         source_position_t   source_position;
545         union {
546                 bool            complete;           /**< used to indicate wether struct/union types are already defined or if just the name is declared */
547                 statement_t    *statement;
548                 initializer_t  *initializer;
549                 expression_t   *enum_value;
550         } init;
551         scope_t             scope;              /**< The scope that this declaration opens. */
552         scope_t            *parent_scope;       /**< The parent scope where this declaration lives. */
553
554         /** next declaration in a scope */
555         declaration_t      *next;
556         /** next declaration with same symbol */
557         declaration_t      *symbol_next;
558
559         /* the following fields are used in ast2firm module */
560         unsigned char       declaration_kind;
561         union {
562                 unsigned int  value_number;
563                 ir_entity    *entity;
564                 ir_node      *block;
565                 ir_node      *vla_base;
566                 tarval       *enum_val;
567                 ir_type      *irtype;
568         } v;
569 };
570
571 typedef enum {
572         STATEMENT_INVALID,
573         STATEMENT_EMPTY,
574         STATEMENT_COMPOUND,
575         STATEMENT_RETURN,
576         STATEMENT_DECLARATION,
577         STATEMENT_IF,
578         STATEMENT_SWITCH,
579         STATEMENT_EXPRESSION,
580         STATEMENT_CONTINUE,
581         STATEMENT_BREAK,
582         STATEMENT_GOTO,
583         STATEMENT_LABEL,
584         STATEMENT_CASE_LABEL,
585         STATEMENT_WHILE,
586         STATEMENT_DO_WHILE,
587         STATEMENT_FOR,
588         STATEMENT_ASM,
589         STATEMENT_MS_TRY,
590         STATEMENT_LEAVE
591 } statement_kind_t;
592
593 struct statement_base_t {
594         statement_kind_t   kind;
595         statement_t       *next;
596         source_position_t  source_position;
597 };
598
599 struct invalid_statement_t {
600         statement_base_t  base;
601 };
602
603 struct empty_statement_t {
604         statement_base_t  base;
605 };
606
607 struct return_statement_t {
608         statement_base_t  base;
609         expression_t     *value;
610 };
611
612 struct compound_statement_t {
613         statement_base_t  base;
614         statement_t      *statements;
615         scope_t           scope;
616 };
617
618 struct declaration_statement_t {
619         statement_base_t  base;
620         declaration_t    *declarations_begin;
621         declaration_t    *declarations_end;
622 };
623
624 struct if_statement_t {
625         statement_base_t  base;
626         expression_t     *condition;
627         statement_t      *true_statement;
628         statement_t      *false_statement;
629 };
630
631 struct switch_statement_t {
632         statement_base_t       base;
633         expression_t           *expression;
634         statement_t            *body;
635         case_label_statement_t *first_case, *last_case;
636 };
637
638 struct goto_statement_t {
639         statement_base_t  base;
640         declaration_t    *label;     /**< The destination label. */
641         goto_statement_t *next;      /**< links all goto statements of a function */
642 };
643
644 struct case_label_statement_t {
645         statement_base_t        base;
646         expression_t           *expression;  /**< The case label expression, NULL for default label. */
647         expression_t           *end_range;   /**< For GNUC case a .. b: the end range expression, NULL else. */
648         statement_t            *statement;
649         case_label_statement_t *next; /**< link to the next case label in switch */
650 };
651
652 struct label_statement_t {
653         statement_base_t   base;
654         declaration_t     *label;
655         statement_t       *statement;
656         label_statement_t *next;    /**< links all label statements of a function */
657 };
658
659 struct expression_statement_t {
660         statement_base_t  base;
661         expression_t     *expression;
662 };
663
664 struct while_statement_t {
665         statement_base_t  base;
666         expression_t     *condition;
667         statement_t      *body;
668 };
669
670 struct do_while_statement_t {
671         statement_base_t  base;
672         expression_t     *condition;
673         statement_t      *body;
674 };
675
676 struct for_statement_t {
677         statement_base_t  base;
678         expression_t     *initialisation;
679         expression_t     *condition;
680         expression_t     *step;
681         statement_t      *body;
682         scope_t           scope;
683 };
684
685 struct asm_constraint_t {
686         string_t          constraints;
687         expression_t     *expression;
688         symbol_t         *symbol;
689         asm_constraint_t *next;
690 };
691
692 struct asm_clobber_t {
693         string_t       clobber;
694         asm_clobber_t *next;
695 };
696
697 struct asm_statement_t {
698         statement_base_t  base;
699         string_t          asm_text;
700         asm_constraint_t *inputs;
701         asm_constraint_t *outputs;
702         asm_clobber_t    *clobbers;
703         bool              is_volatile;
704 };
705
706 struct ms_try_statement_t {
707         statement_base_t  base;
708         statement_t      *try_statement;
709         expression_t     *except_expression; /**< non-null for except, NULL for finally */
710         statement_t      *final_statement;
711 };
712
713 struct leave_statement_t {
714         statement_base_t  base;
715 };
716
717 union statement_t {
718         statement_kind_t         kind;
719         statement_base_t         base;
720         return_statement_t       returns;
721         compound_statement_t     compound;
722         declaration_statement_t  declaration;
723         if_statement_t           ifs;
724         switch_statement_t       switchs;
725         goto_statement_t         gotos;
726         case_label_statement_t   case_label;
727         label_statement_t        label;
728         expression_statement_t   expression;
729         while_statement_t        whiles;
730         do_while_statement_t     do_while;
731         for_statement_t          fors;
732         asm_statement_t          asms;
733         ms_try_statement_t       ms_try;
734         leave_statement_t        leave;
735 };
736
737 struct translation_unit_t {
738         scope_t scope;
739 };
740
741 static inline
742 void *_allocate_ast(size_t size)
743 {
744         return obstack_alloc(&ast_obstack, size);
745 }
746
747 static inline
748 bool is_invalid_expression(expression_t *expression)
749 {
750         return expression->base.kind == EXPR_INVALID;
751 }
752
753 static inline
754 bool is_invalid_statement(statement_t *statement)
755 {
756         return statement->base.kind == STATEMENT_INVALID;
757 }
758
759
760 #define allocate_ast(size)                 _allocate_ast(size)
761
762 #endif