226 lines
3.1 KiB
C
226 lines
3.1 KiB
C
|
|
typedef struct Typespec Typespec;
|
|
|
|
typedef struct Note Note;
|
|
|
|
|
|
|
|
typedef struct Decl_Function_Arg Decl_Function_Arg;
|
|
|
|
typedef struct Decl_Enum_Child Decl_Enum_Child;
|
|
|
|
typedef struct Decl Decl;
|
|
|
|
|
|
typedef struct Stmt_If Stmt_If;
|
|
|
|
typedef struct Stmt Stmt;
|
|
|
|
|
|
typedef struct Pointer Pointer;
|
|
|
|
typedef struct Pointer_Bucket Pointer_Bucket;
|
|
|
|
typedef struct Pointer_Array Pointer_Array;
|
|
|
|
|
|
|
|
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;
|
|
Typespec (*base);
|
|
struct{
|
|
Typespec (*first);
|
|
Typespec (*last);
|
|
Typespec (*ret);
|
|
}function_spec;
|
|
struct{
|
|
Typespec (*base);
|
|
Expr (*size);
|
|
}array_spec;
|
|
};
|
|
};
|
|
|
|
struct Note{
|
|
Token (*pos);
|
|
Intern_String name;
|
|
Expr (*expr);
|
|
Note (*next);
|
|
Note (*first);
|
|
Note (*last);
|
|
};
|
|
|
|
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_Nested,
|
|
STRUCT_Base,
|
|
}Decl_Struct_Kind;
|
|
|
|
struct Decl_Function_Arg{
|
|
Decl_Function_Arg (*next);
|
|
Intern_String name;
|
|
Token (*pos);
|
|
Typespec (*typespec);
|
|
};
|
|
|
|
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 (*first);
|
|
Decl (*last);
|
|
Decl_Struct_Kind kind;
|
|
}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);
|
|
Stmt (*body);
|
|
}function_decl;
|
|
struct{
|
|
Decl (*first);
|
|
Decl (*last);
|
|
}list;
|
|
};
|
|
};
|
|
|
|
typedef enum Stmt_Kind{
|
|
STMT_None,
|
|
STMT_Decl,
|
|
STMT_Expr,
|
|
STMT_List,
|
|
STMT_Return,
|
|
STMT_If,
|
|
STMT_For,
|
|
}Stmt_Kind;
|
|
|
|
struct Stmt_If{
|
|
Stmt_If (*next);
|
|
Expr (*cond);
|
|
Stmt (*body);
|
|
};
|
|
|
|
struct Stmt{
|
|
Stmt_Kind kind;
|
|
Stmt (*next);
|
|
Token (*pos);
|
|
union{
|
|
Stmt_If stmt_if;
|
|
Decl (*decl);
|
|
Expr (*expr);
|
|
struct{
|
|
Stmt (*first);
|
|
Stmt (*last);
|
|
}list;
|
|
struct{
|
|
Expr (*expr);
|
|
}ret;
|
|
};
|
|
};
|
|
|
|
typedef enum Pointer_Kind{
|
|
PK_None,
|
|
PK_Typespec,
|
|
PK_Expr,
|
|
PK_Decl,
|
|
PK_Stmt,
|
|
PK_Enum_Child,
|
|
PK_Func_Arg,
|
|
PK_Intern_String,
|
|
}Pointer_Kind;
|
|
|
|
struct Pointer{
|
|
Pointer_Kind kind;
|
|
union{
|
|
Typespec (*typespec);
|
|
Decl (*decl);
|
|
Expr (*expr);
|
|
Stmt (*stmt);
|
|
Decl_Function_Arg (*func_arg);
|
|
Decl_Enum_Child (*enum_child);
|
|
Intern_String (*string);
|
|
};
|
|
};
|
|
|
|
struct Pointer_Bucket{
|
|
Pointer_Bucket (*next);
|
|
Pointer (data[4096]);
|
|
};
|
|
|
|
struct Pointer_Array{
|
|
Pointer_Bucket first;
|
|
Pointer_Bucket (*last);
|
|
S64 len;
|
|
S64 block;
|
|
Arena (*arena);
|
|
Pointer_Bucket (*iter_bucket);
|
|
S64 iter_len;
|
|
S64 iter_block;
|
|
};
|
|
|
|
typedef enum Gather_Flag{
|
|
GATHER_None = 0,
|
|
GATHER_Typespec = 1,
|
|
GATHER_Expr = 2,
|
|
GATHER_Decl = 4,
|
|
GATHER_Stmt = 8,
|
|
GATHER_Enum_Child = 16,
|
|
GATHER_Func_Arg = 32,
|
|
}Gather_Flag;
|
|
|
|
typedef enum Traversal_Flag{
|
|
TRAVERS_None,
|
|
TRAVERS_Typespec = 1,
|
|
TRAVERS_Expr = 2,
|
|
TRAVERS_Stmt = 8,
|
|
TRAVERS_All = ((TRAVERS_Typespec|TRAVERS_Expr)|TRAVERS_Stmt),
|
|
}Traversal_Flag;
|
|
|