Compare commits
10 Commits
b5ae18d88f
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| d79b4d924c | |||
| 7d832c6ea7 | |||
| b30e04f2fa | |||
| da660ad87e | |||
| 76cd1ba957 | |||
| afced44abe | |||
| 39d2fe6ad0 | |||
| 73f66fd5d4 | |||
| 9cf7b84459 | |||
|
|
d486e4583b |
19
README.md
19
README.md
@@ -1,7 +1,10 @@
|
||||
# Shader Compiler
|
||||
# Ink
|
||||
|
||||
A compiler for a custom, platform-agnostic shader language that compiles to platform specific shader languages (currently only HLSL).
|
||||
|
||||
Ink is not a standalone executable, but rather a library you use to compile your shaders. It has metaprogramming capabilities in the sense that all stages are exposed and data is editable at will.
|
||||
In the future we will support a better API for adding code and possibly macros if we deem it necessary.
|
||||
|
||||
## Features
|
||||
|
||||
A simple passthrough shader (`passthrough.shd`) can look as follows
|
||||
@@ -145,7 +148,7 @@ Field_Kind :: enum {
|
||||
|
||||
Function;
|
||||
Struct;
|
||||
Array; // Not yet supported
|
||||
Array;
|
||||
}
|
||||
|
||||
Field_Type :: struct {
|
||||
@@ -155,15 +158,6 @@ Field_Type :: struct {
|
||||
|
||||
children : [..]Field;
|
||||
}
|
||||
|
||||
Hint_Kind :: enum {
|
||||
None;
|
||||
|
||||
Position;
|
||||
Target;
|
||||
|
||||
Custom;
|
||||
}
|
||||
```
|
||||
|
||||
## Notable missing features
|
||||
@@ -172,3 +166,6 @@ Hint_Kind :: enum {
|
||||
- Multiple render targets
|
||||
- Interpolation specifiers
|
||||
- Importing files such as shared utils etc. with something other than textual `#load`
|
||||
- Other output languages
|
||||
- compute shaders
|
||||
- mesh/amplification shaders
|
||||
51
check.jai
51
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);
|
||||
@@ -2305,8 +2313,8 @@ check :: (ctx : *Compiler_Context, allocator : Allocator = temp) {
|
||||
new_context := context;
|
||||
new_context.allocator = allocator;
|
||||
push_context new_context {
|
||||
init_context_allocators();
|
||||
defer clear_context_allocators();
|
||||
init_scratch();
|
||||
defer clear_scratch();
|
||||
|
||||
checker : Checker;
|
||||
|
||||
@@ -2618,7 +2626,8 @@ pretty_print_symbol_table :: (ctx : *Compiler_Context, allocator : Allocator) ->
|
||||
|
||||
#scope_module
|
||||
|
||||
#import "ncore";
|
||||
#import "Void";
|
||||
#import "Hash_Table";
|
||||
#import "String";
|
||||
#import "Random";
|
||||
#import "Static_Array";
|
||||
|
||||
@@ -608,8 +608,8 @@ codegen :: (result : *Compiler_Context, output_language : Output_Language, alloc
|
||||
new_context := context;
|
||||
new_context.allocator = allocator;
|
||||
push_context new_context {
|
||||
init_context_allocators();
|
||||
defer clear_context_allocators();
|
||||
init_scratch();
|
||||
defer clear_scratch();
|
||||
|
||||
state : Codegen_State;
|
||||
state.ctx = result;
|
||||
@@ -661,4 +661,4 @@ codegen :: (state : *Codegen_State) {
|
||||
}
|
||||
|
||||
#scope_module
|
||||
#import "ncore";
|
||||
#import "Void";
|
||||
|
||||
5
ink.jai
5
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());
|
||||
@@ -644,7 +644,8 @@ evaluate_result :: (result : Result) {
|
||||
main :: () {
|
||||
args := get_command_line_arguments();
|
||||
|
||||
init_context_allocators();
|
||||
init_scratch();
|
||||
defer clear_scratch();
|
||||
|
||||
local_temp := make_arena(Megabytes(128));
|
||||
|
||||
|
||||
24
lexing.jai
24
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;
|
||||
@@ -579,8 +559,8 @@ lex :: (ctx : *Compiler_Context, allocator := temp) {
|
||||
new_context := context;
|
||||
new_context.allocator = allocator;
|
||||
push_context new_context {
|
||||
init_context_allocators();
|
||||
defer clear_context_allocators();
|
||||
init_scratch();
|
||||
defer clear_scratch();
|
||||
|
||||
lexer : Lexer;
|
||||
lexer.ctx = ctx;
|
||||
|
||||
33
module.jai
33
module.jai
@@ -5,6 +5,7 @@
|
||||
#load "codegen.jai";
|
||||
|
||||
#import "File_Utilities";
|
||||
#import "Static_Array";
|
||||
|
||||
/* TODO
|
||||
- [x] Remove builtin stringbuilding and replace it with ad-hoc string building when error reporting. In that case we are already building a string anyway, so we can just pass in the string builder
|
||||
@@ -185,33 +186,6 @@ Compiler_Context :: struct {
|
||||
messages : [..]Compiler_Message;
|
||||
}
|
||||
|
||||
#add_context scratch_allocators : [2]Allocator;
|
||||
#add_context scratch_id : int = 0;
|
||||
|
||||
init_context_allocators :: () {
|
||||
if get_arena(context.scratch_allocators[0]) == null {
|
||||
context.scratch_allocators[0] = make_arena(Megabytes(128));
|
||||
context.scratch_allocators[1] = make_arena(Megabytes(128));
|
||||
}
|
||||
}
|
||||
|
||||
clear_context_allocators :: () {
|
||||
if get_arena(context.scratch_allocators[0]) != null {
|
||||
clear(context.scratch_allocators[0]);
|
||||
clear(context.scratch_allocators[1]);
|
||||
}
|
||||
}
|
||||
|
||||
get_scratch :: (conflict : Allocator = .{}) -> Scratch {
|
||||
arena := cast(*Arena)conflict.data;
|
||||
if arena == get_arena(context.scratch_allocators[0]) || context.scratch_id == 0 {
|
||||
context.scratch_id = 1;
|
||||
return scratch_begin(*context.scratch_allocators[1]);
|
||||
}
|
||||
context.scratch_id = 0;
|
||||
return scratch_begin(*context.scratch_allocators[0]);
|
||||
}
|
||||
|
||||
record_error :: (result : *Compiler_Context, format : string, args : .. Any) {
|
||||
error : Compiler_Message;
|
||||
error.message_kind = .Error;
|
||||
@@ -504,8 +478,8 @@ compile_file :: (ctx : *Compiler_Context, path : string, allocator : Allocator =
|
||||
new_context := context;
|
||||
new_context.allocator = allocator;
|
||||
push_context new_context {
|
||||
init_context_allocators();
|
||||
defer clear_context_allocators();
|
||||
init_scratch();
|
||||
defer clear_scratch();
|
||||
|
||||
ctx.file = make_file(ctx, path);
|
||||
|
||||
@@ -516,3 +490,4 @@ compile_file :: (ctx : *Compiler_Context, path : string, allocator : Allocator =
|
||||
generate_output_data(ctx);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
65
parsing.jai
65
parsing.jai
@@ -643,6 +643,7 @@ precedence :: (parse_state : *Parser, precedence : Precedence, message : string
|
||||
|
||||
while precedence <= get_rule(parse_state.current.kind).precedence {
|
||||
advance(parse_state);
|
||||
|
||||
if parse_state.current.kind == .TOKEN_EOF {
|
||||
tok_s : string;
|
||||
tok_s.data = parse_state.previous.source;
|
||||
@@ -1199,38 +1200,42 @@ 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);
|
||||
|
||||
|
||||
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.");
|
||||
source_location.main_token = identifier;
|
||||
field.name = identifier.ident_value;
|
||||
field.token = identifier;
|
||||
}
|
||||
case .Semicolon; {
|
||||
consume(parse_state, .TOKEN_SEMICOLON, "Expect ';' after field declaration.");
|
||||
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.");
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1471,8 +1476,8 @@ parse :: (ctx : *Compiler_Context, allocator := temp) {
|
||||
new_context := context;
|
||||
new_context.allocator = allocator;
|
||||
push_context new_context {
|
||||
init_context_allocators();
|
||||
defer clear_context_allocators();
|
||||
init_scratch();
|
||||
defer clear_scratch();
|
||||
|
||||
parse_state : Parser;
|
||||
array_reserve(*ctx.nodes, 128); //@Note(niels): This is quite a random number to be honest
|
||||
|
||||
50
pass_test.ink
Normal file
50
pass_test.ink
Normal file
@@ -0,0 +1,50 @@
|
||||
shader Entity {
|
||||
constants :: Constant_Buffer {
|
||||
model : float4x4;
|
||||
projection : float4x4;
|
||||
light_view : float4x4;
|
||||
|
||||
light_dir : float3;
|
||||
light_color : float3;
|
||||
}
|
||||
|
||||
Vertex_In :: struct {
|
||||
position : float3;
|
||||
normal : float3;
|
||||
uv : float2;
|
||||
}
|
||||
|
||||
Vertex_Out :: struct {
|
||||
position : float4;
|
||||
normal : float3;
|
||||
uv : float2;
|
||||
world_pos : float3;
|
||||
}
|
||||
|
||||
vertex main :: (in : Vertex_In) -> Vertex_Out {
|
||||
// Do some stuff here
|
||||
}
|
||||
|
||||
pass : shadow {
|
||||
vertex = main;
|
||||
pixel :: (in : Vertex_Out) -> float4 {
|
||||
// Do some shadow stuff
|
||||
}
|
||||
}
|
||||
|
||||
pass : picking {
|
||||
vertex = main;
|
||||
pixel :: (in : Vertex_Out) -> float4 {
|
||||
// Do some picking stuff
|
||||
}
|
||||
}
|
||||
|
||||
pass : lighting {
|
||||
vertex = main;
|
||||
pixel :: (in : Vertex_Out) -> float4 {
|
||||
// Do some lighting stuff
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Binary file not shown.
8
test/check/hint_in_struct.golden
Normal file
8
test/check/hint_in_struct.golden
Normal file
@@ -0,0 +1,8 @@
|
||||
scope (global) [
|
||||
[VSInput] : {position : float2, color : float4, color : float4, uv : float2}
|
||||
scope (VSInput) [
|
||||
[position] : float2
|
||||
[uv] : float2
|
||||
[color] : float4
|
||||
]
|
||||
]
|
||||
@@ -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
|
||||
]
|
||||
]
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -28,3 +28,4 @@ test/simple_struct_access.ink compile
|
||||
test/struct_within_struct.ink compile
|
||||
test/unary.ink compile
|
||||
test/use_builtin_functions.ink compile
|
||||
test/hint_in_struct.ink compile
|
||||
@@ -1,4 +1,4 @@
|
||||
p :: properties {
|
||||
p :: Constant_Buffer {
|
||||
time : float @time;
|
||||
}
|
||||
|
||||
|
||||
8
test/dangling_dot.ink
Normal file
8
test/dangling_dot.ink
Normal file
@@ -0,0 +1,8 @@
|
||||
Foo :: struct {
|
||||
v : float2;
|
||||
}
|
||||
|
||||
vertex main :: () {
|
||||
f : Foo;
|
||||
f..v.x = 0.0;
|
||||
}
|
||||
10
test/hint_in_struct.ink
Normal file
10
test/hint_in_struct.ink
Normal file
@@ -0,0 +1,10 @@
|
||||
#add_define UV
|
||||
|
||||
VSInput :: struct {
|
||||
position : float2 @position;
|
||||
color : float4 @color;
|
||||
|
||||
#if Env.UV {
|
||||
uv : float2 @UV;
|
||||
}
|
||||
}
|
||||
@@ -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 =''; }
|
||||
|
||||
@@ -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
|
||||
6
test/parse/hint_in_struct.golden
Normal file
6
test/parse/hint_in_struct.golden
Normal file
@@ -0,0 +1,6 @@
|
||||
(program
|
||||
(struct VSInput
|
||||
[(:= position float2 (@position))
|
||||
(:= color float4 (@color))
|
||||
(#if Env.UV
|
||||
(:= uv float2 (@UV)))]))
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user