C codegen

This commit is contained in:
Krzosa Karol
2022-05-03 20:08:13 +02:00
parent 8c04044ea2
commit 557dde1936
11 changed files with 573 additions and 281 deletions

38
test.cc
View File

@@ -1,5 +1,11 @@
#if 0
OpenGL :: struct{
glVertexAttribPointer: (GLuint, GLint, GLenum, GLboolean, GLsizei, GLvoid*);
glBindTexture: (GLenum, GLuint);
glDrawArrays: (GLenum, GLint, GLsizei);
}
OS_Memory::struct{
data: void*;
commit: SizeU;
@@ -89,11 +95,11 @@ Token_Kind::enum{
Token::struct{
kind:Token_Kind;
@using string:String;
val: union{
integer:S64;
error:String;
intern:Intern_String;
};
union{
integer_val:S64;
error_val:String;
intern_val:Intern_String;
}
file:String;
line:S64;
line_begin:U8*;
@@ -128,36 +134,36 @@ Expr:: struct{
kind: Expr_Kind;
token: Token*;
next : Expr*;
_: union{
union{
cast_val: struct{
type: AST_Node*;
expr: Expr*;
};
}
list: struct{
first: Expr *;
last: Expr *;
};
}
call: struct{
atom: Expr *;
list: Expr *;
};
}
index: struct{
atom: Expr *;
index: Expr *;
};
}
unary: struct{
expr: Expr* ;
};
}
binary: struct{
left: Expr* ;
right: Expr* ;
};
}
ternary: struct{
cond: Expr* ;
on_true: Expr*;
on_false: Expr*;
};
};
}
}
}
@prefix="AK_"
@@ -190,13 +196,13 @@ AST_Node::struct{
first_child: AST_Node*;
last_child: AST_Node*;
_:union{
union{
base_type_size: SizeU;
pointer: AST_Node*;
typedef_type: AST_Node*;
variable_type: AST_Node*;
func_return_type: AST_Node*;
};
}
}
Parser_Error :: struct{