More fixes to access and buffer compilation.

This commit is contained in:
2025-09-26 07:01:06 +02:00
parent 6528ca854b
commit 63a68b70b4
35 changed files with 401 additions and 119 deletions

View File

@@ -818,50 +818,7 @@ directive :: (state : *Parse_State) -> *AST_Node {
if_directive.source_location = source_location;
return if_directive;
} else if state.current.ident_value == "load" {
advance(state);
if check(state, .TOKEN_STRING) {
// path_tok := state.current;
// path := path_tok.string_value;
// advance(state);
// result : Compiler_Context;
// ctx.allocator = state.ctx.allocator;
// ctx.environment = state.ctx.environment;
// ctx.file = make_file(*result, path);
// if ctx.file.source.count == 0 {
// unable_to_open_file(state, path, path_tok);
// advance_to_sync_point(state);
// advance(state);
// return null;
// }
// consume(state, .TOKEN_SEMICOLON, "Expected ';' after #load directive");
// lex(*result);
// count := state.ctx.tokens..count;
// current_idx := state.current_token_index;
// result_count := ctx.tokens..count;
// // state.ctx.tokens..count -= 1;
// array_resize(*state.ctx.tokens., count + result_count - 1);
// memcpy(*state.ctx.tokens[current_idx + result_count - 1], *state.ctx.tokens[current_idx], size_of(Token) * (count - current_idx));
// for *tok : ctx.tokens. {
// if tok.kind == .TOKEN_EOF {
// break;
// }
// tok.builtin = true;
// state.ctx.tokens[it_index] = tok.*;
// }
}
}
}
return null;
}
@@ -898,34 +855,30 @@ dot :: (parse_state : *Parse_State, left : *AST_Node) -> *AST_Node {
source_location : Source_Range;
source_location.begin = left.source_location.begin;
source_location.main_token = identifier;
if check_any(parse_state, .TOKEN_ASSIGN, .TOKEN_MINUSEQUALS, .TOKEN_PLUSEQUALS, .TOKEN_DIVEQUALS, .TOKEN_MODEQUALS, .TOKEN_TIMESEQUALS) {
advance(parse_state);
variable := make_node(parse_state, .Variable);
variable.source_location = generate_source_location_from_token(parse_state, identifier);
variable.name = identifier.ident_value;
add_child(left, variable);
node := make_node(parse_state, .Binary);
node.token = parse_state.previous;
add_child(node, left);
add_child(node, expression(parse_state));
return node;
}
access := make_node(parse_state, .Access);
variable := make_node(parse_state, .Variable);
variable.name = identifier.ident_value;
if check(parse_state, .TOKEN_DOT) {
advance(parse_state);
dot(parse_state, variable);
}
add_child(left, variable);
add_child(access, left);
add_child(access, variable);
source_location.end = parse_state.previous;
variable.source_location = source_location;
return left;
if check_any(parse_state, .TOKEN_ASSIGN, .TOKEN_MINUSEQUALS, .TOKEN_PLUSEQUALS, .TOKEN_DIVEQUALS, .TOKEN_MODEQUALS, .TOKEN_TIMESEQUALS) {
advance(parse_state);
access.source_location = generate_source_location_from_token(parse_state, identifier);
node := make_node(parse_state, .Binary);
node.token = parse_state.previous;
add_child(node, access);
add_child(node, expression(parse_state));
return node;
}
source_location.end = parse_state.current;
access.source_location = source_location;
return access;
}
integer :: (parse_state : *Parse_State, left : *AST_Node) -> *AST_Node {
@@ -1557,4 +1510,4 @@ parse :: (ctx : *Compiler_Context, allocator := temp) {
}
}
#load "AST.jai";
#load "ast.jai";