165 lines
3.0 KiB
C
165 lines
3.0 KiB
C
typedef struct Decl_Enum_Child Decl_Enum_Child;
|
|
typedef struct Decl_Function_Arg Decl_Function_Arg;
|
|
typedef struct Typespec Typespec;
|
|
typedef struct Decl Decl;
|
|
typedef struct Note Note;
|
|
typedef struct Stmt Stmt;
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Type specifier
|
|
//-----------------------------------------------------------------------------
|
|
typedef enum Typespec_Kind{
|
|
TS_None,
|
|
TS_Name,
|
|
TS_Pointer,
|
|
TS_Array,
|
|
TS_Function,
|
|
}Typespec_Kind;
|
|
|
|
struct Typespec{
|
|
Typespec_Kind kind;
|
|
Typespec *next;
|
|
Token *pos;
|
|
union{
|
|
Intern_String name;
|
|
struct{
|
|
Typespec *first;
|
|
Typespec *last;
|
|
Typespec *ret;
|
|
}function_spec;
|
|
struct{
|
|
Typespec *base;
|
|
Expr *size;
|
|
}array_spec;
|
|
Typespec *base;
|
|
};
|
|
};
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Notes
|
|
//-----------------------------------------------------------------------------
|
|
struct Note{
|
|
Token *pos;
|
|
Intern_String name;
|
|
Expr *expr;
|
|
|
|
Note *next;
|
|
Note *first;
|
|
Note *last;
|
|
};
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Declarations
|
|
//-----------------------------------------------------------------------------
|
|
typedef enum Decl_Kind{
|
|
DECL_None,
|
|
DECL_Struct,
|
|
DECL_Union,
|
|
DECL_Enum,
|
|
DECL_Variable,
|
|
DECL_Typedef,
|
|
DECL_Function,
|
|
DECL_List,
|
|
}Decl_Kind;
|
|
|
|
typedef enum Decl_Struct_Kind{
|
|
STRUCT_Base ,
|
|
STRUCT_Nested,
|
|
}Decl_Struct_Kind;
|
|
|
|
struct Decl_Function_Arg{
|
|
Decl_Function_Arg *next;
|
|
Intern_String name;
|
|
Typespec *typespec;
|
|
Token *pos;
|
|
};
|
|
|
|
struct Decl_Enum_Child{
|
|
Decl_Enum_Child *next;
|
|
Intern_String name;
|
|
Token *pos;
|
|
Expr *expr;
|
|
|
|
Note *first_note;
|
|
Note *last_note;
|
|
};
|
|
|
|
struct Decl{
|
|
Decl_Kind kind;
|
|
Decl *next;
|
|
|
|
Intern_String name;
|
|
Token *pos;
|
|
|
|
Note *first_note;
|
|
Note *last_note;
|
|
|
|
union{
|
|
struct{
|
|
Decl_Enum_Child *first;
|
|
Decl_Enum_Child *last;
|
|
Typespec *typespec;
|
|
}enum_decl;
|
|
struct{
|
|
Decl_Struct_Kind kind;
|
|
Decl *first;
|
|
Decl *last;
|
|
} struct_decl;
|
|
struct{
|
|
Typespec *type;
|
|
Expr *expr;
|
|
}variable_decl;
|
|
struct{
|
|
Typespec *type;
|
|
}typedef_decl;
|
|
struct{
|
|
Decl_Function_Arg *first;
|
|
Decl_Function_Arg *last ;
|
|
Typespec *ret;
|
|
}function_decl;
|
|
struct{
|
|
Decl *first;
|
|
Decl *last;
|
|
}list;
|
|
};
|
|
};
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Statements
|
|
//-----------------------------------------------------------------------------
|
|
typedef enum Stmt_Kind{
|
|
STMT_None,
|
|
STMT_Decl,
|
|
STMT_Expr,
|
|
STMT_Return,
|
|
STMT_If,
|
|
STMT_For,
|
|
}Stmt_Kind;
|
|
|
|
typedef struct Stmt_List Stmt_List;
|
|
struct Stmt_List{
|
|
Stmt *first;
|
|
Stmt *last;
|
|
};
|
|
|
|
typedef struct Stmt_If Stmt_If;
|
|
struct Stmt_If{
|
|
Stmt_If *next;
|
|
Expr *expr;
|
|
union{
|
|
struct{Stmt *first; Stmt *last;};
|
|
Stmt_List *list;
|
|
};
|
|
};
|
|
|
|
struct Stmt{
|
|
Stmt_Kind kind;
|
|
Stmt *next;
|
|
union{
|
|
Decl *decl;
|
|
Expr *expr;
|
|
Stmt_If *if_stmt;
|
|
Stmt_List *list;
|
|
};
|
|
};
|