New approach, new lexer
This commit is contained in:
12
parser.c
12
parser.c
@@ -16,6 +16,10 @@ global Intern_String intern_sizeu;
|
||||
global Intern_String keyword_sizeof;
|
||||
global Intern_String keyword_cast;
|
||||
global Intern_String keyword_enum;
|
||||
global Intern_String keyword_for;
|
||||
global Intern_String keyword_if;
|
||||
global Intern_String keyword_else;
|
||||
global Intern_String keyword_return;
|
||||
global Intern_String keyword_typedef;
|
||||
global Intern_String keyword_struct;
|
||||
global Intern_String keyword_union;
|
||||
@@ -28,6 +32,10 @@ parser_init(Parser *p){
|
||||
p->interns = arena_push_array(&p->intern_table_arena, Intern_String, p->interns_count);
|
||||
|
||||
keyword_sizeof = intern_string(p, lit("sizeof"));
|
||||
keyword_if = intern_string(p, lit("if"));
|
||||
keyword_else = intern_string(p, lit("else"));
|
||||
keyword_return = intern_string(p, lit("return"));
|
||||
keyword_for = intern_string(p, lit("for"));
|
||||
keyword_cast = intern_string(p, lit("cast"));
|
||||
keyword_struct = intern_string(p, lit("struct"));
|
||||
keyword_enum = intern_string(p, lit("enum"));
|
||||
@@ -74,7 +82,7 @@ parser_push_error(Parser *p, Token *token, char *str, ...){
|
||||
va_end(args1);
|
||||
}
|
||||
|
||||
lex_print("Error: %s\n", string.str);// @Todo(Krzosa):
|
||||
printf("Error: %s %s:%d\n", string.str, token->file.str, (S32)token->line);
|
||||
Parser_Error *error = arena_push_struct(&p->main_arena, Parser_Error);
|
||||
error->message = string;
|
||||
error->next = 0;
|
||||
@@ -140,7 +148,7 @@ table_index_advance(Table_Index *index){
|
||||
|
||||
function Intern_String
|
||||
intern_string(Parser *p, String string){
|
||||
Intern_String result = {};
|
||||
Intern_String result = {0};
|
||||
Table_Index index = table_index_from_string(string, p->interns_count);
|
||||
for(;;){
|
||||
Intern_String *intern = p->interns + index.iter;
|
||||
|
||||
Reference in New Issue
Block a user