AST idea
This commit is contained in:
139
test.cc
139
test.cc
@@ -1,57 +1,23 @@
|
||||
#if 0
|
||||
Thing :: const: *U32 = 0;
|
||||
CONST_VAL::const = 185210591;
|
||||
|
||||
|
||||
@register
|
||||
@param_expr(size)
|
||||
@param_type(Type)
|
||||
test::struct{
|
||||
Array_Block::struct{
|
||||
next: Array_Block*;
|
||||
data: Type[size];
|
||||
}
|
||||
|
||||
@inline Array::struct{
|
||||
first: Array_Block;
|
||||
last : Array_Block*;
|
||||
block: S64;
|
||||
len : S64;
|
||||
}
|
||||
|
||||
array_make::(arena: Arena*) Type {
|
||||
thing: Test_Type;
|
||||
result: Type;
|
||||
result.arena = arena;
|
||||
result.last = &result.first;
|
||||
return result;
|
||||
}
|
||||
|
||||
array_push::(array: Array*, item: Type*){
|
||||
if array->len+1 > size{
|
||||
assert(array->len);
|
||||
block: Array_Block* = cast(Thing)arena_push_struct(array->arena, sizeof(:Array_Block));
|
||||
array->last = array->last.next = block;
|
||||
array->len = 0;
|
||||
array->block += 1;
|
||||
}
|
||||
array->last.data[array->len++] = *item;
|
||||
}
|
||||
}
|
||||
new_function::(Thing:[32]U32): U32;
|
||||
|
||||
@test(size = 4096)
|
||||
OpenGL :: struct{
|
||||
glVertexAttribPointer: (GLuint, GLint, GLenum, GLboolean, GLsizei, GLvoid*);
|
||||
glVertexAttribPointer: (GLuint, GLint, GLenum, GLboolean, GLsizei, *GLvoid);
|
||||
glBindTexture: (GLenum, GLuint);
|
||||
glDrawArrays: (GLenum, GLint, GLsizei);
|
||||
|
||||
test_array: int*[10];
|
||||
test_array: [10]*int;
|
||||
|
||||
thing : Things*;
|
||||
thing : *Things;
|
||||
thing_cap: S64;
|
||||
thing_len: S64;
|
||||
}
|
||||
|
||||
OS_Memory::struct{
|
||||
data: void*;
|
||||
data: *void;
|
||||
commit: SizeU;
|
||||
reserve: SizeU;
|
||||
}
|
||||
@@ -63,10 +29,11 @@ Arena::struct{
|
||||
}
|
||||
|
||||
String::struct{
|
||||
str: U8*;
|
||||
str: *U8;
|
||||
len: S64;
|
||||
}
|
||||
Intern_String::typedef String;
|
||||
Intern_String::typedef = String;
|
||||
//CONST_VALUE::const = 121591;
|
||||
|
||||
@stringify
|
||||
@prefix="TK_"
|
||||
@@ -147,12 +114,12 @@ Token::struct{
|
||||
}
|
||||
file:String;
|
||||
line:S64;
|
||||
line_begin:U8*;
|
||||
line_begin:*U8;
|
||||
}
|
||||
|
||||
Lex_Stream::struct{
|
||||
stream: U8*;
|
||||
line_begin: U8*;
|
||||
stream: *U8;
|
||||
line_begin: *U8;
|
||||
filename: String;
|
||||
line: S64;
|
||||
}
|
||||
@@ -172,36 +139,36 @@ Expr_Kind::enum{
|
||||
|
||||
Expr:: struct{
|
||||
kind: Expr_Kind;
|
||||
token: Token*;
|
||||
next : Expr*;
|
||||
token: *Token;
|
||||
next : *Expr;
|
||||
union{
|
||||
cast_val: struct{
|
||||
type: AST_Node*;
|
||||
expr: Expr*;
|
||||
type: *AST_Node;
|
||||
expr: *Expr;
|
||||
}
|
||||
list: struct{
|
||||
first: Expr *;
|
||||
last: Expr *;
|
||||
first: *Expr;
|
||||
last: *Expr;
|
||||
}
|
||||
call: struct{
|
||||
atom: Expr *;
|
||||
list: Expr *;
|
||||
atom: *Expr;
|
||||
list: *Expr;
|
||||
}
|
||||
index: struct{
|
||||
atom: Expr *;
|
||||
index: Expr *;
|
||||
atom: *Expr;
|
||||
index: *Expr;
|
||||
}
|
||||
unary: struct{
|
||||
expr: Expr* ;
|
||||
expr: *Expr ;
|
||||
}
|
||||
binary: struct{
|
||||
left: Expr* ;
|
||||
right: Expr* ;
|
||||
left: *Expr ;
|
||||
right: *Expr ;
|
||||
}
|
||||
ternary: struct{
|
||||
cond: Expr* ;
|
||||
on_true: Expr*;
|
||||
on_false: Expr*;
|
||||
cond: *Expr ;
|
||||
on_true: *Expr;
|
||||
on_false: *Expr;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -225,36 +192,36 @@ AST_Kind::enum{
|
||||
|
||||
AST_Node::struct{
|
||||
kind: AST_Kind;
|
||||
pos : Token*;
|
||||
pos : *Token;
|
||||
name: Intern_String;
|
||||
|
||||
next: AST_Node*;
|
||||
next_scope: AST_Node*;
|
||||
next: *AST_Node;
|
||||
next_scope: *AST_Node;
|
||||
|
||||
first_note: AST_Node*;
|
||||
last_note: AST_Node*;
|
||||
first_note: *AST_Node;
|
||||
last_note: *AST_Node;
|
||||
|
||||
first_child: AST_Node*;
|
||||
last_child: AST_Node*;
|
||||
first_child: *AST_Node;
|
||||
last_child: *AST_Node;
|
||||
union{
|
||||
base_type_size: SizeU;
|
||||
pointer: AST_Node*;
|
||||
typedef_type: AST_Node*;
|
||||
variable_type: AST_Node*;
|
||||
func_return_type: AST_Node*;
|
||||
pointer: *AST_Node;
|
||||
typedef_type: *AST_Node;
|
||||
variable_type: *AST_Node;
|
||||
func_return_type: *AST_Node;
|
||||
}
|
||||
}
|
||||
|
||||
Parser_Error :: struct{
|
||||
next: Parser_Error*;
|
||||
next: *Parser_Error;
|
||||
message: String;
|
||||
token : Token *;
|
||||
token : *Token;
|
||||
}
|
||||
|
||||
Scope :: struct{
|
||||
next : Scope*;
|
||||
first: AST_Node*;
|
||||
last : AST_Node*;
|
||||
next : *Scope;
|
||||
first: *AST_Node;
|
||||
last : *AST_Node;
|
||||
}
|
||||
|
||||
|
||||
@@ -263,21 +230,21 @@ Parser :: struct{
|
||||
intern_table_arena: Arena;
|
||||
symbol_table_arena: Arena;
|
||||
|
||||
scope_free_list: Scope *;
|
||||
scope_stack: Scope *;
|
||||
global_scope: Scope *;
|
||||
scope_free_list: Scope;
|
||||
scope_stack: Scope;
|
||||
global_scope: Scope;
|
||||
|
||||
symbols_inserted: S64;
|
||||
symbols_count: S64;
|
||||
symbols: AST_Node *;
|
||||
symbols: AST_Node;
|
||||
|
||||
interns: Intern_String *;
|
||||
interns: Intern_String;
|
||||
interns_in_bytes: S64;
|
||||
interns_inserted: S64;
|
||||
interns_count: S64;
|
||||
|
||||
first_keyword: U8 *;
|
||||
last_keyword: U8 *;
|
||||
first_keyword: U8;
|
||||
last_keyword: U8;
|
||||
|
||||
//@map(type="sparse") symbols: AST_Node;
|
||||
|
||||
@@ -305,5 +272,3 @@ struct_type_lower_var_name_lower_push(struct_type *parent, var_type *child){
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user