Opened pandoras box

This commit is contained in:
2024-09-09 22:32:36 +02:00
parent d9dfcc6354
commit d01fca146c
6 changed files with 12 additions and 8 deletions

View File

@@ -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) {

View File

@@ -1738,7 +1738,7 @@ add_hlsl_builtins :: (checker : *Semantic_Checker) {
}
parse_state : Parse_State;
init_parse_state(*parse_state, lex_result.tokens, lexer.path, context.allocator);
init_parse_state(*parse_state, lex_result.tokens, lexer.path);
parse_result := parse(*parse_state);
if parse_result.had_error {

View File

@@ -216,7 +216,7 @@ run_parser_test :: (lexer : *Lexer, output_type : Output_Type = 0) -> Result, *A
result_data : Result;
result_data.path = lexer.path;
result_data.stage = .Parser;
init_parse_state(*parse_state, lexer.result.tokens, lexer.path, context.allocator);
init_parse_state(*parse_state, lexer.result.tokens, lexer.path);
result := parse(*parse_state);
result_node : *AST_Node;
@@ -272,7 +272,7 @@ run_semantic_analysis_test :: (file_path : string, output_type : Output_Type = 0
parse_state : Parse_State;
result_data.stage = .Parser;
init_parse_state(*parse_state, lex_result.tokens, lexer.path, context.allocator);
init_parse_state(*parse_state, lex_result.tokens, lexer.path);
parse_result := parse(*parse_state);
if parse_result.had_error {
@@ -398,7 +398,7 @@ run_codegen_test :: (path : string, output_type : Output_Type = 0) -> Result, Co
parse_state : Parse_State;
result_data.stage = .Parser;
init_parse_state(*parse_state, lex_result.tokens, lexer.path, context.allocator);
init_parse_state(*parse_state, lex_result.tokens, lexer.path);
parse_result := parse(*parse_state);
if parse_result.had_error {

View File

@@ -392,7 +392,7 @@ compile_file :: (compiler : *Shader_Compiler, path : string) -> Compilation_Resu
}
parse_state : Parse_State;
init_parse_state(*parse_state, lex_result.tokens, lexer.path, context.allocator);
init_parse_state(*parse_state, lex_result.tokens, lexer.path);
parse_result := parse(*parse_state);
if parse_result.had_error {

View File

@@ -3,6 +3,7 @@ cbuffer __PROPERTIES : register(b0)
float4 color;
}
float3 vs_main(float3 pos : POSITION) : SV_POSITION
{
return pos;

View File

@@ -3,6 +3,7 @@ cbuffer __PROPERTIES : register(b0)
float4 color;
}
float3 vs_main(float3 pos : POSITION, float2 uv) : SV_POSITION
{
return pos;