Opened pandoras box
This commit is contained in:
@@ -15,6 +15,7 @@ Parse_State :: struct {
|
||||
|
||||
current_token_index : int;
|
||||
allocator : Allocator;
|
||||
arena : Arena;
|
||||
|
||||
had_error : bool;
|
||||
|
||||
@@ -119,10 +120,10 @@ parse_rules :: #run -> [(cast(int)Token_Kind.TOKEN_ERROR) + 1]Parse_Rule {
|
||||
return rules;
|
||||
}
|
||||
|
||||
init_parse_state :: (parse_state : *Parse_State, tokens : [..]Token, path : string, allocator : Allocator) {
|
||||
init_parse_state :: (parse_state : *Parse_State, tokens : [..]Token, path : string) {
|
||||
parse_state.tokens = tokens;
|
||||
parse_state.path = path;
|
||||
parse_state.allocator = allocator;
|
||||
parse_state.allocator = make_arena(*parse_state.arena);
|
||||
parse_state.result.nodes.allocator = parse_state.allocator;
|
||||
array_reserve(*parse_state.result.nodes, 4096);
|
||||
parse_state.current_token_index = 0;
|
||||
@@ -751,6 +752,7 @@ statement :: (parse_state : *Parse_State) -> *AST_Node {
|
||||
|
||||
block :: (parse_state : *Parse_State) -> *AST_Node {
|
||||
node : *AST_Node = make_node(parse_state, .Block);
|
||||
array_reserve(*node.children, 1024);
|
||||
|
||||
source_location : Source_Range;
|
||||
|
||||
@@ -1054,7 +1056,7 @@ declaration :: (parse_state : *Parse_State) -> *AST_Node {
|
||||
parse :: (result : *Compile_Result) {
|
||||
for *file : result.files {
|
||||
parse_state : Parse_State;
|
||||
init_parse_state(*parse_state, file.tokens.tokens, file.file.path, result.allocator);
|
||||
init_parse_state(*parse_state, file.tokens.tokens, file.file.path);
|
||||
advance(*parse_state);
|
||||
|
||||
if !match(*parse_state, .TOKEN_EOF) {
|
||||
|
||||
Reference in New Issue
Block a user