Backup, Decl,Type parsing enum,structs etc.
This commit is contained in:
33
print.c
33
print.c
@@ -1,8 +1,4 @@
|
||||
|
||||
global FILE *global_output_file;
|
||||
#define lex_print(...) fprintf(global_output_file, __VA_ARGS__)
|
||||
#define lex_new_line() lex_print("\n")
|
||||
|
||||
function void
|
||||
tokens_print(Tokens tokens){
|
||||
lex_print("\n== Token count = %d\n", (S32)tokens.len);
|
||||
@@ -30,6 +26,14 @@ type_print(Type *type){
|
||||
type_print(type->pointer);
|
||||
lex_print("*");
|
||||
} break;
|
||||
case TK_Function:{
|
||||
type_print(type->decl->func_val.return_type);
|
||||
lex_print("(");
|
||||
for(Decl *n = type->decl->func_val.first; n; n=n->next){
|
||||
token_print(n->token); // @Todo(Krzosa):
|
||||
}
|
||||
lex_print(")");
|
||||
} break;
|
||||
case TK_Array:{
|
||||
type_print(type->array.pointer);
|
||||
lex_print("[");
|
||||
@@ -110,10 +114,29 @@ expr_print(Expr *expr){
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function void
|
||||
decl_print(Decl *decl){
|
||||
switch(decl->kind) {
|
||||
|
||||
case DK_Union: lex_print("union");
|
||||
case DK_Struct:{
|
||||
lex_print("struct %s{\n", decl->name.s.str);
|
||||
for(Decl *n = decl->aggregate_val.first; n; n=n->next){
|
||||
decl_print(n);
|
||||
lex_print(";\n");
|
||||
}
|
||||
lex_print("}\n");
|
||||
} break;
|
||||
|
||||
case DK_Variable:{
|
||||
type_print(decl->var_val.type);
|
||||
lex_print(" %s", decl->name.s.str);
|
||||
if(decl->var_val.expr){
|
||||
lex_print(" = ");
|
||||
expr_print(decl->var_val.expr);
|
||||
}
|
||||
} break;
|
||||
|
||||
case DK_Enum: {
|
||||
lex_print("enum %s{\n", decl->name.s.str);
|
||||
for(Decl_Enum_Child *n = decl->enum_val.first; n; n=n->next){
|
||||
|
||||
Reference in New Issue
Block a user