Delete previous progress
This commit is contained in:
77
main.c
77
main.c
@@ -7,7 +7,6 @@
|
||||
#include "memory.h"
|
||||
|
||||
#include "lex.h"
|
||||
#include "ast.h"
|
||||
#include "parser.h"
|
||||
#include "expr.h"
|
||||
|
||||
@@ -22,10 +21,8 @@ global FILE *global_output_file;
|
||||
|
||||
#include "lex.c"
|
||||
#include "expr.c"
|
||||
#include "ast.c"
|
||||
#include "parse_expr.c"
|
||||
#include "parse_decl.c"
|
||||
#include "print.c"
|
||||
|
||||
function void
|
||||
lex_test(){
|
||||
@@ -86,52 +83,19 @@ parser_test(){
|
||||
lit("5--"), // @Todo(Krzosa):
|
||||
lit("-5"),
|
||||
lit("(+5)"),
|
||||
lit("(S64)5"),
|
||||
lit("(S64)5+3"),
|
||||
lit("cast(S64)5"),
|
||||
lit("cast(S64)5+3"),
|
||||
lit("534>43?435:42"),
|
||||
lit("(534>43?435:42,234,(S64)42,Thing[10][2],Thing(1,2))"),
|
||||
lit("(534>43?435:42,234,cast(S64)42,Thing[10][2],Thing(1,2))"),
|
||||
};
|
||||
for(S64 i = 0; i < buff_cap(exprs); i++){
|
||||
parser_lex_stream(&p, exprs[i], lit("File"));
|
||||
Expr *expr = parse_expr(&p);
|
||||
assert(expr);
|
||||
//expr_print(expr);
|
||||
//lex_print("\n");
|
||||
expr_print(expr);
|
||||
lex_print("\n");
|
||||
}
|
||||
|
||||
String decls = os_read_file(lit("ast.h"));
|
||||
parser_lex_stream(&p, decls, lit("File"));
|
||||
AST_Node *node = parse(&p);
|
||||
assert(node->first_child);
|
||||
assert(node->last_child);
|
||||
ast_print(node);
|
||||
|
||||
for(AST_Node *n = node->first_child; n; n=n->next){
|
||||
if(n->kind == AK_Enum){
|
||||
AST_Node *prefix = ast_find_note(n, lit("prefix"));
|
||||
lex_print("global String %s_metadata[] = {\n", n->name.s.str);
|
||||
for(AST_Node *member = n->first_child; member; member=member->next){
|
||||
lex_print("[");
|
||||
if(prefix) expr_print(prefix->expr);
|
||||
lex_print("%s] = ", member->name.s.str);
|
||||
AST_Node *str = ast_find_note(member, lit("str"));
|
||||
lex_print("lit(\"");
|
||||
if(str){
|
||||
expr_print(str->expr);
|
||||
}
|
||||
else {
|
||||
lex_print("%s", member->name.s.str);
|
||||
}
|
||||
lex_print("\")");
|
||||
lex_print(",\n");
|
||||
}
|
||||
lex_print("};\n");
|
||||
|
||||
}
|
||||
else if(n->kind == AK_Struct){
|
||||
gen_struct(n, (Intern_String){});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function S32
|
||||
@@ -141,37 +105,6 @@ os_main(){
|
||||
lex_test();
|
||||
parser_test();
|
||||
|
||||
String_Map maps[] = {
|
||||
{lit("cap"), lit("cap")},
|
||||
{lit("len"), lit("len")},
|
||||
{lit("data"), lit("tokens")},
|
||||
{lit("parent_type"), lit("Tokens")},
|
||||
{lit("parent_type_lower"), lit("tokens")},
|
||||
{lit("var_type_lower"), lit("token")},
|
||||
{lit("var_type"), lit("Token")},
|
||||
{lit("var_name"), lit("tokens")},
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
String keywords[]={
|
||||
lit("S64"),
|
||||
lit("U64"),
|
||||
lit("void"),
|
||||
lit("SizeU"),
|
||||
lit("struct"),
|
||||
lit("union"),
|
||||
lit("function"),
|
||||
lit("global"),
|
||||
};
|
||||
|
||||
for(S64 i = 0; i < buff_cap(keywords); i++){
|
||||
lex_print("global Intern_String keyword_%s;\n", keywords[i].str);
|
||||
}
|
||||
for(S64 i = 0; i < buff_cap(keywords); i++){
|
||||
lex_print("keyword_%s = intern_string(p, lit(\"%s\"));\n", keywords[i].str, keywords[i].str);
|
||||
}
|
||||
*/
|
||||
fclose(global_output_file);
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user