Pratt parsing, basic ast, decl parse const

This commit is contained in:
Krzosa Karol
2022-05-13 16:04:39 +02:00
parent 9c22a379ea
commit 2689aa9ba1
7 changed files with 586 additions and 125 deletions

10
lex.c
View File

@@ -140,7 +140,7 @@ typedef enum Token_Kind{
TK_Character,
TK_Error,
TK_Float,
TK_Int,
TK_Integer,
TK_Keyword,
}Token_Kind;
@@ -467,7 +467,7 @@ lex__stream(Token_Array *array, Lex_Stream *s){
case '0':case '1':case '2':case '3':case '4':
case '5':case '6':case '7':case '8':case '9':{
t.kind = TK_Int;
t.kind = TK_Integer;
while(lex_is_numeric(lexc(s)))
lex_advance(s);
lex_set_len(s, &t);
@@ -544,7 +544,7 @@ lex_test(){
TK_At,TK_Question,TK_BitAnd,TK_Add,TK_Sub,TK_Semicolon,
TK_ThreeDots, TK_Dot, TK_Arrow, TK_Comma, TK_DoubleColon, TK_Colon,
TK_StringLit, TK_Identifier, TK_StringLit, TK_AddAssign, TK_SubAssign,
TK_Equals, TK_Int, TK_Int, TK_Int, TK_Keyword, TK_Keyword,
TK_Equals, TK_Integer, TK_Integer, TK_Integer, TK_Keyword, TK_Keyword,
TK_Keyword, TK_Keyword, TK_ColonAssign, TK_End
};
String strs[] = {
@@ -564,7 +564,7 @@ lex_test(){
for(Token *t = token_array_iter_begin(&array); t->kind != TK_End; t = token_array_iter_next(&array)){
assert(t->kind == kind[i]);
assert(string_compare(t->string, strs[i++]));
if(t->kind == TK_Int){
if(t->kind == TK_Integer){
assert(t->int_val == vals[ui++]);
}
}
@@ -637,6 +637,6 @@ global const char *token_kind_string[] = {
[TK_Character] = "Character",
[TK_Error] = "Error",
[TK_Float] = "Float",
[TK_Int] = "Int",
[TK_Integer] = "Int",
[TK_Keyword] = "Keyword",
};