#ifndef AST_H #define AST_H #include "collection.h" typedef struct { int line; int col; } Loc; typedef enum : unsigned int { AstSpec_Typedef = 1 << 0, // AstSpec_Constexpr = 1 << 1, // AstSpec_Auto = 1 << 2, // AstSpec_Register = 1 << 3, AstSpec_Static = 1 << 4, // AstSpec_Extern = 1 << 5, // AstSpec_ThreadLocal = 1 << 6, AstSpec_Const = 1 << 7, // AstSpec_Volatile = 1 << 8, // AstSpec_Restrict = 1 << 9, // AstSpec_Atomic = 1 << 10, AstSpec_Inline = 1 << 11, } AstSpec; typedef enum { AstDeclar_Ident, AstDeclar_Pointer, AstDeclar_Array, } AstDeclarTy; typedef struct AstDeclar AstDeclar; struct AstDeclar { AstDeclarTy ty; Loc loc; union { char* ident; struct { AstDeclar* declar; AstSpec spec; } pointer; }; }; typedef struct { AstSpec spec; unsigned long type_id; ARRAY_FIELD(AstDeclar, declars); Loc loc; } AstDecl; typedef enum { AstStmt_Decl, } AstStmtTy; typedef struct { AstStmtTy ty; union { AstDecl decl; }; } AstStmt; #endif