Add lexing, parsing and some semantic checking for constant buffers.

This commit is contained in:
2024-06-14 19:56:28 +02:00
parent b1dceb298f
commit a9a67e3fac
45 changed files with 1275 additions and 1119 deletions

View File

@@ -883,6 +883,26 @@ property_block :: (parse_state : *Parse_State, identifier_token : *Token = null)
return node;
}
constant_buffer :: (parse_state : *Parse_State, identifier_token : *Token = null) -> *AST_Node {
node : *AST_Node;
source_location : Source_Range;
source_location.begin = parse_state.current;
consume(parse_state, .TOKEN_LEFTBRACE, "Expect '{' after 'constant_buffer' keyword");
buffer := field_list(parse_state, .Semicolon);
node = make_node(parse_state, .CBuffer);
if identifier_token {
node.name = identifier_token.ident_value;
}
add_child(node, buffer);
consume(parse_state, .TOKEN_RIGHTBRACE, "Expect '}' after 'constant_buffer' block");
source_location.end = parse_state.previous;
node.source_location = source_location;
return node;
}
struct_declaration :: (parse_state : *Parse_State, identifier_token : *Token) -> *AST_Node {
source_location := generate_source_location_from_token(parse_state, identifier_token);
@@ -914,6 +934,8 @@ const_declaration :: (parse_state : *Parse_State, identifier_token : *Token) ->
return function_declaration(parse_state, identifier_token, .None);
} else if match(parse_state, .TOKEN_PROPERTIES) {
return property_block(parse_state, identifier_token);
} else if match(parse_state, .TOKEN_CONSTANT_BUFFER) {
return constant_buffer(parse_state, identifier_token);
}
return error_node(parse_state, tprint("Couldn't parse constant declaration at token %\n", parse_state.current.*));
}