Deprecate properties. Use hinted cbuffers instead. This opens up to use a structured buffer in that way as well if you want instead.
This commit is contained in:
76
Parsing.jai
76
Parsing.jai
@@ -75,7 +75,7 @@ parse_rules :: #run -> [(cast(int)Token_Kind.TOKEN_ERROR) + 1]Parse_Rule {
|
||||
rules[Token_Kind.TOKEN_RIGHTBRACKET] = .{null, null, .PREC_NONE};
|
||||
rules[Token_Kind.TOKEN_COMMA] = .{null, null, .PREC_NONE};
|
||||
rules[Token_Kind.TOKEN_DOT] = .{null, dot, .PREC_CALL};
|
||||
rules[Token_Kind.TOKEN_PROPERTIES] = .{named_variable, null, .PREC_CALL};
|
||||
// rules[Token_Kind.TOKEN_PROPERTIES] = .{named_variable, null, .PREC_CALL};
|
||||
rules[Token_Kind.TOKEN_MINUS] = .{unary, binary, .PREC_TERM};
|
||||
rules[Token_Kind.TOKEN_PLUS] = .{null, binary, .PREC_TERM};
|
||||
rules[Token_Kind.TOKEN_SEMICOLON] = .{null, null, .PREC_NONE};
|
||||
@@ -535,7 +535,7 @@ new_builtin_function_node :: (ctx : *Compiler_Context, name : string, members :
|
||||
}
|
||||
|
||||
get_field_list :: (struct_or_func : *AST_Node) -> *AST_Node {
|
||||
assert(struct_or_func.kind == .Function || struct_or_func.kind == .Struct || struct_or_func.kind == .Properties);
|
||||
assert(struct_or_func.kind == .Function || struct_or_func.kind == .Struct || struct_or_func.kind == .CBuffer);
|
||||
return struct_or_func.children[0];
|
||||
}
|
||||
|
||||
@@ -1368,67 +1368,8 @@ function_declaration :: (parse_state : *Parse_State, identifier_token : *Token,
|
||||
return node;
|
||||
}
|
||||
|
||||
instance_block :: (parse_state : *Parse_State) -> *AST_Node {
|
||||
node : *AST_Node;
|
||||
|
||||
source_location : Source_Range;
|
||||
source_location.begin = parse_state.current;
|
||||
|
||||
consume(parse_state, .TOKEN_LEFTBRACE, "Expect '{' after 'instance' keyword");
|
||||
properties := field_list(parse_state, .Semicolon);
|
||||
|
||||
node = make_node(parse_state, .Instance);
|
||||
add_child(node, properties);
|
||||
|
||||
consume(parse_state, .TOKEN_RIGHTBRACE, "Expect '}' after instance block");
|
||||
source_location.end = parse_state.previous;
|
||||
node.source_location = source_location;
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
meta_block :: (parse_state : *Parse_State) -> *AST_Node {
|
||||
node : *AST_Node;
|
||||
|
||||
source_location : Source_Range;
|
||||
source_location.begin = parse_state.current;
|
||||
|
||||
consume(parse_state, .TOKEN_LEFTBRACE, "Expect '{' after 'meta' keyword");
|
||||
properties := field_list(parse_state, .Semicolon);
|
||||
|
||||
node = make_node(parse_state, .Meta);
|
||||
add_child(node, properties);
|
||||
|
||||
consume(parse_state, .TOKEN_RIGHTBRACE, "Expect '}' after meta block");
|
||||
source_location.end = parse_state.previous;
|
||||
node.source_location = source_location;
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
property_block :: (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 'property' keyword");
|
||||
properties := field_list(parse_state, .Semicolon);
|
||||
|
||||
node = make_node(parse_state, .Properties);
|
||||
if identifier_token {
|
||||
node.name = identifier_token.ident_value;
|
||||
}
|
||||
add_child(node, properties);
|
||||
|
||||
consume(parse_state, .TOKEN_RIGHTBRACE, "Expect '}' after 'property' keyword");
|
||||
source_location.end = parse_state.previous;
|
||||
node.source_location = source_location;
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
constant_buffer :: (parse_state : *Parse_State, identifier_token : *Token = null) -> *AST_Node {
|
||||
node : *AST_Node;
|
||||
node : *AST_Node = make_node(parse_state, .CBuffer);
|
||||
source_location : Source_Range;
|
||||
source_location.begin = parse_state.current;
|
||||
|
||||
@@ -1446,7 +1387,6 @@ constant_buffer :: (parse_state : *Parse_State, identifier_token : *Token = null
|
||||
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;
|
||||
}
|
||||
@@ -1488,8 +1428,6 @@ const_declaration :: (parse_state : *Parse_State, identifier_token : *Token) ->
|
||||
return struct_declaration(parse_state, identifier_token);
|
||||
} else if check(parse_state, .TOKEN_LEFTPAREN) {
|
||||
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);
|
||||
}
|
||||
@@ -1499,13 +1437,7 @@ const_declaration :: (parse_state : *Parse_State, identifier_token : *Token) ->
|
||||
declaration :: (parse_state : *Parse_State) -> *AST_Node {
|
||||
skip_statement := false;
|
||||
decl_node : *AST_Node;
|
||||
if match(parse_state, .TOKEN_PROPERTIES) {
|
||||
decl_node = property_block(parse_state);
|
||||
} else if match(parse_state, .TOKEN_INSTANCE) {
|
||||
decl_node = instance_block(parse_state);
|
||||
} else if match(parse_state, .TOKEN_META) {
|
||||
decl_node = meta_block(parse_state);
|
||||
} else if match(parse_state, .TOKEN_VERTEX) {
|
||||
if match(parse_state, .TOKEN_VERTEX) {
|
||||
vertex_token := parse_state.previous;
|
||||
identifier := parse_state.current;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user