This commit is contained in:
Krzosa Karol
2022-04-30 12:28:34 +02:00
parent a5a3acf3ef
commit 3a9b748fed
15 changed files with 296 additions and 746 deletions

View File

@@ -1,43 +1,32 @@
#pragma once
typedef struct Type Type;
typedef struct Expr Expr;
typedef struct Decl Decl;
typedef struct Scope Scope;
typedef struct AST_Node AST_Node;
typedef struct Parser_Error Parser_Error;
typedef enum Symbol_Kind{
SK_None,
SK_Type,
SK_Const,
SK_Decl,
}Symbol_Kind;
typedef struct Symbol{
Symbol_Kind kind;
Intern_String string;
Token *token;
struct{
Type *type;
struct{
Type *type;
Expr *expr;
} const_val;
Decl *decl;
};
}Symbol;
struct Parser_Error{
Parser_Error *next;
String message;
Token *token;
};
struct Scope{
Scope *next;
AST_Node *first;
AST_Node *last;
};
typedef struct Parser{
Arena main_arena;
Arena intern_table_arena;
Arena symbol_table_arena;
Scope *scope_free_list;
Scope *scope_stack;
Scope *global_scope;
S64 symbols_inserted;
Symbol *symbols;
AST_Node *symbols;
S64 symbols_count;
S64 interns_in_bytes;
@@ -55,5 +44,7 @@ typedef struct Parser{
}Parser;
function Intern_String intern_string(Parser *p, String string);
function void type_insert(Parser *p, Type *type, Intern_String string);
function Token *token_get(Parser *p);
function B32 intern_compare(Intern_String a, Intern_String b);
function void parser_push_scope(Parser *p);
function AST_Node *symbol_register_basic_type(Parser *p, Intern_String string, SizeU size);