diff --git a/check.jai b/check.jai index 8350aa1..4cc5b15 100644 --- a/check.jai +++ b/check.jai @@ -1047,12 +1047,18 @@ lookup_type :: (checker : *Checker, scope : Scope_Handle, node : *AST_Node, type return lookup_type(checker, scope, type_string, typename); } -check_block :: (checker : *Checker, node : *AST_Node) { - push_scope(checker, kind = Scope_Kind.Block); +check_block :: (checker : *Checker, node : *AST_Node, skip_scope : bool = false) { + if !skip_scope { + push_scope(checker, kind = Scope_Kind.Block); + } + for child : node.children { check_node(checker, child); } - pop_scope(checker); + + if !skip_scope { + pop_scope(checker); + } } declare_struct :: (checker : *Checker, node : *AST_Node, name : string) -> Type_Variable_Handle { @@ -1082,13 +1088,23 @@ declare_struct :: (checker : *Checker, node : *AST_Node, name : string) -> Type_ for child : node.children { if child.kind == .FieldList { - for field : child.children { - type_var := check_field(checker, field); + for child : child.children { + if child.kind == .Field { + type_var := check_field(checker, child); - if type_var > 0 { - from_handle(checker, type_var).scope = scope_handle; - add_child(checker, handle, type_var); + if type_var > 0 { + from_handle(checker, type_var).scope = scope_handle; + add_child(checker, handle, type_var); + } + } else if child.kind == .If_Directive && child.children.count > 0 { + tv_start_index := checker.ctx.type_variables.count - 1; + check_if_directive(checker, child); + + for i : tv_start_index..checker.ctx.type_variables.count - 1 { + add_child(checker, handle, xx (i + 1)); + } } + } } } @@ -1325,7 +1341,7 @@ check_function :: (checker : *Checker, node : *AST_Node) { } if statement.kind == .If_Directive { - break; + continue; } } } @@ -1872,11 +1888,7 @@ check_if_directive :: (checker : *Checker, directive : *AST_Node) { if checker.current_scope == 1 { traverse(checker, first_child); } else { - check_block(checker, first_child); - } - - for child : directive.children[1].children { - add_child(parent, child); + check_block(checker, first_child, skip_scope=true); } if directive.children.count > 2 { @@ -1889,10 +1901,6 @@ check_if_directive :: (checker : *Checker, directive : *AST_Node) { if else_branch.kind == .If_Directive { check_if_directive(checker, else_branch); } else { - for child : else_branch.children { - add_child(parent, child); - } - if checker.current_scope == 1 { if else_branch.kind == .If_Directive { check_declaration(checker, else_branch); diff --git a/ink.jai b/ink.jai index 40acd46..617e3b0 100644 --- a/ink.jai +++ b/ink.jai @@ -459,7 +459,7 @@ record_result :: (results : *[..]Result, result : Result) { array_add(results, result); } -run_test_suite :: (using suite : *Test_Suite, output_type : Output_Type = 0) { +run_test_suite :: (using suite : *Test_Suite, output_type : Output_Type = 0, record_to_suite : bool = false) { if suite.name.count > 0 { print("%Running suite: %\n", green(), suite.name); print("%", reset_color()); diff --git a/lexing.jai b/lexing.jai index dde1193..edd871d 100644 --- a/lexing.jai +++ b/lexing.jai @@ -271,26 +271,6 @@ error_token :: (lexer : *Lexer, message : string) -> *Token { return token; } -// unable_to_open_file :: (state : *Parse_State, path : string, token : Token) { -// builder : String_Builder; -// init_string_builder(*builder,, temp); - -// print_to_builder(*builder, "Unable to open file '%' for reading\n\n", path); - -// location := generate_source_location_from_token(state, token); - -// indent(*builder, 1); -// cyan(*builder); -// print_to_builder(*builder, "%\n", print_from_source_location(location)); -// indent(*builder, 1); - -// loc := location.begin; -// print_token_pointer(*builder, loc); - -// final_message := builder_to_string(*builder); -// record_error(state, token, final_message, false); -// } - record_error :: (lexer : *Lexer, message : string) { error : Compiler_Message; error.message_kind = .Error; diff --git a/parsing.jai b/parsing.jai index e1eb854..4719455 100644 --- a/parsing.jai +++ b/parsing.jai @@ -1200,39 +1200,43 @@ field_list :: (parse_state : *Parser, separator : Separator_Type, require_field_ source_location.begin = parse_state.previous; source_location.main_token = parse_state.current; - while check(parse_state, .TOKEN_IDENTIFIER) { - field : *AST_Node; - identifier := parse_state.current; - advance(parse_state); - if require_field_names || check(parse_state, .TOKEN_COLON) { - field = field_declaration(parse_state, identifier); - } else { - field = make_node(parse_state, .Unnamed_Field); + while check(parse_state, .TOKEN_IDENTIFIER) || (check(parse_state, .TOKEN_DIRECTIVE) || parse_state.current.ident_value == "if") { + if check(parse_state, .TOKEN_IDENTIFIER) { + field : *AST_Node; + identifier := parse_state.current; + advance(parse_state); + if require_field_names || check(parse_state, .TOKEN_COLON) { + field = field_declaration(parse_state, identifier); + } else { + field = make_node(parse_state, .Unnamed_Field); - source_location : Source_Range; - source_location.begin = identifier; + source_location : Source_Range; + source_location.begin = identifier; + + source_location.main_token = identifier; + field.name = identifier.ident_value; + field.token = identifier; + } + add_child(node, field); - source_location.main_token = identifier; - field.name = identifier.ident_value; - field.token = identifier; - } - add_child(node, field); - - if check(parse_state, .TOKEN_RIGHTPAREN) { - source_location.end = parse_state.current; - node.source_location = source_location; - return node; - } - - if separator == { - case .Comma; { - consume(parse_state, .TOKEN_COMMA, "Expect ',' after field declaration."); + if check(parse_state, .TOKEN_RIGHTPAREN) { + source_location.end = parse_state.current; + node.source_location = source_location; + return node; } - case .Semicolon; { - consume(parse_state, .TOKEN_SEMICOLON, "Expect ';' after field declaration."); + if separator == { + case .Comma; { + consume(parse_state, .TOKEN_COMMA, "Expect ',' after field declaration."); + } + case .Semicolon; { + consume(parse_state, .TOKEN_SEMICOLON, "Expect ';' after field declaration."); + } } - } + } else if check(parse_state, .TOKEN_DIRECTIVE) || parse_state.current.ident_value == "if" { + dir := directive(parse_state); + add_child(node, dir); + } } return node; diff --git a/shader_parsing_session.rdbg b/shader_parsing_session.rdbg index cf70660..fcd763e 100644 Binary files a/shader_parsing_session.rdbg and b/shader_parsing_session.rdbg differ diff --git a/test/check/hint_in_struct.golden b/test/check/hint_in_struct.golden new file mode 100644 index 0000000..69ba0b7 --- /dev/null +++ b/test/check/hint_in_struct.golden @@ -0,0 +1,8 @@ +scope (global) [ +[VSInput] : {position : float2, color : float4, color : float4, uv : float2} + scope (VSInput) [ + [position] : float2 + [uv] : float2 + [color] : float4 + ] +] diff --git a/test/check/if_def_block.golden b/test/check/if_def_block.golden index 9dd53c6..8002469 100644 --- a/test/check/if_def_block.golden +++ b/test/check/if_def_block.golden @@ -1,8 +1,7 @@ scope (global) [ [pixel__ps_main] : () - scope (pixel__ps_main) [ scope (block) [ - [alpha_color] : float4 - [f] : float - ] + scope (pixel__ps_main) [ + [alpha_color] : float4 + [f] : float ] ] diff --git a/test/check_all.suite b/test/check_all.suite index 7f153a9..a429398 100644 --- a/test/check_all.suite +++ b/test/check_all.suite @@ -45,3 +45,4 @@ test/use_builtin_functions.ink check test/wrong_argument_count.ink check test/wrong_multiply.ink check test/wrong_type_for_function.ink check +test/hint_in_struct.ink check \ No newline at end of file diff --git a/test/codegen_all.suite b/test/codegen_all.suite index d1e0be4..b024191 100644 --- a/test/codegen_all.suite +++ b/test/codegen_all.suite @@ -28,3 +28,4 @@ test/simple_struct_access.ink codegen test/struct_within_struct.ink codegen test/unary.ink codegen test/use_builtin_functions.ink codegen +test/hint_in_struct.ink codegen \ No newline at end of file diff --git a/test/compile_all.suite b/test/compile_all.suite index 075e834..dea6f68 100644 --- a/test/compile_all.suite +++ b/test/compile_all.suite @@ -27,4 +27,5 @@ test/simple_if.ink compile test/simple_struct_access.ink compile test/struct_within_struct.ink compile test/unary.ink compile -test/use_builtin_functions.ink compile \ No newline at end of file +test/use_builtin_functions.ink compile +test/hint_in_struct.ink compile \ No newline at end of file diff --git a/test/custom_hint.ink b/test/custom_hint.ink index 69772be..74fb212 100644 --- a/test/custom_hint.ink +++ b/test/custom_hint.ink @@ -1,4 +1,4 @@ -p :: properties { +p :: Constant_Buffer { time : float @time; } diff --git a/test/hint_in_struct.ink b/test/hint_in_struct.ink new file mode 100644 index 0000000..85aed0f --- /dev/null +++ b/test/hint_in_struct.ink @@ -0,0 +1,10 @@ +#add_define UV + +VSInput :: struct { + position : float2 @position; + color : float4 @color; + + #if Env.UV { + uv : float2 @UV; + } +} diff --git a/test/lex/custom_hint.golden b/test/lex/custom_hint.golden index 3e224eb..d060508 100644 --- a/test/lex/custom_hint.golden +++ b/test/lex/custom_hint.golden @@ -1,81 +1,81 @@ {kind = TOKEN_IDENTIFIER; ; index = 0 ; length = 1 line = 1 ; column = 0 ; value ='p'; } {kind = TOKEN_DOUBLECOLON; ; index = 2 ; length = 2 line = 1 ; column = 2 ; value ='::'; } -{kind = TOKEN_PROPERTIES; ; index = 5 ; length = 10 line = 1 ; column = 5 ; value ='properties'; } -{kind = TOKEN_LEFTBRACE; ; index = 16 ; length = 1 line = 1 ; column = 16 ; value ='{'; } -{kind = TOKEN_IDENTIFIER; ; index = 20 ; length = 4 line = 2 ; column = 0 ; value ='time'; } -{kind = TOKEN_COLON; ; index = 25 ; length = 1 line = 2 ; column = 5 ; value =':'; } -{kind = TOKEN_IDENTIFIER; ; index = 27 ; length = 5 line = 2 ; column = 7 ; value ='float'; } -{kind = TOKEN_AT; ; index = 33 ; length = 1 line = 2 ; column = 13 ; value ='@'; } -{kind = TOKEN_IDENTIFIER; ; index = 34 ; length = 4 line = 2 ; column = 14 ; value ='time'; } -{kind = TOKEN_SEMICOLON; ; index = 38 ; length = 1 line = 2 ; column = 18 ; value =';'; } -{kind = TOKEN_RIGHTBRACE; ; index = 41 ; length = 1 line = 3 ; column = 0 ; value ='}'; } -{kind = TOKEN_VERTEX; ; index = 46 ; length = 6 line = 5 ; column = 0 ; value ='vertex'; } -{kind = TOKEN_IDENTIFIER; ; index = 53 ; length = 4 line = 5 ; column = 7 ; value ='main'; } -{kind = TOKEN_DOUBLECOLON; ; index = 58 ; length = 2 line = 5 ; column = 12 ; value ='::'; } -{kind = TOKEN_LEFTPAREN; ; index = 61 ; length = 1 line = 5 ; column = 15 ; value ='('; } -{kind = TOKEN_IDENTIFIER; ; index = 62 ; length = 3 line = 5 ; column = 16 ; value ='pos'; } -{kind = TOKEN_COLON; ; index = 66 ; length = 1 line = 5 ; column = 20 ; value =':'; } -{kind = TOKEN_IDENTIFIER; ; index = 68 ; length = 6 line = 5 ; column = 22 ; value ='float3'; } -{kind = TOKEN_AT; ; index = 75 ; length = 1 line = 5 ; column = 29 ; value ='@'; } -{kind = TOKEN_IDENTIFIER; ; index = 76 ; length = 8 line = 5 ; column = 30 ; value ='position'; } -{kind = TOKEN_RIGHTPAREN; ; index = 84 ; length = 1 line = 5 ; column = 38 ; value =')'; } -{kind = TOKEN_ARROW; ; index = 86 ; length = 2 line = 5 ; column = 40 ; value ='->'; } -{kind = TOKEN_IDENTIFIER; ; index = 89 ; length = 6 line = 5 ; column = 43 ; value ='float4'; } -{kind = TOKEN_AT; ; index = 96 ; length = 1 line = 5 ; column = 50 ; value ='@'; } -{kind = TOKEN_IDENTIFIER; ; index = 97 ; length = 8 line = 5 ; column = 51 ; value ='position'; } -{kind = TOKEN_LEFTBRACE; ; index = 106 ; length = 1 line = 5 ; column = 60 ; value ='{'; } -{kind = TOKEN_RETURN; ; index = 110 ; length = 6 line = 6 ; column = 0 ; value ='return'; } -{kind = TOKEN_IDENTIFIER; ; index = 117 ; length = 6 line = 6 ; column = 7 ; value ='float4'; } -{kind = TOKEN_LEFTPAREN; ; index = 123 ; length = 1 line = 6 ; column = 13 ; value ='('; } -{kind = TOKEN_IDENTIFIER; ; index = 124 ; length = 3 line = 6 ; column = 14 ; value ='pos'; } -{kind = TOKEN_DOT; ; index = 127 ; length = 1 line = 6 ; column = 17 ; value ='.'; } -{kind = TOKEN_IDENTIFIER; ; index = 128 ; length = 1 line = 6 ; column = 18 ; value ='x'; } -{kind = TOKEN_COMMA; ; index = 129 ; length = 1 line = 6 ; column = 19 ; value =','; } -{kind = TOKEN_IDENTIFIER; ; index = 131 ; length = 3 line = 6 ; column = 21 ; value ='pos'; } -{kind = TOKEN_DOT; ; index = 134 ; length = 1 line = 6 ; column = 24 ; value ='.'; } -{kind = TOKEN_IDENTIFIER; ; index = 135 ; length = 1 line = 6 ; column = 25 ; value ='y'; } -{kind = TOKEN_COMMA; ; index = 136 ; length = 1 line = 6 ; column = 26 ; value =','; } -{kind = TOKEN_IDENTIFIER; ; index = 138 ; length = 3 line = 6 ; column = 28 ; value ='pos'; } -{kind = TOKEN_DOT; ; index = 141 ; length = 1 line = 6 ; column = 31 ; value ='.'; } -{kind = TOKEN_IDENTIFIER; ; index = 142 ; length = 1 line = 6 ; column = 32 ; value ='z'; } -{kind = TOKEN_COMMA; ; index = 143 ; length = 1 line = 6 ; column = 33 ; value =','; } -{kind = TOKEN_FLOATLITERAL; ; index = 145 ; length = 3 line = 6 ; column = 35 ; value ='1'; } -{kind = TOKEN_RIGHTPAREN; ; index = 148 ; length = 1 line = 6 ; column = 38 ; value =')'; } -{kind = TOKEN_SEMICOLON; ; index = 149 ; length = 1 line = 6 ; column = 39 ; value =';'; } -{kind = TOKEN_RIGHTBRACE; ; index = 152 ; length = 1 line = 7 ; column = 0 ; value ='}'; } -{kind = TOKEN_PIXEL; ; index = 157 ; length = 5 line = 9 ; column = 0 ; value ='pixel'; } -{kind = TOKEN_IDENTIFIER; ; index = 163 ; length = 4 line = 9 ; column = 6 ; value ='main'; } -{kind = TOKEN_DOUBLECOLON; ; index = 168 ; length = 2 line = 9 ; column = 11 ; value ='::'; } -{kind = TOKEN_LEFTPAREN; ; index = 171 ; length = 1 line = 9 ; column = 14 ; value ='('; } -{kind = TOKEN_IDENTIFIER; ; index = 172 ; length = 3 line = 9 ; column = 15 ; value ='pos'; } -{kind = TOKEN_COLON; ; index = 176 ; length = 1 line = 9 ; column = 19 ; value =':'; } -{kind = TOKEN_IDENTIFIER; ; index = 178 ; length = 6 line = 9 ; column = 21 ; value ='float4'; } -{kind = TOKEN_AT; ; index = 185 ; length = 1 line = 9 ; column = 28 ; value ='@'; } -{kind = TOKEN_IDENTIFIER; ; index = 186 ; length = 11 line = 9 ; column = 29 ; value ='outposition'; } -{kind = TOKEN_RIGHTPAREN; ; index = 197 ; length = 1 line = 9 ; column = 40 ; value =')'; } -{kind = TOKEN_ARROW; ; index = 199 ; length = 2 line = 9 ; column = 42 ; value ='->'; } -{kind = TOKEN_IDENTIFIER; ; index = 202 ; length = 6 line = 9 ; column = 45 ; value ='float4'; } -{kind = TOKEN_AT; ; index = 209 ; length = 1 line = 9 ; column = 52 ; value ='@'; } -{kind = TOKEN_IDENTIFIER; ; index = 210 ; length = 6 line = 9 ; column = 53 ; value ='target'; } -{kind = TOKEN_LEFTBRACE; ; index = 217 ; length = 1 line = 9 ; column = 60 ; value ='{'; } -{kind = TOKEN_IDENTIFIER; ; index = 221 ; length = 1 line = 10 ; column = 0 ; value ='t'; } -{kind = TOKEN_COLON; ; index = 223 ; length = 1 line = 10 ; column = 2 ; value =':'; } -{kind = TOKEN_ASSIGN; ; index = 224 ; length = 1 line = 10 ; column = 3 ; value ='='; } -{kind = TOKEN_IDENTIFIER; ; index = 226 ; length = 1 line = 10 ; column = 5 ; value ='p'; } -{kind = TOKEN_DOT; ; index = 227 ; length = 1 line = 10 ; column = 6 ; value ='.'; } -{kind = TOKEN_IDENTIFIER; ; index = 228 ; length = 4 line = 10 ; column = 7 ; value ='time'; } -{kind = TOKEN_SEMICOLON; ; index = 232 ; length = 1 line = 10 ; column = 11 ; value =';'; } -{kind = TOKEN_RETURN; ; index = 236 ; length = 6 line = 11 ; column = 0 ; value ='return'; } -{kind = TOKEN_IDENTIFIER; ; index = 243 ; length = 6 line = 11 ; column = 7 ; value ='float4'; } -{kind = TOKEN_LEFTPAREN; ; index = 249 ; length = 1 line = 11 ; column = 13 ; value ='('; } -{kind = TOKEN_INTLITERAL; ; index = 250 ; length = 1 line = 11 ; column = 14 ; value ='1'; } -{kind = TOKEN_COMMA; ; index = 251 ; length = 1 line = 11 ; column = 15 ; value =','; } -{kind = TOKEN_INTLITERAL; ; index = 253 ; length = 1 line = 11 ; column = 17 ; value ='1'; } -{kind = TOKEN_COMMA; ; index = 254 ; length = 1 line = 11 ; column = 18 ; value =','; } -{kind = TOKEN_INTLITERAL; ; index = 256 ; length = 1 line = 11 ; column = 20 ; value ='1'; } -{kind = TOKEN_COMMA; ; index = 257 ; length = 1 line = 11 ; column = 21 ; value =','; } -{kind = TOKEN_INTLITERAL; ; index = 259 ; length = 1 line = 11 ; column = 23 ; value ='1'; } -{kind = TOKEN_RIGHTPAREN; ; index = 260 ; length = 1 line = 11 ; column = 24 ; value =')'; } -{kind = TOKEN_SEMICOLON; ; index = 261 ; length = 1 line = 11 ; column = 25 ; value =';'; } -{kind = TOKEN_RIGHTBRACE; ; index = 264 ; length = 1 line = 12 ; column = 0 ; value ='}'; } -{kind = TOKEN_EOF; ; index = 267 ; length = 0 line = 13 ; column = 0 ; value =''; } +{kind = TOKEN_CONSTANT_BUFFER; ; index = 5 ; length = 15 line = 1 ; column = 5 ; value ='Constant_Buffer'; } +{kind = TOKEN_LEFTBRACE; ; index = 21 ; length = 1 line = 1 ; column = 21 ; value ='{'; } +{kind = TOKEN_IDENTIFIER; ; index = 25 ; length = 4 line = 2 ; column = 0 ; value ='time'; } +{kind = TOKEN_COLON; ; index = 30 ; length = 1 line = 2 ; column = 5 ; value =':'; } +{kind = TOKEN_IDENTIFIER; ; index = 32 ; length = 5 line = 2 ; column = 7 ; value ='float'; } +{kind = TOKEN_AT; ; index = 38 ; length = 1 line = 2 ; column = 13 ; value ='@'; } +{kind = TOKEN_IDENTIFIER; ; index = 39 ; length = 4 line = 2 ; column = 14 ; value ='time'; } +{kind = TOKEN_SEMICOLON; ; index = 43 ; length = 1 line = 2 ; column = 18 ; value =';'; } +{kind = TOKEN_RIGHTBRACE; ; index = 46 ; length = 1 line = 3 ; column = 0 ; value ='}'; } +{kind = TOKEN_VERTEX; ; index = 51 ; length = 6 line = 5 ; column = 0 ; value ='vertex'; } +{kind = TOKEN_IDENTIFIER; ; index = 58 ; length = 4 line = 5 ; column = 7 ; value ='main'; } +{kind = TOKEN_DOUBLECOLON; ; index = 63 ; length = 2 line = 5 ; column = 12 ; value ='::'; } +{kind = TOKEN_LEFTPAREN; ; index = 66 ; length = 1 line = 5 ; column = 15 ; value ='('; } +{kind = TOKEN_IDENTIFIER; ; index = 67 ; length = 3 line = 5 ; column = 16 ; value ='pos'; } +{kind = TOKEN_COLON; ; index = 71 ; length = 1 line = 5 ; column = 20 ; value =':'; } +{kind = TOKEN_IDENTIFIER; ; index = 73 ; length = 6 line = 5 ; column = 22 ; value ='float3'; } +{kind = TOKEN_AT; ; index = 80 ; length = 1 line = 5 ; column = 29 ; value ='@'; } +{kind = TOKEN_IDENTIFIER; ; index = 81 ; length = 8 line = 5 ; column = 30 ; value ='position'; } +{kind = TOKEN_RIGHTPAREN; ; index = 89 ; length = 1 line = 5 ; column = 38 ; value =')'; } +{kind = TOKEN_ARROW; ; index = 91 ; length = 2 line = 5 ; column = 40 ; value ='->'; } +{kind = TOKEN_IDENTIFIER; ; index = 94 ; length = 6 line = 5 ; column = 43 ; value ='float4'; } +{kind = TOKEN_AT; ; index = 101 ; length = 1 line = 5 ; column = 50 ; value ='@'; } +{kind = TOKEN_IDENTIFIER; ; index = 102 ; length = 8 line = 5 ; column = 51 ; value ='position'; } +{kind = TOKEN_LEFTBRACE; ; index = 111 ; length = 1 line = 5 ; column = 60 ; value ='{'; } +{kind = TOKEN_RETURN; ; index = 115 ; length = 6 line = 6 ; column = 0 ; value ='return'; } +{kind = TOKEN_IDENTIFIER; ; index = 122 ; length = 6 line = 6 ; column = 7 ; value ='float4'; } +{kind = TOKEN_LEFTPAREN; ; index = 128 ; length = 1 line = 6 ; column = 13 ; value ='('; } +{kind = TOKEN_IDENTIFIER; ; index = 129 ; length = 3 line = 6 ; column = 14 ; value ='pos'; } +{kind = TOKEN_DOT; ; index = 132 ; length = 1 line = 6 ; column = 17 ; value ='.'; } +{kind = TOKEN_IDENTIFIER; ; index = 133 ; length = 1 line = 6 ; column = 18 ; value ='x'; } +{kind = TOKEN_COMMA; ; index = 134 ; length = 1 line = 6 ; column = 19 ; value =','; } +{kind = TOKEN_IDENTIFIER; ; index = 136 ; length = 3 line = 6 ; column = 21 ; value ='pos'; } +{kind = TOKEN_DOT; ; index = 139 ; length = 1 line = 6 ; column = 24 ; value ='.'; } +{kind = TOKEN_IDENTIFIER; ; index = 140 ; length = 1 line = 6 ; column = 25 ; value ='y'; } +{kind = TOKEN_COMMA; ; index = 141 ; length = 1 line = 6 ; column = 26 ; value =','; } +{kind = TOKEN_IDENTIFIER; ; index = 143 ; length = 3 line = 6 ; column = 28 ; value ='pos'; } +{kind = TOKEN_DOT; ; index = 146 ; length = 1 line = 6 ; column = 31 ; value ='.'; } +{kind = TOKEN_IDENTIFIER; ; index = 147 ; length = 1 line = 6 ; column = 32 ; value ='z'; } +{kind = TOKEN_COMMA; ; index = 148 ; length = 1 line = 6 ; column = 33 ; value =','; } +{kind = TOKEN_FLOATLITERAL; ; index = 150 ; length = 3 line = 6 ; column = 35 ; value ='1'; } +{kind = TOKEN_RIGHTPAREN; ; index = 153 ; length = 1 line = 6 ; column = 38 ; value =')'; } +{kind = TOKEN_SEMICOLON; ; index = 154 ; length = 1 line = 6 ; column = 39 ; value =';'; } +{kind = TOKEN_RIGHTBRACE; ; index = 157 ; length = 1 line = 7 ; column = 0 ; value ='}'; } +{kind = TOKEN_PIXEL; ; index = 162 ; length = 5 line = 9 ; column = 0 ; value ='pixel'; } +{kind = TOKEN_IDENTIFIER; ; index = 168 ; length = 4 line = 9 ; column = 6 ; value ='main'; } +{kind = TOKEN_DOUBLECOLON; ; index = 173 ; length = 2 line = 9 ; column = 11 ; value ='::'; } +{kind = TOKEN_LEFTPAREN; ; index = 176 ; length = 1 line = 9 ; column = 14 ; value ='('; } +{kind = TOKEN_IDENTIFIER; ; index = 177 ; length = 3 line = 9 ; column = 15 ; value ='pos'; } +{kind = TOKEN_COLON; ; index = 181 ; length = 1 line = 9 ; column = 19 ; value =':'; } +{kind = TOKEN_IDENTIFIER; ; index = 183 ; length = 6 line = 9 ; column = 21 ; value ='float4'; } +{kind = TOKEN_AT; ; index = 190 ; length = 1 line = 9 ; column = 28 ; value ='@'; } +{kind = TOKEN_IDENTIFIER; ; index = 191 ; length = 11 line = 9 ; column = 29 ; value ='outposition'; } +{kind = TOKEN_RIGHTPAREN; ; index = 202 ; length = 1 line = 9 ; column = 40 ; value =')'; } +{kind = TOKEN_ARROW; ; index = 204 ; length = 2 line = 9 ; column = 42 ; value ='->'; } +{kind = TOKEN_IDENTIFIER; ; index = 207 ; length = 6 line = 9 ; column = 45 ; value ='float4'; } +{kind = TOKEN_AT; ; index = 214 ; length = 1 line = 9 ; column = 52 ; value ='@'; } +{kind = TOKEN_IDENTIFIER; ; index = 215 ; length = 6 line = 9 ; column = 53 ; value ='target'; } +{kind = TOKEN_LEFTBRACE; ; index = 222 ; length = 1 line = 9 ; column = 60 ; value ='{'; } +{kind = TOKEN_IDENTIFIER; ; index = 226 ; length = 1 line = 10 ; column = 0 ; value ='t'; } +{kind = TOKEN_COLON; ; index = 228 ; length = 1 line = 10 ; column = 2 ; value =':'; } +{kind = TOKEN_ASSIGN; ; index = 229 ; length = 1 line = 10 ; column = 3 ; value ='='; } +{kind = TOKEN_IDENTIFIER; ; index = 231 ; length = 1 line = 10 ; column = 5 ; value ='p'; } +{kind = TOKEN_DOT; ; index = 232 ; length = 1 line = 10 ; column = 6 ; value ='.'; } +{kind = TOKEN_IDENTIFIER; ; index = 233 ; length = 4 line = 10 ; column = 7 ; value ='time'; } +{kind = TOKEN_SEMICOLON; ; index = 237 ; length = 1 line = 10 ; column = 11 ; value =';'; } +{kind = TOKEN_RETURN; ; index = 241 ; length = 6 line = 11 ; column = 0 ; value ='return'; } +{kind = TOKEN_IDENTIFIER; ; index = 248 ; length = 6 line = 11 ; column = 7 ; value ='float4'; } +{kind = TOKEN_LEFTPAREN; ; index = 254 ; length = 1 line = 11 ; column = 13 ; value ='('; } +{kind = TOKEN_INTLITERAL; ; index = 255 ; length = 1 line = 11 ; column = 14 ; value ='1'; } +{kind = TOKEN_COMMA; ; index = 256 ; length = 1 line = 11 ; column = 15 ; value =','; } +{kind = TOKEN_INTLITERAL; ; index = 258 ; length = 1 line = 11 ; column = 17 ; value ='1'; } +{kind = TOKEN_COMMA; ; index = 259 ; length = 1 line = 11 ; column = 18 ; value =','; } +{kind = TOKEN_INTLITERAL; ; index = 261 ; length = 1 line = 11 ; column = 20 ; value ='1'; } +{kind = TOKEN_COMMA; ; index = 262 ; length = 1 line = 11 ; column = 21 ; value =','; } +{kind = TOKEN_INTLITERAL; ; index = 264 ; length = 1 line = 11 ; column = 23 ; value ='1'; } +{kind = TOKEN_RIGHTPAREN; ; index = 265 ; length = 1 line = 11 ; column = 24 ; value =')'; } +{kind = TOKEN_SEMICOLON; ; index = 266 ; length = 1 line = 11 ; column = 25 ; value =';'; } +{kind = TOKEN_RIGHTBRACE; ; index = 269 ; length = 1 line = 12 ; column = 0 ; value ='}'; } +{kind = TOKEN_EOF; ; index = 272 ; length = 0 line = 13 ; column = 0 ; value =''; } diff --git a/test/lex_all.suite b/test/lex_all.suite index 70625bf..414446e 100644 --- a/test/lex_all.suite +++ b/test/lex_all.suite @@ -53,3 +53,4 @@ test/use_builtin_functions.ink lex test/wrong_argument_count.ink lex test/wrong_multiply.ink lex test/wrong_type_for_function.ink lex +test/hint_in_struct.ink lex \ No newline at end of file diff --git a/test/parse/hint_in_struct.golden b/test/parse/hint_in_struct.golden new file mode 100644 index 0000000..cd8e46c --- /dev/null +++ b/test/parse/hint_in_struct.golden @@ -0,0 +1,6 @@ +(program + (struct VSInput + [(:= position float2 (@position)) + (:= color float4 (@color)) + (#if Env.UV + (:= uv float2 (@UV)))])) \ No newline at end of file diff --git a/test/parse_all.suite b/test/parse_all.suite index d273418..608db02 100644 --- a/test/parse_all.suite +++ b/test/parse_all.suite @@ -53,3 +53,4 @@ test/use_builtin_functions.ink parse test/wrong_argument_count.ink parse test/wrong_multiply.ink parse test/wrong_type_for_function.ink parse +test/hint_in_struct.ink parse \ No newline at end of file