Swinging in a different direction, different syntax
This commit is contained in:
30
main.c
30
main.c
@@ -67,10 +67,10 @@ parser_test(){
|
||||
}
|
||||
|
||||
parser_lex_stream(&p, lit("S64 thing; S64 second_var = 10;"), lit("File"));
|
||||
assert(token_match(&p, TK_Keyword));
|
||||
assert(token_match(&p, TK_Identifier));
|
||||
assert(token_match(&p, TK_Identifier));
|
||||
assert(token_match(&p, TK_Semicolon));
|
||||
assert(token_match(&p, TK_Keyword));
|
||||
assert(token_match(&p, TK_Identifier));
|
||||
assert(token_match(&p, TK_Identifier));
|
||||
assert(token_match(&p, TK_Assign));
|
||||
assert(token_match(&p, TK_Int));
|
||||
@@ -99,20 +99,26 @@ parser_test(){
|
||||
lex_print("\n");
|
||||
}
|
||||
|
||||
String decls[] = {
|
||||
lit("enum Thing{ Thing_1 = 10, Thing_2 = 20<<1 };"),
|
||||
};
|
||||
for(S64 i = 0; i < buff_cap(decls); i++){
|
||||
parser_lex_stream(&p, decls[i], lit("File"));
|
||||
AST_Node *node = parse(&p);
|
||||
assert(node);
|
||||
|
||||
}
|
||||
/*
|
||||
String decls =
|
||||
lit("@Test(a=\"thing\") @str=\"based\" Thing:enum{ Thing_1 = 1<<10, Thing_2 = 10 }"
|
||||
"TTT:struct{ thing:U64; nested:struct{ thing:S64; }}"
|
||||
""
|
||||
);
|
||||
*/
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
function S32
|
||||
os_main(){
|
||||
global_output_file = fopen("output.txt", "w");
|
||||
global_output_file = fopen("output.cc", "w");
|
||||
assert_msg(global_output_file, "Failed to open output.txt");
|
||||
lex_test();
|
||||
parser_test();
|
||||
|
||||
Reference in New Issue
Block a user