202 lines
3.8 KiB
C
202 lines
3.8 KiB
C
#if 0
|
|
//-----------------------------------------------------------------------------
|
|
// Type specifiers
|
|
//-----------------------------------------------------------------------------
|
|
@prefix="TS_" Typespec_Kind :: enum{ None, Name, Pointer, Array, Function }
|
|
Typespec :: struct{
|
|
kind: Typespec_Kind;
|
|
next: Typespec*;
|
|
pos : Token*;
|
|
|
|
union{
|
|
name: Intern_String;
|
|
base: Typespec*;
|
|
function_spec: struct{
|
|
first: Typespec*;
|
|
last : Typespec*;
|
|
ret : Typespec*;
|
|
}
|
|
array_spec: struct{
|
|
base: Typespec*;
|
|
size: Expr*;
|
|
}
|
|
}
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Notes
|
|
//-----------------------------------------------------------------------------
|
|
Note :: struct{
|
|
pos : Token*;
|
|
name: Intern_String;
|
|
expr: Expr*;
|
|
|
|
next : Note*;
|
|
first: Note*;
|
|
last : Note*;
|
|
};
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Declarations
|
|
//-----------------------------------------------------------------------------
|
|
@prefix = "DECL_" Decl_Kind :: enum { None, Struct, Union, Enum, Variable, Typedef, Function, List }
|
|
@prefix="STRUCT_" Decl_Struct_Kind :: enum { Nested, Base }
|
|
|
|
Decl_Function_Arg :: struct{
|
|
next: Decl_Function_Arg *;
|
|
name: Intern_String;
|
|
pos : Token *;
|
|
typespec: Typespec *;
|
|
}
|
|
|
|
Decl_Enum_Child :: struct{
|
|
next: Decl_Enum_Child *;
|
|
name: Intern_String;
|
|
pos : Token *;
|
|
expr: Expr *;
|
|
|
|
first_note: Note *;
|
|
last_note : Note *;
|
|
};
|
|
|
|
Decl :: struct{
|
|
kind: Decl_Kind;
|
|
next: Decl *;
|
|
|
|
name: Intern_String;
|
|
pos : Token *;
|
|
|
|
first_note: Note *;
|
|
last_note : Note *;
|
|
|
|
union{
|
|
enum_decl: struct{
|
|
first: Decl_Enum_Child *;
|
|
last: Decl_Enum_Child *;
|
|
typespec: Typespec *;
|
|
}
|
|
struct_decl: struct{
|
|
first: Decl *;
|
|
last: Decl *;
|
|
kind: Decl_Struct_Kind ;
|
|
}
|
|
variable_decl: struct{
|
|
type: Typespec *;
|
|
expr: Expr *;
|
|
}
|
|
typedef_decl: struct{
|
|
type: Typespec *;
|
|
}
|
|
function_decl: struct{
|
|
first: Decl_Function_Arg *;
|
|
last : Decl_Function_Arg *;
|
|
ret: Typespec *;
|
|
body : Stmt*;
|
|
}
|
|
list: struct{
|
|
first: Decl *;
|
|
last: Decl *;
|
|
}
|
|
}
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Statements
|
|
//-----------------------------------------------------------------------------
|
|
@prefix="STMT_" Stmt_Kind :: enum{ None, Decl, Expr, List, Return, If, For}
|
|
|
|
Stmt_If :: struct {
|
|
next: Stmt_If*;
|
|
cond: Expr*;
|
|
body: Stmt*;
|
|
}
|
|
|
|
Stmt :: struct {
|
|
kind: Stmt_Kind;
|
|
next: Stmt*;
|
|
pos : Token*;
|
|
|
|
union{
|
|
stmt_if: Stmt_If;
|
|
decl: Decl*;
|
|
expr: Expr*;
|
|
list: struct{
|
|
first: Stmt*;
|
|
last : Stmt*;
|
|
}
|
|
ret: struct{
|
|
expr: Expr*;
|
|
}
|
|
}
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Gather
|
|
//-----------------------------------------------------------------------------
|
|
|
|
@prefix="PK_"
|
|
Pointer_Kind::enum{
|
|
None,
|
|
Typespec,
|
|
Expr,
|
|
Decl,
|
|
Stmt,
|
|
Enum_Child,
|
|
Func_Arg,
|
|
Intern_String
|
|
}
|
|
|
|
Pointer::struct{
|
|
kind: Pointer_Kind;
|
|
union {
|
|
typespec: Typespec *;
|
|
decl: Decl *;
|
|
expr: Expr *;
|
|
stmt: Stmt *;
|
|
func_arg: Decl_Function_Arg*;
|
|
enum_child: Decl_Enum_Child*;
|
|
string: Intern_String *;
|
|
}
|
|
}
|
|
|
|
Pointer_Bucket::struct{
|
|
next: Pointer_Bucket*;
|
|
data: Pointer[4096];
|
|
}
|
|
|
|
Pointer_Array::struct{
|
|
first: Pointer_Bucket;
|
|
last : Pointer_Bucket*;
|
|
len : S64;
|
|
block: S64;
|
|
arena: Arena*;
|
|
|
|
iter_bucket: Pointer_Bucket*;
|
|
iter_len: S64;
|
|
iter_block: S64;
|
|
}
|
|
|
|
@prefix="GATHER_"
|
|
Gather_Flag::enum{
|
|
None = 0,
|
|
Typespec = 1,
|
|
Expr = 2,
|
|
Decl = 4,
|
|
Stmt = 8,
|
|
Enum_Child = 16,
|
|
Func_Arg = 32,
|
|
}
|
|
|
|
@prefix="TRAVERS_"
|
|
Traversal_Flag :: enum{
|
|
None,
|
|
Typespec = 1,
|
|
Expr = 2,
|
|
//Decl = 4,
|
|
Stmt = 8,
|
|
All = TRAVERS_Typespec | TRAVERS_Expr | TRAVERS_Stmt,
|
|
}
|
|
|
|
#endif
|
|
#include "generated_ast.h"
|