struct Lex_Stream{ String stream; S64 iter; U8 *line_begin; Intern_String file; S32 line; S32 inside_brace_paren; Array indent_stack; }; struct Lexer{ Arena *arena; Lex_Stream stream; Array tokens; Intern_Table interns; S64 token_iter; U32 token_debug_ids; Intern_String intern(String string){ return intern_string(&interns, string); } }; // Lexer::interns::map::allocator - array allocator, resizing // Lexer::tokens - array allocator, resizing // // Parser::ast_arena - arena for asts // Lexer::interns::string_allocator - arena for interns // struct Parse_Ctx:Lexer{ Arena *perm; // Stores: AST, tokens, interns Arena stage_arena; List all_types; S32 type_ids; int lambda_ids; U64 unique_ids; // @Debug Map type_map; Ast_Module *language_base_module; List files; List modules; List ordered_decls; S32 base_language_ordered_decl_len; Ast_Scope *currently_parsed_scope; Ast_File *currently_parsed_file; U32 scope_ids; U32 scope_visit_id; List module_folders; String module_folder; String exe_folder; String working_folder; List files_to_link; S64 indent; String_Builder gen; String_Builder helper_builder; }; CORE_Static void init_type(); CORE_Static void lex_init(Arena *token_string_arena, Arena *map_allocator, Lexer *l); CORE_Static String compile_to_c_code(); CORE_Static Ast_Module *ast_module(Token *pos, Intern_String filename); CORE_Static void insert_builtin_types_into_scope(Ast_Scope *p); CORE_Static void insert_into_scope(Ast_Scope *scope, Ast_Decl *decl); CORE_Static Ast_Type *type_incomplete(Ast *ast); CORE_Static Ast_Expr *parse_expr(S64 minbp = 0);