Complete rework, adding packages
This commit is contained in:
31
compiler.h
31
compiler.h
@@ -112,19 +112,19 @@ struct Token{
|
||||
S64 indent;
|
||||
};
|
||||
|
||||
String file;
|
||||
S32 line;
|
||||
U8 *line_begin;
|
||||
Intern_String file;
|
||||
S32 line;
|
||||
U8 *line_begin;
|
||||
};
|
||||
|
||||
struct Lex_Stream{
|
||||
String stream;
|
||||
S64 iter;
|
||||
|
||||
U8 *line_begin;
|
||||
String file;
|
||||
S32 line;
|
||||
S32 inside_brace_paren;
|
||||
U8 *line_begin;
|
||||
Intern_String file;
|
||||
S32 line;
|
||||
S32 inside_brace_paren;
|
||||
Array<Token *> indent_stack;
|
||||
};
|
||||
|
||||
@@ -154,6 +154,7 @@ Intern_String keyword_if;
|
||||
Intern_String keyword_else;
|
||||
Intern_String keyword_true;
|
||||
Intern_String keyword_false;
|
||||
Intern_String keyword_package;
|
||||
Intern_String keyword_for;
|
||||
Intern_String keyword_pass;
|
||||
Intern_String keyword_cast;
|
||||
@@ -163,8 +164,10 @@ Intern_String intern_void;
|
||||
Intern_String intern_foreign;
|
||||
Intern_String intern_printf;
|
||||
|
||||
|
||||
struct Ast_Scope;
|
||||
struct Ast_Decl;
|
||||
struct Ast_Package;
|
||||
struct Sym;
|
||||
struct Parse_Ctx:Lexer{
|
||||
Allocator *perm; // Stores: AST, tokens, interns
|
||||
Allocator *heap;
|
||||
@@ -172,15 +175,12 @@ struct Parse_Ctx:Lexer{
|
||||
U64 unique_ids;
|
||||
Map type_map;
|
||||
|
||||
Ast_Scope *current_scope;
|
||||
Ast_Package *resolving_package;
|
||||
Map resolved;
|
||||
Map syms;
|
||||
S32 scope;
|
||||
Array<Sym *> local_syms;
|
||||
Array<Ast_Decl *> ordered_decls;
|
||||
|
||||
Token empty_token;
|
||||
S64 indent;
|
||||
|
||||
String_Builder gen;
|
||||
};
|
||||
|
||||
@@ -201,6 +201,7 @@ lex_init(Allocator *token_string_arena, Allocator *map_allocator, Lexer *l){
|
||||
keyword_cast = l->intern("cast"_s);
|
||||
keyword_true = l->intern("true"_s);
|
||||
keyword_false = l->intern("false"_s);
|
||||
keyword_package = l->intern("package"_s);
|
||||
keyword_return = l->intern("return"_s);
|
||||
keyword_if = l->intern("if"_s);
|
||||
keyword_pass = l->intern("pass"_s);
|
||||
@@ -220,10 +221,8 @@ parse_init(Parse_Ctx *ctx, Allocator *perm_allocator, Allocator *heap_allocator)
|
||||
ctx->perm = perm_allocator;
|
||||
ctx->heap = heap_allocator;
|
||||
ctx->gen = {ctx->perm};
|
||||
ctx->resolved = {ctx->heap};
|
||||
ctx->syms = {ctx->heap};
|
||||
ctx->ordered_decls = {ctx->heap};
|
||||
ctx->type_map = {ctx->heap};
|
||||
ctx->local_syms = {ctx->heap};
|
||||
bigint_allocator = ctx->perm;
|
||||
|
||||
lex_init(ctx->perm, ctx->heap, ctx);
|
||||
|
||||
Reference in New Issue
Block a user