Compare commits
68 Commits
d9dfcc6354
...
new-builti
| Author | SHA1 | Date | |
|---|---|---|---|
| d5476b54d7 | |||
| 622ce388fa | |||
| b0653b6563 | |||
| d6ea2e4c2f | |||
| 361a310ed1 | |||
| 78e6d6146e | |||
| 79ec6cc42f | |||
| 9461fe626f | |||
| ceafd197f5 | |||
| f4a9592f26 | |||
| 9cf51a1534 | |||
| 11c936ba7f | |||
| 4924b01eac | |||
| 603b625e21 | |||
| 9e0728f952 | |||
| 94fc3a4dad | |||
| 14f8b20d5f | |||
| 4825623c73 | |||
| da87209690 | |||
| e0908a67c0 | |||
| ab711b5610 | |||
| f6801e3eeb | |||
| 4f37ed03c0 | |||
| 5b2e2e936b | |||
| b491a56409 | |||
| 45f67e16a8 | |||
| 01ffe9c73d | |||
| 382d790c5b | |||
| 27933e599a | |||
| b7e34a22b2 | |||
| c36712b3ed | |||
| 6b6c7bce62 | |||
| e356c5a3a9 | |||
| 5ec2186a42 | |||
| af3e298b29 | |||
| af42b61ed6 | |||
| cd167d1560 | |||
| 8ce8651d6b | |||
| 42c5baa846 | |||
| 45ea54cf93 | |||
| b4d119230b | |||
| a72a9ff50d | |||
| 41d1dd406d | |||
| bc69a39570 | |||
| aaeda22fa3 | |||
| 4b927b6be9 | |||
| 85b23f90e5 | |||
| ec31046d30 | |||
| 8bd766281e | |||
| 4053400152 | |||
| 1adb289c10 | |||
| d65c6359db | |||
| d08529a3eb | |||
| 7787d1307b | |||
| 4deb07027f | |||
| f13508262b | |||
| 90fb1a035e | |||
| e365067354 | |||
| 243d83663a | |||
| 3f93e1a92d | |||
| fca325b761 | |||
| d3aa4fffeb | |||
| 6eba51cc8c | |||
| 5b237d34de | |||
| ff668b6c95 | |||
| c84516d39f | |||
| 517209c886 | |||
| d01fca146c |
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -1,3 +1,6 @@
|
||||
[submodule "modules/nbrutil"]
|
||||
path = modules/ncore
|
||||
url = git@git.nbross.com:nielsbross/NCore.git
|
||||
[submodule "modules/tracy"]
|
||||
path = modules/tracy
|
||||
url = https://github.com/rluba/jai-tracy.git
|
||||
|
||||
241
AST.jai
241
AST.jai
@@ -14,12 +14,16 @@ AST_Kind :: enum {
|
||||
Meta;
|
||||
Instance;
|
||||
//==
|
||||
// Directives
|
||||
If_Directive;
|
||||
|
||||
// Hint;
|
||||
// Type;
|
||||
// Operator;
|
||||
Call;
|
||||
Struct;
|
||||
If;
|
||||
For;
|
||||
CBuffer;
|
||||
FieldList;
|
||||
ArgList;
|
||||
@@ -71,22 +75,25 @@ AST_Node :: struct {
|
||||
pixel_entry_point : bool;
|
||||
}
|
||||
|
||||
|
||||
// ===========================================================
|
||||
// Pretty printing
|
||||
pretty_print_call :: (node : *AST_Node, indentation : int, builder : *String_Builder) {
|
||||
indent(builder, indentation);
|
||||
pretty_print_call :: (node : *AST_Node, indentation : int, builder : *String_Builder, skip_indent := false) {
|
||||
if !skip_indent {
|
||||
indent(builder, indentation);
|
||||
}
|
||||
append(builder, "(");
|
||||
append(builder, node.name);
|
||||
if node.children.count > 0 {
|
||||
append(builder, " ");
|
||||
pretty_print_children(node.children[0], indentation, builder, flags = 0);
|
||||
pretty_print_children(node.children[0], indentation, builder, flags = 0, skip_indent = true);
|
||||
}
|
||||
append(builder, ")");
|
||||
}
|
||||
|
||||
pretty_print_arglist :: (node : *AST_Node, indentation : int, builder : *String_Builder) {
|
||||
indent(builder, indentation);
|
||||
pretty_print_arglist :: (node : *AST_Node, indentation : int, builder : *String_Builder, skip_indent := false) {
|
||||
if !skip_indent {
|
||||
indent(builder, indentation);
|
||||
}
|
||||
append(builder, "[");
|
||||
|
||||
pretty_print_children(node, indentation + 1, builder, flags = .NewLine);
|
||||
@@ -94,8 +101,10 @@ pretty_print_arglist :: (node : *AST_Node, indentation : int, builder : *String_
|
||||
append(builder, "]");
|
||||
}
|
||||
|
||||
pretty_print_fieldlist :: (node : *AST_Node, indentation : int, builder : *String_Builder) {
|
||||
indent(builder, indentation);
|
||||
pretty_print_fieldlist :: (node : *AST_Node, indentation : int, builder : *String_Builder, skip_indent := false) {
|
||||
if !skip_indent {
|
||||
indent(builder, indentation);
|
||||
}
|
||||
|
||||
append(builder, "[");
|
||||
pretty_print_children(node, indentation + 1, builder, flags = .NewLine);
|
||||
@@ -103,13 +112,16 @@ pretty_print_fieldlist :: (node : *AST_Node, indentation : int, builder : *Strin
|
||||
append(builder, "]");
|
||||
}
|
||||
|
||||
pretty_print_field :: (node : *AST_Node, indentation : int, builder : *String_Builder) {
|
||||
pretty_print_field :: (node : *AST_Node, indentation : int, builder : *String_Builder, skip_indent := false) {
|
||||
if !skip_indent {
|
||||
indent(builder, indentation);
|
||||
}
|
||||
print_to_builder(builder, tprint("(:= %", node.name));
|
||||
|
||||
if node.kind != .Unnamed_Field && node.token.ident_value.count > 0 {
|
||||
if node.array_field {
|
||||
append(builder, " [");
|
||||
pretty_print_node(node.children[0], 0, builder);
|
||||
pretty_print_node(node.children[0], indentation, builder, true);
|
||||
append(builder, "].");
|
||||
print_to_builder(builder, "%", node.token.ident_value);
|
||||
} else {
|
||||
@@ -126,31 +138,68 @@ pretty_print_field :: (node : *AST_Node, indentation : int, builder : *String_Bu
|
||||
|
||||
if !node.array_field && node.children.count > 0 {
|
||||
append(builder, " ");
|
||||
pretty_print_children(node, indentation, builder);
|
||||
pretty_print_node(node.children[0], indentation, builder, true);
|
||||
}
|
||||
|
||||
append(builder, ")");
|
||||
}
|
||||
|
||||
Children_Print_Flags :: enum_flags {
|
||||
NewLine :: 1 << 0;
|
||||
Separator :: 1 << 1;
|
||||
Space :: 1 << 2;
|
||||
NewLine :: 1 << 0;
|
||||
Separator :: 1 << 1;
|
||||
Space :: 1 << 2;
|
||||
Dont_Skip_Indent_On_First :: 1 << 3;
|
||||
}
|
||||
|
||||
pretty_print_children :: (parent : *AST_Node, indentation : int, builder : *String_Builder, flags : Children_Print_Flags = .Separator) {
|
||||
pretty_print_block :: (node : *AST_Node, indentation : int, builder : *String_Builder, skip_indent := false) {
|
||||
if node.children.count == 0 {
|
||||
if !skip_indent {
|
||||
indent(builder, indentation);
|
||||
}
|
||||
append(builder, "()");
|
||||
} else {
|
||||
flags := Children_Print_Flags.NewLine;
|
||||
if !skip_indent {
|
||||
flags |= .Dont_Skip_Indent_On_First;
|
||||
}
|
||||
pretty_print_children(node, indentation, builder, flags);
|
||||
}
|
||||
}
|
||||
|
||||
pretty_print_children :: (parent : *AST_Node, indentation : int, builder : *String_Builder, flags : Children_Print_Flags = .Separator, skip_indent := false) {
|
||||
if !parent {
|
||||
return;
|
||||
}
|
||||
|
||||
children := parent.children;
|
||||
for child : children {
|
||||
if it_index > 0 {
|
||||
indent(builder, indentation);
|
||||
}
|
||||
// if it_index > 0 {
|
||||
// indent(builder, indentation);
|
||||
// }
|
||||
|
||||
if !child continue;
|
||||
pretty_print_node(child, 0, builder);
|
||||
|
||||
|
||||
ind := indentation;
|
||||
if flags & .Dont_Skip_Indent_On_First {
|
||||
ind = indentation;
|
||||
} else {
|
||||
if it_index == 0 {
|
||||
ind = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if skip_indent{
|
||||
ind = 0;
|
||||
}
|
||||
// skip := ifx it_index > 0 then false else true;
|
||||
|
||||
if child.kind == .Function {
|
||||
pretty_print_declaration(child, ind, builder);
|
||||
} else {
|
||||
pretty_print_node(child, ind, builder);
|
||||
}
|
||||
|
||||
|
||||
if it_index != children.count - 1 {
|
||||
if flags & .Separator {
|
||||
@@ -176,6 +225,16 @@ op_to_string :: (oper : Token) -> string {
|
||||
return "*";
|
||||
case .TOKEN_SLASH;
|
||||
return "/";
|
||||
case .TOKEN_MINUSEQUALS;
|
||||
return "-=";
|
||||
case .TOKEN_PLUSEQUALS;
|
||||
return "+=";
|
||||
case .TOKEN_DIVEQUALS;
|
||||
return "/=";
|
||||
case .TOKEN_TIMESEQUALS;
|
||||
return "*=";
|
||||
case .TOKEN_MODEQUALS;
|
||||
return "%=";
|
||||
case .TOKEN_ISEQUAL;
|
||||
return "==";
|
||||
case .TOKEN_ASSIGN;
|
||||
@@ -198,95 +257,161 @@ op_to_string :: (oper : Token) -> string {
|
||||
return "";
|
||||
}
|
||||
|
||||
pretty_print_binary :: (node : *AST_Node, indentation : int, builder : *String_Builder) {
|
||||
indent(builder, indentation);
|
||||
pretty_print_binary :: (node : *AST_Node, indentation : int, builder : *String_Builder, skip_indent := false) {
|
||||
if !skip_indent {
|
||||
indent(builder, indentation);
|
||||
}
|
||||
append(builder, "(");
|
||||
op := node.token;
|
||||
|
||||
print_to_builder(builder, op_to_string(op));
|
||||
append(builder, " ");
|
||||
|
||||
pretty_print_children(node, 0, builder, flags = 0);
|
||||
pretty_print_node(node.children[0], 0, builder);
|
||||
append(builder, " ");
|
||||
pretty_print_node(node.children[1], 0, builder);
|
||||
append(builder, ")");
|
||||
}
|
||||
|
||||
pretty_print_unary :: (node : *AST_Node, indentation : int, builder : *String_Builder) {
|
||||
pretty_print_unary :: (node : *AST_Node, indentation : int, builder : *String_Builder, skip_indent := false) {
|
||||
if !skip_indent {
|
||||
indent(builder, indentation);
|
||||
}
|
||||
op := node.token;
|
||||
|
||||
print_to_builder(builder, op_to_string(op));
|
||||
pretty_print_node(node.children[0], 0, builder);
|
||||
}
|
||||
|
||||
print_return_node :: (node : *AST_Node, indentation : int, builder : *String_Builder) {
|
||||
print_return_node :: (node : *AST_Node, indentation : int, builder : *String_Builder, skip_indent := false) {
|
||||
if !skip_indent {
|
||||
indent(builder, indentation);
|
||||
}
|
||||
append(builder, "(return ");
|
||||
|
||||
pretty_print_children(node, 0, builder);
|
||||
pretty_print_children(node, indentation, builder);
|
||||
|
||||
append(builder, ")");
|
||||
}
|
||||
|
||||
print_expression_statement :: (node : *AST_Node, indentation : int, builder : *String_Builder) {
|
||||
indent(builder, indentation);
|
||||
pretty_print_if :: (node : *AST_Node, indentation : int, builder : *String_Builder, skip_indent := false) {
|
||||
if !skip_indent {
|
||||
indent(builder, indentation);
|
||||
}
|
||||
append(builder, "(if ");
|
||||
|
||||
condition := node.children[0];
|
||||
pretty_print_node(condition, 0, builder);
|
||||
append(builder, "\n");
|
||||
|
||||
body := node.children[1];
|
||||
// indent(builder,indentation + 4);
|
||||
// append(builder, "(");
|
||||
pretty_print_node(body, indentation + 4, builder);
|
||||
// append(builder, ")");
|
||||
|
||||
if node.children.count == 3 {
|
||||
append(builder, "\n");
|
||||
pretty_print_node(node.children[2], indentation + 4, builder);
|
||||
}
|
||||
|
||||
append(builder, ")");
|
||||
}
|
||||
|
||||
pretty_print_for :: (node : *AST_Node, indentation : int, builder : *String_Builder, skip_indent := false) {
|
||||
if !skip_indent {
|
||||
indent(builder, indentation);
|
||||
}
|
||||
|
||||
append(builder, "(for ");
|
||||
|
||||
loop_iterator := node.token;
|
||||
print_to_builder(builder, "% : ", loop_iterator.ident_value);
|
||||
|
||||
pretty_print_node(node.children[0], 0, builder);
|
||||
append(builder, "..");
|
||||
pretty_print_node(node.children[1], 0, builder);
|
||||
append(builder, "\n");
|
||||
|
||||
pretty_print_node(node.children[2], indentation + 4, builder);
|
||||
|
||||
append(builder, ")");
|
||||
}
|
||||
|
||||
print_expression_statement :: (node : *AST_Node, indentation : int, builder : *String_Builder, skip_indent := false) {
|
||||
if !skip_indent {
|
||||
indent(builder, indentation);
|
||||
}
|
||||
|
||||
if node.children[0] {
|
||||
pretty_print_node(node.children[0], indentation, builder);
|
||||
pretty_print_node(node.children[0], 0, builder);
|
||||
}
|
||||
}
|
||||
|
||||
pretty_print_node :: (node : *AST_Node, indentation : int, builder : *String_Builder) {
|
||||
pretty_print_node :: (node : *AST_Node, indentation : int, builder : *String_Builder, skip_indent := false) {
|
||||
if node.kind == {
|
||||
case .Return; {
|
||||
print_return_node(node, indentation, builder);
|
||||
print_return_node(node, indentation, builder, skip_indent);
|
||||
}
|
||||
case .If; {
|
||||
pretty_print_if(node, indentation, builder, skip_indent);
|
||||
}
|
||||
case .For; {
|
||||
pretty_print_for(node, indentation, builder, skip_indent);
|
||||
}
|
||||
case .Struct;
|
||||
case .ArgList; {
|
||||
pretty_print_arglist(node, indentation + 2, builder);
|
||||
pretty_print_arglist(node, indentation + 2, builder, skip_indent);
|
||||
}
|
||||
case .FieldList; {
|
||||
pretty_print_fieldlist(node, indentation + 2, builder);
|
||||
pretty_print_fieldlist(node, indentation + 2, builder, skip_indent);
|
||||
}
|
||||
case .Field; {
|
||||
pretty_print_field(node, indentation, builder);
|
||||
pretty_print_field(node, indentation, builder, skip_indent);
|
||||
}
|
||||
case .Unnamed_Field; {
|
||||
pretty_print_field(node, indentation, builder);
|
||||
pretty_print_field(node, indentation, builder, skip_indent);
|
||||
}
|
||||
case .Block; {
|
||||
pretty_print_children(node, indentation + 2, builder, flags = .NewLine);
|
||||
pretty_print_block(node, indentation, builder, skip_indent);
|
||||
}
|
||||
case .Binary; {
|
||||
pretty_print_binary(node, indentation, builder);
|
||||
pretty_print_binary(node, indentation, builder, skip_indent);
|
||||
}
|
||||
case .Unary; {
|
||||
pretty_print_unary(node, indentation, builder);
|
||||
pretty_print_unary(node, indentation, builder, skip_indent);
|
||||
}
|
||||
case .Variable; {
|
||||
pretty_print_variable(node, indentation, builder);
|
||||
pretty_print_variable(node, indentation, builder, skip_indent);
|
||||
}
|
||||
case .Expression_Statement; {
|
||||
print_expression_statement(node, indentation, builder);
|
||||
print_expression_statement(node, indentation, builder, skip_indent);
|
||||
}
|
||||
case .Integer; {
|
||||
print_to_builder(builder, "%", node.integer_value);
|
||||
print_to_builder(builder, "%", node.integer_value, skip_indent);
|
||||
}
|
||||
case .Float; {
|
||||
print_to_builder(builder, "%", node.float_value);
|
||||
print_to_builder(builder, "%", node.float_value, skip_indent);
|
||||
}
|
||||
case .Call; {
|
||||
pretty_print_call(node, indentation, builder);
|
||||
pretty_print_call(node, indentation, builder, skip_indent);
|
||||
}
|
||||
case .Error; {
|
||||
print_to_builder(builder, "(error \"%\")", node.name);
|
||||
print_to_builder(builder, "(error \"%\")", node.name, skip_indent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pretty_print_variable :: (node : *AST_Node, indentation : int, builder : *String_Builder) {
|
||||
indent(builder, indentation);
|
||||
pretty_print_variable :: (node : *AST_Node, indentation : int, builder : *String_Builder, skip_indent := false) {
|
||||
if !skip_indent {
|
||||
indent(builder, indentation);
|
||||
}
|
||||
print_to_builder(builder, "%", node.name);
|
||||
|
||||
for child : node.children {
|
||||
print("%\n", child.kind);
|
||||
if child.kind == .Variable {
|
||||
append(builder, ".");
|
||||
pretty_print_variable(child, indentation, builder);
|
||||
pretty_print_variable(child, indentation, builder, skip_indent = true);
|
||||
} else if child.kind == .Unary {
|
||||
append(builder, "[");
|
||||
pretty_print_node(child.children[0], 0, builder);
|
||||
@@ -295,8 +420,10 @@ pretty_print_variable :: (node : *AST_Node, indentation : int, builder : *String
|
||||
}
|
||||
}
|
||||
|
||||
pretty_print_declaration :: (declaration : *AST_Node, indentation : int, builder : *String_Builder) {
|
||||
indent(builder, indentation);
|
||||
pretty_print_declaration :: (declaration : *AST_Node, indentation : int, builder : *String_Builder, skip_indent := false) {
|
||||
if !skip_indent {
|
||||
indent(builder, indentation);
|
||||
}
|
||||
append(builder, "(");
|
||||
|
||||
if declaration.foreign_declaration {
|
||||
@@ -315,6 +442,10 @@ pretty_print_declaration :: (declaration : *AST_Node, indentation : int, builder
|
||||
append(builder, "pixel ");
|
||||
}
|
||||
|
||||
if declaration.kind == .If_Directive {
|
||||
append(builder, "#if ");
|
||||
}
|
||||
|
||||
if declaration.kind == .Properties {
|
||||
append(builder, "properties");
|
||||
if declaration.name.count > 0 {
|
||||
@@ -341,12 +472,18 @@ pretty_print_declaration :: (declaration : *AST_Node, indentation : int, builder
|
||||
print_to_builder(builder, " (@%)", hint.string_value);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if declaration.children.count > 0 {
|
||||
print_to_builder(builder, "\n");
|
||||
pretty_print_children(declaration, indentation + 1, builder, flags = .NewLine);
|
||||
if declaration.kind == .If_Directive {
|
||||
pretty_print_node(declaration.children[0], 0, builder);
|
||||
append(builder, "\n");
|
||||
pretty_print_node(declaration.children[1], indentation + 5, builder);
|
||||
} else {
|
||||
print_to_builder(builder, "\n");
|
||||
pretty_print_children(declaration, indentation + 1, builder, flags = .NewLine);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
append(builder, ")");
|
||||
|
||||
335
Codegen.jai
335
Codegen.jai
@@ -1,3 +1,12 @@
|
||||
/////////////////////////////////////
|
||||
//~ nbr:
|
||||
//
|
||||
|
||||
/////////////////////////////////////
|
||||
//~ nbr: Codegen TODOs
|
||||
//
|
||||
// [ ] Prefix output of property values with __PROPERTIES so we don't get name clashes
|
||||
|
||||
Output_Language :: enum {
|
||||
HLSL;
|
||||
GLSL; // @Incomplete
|
||||
@@ -7,31 +16,47 @@ Output_Language :: enum {
|
||||
Codegen_State :: struct {
|
||||
path : string;
|
||||
|
||||
scope_stack : Scope_Stack;
|
||||
// scope_stack : Scope_Stack;
|
||||
current_scope : Scope_Handle;
|
||||
|
||||
type_variables : []Type_Variable;
|
||||
root : *AST_Node;
|
||||
// type_variables : []Type_Variable;
|
||||
// root : *AST_Node;
|
||||
|
||||
output_language : Output_Language;
|
||||
|
||||
builder : String_Builder;
|
||||
|
||||
result : Codegen_Result;
|
||||
result : *Compiler_Context;
|
||||
}
|
||||
|
||||
Codegen_Result :: struct {
|
||||
messages : [..]Compiler_Message;
|
||||
// Codegen_Result :: struct {
|
||||
// messages : [..]Compiler_Message;
|
||||
|
||||
had_error : bool;
|
||||
// had_error : bool;
|
||||
|
||||
result_text : string; // @Incomplete(nb): Result for now, should likely be far more sophisticated.
|
||||
}
|
||||
// result_text : string; // @Incomplete(nb): Result for now, should likely be far more sophisticated.
|
||||
// }
|
||||
|
||||
init_codegen_state :: (state : *Codegen_State, root : *AST_Node, checker_result : Semantic_Check_Result, output_language : Output_Language) {
|
||||
state.root = root;
|
||||
state.scope_stack = checker_result.scope_stack;
|
||||
state.type_variables = checker_result.type_variables;
|
||||
Reserved_HLSL_Words :: string.[
|
||||
"texture",
|
||||
"sampler",
|
||||
"matrix",
|
||||
"line",
|
||||
"precise",
|
||||
"shared",
|
||||
"triangle",
|
||||
"triangleadj",
|
||||
];
|
||||
|
||||
Reserved_MLSL_Words :: string.[
|
||||
""
|
||||
];
|
||||
|
||||
Reserved_GLSL_Words :: string.[
|
||||
""
|
||||
];
|
||||
|
||||
init_codegen_state :: (state : *Codegen_State, result : *Compiler_Context, output_language : Output_Language) {
|
||||
state.current_scope = cast(Scope_Handle)1;
|
||||
state.output_language = output_language;
|
||||
init_string_builder(*state.builder);
|
||||
@@ -41,13 +66,57 @@ indent :: (state : *Codegen_State, indentation : int) {
|
||||
for 1..indentation append(*state.builder, " ");
|
||||
}
|
||||
|
||||
emit_field :: (state : *Codegen_State, node : *AST_Node, indentation : int) {
|
||||
find_result := find_symbol(state.scope_stack, node.name, state.current_scope);
|
||||
hlsl_type_to_string :: (type_variable : Type_Variable) -> string {
|
||||
if type_variable.type == {
|
||||
case .Invalid;
|
||||
return "{{invalid}}";
|
||||
case .Unit;
|
||||
return "()";
|
||||
case .Int; {
|
||||
return "int";
|
||||
}
|
||||
case .Half; {
|
||||
return "half";
|
||||
}
|
||||
case .Float; {
|
||||
return "float";
|
||||
}
|
||||
case .Double; {
|
||||
return "double";
|
||||
}
|
||||
case .Sampler; {
|
||||
return "SamplerState";
|
||||
}
|
||||
case .Texture2D; {
|
||||
return "Texture2D";
|
||||
}
|
||||
case .Function; #through;
|
||||
case .Struct; {
|
||||
return type_variable.typename;
|
||||
}
|
||||
case .Array;
|
||||
return "array";
|
||||
}
|
||||
|
||||
field := h2tv(state.type_variables, find_result.type_variable);
|
||||
return "";
|
||||
}
|
||||
|
||||
emit_field :: (state : *Codegen_State, node : *AST_Node, indentation : int) {
|
||||
find_result := find_symbol(state.result.scope_stack, node.name, state.current_scope);
|
||||
|
||||
field := from_handle(state.result.type_variables, find_result.type_variable);
|
||||
|
||||
indent(state, indentation);
|
||||
print_to_builder(*state.builder, "% ", type_to_string(field));
|
||||
|
||||
print_to_builder(*state.builder, "% ", hlsl_type_to_string(field));
|
||||
|
||||
if field.struct_field_parent {
|
||||
parent_tv := from_handle(state.result.type_variables, field.struct_field_parent.type_variable);
|
||||
|
||||
if parent_tv.typename == "properties" {
|
||||
append(*state.builder, "__PROPERTIES__");
|
||||
}
|
||||
}
|
||||
print_to_builder(*state.builder, "%", node.name);
|
||||
|
||||
if field.type == .Sampler {
|
||||
@@ -58,15 +127,21 @@ emit_field :: (state : *Codegen_State, node : *AST_Node, indentation : int) {
|
||||
print_to_builder(*state.builder, " : register(t%)", field.resource_index);
|
||||
}
|
||||
|
||||
for i :0..node.children.count - 1 {
|
||||
child := node.children[i];
|
||||
if node.children.count == 1 {
|
||||
child := node.children[0];
|
||||
|
||||
print_to_builder(*state.builder, " = ");
|
||||
emit_node(state, child, 0);
|
||||
|
||||
}
|
||||
|
||||
for i :0..field.child_count - 1 {
|
||||
child := h2tv(state.type_variables, field.children[i]);
|
||||
if node.parent.kind == .Block {
|
||||
append(*state.builder, ";");
|
||||
}
|
||||
|
||||
|
||||
for i :0..field.children.count - 1 {
|
||||
child := from_handle(state.result.type_variables, field.children[i]);
|
||||
emit_node(state, child.source_node, 0);
|
||||
}
|
||||
|
||||
@@ -74,6 +149,10 @@ emit_field :: (state : *Codegen_State, node : *AST_Node, indentation : int) {
|
||||
if hint.ident_value == "position" {
|
||||
// @Incomplete(nb): Should be a lookup table somewhere
|
||||
append(*state.builder, " : POSITION");
|
||||
} else if hint.ident_value == "uv" {
|
||||
append(*state.builder, " : TEXCOORD0");
|
||||
} else if hint.ident_value == "outposition" {
|
||||
append(*state.builder, " : SV_POSITION");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -83,7 +162,7 @@ emit_block :: (state : *Codegen_State, node : *AST_Node, indentation : int) {
|
||||
emit_node(state, statement, indentation);
|
||||
|
||||
if it_index < node.children.count {
|
||||
append(*state.builder, ";\n");
|
||||
append(*state.builder, "\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -97,7 +176,7 @@ emit_call :: (state : *Codegen_State, node : *AST_Node, indentation : int) {
|
||||
|
||||
emit_node(state, args.children[0], 0);
|
||||
append(*state.builder, ".");
|
||||
print_to_builder(*state.builder, "%(", node.name);
|
||||
print_to_builder(*state.builder, "Sample(");
|
||||
|
||||
for i : 1..args.children.count - 1 {
|
||||
child := args.children[i];
|
||||
@@ -108,6 +187,24 @@ emit_call :: (state : *Codegen_State, node : *AST_Node, indentation : int) {
|
||||
append(*state.builder, ", ");
|
||||
}
|
||||
}
|
||||
} else if starts_with(node.name, "float") && node.children[0].children.count == 1 {
|
||||
args := node.children[0];
|
||||
|
||||
print_to_builder(*state.builder, "%(", node.name);
|
||||
|
||||
number : string;
|
||||
number.data = *node.name.data[5];
|
||||
number.count = node.name.count - 5;
|
||||
count := parse_int(*number, s32);
|
||||
|
||||
for i : 0..count - 1 {
|
||||
child := args.children[0];
|
||||
emit_node(state, child, 0);
|
||||
|
||||
if i != count - 1 {
|
||||
append(*state.builder, ", ");
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
print_to_builder(*state.builder, "%(", node.name);
|
||||
@@ -130,7 +227,7 @@ emit_call :: (state : *Codegen_State, node : *AST_Node, indentation : int) {
|
||||
}
|
||||
|
||||
emit_properties :: (state : *Codegen_State, node : *AST_Node, indentation : int) {
|
||||
find_result := find_symbol(state.scope_stack, ifx node.name.count > 0 then node.name else "properties", state.current_scope);
|
||||
find_result := find_symbol(state.result.scope_stack, ifx node.name.count > 0 then node.name else "properties", state.current_scope);
|
||||
|
||||
if !find_result {
|
||||
message : Compiler_Message;
|
||||
@@ -141,7 +238,7 @@ emit_properties :: (state : *Codegen_State, node : *AST_Node, indentation : int)
|
||||
}
|
||||
assert(find_result != null, "Attempting to generate undeclared properties buffer. This should never happen at this stage.");
|
||||
|
||||
variable := h2tv(state.type_variables, find_result.type_variable);
|
||||
variable := from_handle(state.result.type_variables, find_result.type_variable);
|
||||
|
||||
print_to_builder(*state.builder, "cbuffer __PROPERTIES : register(b%) \n{\n", variable.resource_index);
|
||||
|
||||
@@ -153,7 +250,7 @@ emit_properties :: (state : *Codegen_State, node : *AST_Node, indentation : int)
|
||||
for child : node.children {
|
||||
if child.kind == .FieldList {
|
||||
for field : child.children {
|
||||
tv := h2tv(state.type_variables, field.type_variable);
|
||||
tv := from_handle(state.result.type_variables, field.type_variable);
|
||||
if tv.type == .Sampler || tv.type == .Texture2D {
|
||||
array_add(*resources, field);
|
||||
continue;
|
||||
@@ -181,7 +278,7 @@ emit_properties :: (state : *Codegen_State, node : *AST_Node, indentation : int)
|
||||
|
||||
emit_function :: (state : *Codegen_State, node : *AST_Node, indentation : int, emit_body := true) {
|
||||
name := get_actual_function_name(node);
|
||||
find_result := find_symbol(state.scope_stack, name, state.current_scope);
|
||||
find_result := find_symbol(state.result.scope_stack, name, state.current_scope);
|
||||
|
||||
assert(find_result != null, "Attempting to generate undeclared function. This should never happen at this stage.");
|
||||
if !find_result {
|
||||
@@ -193,13 +290,13 @@ emit_function :: (state : *Codegen_State, node : *AST_Node, indentation : int, e
|
||||
}
|
||||
|
||||
for func : find_result.functions {
|
||||
function_variable := h2tv(state.type_variables, func.type_variable);
|
||||
function_variable := from_handle(state.result.type_variables, func.type_variable);
|
||||
|
||||
indent(state, indentation);
|
||||
|
||||
if function_variable.return_type_variable {
|
||||
return_variable := h2tv(state.type_variables, function_variable.return_type_variable);
|
||||
print_to_builder(*state.builder, "% ", type_to_string(return_variable));
|
||||
return_variable := from_handle(state.result.type_variables, function_variable.return_type_variable);
|
||||
print_to_builder(*state.builder, "% ", hlsl_type_to_string(return_variable));
|
||||
} else {
|
||||
append(*state.builder, "void ");
|
||||
}
|
||||
@@ -271,7 +368,22 @@ emit_operator :: (state : *Codegen_State, op_kind : Token_Kind) {
|
||||
}
|
||||
case .TOKEN_SLASH; {
|
||||
append(*state.builder, "/");
|
||||
}
|
||||
}
|
||||
case .TOKEN_MINUSEQUALS; {
|
||||
append(*state.builder, "-=");
|
||||
}
|
||||
case .TOKEN_PLUSEQUALS; {
|
||||
append(*state.builder, "+=");
|
||||
}
|
||||
case .TOKEN_DIVEQUALS; {
|
||||
append(*state.builder, "/=");
|
||||
}
|
||||
case .TOKEN_TIMESEQUALS; {
|
||||
append(*state.builder, "*=");
|
||||
}
|
||||
case .TOKEN_MODEQUALS; {
|
||||
append(*state.builder, "%=");
|
||||
}
|
||||
case .TOKEN_ISEQUAL; {
|
||||
append(*state.builder, "==");
|
||||
}
|
||||
@@ -317,15 +429,23 @@ emit_node :: (state : *Codegen_State, node : *AST_Node, indentation : int) {
|
||||
emit_field(state, node, indentation);
|
||||
}
|
||||
case .Block; {
|
||||
|
||||
assert(false, "Not implemented yet: block");
|
||||
}
|
||||
case .Variable; {
|
||||
indent(*state.builder, indentation);
|
||||
|
||||
type_var := h2tv(state.type_variables, node.type_variable);
|
||||
type_var := from_handle(state.result.type_variables, node.type_variable);
|
||||
is_properties := type_var.typename == "properties";
|
||||
|
||||
if !is_properties {
|
||||
if type_var.struct_field_parent {
|
||||
parent_tv := from_handle(state.result.type_variables, type_var.struct_field_parent.type_variable);
|
||||
|
||||
if parent_tv.typename == "properties" {
|
||||
append(*state.builder, "__PROPERTIES__");
|
||||
}
|
||||
}
|
||||
print_to_builder(*state.builder, "%", node.name);
|
||||
}
|
||||
|
||||
@@ -338,6 +458,11 @@ emit_node :: (state : *Codegen_State, node : *AST_Node, indentation : int) {
|
||||
}
|
||||
case .Binary; {
|
||||
indent(*state.builder, indentation);
|
||||
|
||||
if node.token.kind != .TOKEN_ASSIGN {
|
||||
append(*state.builder, "(");
|
||||
}
|
||||
|
||||
lhs := node.children[0];
|
||||
rhs := node.children[1];
|
||||
emit_node(state, lhs, 0);
|
||||
@@ -346,12 +471,19 @@ emit_node :: (state : *Codegen_State, node : *AST_Node, indentation : int) {
|
||||
emit_operator(state, node.token.kind);
|
||||
append(*state.builder, " ");
|
||||
emit_node(state, rhs, 0);
|
||||
if node.token.kind != .TOKEN_ASSIGN {
|
||||
append(*state.builder, ")");
|
||||
}
|
||||
}
|
||||
case .Unary; {
|
||||
assert(false, "Not implemented yet: unary");
|
||||
indent(*state.builder, indentation);
|
||||
|
||||
emit_operator(state, node.token.kind);
|
||||
emit_node(state, node.children[0], 0);
|
||||
}
|
||||
case .Expression_Statement; {
|
||||
emit_node(state, node.children[0], indentation);
|
||||
append(*state.builder, ";");
|
||||
}
|
||||
case .Call; {
|
||||
emit_call(state, node, indentation);
|
||||
@@ -360,7 +492,70 @@ emit_node :: (state : *Codegen_State, node : *AST_Node, indentation : int) {
|
||||
indent(*state.builder, indentation);
|
||||
append(*state.builder, "return ");
|
||||
emit_node(state, node.children[0], 0);
|
||||
append(*state.builder, ";");
|
||||
}
|
||||
case .For; {
|
||||
if node.parent.kind != .For {
|
||||
indent(*state.builder, indentation);
|
||||
}
|
||||
|
||||
append(*state.builder, "for ");
|
||||
|
||||
loop_ident := node.token.ident_value;
|
||||
begin_val := node.children[0].integer_value;
|
||||
end_val := node.children[1].integer_value;
|
||||
print_to_builder(*state.builder, "(int % = %; % < %; %++)\n", loop_ident, begin_val, loop_ident, end_val, loop_ident);
|
||||
|
||||
indent(*state.builder, indentation);
|
||||
append(*state.builder, "{\n");
|
||||
|
||||
emit_block(state, node.children[2], indentation + 1);
|
||||
|
||||
indent(*state.builder, indentation);
|
||||
append(*state.builder, "}\n");
|
||||
}
|
||||
case .If; {
|
||||
if node.parent.kind != .If {
|
||||
indent(*state.builder, indentation);
|
||||
}
|
||||
|
||||
append(*state.builder, "if ");
|
||||
|
||||
cond := node.children[0];
|
||||
emit_node(state, cond, 0);
|
||||
|
||||
body := node.children[1];
|
||||
append(*state.builder, "\n");
|
||||
indent(*state.builder, indentation);
|
||||
append(*state.builder, "{\n");
|
||||
|
||||
emit_block(state, body, indentation + 1);
|
||||
|
||||
indent(*state.builder, indentation);
|
||||
append(*state.builder, "}\n");
|
||||
|
||||
if node.children.count == 3 {
|
||||
emit_else(state, node.children[2], indentation);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
emit_else :: (state : *Codegen_State, node : *AST_Node, indentation : int) {
|
||||
indent(*state.builder, indentation);
|
||||
append(*state.builder, "else ");
|
||||
|
||||
if node.kind == .If {
|
||||
emit_node(state, node, indentation);
|
||||
} else if node.kind == .Block {
|
||||
append(*state.builder, "\n");
|
||||
indent(*state.builder, indentation);
|
||||
append(*state.builder, "{\n");
|
||||
|
||||
emit_block(state, node, indentation + 1);
|
||||
|
||||
indent(*state.builder, indentation);
|
||||
append(*state.builder, "}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -378,7 +573,7 @@ emit_struct :: (state : *Codegen_State, node : *AST_Node, indentation : int) {
|
||||
print_to_builder(*state.builder, "struct %", node.name);
|
||||
|
||||
current_scope := state.current_scope;
|
||||
state.current_scope = h2tv(state.type_variables, node.type_variable).scope;
|
||||
state.current_scope = from_handle(state.result.type_variables, node.type_variable).scope;
|
||||
|
||||
field_list := node.children[0];
|
||||
|
||||
@@ -390,16 +585,16 @@ emit_struct :: (state : *Codegen_State, node : *AST_Node, indentation : int) {
|
||||
|
||||
emit_field_list(state, field_list, indentation);
|
||||
|
||||
append(*state.builder, "}\n\n");
|
||||
append(*state.builder, "};\n\n");
|
||||
state.current_scope = current_scope;
|
||||
}
|
||||
|
||||
emit_cbuffer :: (state : *Codegen_State, node : *AST_Node, indentation : int) {
|
||||
variable := h2tv(state.type_variables, node.type_variable);
|
||||
variable := from_handle(state.result.type_variables, node.type_variable);
|
||||
print_to_builder(*state.builder, "cbuffer % : register(b%)", variable.name, variable.resource_index);
|
||||
|
||||
current_scope := state.current_scope;
|
||||
state.current_scope = h2tv(state.type_variables, node.type_variable).scope;
|
||||
state.current_scope = from_handle(state.result.type_variables, node.type_variable).scope;
|
||||
|
||||
field_list := node.children[0];
|
||||
|
||||
@@ -432,24 +627,50 @@ emit_declaration :: (state : *Codegen_State, node : *AST_Node) {
|
||||
}
|
||||
}
|
||||
|
||||
codegen :: (state : *Codegen_State) -> Codegen_Result {
|
||||
codegen :: (result : *Compiler_Context, allocator := temp) {
|
||||
codegen(result, .HLSL);
|
||||
}
|
||||
|
||||
codegen :: (result : *Compiler_Context, output_language : Output_Language, allocator := temp) {
|
||||
if result.had_error {
|
||||
return;
|
||||
}
|
||||
|
||||
new_context := context;
|
||||
new_context.allocator = allocator;
|
||||
push_context new_context {
|
||||
init_context_allocators();
|
||||
defer clear_context_allocators();
|
||||
|
||||
state : Codegen_State;
|
||||
state.result = result;
|
||||
state.current_scope = cast(Scope_Handle)1;
|
||||
state.output_language = output_language;
|
||||
init_string_builder(*state.builder);
|
||||
|
||||
codegen(*state);
|
||||
}
|
||||
}
|
||||
|
||||
#scope_file
|
||||
codegen :: (state : *Codegen_State) {
|
||||
found_function : bool = false;
|
||||
found_struct : bool = false;
|
||||
// found_struct : bool = false;
|
||||
|
||||
for variable : state.type_variables {
|
||||
if variable.type == .Struct && variable.kind == .Declaration && !variable.builtin {
|
||||
if variable.source_node.kind == .Properties continue;
|
||||
if variable.source_node.kind == .Meta continue;
|
||||
print_to_builder(*state.builder, "struct %;\n", variable.source_node.name);
|
||||
found_struct = true;
|
||||
}
|
||||
}
|
||||
// for variable : state.result.type_variables {
|
||||
// if variable.type == .Struct && variable.kind == .Declaration && !variable.builtin {
|
||||
// if variable.source_node.kind == .Properties continue;
|
||||
// if variable.source_node.kind == .Meta continue;
|
||||
// print_to_builder(*state.builder, "struct %;\n", variable.source_node.name);
|
||||
// found_struct = true;
|
||||
// }
|
||||
// }
|
||||
|
||||
if found_struct {
|
||||
append(*state.builder, "\n");
|
||||
}
|
||||
// if found_struct {
|
||||
// append(*state.builder, "\n");
|
||||
// }
|
||||
|
||||
for variable : state.type_variables {
|
||||
for variable : state.result.type_variables {
|
||||
if variable.type == .Function && !variable.builtin
|
||||
&& !variable.source_node.vertex_entry_point && !variable.source_node.pixel_entry_point {
|
||||
emit_function(state, variable.source_node, 0, false);
|
||||
@@ -460,22 +681,14 @@ codegen :: (state : *Codegen_State) -> Codegen_Result {
|
||||
append(*state.builder, "\n");
|
||||
}
|
||||
|
||||
for declaration : state.root.children {
|
||||
for declaration : state.result.root.children {
|
||||
if declaration.foreign_declaration {
|
||||
continue;
|
||||
}
|
||||
emit_declaration(state, declaration);
|
||||
}
|
||||
|
||||
state.result.result_text = builder_to_string(*state.builder);
|
||||
|
||||
return state.result;
|
||||
}
|
||||
|
||||
codegen :: (ast_root : *AST_Node, checker_result : Semantic_Check_Result, output_language : Output_Language) -> Codegen_Result {
|
||||
codegen_state : Codegen_State;
|
||||
init_codegen_state(*codegen_state, ast_root, checker_result, output_language);
|
||||
return codegen(*codegen_state);
|
||||
state.result.codegen_result_text = builder_to_string(*state.builder);
|
||||
}
|
||||
|
||||
#scope_module
|
||||
|
||||
749
Ink.jai
Normal file
749
Ink.jai
Normal file
@@ -0,0 +1,749 @@
|
||||
/////////////////////////////////////
|
||||
/*~ nbr: General improvements
|
||||
- [x] Print out all failed tests in a list at the end
|
||||
- [x] Use new compiler API with Compile_Result and Compiled_File instead
|
||||
- [ ] Use unix (posix? bash? ascii?) color codes for errors
|
||||
- [ ] Print golden file as green and new output as red
|
||||
- [ ] Rename to Ink.jai
|
||||
- [ ] Add -test option. -test does the same as test.exe used to do
|
||||
- [ ] Add -fuzz option to run fuzzer (add args later)
|
||||
- [ ] Add -output option to output the compiled file. Issue with this is the generated data can't be output like that. Would require serialization.
|
||||
*/
|
||||
|
||||
#import "Basic";
|
||||
#import "File";
|
||||
#import "String";
|
||||
#import "File_Utilities";
|
||||
#import "Print_Color";
|
||||
|
||||
#load "module.jai";
|
||||
|
||||
GOLDEN_EXTENSION :: "golden";
|
||||
LEXER_FOLDER :: "lex";
|
||||
PARSER_FOLDER :: "parse";
|
||||
CODEGEN_FOLDER :: "codegen";
|
||||
COMPILED_FOLDER :: "compiled";
|
||||
SEMANTIC_ANALYSIS_FOLDER :: "semant";
|
||||
TESTS_FOLDER :: "test";
|
||||
|
||||
SHADER_EXTENSION :: "ink";
|
||||
SUITE_EXTENSION :: "suite";
|
||||
|
||||
Stage_Flags :: enum_flags u16 {
|
||||
Lexer :: 0x1;
|
||||
Parser :: 0x2;
|
||||
Semantic_Analysis :: 0x4;
|
||||
Codegen :: 0x8;
|
||||
Compile :: 0x10;
|
||||
}
|
||||
|
||||
Output_Type :: enum_flags u16 {
|
||||
Golden :: 0x1;
|
||||
StdOut :: 0x2;
|
||||
}
|
||||
|
||||
Result_Type :: enum {
|
||||
File_Read_Failed;
|
||||
Golden_File_Not_Found;
|
||||
StdOut;
|
||||
Golden_Output;
|
||||
Passed;
|
||||
Failed;
|
||||
}
|
||||
|
||||
Result :: struct {
|
||||
type : Result_Type;
|
||||
path : string;
|
||||
stage : Stage_Flags;
|
||||
|
||||
golden_path : string;
|
||||
info_text : string;
|
||||
}
|
||||
|
||||
Test_Case :: struct {
|
||||
path : string;
|
||||
stage_flags : Stage_Flags;
|
||||
}
|
||||
|
||||
Test_Suite :: struct {
|
||||
name : string;
|
||||
test_cases : [..]Test_Case;
|
||||
|
||||
results : [..]Result;
|
||||
}
|
||||
|
||||
get_golden_path :: (file_path : string, stage : Stage_Flags) -> string {
|
||||
sc := get_scratch();
|
||||
defer scratch_end(sc);
|
||||
path := parse_path(file_path,, sc.allocator);
|
||||
file_without_extension := split(path.words[path.words.count - 1], ".",, sc.allocator);
|
||||
|
||||
builder : String_Builder;
|
||||
builder.allocator = temp;
|
||||
|
||||
final_path_length := file_path.count - SHADER_EXTENSION.count + GOLDEN_EXTENSION.count + 1; // +1 for dot
|
||||
|
||||
path.words.count -= 1;
|
||||
path.words.allocator = sc.allocator;
|
||||
|
||||
if stage == {
|
||||
case .Lexer; {
|
||||
dir := tprint("%/%", TESTS_FOLDER, LEXER_FOLDER);
|
||||
make_directory_if_it_does_not_exist(dir);
|
||||
array_add(*path.words, LEXER_FOLDER);
|
||||
}
|
||||
case .Parser; {
|
||||
dir := tprint("%/%", TESTS_FOLDER, PARSER_FOLDER);
|
||||
make_directory_if_it_does_not_exist(dir);
|
||||
array_add(*path.words, PARSER_FOLDER);
|
||||
}
|
||||
case .Semantic_Analysis; {
|
||||
dir := tprint("%/%", TESTS_FOLDER, SEMANTIC_ANALYSIS_FOLDER);
|
||||
make_directory_if_it_does_not_exist(dir);
|
||||
array_add(*path.words, SEMANTIC_ANALYSIS_FOLDER);
|
||||
}
|
||||
case .Codegen; {
|
||||
dir := tprint("%/%", TESTS_FOLDER, CODEGEN_FOLDER);
|
||||
make_directory_if_it_does_not_exist(dir);
|
||||
array_add(*path.words, CODEGEN_FOLDER);
|
||||
}
|
||||
case .Compile; {
|
||||
dir := tprint("%/%", TESTS_FOLDER, COMPILED_FOLDER);
|
||||
make_directory_if_it_does_not_exist(dir);
|
||||
array_add(*path.words, COMPILED_FOLDER);
|
||||
}
|
||||
}
|
||||
|
||||
init_string_builder(*builder, file_without_extension.count + GOLDEN_EXTENSION.count + 1);
|
||||
builder.allocator = sc.allocator;
|
||||
append(*builder, file_without_extension[0]);
|
||||
append(*builder, ".");
|
||||
append(*builder, GOLDEN_EXTENSION);
|
||||
golden_path := builder_to_string(*builder,, sc.allocator);
|
||||
array_add(*path.words, golden_path);
|
||||
|
||||
final_path := path_to_string(path);
|
||||
|
||||
return final_path;
|
||||
}
|
||||
|
||||
do_golden_comparison :: (golden_path : string, comparison_text : string, result : *Result, output_type : Output_Type) {
|
||||
sc := get_scratch();
|
||||
defer scratch_end(sc);
|
||||
if output_type & .Golden {
|
||||
// Output the comparison file
|
||||
write_entire_file(golden_path, comparison_text);
|
||||
result.golden_path = copy_string(golden_path);
|
||||
result.type = .Golden_Output;
|
||||
return;
|
||||
} else {
|
||||
// Do the comparison
|
||||
if !file_exists(golden_path) {
|
||||
result.info_text = tprint("Golden file % does not exist. Please run with -output-as-golden at least once.\n", golden_path);
|
||||
result.type = .Golden_File_Not_Found;
|
||||
return;
|
||||
}
|
||||
|
||||
golden_text, ok := read_entire_file(golden_path,, sc.allocator);
|
||||
if !ok {
|
||||
result.info_text = tprint("Unable to open golden file %\n", golden_path);
|
||||
result.type = .Golden_File_Not_Found;
|
||||
return;
|
||||
}
|
||||
|
||||
comp := replace(comparison_text, "\r\n", "\n",, sc.allocator);
|
||||
gold := replace(golden_text, "\r\n", "\n",, sc.allocator);
|
||||
ok = compare(comp, gold) == 0;
|
||||
if !ok {
|
||||
result.type = .Failed;
|
||||
result.info_text = tprint("Golden file:\n%\n===============\n%", gold, comp);
|
||||
} else {
|
||||
result.type = .Passed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
run_codegen_test :: (file_path : string, ctx : *Compiler_Context, output_type : Output_Type = 0) -> Result {
|
||||
result : Result;
|
||||
result.path = file_path;
|
||||
|
||||
lex(ctx, context.allocator);
|
||||
parse(ctx, context.allocator);
|
||||
check(ctx, context.allocator);
|
||||
|
||||
if ctx.had_error {
|
||||
result.type = .Failed;
|
||||
return result;
|
||||
}
|
||||
result = run_codegen_test(ctx, output_type);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
run_codegen_test :: (ctx : *Compiler_Context, output_type : Output_Type = 0) -> Result {
|
||||
result : Result;
|
||||
result.path = ctx.file.path;
|
||||
result_text : string;
|
||||
|
||||
codegen(ctx, context.allocator);
|
||||
|
||||
if ctx.had_error {
|
||||
result.type = .Failed;
|
||||
result_text = report_messages(ctx.messages);
|
||||
return result;
|
||||
}
|
||||
|
||||
result_text = ctx.codegen_result_text;
|
||||
|
||||
if output_type & .StdOut {
|
||||
result.info_text = result_text;
|
||||
result.type = .StdOut;
|
||||
return result;
|
||||
}
|
||||
|
||||
golden_path := get_golden_path(ctx.file.path, .Codegen);
|
||||
do_golden_comparison(golden_path, result_text, *result, output_type);
|
||||
return result;
|
||||
}
|
||||
|
||||
run_compile_test :: (path : string, output_type : Output_Type = 0) -> Result, Compiler_Context {
|
||||
ctx : Compiler_Context;
|
||||
result : Result;
|
||||
result.path = path;
|
||||
compile_file(*ctx, path, context.allocator);
|
||||
|
||||
if ctx.had_error {
|
||||
result.type = .Failed;
|
||||
result.info_text = tprint("Failed compiling: %\n", path);
|
||||
} else {
|
||||
sc := get_scratch();
|
||||
defer scratch_end(sc);
|
||||
sb : String_Builder;
|
||||
init_string_builder(*sb,, sc.allocator);
|
||||
if ctx.vertex_entry_point.name.count > 0 {
|
||||
print_to_builder(*sb, "[vertex entry point] - %\n", ctx.vertex_entry_point.name);
|
||||
}
|
||||
if ctx.pixel_entry_point.name.count > 0 {
|
||||
print_to_builder(*sb, "[pixel entry point] - %\n", ctx.pixel_entry_point.name);
|
||||
}
|
||||
|
||||
for cb : ctx.cbuffers {
|
||||
print_to_builder(*sb, "[constant_buffer] - % - %\n", cb.name, cb.buffer_index);
|
||||
|
||||
indent(*sb, 1);
|
||||
for field : cb.fields {
|
||||
append(*sb, "[field] - ");
|
||||
pretty_print_field(*sb, *field.base_field);
|
||||
}
|
||||
}
|
||||
|
||||
result.info_text = builder_to_string(*sb);
|
||||
}
|
||||
|
||||
if output_type & .StdOut {
|
||||
result.type = .StdOut;
|
||||
return result, ctx;
|
||||
}
|
||||
|
||||
golden_path := get_golden_path(ctx.file.path, .Compile);
|
||||
do_golden_comparison(golden_path, result.info_text, *result, output_type);
|
||||
|
||||
return result, ctx;
|
||||
}
|
||||
|
||||
run_lexer_test :: (file_path : string, ctx : *Compiler_Context, output_type : Output_Type = 0) -> Result {
|
||||
result : Result;
|
||||
result.path = file_path;
|
||||
result.stage = .Lexer;
|
||||
|
||||
result_text : string;
|
||||
|
||||
lex(ctx);
|
||||
if ctx.had_error {
|
||||
result.type = .Failed;
|
||||
result_text = report_messages(ctx.messages);
|
||||
} else {
|
||||
result_text = pretty_print_tokens(ctx.tokens, context.allocator);
|
||||
}
|
||||
|
||||
if output_type & .StdOut {
|
||||
result.info_text = result_text;
|
||||
result.type = .StdOut;
|
||||
return result;
|
||||
}
|
||||
|
||||
golden_path := get_golden_path(file_path, .Lexer);
|
||||
do_golden_comparison(golden_path, result_text, *result, output_type);
|
||||
return result;
|
||||
}
|
||||
|
||||
run_parser_test :: (file_path : string, ctx : *Compiler_Context, output_type : Output_Type = 0) -> Result {
|
||||
result : Result;
|
||||
result.path = file_path;
|
||||
|
||||
lex(ctx);
|
||||
if ctx.had_error {
|
||||
result.type = .Passed;
|
||||
return result;
|
||||
}
|
||||
|
||||
result = run_parser_test(ctx, output_type);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
run_parser_test :: (ctx : *Compiler_Context, output_type : Output_Type = 0) -> Result {
|
||||
parse(ctx, context.allocator);
|
||||
result : Result;
|
||||
result.path = ctx.file.path;
|
||||
result_text : string;
|
||||
|
||||
if ctx.had_error {
|
||||
result.type = .Failed;
|
||||
result_text = report_messages(ctx.messages);
|
||||
} else {
|
||||
result_text = pretty_print_ast(ctx.root, context.allocator);
|
||||
}
|
||||
|
||||
if output_type & .StdOut {
|
||||
result.info_text = result_text;
|
||||
result.type = .StdOut;
|
||||
return result;
|
||||
}
|
||||
|
||||
golden_path := get_golden_path(ctx.file.path, .Parser);
|
||||
do_golden_comparison(golden_path, result_text, *result, output_type);
|
||||
return result;
|
||||
}
|
||||
|
||||
run_semantic_analysis_test :: (ctx : *Compiler_Context, output_type : Output_Type = 0) -> Result {
|
||||
result : Result;
|
||||
result.path = ctx.file.path;
|
||||
result_text : string;
|
||||
|
||||
check(ctx, context.allocator);
|
||||
|
||||
if ctx.had_error {
|
||||
result.type = .Failed;
|
||||
result_text = report_messages(ctx.messages);
|
||||
} else {
|
||||
result_text = pretty_print_symbol_table(ctx, context.allocator);
|
||||
}
|
||||
|
||||
if output_type & .StdOut {
|
||||
result.info_text = result_text;
|
||||
result.type = .StdOut;
|
||||
return result;
|
||||
}
|
||||
|
||||
golden_path := get_golden_path(ctx.file.path, .Semantic_Analysis);
|
||||
do_golden_comparison(golden_path, result_text, *result, output_type);
|
||||
return result;
|
||||
}
|
||||
|
||||
run_semantic_analysis_test :: (file_path : string, ctx : *Compiler_Context, output_type : Output_Type = 0) -> Result {
|
||||
result : Result;
|
||||
result.path = file_path;
|
||||
|
||||
lex(ctx, context.allocator);
|
||||
parse(ctx, context.allocator);
|
||||
if ctx.had_error {
|
||||
result.type = .Failed;
|
||||
return result;
|
||||
}
|
||||
|
||||
result = run_semantic_analysis_test(ctx, output_type);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
make_test_case :: (path : string, stage_flags : Stage_Flags, allocator := context.allocator) -> Test_Case {
|
||||
test_case : Test_Case;
|
||||
test_case.path = copy_string(path,, allocator);
|
||||
replace_chars(test_case.path, "\\", #char "/");
|
||||
test_case.stage_flags = stage_flags;
|
||||
|
||||
return test_case;
|
||||
}
|
||||
|
||||
run_test_new :: (file_path : string, stage_flags : Stage_Flags, results : *[..]Result, output_type : Output_Type = 0, allocator := temp) {
|
||||
new_context := context;
|
||||
new_context.allocator = allocator;
|
||||
push_context new_context {
|
||||
ctx : Compiler_Context;
|
||||
|
||||
ctx.file = make_file(*ctx, file_path);
|
||||
|
||||
result : Result;
|
||||
if stage_flags & .Lexer {
|
||||
result = run_lexer_test(file_path, *ctx, output_type);
|
||||
record_result(results, result);
|
||||
}
|
||||
|
||||
if stage_flags & .Parser {
|
||||
if stage_flags & .Lexer && result.type == .Passed || result.type == .Golden_Output {
|
||||
result = run_parser_test(*ctx, output_type);
|
||||
} else {
|
||||
result = run_parser_test(file_path, *ctx, output_type);
|
||||
}
|
||||
record_result(results, result);
|
||||
}
|
||||
|
||||
if stage_flags & .Semantic_Analysis {
|
||||
if stage_flags & .Parser && (result.type == .Passed || result.type == .Golden_Output) {
|
||||
result = run_semantic_analysis_test(*ctx, output_type);
|
||||
} else {
|
||||
result = run_semantic_analysis_test(file_path, *ctx, output_type);
|
||||
}
|
||||
record_result(results, result);
|
||||
}
|
||||
|
||||
if stage_flags & .Codegen {
|
||||
if stage_flags & .Semantic_Analysis && (result.type == .Passed || result.type == .Golden_Output) {
|
||||
result = run_codegen_test(*ctx, output_type);
|
||||
} else {
|
||||
result = run_codegen_test(file_path, *ctx, output_type);
|
||||
}
|
||||
record_result(results, result);
|
||||
}
|
||||
|
||||
if stage_flags & .Compile {
|
||||
result = run_compile_test(file_path, output_type);
|
||||
record_result(results, result);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
run_test :: (test_case : Test_Case, results : *[..]Result, output_type : Output_Type = 0, allocator := temp) {
|
||||
print("%Running test: %......", cyan(), test_case.path);
|
||||
|
||||
// path 30
|
||||
// len 35
|
||||
// == 5
|
||||
|
||||
|
||||
// path 20
|
||||
// len = 35
|
||||
// == 15
|
||||
|
||||
len := 50;
|
||||
rest := len - test_case.path.count;
|
||||
for i: 0..rest {
|
||||
print(" ");
|
||||
}
|
||||
|
||||
run_test_new(test_case.path, test_case.stage_flags, results, output_type, allocator);
|
||||
}
|
||||
|
||||
record_result :: (results : *[..]Result, result : Result) {
|
||||
array_add(results, result);
|
||||
}
|
||||
|
||||
run_test_suite :: (using suite : *Test_Suite, output_type : Output_Type = 0) {
|
||||
if suite.name.count > 0 {
|
||||
print("%Running suite: %\n", green(), suite.name);
|
||||
print("%", reset_color());
|
||||
}
|
||||
|
||||
Fail_Data :: struct {
|
||||
path : string;
|
||||
stage : string;
|
||||
}
|
||||
|
||||
test_arena : Allocator = make_arena(Gigabytes(1));
|
||||
|
||||
failed_test_paths : [..]Fail_Data;
|
||||
failed_test_paths.allocator = test_arena;
|
||||
|
||||
builder : String_Builder;
|
||||
init_string_builder(*builder,, test_arena);
|
||||
|
||||
for test_case : test_cases {
|
||||
run_test(test_case, *suite.results, output_type, allocator = test_arena);
|
||||
|
||||
for < suite.results {
|
||||
result := suite.results[it_index];
|
||||
if compare(result.path, test_case.path) == 0 {
|
||||
if result.type == {
|
||||
case .Failed; {
|
||||
array_add(*failed_test_paths, .{ result.path, stage_to_string(result.stage) });
|
||||
}
|
||||
case .File_Read_Failed; {
|
||||
array_add(*failed_test_paths, .{ result.path, "file not found" });
|
||||
}
|
||||
case .Golden_File_Not_Found; {
|
||||
array_add(*failed_test_paths, .{ result.path, tprint("golden file not found for %", stage_to_string(result.stage)) });
|
||||
}
|
||||
}
|
||||
evaluate_result(result);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// print("\n");
|
||||
}
|
||||
append(*builder, "\n");
|
||||
|
||||
if output_type == 0 {
|
||||
if failed_test_paths.count == 0 {
|
||||
green(*builder);
|
||||
print_to_builder(*builder, "All % tests passed!\n", test_cases.count);
|
||||
reset_color(*builder);
|
||||
} else {
|
||||
print_to_builder(*builder, "%/% tests passed\n", test_cases.count - failed_test_paths.count, test_cases.count);
|
||||
red(*builder);
|
||||
|
||||
print_to_builder(*builder, "% failed\n", failed_test_paths.count);
|
||||
for failed_test : failed_test_paths {
|
||||
print_to_builder(*builder, "% failed with error: %\n", failed_test.path, failed_test.stage);
|
||||
}
|
||||
reset_color(*builder);
|
||||
}
|
||||
}
|
||||
|
||||
print("%\n", builder_to_string(*builder,, test_arena));
|
||||
}
|
||||
|
||||
read_suite :: (file_path : string, suite : *Test_Suite, allocator := temp) -> bool {
|
||||
sc := get_scratch();
|
||||
defer scratch_end(sc);
|
||||
bytes, ok := read_entire_file(file_path,, sc.allocator);
|
||||
if !ok {
|
||||
log_error("Unable to read suite file %\n", file_path);
|
||||
return false;
|
||||
}
|
||||
|
||||
path := parse_path(file_path,, sc.allocator);
|
||||
file_without_extension := split(path.words[path.words.count - 1], ".",, sc.allocator);
|
||||
suite.name = copy_string(file_without_extension[0],, allocator);
|
||||
split_lines := split(bytes, "\n",, sc.allocator);
|
||||
|
||||
for split_line : split_lines {
|
||||
if split_line.count == 0 {
|
||||
break;
|
||||
}
|
||||
|
||||
if split_line[0] == #char "#" {
|
||||
continue;
|
||||
}
|
||||
|
||||
line := split(split_line, " ",, sc.allocator);
|
||||
if line[0].count == 0 {
|
||||
continue;
|
||||
}
|
||||
|
||||
if line[0].data[0] == #char "#" {
|
||||
continue;
|
||||
}
|
||||
|
||||
if line.count == 1 {
|
||||
line = split(split_line, "\t",, sc.allocator);
|
||||
if line.count == 1 {
|
||||
log_error("Invalid line - % - \n", it_index + 1);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
test_case_path := line[0];
|
||||
stage_flags : Stage_Flags;
|
||||
|
||||
for i: 0..line.count - 1 {
|
||||
trimmed := trim(line[i]);
|
||||
if equal(trimmed, "lex") {
|
||||
stage_flags |= .Lexer;
|
||||
} else if equal(trimmed, "parse") {
|
||||
stage_flags |= .Parser;
|
||||
} else if equal(trimmed, "semant") {
|
||||
stage_flags |= .Semantic_Analysis;
|
||||
} else if equal(trimmed, "codegen") {
|
||||
stage_flags |= .Codegen;
|
||||
} else if equal(trimmed, "compile") {
|
||||
stage_flags |= .Compile;
|
||||
}
|
||||
}
|
||||
test_case := make_test_case(test_case_path, stage_flags, allocator);
|
||||
array_add(*suite.test_cases, test_case);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
read_test :: () {
|
||||
|
||||
}
|
||||
|
||||
stage_to_string :: (stage : Stage_Flags) -> string {
|
||||
if #complete stage == {
|
||||
case .Lexer; return "lexing";
|
||||
case .Parser; return "parsing";
|
||||
case .Semantic_Analysis; return "semantic checking";
|
||||
case .Codegen; return "codegen";
|
||||
case .Compile; return "compiled";
|
||||
case; return "";
|
||||
}
|
||||
}
|
||||
|
||||
evaluate_result :: (result : Result) {
|
||||
stage : string = stage_to_string(result.stage);
|
||||
|
||||
if #complete result.type == {
|
||||
case .File_Read_Failed; {
|
||||
print(" %", red());
|
||||
print("failed with File_Read_Failed\n");
|
||||
}
|
||||
case .Golden_File_Not_Found; {
|
||||
print(" %", red());
|
||||
print("failed with Golden File Not Found for stage %\n", stage);
|
||||
}
|
||||
case .StdOut; {
|
||||
}
|
||||
case .Golden_Output; {
|
||||
print(" %", yellow());
|
||||
print("output new golden file at %\n", result.golden_path);
|
||||
}
|
||||
case .Passed; {
|
||||
print(" %", green());
|
||||
print("passed %\n", stage);
|
||||
}
|
||||
case .Failed; {
|
||||
print(" %", red());
|
||||
print("failed %\n", stage);
|
||||
}
|
||||
}
|
||||
|
||||
if result.info_text.count > 0 {
|
||||
print("%", cyan());
|
||||
print("--- Info text ---\n");
|
||||
print("%", yellow());
|
||||
print("%\n", result.info_text);
|
||||
}
|
||||
|
||||
print("%", reset_color());
|
||||
}
|
||||
|
||||
main :: () {
|
||||
args := get_command_line_arguments();
|
||||
|
||||
init_context_allocators();
|
||||
|
||||
local_temp := make_arena(Megabytes(128));
|
||||
|
||||
suites : [..]Test_Suite;
|
||||
suites.allocator = local_temp;
|
||||
output_type : Output_Type = 0;
|
||||
|
||||
Argument_Parse_State :: enum {
|
||||
None;
|
||||
Compile;
|
||||
Run_Suite;
|
||||
Run_Test;
|
||||
}
|
||||
|
||||
arg_parse_state : Argument_Parse_State;
|
||||
current_suite : *Test_Suite;
|
||||
|
||||
path : string;
|
||||
|
||||
for i: 1..args.count - 1 {
|
||||
arg := args[i];
|
||||
if arg == "-output-as-golden" {
|
||||
output_type |= .Golden;
|
||||
continue;
|
||||
} else if arg == "-output" {
|
||||
output_type |= .StdOut;
|
||||
continue;
|
||||
}
|
||||
|
||||
if arg_parse_state == {
|
||||
case .Run_Suite; {
|
||||
if arg == "-output-as-golden" {
|
||||
output_type |= .Golden;
|
||||
} else if arg == "-output" {
|
||||
output_type |= .StdOut;
|
||||
} else {
|
||||
print("%Unknown argument % %\n", red(), arg, reset_color());
|
||||
}
|
||||
}
|
||||
case .Run_Test; {
|
||||
cases := current_suite.test_cases.count;
|
||||
if arg == "-lex" {
|
||||
current_suite.test_cases[cases - 1].stage_flags |= .Lexer;
|
||||
} else if arg == "-parse" {
|
||||
current_suite.test_cases[cases - 1].stage_flags |= .Parser;
|
||||
} else if arg == "-semant" {
|
||||
current_suite.test_cases[cases - 1].stage_flags |= .Semantic_Analysis;
|
||||
} else if arg == "-codegen" {
|
||||
current_suite.test_cases[cases - 1].stage_flags |= .Codegen;
|
||||
} else if arg == "-compile" {
|
||||
current_suite.test_cases[cases - 1].stage_flags |= .Compile;
|
||||
} else if contains(arg, ".") {
|
||||
sc := get_scratch();
|
||||
defer scratch_end(sc);
|
||||
path_split := split(arg, "\\",, sc.allocator);
|
||||
split_path := split(path_split[path_split.count - 1], ".",, sc.allocator);
|
||||
extension := split_path[1];
|
||||
if extension == SHADER_EXTENSION {
|
||||
path := copy_string(arg,, local_temp);
|
||||
test_case := make_test_case(path, 0, local_temp);
|
||||
array_add(*current_suite.test_cases, test_case);
|
||||
} else {
|
||||
print("%Invalid file as argument % %\n", red(), arg, reset_color());
|
||||
}
|
||||
} else {
|
||||
print("%Unknown argument % %\n", red(), arg, reset_color());
|
||||
}
|
||||
}
|
||||
case .None; {
|
||||
if contains(arg, ".") {
|
||||
sc := get_scratch();
|
||||
defer scratch_end(sc);
|
||||
path_split := split(arg, "\\",, sc.allocator);
|
||||
split_path := split(path_split[path_split.count - 1], ".",, sc.allocator);
|
||||
extension := split_path[1];
|
||||
|
||||
if extension == SHADER_EXTENSION {
|
||||
if arg_parse_state == .Run_Suite {
|
||||
log_error("Unable to run a test while already running suite.");
|
||||
continue;
|
||||
}
|
||||
|
||||
if !current_suite {
|
||||
suite : Test_Suite;
|
||||
suite.results.allocator = local_temp;
|
||||
suite.test_cases.allocator = local_temp;
|
||||
array_add(*suites, suite);
|
||||
current_suite = *suites[0];
|
||||
}
|
||||
arg_parse_state = .Run_Test;
|
||||
path := copy_string(arg,, local_temp);
|
||||
test_case := make_test_case(path, 0, local_temp);
|
||||
array_add(*current_suite.test_cases, test_case);
|
||||
} else if extension == SUITE_EXTENSION {
|
||||
if arg_parse_state == .Run_Test {
|
||||
log_error("Unable to run a suite while already running test.");
|
||||
continue;
|
||||
}
|
||||
arg_parse_state = .Run_Suite;
|
||||
path := copy_string(arg);
|
||||
|
||||
suite : Test_Suite;
|
||||
suite.results.allocator = local_temp;
|
||||
suite.test_cases.allocator = local_temp;
|
||||
read_suite(path, *suite, local_temp);
|
||||
array_add(*suites, suite);
|
||||
current_suite = *suites[0];
|
||||
} else {
|
||||
print("%Invalid file as argument % %\n", red(), arg, reset_color());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for suite : suites {
|
||||
run_test_suite(*suite, output_type);
|
||||
}
|
||||
|
||||
clear(local_temp);
|
||||
}
|
||||
143
Lexing.jai
143
Lexing.jai
@@ -5,17 +5,11 @@ Lexer :: struct {
|
||||
current_line : int;
|
||||
current_column : int;
|
||||
|
||||
result : Lexing_Result;
|
||||
ctx : *Compiler_Context;
|
||||
|
||||
path : string;
|
||||
}
|
||||
|
||||
Lexing_Result :: struct {
|
||||
tokens : [..]Token;
|
||||
had_error : bool;
|
||||
messages : [..]Compiler_Message;
|
||||
}
|
||||
|
||||
Token_Kind :: enum {
|
||||
TOKEN_FLOATLITERAL;
|
||||
TOKEN_INTLITERAL;
|
||||
@@ -54,6 +48,7 @@ Token_Kind :: enum {
|
||||
TOKEN_SEMICOLON;
|
||||
TOKEN_COMMA;
|
||||
TOKEN_DOT;
|
||||
TOKEN_DOTDOT;
|
||||
|
||||
TOKEN_IDENTIFIER;
|
||||
|
||||
@@ -100,6 +95,7 @@ Token_Kind :: enum {
|
||||
TOKEN_RETURN;
|
||||
TOKEN_REGISTER;
|
||||
|
||||
TOKEN_STRING;
|
||||
TOKEN_STRUCT;
|
||||
TOKEN_SWITCH;
|
||||
|
||||
@@ -137,6 +133,8 @@ Token :: struct {
|
||||
index : int;
|
||||
|
||||
error : string;
|
||||
|
||||
builtin : bool; // @Incomplete: This is kind of a bad idea, but let's just do it for now...
|
||||
}
|
||||
|
||||
Source_Range :: struct {
|
||||
@@ -264,12 +262,32 @@ identifier_kind :: (using lexer : *Lexer) -> Token_Kind {
|
||||
error_token :: (lexer : *Lexer, message : string) -> *Token {
|
||||
token : *Token = new_token(lexer, .TOKEN_ERROR);
|
||||
|
||||
lexer.result.had_error = true;
|
||||
lexer.ctx.had_error = true;
|
||||
token.error = copy_string(message);
|
||||
|
||||
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;
|
||||
@@ -291,8 +309,8 @@ record_error :: (lexer : *Lexer, message : string) {
|
||||
|
||||
array_add(*error.source_locations, source_location);
|
||||
|
||||
lexer.result.had_error = true;
|
||||
array_add(*lexer.result.messages, error);
|
||||
lexer.ctx.had_error = true;
|
||||
array_add(*lexer.ctx.messages, error);
|
||||
}
|
||||
|
||||
make_int :: (lexer : *Lexer) -> *Token {
|
||||
@@ -322,10 +340,6 @@ make_float :: (lexer : *Lexer) -> *Token {
|
||||
return token;
|
||||
}
|
||||
|
||||
make_string :: () {
|
||||
|
||||
}
|
||||
|
||||
new_token :: (lexer : *Lexer, kind : Token_Kind) -> *Token {
|
||||
length := lexer.cursor - lexer.start;
|
||||
token : Token;
|
||||
@@ -342,13 +356,49 @@ new_token :: (lexer : *Lexer, kind : Token_Kind) -> *Token {
|
||||
}
|
||||
lexer.current_column += length;
|
||||
|
||||
array_add(*lexer.result.tokens, token);
|
||||
return *lexer.result.tokens[lexer.result.tokens.count - 1];
|
||||
array_add(*lexer.ctx.tokens, token);
|
||||
return *lexer.ctx.tokens[lexer.ctx.tokens.count - 1];
|
||||
}
|
||||
|
||||
make_directive :: (lexer : *Lexer) -> *Token {
|
||||
lexer.start += 1;
|
||||
return make_identifier(lexer, .TOKEN_DIRECTIVE);
|
||||
ident := make_identifier(lexer, .TOKEN_DIRECTIVE);
|
||||
if ident.ident_value == "load" {
|
||||
path_tok := scan_next_token(lexer);
|
||||
path := path_tok.string_value;
|
||||
ctx : Compiler_Context;
|
||||
ctx.environment = lexer.ctx.environment;
|
||||
|
||||
ctx.file = make_file(*ctx, path);
|
||||
|
||||
if ctx.file.source.count == 0 {
|
||||
// unable_to_open_file(lexer, path, path_tok);
|
||||
record_error(lexer, tprint("Unable to open file '%' for reading\n", path));
|
||||
return error_token(lexer, tprint("Unable to open file '%' for reading\n", path));
|
||||
}
|
||||
|
||||
lex(*ctx);
|
||||
|
||||
ctx.tokens.count -= 1; // @Note: remote TOKEN_EOF
|
||||
lexer.ctx.tokens.count -= 2;
|
||||
array_resize(*lexer.ctx.tokens, lexer.ctx.tokens.count + ctx.tokens.count);
|
||||
|
||||
for tok : ctx.tokens {
|
||||
lexer.ctx.tokens[it_index] = tok;
|
||||
}
|
||||
return scan_next_token(lexer);;
|
||||
}
|
||||
return ident;
|
||||
}
|
||||
|
||||
make_string :: (lexer : *Lexer) -> *Token {
|
||||
token : *Token = new_token(lexer, .TOKEN_STRING);
|
||||
|
||||
name : string = .{ count = token.length - 2,
|
||||
data = *lexer.input.data[lexer.start + 1] };
|
||||
token.string_value = name;
|
||||
|
||||
return token;
|
||||
}
|
||||
|
||||
make_identifier :: (lexer : *Lexer, kind : Token_Kind) -> *Token {
|
||||
@@ -367,6 +417,7 @@ make_token :: (lexer : *Lexer, token_kind : Token_Kind) -> *Token {
|
||||
|
||||
skip_whitespace :: (lexer : *Lexer) {
|
||||
while true {
|
||||
if is_at_end(lexer) return;
|
||||
c := peek_char(lexer);
|
||||
|
||||
if c == {
|
||||
@@ -421,6 +472,17 @@ scan_next_token :: (lexer : *Lexer) -> *Token {
|
||||
if is_digit(c) return number(lexer);
|
||||
|
||||
if c == {
|
||||
case #char "\""; {
|
||||
c = advance(lexer);
|
||||
// lexer.start = lexer.cursor;
|
||||
while c != #char "\"" {
|
||||
c = advance(lexer);
|
||||
}
|
||||
// lexer.cursor -= 1;
|
||||
tok := make_string(lexer);
|
||||
// advance(lexer);
|
||||
return tok;
|
||||
}
|
||||
case #char "+"; {
|
||||
if match_character(lexer, #char "=") return make_token(lexer, .TOKEN_PLUSEQUALS);
|
||||
return make_token(lexer, .TOKEN_PLUS);
|
||||
@@ -490,7 +552,10 @@ scan_next_token :: (lexer : *Lexer) -> *Token {
|
||||
}
|
||||
case #char ";"; return make_token(lexer, .TOKEN_SEMICOLON);
|
||||
case #char ","; return make_token(lexer, .TOKEN_COMMA);
|
||||
case #char "."; return make_token(lexer, .TOKEN_DOT);
|
||||
case #char "."; {
|
||||
if match_character(lexer, #char ".") return make_token(lexer, .TOKEN_DOTDOT);
|
||||
return make_token(lexer, .TOKEN_DOT);
|
||||
}
|
||||
}
|
||||
|
||||
s : string = .{ count = 1, data = *c };
|
||||
@@ -499,41 +564,35 @@ scan_next_token :: (lexer : *Lexer) -> *Token {
|
||||
// return error_token(lexer, tprint("Invalid token: %", s));
|
||||
}
|
||||
|
||||
|
||||
|
||||
lex :: (result : *Compile_Result) {
|
||||
if result.had_error {
|
||||
lex :: (ctx : *Compiler_Context, allocator := temp) {
|
||||
if ctx.had_error {
|
||||
return;
|
||||
}
|
||||
|
||||
for file : result.files {
|
||||
new_context := context;
|
||||
new_context.allocator = allocator;
|
||||
push_context new_context {
|
||||
init_context_allocators();
|
||||
defer clear_context_allocators();
|
||||
|
||||
lexer : Lexer;
|
||||
init_lexer_from_string(*lexer, file.file.source);
|
||||
lexer.ctx = ctx;
|
||||
array_reserve(*lexer.ctx.tokens, 1024);
|
||||
|
||||
init_lexer_from_string(*lexer, ctx.file.source);
|
||||
lexer.path = ctx.file.path;
|
||||
token : *Token = scan_next_token(*lexer);
|
||||
while token && token.kind != .TOKEN_EOF {
|
||||
token = scan_next_token(*lexer);
|
||||
}
|
||||
|
||||
// @Incomplete(nb): Temporary until we figure out a good way of passing this stuff around
|
||||
copy_messages(lexer.result.messages, *result.messages);
|
||||
}
|
||||
}
|
||||
|
||||
lex :: (lexer : *Lexer, allocator : Allocator = context.allocator) -> Lexing_Result {
|
||||
lexer.result.tokens.allocator = allocator;
|
||||
token : *Token = scan_next_token(lexer);
|
||||
while token && token.kind != .TOKEN_EOF {
|
||||
token = scan_next_token(lexer);
|
||||
}
|
||||
|
||||
return lexer.result;
|
||||
}
|
||||
|
||||
init_lexer_from_string :: (lexer : *Lexer, input : string) {
|
||||
ok := read_input_from_string(lexer, input);
|
||||
if !ok {
|
||||
record_error(lexer, "Unable to initialize from string\n");
|
||||
lexer.result.had_error = true;
|
||||
lexer.ctx.had_error = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -541,7 +600,7 @@ init_lexer_from_file :: (lexer : *Lexer, file_path : string) {
|
||||
ok := read_input_from_file(lexer, file_path);
|
||||
if !ok {
|
||||
record_error(lexer, tprint("Unable to read file: %\n", file_path));
|
||||
lexer.result.had_error = true;
|
||||
lexer.ctx.had_error = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -711,9 +770,11 @@ print_from_source_location :: (builder : *String_Builder, source_location : Sour
|
||||
}
|
||||
|
||||
print_from_source_location :: (source_location : Source_Range, allocator := context.allocator, indentation : int = 0) -> string {
|
||||
sc := get_scratch();
|
||||
defer scratch_end(sc);
|
||||
builder : String_Builder;
|
||||
init_string_builder(*builder,, allocator);
|
||||
print_from_source_location(*builder, source_location);
|
||||
init_string_builder(*builder,, sc.allocator);
|
||||
print_from_source_location(*builder, source_location,, sc.allocator);
|
||||
return builder_to_string(*builder,, allocator);
|
||||
}
|
||||
|
||||
|
||||
689
Parsing.jai
689
Parsing.jai
@@ -1,5 +1,7 @@
|
||||
#import "Flat_Pool";
|
||||
|
||||
// #load "qpwodkqopwkd.jai";
|
||||
|
||||
/**
|
||||
* TODO:
|
||||
* if parsing
|
||||
@@ -11,29 +13,14 @@
|
||||
Parse_State :: struct {
|
||||
current : *Token;
|
||||
previous : *Token;
|
||||
tokens : [..]Token;
|
||||
|
||||
current_token_index : int;
|
||||
allocator : Allocator;
|
||||
|
||||
had_error : bool;
|
||||
|
||||
path : string;
|
||||
|
||||
result : Parse_Result;
|
||||
ctx : *Compiler_Context;
|
||||
}
|
||||
|
||||
////////////////////////////
|
||||
//@nb - Result and error handling
|
||||
Parse_Result :: struct {
|
||||
root : *AST_Node;
|
||||
nodes : [..]AST_Node;
|
||||
|
||||
had_error : bool;
|
||||
|
||||
messages : [..]Compiler_Message;
|
||||
}
|
||||
|
||||
Parse_Error_Kind :: enum {
|
||||
Parse_Error_Type_Missing;
|
||||
Parse_Error_Expected_Expression;
|
||||
@@ -96,6 +83,11 @@ parse_rules :: #run -> [(cast(int)Token_Kind.TOKEN_ERROR) + 1]Parse_Rule {
|
||||
rules[Token_Kind.TOKEN_STAR] = .{null, binary, .PREC_FACTOR};
|
||||
rules[Token_Kind.TOKEN_ISNOTEQUAL] = .{null, binary, .PREC_COMPARISON};
|
||||
rules[Token_Kind.TOKEN_ASSIGN] = .{null, binary, .PREC_COMPARISON};
|
||||
rules[Token_Kind.TOKEN_MINUSEQUALS] = .{null, binary, .PREC_COMPARISON};
|
||||
rules[Token_Kind.TOKEN_PLUSEQUALS] = .{null, binary, .PREC_COMPARISON};
|
||||
rules[Token_Kind.TOKEN_DIVEQUALS] = .{null, binary, .PREC_COMPARISON};
|
||||
rules[Token_Kind.TOKEN_TIMESEQUALS] = .{null, binary, .PREC_COMPARISON};
|
||||
rules[Token_Kind.TOKEN_MODEQUALS] = .{null, binary, .PREC_COMPARISON};
|
||||
rules[Token_Kind.TOKEN_ISEQUAL] = .{null, binary, .PREC_EQUALITY};
|
||||
rules[Token_Kind.TOKEN_GREATER] = .{null, binary, .PREC_COMPARISON};
|
||||
rules[Token_Kind.TOKEN_GREATEREQUALS] = .{null, binary, .PREC_COMPARISON};
|
||||
@@ -119,15 +111,6 @@ 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) {
|
||||
parse_state.tokens = tokens;
|
||||
parse_state.path = path;
|
||||
parse_state.allocator = allocator;
|
||||
parse_state.result.nodes.allocator = parse_state.allocator;
|
||||
array_reserve(*parse_state.result.nodes, 4096);
|
||||
parse_state.current_token_index = 0;
|
||||
}
|
||||
|
||||
////////////////////////////
|
||||
//@nb - Error handling functions
|
||||
|
||||
@@ -136,7 +119,7 @@ record_error :: (parse_state : *Parse_State, token : Token, message : string, re
|
||||
error : Compiler_Message;
|
||||
error.message_kind = .Error;
|
||||
error.message = message;
|
||||
error.path = parse_state.path;
|
||||
error.path = parse_state.ctx.file.path;
|
||||
|
||||
source_location : Source_Range;
|
||||
source_location.begin = token;
|
||||
@@ -144,14 +127,17 @@ record_error :: (parse_state : *Parse_State, token : Token, message : string, re
|
||||
source_location.begin.source = source_location.begin.source - source_location.begin.column;
|
||||
source_location.main_token = token;
|
||||
|
||||
snap := snapshot_state(parse_state);
|
||||
advance_to_sync_point(parse_state);
|
||||
error.report_source_location = report_source_location;
|
||||
|
||||
source_location.end = parse_state.current;
|
||||
array_add(*error.source_locations, source_location);
|
||||
|
||||
parse_state.result.had_error = true;
|
||||
array_add(*parse_state.result.messages, error);
|
||||
parse_state.ctx.had_error = true;
|
||||
array_add(*parse_state.ctx.messages, error);
|
||||
|
||||
rewind_to_snapshot(parse_state, snap);
|
||||
}
|
||||
|
||||
generate_source_location_from_token :: (state : *Parse_State, token : Token) -> Source_Range {
|
||||
@@ -176,7 +162,101 @@ generate_source_location_from_token :: (state : *Parse_State, token : Token) ->
|
||||
}
|
||||
|
||||
unexpected_token :: (state : *Parse_State, token : Token, message : string) {
|
||||
record_error(state, token, message);
|
||||
/*
|
||||
|
||||
*/
|
||||
sc := get_scratch();
|
||||
defer scratch_end(sc);
|
||||
builder : String_Builder;
|
||||
init_string_builder(*builder,, sc.allocator);
|
||||
|
||||
print_to_builder(*builder, "%\n\n", message);
|
||||
|
||||
location : Source_Range;
|
||||
location.begin = token;
|
||||
location.begin.index -= location.begin.column;
|
||||
location.begin.source -= location.begin.column;
|
||||
location.begin.length += location.begin.column;
|
||||
location.begin.column = 0;
|
||||
|
||||
location.main_token = token;
|
||||
location.end = token;
|
||||
|
||||
// advance(state);
|
||||
|
||||
indent(*builder, 1);
|
||||
cyan(*builder);
|
||||
print_to_builder(*builder, "%\n", print_from_source_location(location));
|
||||
|
||||
indent(*builder, 1);
|
||||
print_token_pointer(*builder, token);
|
||||
|
||||
final_message := builder_to_string(*builder,, context.allocator);
|
||||
record_error(state, token, final_message, false);
|
||||
}
|
||||
|
||||
else_if_without_if :: (state : *Parse_State) {
|
||||
builder : String_Builder;
|
||||
init_string_builder(*builder,, temp);
|
||||
|
||||
append(*builder, "'else if' without 'if'\n");
|
||||
|
||||
token := state.previous;
|
||||
|
||||
location : Source_Range = 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);
|
||||
print_token_pointer(*builder, token);
|
||||
white(*builder);
|
||||
|
||||
final_message := builder_to_string(*builder);
|
||||
record_error(state, token, final_message, false);
|
||||
}
|
||||
|
||||
else_without_if :: (state : *Parse_State) {
|
||||
builder : String_Builder;
|
||||
init_string_builder(*builder,, temp);
|
||||
|
||||
append(*builder, "'else' without 'if'\n");
|
||||
|
||||
token := state.previous;
|
||||
|
||||
location : Source_Range = 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);
|
||||
print_token_pointer(*builder, token);
|
||||
white(*builder);
|
||||
|
||||
final_message := builder_to_string(*builder);
|
||||
record_error(state, token, final_message, false);
|
||||
}
|
||||
|
||||
unable_to_parse_statement :: (state : *Parse_State, token : Token, message : string = "") {
|
||||
builder : String_Builder;
|
||||
init_string_builder(*builder,, temp);
|
||||
|
||||
print_to_builder(*builder, "Unable to parse statement here. %\n", message);
|
||||
|
||||
location : Source_Range = 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);
|
||||
print_token_pointer(*builder, token);
|
||||
|
||||
final_message := builder_to_string(*builder);
|
||||
record_error(state, token, final_message, false);
|
||||
}
|
||||
|
||||
expected_expression :: (state : *Parse_State, token : Token, message : string) {
|
||||
@@ -246,6 +326,26 @@ empty_block :: (state : *Parse_State, token : Token, message : string) {
|
||||
record_error(state, token, final_message, false);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
error_node :: (parse_state : *Parse_State, message : string) -> *AST_Node {
|
||||
node := make_node(parse_state, .Error);
|
||||
node.name = copy_string(message);
|
||||
@@ -258,8 +358,8 @@ error_node :: (parse_state : *Parse_State, message : string) -> *AST_Node {
|
||||
advance_to_sync_point :: (parse_state : *Parse_State) {
|
||||
while true {
|
||||
if parse_state.current.kind == .TOKEN_SEMICOLON || parse_state.current.kind == .TOKEN_RIGHTBRACE ||
|
||||
parse_state.current.kind == .TOKEN_LEFTBRACE{
|
||||
break;
|
||||
parse_state.current.kind == .TOKEN_LEFTBRACE || parse_state.current.kind == .TOKEN_EOF {
|
||||
break;
|
||||
}
|
||||
advance(parse_state);
|
||||
}
|
||||
@@ -270,13 +370,217 @@ advance_to_sync_point :: (parse_state : *Parse_State) {
|
||||
////////////////////////////
|
||||
//@nb - Base parsing functions
|
||||
|
||||
make_node :: (parse_state : *Parse_State, kind : AST_Kind) -> *AST_Node {
|
||||
make_node :: (nodes : *[..]AST_Node, kind : AST_Kind) -> *AST_Node {
|
||||
node : AST_Node;
|
||||
|
||||
node.kind = kind;
|
||||
array_add(*parse_state.result.nodes, node);
|
||||
array_add(nodes, node);
|
||||
|
||||
return *parse_state.result.nodes[parse_state.result.nodes.count - 1];
|
||||
return *(nodes.*[nodes.count - 1]);
|
||||
}
|
||||
|
||||
make_node :: (parse_state : *Parse_State, kind : AST_Kind) -> *AST_Node {
|
||||
return make_node(*parse_state.ctx.nodes, kind);
|
||||
}
|
||||
|
||||
// new_builtin_node :: (nodes : *[..]AST_Node, kind : AST_Kind) -> *AST_Node {
|
||||
// node := make_node(parse_state, kind);
|
||||
// node.builtin = true;
|
||||
// return node;
|
||||
// }
|
||||
|
||||
make_builtin_token :: (tokens : *[..]Token, builder : *String_Builder, kind : Token_Kind, text : string, col : *int, line : *int) -> *Token {
|
||||
tok : Token;
|
||||
tok.kind = kind;
|
||||
|
||||
start := 0;
|
||||
|
||||
buffer := get_current_buffer(builder);
|
||||
|
||||
if buffer {
|
||||
start := buffer.count;
|
||||
}
|
||||
tok.column = col.*;
|
||||
|
||||
print_to_builder(builder, "%", text);
|
||||
buffer = get_current_buffer(builder);
|
||||
end := buffer.count;
|
||||
|
||||
for c : text {
|
||||
if c == #char "\n" {
|
||||
line.* ++ 1;
|
||||
col.* = 0;
|
||||
} else {
|
||||
col.* += 1;
|
||||
}
|
||||
}
|
||||
|
||||
tok.index = buffer.count - text.count;
|
||||
tok.length = text.count;
|
||||
tok.builtin = true;
|
||||
|
||||
array_add(tokens, tok);
|
||||
|
||||
return *(tokens.*)[tokens.count - 1];
|
||||
}
|
||||
|
||||
new_builtin_struct_node :: (ctx : *Compiler_Context, name : string, members : []Arg) -> *AST_Node {
|
||||
sc := get_scratch(context.allocator);
|
||||
defer scratch_end(sc);
|
||||
builder : String_Builder;
|
||||
builder.allocator = sc.allocator; // I want to find a good way to use scratch here...
|
||||
|
||||
node := make_node(*ctx.nodes, .Struct);
|
||||
|
||||
source_location : Source_Range;
|
||||
|
||||
col := 0;
|
||||
line := 0;
|
||||
|
||||
tok_index := ctx.tokens.count;
|
||||
|
||||
ident_token := make_builtin_token(*ctx.tokens, *builder, .TOKEN_IDENTIFIER, tprint("%", name), *col, *line);
|
||||
ident_token.ident_value = name;
|
||||
source_location.begin = ident_token;
|
||||
|
||||
append(*builder, " ");
|
||||
make_builtin_token(*ctx.tokens, *builder, .TOKEN_DOUBLECOLON, "::", *col, *line);
|
||||
append(*builder, " ");
|
||||
make_builtin_token(*ctx.tokens, *builder, .TOKEN_STRUCT, "struct", *col, *line);
|
||||
append(*builder, " ");
|
||||
make_builtin_token(*ctx.tokens, *builder, .TOKEN_LEFTBRACE, "{", *col, *line);
|
||||
append(*builder, "\n");
|
||||
line += 1;
|
||||
col = 0;
|
||||
|
||||
field_list := make_node(*ctx.nodes, .FieldList);
|
||||
add_child(node, field_list);
|
||||
|
||||
for member : members {
|
||||
field := make_node(*ctx.nodes, .Field);
|
||||
field_source_loc : Source_Range;
|
||||
|
||||
indent(*builder, 1);
|
||||
field_ident := make_builtin_token(*ctx.tokens, *builder, .TOKEN_IDENTIFIER, tprint("%", member.name), *col, *line);
|
||||
field_source_loc.begin = field_ident;
|
||||
field.token = field_ident;
|
||||
field.name = member.name;
|
||||
|
||||
append(*builder, " ");
|
||||
make_builtin_token(*ctx.tokens, *builder, .TOKEN_COLON, ":", *col, *line);
|
||||
append(*builder, " ");
|
||||
make_builtin_token(*ctx.tokens, *builder, .TOKEN_IDENTIFIER, tprint("%", member.typename), *col, *line);
|
||||
semicolon_tok := make_builtin_token(*ctx.tokens, *builder, .TOKEN_SEMICOLON, ";", *col, *line);
|
||||
append(*builder, "\n");
|
||||
col = 0;
|
||||
line += 1;
|
||||
|
||||
field_source_loc.end = semicolon_tok;
|
||||
field.source_location = field_source_loc;
|
||||
|
||||
add_child(field_list, field);
|
||||
}
|
||||
|
||||
brace_token := make_builtin_token(*ctx.tokens, *builder, .TOKEN_RIGHTBRACE, "}", *col, *line);
|
||||
append(*builder, "\n");
|
||||
|
||||
source_location.end = brace_token;
|
||||
|
||||
source := builder_to_string(*builder,, context.allocator);
|
||||
|
||||
source_location.begin.source = *source.data[source_location.begin.column];
|
||||
source_location.end.source = *source.data[source_location.end.column];
|
||||
|
||||
for i : tok_index..ctx.tokens.count - 1 {
|
||||
tok := ctx.tokens[i];
|
||||
tok.source = *source.data[tok.column];
|
||||
}
|
||||
|
||||
for field : field_list.children {
|
||||
field.source_location.begin.source = *source.data[field.source_location.begin.column];
|
||||
field.source_location.end.source = *source.data[field.source_location.end.column];
|
||||
// field.source_location.main_token.source = *source.data[tok.column];
|
||||
}
|
||||
|
||||
node.source_location = source_location;
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
new_builtin_function_node :: (ctx : *Compiler_Context, name : string, members : []Arg, return_var : Arg) -> *AST_Node {
|
||||
sc := get_scratch(context.allocator);
|
||||
defer scratch_end(sc);
|
||||
builder : String_Builder;
|
||||
builder.allocator = sc.allocator; // I want to find a good way to use scratch here...
|
||||
|
||||
node := make_node(*ctx.nodes, .Function);
|
||||
|
||||
source_location : Source_Range;
|
||||
|
||||
col := 0;
|
||||
line := 0;
|
||||
|
||||
tok_index := ctx.tokens.count;
|
||||
|
||||
ident_token := make_builtin_token(*ctx.tokens, *builder, .TOKEN_IDENTIFIER, tprint("%", name), *col, *line);
|
||||
source_location.begin = ident_token;
|
||||
|
||||
append(*builder, " ");
|
||||
make_builtin_token(*ctx.tokens, *builder, .TOKEN_DOUBLECOLON, "::", *col, *line);
|
||||
append(*builder, " ");
|
||||
make_builtin_token(*ctx.tokens, *builder, .TOKEN_LEFTPAREN, "(", *col, *line);
|
||||
field_list := make_node(*ctx.nodes, .FieldList);
|
||||
add_child(node, field_list);
|
||||
|
||||
for member : members {
|
||||
field := make_node(*ctx.nodes, .Field);
|
||||
field_source_loc : Source_Range;
|
||||
|
||||
// field_ident := make_builtin_token(*ctx.tokens, *builder, .TOKEN_IDENTIFIER, tprint("%", member.name), *col, *line);
|
||||
type_tok := make_builtin_token(*ctx.tokens, *builder, .TOKEN_IDENTIFIER, tprint("%", member.typename), *col, *line);
|
||||
field_source_loc.begin = type_tok;
|
||||
field.token = type_tok;
|
||||
|
||||
if it_index < members.count - 1 {
|
||||
make_builtin_token(*ctx.tokens, *builder, .TOKEN_COMMA, ",", *col, *line);
|
||||
append(*builder, " ");
|
||||
}
|
||||
|
||||
field_source_loc.end = type_tok;
|
||||
field.source_location = field_source_loc;
|
||||
|
||||
add_child(field_list, field);
|
||||
}
|
||||
|
||||
make_builtin_token(*ctx.tokens, *builder, .TOKEN_RIGHTPAREN, ")", *col, *line);
|
||||
semicolon_tok := make_builtin_token(*ctx.tokens, *builder, .TOKEN_SEMICOLON, ";", *col, *line);
|
||||
|
||||
source_location.end = semicolon_tok;
|
||||
|
||||
source := builder_to_string(*builder,, context.allocator);
|
||||
|
||||
source_location.begin.source = *source.data[source_location.begin.column];
|
||||
source_location.end.source = *source.data[source_location.end.column];
|
||||
|
||||
for i : tok_index..ctx.tokens.count - 1 {
|
||||
tok := ctx.tokens[i];
|
||||
tok.source = *source.data[tok.column];
|
||||
}
|
||||
|
||||
for field : field_list.children {
|
||||
field.source_location.begin.source = *source.data[field.source_location.begin.column];
|
||||
field.source_location.end.source = *source.data[field.source_location.end.column];
|
||||
// field.source_location.main_token.source = *source.data[tok.column];
|
||||
}
|
||||
|
||||
node.source_location = source_location;
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
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);
|
||||
return struct_or_func.children[0];
|
||||
}
|
||||
|
||||
add_child :: (node : *AST_Node, child : *AST_Node) {
|
||||
@@ -309,7 +613,10 @@ advance :: (parse_state : *Parse_State) {
|
||||
parse_state.previous = parse_state.current;
|
||||
|
||||
while true {
|
||||
parse_state.current = *parse_state.tokens[parse_state.current_token_index];
|
||||
if parse_state.current_token_index >= parse_state.ctx.tokens.count {
|
||||
break;
|
||||
}
|
||||
parse_state.current = *parse_state.ctx.tokens[parse_state.current_token_index];
|
||||
parse_state.current_token_index += 1;
|
||||
if parse_state.current.kind != .TOKEN_ERROR break;
|
||||
|
||||
@@ -331,21 +638,35 @@ check :: (parse_state : *Parse_State, kind : Token_Kind) -> bool {
|
||||
return parse_state.current.kind == kind;
|
||||
}
|
||||
|
||||
check_any :: (parse_state : *Parse_State, kinds : ..Token_Kind) -> bool {
|
||||
for kind : kinds {
|
||||
if check(parse_state, kind) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//nb - Checks if the next token is of a certain kind
|
||||
check_next :: (parse_state : *Parse_State, kind : Token_Kind) -> bool {
|
||||
return parse_state.tokens[parse_state.current_token_index].kind == kind;
|
||||
return parse_state.ctx.tokens[parse_state.current_token_index].kind == kind;
|
||||
}
|
||||
|
||||
//nb - Consume a token if
|
||||
consume :: (parse_state : *Parse_State, kind : Token_Kind, message : string) {
|
||||
consume :: (parse_state : *Parse_State, kind : Token_Kind, message : string) {
|
||||
if parse_state.current.kind == kind {
|
||||
advance(parse_state);
|
||||
return;
|
||||
}
|
||||
|
||||
advance(parse_state);
|
||||
unexpected_token(parse_state, parse_state.current, message);
|
||||
consume(parse_state, kind, message);
|
||||
token := parse_state.previous;
|
||||
advance_to_sync_point(parse_state);
|
||||
|
||||
unexpected_token(parse_state, token, message);
|
||||
|
||||
if parse_state.current.kind == .TOKEN_EOF {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////
|
||||
@@ -354,13 +675,21 @@ get_rule :: (kind : Token_Kind) -> *Parse_Rule {
|
||||
return *parse_rules[kind];
|
||||
}
|
||||
|
||||
precedence :: (parse_state : *Parse_State, precedence : Precedence) -> *AST_Node {
|
||||
precedence :: (parse_state : *Parse_State, precedence : Precedence, message : string = "") -> *AST_Node {
|
||||
prev := parse_state.previous;
|
||||
advance(parse_state);
|
||||
|
||||
prefix_rule := get_rule(parse_state.previous.kind).prefix;
|
||||
if prefix_rule == null {
|
||||
expected_expression(parse_state, parse_state.current, "Expected expression.");
|
||||
// @Incomplete: Add error node here?
|
||||
tok_s : string;
|
||||
tok_s.data = prev.source;
|
||||
tok_s.count = prev.length;
|
||||
if message {
|
||||
expected_expression(parse_state, prev, tprint("Expected expression after '%'. %", tok_s, message));
|
||||
} else {
|
||||
expected_expression(parse_state, prev, tprint("Expected expression after '%'.", tok_s));
|
||||
}
|
||||
|
||||
return error_node(parse_state, "Expected expression.");
|
||||
}
|
||||
|
||||
@@ -369,7 +698,10 @@ precedence :: (parse_state : *Parse_State, precedence : Precedence) -> *AST_Node
|
||||
while precedence <= get_rule(parse_state.current.kind).precedence {
|
||||
advance(parse_state);
|
||||
if parse_state.current.kind == .TOKEN_EOF {
|
||||
expected_expression(parse_state, parse_state.current, "Reached end of file. Expected expression.");
|
||||
tok_s : string;
|
||||
tok_s.data = parse_state.previous.source;
|
||||
tok_s.count = parse_state.previous.length;
|
||||
expected_expression(parse_state, parse_state.current, tprint("Reached end of file. Expected expression after '%'.", tok_s));
|
||||
// @Incomplete: Add error node here?
|
||||
return null;
|
||||
}
|
||||
@@ -408,6 +740,10 @@ binary :: (parse_state : *Parse_State, left : *AST_Node) -> *AST_Node {
|
||||
|
||||
if op.kind == {
|
||||
case .TOKEN_PLUS; #through;
|
||||
case .TOKEN_PLUSEQUALS; #through;
|
||||
case .TOKEN_MINUSEQUALS; #through;
|
||||
case .TOKEN_TIMESEQUALS; #through;
|
||||
case .TOKEN_DIVEQUALS; #through;
|
||||
case .TOKEN_MINUS; #through;
|
||||
case .TOKEN_STAR; #through;
|
||||
case .TOKEN_SLASH; #through;
|
||||
@@ -432,8 +768,8 @@ binary :: (parse_state : *Parse_State, left : *AST_Node) -> *AST_Node {
|
||||
}
|
||||
|
||||
array_access :: (parse_state : *Parse_State, left : *AST_Node) -> *AST_Node {
|
||||
identifier := parse_state.tokens[parse_state.current_token_index - 3];
|
||||
left_bracket := parse_state.tokens[parse_state.current_token_index - 2];
|
||||
identifier := parse_state.ctx.tokens[parse_state.current_token_index - 3];
|
||||
left_bracket := parse_state.ctx.tokens[parse_state.current_token_index - 2];
|
||||
|
||||
array_access := make_node(parse_state, .Unary);
|
||||
array_access.token = left_bracket;
|
||||
@@ -456,8 +792,9 @@ array_access :: (parse_state : *Parse_State, left : *AST_Node) -> *AST_Node {
|
||||
add_child(node, expression(parse_state));
|
||||
return node;
|
||||
}
|
||||
|
||||
|
||||
source_location.end = parse_state.previous;
|
||||
left.source_location = source_location;
|
||||
return left;
|
||||
}
|
||||
|
||||
@@ -497,6 +834,66 @@ directive :: (state : *Parse_State) -> *AST_Node {
|
||||
func := function_declaration(state, identifier_token, .None, false, false);
|
||||
func.foreign_declaration = true;
|
||||
return func;
|
||||
} else if state.current.ident_value == "if" {
|
||||
if_directive := make_node(state, .If_Directive);
|
||||
|
||||
source_location : Source_Range;
|
||||
// source_location.begin = state.previous;
|
||||
|
||||
advance(state);
|
||||
|
||||
cond := expression(state);
|
||||
add_child(if_directive, cond);
|
||||
|
||||
if_body := block(state);
|
||||
add_child(if_directive, if_body);
|
||||
|
||||
if_directive.source_location = source_location;
|
||||
|
||||
return if_directive;
|
||||
} else if state.current.ident_value == "load" {
|
||||
advance(state);
|
||||
|
||||
if check(state, .TOKEN_STRING) {
|
||||
// path_tok := state.current;
|
||||
// path := path_tok.string_value;
|
||||
|
||||
// advance(state);
|
||||
|
||||
// result : Compiler_Context;
|
||||
// ctx.allocator = state.ctx.allocator;
|
||||
// ctx.environment = state.ctx.environment;
|
||||
|
||||
// ctx.file = make_file(*result, path);
|
||||
|
||||
// if ctx.file.source.count == 0 {
|
||||
// unable_to_open_file(state, path, path_tok);
|
||||
// advance_to_sync_point(state);
|
||||
// advance(state);
|
||||
// return null;
|
||||
// }
|
||||
|
||||
// consume(state, .TOKEN_SEMICOLON, "Expected ';' after #load directive");
|
||||
|
||||
// lex(*result);
|
||||
|
||||
// count := state.ctx.tokens..count;
|
||||
// current_idx := state.current_token_index;
|
||||
// result_count := ctx.tokens..count;
|
||||
|
||||
// // state.ctx.tokens..count -= 1;
|
||||
// array_resize(*state.ctx.tokens., count + result_count - 1);
|
||||
|
||||
// memcpy(*state.ctx.tokens[current_idx + result_count - 1], *state.ctx.tokens[current_idx], size_of(Token) * (count - current_idx));
|
||||
|
||||
// for *tok : ctx.tokens. {
|
||||
// if tok.kind == .TOKEN_EOF {
|
||||
// break;
|
||||
// }
|
||||
// tok.builtin = true;
|
||||
// state.ctx.tokens[it_index] = tok.*;
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -535,7 +932,7 @@ dot :: (parse_state : *Parse_State, left : *AST_Node) -> *AST_Node {
|
||||
source_location : Source_Range;
|
||||
source_location.begin = left.source_location.begin;
|
||||
|
||||
if check(parse_state, .TOKEN_ASSIGN) {
|
||||
if check_any(parse_state, .TOKEN_ASSIGN, .TOKEN_MINUSEQUALS, .TOKEN_PLUSEQUALS, .TOKEN_DIVEQUALS, .TOKEN_MODEQUALS, .TOKEN_TIMESEQUALS) {
|
||||
advance(parse_state);
|
||||
variable := make_node(parse_state, .Variable);
|
||||
variable.source_location = generate_source_location_from_token(parse_state, identifier);
|
||||
@@ -548,12 +945,15 @@ dot :: (parse_state : *Parse_State, left : *AST_Node) -> *AST_Node {
|
||||
add_child(node, left);
|
||||
add_child(node, expression(parse_state));
|
||||
return node;
|
||||
} else if check(parse_state, .TOKEN_DOT) {
|
||||
// @Incomplete(nb): Another level of access
|
||||
}
|
||||
}
|
||||
variable := make_node(parse_state, .Variable);
|
||||
variable.name = identifier.ident_value;
|
||||
|
||||
if check(parse_state, .TOKEN_DOT) {
|
||||
advance(parse_state);
|
||||
dot(parse_state, variable);
|
||||
}
|
||||
|
||||
add_child(left, variable);
|
||||
|
||||
source_location.end = parse_state.previous;
|
||||
@@ -581,8 +981,8 @@ floating :: (parse_state : *Parse_State, left : *AST_Node) -> *AST_Node {
|
||||
return node;
|
||||
}
|
||||
|
||||
expression :: (parse_state : *Parse_State) -> *AST_Node {
|
||||
expression := precedence(parse_state, .PREC_ASSIGNMENT);
|
||||
expression :: (parse_state : *Parse_State, message : string = "") -> *AST_Node {
|
||||
expression := precedence(parse_state, .PREC_ASSIGNMENT, message);
|
||||
return expression;
|
||||
}
|
||||
|
||||
@@ -636,8 +1036,12 @@ field_declaration :: (parse_state : *Parse_State, identifier_token : *Token) ->
|
||||
advance(parse_state);
|
||||
node.array_field = true;
|
||||
} else {
|
||||
missing_type_specifier(parse_state, identifier_token, "Expected type specifier after field name.");
|
||||
return node;
|
||||
if !check(parse_state, .TOKEN_ASSIGN) {
|
||||
internal_error_message(*parse_state.ctx.messages, "Unimplemented error message.", parse_state.ctx.file.path);
|
||||
return node;
|
||||
}
|
||||
// missing_type_specifier(parse_state, identifier_token, "Expected type specifier after field name.");
|
||||
|
||||
}
|
||||
|
||||
if check(parse_state, .TOKEN_AT) {
|
||||
@@ -655,7 +1059,6 @@ field_declaration :: (parse_state : *Parse_State, identifier_token : *Token) ->
|
||||
advance(parse_state);
|
||||
}
|
||||
}
|
||||
|
||||
} else if match(parse_state, .TOKEN_ASSIGN) {
|
||||
add_child(node, expression(parse_state));
|
||||
}
|
||||
@@ -678,6 +1081,9 @@ argument_list :: (parse_state : *Parse_State) -> *AST_Node {
|
||||
|
||||
source_location.main_token = parse_state.current;
|
||||
|
||||
error_before := parse_state.ctx.had_error;
|
||||
parse_state.ctx.had_error = false;
|
||||
|
||||
while !check(parse_state, .TOKEN_RIGHTPAREN) {
|
||||
arg := expression(parse_state);
|
||||
if !node {
|
||||
@@ -688,8 +1094,14 @@ argument_list :: (parse_state : *Parse_State) -> *AST_Node {
|
||||
|
||||
if check(parse_state, .TOKEN_RIGHTPAREN) break;
|
||||
consume(parse_state, .TOKEN_COMMA, "Expect ',' after function argument.");
|
||||
|
||||
if parse_state.ctx.had_error {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
parse_state.ctx.had_error = error_before || parse_state.ctx.had_error;
|
||||
|
||||
consume(parse_state, .TOKEN_RIGHTPAREN, "Expect ')' after function call.");
|
||||
|
||||
if node {
|
||||
@@ -742,6 +1154,98 @@ statement :: (parse_state : *Parse_State) -> *AST_Node {
|
||||
source_location.end = parse_state.previous;
|
||||
node.source_location = source_location;
|
||||
return node;
|
||||
} else if match(parse_state, .TOKEN_IF) {
|
||||
node := make_node(parse_state, .If);
|
||||
|
||||
source_location : Source_Range;
|
||||
source_location.begin = parse_state.previous;
|
||||
|
||||
if_cond := expression(parse_state, "Expected if condition.");
|
||||
add_child(node, if_cond);
|
||||
source_location.end = parse_state.previous;
|
||||
advance_to_sync_point(parse_state);
|
||||
|
||||
if_body := block(parse_state);
|
||||
add_child(node, if_body);
|
||||
|
||||
if match(parse_state, .TOKEN_ELSE) {
|
||||
else_node := else_statement(parse_state);
|
||||
add_child(node, else_node);
|
||||
}
|
||||
|
||||
node.source_location = source_location;
|
||||
|
||||
return node;
|
||||
} else if match(parse_state, .TOKEN_ELSE) {
|
||||
if check(parse_state, .TOKEN_IF) {
|
||||
else_if_without_if(parse_state);
|
||||
advance_to_sync_point(parse_state);
|
||||
if check(parse_state, .TOKEN_LEFTBRACE) {
|
||||
return block(parse_state);
|
||||
}
|
||||
return error_node(parse_state, "'else if' without 'if'.");
|
||||
} else {
|
||||
else_without_if(parse_state);
|
||||
advance_to_sync_point(parse_state);
|
||||
if check(parse_state, .TOKEN_LEFTBRACE) {
|
||||
return block(parse_state);
|
||||
}
|
||||
|
||||
return error_node(parse_state, "'else' without 'if'.");
|
||||
}
|
||||
} else if match(parse_state, .TOKEN_FOR) {
|
||||
if check(parse_state, .TOKEN_IDENTIFIER) {
|
||||
node := make_node(parse_state, .For);
|
||||
|
||||
source_location : Source_Range;
|
||||
source_location.begin = parse_state.previous;
|
||||
|
||||
loop_iterator := parse_state.current;
|
||||
node.token = loop_iterator;
|
||||
advance(parse_state);
|
||||
consume(parse_state, .TOKEN_COLON, "Expect ':' after for loop iterator.");
|
||||
|
||||
snap := snapshot_state(parse_state);
|
||||
|
||||
begin_iter := expression(parse_state, "Expected beginning of iterator.");
|
||||
if begin_iter.kind == .Error {
|
||||
unable_to_parse_statement(parse_state, source_location.begin);
|
||||
rewind_to_snapshot(parse_state, snap);
|
||||
if parse_state.current.kind == .TOKEN_LEFTBRACE {
|
||||
block(parse_state);
|
||||
}
|
||||
return error_node(parse_state, "'for' without well-formed iterator expression.");
|
||||
}
|
||||
add_child(node, begin_iter);
|
||||
|
||||
consume(parse_state, .TOKEN_DOTDOT, "Expect '..' after for loop iter left hand side.");
|
||||
|
||||
snap = snapshot_state(parse_state);
|
||||
end_iter := expression(parse_state, "Expected end of iterator.");
|
||||
if end_iter.kind == .Error {
|
||||
unable_to_parse_statement(parse_state, source_location.begin);
|
||||
rewind_to_snapshot(parse_state, snap);
|
||||
|
||||
if parse_state.current.kind == .TOKEN_LEFTBRACE {
|
||||
|
||||
block(parse_state);
|
||||
}
|
||||
return error_node(parse_state, "'for' without well-formed iterator expression.");
|
||||
}
|
||||
add_child(node, end_iter);
|
||||
|
||||
if check(parse_state, .TOKEN_LEFTBRACE) {
|
||||
for_body := block(parse_state);
|
||||
add_child(node, for_body);
|
||||
} else {
|
||||
unable_to_parse_statement(parse_state, source_location.begin, "'for' currently expects a brace-enclosed block as a body.");
|
||||
return error_node(parse_state, "'for' currently expects a brace-enclosed block as a body.");
|
||||
}
|
||||
|
||||
node.source_location = source_location;
|
||||
|
||||
return node;
|
||||
}
|
||||
} else {
|
||||
return expression_statement(parse_state);
|
||||
}
|
||||
@@ -749,8 +1253,16 @@ statement :: (parse_state : *Parse_State) -> *AST_Node {
|
||||
return error_node(parse_state, "Couldn't parse statement.");
|
||||
}
|
||||
|
||||
else_statement :: (parse_state : *Parse_State) -> *AST_Node {
|
||||
if check(parse_state, .TOKEN_IF) {
|
||||
return statement(parse_state);
|
||||
}
|
||||
return block(parse_state);
|
||||
}
|
||||
|
||||
block :: (parse_state : *Parse_State) -> *AST_Node {
|
||||
node : *AST_Node = make_node(parse_state, .Block);
|
||||
array_reserve(*node.children, 1024);
|
||||
|
||||
source_location : Source_Range;
|
||||
|
||||
@@ -937,6 +1449,18 @@ constant_buffer :: (parse_state : *Parse_State, identifier_token : *Token = null
|
||||
node : *AST_Node;
|
||||
source_location : Source_Range;
|
||||
source_location.begin = parse_state.current;
|
||||
|
||||
if check(parse_state, .TOKEN_AT) {
|
||||
while check(parse_state, .TOKEN_AT) {
|
||||
advance(parse_state);
|
||||
// @Incomplete(niels): this is a mapping
|
||||
if check(parse_state, .TOKEN_IDENTIFIER) {
|
||||
array_add(*node.hint_tokens, parse_state.current);
|
||||
advance(parse_state);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
consume(parse_state, .TOKEN_LEFTBRACE, "Expect '{' after 'constant_buffer' keyword");
|
||||
buffer := field_list(parse_state, .Semicolon);
|
||||
|
||||
@@ -991,6 +1515,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);
|
||||
@@ -1018,6 +1543,7 @@ declaration :: (parse_state : *Parse_State) -> *AST_Node {
|
||||
decl_node = call(parse_state, null);
|
||||
} else if check(parse_state, .TOKEN_DIRECTIVE) {
|
||||
decl_node = directive(parse_state);
|
||||
skip_statement = true;
|
||||
} else if check(parse_state, .TOKEN_IDENTIFIER) {
|
||||
identifier := parse_state.current;
|
||||
|
||||
@@ -1040,7 +1566,7 @@ declaration :: (parse_state : *Parse_State) -> *AST_Node {
|
||||
decl_node = error;
|
||||
}
|
||||
|
||||
if !decl_node {
|
||||
if !decl_node && !skip_statement {
|
||||
decl_node = statement(parse_state);
|
||||
}
|
||||
|
||||
@@ -1051,16 +1577,28 @@ declaration :: (parse_state : *Parse_State) -> *AST_Node {
|
||||
return decl_node;
|
||||
}
|
||||
|
||||
parse :: (result : *Compile_Result) {
|
||||
for *file : result.files {
|
||||
parse :: (ctx : *Compiler_Context, allocator := temp) {
|
||||
if ctx.had_error {
|
||||
return;
|
||||
}
|
||||
|
||||
new_context := context;
|
||||
new_context.allocator = allocator;
|
||||
push_context new_context {
|
||||
init_context_allocators();
|
||||
defer clear_context_allocators();
|
||||
|
||||
parse_state : Parse_State;
|
||||
init_parse_state(*parse_state, file.tokens.tokens, file.file.path, result.allocator);
|
||||
array_reserve(*ctx.nodes, 4096);
|
||||
parse_state.current_token_index = 0;
|
||||
parse_state.ctx = ctx;
|
||||
|
||||
advance(*parse_state);
|
||||
|
||||
if !match(*parse_state, .TOKEN_EOF) {
|
||||
parse_state.result.root = make_node(*parse_state, .Program);
|
||||
array_reserve(*parse_state.result.root.children, 1024);
|
||||
program := parse_state.result.root;
|
||||
parse_state.ctx.root = make_node(*parse_state, .Program);
|
||||
array_reserve(*parse_state.ctx.root.children, 1024);
|
||||
program := parse_state.ctx.root;
|
||||
|
||||
while !check(*parse_state, .TOKEN_EOF) {
|
||||
decl := declaration(*parse_state);
|
||||
@@ -1069,32 +1607,7 @@ parse :: (result : *Compile_Result) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//@Incomplete(nb): will this straight copy just work?
|
||||
// Might need to rething how we do this.
|
||||
file.ast_root = parse_state.result.root;
|
||||
file.ast_nodes = parse_state.result.nodes;
|
||||
copy_messages(parse_state.result.messages, *result.messages);
|
||||
}
|
||||
}
|
||||
|
||||
parse :: (parse_state : *Parse_State) -> Parse_Result {
|
||||
advance(parse_state);
|
||||
|
||||
if !match(parse_state, .TOKEN_EOF) {
|
||||
parse_state.result.root = make_node(parse_state, .Program);
|
||||
array_reserve(*parse_state.result.root.children, 1024);
|
||||
program := parse_state.result.root;
|
||||
|
||||
while !check(parse_state, .TOKEN_EOF) {
|
||||
decl := declaration(parse_state);
|
||||
if decl {
|
||||
add_child(program, decl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return parse_state.result;
|
||||
}
|
||||
|
||||
#load "AST.jai";
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
762
Test.jai
762
Test.jai
@@ -1,762 +0,0 @@
|
||||
/////////////////////////////////////
|
||||
//~ nbr: General improvements
|
||||
//
|
||||
// [x] Print out all failed tests in a list at the end
|
||||
// [ ] Use unix (posix? bash? ascii?) color codes for errors
|
||||
// [ ] Print golden file as green and new output as red
|
||||
|
||||
#import "Basic";
|
||||
#import "File";
|
||||
#import "String";
|
||||
#import "File_Utilities";
|
||||
#import "Print_Color";
|
||||
|
||||
#load "module.jai";
|
||||
|
||||
GOLDEN_EXTENSION :: "golden";
|
||||
LEXER_FOLDER :: "lex";
|
||||
PARSER_FOLDER :: "parse";
|
||||
CODEGEN_FOLDER :: "codegen";
|
||||
COMPILED_FOLDER :: "compiled";
|
||||
SEMANTIC_ANALYSIS_FOLDER :: "semant";
|
||||
TESTS_FOLDER :: "test";
|
||||
|
||||
SHADER_EXTENSION :: "shd";
|
||||
SUITE_EXTENSION :: "suite";
|
||||
|
||||
Stage_Flags :: enum_flags u16 {
|
||||
Lexer :: 0x1;
|
||||
Parser :: 0x2;
|
||||
Semantic_Analysis :: 0x4;
|
||||
Codegen :: 0x8;
|
||||
Compile :: 0x10;
|
||||
}
|
||||
|
||||
Output_Type :: enum_flags u16 {
|
||||
Golden :: 0x1;
|
||||
StdOut :: 0x2;
|
||||
}
|
||||
|
||||
Result_Type :: enum {
|
||||
File_Read_Failed;
|
||||
Golden_File_Not_Found;
|
||||
StdOut;
|
||||
Golden_Output;
|
||||
Passed;
|
||||
Failed;
|
||||
}
|
||||
|
||||
Result :: struct {
|
||||
type : Result_Type;
|
||||
path : string;
|
||||
stage : Stage_Flags;
|
||||
|
||||
golden_path : string;
|
||||
info_text : string;
|
||||
}
|
||||
|
||||
Test_Case :: struct {
|
||||
path : string;
|
||||
stage_flags : Stage_Flags;
|
||||
}
|
||||
|
||||
Test_Suite :: struct {
|
||||
name : string;
|
||||
test_cases : [..]Test_Case;
|
||||
|
||||
results : [..]Result;
|
||||
}
|
||||
|
||||
get_golden_path :: (file_path : string, stage : Stage_Flags, allocator := context.allocator) -> string {
|
||||
path := parse_path(file_path);
|
||||
file_without_extension := split(path.words[path.words.count - 1], ".");
|
||||
|
||||
builder : String_Builder;
|
||||
builder.allocator = temp;
|
||||
|
||||
final_path_length := file_path.count - SHADER_EXTENSION.count + GOLDEN_EXTENSION.count + 1; // +1 for dot
|
||||
|
||||
path.words.count -= 1;
|
||||
|
||||
if stage == {
|
||||
case .Lexer; {
|
||||
dir := tprint("%/%", TESTS_FOLDER, LEXER_FOLDER);
|
||||
make_directory_if_it_does_not_exist(dir);
|
||||
array_add(*path.words, LEXER_FOLDER);
|
||||
}
|
||||
case .Parser; {
|
||||
dir := tprint("%/%", TESTS_FOLDER, PARSER_FOLDER);
|
||||
make_directory_if_it_does_not_exist(dir);
|
||||
array_add(*path.words, PARSER_FOLDER);
|
||||
}
|
||||
case .Semantic_Analysis; {
|
||||
dir := tprint("%/%", TESTS_FOLDER, SEMANTIC_ANALYSIS_FOLDER);
|
||||
make_directory_if_it_does_not_exist(dir);
|
||||
array_add(*path.words, SEMANTIC_ANALYSIS_FOLDER);
|
||||
}
|
||||
case .Codegen; {
|
||||
dir := tprint("%/%", TESTS_FOLDER, CODEGEN_FOLDER);
|
||||
make_directory_if_it_does_not_exist(dir);
|
||||
array_add(*path.words, CODEGEN_FOLDER);
|
||||
}
|
||||
case .Compile; {
|
||||
dir := tprint("%/%", TESTS_FOLDER, COMPILED_FOLDER);
|
||||
make_directory_if_it_does_not_exist(dir);
|
||||
array_add(*path.words, COMPILED_FOLDER);
|
||||
}
|
||||
}
|
||||
|
||||
init_string_builder(*builder, file_without_extension.count + GOLDEN_EXTENSION.count + 1);
|
||||
append(*builder, file_without_extension[0]);
|
||||
append(*builder, ".");
|
||||
append(*builder, GOLDEN_EXTENSION);
|
||||
golden_path := builder_to_string(*builder);
|
||||
array_add(*path.words, golden_path);
|
||||
|
||||
final_path := path_to_string(path);
|
||||
|
||||
return final_path;
|
||||
}
|
||||
|
||||
run_lexer_test :: (file_path : string, lexer : *Lexer, output_type : Output_Type = 0) -> Result {
|
||||
ok := read_input_from_file(lexer, file_path);
|
||||
|
||||
result_data : Result;
|
||||
result_data.path = file_path;
|
||||
result_data.stage = .Lexer;
|
||||
|
||||
if !ok {
|
||||
result_data.type = .File_Read_Failed;
|
||||
result_data.info_text = tprint("Unable to read file: %\n", file_path);
|
||||
|
||||
return result_data;
|
||||
} else {
|
||||
result_text : string;
|
||||
result := lex(lexer, *temp);
|
||||
|
||||
if result.had_error {
|
||||
result_data.type = .Failed;
|
||||
result_text = report_messages(result.messages);
|
||||
} else {
|
||||
result_text = pretty_print_tokens(result.tokens, *temp);
|
||||
}
|
||||
|
||||
if output_type & .StdOut {
|
||||
result_data.info_text = result_text;
|
||||
result_data.type = .StdOut;
|
||||
return result_data;
|
||||
}
|
||||
|
||||
golden_path := get_golden_path(file_path, .Lexer);
|
||||
do_golden_comparison(golden_path, result_text, *result_data, output_type);
|
||||
return result_data;
|
||||
}
|
||||
}
|
||||
|
||||
run_parser_test :: (file_path : string, output_type : Output_Type = 0) -> Result, *AST_Node {
|
||||
lexer : Lexer;
|
||||
result_data : Result;
|
||||
result_data.path = file_path;
|
||||
|
||||
ok := read_input_from_file(*lexer, file_path);
|
||||
if !ok {
|
||||
log_error("Unable to read file: %\n", file_path);
|
||||
result_data.type = .File_Read_Failed;
|
||||
result_data.stage = .Lexer;
|
||||
return result_data, null;
|
||||
}
|
||||
|
||||
result := lex(*lexer, *temp);
|
||||
if result.had_error {
|
||||
result_data.type = .Passed;
|
||||
return result_data, null;
|
||||
}
|
||||
|
||||
result_data =, root := run_parser_test(*lexer, output_type);
|
||||
|
||||
return result_data, root;
|
||||
}
|
||||
|
||||
do_golden_comparison :: (golden_path : string, comparison_text : string, result_data : *Result, output_type : Output_Type) {
|
||||
if output_type & .Golden {
|
||||
// Output the comparison file
|
||||
write_entire_file(golden_path, comparison_text);
|
||||
result_data.golden_path = copy_string(golden_path);
|
||||
result_data.type = .Golden_Output;
|
||||
return;
|
||||
} else {
|
||||
// Do the comparison
|
||||
if !file_exists(golden_path) {
|
||||
result_data.info_text = tprint("Golden file % does not exist. Please run with -output-as-golden at least once.\n", golden_path);
|
||||
result_data.type = .Golden_File_Not_Found;
|
||||
return;
|
||||
}
|
||||
|
||||
golden_text, ok := read_entire_file(golden_path);
|
||||
if !ok {
|
||||
result_data.info_text = tprint("Unable to open golden file %\n", golden_path);
|
||||
result_data.type = .Golden_File_Not_Found;
|
||||
return;
|
||||
}
|
||||
|
||||
comp := replace(comparison_text, "\r\n", "\n");
|
||||
gold := replace(golden_text, "\r\n", "\n");
|
||||
result := compare(comp, gold) == 0;
|
||||
if !result {
|
||||
result_data.type = .Failed;
|
||||
result_data.info_text = tprint("Golden file:\n%\n===============\n%", gold, comp);
|
||||
} else {
|
||||
result_data.type = .Passed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
run_parser_test :: (lexer : *Lexer, output_type : Output_Type = 0) -> Result, *AST_Node {
|
||||
parse_state : Parse_State;
|
||||
result_data : Result;
|
||||
result_data.path = lexer.path;
|
||||
result_data.stage = .Parser;
|
||||
init_parse_state(*parse_state, lexer.result.tokens, lexer.path, context.allocator);
|
||||
|
||||
result := parse(*parse_state);
|
||||
result_node : *AST_Node;
|
||||
result_text : string;
|
||||
|
||||
if result.had_error {
|
||||
result_data.type = .Failed;
|
||||
result_text = report_messages(result.messages,, temp);
|
||||
} else {
|
||||
result_text = pretty_print_ast(parse_state.result.root, *temp);
|
||||
result_node = parse_state.result.root;
|
||||
}
|
||||
|
||||
if output_type & .StdOut {
|
||||
result_data.info_text = result_text;
|
||||
result_data.type = .StdOut;
|
||||
return result_data, result_node;
|
||||
}
|
||||
|
||||
golden_path := get_golden_path(parse_state.path, .Parser);
|
||||
do_golden_comparison(golden_path, result_text, *result_data, output_type);
|
||||
return result_data, result_node;
|
||||
}
|
||||
|
||||
run_semantic_analysis_test :: (file_path : string, output_type : Output_Type = 0) -> Result, Semantic_Check_Result {
|
||||
lexer : Lexer;
|
||||
result_data : Result;
|
||||
result_data.path = file_path;
|
||||
|
||||
ok := read_input_from_file(*lexer, file_path);
|
||||
if !ok {
|
||||
log_error("Unable to read file: %\n", file_path);
|
||||
result_data.type = .File_Read_Failed;
|
||||
result_data.stage = .Lexer;
|
||||
|
||||
return result_data, .{};
|
||||
}
|
||||
|
||||
lex_result := lex(*lexer, *temp);
|
||||
if lex_result.had_error {
|
||||
result_data.type = .Failed;
|
||||
result_data.stage = .Lexer;
|
||||
result_data.info_text = report_messages(lex_result.messages);
|
||||
|
||||
if output_type & .StdOut {
|
||||
result_data.type = .StdOut;
|
||||
return result_data, .{};
|
||||
}
|
||||
golden_path := get_golden_path(file_path, .Semantic_Analysis);
|
||||
do_golden_comparison(golden_path, result_data.info_text, *result_data, output_type);
|
||||
return result_data, .{};
|
||||
}
|
||||
|
||||
parse_state : Parse_State;
|
||||
result_data.stage = .Parser;
|
||||
init_parse_state(*parse_state, lex_result.tokens, lexer.path, context.allocator);
|
||||
|
||||
parse_result := parse(*parse_state);
|
||||
if parse_result.had_error {
|
||||
result_data.type = .Failed;
|
||||
result_data.info_text = report_messages(parse_result.messages);
|
||||
|
||||
if output_type & .StdOut {
|
||||
result_data.type = .StdOut;
|
||||
return result_data, .{};
|
||||
}
|
||||
|
||||
golden_path := get_golden_path(file_path, .Semantic_Analysis);
|
||||
do_golden_comparison(golden_path, result_data.info_text, *result_data, output_type);
|
||||
return result_data, .{};
|
||||
}
|
||||
|
||||
result, check_result := run_semantic_analysis_test(file_path, parse_state.result.root, output_type);
|
||||
return result, check_result;
|
||||
}
|
||||
|
||||
run_semantic_analysis_test :: (file_path : string, root : *AST_Node, output_type : Output_Type = 0) -> Result, Semantic_Check_Result {
|
||||
result_data : Result;
|
||||
|
||||
result_data.path = file_path;
|
||||
result_data.stage = .Semantic_Analysis;
|
||||
checker : Semantic_Checker;
|
||||
init_semantic_checker(*checker, root, file_path);
|
||||
result_text : string;
|
||||
|
||||
result := check(*checker);
|
||||
if result.had_error {
|
||||
result_data.type = .Failed;
|
||||
result_text = report_messages(checker.result.messages);
|
||||
} else {
|
||||
result_text = pretty_print_symbol_table(*checker, temp);
|
||||
constraints := pretty_print_type_constraints(*checker, temp);
|
||||
type_vars := pretty_print_type_variables(*checker, temp);
|
||||
print("Constraints\n%\n", constraints);
|
||||
print("Solution\n%\n", type_vars);
|
||||
}
|
||||
|
||||
if output_type & .StdOut {
|
||||
result_data.info_text = result_text;
|
||||
result_data.type = .StdOut;
|
||||
return result_data, .{};
|
||||
}
|
||||
|
||||
golden_path := get_golden_path(checker.path, .Semantic_Analysis);
|
||||
do_golden_comparison(golden_path, result_text, *result_data, output_type);
|
||||
return result_data, result;
|
||||
}
|
||||
|
||||
run_codegen_test :: (path : string, root : *AST_Node, check_result : Semantic_Check_Result, output_type : Output_Type = 0) -> Result, Codegen_Result {
|
||||
|
||||
result_data : Result;
|
||||
result_data.path = path;
|
||||
result_data.stage = .Codegen;
|
||||
|
||||
state : Codegen_State;
|
||||
init_codegen_state(*state, root, check_result, .HLSL);
|
||||
|
||||
result_text : string;
|
||||
|
||||
result := codegen(*state);
|
||||
|
||||
if result.had_error {
|
||||
result_data.type = .Failed;
|
||||
result_data.info_text = report_messages(result.messages);
|
||||
return result_data, .{};
|
||||
}
|
||||
|
||||
result_text = result.result_text;
|
||||
|
||||
if output_type & .StdOut {
|
||||
result_data.info_text = result_text;
|
||||
result_data.type = .StdOut;
|
||||
return result_data, result;
|
||||
}
|
||||
|
||||
golden_path := get_golden_path(path, .Codegen);
|
||||
do_golden_comparison(golden_path, result_text, *result_data, output_type);
|
||||
return result_data, result;
|
||||
}
|
||||
|
||||
run_codegen_test :: (path : string, root : *AST_Node, output_type : Output_Type = 0) -> Result, Codegen_Result {
|
||||
checker : Semantic_Checker;
|
||||
init_semantic_checker(*checker, root, path);
|
||||
|
||||
result_data : Result;
|
||||
result_data.path = path;
|
||||
result_data.stage = .Semantic_Analysis;
|
||||
|
||||
check_result := check(*checker);
|
||||
if check_result.had_error {
|
||||
result_data.type = .Failed;
|
||||
result_data.info_text = report_messages(check_result.messages);
|
||||
return result_data, .{};
|
||||
}
|
||||
|
||||
result, codegen_result := run_codegen_test(path, root, check_result, output_type);
|
||||
return result, codegen_result;
|
||||
}
|
||||
|
||||
run_codegen_test :: (path : string, output_type : Output_Type = 0) -> Result, Codegen_Result {
|
||||
lexer : Lexer;
|
||||
result_data : Result;
|
||||
result_data.path = path;
|
||||
|
||||
ok := read_input_from_file(*lexer, path);
|
||||
if !ok {
|
||||
log_error("Unable to read file: %\n", path);
|
||||
result_data.type = .File_Read_Failed;
|
||||
result_data.stage = .Lexer;
|
||||
return result_data, .{};
|
||||
}
|
||||
|
||||
lex_result := lex(*lexer, *temp);
|
||||
if lex_result.had_error {
|
||||
result_data.type = .Failed;
|
||||
result_data.stage = .Lexer;
|
||||
return result_data, .{};
|
||||
}
|
||||
|
||||
parse_state : Parse_State;
|
||||
result_data.stage = .Parser;
|
||||
init_parse_state(*parse_state, lex_result.tokens, lexer.path, context.allocator);
|
||||
|
||||
parse_result := parse(*parse_state);
|
||||
if parse_result.had_error {
|
||||
result_data.type = .Failed;
|
||||
result_data.info_text = pretty_print_ast(parse_result.root, *temp);
|
||||
return result_data, .{};
|
||||
}
|
||||
|
||||
result, codegen_result := run_codegen_test(path, parse_result.root, output_type);
|
||||
return result, codegen_result;
|
||||
}
|
||||
|
||||
run_compile_test :: (path : string, output_type : Output_Type = 0) -> Result, Compilation_Result {
|
||||
compiler : Shader_Compiler;
|
||||
result : Result;
|
||||
compilation_result := compile_file(*compiler, path);
|
||||
if compilation_result.had_error {
|
||||
result.type = .Failed;
|
||||
result.info_text = tprint("Failed compiling: %\n", path);
|
||||
}
|
||||
|
||||
return result, compilation_result;
|
||||
}
|
||||
|
||||
make_test_case :: (path : string, stage_flags : Stage_Flags, allocator := context.allocator) -> Test_Case {
|
||||
test_case : Test_Case;
|
||||
test_case.path = copy_string(path,, allocator);
|
||||
replace_chars(test_case.path, "\\", #char "/");
|
||||
test_case.stage_flags = stage_flags;
|
||||
|
||||
return test_case;
|
||||
}
|
||||
|
||||
run_test :: (file_path : string, stage_flags : Stage_Flags, results : *[..]Result, output_type : Output_Type = 0) {
|
||||
lexer : Lexer;
|
||||
result : Result;
|
||||
if stage_flags & .Lexer {
|
||||
result = run_lexer_test(file_path, *lexer, output_type);
|
||||
record_result(results, result);
|
||||
}
|
||||
|
||||
root_node : *AST_Node;
|
||||
if stage_flags & .Parser {
|
||||
if stage_flags & .Lexer && result.type == .Passed || result.type == .Golden_Output {
|
||||
result, root_node = run_parser_test(*lexer, output_type);
|
||||
} else {
|
||||
result, root_node = run_parser_test(file_path, output_type);
|
||||
}
|
||||
record_result(results, result);
|
||||
}
|
||||
|
||||
check_result : Semantic_Check_Result;
|
||||
if stage_flags & .Semantic_Analysis {
|
||||
if stage_flags & .Parser && (result.type == .Passed || result.type == .Golden_Output) {
|
||||
result, check_result = run_semantic_analysis_test(file_path, root_node, output_type);
|
||||
} else {
|
||||
result, check_result = run_semantic_analysis_test(file_path, output_type);
|
||||
}
|
||||
record_result(results, result);
|
||||
}
|
||||
|
||||
if stage_flags & .Codegen {
|
||||
if stage_flags & .Semantic_Analysis && (result.type == .Passed || result.type == .Golden_Output) {
|
||||
result = run_codegen_test(file_path, root_node, check_result, output_type);
|
||||
} else if root_node {
|
||||
result = run_codegen_test(file_path, root_node, output_type);
|
||||
} else {
|
||||
result = run_codegen_test(file_path, output_type);
|
||||
}
|
||||
record_result(results, result);
|
||||
}
|
||||
|
||||
if stage_flags & .Compile {
|
||||
result = run_compile_test(file_path, output_type);
|
||||
}
|
||||
}
|
||||
|
||||
run_test :: (test_case : Test_Case, results : *[..]Result, output_type : Output_Type = 0) {
|
||||
print("%Running test: %\n", cyan(), test_case.path);
|
||||
run_test(test_case.path, test_case.stage_flags, results, output_type);
|
||||
}
|
||||
|
||||
record_result :: (results : *[..]Result, result : Result) {
|
||||
array_add(results, result);
|
||||
}
|
||||
|
||||
run_test_suite :: (using suite : *Test_Suite, output_type : Output_Type = 0) {
|
||||
if suite.name.count > 0 {
|
||||
print("%Running suite: %\n", green(), suite.name);
|
||||
print("%", reset_color());
|
||||
}
|
||||
|
||||
Fail_Data :: struct {
|
||||
path : string;
|
||||
stage : string;
|
||||
}
|
||||
|
||||
failed_test_paths : [..]Fail_Data;
|
||||
failed_test_paths.allocator = temp;
|
||||
|
||||
builder : String_Builder;
|
||||
init_string_builder(*builder,, temp);
|
||||
|
||||
for test_case : test_cases {
|
||||
run_test(test_case, *suite.results, output_type);
|
||||
|
||||
for < suite.results {
|
||||
result := suite.results[it_index];
|
||||
if compare(result.path, test_case.path) == 0 {
|
||||
if result.type == {
|
||||
case .Failed; {
|
||||
array_add(*failed_test_paths, .{ result.path, stage_to_string(result.stage) });
|
||||
}
|
||||
case .File_Read_Failed; {
|
||||
array_add(*failed_test_paths, .{ result.path, "file not found" });
|
||||
}
|
||||
case .Golden_File_Not_Found; {
|
||||
array_add(*failed_test_paths, .{ result.path, tprint("golden file not found for %", stage_to_string(result.stage)) });
|
||||
}
|
||||
}
|
||||
evaluate_result(result);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
print("\n");
|
||||
}
|
||||
print("\n");
|
||||
|
||||
if output_type == 0 {
|
||||
if failed_test_paths.count == 0 {
|
||||
green(*builder);
|
||||
print_to_builder(*builder, "All % tests passed!\n", test_cases.count);
|
||||
reset_color(*builder);
|
||||
} else {
|
||||
print_to_builder(*builder, "%/% tests passed\n", test_cases.count - failed_test_paths.count, test_cases.count);
|
||||
red(*builder);
|
||||
|
||||
print_to_builder(*builder, "% failed\n", failed_test_paths.count);
|
||||
for failed_test : failed_test_paths {
|
||||
print_to_builder(*builder, "% failed with error: %\n", failed_test.path, failed_test.stage);
|
||||
}
|
||||
reset_color(*builder);
|
||||
}
|
||||
}
|
||||
|
||||
print("%\n", builder_to_string(*builder));
|
||||
}
|
||||
|
||||
read_suite :: (file_path : string, suite : *Test_Suite) -> bool {
|
||||
bytes, ok := read_entire_file(file_path);
|
||||
if !ok {
|
||||
log_error("Unable to read suite file %\n", file_path);
|
||||
return false;
|
||||
}
|
||||
|
||||
path := parse_path(file_path);
|
||||
file_without_extension := split(path.words[path.words.count - 1], ".");
|
||||
suite.name = copy_string(file_without_extension[0]);
|
||||
split_lines := split(bytes, "\n");
|
||||
|
||||
for split_line : split_lines {
|
||||
line := split(split_line, " ");
|
||||
if line[0].count == 0 {
|
||||
continue;
|
||||
}
|
||||
|
||||
if line[0].data[0] == #char "#" {
|
||||
continue;
|
||||
}
|
||||
|
||||
if line.count == 1 {
|
||||
log_error("Invalid line - % - %\n", it_index + 1, line);
|
||||
continue;
|
||||
}
|
||||
test_case_path := line[0];
|
||||
stage_flags : Stage_Flags;
|
||||
|
||||
for i: 0..line.count - 1 {
|
||||
trimmed := trim(line[i]);
|
||||
if equal(trimmed, "lex") {
|
||||
stage_flags |= .Lexer;
|
||||
} else if equal(trimmed, "parse") {
|
||||
stage_flags |= .Parser;
|
||||
} else if equal(trimmed, "semant") {
|
||||
stage_flags |= .Semantic_Analysis;
|
||||
} else if equal(trimmed, "codegen") {
|
||||
stage_flags |= .Codegen;
|
||||
} else if equal(trimmed, "compile") {
|
||||
stage_flags |= .Compile;
|
||||
}
|
||||
}
|
||||
|
||||
test_case := make_test_case(test_case_path, stage_flags);
|
||||
array_add(*suite.test_cases, test_case);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
read_test :: () {
|
||||
|
||||
}
|
||||
|
||||
stage_to_string :: (stage : Stage_Flags) -> string {
|
||||
if #complete stage == {
|
||||
case .Lexer; return "lexing";
|
||||
case .Parser; return "parsing";
|
||||
case .Semantic_Analysis; return "semantic checking";
|
||||
case .Codegen; return "codegen";
|
||||
case .Compile; return "compiled";
|
||||
case; return "";
|
||||
}
|
||||
}
|
||||
|
||||
evaluate_result :: (result : Result) {
|
||||
stage : string = stage_to_string(result.stage);
|
||||
|
||||
if #complete result.type == {
|
||||
case .File_Read_Failed; {
|
||||
print("%", red());
|
||||
print("% failed with File_Read_Failed\n", result.path);
|
||||
}
|
||||
case .Golden_File_Not_Found; {
|
||||
print("%", red());
|
||||
print("% failed with Golden File Not Found for stage %\n", result.path, stage);
|
||||
}
|
||||
case .StdOut; {
|
||||
}
|
||||
case .Golden_Output; {
|
||||
print("%", yellow());
|
||||
print("% output new golden file at %\n", result.path, result.golden_path);
|
||||
}
|
||||
case .Passed; {
|
||||
print("%", green());
|
||||
print("% passed %\n", result.path, stage);
|
||||
}
|
||||
case .Failed; {
|
||||
print("%", red());
|
||||
print("% failed %\n", result.path, stage);
|
||||
}
|
||||
}
|
||||
|
||||
if result.info_text.count > 0 {
|
||||
print("%", cyan());
|
||||
print("--- Info text ---\n");
|
||||
print("%", yellow());
|
||||
print("%\n", result.info_text);
|
||||
}
|
||||
|
||||
print("%", reset_color());
|
||||
}
|
||||
|
||||
main :: () {
|
||||
lexer : Lexer;
|
||||
|
||||
args := get_command_line_arguments();
|
||||
|
||||
suites : [..]Test_Suite;
|
||||
output_type : Output_Type = 0;
|
||||
|
||||
Argument_Parse_State :: enum {
|
||||
None;
|
||||
Run_Suite;
|
||||
Run_Test;
|
||||
}
|
||||
|
||||
arg_parse_state : Argument_Parse_State;
|
||||
current_suite : *Test_Suite;
|
||||
|
||||
path : string;
|
||||
|
||||
for i: 1..args.count - 1 {
|
||||
arg := args[i];
|
||||
if arg == "-output-as-golden" {
|
||||
output_type |= .Golden;
|
||||
continue;
|
||||
} else if arg == "-output" {
|
||||
output_type |= .StdOut;
|
||||
continue;
|
||||
}
|
||||
|
||||
if arg_parse_state == {
|
||||
case .Run_Suite; {
|
||||
if arg == "-output-as-golden" {
|
||||
output_type |= .Golden;
|
||||
} else if arg == "-output" {
|
||||
output_type |= .StdOut;
|
||||
} else {
|
||||
print("%Unknown argument %\n", red(), arg);
|
||||
}
|
||||
}
|
||||
case .Run_Test; {
|
||||
cases := current_suite.test_cases.count;
|
||||
if arg == "-lex" {
|
||||
current_suite.test_cases[cases - 1].stage_flags |= .Lexer;
|
||||
} else if arg == "-parse" {
|
||||
current_suite.test_cases[cases - 1].stage_flags |= .Parser;
|
||||
} else if arg == "-semant" {
|
||||
current_suite.test_cases[cases - 1].stage_flags |= .Semantic_Analysis;
|
||||
} else if arg == "-codegen" {
|
||||
current_suite.test_cases[cases - 1].stage_flags |= .Codegen;
|
||||
} else if arg == "-compile" {
|
||||
current_suite.test_cases[cases - 1].stage_flags |= .Compile;
|
||||
} else if contains(arg, ".") {
|
||||
split_path := split(arg, ".");
|
||||
extension := split_path[1];
|
||||
if extension == SHADER_EXTENSION {
|
||||
path := copy_string(arg);
|
||||
test_case := make_test_case(path, 0);
|
||||
array_add(*current_suite.test_cases, test_case);
|
||||
}
|
||||
} else {
|
||||
print("%Unknown argument %\n", red, arg);
|
||||
}
|
||||
}
|
||||
case .None; {
|
||||
if contains(arg, ".") {
|
||||
split_path := split(arg, ".");
|
||||
extension := split_path[1];
|
||||
|
||||
if extension == SHADER_EXTENSION {
|
||||
if arg_parse_state == .Run_Suite {
|
||||
log_error("Unable to run a test while already running suite.");
|
||||
continue;
|
||||
}
|
||||
|
||||
if !current_suite {
|
||||
suite : Test_Suite;
|
||||
array_add(*suites, suite);
|
||||
current_suite = *suites[0];
|
||||
}
|
||||
|
||||
arg_parse_state = .Run_Test;
|
||||
path := copy_string(arg);
|
||||
test_case := make_test_case(path, 0);
|
||||
array_add(*current_suite.test_cases, test_case);
|
||||
} else if extension == SUITE_EXTENSION {
|
||||
if arg_parse_state == .Run_Test {
|
||||
log_error("Unable to run a suite while already running test.");
|
||||
continue;
|
||||
}
|
||||
|
||||
arg_parse_state = .Run_Suite;
|
||||
path := copy_string(arg);
|
||||
|
||||
suite : Test_Suite;
|
||||
read_suite(path, *suite);
|
||||
array_add(*suites, suite);
|
||||
current_suite = *suites[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for suite : suites {
|
||||
run_test_suite(*suite, output_type);
|
||||
}
|
||||
}
|
||||
@@ -74,8 +74,24 @@ int4x4 :: struct {
|
||||
|
||||
//~ nbr: Constructors
|
||||
#foreign float2 :: (float, float) -> float2;
|
||||
#foreign float2 :: (float2) -> float2;
|
||||
#foreign float2 :: (float) -> float2;
|
||||
|
||||
#foreign float3 :: (float, float, float) -> float3;
|
||||
#foreign float3 :: (float3) -> float3;
|
||||
#foreign float3 :: (float2, float) -> float3;
|
||||
#foreign float3 :: (float, float2) -> float3;
|
||||
#foreign float3 :: (float) -> float3;
|
||||
|
||||
#foreign float4 :: (float, float, float, float) -> float4;
|
||||
#foreign float4 :: (float4) -> float4;
|
||||
#foreign float4 :: (float2, float2) -> float4;
|
||||
#foreign float4 :: (float2, float, float) -> float4;
|
||||
#foreign float4 :: (float, float2, float) -> float4;
|
||||
#foreign float4 :: (float, float, float2) -> float4;
|
||||
#foreign float4 :: (float3, float) -> float4;
|
||||
#foreign float4 :: (float, float3) -> float4;
|
||||
#foreign float4 :: (float) -> float4;
|
||||
|
||||
//~ nbr: Vectors
|
||||
#foreign cross :: (float3, float3) -> float3;
|
||||
@@ -83,6 +99,10 @@ int4x4 :: struct {
|
||||
#foreign distance :: (float3, float3) -> float;
|
||||
#foreign distance :: (float4, float4) -> float;
|
||||
|
||||
#foreign length :: (float2) -> float;
|
||||
#foreign length :: (float3) -> float;
|
||||
#foreign length :: (float4) -> float;
|
||||
|
||||
#foreign dot :: (float2, float2) -> float;
|
||||
#foreign dot :: (float3, float3) -> float;
|
||||
#foreign dot :: (float4, float4) -> float;
|
||||
@@ -259,4 +279,11 @@ int4x4 :: struct {
|
||||
#foreign atan2 :: (float4, float4) -> float4;
|
||||
#foreign atan2 :: (float4x4, float4x4) -> float4x4;
|
||||
|
||||
#foreign sample :: (Texture2D, float2, Sampler) -> float4;
|
||||
#foreign sample :: (Texture2D, Sampler, float2) -> float4;
|
||||
|
||||
#foreign lerp :: (float, float, float) -> float;
|
||||
#foreign lerp :: (float2, float2, float) -> float2;
|
||||
#foreign lerp :: (float3, float3, float) -> float3;
|
||||
#foreign lerp :: (float4, float4, float) -> float4;
|
||||
|
||||
#foreign fmod :: (float, float) -> float;
|
||||
81
first.jai
81
first.jai
@@ -1,21 +1,65 @@
|
||||
#import "Basic";
|
||||
#import "File";
|
||||
#import "Compiler";
|
||||
#import "Metaprogram_Plugins";
|
||||
|
||||
plugins: [..] *Metaprogram_Plugin;
|
||||
|
||||
build :: () {
|
||||
w := compiler_create_workspace("Shader Compiler Test Build");
|
||||
w := compiler_create_workspace("Ink Build");
|
||||
if !w {
|
||||
print("Workspace creation failed.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
EXECUTABLE_NAME :: "test";
|
||||
MAIN_FILE :: "Test.jai";
|
||||
EXECUTABLE_NAME :: "ink";
|
||||
MAIN_FILE :: "Ink.jai";
|
||||
|
||||
options := get_build_options(w);
|
||||
|
||||
options.write_added_strings = true;
|
||||
|
||||
args := options.compile_time_command_line;
|
||||
|
||||
intercept_flags: Intercept_Flags;
|
||||
plugin_start_index := -1;
|
||||
|
||||
for arg : args {
|
||||
if arg == {
|
||||
case "check"; {
|
||||
options.output_type = .NO_OUTPUT;
|
||||
}
|
||||
}
|
||||
|
||||
it := args[it_index];
|
||||
|
||||
if !it continue;
|
||||
|
||||
if it[0] == #char "+" {
|
||||
plugin_start_index = it_index;
|
||||
}
|
||||
}
|
||||
|
||||
plugins_to_create: [..] Plugin_To_Create;
|
||||
tracy : Plugin_To_Create;
|
||||
tracy.name = "tracy";
|
||||
array_add(*plugins_to_create, tracy);
|
||||
// got_error := false;
|
||||
// if plugin_start_index >= 0 {
|
||||
// success:, plugins_to_create = parse_plugin_arguments(args, plugin_start_index);
|
||||
// if !success got_error = true;
|
||||
// }
|
||||
|
||||
// if got_error {
|
||||
// exit(1);
|
||||
// }
|
||||
|
||||
success := init_plugins(plugins_to_create, *plugins, w);
|
||||
if !success {
|
||||
log_error("A plugin init() failed. Exiting.\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
new_path: [..] string;
|
||||
array_add(*new_path, ..options.import_path);
|
||||
array_add(*new_path, "modules");
|
||||
@@ -25,18 +69,41 @@ build :: () {
|
||||
|
||||
wd := get_working_directory();
|
||||
|
||||
|
||||
set_build_options(options, w);
|
||||
|
||||
compiler_begin_intercept(w);
|
||||
for plugins {
|
||||
if it.before_intercept it.before_intercept(it, *intercept_flags);
|
||||
}
|
||||
|
||||
compiler_begin_intercept(w, intercept_flags);
|
||||
|
||||
for plugins if it.add_source it.add_source(it);
|
||||
|
||||
add_build_file(MAIN_FILE, w);
|
||||
|
||||
// Call message_loop(), which is a routine of ours below that will receive the messages.
|
||||
message_loop(w);
|
||||
|
||||
compiler_end_intercept(w);
|
||||
|
||||
for plugins if it.finish it.finish (it);
|
||||
for plugins if it.shutdown it.shutdown(it);
|
||||
|
||||
print("\nDone!\n\n");
|
||||
|
||||
set_build_options_dc(.{do_output=false});
|
||||
set_build_options_dc(.{do_output=false, write_added_strings=false});
|
||||
}
|
||||
|
||||
#run build();
|
||||
message_loop :: (w: Workspace) {
|
||||
while true {
|
||||
// We ask the compiler for the next message. If one is not available,
|
||||
// we will wait until it becomes available.
|
||||
message := compiler_wait_for_message();
|
||||
// Pass the message to all plugins.
|
||||
for plugins if it.message it.message(it, message);
|
||||
|
||||
if message.kind == .COMPLETE break;
|
||||
}
|
||||
}
|
||||
|
||||
#run, stallable build();
|
||||
|
||||
304
module.jai
304
module.jai
@@ -4,6 +4,7 @@
|
||||
#load "Semantic_Analysis.jai";
|
||||
#load "Codegen.jai";
|
||||
|
||||
#import "File_Utilities";
|
||||
|
||||
add_define :: (env : *Environment, key : string) {
|
||||
for define : env.defines {
|
||||
@@ -27,10 +28,6 @@ Environment :: struct {
|
||||
defines : [..]string;
|
||||
}
|
||||
|
||||
Shader_Compiler :: struct {
|
||||
environment : Environment;
|
||||
}
|
||||
|
||||
Field_Kind :: enum {
|
||||
Int :: 0;
|
||||
Half :: 1;
|
||||
@@ -56,6 +53,7 @@ Hint_Kind :: enum {
|
||||
None;
|
||||
|
||||
Position;
|
||||
UV;
|
||||
Target;
|
||||
|
||||
Custom;
|
||||
@@ -119,6 +117,9 @@ Constant_Buffer :: struct {
|
||||
|
||||
fields : Static_Array(Property_Field, 16);
|
||||
|
||||
// hints : Field_Hint; // optional hint...
|
||||
hints : [..]Field_Hint;
|
||||
|
||||
buffer_index : u32;
|
||||
}
|
||||
|
||||
@@ -136,69 +137,103 @@ Input_File :: struct {
|
||||
path : string;
|
||||
}
|
||||
|
||||
Token_Stream :: struct {
|
||||
tokens : [..]Token;
|
||||
}
|
||||
|
||||
Compiled_File :: struct {
|
||||
Compiler_Context :: struct {
|
||||
file : Input_File;
|
||||
tokens : Token_Stream;
|
||||
ast_root : *AST_Node;
|
||||
ast_nodes : [..]AST_Node;
|
||||
}
|
||||
|
||||
Compile_Result :: struct {
|
||||
files : [..]Compiled_File;
|
||||
environment : Environment;
|
||||
|
||||
tokens : [..]Token;;
|
||||
root : *AST_Node;
|
||||
nodes : [..]AST_Node;
|
||||
|
||||
codegen_result_text : string;
|
||||
|
||||
constant_buffers : Static_Array(Type_Variable_Handle, 16);
|
||||
|
||||
scope_stack : Scope_Stack;
|
||||
type_variables : [..]Type_Variable;
|
||||
|
||||
property_name : string;
|
||||
|
||||
vertex_entry_point : struct {
|
||||
node : *AST_Node;
|
||||
name : string;
|
||||
input : [..]Field;
|
||||
}
|
||||
|
||||
pixel_entry_point : struct {
|
||||
node : *AST_Node;
|
||||
name : string;
|
||||
return_value : Field;
|
||||
}
|
||||
|
||||
properties : Properties;
|
||||
|
||||
max_constant_buffers :: 16;
|
||||
|
||||
cbuffers : Static_Array(Constant_Buffer, max_constant_buffers);
|
||||
|
||||
had_error : bool;
|
||||
messages : [..]Compiler_Message;
|
||||
|
||||
allocator : Allocator;
|
||||
arena : Arena;
|
||||
}
|
||||
|
||||
//@Incomplete(niels): need to consider allocation
|
||||
add_file :: (result : *Compile_Result, path : string) {
|
||||
#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;
|
||||
error.message = sprint(format, args);
|
||||
|
||||
array_add(*result.messages, error);
|
||||
}
|
||||
|
||||
make_file :: (result : *Compiler_Context, path : string) -> Input_File {
|
||||
if !file_exists(path) {
|
||||
record_error(result, "Unable to load file: %", path);
|
||||
return .{};
|
||||
}
|
||||
file_string, ok := read_entire_file(path);
|
||||
|
||||
if !ok {
|
||||
// record_error(.File_Load_Failed, "Unable to load file: %", path);
|
||||
return;
|
||||
record_error(result, "Unable to load file: %", path);
|
||||
return .{};
|
||||
}
|
||||
|
||||
return make_file_from_string(file_string, path);
|
||||
}
|
||||
|
||||
make_file_from_string :: (source : string, path : string = "") -> Input_File {
|
||||
input_file : Input_File;
|
||||
|
||||
input_file.source = file_string;
|
||||
input_file.source = source;
|
||||
input_file.path = path;
|
||||
|
||||
compiled_file : Compiled_File;
|
||||
compiled_file.file = input_file;
|
||||
|
||||
array_add(*result.files, compiled_file);
|
||||
}
|
||||
|
||||
// @Incomplete(nb): Will we ever even use this?
|
||||
from_file :: (path : string) -> Compile_Result {
|
||||
arr : [1]string;
|
||||
arr[0] = path;
|
||||
return from_files(arr);
|
||||
}
|
||||
|
||||
from_files :: (paths : []string) -> Compile_Result {
|
||||
result : Compile_Result;
|
||||
for path : paths {
|
||||
add_file(*result, path);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Compilation_Result :: struct {
|
||||
messages : [..]Compiler_Message;
|
||||
|
||||
had_error : bool;
|
||||
|
||||
collection : Shader_Variant_Collection;
|
||||
return input_file;
|
||||
}
|
||||
|
||||
pretty_print_field :: (field : *Field) -> string {
|
||||
@@ -278,10 +313,10 @@ pretty_print_field :: (builder : *String_Builder, field : *Field) {
|
||||
}
|
||||
|
||||
type_variable_to_field :: (checker : *Semantic_Checker, variable : Type_Variable_Handle) -> Field {
|
||||
return type_variable_to_field(checker, h2tv(checker, variable));
|
||||
return type_variable_to_field(checker, from_handle(checker, variable));
|
||||
}
|
||||
|
||||
type_variable_to_field :: (checker : *Semantic_Checker, variable : *Type_Variable) -> Field {
|
||||
type_variable_to_field :: (type_variables : []Type_Variable, scope_stack : Scope_Stack, variable : *Type_Variable) -> Field {
|
||||
field : Field;
|
||||
|
||||
field.name = variable.name;
|
||||
@@ -314,14 +349,14 @@ type_variable_to_field :: (checker : *Semantic_Checker, variable : *Type_Variabl
|
||||
case .Struct; {
|
||||
type.kind = Field_Kind.Struct;
|
||||
|
||||
find_result := find_symbol(checker, variable.typename, xx 1);
|
||||
find_result := find_symbol(scope_stack, variable.typename, xx 1);
|
||||
assert(find_result != null, "Internal compiler error\n");
|
||||
|
||||
type_var := h2tv(checker, find_result.type_variable);
|
||||
type_var := from_handle(type_variables, find_result.type_variable);
|
||||
|
||||
for i : 0..type_var.child_count - 1 {
|
||||
for i : 0..type_var.children.count - 1 {
|
||||
child := type_var.children[i];
|
||||
child_field := type_variable_to_field(checker, h2tv(checker, child));
|
||||
child_field := type_variable_to_field(type_variables, scope_stack, child);
|
||||
array_add(*type.children, child_field);
|
||||
}
|
||||
|
||||
@@ -335,6 +370,8 @@ type_variable_to_field :: (checker : *Semantic_Checker, variable : *Type_Variabl
|
||||
if hint.ident_value == "position" {
|
||||
// @Incomplete(nb): Should be a lookup table somewhere
|
||||
field_hint.kind = .Position;
|
||||
} else if hint.ident_value == "uv" {
|
||||
field_hint.kind = .UV;
|
||||
} else if starts_with(hint.ident_value, "target") {
|
||||
// @Incomplete(nb): Should be a lookup table somewhere
|
||||
index_str : string;
|
||||
@@ -347,7 +384,8 @@ type_variable_to_field :: (checker : *Semantic_Checker, variable : *Type_Variabl
|
||||
}
|
||||
field_hint.kind = .Target;
|
||||
} else {
|
||||
// @Incomplete(nb): custo hints
|
||||
field_hint.custom_hint_name = hint.ident_value;
|
||||
field_hint.kind = .Custom;
|
||||
}
|
||||
array_add(*field.hints, field_hint);
|
||||
}
|
||||
@@ -357,82 +395,23 @@ type_variable_to_field :: (checker : *Semantic_Checker, variable : *Type_Variabl
|
||||
return field;
|
||||
}
|
||||
|
||||
compile_file :: (compiler : *Shader_Compiler, paths : []string) -> Compile_Result {
|
||||
result : Compile_Result;
|
||||
|
||||
for path : paths {
|
||||
add_file(*result, path);
|
||||
}
|
||||
|
||||
lex(*result);
|
||||
// parse(*result);
|
||||
// check(*result);
|
||||
// codegen(*result);
|
||||
|
||||
return result;
|
||||
type_variable_to_field :: (type_variables : []Type_Variable, scope_stack : Scope_Stack, variable : Type_Variable_Handle) -> Field {
|
||||
return type_variable_to_field(type_variables, scope_stack, from_handle(type_variables, variable));
|
||||
}
|
||||
|
||||
compile_file :: (compiler : *Shader_Compiler, path : string) -> Compilation_Result {
|
||||
result : Compilation_Result;
|
||||
type_variable_to_field :: (checker : *Semantic_Checker, variable : *Type_Variable) -> Field {
|
||||
return type_variable_to_field(checker.ctx.type_variables, checker.ctx.scope_stack, variable);
|
||||
}
|
||||
|
||||
lexer : Lexer;
|
||||
|
||||
init_lexer_from_file(*lexer, path);
|
||||
if lexer.result.had_error {
|
||||
copy_messages(lexer.result.messages, *result.messages);
|
||||
result.had_error = true;
|
||||
return result;
|
||||
generate_output_data :: (ctx : *Compiler_Context) {
|
||||
if ctx.had_error {
|
||||
return;
|
||||
}
|
||||
|
||||
lex_result := lex(*lexer,, *temp);
|
||||
if lex_result.had_error {
|
||||
copy_messages(lex_result.messages, *result.messages);
|
||||
result.had_error = true;
|
||||
return result;
|
||||
}
|
||||
if ctx.vertex_entry_point.node {
|
||||
ctx.vertex_entry_point.name = ctx.vertex_entry_point.node.name;
|
||||
|
||||
parse_state : Parse_State;
|
||||
init_parse_state(*parse_state, lex_result.tokens, lexer.path, context.allocator);
|
||||
|
||||
parse_result := parse(*parse_state);
|
||||
if parse_result.had_error {
|
||||
copy_messages(parse_result.messages, *result.messages);
|
||||
result.had_error = true;
|
||||
return result;
|
||||
}
|
||||
|
||||
checker : Semantic_Checker;
|
||||
init_semantic_checker(*checker, parse_result.root, path);
|
||||
|
||||
check_result := check(*checker);
|
||||
if check_result.had_error {
|
||||
copy_messages(check_result.messages, *result.messages);
|
||||
result.had_error = true;
|
||||
return result;
|
||||
}
|
||||
|
||||
state : Codegen_State;
|
||||
init_codegen_state(*state, parse_result.root, check_result, .HLSL);
|
||||
|
||||
result_text : string;
|
||||
|
||||
codegen_result := codegen(*state);
|
||||
if codegen_result.had_error {
|
||||
copy_messages(codegen_result.messages, *result.messages);
|
||||
result.had_error = true;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// @Incomplete(nb): Assumes only a single variant for now
|
||||
|
||||
variant : Shader_Variant;
|
||||
variant.text = codegen_result.result_text;
|
||||
|
||||
if checker.result.vertex_entry_point {
|
||||
variant.vertex_entry_point.name = checker.result.vertex_entry_point.name;
|
||||
|
||||
type_variable := h2tv(*checker, checker.result.vertex_entry_point.type_variable);
|
||||
type_variable := from_handle(ctx.type_variables, ctx.vertex_entry_point.node.type_variable);
|
||||
assert(type_variable.type == .Function);
|
||||
|
||||
node := type_variable.source_node;
|
||||
@@ -440,50 +419,58 @@ compile_file :: (compiler : *Shader_Compiler, path : string) -> Compilation_Resu
|
||||
if node.children[0].kind == .FieldList {
|
||||
field_list := node.children[0];
|
||||
for child : field_list.children {
|
||||
tv := h2tv(*checker, child.type_variable);
|
||||
field := type_variable_to_field(*checker, tv);
|
||||
array_add(*variant.vertex_entry_point.input, field);
|
||||
tv := from_handle(ctx.type_variables, child.type_variable);
|
||||
field := type_variable_to_field(ctx.type_variables, ctx.scope_stack, tv);
|
||||
array_add(*ctx.vertex_entry_point.input, field);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for buffer_variable : to_array(*check_result.constant_buffers) {
|
||||
variable := h2tv(check_result.type_variables, buffer_variable);
|
||||
for buffer_variable : ctx.constant_buffers {
|
||||
variable := from_handle(ctx.type_variables, buffer_variable);
|
||||
|
||||
cb := array_add(*result.collection.cbuffers);
|
||||
cb := array_add(*ctx.cbuffers);
|
||||
|
||||
for i : 0..variable.child_count - 1 {
|
||||
for i : 0..variable.children.count - 1 {
|
||||
child := variable.children[i];
|
||||
field : Property_Field;
|
||||
field.base_field = type_variable_to_field(*checker, h2tv(*checker, child));;
|
||||
field.base_field = type_variable_to_field(ctx.type_variables, ctx.scope_stack, from_handle(ctx.type_variables, child));
|
||||
array_add(*cb.fields, field);
|
||||
}
|
||||
|
||||
cb.buffer_index = variable.resource_index;
|
||||
|
||||
for hint : variable.source_node.hint_tokens {
|
||||
field_hint : Field_Hint;
|
||||
field_hint.custom_hint_name = hint.ident_value;
|
||||
field_hint.kind = .Custom;
|
||||
array_add(*cb.hints, field_hint);
|
||||
}
|
||||
}
|
||||
|
||||
find_result := find_symbol(*check_result.scope_stack, check_result.property_name, xx 1);
|
||||
find_result := find_symbol(*ctx.scope_stack, ctx.property_name, xx 1);
|
||||
if find_result {
|
||||
property_variable := h2tv(check_result.type_variables, find_result.type_variable);
|
||||
property_variable := from_handle(ctx.type_variables, find_result.type_variable);
|
||||
|
||||
for i : 0..property_variable.child_count - 1 {
|
||||
for i : 0..property_variable.children.count - 1 {
|
||||
child := property_variable.children[i];
|
||||
field := type_variable_to_field(*checker, h2tv(*checker, child));
|
||||
field := type_variable_to_field(ctx.type_variables, ctx.scope_stack, from_handle(ctx.type_variables, child));
|
||||
prop_field : Property_Field;
|
||||
prop_field.base_field = field;
|
||||
array_add(*result.collection.properties.fields, prop_field);
|
||||
array_add(*ctx.properties.fields, prop_field);
|
||||
}
|
||||
result.collection.properties.buffer_index = property_variable.resource_index;
|
||||
ctx.properties.buffer_index = property_variable.resource_index;
|
||||
}
|
||||
|
||||
if checker.result.pixel_entry_point {
|
||||
variant.pixel_entry_point.name = checker.result.pixel_entry_point.name;
|
||||
|
||||
type_variable := h2tv(*checker, checker.result.pixel_entry_point.type_variable);
|
||||
if ctx.pixel_entry_point.node {
|
||||
ctx.pixel_entry_point.name = ctx.pixel_entry_point.node.name;
|
||||
|
||||
type_variable := from_handle(ctx.type_variables, ctx.pixel_entry_point.node.type_variable);
|
||||
assert(type_variable.type == .Function);
|
||||
|
||||
field := type_variable_to_field(*checker, type_variable.return_type_variable);
|
||||
field := type_variable_to_field(ctx.type_variables, ctx.scope_stack, type_variable.return_type_variable);
|
||||
for hint : type_variable.source_node.hint_tokens {
|
||||
field_hint : Field_Hint;
|
||||
|
||||
@@ -502,15 +489,28 @@ compile_file :: (compiler : *Shader_Compiler, path : string) -> Compilation_Resu
|
||||
}
|
||||
field_hint.kind = .Target;
|
||||
} else {
|
||||
// @Incomplete(nb): custo hints
|
||||
// @Incomplete(nb): custom hints
|
||||
}
|
||||
array_add(*field.hints, field_hint);
|
||||
}
|
||||
|
||||
variant.pixel_entry_point.return_value = field;
|
||||
ctx.pixel_entry_point.return_value = field;
|
||||
}
|
||||
}
|
||||
|
||||
compile_file :: (ctx : *Compiler_Context, path : string, allocator : Allocator = temp) {
|
||||
new_context := context;
|
||||
new_context.allocator = allocator;
|
||||
push_context new_context {
|
||||
init_context_allocators();
|
||||
defer clear_context_allocators();
|
||||
|
||||
ctx.file = make_file(ctx, path);
|
||||
|
||||
lex(ctx, allocator);
|
||||
parse(ctx, allocator);
|
||||
check(ctx, allocator);
|
||||
codegen(ctx, allocator);
|
||||
generate_output_data(ctx);
|
||||
}
|
||||
|
||||
array_add(*result.collection.variants, variant);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Submodule modules/ncore updated: 9db7ff0940...788980c88f
1
modules/tracy
Submodule
1
modules/tracy
Submodule
Submodule modules/tracy added at 9668d7b8ab
BIN
output.tracy
Normal file
BIN
output.tracy
Normal file
Binary file not shown.
@@ -1,12 +1,12 @@
|
||||
test/assign_arithmetic_expression.shd lex parse
|
||||
test/empty_vertex_main.shd lex parse
|
||||
test/empty_vertex_main_with_position_parameter.shd lex parse
|
||||
test/meta_block.shd lex parse
|
||||
test/basic_property_and_return_value.shd lex parse
|
||||
test/function_call_return.shd lex parse
|
||||
test/struct_field_access_test.shd lex parse
|
||||
test/pass_and_access_struct_fields_in_functions.shd lex parse
|
||||
test/field_without_type_specifier.shd lex parse
|
||||
test/functions_with_same_name.shd lex parse
|
||||
test/function_with_int_return.shd lex parse
|
||||
test/type_as_variable_name.shd lex parse
|
||||
test/assign_arithmetic_expression.inx lex parse
|
||||
test/empty_vertex_main.inx lex parse
|
||||
test/empty_vertex_main_with_position_parameter.inx lex parse
|
||||
test/meta_block.inx lex parse
|
||||
test/basic_property_and_return_value.inx lex parse
|
||||
test/function_call_return.inx lex parse
|
||||
test/struct_field_access_test.inx lex parse
|
||||
test/pass_and_access_struct_fields_in_functions.inx lex parse
|
||||
test/field_without_type_specifier.inx lex parse
|
||||
test/functions_with_same_name.inx lex parse
|
||||
test/function_with_int_return.inx lex parse
|
||||
test/type_as_variable_name.inx lex parse
|
||||
8
test/binary_with_access.ink
Normal file
8
test/binary_with_access.ink
Normal file
@@ -0,0 +1,8 @@
|
||||
props :: properties {
|
||||
resolution : float2;
|
||||
}
|
||||
|
||||
vertex main :: (pos : float3 @position) -> float4 @position {
|
||||
p := float2(1.0 - 2.0 * props.resolution.x, 1.0 - 2.0 * props.resolution.y);
|
||||
return float4(p, 1.0, 1.0);
|
||||
}
|
||||
34
test/builtin_types.ink
Normal file
34
test/builtin_types.ink
Normal file
@@ -0,0 +1,34 @@
|
||||
vertex main :: () {
|
||||
v2 : float2 = float2(2.0, 2.0);
|
||||
v2 = float2(2.0);
|
||||
v2 = float2(v2);
|
||||
|
||||
v3 : float3 = float3(2.0, 2.0, 2.0);
|
||||
v3 = float3(v2, 1.0);
|
||||
v3 = float3(1.0, v2);
|
||||
v3 = float3(1.0);
|
||||
v3 = float3(v3);
|
||||
|
||||
v4 : float4 = float4(2.0, 2.0, 2.0, 2.0);
|
||||
v4 = float4(v4);
|
||||
v4 = float4(v2, v2);
|
||||
v4 = float4(v2, 1.0, 1.0);
|
||||
v4 = float4(1.0, v2, 1.0);
|
||||
v4 = float4(1.0, 1.0, v2);
|
||||
v4 = float4(v3, 2.0);
|
||||
v4 = float4(2.0, v3);
|
||||
v4 = float4(2.0);
|
||||
|
||||
|
||||
v4 = float4(1.0, 1.0, v2);
|
||||
v4 = float4(2.0);
|
||||
|
||||
v2.x = 2.0;
|
||||
v2.y = 2.0;
|
||||
|
||||
p := v2.x + v3.z;
|
||||
q := v4.w + v2.x;
|
||||
|
||||
m : float4x4;
|
||||
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
void vs_main()
|
||||
{
|
||||
float x = 2.0f + 5.0f;
|
||||
float x = (2.0f + 5.0f);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
cbuffer __PROPERTIES : register(b0)
|
||||
{
|
||||
float4 color;
|
||||
float4 __PROPERTIES__color;
|
||||
}
|
||||
|
||||
|
||||
float3 vs_main(float3 pos : POSITION) : SV_POSITION
|
||||
{
|
||||
return pos;
|
||||
@@ -10,6 +11,6 @@ float3 vs_main(float3 pos : POSITION) : SV_POSITION
|
||||
|
||||
float4 ps_main() : SV_TARGET
|
||||
{
|
||||
return color;
|
||||
return __PROPERTIES__color;
|
||||
}
|
||||
|
||||
|
||||
28
test/codegen/builtin_types.golden
Normal file
28
test/codegen/builtin_types.golden
Normal file
@@ -0,0 +1,28 @@
|
||||
void vs_main()
|
||||
{
|
||||
float2 v2 = float2(2.0f, 2.0f);
|
||||
v2 = float2(2.0f, 2.0f);
|
||||
v2 = float2(v2, v2);
|
||||
float3 v3 = float3(2.0f, 2.0f, 2.0f);
|
||||
v3 = float3(v2, 1.0f);
|
||||
v3 = float3(1.0f, v2);
|
||||
v3 = float3(1.0f, 1.0f, 1.0f);
|
||||
v3 = float3(v3, v3, v3);
|
||||
float4 v4 = float4(2.0f, 2.0f, 2.0f, 2.0f);
|
||||
v4 = float4(v4, v4, v4, v4);
|
||||
v4 = float4(v2, v2);
|
||||
v4 = float4(v2, 1.0f, 1.0f);
|
||||
v4 = float4(1.0f, v2, 1.0f);
|
||||
v4 = float4(1.0f, 1.0f, v2);
|
||||
v4 = float4(v3, 2.0f);
|
||||
v4 = float4(2.0f, v3);
|
||||
v4 = float4(2.0f, 2.0f, 2.0f, 2.0f);
|
||||
v4 = float4(1.0f, 1.0f, v2);
|
||||
v4 = float4(2.0f, 2.0f, 2.0f, 2.0f);
|
||||
v2.x = 2.0f;
|
||||
v2.y = 2.0f;
|
||||
float p = (v2.x + v3.z);
|
||||
float q = (v4.w + v2.x);
|
||||
float4x4 m;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,6 @@ void vs_main()
|
||||
{
|
||||
float x = 5.0f;
|
||||
float y = 3000.0f;
|
||||
float z = y * y + x;
|
||||
float z = ((y * y) + x);
|
||||
}
|
||||
|
||||
|
||||
18
test/codegen/constant_buffer.golden
Normal file
18
test/codegen/constant_buffer.golden
Normal file
@@ -0,0 +1,18 @@
|
||||
cbuffer camera : register(b0)
|
||||
{
|
||||
float4x4 projection;
|
||||
float4x4 view;
|
||||
}
|
||||
|
||||
float4 vs_main(float4 pos : POSITION) : SV_POSITION
|
||||
{
|
||||
float4 mv = mul(camera.view, pos);
|
||||
float4 mvp = mul(camera.projection, mv);
|
||||
return mvp;
|
||||
}
|
||||
|
||||
float4 ps_main() : SV_TARGET
|
||||
{
|
||||
return float4(0.5f, 0.5f, 0.5f, 1.0f);
|
||||
}
|
||||
|
||||
17
test/codegen/custom_hint.golden
Normal file
17
test/codegen/custom_hint.golden
Normal file
@@ -0,0 +1,17 @@
|
||||
cbuffer __PROPERTIES : register(b0)
|
||||
{
|
||||
float __PROPERTIES__time;
|
||||
}
|
||||
|
||||
|
||||
float4 vs_main(float3 pos : POSITION) : SV_POSITION
|
||||
{
|
||||
return float4(pos.x, pos.y, pos.z, 1.0f);
|
||||
}
|
||||
|
||||
float4 ps_main(float4 pos : SV_POSITION) : SV_TARGET
|
||||
{
|
||||
float t = __PROPERTIES__time;
|
||||
return float4(1, 1, 1, 1);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,2 @@
|
||||
struct Foo;
|
||||
|
||||
struct Foo {}
|
||||
struct Foo {};
|
||||
|
||||
|
||||
24
test/codegen/inferred_types.golden
Normal file
24
test/codegen/inferred_types.golden
Normal file
@@ -0,0 +1,24 @@
|
||||
float bar();
|
||||
float foo();
|
||||
|
||||
float bar()
|
||||
{
|
||||
return 5.0f;
|
||||
}
|
||||
|
||||
float foo()
|
||||
{
|
||||
return bar();
|
||||
}
|
||||
|
||||
float4 vs_main(float3 pos : POSITION) : SV_POSITION
|
||||
{
|
||||
float f = 2.0f;
|
||||
int i = 10;
|
||||
f = foo();
|
||||
float2 v2 = float2(2, 2);
|
||||
float3 v3 = float3(2, 2, 3);
|
||||
float4 v4 = float4(4, 5, 6, 7);
|
||||
return float4(1, 1, 1, 1);
|
||||
}
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
cbuffer __PROPERTIES : register(b0)
|
||||
{
|
||||
float4 color;
|
||||
float4 __PROPERTIES__color;
|
||||
}
|
||||
|
||||
float3 vs_main(float3 pos : POSITION, float2 uv) : SV_POSITION
|
||||
|
||||
float3 vs_main(float3 pos : POSITION, float2 uv : TEXCOORD0) : SV_POSITION
|
||||
{
|
||||
return pos;
|
||||
}
|
||||
|
||||
float4 ps_main() : SV_TARGET
|
||||
{
|
||||
return color;
|
||||
return __PROPERTIES__color;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ int foo()
|
||||
|
||||
float bar()
|
||||
{
|
||||
return 1235.0f * 500;
|
||||
return (1235.0f * 500);
|
||||
}
|
||||
|
||||
void vs_main()
|
||||
|
||||
18
test/codegen/nested_if.golden
Normal file
18
test/codegen/nested_if.golden
Normal file
@@ -0,0 +1,18 @@
|
||||
float4 vs_main(float3 pos : POSITION) : SV_POSITION
|
||||
{
|
||||
if (pos.x > 100)
|
||||
{
|
||||
if (pos.x > 50)
|
||||
{
|
||||
return float4(pos, 1.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
return float4(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
}
|
||||
return float4(pos, 1.0f);
|
||||
}
|
||||
|
||||
return float4(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
|
||||
93
test/codegen/night_time.golden
Normal file
93
test/codegen/night_time.golden
Normal file
@@ -0,0 +1,93 @@
|
||||
float4 apply_night(float4 color);
|
||||
float4 apply_twilight(float4 color);
|
||||
float4 apply_morning(float4 color);
|
||||
float4 apply_dawn(float4 color);
|
||||
|
||||
cbuffer __PROPERTIES : register(b0)
|
||||
{
|
||||
float __PROPERTIES__hour_of_day;
|
||||
}
|
||||
|
||||
Texture2D __PROPERTIES__input_tex : register(t0);
|
||||
SamplerState __PROPERTIES__tex_sampler : register(s0);
|
||||
|
||||
struct VS_Input
|
||||
{
|
||||
float3 pos : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct VS_Output
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
VS_Output vs_main(VS_Input input)
|
||||
{
|
||||
VS_Output output;
|
||||
output.pos = float4(input.pos, 1.0f);
|
||||
output.uv = input.uv;
|
||||
return output;
|
||||
}
|
||||
|
||||
float4 apply_night(float4 color)
|
||||
{
|
||||
float4 result = color;
|
||||
(result -= float4(0.3f, 0.2f, 0.0f, 0.0f));
|
||||
(result *= 0.8f);
|
||||
return result;
|
||||
}
|
||||
|
||||
float4 apply_twilight(float4 color)
|
||||
{
|
||||
float4 result = color;
|
||||
(result += float4(0.2f, -0.1f, 0.1f, 0.0f));
|
||||
(result *= 0.9f);
|
||||
return result;
|
||||
}
|
||||
|
||||
float4 apply_morning(float4 color)
|
||||
{
|
||||
return (color * 1.3f);
|
||||
}
|
||||
|
||||
float4 apply_dawn(float4 color)
|
||||
{
|
||||
return color;
|
||||
}
|
||||
|
||||
float4 ps_main(VS_Output input)
|
||||
{
|
||||
float4 sampled_color = __PROPERTIES__input_tex.Sample(__PROPERTIES__tex_sampler, input.uv);
|
||||
float t = 0.0f;
|
||||
float4 a = float4(0, 0, 0, 0);
|
||||
float4 b = float4(0, 0, 0, 0);
|
||||
if (__PROPERTIES__hour_of_day > 16)
|
||||
{
|
||||
t = ((__PROPERTIES__hour_of_day - 16) / 6);
|
||||
a = apply_twilight(sampled_color);
|
||||
b = apply_night(sampled_color);
|
||||
}
|
||||
else if (__PROPERTIES__hour_of_day > 12)
|
||||
{
|
||||
t = ((__PROPERTIES__hour_of_day - 12) / 6);
|
||||
a = sampled_color;
|
||||
b = apply_twilight(sampled_color);
|
||||
}
|
||||
else if (__PROPERTIES__hour_of_day > 6)
|
||||
{
|
||||
t = ((__PROPERTIES__hour_of_day - 6) / 6);
|
||||
a = apply_morning(sampled_color);
|
||||
b = sampled_color;
|
||||
}
|
||||
else if (__PROPERTIES__hour_of_day >= 0)
|
||||
{
|
||||
t = (__PROPERTIES__hour_of_day / 6);
|
||||
a = apply_night(sampled_color);
|
||||
b = apply_morning(sampled_color);
|
||||
}
|
||||
|
||||
return lerp(a, b, t);
|
||||
}
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
struct Foo;
|
||||
|
||||
float foo(Foo f);
|
||||
|
||||
struct Foo
|
||||
{
|
||||
float some_data;
|
||||
}
|
||||
};
|
||||
|
||||
float foo(Foo f)
|
||||
{
|
||||
return f.some_data * 2.0f;
|
||||
return (f.some_data * 2.0f);
|
||||
}
|
||||
|
||||
void vs_main()
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
cbuffer __PROPERTIES : register(b0)
|
||||
{
|
||||
float4 color;
|
||||
float4 __PROPERTIES__color;
|
||||
}
|
||||
|
||||
|
||||
float4 vs_main(float4 pos : POSITION) : SV_POSITION
|
||||
{
|
||||
return pos;
|
||||
@@ -10,6 +11,6 @@ float4 vs_main(float4 pos : POSITION) : SV_POSITION
|
||||
|
||||
float4 ps_main() : SV_TARGET
|
||||
{
|
||||
return color;
|
||||
return __PROPERTIES__color;
|
||||
}
|
||||
|
||||
|
||||
17
test/codegen/simple_else_if.golden
Normal file
17
test/codegen/simple_else_if.golden
Normal file
@@ -0,0 +1,17 @@
|
||||
float4 vs_main(float3 pos : POSITION) : SV_POSITION
|
||||
{
|
||||
if (pos.x > 100)
|
||||
{
|
||||
return float4(pos, 1.0f);
|
||||
}
|
||||
else if (pos.x > 50)
|
||||
{
|
||||
return float4(pos, 1.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
return float4(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
}
|
||||
return float4(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
|
||||
10
test/codegen/simple_if.golden
Normal file
10
test/codegen/simple_if.golden
Normal file
@@ -0,0 +1,10 @@
|
||||
float4 vs_main(float3 pos : POSITION) : SV_POSITION
|
||||
{
|
||||
if (0 > 100)
|
||||
{
|
||||
return float4(pos, 1.0f);
|
||||
}
|
||||
|
||||
return float4(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
|
||||
13
test/codegen/simple_if_else.golden
Normal file
13
test/codegen/simple_if_else.golden
Normal file
@@ -0,0 +1,13 @@
|
||||
float4 vs_main(float3 pos : POSITION) : SV_POSITION
|
||||
{
|
||||
if (0 > 100)
|
||||
{
|
||||
return float4(pos, 1.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
return float4(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
}
|
||||
return float4(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
struct Data;
|
||||
|
||||
struct Data
|
||||
{
|
||||
float4 color;
|
||||
}
|
||||
};
|
||||
|
||||
void vs_main()
|
||||
{
|
||||
|
||||
@@ -1,15 +1,12 @@
|
||||
struct Foo;
|
||||
struct Bar;
|
||||
|
||||
struct Foo
|
||||
{
|
||||
float4 color;
|
||||
}
|
||||
};
|
||||
|
||||
struct Bar
|
||||
{
|
||||
Foo t;
|
||||
}
|
||||
};
|
||||
|
||||
void vs_main()
|
||||
{
|
||||
|
||||
10
test/codegen/unary.golden
Normal file
10
test/codegen/unary.golden
Normal file
@@ -0,0 +1,10 @@
|
||||
float4 vs_vs_main(float3 position : POSITION) : SV_POSITION
|
||||
{
|
||||
return float4(position.x, position.y, position.z, 1.0f);
|
||||
}
|
||||
|
||||
float4 ps_ps_main(float4 position : SV_POSITION) : SV_TARGET
|
||||
{
|
||||
return float4(0.5f, -1, 0, 1);
|
||||
}
|
||||
|
||||
@@ -1,20 +1,27 @@
|
||||
test/assign_arithmetic_expression.shd codegen
|
||||
test/basic_property_and_return_value.shd codegen
|
||||
test/complicated_computation.shd codegen
|
||||
test/constant_buffer.shd codegen
|
||||
test/empty_struct.shd codegen
|
||||
test/empty_vertex_main.shd codegen
|
||||
test/empty_vertex_main_with_position_parameter.shd codegen
|
||||
test/field_assignment.shd codegen
|
||||
test/function_call.shd codegen
|
||||
test/function_call_out_of_order_declaration.shd codegen
|
||||
test/function_call_return.shd codegen
|
||||
test/meta_block.shd codegen
|
||||
test/multiple_functions.shd codegen
|
||||
test/multiple_semicolons_everywhere.shd codegen
|
||||
test/pass_and_access_struct_fields_in_functions.shd codegen
|
||||
test/passthrough.shd codegen
|
||||
test/property_rename.shd codegen
|
||||
test/simple_struct_access.shd codegen
|
||||
test/struct_within_struct.shd codegen
|
||||
test/use_builtin_functions.shd codegen
|
||||
test/assign_arithmetic_expression.ink codegen
|
||||
test/basic_property_and_return_value.ink codegen
|
||||
test/builtin_types.ink codegen
|
||||
test/complicated_computation.ink codegen
|
||||
test/constant_buffer.ink codegen
|
||||
test/empty_struct.ink codegen
|
||||
test/empty_vertex_main.ink codegen
|
||||
test/empty_vertex_main_with_position_parameter.ink codegen
|
||||
test/field_assignment.ink codegen
|
||||
test/function_call.ink codegen
|
||||
test/function_call_out_of_order_declaration.ink codegen
|
||||
test/function_call_return.ink codegen
|
||||
test/inferred_types.ink codegen
|
||||
test/meta_block.ink codegen
|
||||
test/multiple_functions.ink codegen
|
||||
test/multiple_semicolons_everywhere.ink codegen
|
||||
test/nested_if.ink codegen
|
||||
test/pass_and_access_struct_fields_in_functions.ink codegen
|
||||
test/passthrough.ink codegen
|
||||
test/property_rename.ink codegen
|
||||
test/simple_else_if.ink codegen
|
||||
test/simple_if_else.ink codegen
|
||||
test/simple_if.ink codegen
|
||||
test/simple_struct_access.ink codegen
|
||||
test/struct_within_struct.ink codegen
|
||||
test/unary.ink codegen
|
||||
test/use_builtin_functions.ink codegen
|
||||
|
||||
39
test/colorful_circle.ink
Normal file
39
test/colorful_circle.ink
Normal file
@@ -0,0 +1,39 @@
|
||||
prop :: properties {
|
||||
time : float @time;
|
||||
resolution : float2 @resolution;
|
||||
}
|
||||
|
||||
vertex main :: (pos : float3 @position) -> float4 @position {
|
||||
return float4(pos, 1.0);
|
||||
}
|
||||
|
||||
pixel main :: (pos : float4 @outposition) -> float4 @target {
|
||||
p := float2(2.0 * pos.x - prop.resolution.x, 2.0 * pos.y - prop.resolution.y) / prop.resolution.y;
|
||||
tau := 3.1415926535 * 2.0;
|
||||
a := atan(p.x, p.y);
|
||||
r := length(p) * 0.75;
|
||||
|
||||
uv := float2(a / tau, r);
|
||||
|
||||
x_col := (uv.x - (p.time / 3.0)) * 3.0;
|
||||
x_col = mod(x_col, 3.0);
|
||||
hor_colour := float3(0.25, 0.25, 0.25);
|
||||
|
||||
if x_col < 1.0 {
|
||||
horColour.r += 1.0 - xCol;
|
||||
horColour.g += xCol;
|
||||
} else if x_col < 2.0 {
|
||||
xCol -= 1.0;
|
||||
horColour.g += 1.0 - xCol;
|
||||
horColour.b += xCol;
|
||||
} else {
|
||||
x_col -= 2.0;
|
||||
hor_colour.b += 1.0 - x_col;
|
||||
hor_colour.r += x_col;
|
||||
}
|
||||
|
||||
uv = (2.0 * uv) - 1.0;
|
||||
beam_width = (0.7+0.5*cos(uv.x*10.0*tau*0.15*clamp(floor(5.0 + 10.0*cos(iTime)), 0.0, 10.0))) * abs(1.0 / (30.0 * uv.y));
|
||||
hor_beam = float3(beam_width);
|
||||
result := float4(((hor_beam) * hor_colour), 1.0);
|
||||
}
|
||||
@@ -1,20 +1,26 @@
|
||||
test/assign_arithmetic_expression.shd compile
|
||||
test/basic_property_and_return_value.shd compile
|
||||
test/complicated_computation.shd compile
|
||||
test/empty_struct.shd compile
|
||||
test/empty_vertex_main.shd compile
|
||||
test/empty_vertex_main_with_position_parameter.shd compile
|
||||
test/field_assignment.shd compile
|
||||
test/float_suffix.shd compile
|
||||
test/function_call.shd compile
|
||||
test/function_call_out_of_order_declaration.shd compile
|
||||
test/function_call_return.shd compile
|
||||
test/functions_with_same_name.shd compile
|
||||
test/meta_block.shd compile
|
||||
test/multiple_functions.shd compile
|
||||
test/multiple_semicolons_everywhere.shd compile
|
||||
test/pass_and_access_struct_fields_in_functions.shd compile
|
||||
test/passthrough.shd compile
|
||||
test/simple_struct_access.shd compile
|
||||
test/struct_within_struct.shd compile
|
||||
test/use_builtin_functions.shd compile
|
||||
test/assign_arithmetic_expression.ink compile
|
||||
test/basic_property_and_return_value.ink compile
|
||||
test/builtin_types.ink compile
|
||||
test/complicated_computation.ink compile
|
||||
test/empty_struct.ink compile
|
||||
test/empty_vertex_main.ink compile
|
||||
test/empty_vertex_main_with_position_parameter.ink compile
|
||||
test/field_assignment.ink compile
|
||||
test/float_suffix.ink compile
|
||||
test/function_call.ink compile
|
||||
test/function_call_out_of_order_declaration.ink compile
|
||||
test/function_call_return.ink compile
|
||||
test/functions_with_same_name.ink compile
|
||||
test/inferred_types.ink compile
|
||||
test/meta_block.ink compile
|
||||
test/multiple_functions.ink compile
|
||||
test/multiple_semicolons_everywhere.ink compile
|
||||
test/pass_and_access_struct_fields_in_functions.ink compile
|
||||
test/passthrough.ink compile
|
||||
test/simple_else_if.ink compile
|
||||
test/simple_if_else.ink compile
|
||||
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
|
||||
1
test/compiled/builtin_types.golden
Normal file
1
test/compiled/builtin_types.golden
Normal file
@@ -0,0 +1 @@
|
||||
[vertex entry point] - vs_main
|
||||
12
test/custom_hint.ink
Normal file
12
test/custom_hint.ink
Normal file
@@ -0,0 +1,12 @@
|
||||
p :: properties {
|
||||
time : float @time;
|
||||
}
|
||||
|
||||
vertex main :: (pos : float3 @position) -> float4 @position {
|
||||
return float4(pos.x, pos.y, pos.z, 1.0);
|
||||
}
|
||||
|
||||
pixel main :: (pos : float4 @outposition) -> float4 @target {
|
||||
t := p.time;
|
||||
return float4(1, 1, 1, 1);
|
||||
}
|
||||
7
test/double_access.ink
Normal file
7
test/double_access.ink
Normal file
@@ -0,0 +1,7 @@
|
||||
p :: properties {
|
||||
v : float2;
|
||||
}
|
||||
|
||||
vertex main ::() {
|
||||
x : float = p.v.x / p.v.y;
|
||||
}
|
||||
10
test/else_if_after_else.ink
Normal file
10
test/else_if_after_else.ink
Normal file
@@ -0,0 +1,10 @@
|
||||
vertex main :: (pos : float3 @position) -> float4 @position {
|
||||
if 0 > 100 {
|
||||
|
||||
} else {
|
||||
|
||||
} else if 0 > 200 {
|
||||
|
||||
}
|
||||
return float4(0.0);
|
||||
}
|
||||
6
test/float_if_cond.ink
Normal file
6
test/float_if_cond.ink
Normal file
@@ -0,0 +1,6 @@
|
||||
vertex main :: (pos : float3 @position) -> float4 @position {
|
||||
if 1.0 {
|
||||
return float4(pos, 1.0);
|
||||
}
|
||||
return float4(0.0);
|
||||
}
|
||||
6
test/for_i_loop.ink
Normal file
6
test/for_i_loop.ink
Normal file
@@ -0,0 +1,6 @@
|
||||
vertex main :: () {
|
||||
x := 0;
|
||||
for i : 0..10 {
|
||||
x += 1.0;
|
||||
}
|
||||
}
|
||||
4
test/for_i_one_liner.ink
Normal file
4
test/for_i_one_liner.ink
Normal file
@@ -0,0 +1,4 @@
|
||||
vertex main :: () {
|
||||
x := 0.0;
|
||||
for i : 0..10 x += 2.0;
|
||||
}
|
||||
6
test/for_no_iter.ink
Normal file
6
test/for_no_iter.ink
Normal file
@@ -0,0 +1,6 @@
|
||||
vertex main :: () {
|
||||
x := 0.0;
|
||||
for i : 0.. {
|
||||
x += 2.0;
|
||||
}
|
||||
}
|
||||
6
test/if_cond_assign.ink
Normal file
6
test/if_cond_assign.ink
Normal file
@@ -0,0 +1,6 @@
|
||||
vertex main :: (pos : float3 @position) -> float4 @position {
|
||||
if 0 = 100 {
|
||||
return float4(pos, 1.0);
|
||||
}
|
||||
return float4(0.0);
|
||||
}
|
||||
6
test/if_if_if.ink
Normal file
6
test/if_if_if.ink
Normal file
@@ -0,0 +1,6 @@
|
||||
vertex main :: (pos : float3 @position) -> float4 @position {
|
||||
if if if 0 > 100 {
|
||||
return float4(pos, 1.0);
|
||||
}
|
||||
return float4(0.0);
|
||||
}
|
||||
5
test/if_no_cond.ink
Normal file
5
test/if_no_cond.ink
Normal file
@@ -0,0 +1,5 @@
|
||||
vertex main :: () {
|
||||
if {
|
||||
|
||||
}
|
||||
}
|
||||
5
test/ifdefs.ink
Normal file
5
test/ifdefs.ink
Normal file
@@ -0,0 +1,5 @@
|
||||
#if Defines.Skinning {
|
||||
vertex main :: () {
|
||||
// Stub
|
||||
}
|
||||
}
|
||||
17
test/inferred_types.ink
Normal file
17
test/inferred_types.ink
Normal file
@@ -0,0 +1,17 @@
|
||||
bar :: () -> float {
|
||||
return 5.0;
|
||||
}
|
||||
|
||||
foo :: () -> float {
|
||||
return bar();
|
||||
}
|
||||
|
||||
vertex main :: (pos : float3 @position) -> float4 @position {
|
||||
f := 2.0;
|
||||
i := 10;
|
||||
f = foo();
|
||||
v2 := float2(2, 2);
|
||||
v3 := float3(2, 2, 3);
|
||||
v4 := float4(4, 5, 6, 7);
|
||||
return float4(1, 1, 1, 1);
|
||||
}
|
||||
42
test/large_block.ink
Normal file
42
test/large_block.ink
Normal file
@@ -0,0 +1,42 @@
|
||||
p :: properties {
|
||||
color : float4;
|
||||
rect_position : float2;
|
||||
rect_scale : float2;
|
||||
resolution : float2;
|
||||
texture : Texture2D;
|
||||
sampler : Sampler;
|
||||
}
|
||||
|
||||
PS_Input :: struct {
|
||||
uv : float2 @uv;
|
||||
pos : float4 @pos;
|
||||
}
|
||||
|
||||
vertex main :: (pos : float4 @position) -> PS_Input {
|
||||
res : float2 = p.resolution;
|
||||
scale : float2 = p.rect_scale;
|
||||
rect_pos : float2 = p.rect_position;;
|
||||
|
||||
center : float2 = rect_pos;
|
||||
half_size : float2 = float2(scale.x / 2, scale.y / 2);
|
||||
dst_pos : float4 = float4(pos.x * half_size.x + center.x, pos.y * half_size.y + center.y, 0.0, 1.0);
|
||||
|
||||
result : PS_Input;
|
||||
|
||||
src_p0 : float2 = float2(0.0, 1.0);
|
||||
src_p1 : float2 = float2(1.0, 0.0);
|
||||
|
||||
src_half_size : float2 = (src_p1 - src_p0) / 2;
|
||||
src_center : float2 = (src_p1 + src_p0) / 2;
|
||||
src_pos : float2 = float2(pos.x, pos.y) * src_half_size + src_center;
|
||||
|
||||
result.uv = float2(1, 1);
|
||||
result.pos = float4(2.0 * dst_pos.x / res.x - 1, 2.0 * dst_pos.y / res.y - 1, 0.0, 1.0);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
pixel main :: (input : PS_Input) -> float4 @target0 {
|
||||
color : float4 = p.color;
|
||||
return color;
|
||||
}
|
||||
223
test/lex/builtin_types.golden
Normal file
223
test/lex/builtin_types.golden
Normal file
@@ -0,0 +1,223 @@
|
||||
{kind = TOKEN_VERTEX; ; index = 0 ; length = 6 line = 1 ; column = 0 ; value ='vertex'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 7 ; length = 4 line = 1 ; column = 7 ; value ='main'; }
|
||||
{kind = TOKEN_DOUBLECOLON; ; index = 12 ; length = 2 line = 1 ; column = 12 ; value ='::'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 15 ; length = 1 line = 1 ; column = 15 ; value ='('; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 16 ; length = 1 line = 1 ; column = 16 ; value =')'; }
|
||||
{kind = TOKEN_LEFTBRACE; ; index = 18 ; length = 1 line = 1 ; column = 18 ; value ='{'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 22 ; length = 2 line = 2 ; column = 0 ; value ='v2'; }
|
||||
{kind = TOKEN_COLON; ; index = 25 ; length = 1 line = 2 ; column = 3 ; value =':'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 27 ; length = 6 line = 2 ; column = 5 ; value ='float2'; }
|
||||
{kind = TOKEN_ASSIGN; ; index = 34 ; length = 1 line = 2 ; column = 12 ; value ='='; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 36 ; length = 6 line = 2 ; column = 14 ; value ='float2'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 42 ; length = 1 line = 2 ; column = 20 ; value ='('; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 43 ; length = 3 line = 2 ; column = 21 ; value ='2'; }
|
||||
{kind = TOKEN_COMMA; ; index = 46 ; length = 1 line = 2 ; column = 24 ; value =','; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 48 ; length = 3 line = 2 ; column = 26 ; value ='2'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 51 ; length = 1 line = 2 ; column = 29 ; value =')'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 52 ; length = 1 line = 2 ; column = 30 ; value =';'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 56 ; length = 2 line = 3 ; column = 0 ; value ='v2'; }
|
||||
{kind = TOKEN_ASSIGN; ; index = 59 ; length = 1 line = 3 ; column = 3 ; value ='='; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 61 ; length = 6 line = 3 ; column = 5 ; value ='float2'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 67 ; length = 1 line = 3 ; column = 11 ; value ='('; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 68 ; length = 3 line = 3 ; column = 12 ; value ='2'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 71 ; length = 1 line = 3 ; column = 15 ; value =')'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 72 ; length = 1 line = 3 ; column = 16 ; value =';'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 76 ; length = 2 line = 4 ; column = 0 ; value ='v2'; }
|
||||
{kind = TOKEN_ASSIGN; ; index = 79 ; length = 1 line = 4 ; column = 3 ; value ='='; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 81 ; length = 6 line = 4 ; column = 5 ; value ='float2'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 87 ; length = 1 line = 4 ; column = 11 ; value ='('; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 88 ; length = 2 line = 4 ; column = 12 ; value ='v2'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 90 ; length = 1 line = 4 ; column = 14 ; value =')'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 91 ; length = 1 line = 4 ; column = 15 ; value =';'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 97 ; length = 2 line = 6 ; column = 0 ; value ='v3'; }
|
||||
{kind = TOKEN_COLON; ; index = 100 ; length = 1 line = 6 ; column = 3 ; value =':'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 102 ; length = 6 line = 6 ; column = 5 ; value ='float3'; }
|
||||
{kind = TOKEN_ASSIGN; ; index = 109 ; length = 1 line = 6 ; column = 12 ; value ='='; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 111 ; length = 6 line = 6 ; column = 14 ; value ='float3'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 117 ; length = 1 line = 6 ; column = 20 ; value ='('; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 118 ; length = 3 line = 6 ; column = 21 ; value ='2'; }
|
||||
{kind = TOKEN_COMMA; ; index = 121 ; length = 1 line = 6 ; column = 24 ; value =','; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 123 ; length = 3 line = 6 ; column = 26 ; value ='2'; }
|
||||
{kind = TOKEN_COMMA; ; index = 126 ; length = 1 line = 6 ; column = 29 ; value =','; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 128 ; length = 3 line = 6 ; column = 31 ; value ='2'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 131 ; length = 1 line = 6 ; column = 34 ; value =')'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 132 ; length = 1 line = 6 ; column = 35 ; value =';'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 136 ; length = 2 line = 7 ; column = 0 ; value ='v3'; }
|
||||
{kind = TOKEN_ASSIGN; ; index = 139 ; length = 1 line = 7 ; column = 3 ; value ='='; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 141 ; length = 6 line = 7 ; column = 5 ; value ='float3'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 147 ; length = 1 line = 7 ; column = 11 ; value ='('; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 148 ; length = 2 line = 7 ; column = 12 ; value ='v2'; }
|
||||
{kind = TOKEN_COMMA; ; index = 150 ; length = 1 line = 7 ; column = 14 ; value =','; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 152 ; length = 3 line = 7 ; column = 16 ; value ='1'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 155 ; length = 1 line = 7 ; column = 19 ; value =')'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 156 ; length = 1 line = 7 ; column = 20 ; value =';'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 160 ; length = 2 line = 8 ; column = 0 ; value ='v3'; }
|
||||
{kind = TOKEN_ASSIGN; ; index = 163 ; length = 1 line = 8 ; column = 3 ; value ='='; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 165 ; length = 6 line = 8 ; column = 5 ; value ='float3'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 171 ; length = 1 line = 8 ; column = 11 ; value ='('; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 172 ; length = 3 line = 8 ; column = 12 ; value ='1'; }
|
||||
{kind = TOKEN_COMMA; ; index = 175 ; length = 1 line = 8 ; column = 15 ; value =','; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 177 ; length = 2 line = 8 ; column = 17 ; value ='v2'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 179 ; length = 1 line = 8 ; column = 19 ; value =')'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 180 ; length = 1 line = 8 ; column = 20 ; value =';'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 184 ; length = 2 line = 9 ; column = 0 ; value ='v3'; }
|
||||
{kind = TOKEN_ASSIGN; ; index = 187 ; length = 1 line = 9 ; column = 3 ; value ='='; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 189 ; length = 6 line = 9 ; column = 5 ; value ='float3'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 195 ; length = 1 line = 9 ; column = 11 ; value ='('; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 196 ; length = 3 line = 9 ; column = 12 ; value ='1'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 199 ; length = 1 line = 9 ; column = 15 ; value =')'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 200 ; length = 1 line = 9 ; column = 16 ; value =';'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 204 ; length = 2 line = 10 ; column = 0 ; value ='v3'; }
|
||||
{kind = TOKEN_ASSIGN; ; index = 207 ; length = 1 line = 10 ; column = 3 ; value ='='; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 209 ; length = 6 line = 10 ; column = 5 ; value ='float3'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 215 ; length = 1 line = 10 ; column = 11 ; value ='('; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 216 ; length = 2 line = 10 ; column = 12 ; value ='v3'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 218 ; length = 1 line = 10 ; column = 14 ; value =')'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 219 ; length = 1 line = 10 ; column = 15 ; value =';'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 226 ; length = 2 line = 12 ; column = 0 ; value ='v4'; }
|
||||
{kind = TOKEN_COLON; ; index = 229 ; length = 1 line = 12 ; column = 3 ; value =':'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 231 ; length = 6 line = 12 ; column = 5 ; value ='float4'; }
|
||||
{kind = TOKEN_ASSIGN; ; index = 238 ; length = 1 line = 12 ; column = 12 ; value ='='; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 240 ; length = 6 line = 12 ; column = 14 ; value ='float4'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 246 ; length = 1 line = 12 ; column = 20 ; value ='('; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 247 ; length = 3 line = 12 ; column = 21 ; value ='2'; }
|
||||
{kind = TOKEN_COMMA; ; index = 250 ; length = 1 line = 12 ; column = 24 ; value =','; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 252 ; length = 3 line = 12 ; column = 26 ; value ='2'; }
|
||||
{kind = TOKEN_COMMA; ; index = 255 ; length = 1 line = 12 ; column = 29 ; value =','; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 257 ; length = 3 line = 12 ; column = 31 ; value ='2'; }
|
||||
{kind = TOKEN_COMMA; ; index = 260 ; length = 1 line = 12 ; column = 34 ; value =','; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 262 ; length = 3 line = 12 ; column = 36 ; value ='2'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 265 ; length = 1 line = 12 ; column = 39 ; value =')'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 266 ; length = 1 line = 12 ; column = 40 ; value =';'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 270 ; length = 2 line = 13 ; column = 0 ; value ='v4'; }
|
||||
{kind = TOKEN_ASSIGN; ; index = 273 ; length = 1 line = 13 ; column = 3 ; value ='='; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 275 ; length = 6 line = 13 ; column = 5 ; value ='float4'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 281 ; length = 1 line = 13 ; column = 11 ; value ='('; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 282 ; length = 2 line = 13 ; column = 12 ; value ='v4'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 284 ; length = 1 line = 13 ; column = 14 ; value =')'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 285 ; length = 1 line = 13 ; column = 15 ; value =';'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 289 ; length = 2 line = 14 ; column = 0 ; value ='v4'; }
|
||||
{kind = TOKEN_ASSIGN; ; index = 292 ; length = 1 line = 14 ; column = 3 ; value ='='; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 294 ; length = 6 line = 14 ; column = 5 ; value ='float4'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 300 ; length = 1 line = 14 ; column = 11 ; value ='('; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 301 ; length = 2 line = 14 ; column = 12 ; value ='v2'; }
|
||||
{kind = TOKEN_COMMA; ; index = 303 ; length = 1 line = 14 ; column = 14 ; value =','; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 305 ; length = 2 line = 14 ; column = 16 ; value ='v2'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 307 ; length = 1 line = 14 ; column = 18 ; value =')'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 308 ; length = 1 line = 14 ; column = 19 ; value =';'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 312 ; length = 2 line = 15 ; column = 0 ; value ='v4'; }
|
||||
{kind = TOKEN_ASSIGN; ; index = 315 ; length = 1 line = 15 ; column = 3 ; value ='='; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 317 ; length = 6 line = 15 ; column = 5 ; value ='float4'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 323 ; length = 1 line = 15 ; column = 11 ; value ='('; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 324 ; length = 2 line = 15 ; column = 12 ; value ='v2'; }
|
||||
{kind = TOKEN_COMMA; ; index = 326 ; length = 1 line = 15 ; column = 14 ; value =','; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 328 ; length = 3 line = 15 ; column = 16 ; value ='1'; }
|
||||
{kind = TOKEN_COMMA; ; index = 331 ; length = 1 line = 15 ; column = 19 ; value =','; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 333 ; length = 3 line = 15 ; column = 21 ; value ='1'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 336 ; length = 1 line = 15 ; column = 24 ; value =')'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 337 ; length = 1 line = 15 ; column = 25 ; value =';'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 341 ; length = 2 line = 16 ; column = 0 ; value ='v4'; }
|
||||
{kind = TOKEN_ASSIGN; ; index = 344 ; length = 1 line = 16 ; column = 3 ; value ='='; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 346 ; length = 6 line = 16 ; column = 5 ; value ='float4'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 352 ; length = 1 line = 16 ; column = 11 ; value ='('; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 353 ; length = 3 line = 16 ; column = 12 ; value ='1'; }
|
||||
{kind = TOKEN_COMMA; ; index = 356 ; length = 1 line = 16 ; column = 15 ; value =','; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 358 ; length = 2 line = 16 ; column = 17 ; value ='v2'; }
|
||||
{kind = TOKEN_COMMA; ; index = 360 ; length = 1 line = 16 ; column = 19 ; value =','; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 362 ; length = 3 line = 16 ; column = 21 ; value ='1'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 365 ; length = 1 line = 16 ; column = 24 ; value =')'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 366 ; length = 1 line = 16 ; column = 25 ; value =';'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 370 ; length = 2 line = 17 ; column = 0 ; value ='v4'; }
|
||||
{kind = TOKEN_ASSIGN; ; index = 373 ; length = 1 line = 17 ; column = 3 ; value ='='; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 375 ; length = 6 line = 17 ; column = 5 ; value ='float4'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 381 ; length = 1 line = 17 ; column = 11 ; value ='('; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 382 ; length = 3 line = 17 ; column = 12 ; value ='1'; }
|
||||
{kind = TOKEN_COMMA; ; index = 385 ; length = 1 line = 17 ; column = 15 ; value =','; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 387 ; length = 3 line = 17 ; column = 17 ; value ='1'; }
|
||||
{kind = TOKEN_COMMA; ; index = 390 ; length = 1 line = 17 ; column = 20 ; value =','; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 392 ; length = 2 line = 17 ; column = 22 ; value ='v2'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 394 ; length = 1 line = 17 ; column = 24 ; value =')'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 395 ; length = 1 line = 17 ; column = 25 ; value =';'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 399 ; length = 2 line = 18 ; column = 0 ; value ='v4'; }
|
||||
{kind = TOKEN_ASSIGN; ; index = 402 ; length = 1 line = 18 ; column = 3 ; value ='='; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 404 ; length = 6 line = 18 ; column = 5 ; value ='float4'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 410 ; length = 1 line = 18 ; column = 11 ; value ='('; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 411 ; length = 2 line = 18 ; column = 12 ; value ='v3'; }
|
||||
{kind = TOKEN_COMMA; ; index = 413 ; length = 1 line = 18 ; column = 14 ; value =','; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 415 ; length = 3 line = 18 ; column = 16 ; value ='2'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 418 ; length = 1 line = 18 ; column = 19 ; value =')'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 419 ; length = 1 line = 18 ; column = 20 ; value =';'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 423 ; length = 2 line = 19 ; column = 0 ; value ='v4'; }
|
||||
{kind = TOKEN_ASSIGN; ; index = 426 ; length = 1 line = 19 ; column = 3 ; value ='='; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 428 ; length = 6 line = 19 ; column = 5 ; value ='float4'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 434 ; length = 1 line = 19 ; column = 11 ; value ='('; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 435 ; length = 3 line = 19 ; column = 12 ; value ='2'; }
|
||||
{kind = TOKEN_COMMA; ; index = 438 ; length = 1 line = 19 ; column = 15 ; value =','; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 440 ; length = 2 line = 19 ; column = 17 ; value ='v3'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 442 ; length = 1 line = 19 ; column = 19 ; value =')'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 443 ; length = 1 line = 19 ; column = 20 ; value =';'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 447 ; length = 2 line = 20 ; column = 0 ; value ='v4'; }
|
||||
{kind = TOKEN_ASSIGN; ; index = 450 ; length = 1 line = 20 ; column = 3 ; value ='='; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 452 ; length = 6 line = 20 ; column = 5 ; value ='float4'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 458 ; length = 1 line = 20 ; column = 11 ; value ='('; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 459 ; length = 3 line = 20 ; column = 12 ; value ='2'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 462 ; length = 1 line = 20 ; column = 15 ; value =')'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 463 ; length = 1 line = 20 ; column = 16 ; value =';'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 472 ; length = 2 line = 23 ; column = 0 ; value ='v4'; }
|
||||
{kind = TOKEN_ASSIGN; ; index = 475 ; length = 1 line = 23 ; column = 3 ; value ='='; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 477 ; length = 6 line = 23 ; column = 5 ; value ='float4'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 483 ; length = 1 line = 23 ; column = 11 ; value ='('; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 484 ; length = 3 line = 23 ; column = 12 ; value ='1'; }
|
||||
{kind = TOKEN_COMMA; ; index = 487 ; length = 1 line = 23 ; column = 15 ; value =','; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 489 ; length = 3 line = 23 ; column = 17 ; value ='1'; }
|
||||
{kind = TOKEN_COMMA; ; index = 492 ; length = 1 line = 23 ; column = 20 ; value =','; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 494 ; length = 2 line = 23 ; column = 22 ; value ='v2'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 496 ; length = 1 line = 23 ; column = 24 ; value =')'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 497 ; length = 1 line = 23 ; column = 25 ; value =';'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 501 ; length = 2 line = 24 ; column = 0 ; value ='v4'; }
|
||||
{kind = TOKEN_ASSIGN; ; index = 504 ; length = 1 line = 24 ; column = 3 ; value ='='; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 506 ; length = 6 line = 24 ; column = 5 ; value ='float4'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 512 ; length = 1 line = 24 ; column = 11 ; value ='('; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 513 ; length = 3 line = 24 ; column = 12 ; value ='2'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 516 ; length = 1 line = 24 ; column = 15 ; value =')'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 517 ; length = 1 line = 24 ; column = 16 ; value =';'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 524 ; length = 2 line = 26 ; column = 0 ; value ='v2'; }
|
||||
{kind = TOKEN_DOT; ; index = 526 ; length = 1 line = 26 ; column = 2 ; value ='.'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 527 ; length = 1 line = 26 ; column = 3 ; value ='x'; }
|
||||
{kind = TOKEN_ASSIGN; ; index = 529 ; length = 1 line = 26 ; column = 5 ; value ='='; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 531 ; length = 3 line = 26 ; column = 7 ; value ='2'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 534 ; length = 1 line = 26 ; column = 10 ; value =';'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 538 ; length = 2 line = 27 ; column = 0 ; value ='v2'; }
|
||||
{kind = TOKEN_DOT; ; index = 540 ; length = 1 line = 27 ; column = 2 ; value ='.'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 541 ; length = 1 line = 27 ; column = 3 ; value ='y'; }
|
||||
{kind = TOKEN_ASSIGN; ; index = 543 ; length = 1 line = 27 ; column = 5 ; value ='='; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 545 ; length = 3 line = 27 ; column = 7 ; value ='2'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 548 ; length = 1 line = 27 ; column = 10 ; value =';'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 554 ; length = 1 line = 29 ; column = 0 ; value ='p'; }
|
||||
{kind = TOKEN_COLON; ; index = 556 ; length = 1 line = 29 ; column = 2 ; value =':'; }
|
||||
{kind = TOKEN_ASSIGN; ; index = 557 ; length = 1 line = 29 ; column = 3 ; value ='='; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 559 ; length = 2 line = 29 ; column = 5 ; value ='v2'; }
|
||||
{kind = TOKEN_DOT; ; index = 561 ; length = 1 line = 29 ; column = 7 ; value ='.'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 562 ; length = 1 line = 29 ; column = 8 ; value ='x'; }
|
||||
{kind = TOKEN_PLUS; ; index = 564 ; length = 1 line = 29 ; column = 10 ; value ='+'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 566 ; length = 2 line = 29 ; column = 12 ; value ='v3'; }
|
||||
{kind = TOKEN_DOT; ; index = 568 ; length = 1 line = 29 ; column = 14 ; value ='.'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 569 ; length = 1 line = 29 ; column = 15 ; value ='z'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 570 ; length = 1 line = 29 ; column = 16 ; value =';'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 574 ; length = 1 line = 30 ; column = 0 ; value ='q'; }
|
||||
{kind = TOKEN_COLON; ; index = 576 ; length = 1 line = 30 ; column = 2 ; value =':'; }
|
||||
{kind = TOKEN_ASSIGN; ; index = 577 ; length = 1 line = 30 ; column = 3 ; value ='='; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 579 ; length = 2 line = 30 ; column = 5 ; value ='v4'; }
|
||||
{kind = TOKEN_DOT; ; index = 581 ; length = 1 line = 30 ; column = 7 ; value ='.'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 582 ; length = 1 line = 30 ; column = 8 ; value ='w'; }
|
||||
{kind = TOKEN_PLUS; ; index = 584 ; length = 1 line = 30 ; column = 10 ; value ='+'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 586 ; length = 2 line = 30 ; column = 12 ; value ='v2'; }
|
||||
{kind = TOKEN_DOT; ; index = 588 ; length = 1 line = 30 ; column = 14 ; value ='.'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 589 ; length = 1 line = 30 ; column = 15 ; value ='x'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 590 ; length = 1 line = 30 ; column = 16 ; value =';'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 596 ; length = 1 line = 32 ; column = 0 ; value ='m'; }
|
||||
{kind = TOKEN_COLON; ; index = 598 ; length = 1 line = 32 ; column = 2 ; value =':'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 600 ; length = 8 line = 32 ; column = 4 ; value ='float4x4'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 608 ; length = 1 line = 32 ; column = 12 ; value =';'; }
|
||||
{kind = TOKEN_RIGHTBRACE; ; index = 614 ; length = 1 line = 34 ; column = 0 ; value ='}'; }
|
||||
{kind = TOKEN_EOF; ; index = 617 ; length = 0 line = 35 ; column = 0 ; value =''; }
|
||||
297
test/lex/colorful_circle.golden
Normal file
297
test/lex/colorful_circle.golden
Normal file
@@ -0,0 +1,297 @@
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 0 ; length = 4 line = 1 ; column = 0 ; value ='prop'; }
|
||||
{kind = TOKEN_DOUBLECOLON; ; index = 5 ; length = 2 line = 1 ; column = 5 ; value ='::'; }
|
||||
{kind = TOKEN_PROPERTIES; ; index = 8 ; length = 10 line = 1 ; column = 8 ; value ='properties'; }
|
||||
{kind = TOKEN_LEFTBRACE; ; index = 19 ; length = 1 line = 1 ; column = 19 ; value ='{'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 23 ; length = 4 line = 2 ; column = 0 ; value ='time'; }
|
||||
{kind = TOKEN_COLON; ; index = 28 ; length = 1 line = 2 ; column = 5 ; value =':'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 30 ; length = 5 line = 2 ; column = 7 ; value ='float'; }
|
||||
{kind = TOKEN_AT; ; index = 36 ; length = 1 line = 2 ; column = 13 ; value ='@'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 37 ; length = 4 line = 2 ; column = 14 ; value ='time'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 41 ; length = 1 line = 2 ; column = 18 ; value =';'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 45 ; length = 10 line = 3 ; column = 0 ; value ='resolution'; }
|
||||
{kind = TOKEN_COLON; ; index = 56 ; length = 1 line = 3 ; column = 11 ; value =':'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 58 ; length = 6 line = 3 ; column = 13 ; value ='float2'; }
|
||||
{kind = TOKEN_AT; ; index = 65 ; length = 1 line = 3 ; column = 20 ; value ='@'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 66 ; length = 10 line = 3 ; column = 21 ; value ='resolution'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 76 ; length = 1 line = 3 ; column = 31 ; value =';'; }
|
||||
{kind = TOKEN_RIGHTBRACE; ; index = 79 ; length = 1 line = 4 ; column = 0 ; value ='}'; }
|
||||
{kind = TOKEN_VERTEX; ; index = 84 ; length = 6 line = 6 ; column = 0 ; value ='vertex'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 91 ; length = 4 line = 6 ; column = 7 ; value ='main'; }
|
||||
{kind = TOKEN_DOUBLECOLON; ; index = 96 ; length = 2 line = 6 ; column = 12 ; value ='::'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 99 ; length = 1 line = 6 ; column = 15 ; value ='('; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 100 ; length = 3 line = 6 ; column = 16 ; value ='pos'; }
|
||||
{kind = TOKEN_COLON; ; index = 104 ; length = 1 line = 6 ; column = 20 ; value =':'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 106 ; length = 6 line = 6 ; column = 22 ; value ='float3'; }
|
||||
{kind = TOKEN_AT; ; index = 113 ; length = 1 line = 6 ; column = 29 ; value ='@'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 114 ; length = 8 line = 6 ; column = 30 ; value ='position'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 122 ; length = 1 line = 6 ; column = 38 ; value =')'; }
|
||||
{kind = TOKEN_ARROW; ; index = 124 ; length = 2 line = 6 ; column = 40 ; value ='->'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 127 ; length = 6 line = 6 ; column = 43 ; value ='float4'; }
|
||||
{kind = TOKEN_AT; ; index = 134 ; length = 1 line = 6 ; column = 50 ; value ='@'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 135 ; length = 8 line = 6 ; column = 51 ; value ='position'; }
|
||||
{kind = TOKEN_LEFTBRACE; ; index = 144 ; length = 1 line = 6 ; column = 60 ; value ='{'; }
|
||||
{kind = TOKEN_RETURN; ; index = 148 ; length = 6 line = 7 ; column = 0 ; value ='return'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 155 ; length = 6 line = 7 ; column = 7 ; value ='float4'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 161 ; length = 1 line = 7 ; column = 13 ; value ='('; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 162 ; length = 3 line = 7 ; column = 14 ; value ='pos'; }
|
||||
{kind = TOKEN_COMMA; ; index = 165 ; length = 1 line = 7 ; column = 17 ; value =','; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 167 ; length = 3 line = 7 ; column = 19 ; value ='1'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 170 ; length = 1 line = 7 ; column = 22 ; value =')'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 171 ; length = 1 line = 7 ; column = 23 ; value =';'; }
|
||||
{kind = TOKEN_RIGHTBRACE; ; index = 174 ; length = 1 line = 8 ; column = 0 ; value ='}'; }
|
||||
{kind = TOKEN_PIXEL; ; index = 179 ; length = 5 line = 10 ; column = 0 ; value ='pixel'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 185 ; length = 4 line = 10 ; column = 6 ; value ='main'; }
|
||||
{kind = TOKEN_DOUBLECOLON; ; index = 190 ; length = 2 line = 10 ; column = 11 ; value ='::'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 193 ; length = 1 line = 10 ; column = 14 ; value ='('; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 194 ; length = 3 line = 10 ; column = 15 ; value ='pos'; }
|
||||
{kind = TOKEN_COLON; ; index = 198 ; length = 1 line = 10 ; column = 19 ; value =':'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 200 ; length = 6 line = 10 ; column = 21 ; value ='float4'; }
|
||||
{kind = TOKEN_AT; ; index = 207 ; length = 1 line = 10 ; column = 28 ; value ='@'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 208 ; length = 11 line = 10 ; column = 29 ; value ='outposition'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 219 ; length = 1 line = 10 ; column = 40 ; value =')'; }
|
||||
{kind = TOKEN_ARROW; ; index = 221 ; length = 2 line = 10 ; column = 42 ; value ='->'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 224 ; length = 6 line = 10 ; column = 45 ; value ='float4'; }
|
||||
{kind = TOKEN_AT; ; index = 231 ; length = 1 line = 10 ; column = 52 ; value ='@'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 232 ; length = 6 line = 10 ; column = 53 ; value ='target'; }
|
||||
{kind = TOKEN_LEFTBRACE; ; index = 239 ; length = 1 line = 10 ; column = 60 ; value ='{'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 243 ; length = 1 line = 11 ; column = 0 ; value ='p'; }
|
||||
{kind = TOKEN_COLON; ; index = 245 ; length = 1 line = 11 ; column = 2 ; value =':'; }
|
||||
{kind = TOKEN_ASSIGN; ; index = 246 ; length = 1 line = 11 ; column = 3 ; value ='='; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 248 ; length = 6 line = 11 ; column = 5 ; value ='float2'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 254 ; length = 1 line = 11 ; column = 11 ; value ='('; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 255 ; length = 3 line = 11 ; column = 12 ; value ='2'; }
|
||||
{kind = TOKEN_STAR; ; index = 259 ; length = 1 line = 11 ; column = 16 ; value ='*'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 261 ; length = 3 line = 11 ; column = 18 ; value ='pos'; }
|
||||
{kind = TOKEN_DOT; ; index = 264 ; length = 1 line = 11 ; column = 21 ; value ='.'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 265 ; length = 1 line = 11 ; column = 22 ; value ='x'; }
|
||||
{kind = TOKEN_MINUS; ; index = 267 ; length = 1 line = 11 ; column = 24 ; value ='-'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 269 ; length = 4 line = 11 ; column = 26 ; value ='prop'; }
|
||||
{kind = TOKEN_DOT; ; index = 273 ; length = 1 line = 11 ; column = 30 ; value ='.'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 274 ; length = 10 line = 11 ; column = 31 ; value ='resolution'; }
|
||||
{kind = TOKEN_DOT; ; index = 284 ; length = 1 line = 11 ; column = 41 ; value ='.'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 285 ; length = 1 line = 11 ; column = 42 ; value ='x'; }
|
||||
{kind = TOKEN_COMMA; ; index = 286 ; length = 1 line = 11 ; column = 43 ; value =','; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 288 ; length = 3 line = 11 ; column = 45 ; value ='2'; }
|
||||
{kind = TOKEN_STAR; ; index = 292 ; length = 1 line = 11 ; column = 49 ; value ='*'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 294 ; length = 3 line = 11 ; column = 51 ; value ='pos'; }
|
||||
{kind = TOKEN_DOT; ; index = 297 ; length = 1 line = 11 ; column = 54 ; value ='.'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 298 ; length = 1 line = 11 ; column = 55 ; value ='y'; }
|
||||
{kind = TOKEN_MINUS; ; index = 300 ; length = 1 line = 11 ; column = 57 ; value ='-'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 302 ; length = 4 line = 11 ; column = 59 ; value ='prop'; }
|
||||
{kind = TOKEN_DOT; ; index = 306 ; length = 1 line = 11 ; column = 63 ; value ='.'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 307 ; length = 10 line = 11 ; column = 64 ; value ='resolution'; }
|
||||
{kind = TOKEN_DOT; ; index = 317 ; length = 1 line = 11 ; column = 74 ; value ='.'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 318 ; length = 1 line = 11 ; column = 75 ; value ='y'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 319 ; length = 1 line = 11 ; column = 76 ; value =')'; }
|
||||
{kind = TOKEN_SLASH; ; index = 321 ; length = 1 line = 11 ; column = 78 ; value ='/'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 323 ; length = 4 line = 11 ; column = 80 ; value ='prop'; }
|
||||
{kind = TOKEN_DOT; ; index = 327 ; length = 1 line = 11 ; column = 84 ; value ='.'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 328 ; length = 10 line = 11 ; column = 85 ; value ='resolution'; }
|
||||
{kind = TOKEN_DOT; ; index = 338 ; length = 1 line = 11 ; column = 95 ; value ='.'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 339 ; length = 1 line = 11 ; column = 96 ; value ='y'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 340 ; length = 1 line = 11 ; column = 97 ; value =';'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 344 ; length = 3 line = 12 ; column = 0 ; value ='tau'; }
|
||||
{kind = TOKEN_COLON; ; index = 348 ; length = 1 line = 12 ; column = 4 ; value =':'; }
|
||||
{kind = TOKEN_ASSIGN; ; index = 349 ; length = 1 line = 12 ; column = 5 ; value ='='; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 351 ; length = 12 line = 12 ; column = 7 ; value ='3.141593'; }
|
||||
{kind = TOKEN_STAR; ; index = 364 ; length = 1 line = 12 ; column = 20 ; value ='*'; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 366 ; length = 3 line = 12 ; column = 22 ; value ='2'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 369 ; length = 1 line = 12 ; column = 25 ; value =';'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 373 ; length = 1 line = 13 ; column = 0 ; value ='a'; }
|
||||
{kind = TOKEN_COLON; ; index = 375 ; length = 1 line = 13 ; column = 2 ; value =':'; }
|
||||
{kind = TOKEN_ASSIGN; ; index = 376 ; length = 1 line = 13 ; column = 3 ; value ='='; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 378 ; length = 4 line = 13 ; column = 5 ; value ='atan'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 382 ; length = 1 line = 13 ; column = 9 ; value ='('; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 383 ; length = 1 line = 13 ; column = 10 ; value ='p'; }
|
||||
{kind = TOKEN_DOT; ; index = 384 ; length = 1 line = 13 ; column = 11 ; value ='.'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 385 ; length = 1 line = 13 ; column = 12 ; value ='x'; }
|
||||
{kind = TOKEN_COMMA; ; index = 386 ; length = 1 line = 13 ; column = 13 ; value =','; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 388 ; length = 1 line = 13 ; column = 15 ; value ='p'; }
|
||||
{kind = TOKEN_DOT; ; index = 389 ; length = 1 line = 13 ; column = 16 ; value ='.'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 390 ; length = 1 line = 13 ; column = 17 ; value ='y'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 391 ; length = 1 line = 13 ; column = 18 ; value =')'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 392 ; length = 1 line = 13 ; column = 19 ; value =';'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 396 ; length = 1 line = 14 ; column = 0 ; value ='r'; }
|
||||
{kind = TOKEN_COLON; ; index = 398 ; length = 1 line = 14 ; column = 2 ; value =':'; }
|
||||
{kind = TOKEN_ASSIGN; ; index = 399 ; length = 1 line = 14 ; column = 3 ; value ='='; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 401 ; length = 6 line = 14 ; column = 5 ; value ='length'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 407 ; length = 1 line = 14 ; column = 11 ; value ='('; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 408 ; length = 1 line = 14 ; column = 12 ; value ='p'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 409 ; length = 1 line = 14 ; column = 13 ; value =')'; }
|
||||
{kind = TOKEN_STAR; ; index = 411 ; length = 1 line = 14 ; column = 15 ; value ='*'; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 413 ; length = 4 line = 14 ; column = 17 ; value ='0.75'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 417 ; length = 1 line = 14 ; column = 21 ; value =';'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 423 ; length = 2 line = 16 ; column = 0 ; value ='uv'; }
|
||||
{kind = TOKEN_COLON; ; index = 426 ; length = 1 line = 16 ; column = 3 ; value =':'; }
|
||||
{kind = TOKEN_ASSIGN; ; index = 427 ; length = 1 line = 16 ; column = 4 ; value ='='; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 429 ; length = 6 line = 16 ; column = 6 ; value ='float2'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 435 ; length = 1 line = 16 ; column = 12 ; value ='('; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 436 ; length = 1 line = 16 ; column = 13 ; value ='a'; }
|
||||
{kind = TOKEN_SLASH; ; index = 438 ; length = 1 line = 16 ; column = 15 ; value ='/'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 440 ; length = 3 line = 16 ; column = 17 ; value ='tau'; }
|
||||
{kind = TOKEN_COMMA; ; index = 443 ; length = 1 line = 16 ; column = 20 ; value =','; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 445 ; length = 1 line = 16 ; column = 22 ; value ='r'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 446 ; length = 1 line = 16 ; column = 23 ; value =')'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 447 ; length = 1 line = 16 ; column = 24 ; value =';'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 453 ; length = 5 line = 18 ; column = 0 ; value ='x_col'; }
|
||||
{kind = TOKEN_COLON; ; index = 459 ; length = 1 line = 18 ; column = 6 ; value =':'; }
|
||||
{kind = TOKEN_ASSIGN; ; index = 460 ; length = 1 line = 18 ; column = 7 ; value ='='; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 462 ; length = 1 line = 18 ; column = 9 ; value ='('; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 463 ; length = 2 line = 18 ; column = 10 ; value ='uv'; }
|
||||
{kind = TOKEN_DOT; ; index = 465 ; length = 1 line = 18 ; column = 12 ; value ='.'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 466 ; length = 1 line = 18 ; column = 13 ; value ='x'; }
|
||||
{kind = TOKEN_MINUS; ; index = 468 ; length = 1 line = 18 ; column = 15 ; value ='-'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 470 ; length = 1 line = 18 ; column = 17 ; value ='('; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 471 ; length = 1 line = 18 ; column = 18 ; value ='p'; }
|
||||
{kind = TOKEN_DOT; ; index = 472 ; length = 1 line = 18 ; column = 19 ; value ='.'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 473 ; length = 4 line = 18 ; column = 20 ; value ='time'; }
|
||||
{kind = TOKEN_SLASH; ; index = 478 ; length = 1 line = 18 ; column = 25 ; value ='/'; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 480 ; length = 3 line = 18 ; column = 27 ; value ='3'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 483 ; length = 1 line = 18 ; column = 30 ; value =')'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 484 ; length = 1 line = 18 ; column = 31 ; value =')'; }
|
||||
{kind = TOKEN_STAR; ; index = 486 ; length = 1 line = 18 ; column = 33 ; value ='*'; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 488 ; length = 3 line = 18 ; column = 35 ; value ='3'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 491 ; length = 1 line = 18 ; column = 38 ; value =';'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 495 ; length = 5 line = 19 ; column = 0 ; value ='x_col'; }
|
||||
{kind = TOKEN_ASSIGN; ; index = 501 ; length = 1 line = 19 ; column = 6 ; value ='='; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 503 ; length = 3 line = 19 ; column = 8 ; value ='mod'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 506 ; length = 1 line = 19 ; column = 11 ; value ='('; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 507 ; length = 5 line = 19 ; column = 12 ; value ='x_col'; }
|
||||
{kind = TOKEN_COMMA; ; index = 512 ; length = 1 line = 19 ; column = 17 ; value =','; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 514 ; length = 3 line = 19 ; column = 19 ; value ='3'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 517 ; length = 1 line = 19 ; column = 22 ; value =')'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 518 ; length = 1 line = 19 ; column = 23 ; value =';'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 522 ; length = 10 line = 20 ; column = 0 ; value ='hor_colour'; }
|
||||
{kind = TOKEN_COLON; ; index = 533 ; length = 1 line = 20 ; column = 11 ; value =':'; }
|
||||
{kind = TOKEN_ASSIGN; ; index = 534 ; length = 1 line = 20 ; column = 12 ; value ='='; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 536 ; length = 6 line = 20 ; column = 14 ; value ='float3'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 542 ; length = 1 line = 20 ; column = 20 ; value ='('; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 543 ; length = 4 line = 20 ; column = 21 ; value ='0.25'; }
|
||||
{kind = TOKEN_COMMA; ; index = 547 ; length = 1 line = 20 ; column = 25 ; value =','; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 549 ; length = 4 line = 20 ; column = 27 ; value ='0.25'; }
|
||||
{kind = TOKEN_COMMA; ; index = 553 ; length = 1 line = 20 ; column = 31 ; value =','; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 555 ; length = 4 line = 20 ; column = 33 ; value ='0.25'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 559 ; length = 1 line = 20 ; column = 37 ; value =')'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 560 ; length = 1 line = 20 ; column = 38 ; value =';'; }
|
||||
{kind = TOKEN_IF; ; index = 567 ; length = 2 line = 22 ; column = 0 ; value ='if'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 570 ; length = 5 line = 22 ; column = 3 ; value ='x_col'; }
|
||||
{kind = TOKEN_LESS; ; index = 576 ; length = 1 line = 22 ; column = 9 ; value ='<'; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 578 ; length = 3 line = 22 ; column = 11 ; value ='1'; }
|
||||
{kind = TOKEN_LEFTBRACE; ; index = 582 ; length = 1 line = 22 ; column = 15 ; value ='{'; }
|
||||
{kind = TOKEN_RIGHTBRACE; ; index = 587 ; length = 1 line = 24 ; column = 0 ; value ='}'; }
|
||||
{kind = TOKEN_ELSE; ; index = 589 ; length = 4 line = 24 ; column = 2 ; value ='else'; }
|
||||
{kind = TOKEN_IF; ; index = 594 ; length = 2 line = 24 ; column = 7 ; value ='if'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 597 ; length = 5 line = 24 ; column = 10 ; value ='x_col'; }
|
||||
{kind = TOKEN_LESS; ; index = 603 ; length = 1 line = 24 ; column = 16 ; value ='<'; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 605 ; length = 3 line = 24 ; column = 18 ; value ='2'; }
|
||||
{kind = TOKEN_LEFTBRACE; ; index = 609 ; length = 1 line = 24 ; column = 22 ; value ='{'; }
|
||||
{kind = TOKEN_RIGHTBRACE; ; index = 615 ; length = 1 line = 26 ; column = 0 ; value ='}'; }
|
||||
{kind = TOKEN_ELSE; ; index = 617 ; length = 4 line = 26 ; column = 2 ; value ='else'; }
|
||||
{kind = TOKEN_LEFTBRACE; ; index = 622 ; length = 1 line = 26 ; column = 7 ; value ='{'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 626 ; length = 5 line = 27 ; column = 0 ; value ='x_col'; }
|
||||
{kind = TOKEN_MINUSEQUALS; ; index = 632 ; length = 2 line = 27 ; column = 6 ; value ='-='; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 635 ; length = 3 line = 27 ; column = 9 ; value ='2'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 638 ; length = 1 line = 27 ; column = 12 ; value =';'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 642 ; length = 10 line = 28 ; column = 0 ; value ='hor_colour'; }
|
||||
{kind = TOKEN_DOT; ; index = 652 ; length = 1 line = 28 ; column = 10 ; value ='.'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 653 ; length = 1 line = 28 ; column = 11 ; value ='b'; }
|
||||
{kind = TOKEN_PLUSEQUALS; ; index = 655 ; length = 2 line = 28 ; column = 13 ; value ='+='; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 658 ; length = 3 line = 28 ; column = 16 ; value ='1'; }
|
||||
{kind = TOKEN_MINUS; ; index = 662 ; length = 1 line = 28 ; column = 20 ; value ='-'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 664 ; length = 5 line = 28 ; column = 22 ; value ='x_col'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 669 ; length = 1 line = 28 ; column = 27 ; value =';'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 673 ; length = 10 line = 29 ; column = 0 ; value ='hor_colour'; }
|
||||
{kind = TOKEN_DOT; ; index = 683 ; length = 1 line = 29 ; column = 10 ; value ='.'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 684 ; length = 1 line = 29 ; column = 11 ; value ='r'; }
|
||||
{kind = TOKEN_PLUSEQUALS; ; index = 686 ; length = 2 line = 29 ; column = 13 ; value ='+='; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 689 ; length = 5 line = 29 ; column = 16 ; value ='x_col'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 694 ; length = 1 line = 29 ; column = 21 ; value =';'; }
|
||||
{kind = TOKEN_RIGHTBRACE; ; index = 697 ; length = 1 line = 30 ; column = 0 ; value ='}'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 702 ; length = 2 line = 32 ; column = 0 ; value ='uv'; }
|
||||
{kind = TOKEN_ASSIGN; ; index = 705 ; length = 1 line = 32 ; column = 3 ; value ='='; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 707 ; length = 1 line = 32 ; column = 5 ; value ='('; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 708 ; length = 3 line = 32 ; column = 6 ; value ='2'; }
|
||||
{kind = TOKEN_STAR; ; index = 712 ; length = 1 line = 32 ; column = 10 ; value ='*'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 714 ; length = 2 line = 32 ; column = 12 ; value ='uv'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 716 ; length = 1 line = 32 ; column = 14 ; value =')'; }
|
||||
{kind = TOKEN_MINUS; ; index = 718 ; length = 1 line = 32 ; column = 16 ; value ='-'; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 720 ; length = 3 line = 32 ; column = 18 ; value ='1'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 723 ; length = 1 line = 32 ; column = 21 ; value =';'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 726 ; length = 10 line = 33 ; column = 0 ; value ='beam_width'; }
|
||||
{kind = TOKEN_ASSIGN; ; index = 737 ; length = 1 line = 33 ; column = 11 ; value ='='; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 739 ; length = 1 line = 33 ; column = 13 ; value ='('; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 740 ; length = 3 line = 33 ; column = 14 ; value ='0.7'; }
|
||||
{kind = TOKEN_PLUS; ; index = 743 ; length = 1 line = 33 ; column = 17 ; value ='+'; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 744 ; length = 3 line = 33 ; column = 18 ; value ='0.5'; }
|
||||
{kind = TOKEN_STAR; ; index = 747 ; length = 1 line = 33 ; column = 21 ; value ='*'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 748 ; length = 3 line = 33 ; column = 22 ; value ='cos'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 751 ; length = 1 line = 33 ; column = 25 ; value ='('; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 752 ; length = 2 line = 33 ; column = 26 ; value ='uv'; }
|
||||
{kind = TOKEN_DOT; ; index = 754 ; length = 1 line = 33 ; column = 28 ; value ='.'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 755 ; length = 1 line = 33 ; column = 29 ; value ='x'; }
|
||||
{kind = TOKEN_STAR; ; index = 756 ; length = 1 line = 33 ; column = 30 ; value ='*'; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 757 ; length = 4 line = 33 ; column = 31 ; value ='10'; }
|
||||
{kind = TOKEN_STAR; ; index = 761 ; length = 1 line = 33 ; column = 35 ; value ='*'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 762 ; length = 3 line = 33 ; column = 36 ; value ='tau'; }
|
||||
{kind = TOKEN_STAR; ; index = 765 ; length = 1 line = 33 ; column = 39 ; value ='*'; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 766 ; length = 4 line = 33 ; column = 40 ; value ='0.15'; }
|
||||
{kind = TOKEN_STAR; ; index = 770 ; length = 1 line = 33 ; column = 44 ; value ='*'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 771 ; length = 5 line = 33 ; column = 45 ; value ='clamp'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 776 ; length = 1 line = 33 ; column = 50 ; value ='('; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 777 ; length = 5 line = 33 ; column = 51 ; value ='floor'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 782 ; length = 1 line = 33 ; column = 56 ; value ='('; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 783 ; length = 3 line = 33 ; column = 57 ; value ='5'; }
|
||||
{kind = TOKEN_PLUS; ; index = 787 ; length = 1 line = 33 ; column = 61 ; value ='+'; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 789 ; length = 4 line = 33 ; column = 63 ; value ='10'; }
|
||||
{kind = TOKEN_STAR; ; index = 793 ; length = 1 line = 33 ; column = 67 ; value ='*'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 794 ; length = 3 line = 33 ; column = 68 ; value ='cos'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 797 ; length = 1 line = 33 ; column = 71 ; value ='('; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 798 ; length = 5 line = 33 ; column = 72 ; value ='iTime'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 803 ; length = 1 line = 33 ; column = 77 ; value =')'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 804 ; length = 1 line = 33 ; column = 78 ; value =')'; }
|
||||
{kind = TOKEN_COMMA; ; index = 805 ; length = 1 line = 33 ; column = 79 ; value =','; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 807 ; length = 3 line = 33 ; column = 81 ; value ='0'; }
|
||||
{kind = TOKEN_COMMA; ; index = 810 ; length = 1 line = 33 ; column = 84 ; value =','; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 812 ; length = 4 line = 33 ; column = 86 ; value ='10'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 816 ; length = 1 line = 33 ; column = 90 ; value =')'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 817 ; length = 1 line = 33 ; column = 91 ; value =')'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 818 ; length = 1 line = 33 ; column = 92 ; value =')'; }
|
||||
{kind = TOKEN_STAR; ; index = 820 ; length = 1 line = 33 ; column = 94 ; value ='*'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 822 ; length = 3 line = 33 ; column = 96 ; value ='abs'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 825 ; length = 1 line = 33 ; column = 99 ; value ='('; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 826 ; length = 3 line = 33 ; column = 100 ; value ='1'; }
|
||||
{kind = TOKEN_SLASH; ; index = 830 ; length = 1 line = 33 ; column = 104 ; value ='/'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 832 ; length = 1 line = 33 ; column = 106 ; value ='('; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 833 ; length = 4 line = 33 ; column = 107 ; value ='30'; }
|
||||
{kind = TOKEN_STAR; ; index = 838 ; length = 1 line = 33 ; column = 112 ; value ='*'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 840 ; length = 2 line = 33 ; column = 114 ; value ='uv'; }
|
||||
{kind = TOKEN_DOT; ; index = 842 ; length = 1 line = 33 ; column = 116 ; value ='.'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 843 ; length = 1 line = 33 ; column = 117 ; value ='y'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 844 ; length = 1 line = 33 ; column = 118 ; value =')'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 845 ; length = 1 line = 33 ; column = 119 ; value =')'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 846 ; length = 1 line = 33 ; column = 120 ; value =';'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 849 ; length = 8 line = 34 ; column = 0 ; value ='hor_beam'; }
|
||||
{kind = TOKEN_ASSIGN; ; index = 858 ; length = 1 line = 34 ; column = 9 ; value ='='; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 860 ; length = 6 line = 34 ; column = 11 ; value ='float3'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 866 ; length = 1 line = 34 ; column = 17 ; value ='('; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 867 ; length = 10 line = 34 ; column = 18 ; value ='beam_width'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 877 ; length = 1 line = 34 ; column = 28 ; value =')'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 878 ; length = 1 line = 34 ; column = 29 ; value =';'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 881 ; length = 6 line = 35 ; column = 0 ; value ='result'; }
|
||||
{kind = TOKEN_COLON; ; index = 888 ; length = 1 line = 35 ; column = 7 ; value =':'; }
|
||||
{kind = TOKEN_ASSIGN; ; index = 889 ; length = 1 line = 35 ; column = 8 ; value ='='; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 891 ; length = 6 line = 35 ; column = 10 ; value ='float4'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 897 ; length = 1 line = 35 ; column = 16 ; value ='('; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 898 ; length = 1 line = 35 ; column = 17 ; value ='('; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 899 ; length = 1 line = 35 ; column = 18 ; value ='('; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 900 ; length = 8 line = 35 ; column = 19 ; value ='hor_beam'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 908 ; length = 1 line = 35 ; column = 27 ; value =')'; }
|
||||
{kind = TOKEN_STAR; ; index = 910 ; length = 1 line = 35 ; column = 29 ; value ='*'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 912 ; length = 10 line = 35 ; column = 31 ; value ='hor_colour'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 922 ; length = 1 line = 35 ; column = 41 ; value =')'; }
|
||||
{kind = TOKEN_COMMA; ; index = 923 ; length = 1 line = 35 ; column = 42 ; value =','; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 925 ; length = 3 line = 35 ; column = 44 ; value ='1'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 928 ; length = 1 line = 35 ; column = 47 ; value =')'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 929 ; length = 1 line = 35 ; column = 48 ; value =';'; }
|
||||
{kind = TOKEN_RIGHTBRACE; ; index = 932 ; length = 1 line = 36 ; column = 0 ; value ='}'; }
|
||||
{kind = TOKEN_EOF; ; index = 935 ; length = 0 line = 37 ; column = 0 ; value =''; }
|
||||
@@ -1,66 +1,82 @@
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 0 ; length = 11 line = 1 ; column = 0 ; value ='Camera_Data'; }
|
||||
{kind = TOKEN_DOUBLECOLON; ; index = 12 ; length = 2 line = 1 ; column = 12 ; value ='::'; }
|
||||
{kind = TOKEN_CONSTANT_BUFFER; ; index = 15 ; length = 15 line = 1 ; column = 15 ; value ='constant_buffer'; }
|
||||
{kind = TOKEN_LEFTBRACE; ; index = 31 ; length = 1 line = 1 ; column = 31 ; value ='{'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 35 ; length = 10 line = 2 ; column = 0 ; value ='projection'; }
|
||||
{kind = TOKEN_COLON; ; index = 46 ; length = 1 line = 2 ; column = 11 ; value =':'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 48 ; length = 8 line = 2 ; column = 13 ; value ='float4x4'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 56 ; length = 1 line = 2 ; column = 21 ; value =';'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 60 ; length = 4 line = 3 ; column = 0 ; value ='view'; }
|
||||
{kind = TOKEN_COLON; ; index = 71 ; length = 1 line = 3 ; column = 11 ; value =':'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 73 ; length = 8 line = 3 ; column = 13 ; value ='float4x4'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 81 ; length = 1 line = 3 ; column = 21 ; value =';'; }
|
||||
{kind = TOKEN_RIGHTBRACE; ; index = 84 ; length = 1 line = 4 ; column = 0 ; value ='}'; }
|
||||
{kind = TOKEN_VERTEX; ; index = 89 ; length = 6 line = 6 ; column = 0 ; value ='vertex'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 96 ; length = 4 line = 6 ; column = 7 ; value ='main'; }
|
||||
{kind = TOKEN_DOUBLECOLON; ; index = 101 ; length = 2 line = 6 ; column = 12 ; value ='::'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 104 ; length = 1 line = 6 ; column = 15 ; value ='('; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 105 ; length = 3 line = 6 ; column = 16 ; value ='pos'; }
|
||||
{kind = TOKEN_COLON; ; index = 109 ; length = 1 line = 6 ; column = 20 ; value =':'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 111 ; length = 6 line = 6 ; column = 22 ; value ='float4'; }
|
||||
{kind = TOKEN_AT; ; index = 118 ; length = 1 line = 6 ; column = 29 ; value ='@'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 119 ; length = 8 line = 6 ; column = 30 ; value ='position'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 127 ; length = 1 line = 6 ; column = 38 ; value =')'; }
|
||||
{kind = TOKEN_ARROW; ; index = 129 ; length = 2 line = 6 ; column = 40 ; value ='->'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 132 ; length = 6 line = 6 ; column = 43 ; value ='float4'; }
|
||||
{kind = TOKEN_AT; ; index = 139 ; length = 1 line = 6 ; column = 50 ; value ='@'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 140 ; length = 8 line = 6 ; column = 51 ; value ='position'; }
|
||||
{kind = TOKEN_LEFTBRACE; ; index = 149 ; length = 1 line = 6 ; column = 60 ; value ='{'; }
|
||||
{kind = TOKEN_RETURN; ; index = 153 ; length = 6 line = 7 ; column = 0 ; value ='return'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 160 ; length = 3 line = 7 ; column = 7 ; value ='mul'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 163 ; length = 1 line = 7 ; column = 10 ; value ='('; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 164 ; length = 10 line = 7 ; column = 11 ; value ='projection'; }
|
||||
{kind = TOKEN_COMMA; ; index = 174 ; length = 1 line = 7 ; column = 21 ; value =','; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 176 ; length = 3 line = 7 ; column = 23 ; value ='mul'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 179 ; length = 1 line = 7 ; column = 26 ; value ='('; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 180 ; length = 4 line = 7 ; column = 27 ; value ='view'; }
|
||||
{kind = TOKEN_COMMA; ; index = 184 ; length = 1 line = 7 ; column = 31 ; value =','; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 186 ; length = 3 line = 7 ; column = 33 ; value ='pos'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 189 ; length = 1 line = 7 ; column = 36 ; value =')'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 190 ; length = 1 line = 7 ; column = 37 ; value =')'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 191 ; length = 1 line = 7 ; column = 38 ; value =';'; }
|
||||
{kind = TOKEN_RIGHTBRACE; ; index = 194 ; length = 1 line = 8 ; column = 0 ; value ='}'; }
|
||||
{kind = TOKEN_PIXEL; ; index = 199 ; length = 5 line = 10 ; column = 0 ; value ='pixel'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 205 ; length = 4 line = 10 ; column = 6 ; value ='main'; }
|
||||
{kind = TOKEN_DOUBLECOLON; ; index = 210 ; length = 2 line = 10 ; column = 11 ; value ='::'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 213 ; length = 1 line = 10 ; column = 14 ; value ='('; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 214 ; length = 1 line = 10 ; column = 15 ; value =')'; }
|
||||
{kind = TOKEN_ARROW; ; index = 216 ; length = 2 line = 10 ; column = 17 ; value ='->'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 219 ; length = 6 line = 10 ; column = 20 ; value ='float4'; }
|
||||
{kind = TOKEN_AT; ; index = 226 ; length = 1 line = 10 ; column = 27 ; value ='@'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 227 ; length = 6 line = 10 ; column = 28 ; value ='target'; }
|
||||
{kind = TOKEN_LEFTBRACE; ; index = 234 ; length = 1 line = 10 ; column = 35 ; value ='{'; }
|
||||
{kind = TOKEN_RETURN; ; index = 238 ; length = 6 line = 11 ; column = 0 ; value ='return'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 245 ; length = 5 line = 11 ; column = 7 ; value ='float'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 250 ; length = 1 line = 11 ; column = 12 ; value ='('; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 251 ; length = 3 line = 11 ; column = 13 ; value ='0.5'; }
|
||||
{kind = TOKEN_COMMA; ; index = 254 ; length = 1 line = 11 ; column = 16 ; value =','; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 256 ; length = 3 line = 11 ; column = 18 ; value ='0.5'; }
|
||||
{kind = TOKEN_COMMA; ; index = 259 ; length = 1 line = 11 ; column = 21 ; value =','; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 261 ; length = 3 line = 11 ; column = 23 ; value ='0.5'; }
|
||||
{kind = TOKEN_COMMA; ; index = 264 ; length = 1 line = 11 ; column = 26 ; value =','; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 266 ; length = 3 line = 11 ; column = 28 ; value ='1'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 269 ; length = 1 line = 11 ; column = 31 ; value =')'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 270 ; length = 1 line = 11 ; column = 32 ; value =';'; }
|
||||
{kind = TOKEN_RIGHTBRACE; ; index = 273 ; length = 1 line = 12 ; column = 0 ; value ='}'; }
|
||||
{kind = TOKEN_EOF; ; index = 276 ; length = 0 line = 13 ; column = 0 ; value =''; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 0 ; length = 6 line = 1 ; column = 0 ; value ='camera'; }
|
||||
{kind = TOKEN_DOUBLECOLON; ; index = 7 ; length = 2 line = 1 ; column = 7 ; value ='::'; }
|
||||
{kind = TOKEN_CONSTANT_BUFFER; ; index = 10 ; length = 15 line = 1 ; column = 10 ; value ='constant_buffer'; }
|
||||
{kind = TOKEN_LEFTBRACE; ; index = 26 ; length = 1 line = 1 ; column = 26 ; value ='{'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 30 ; length = 10 line = 2 ; column = 0 ; value ='projection'; }
|
||||
{kind = TOKEN_COLON; ; index = 41 ; length = 1 line = 2 ; column = 11 ; value =':'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 43 ; length = 8 line = 2 ; column = 13 ; value ='float4x4'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 51 ; length = 1 line = 2 ; column = 21 ; value =';'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 55 ; length = 4 line = 3 ; column = 0 ; value ='view'; }
|
||||
{kind = TOKEN_COLON; ; index = 66 ; length = 1 line = 3 ; column = 11 ; value =':'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 68 ; length = 8 line = 3 ; column = 13 ; value ='float4x4'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 76 ; length = 1 line = 3 ; column = 21 ; value =';'; }
|
||||
{kind = TOKEN_RIGHTBRACE; ; index = 79 ; length = 1 line = 4 ; column = 0 ; value ='}'; }
|
||||
{kind = TOKEN_VERTEX; ; index = 84 ; length = 6 line = 6 ; column = 0 ; value ='vertex'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 91 ; length = 4 line = 6 ; column = 7 ; value ='main'; }
|
||||
{kind = TOKEN_DOUBLECOLON; ; index = 96 ; length = 2 line = 6 ; column = 12 ; value ='::'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 99 ; length = 1 line = 6 ; column = 15 ; value ='('; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 100 ; length = 3 line = 6 ; column = 16 ; value ='pos'; }
|
||||
{kind = TOKEN_COLON; ; index = 104 ; length = 1 line = 6 ; column = 20 ; value =':'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 106 ; length = 6 line = 6 ; column = 22 ; value ='float4'; }
|
||||
{kind = TOKEN_AT; ; index = 113 ; length = 1 line = 6 ; column = 29 ; value ='@'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 114 ; length = 8 line = 6 ; column = 30 ; value ='position'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 122 ; length = 1 line = 6 ; column = 38 ; value =')'; }
|
||||
{kind = TOKEN_ARROW; ; index = 124 ; length = 2 line = 6 ; column = 40 ; value ='->'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 127 ; length = 6 line = 6 ; column = 43 ; value ='float4'; }
|
||||
{kind = TOKEN_AT; ; index = 134 ; length = 1 line = 6 ; column = 50 ; value ='@'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 135 ; length = 8 line = 6 ; column = 51 ; value ='position'; }
|
||||
{kind = TOKEN_LEFTBRACE; ; index = 144 ; length = 1 line = 6 ; column = 60 ; value ='{'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 148 ; length = 2 line = 7 ; column = 0 ; value ='mv'; }
|
||||
{kind = TOKEN_COLON; ; index = 151 ; length = 1 line = 7 ; column = 3 ; value =':'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 153 ; length = 6 line = 7 ; column = 5 ; value ='float4'; }
|
||||
{kind = TOKEN_ASSIGN; ; index = 160 ; length = 1 line = 7 ; column = 12 ; value ='='; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 162 ; length = 3 line = 7 ; column = 14 ; value ='mul'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 165 ; length = 1 line = 7 ; column = 17 ; value ='('; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 166 ; length = 6 line = 7 ; column = 18 ; value ='camera'; }
|
||||
{kind = TOKEN_DOT; ; index = 172 ; length = 1 line = 7 ; column = 24 ; value ='.'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 173 ; length = 4 line = 7 ; column = 25 ; value ='view'; }
|
||||
{kind = TOKEN_COMMA; ; index = 177 ; length = 1 line = 7 ; column = 29 ; value =','; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 179 ; length = 3 line = 7 ; column = 31 ; value ='pos'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 182 ; length = 1 line = 7 ; column = 34 ; value =')'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 183 ; length = 1 line = 7 ; column = 35 ; value =';'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 187 ; length = 3 line = 8 ; column = 0 ; value ='mvp'; }
|
||||
{kind = TOKEN_COLON; ; index = 191 ; length = 1 line = 8 ; column = 4 ; value =':'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 193 ; length = 6 line = 8 ; column = 6 ; value ='float4'; }
|
||||
{kind = TOKEN_ASSIGN; ; index = 200 ; length = 1 line = 8 ; column = 13 ; value ='='; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 202 ; length = 3 line = 8 ; column = 15 ; value ='mul'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 205 ; length = 1 line = 8 ; column = 18 ; value ='('; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 206 ; length = 6 line = 8 ; column = 19 ; value ='camera'; }
|
||||
{kind = TOKEN_DOT; ; index = 212 ; length = 1 line = 8 ; column = 25 ; value ='.'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 213 ; length = 10 line = 8 ; column = 26 ; value ='projection'; }
|
||||
{kind = TOKEN_COMMA; ; index = 223 ; length = 1 line = 8 ; column = 36 ; value =','; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 225 ; length = 2 line = 8 ; column = 38 ; value ='mv'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 227 ; length = 1 line = 8 ; column = 40 ; value =')'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 228 ; length = 1 line = 8 ; column = 41 ; value =';'; }
|
||||
{kind = TOKEN_RETURN; ; index = 232 ; length = 6 line = 9 ; column = 0 ; value ='return'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 239 ; length = 3 line = 9 ; column = 7 ; value ='mvp'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 242 ; length = 1 line = 9 ; column = 10 ; value =';'; }
|
||||
{kind = TOKEN_RIGHTBRACE; ; index = 245 ; length = 1 line = 10 ; column = 0 ; value ='}'; }
|
||||
{kind = TOKEN_PIXEL; ; index = 250 ; length = 5 line = 12 ; column = 0 ; value ='pixel'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 256 ; length = 4 line = 12 ; column = 6 ; value ='main'; }
|
||||
{kind = TOKEN_DOUBLECOLON; ; index = 261 ; length = 2 line = 12 ; column = 11 ; value ='::'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 264 ; length = 1 line = 12 ; column = 14 ; value ='('; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 265 ; length = 1 line = 12 ; column = 15 ; value =')'; }
|
||||
{kind = TOKEN_ARROW; ; index = 267 ; length = 2 line = 12 ; column = 17 ; value ='->'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 270 ; length = 6 line = 12 ; column = 20 ; value ='float4'; }
|
||||
{kind = TOKEN_AT; ; index = 277 ; length = 1 line = 12 ; column = 27 ; value ='@'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 278 ; length = 6 line = 12 ; column = 28 ; value ='target'; }
|
||||
{kind = TOKEN_LEFTBRACE; ; index = 285 ; length = 1 line = 12 ; column = 35 ; value ='{'; }
|
||||
{kind = TOKEN_RETURN; ; index = 289 ; length = 6 line = 13 ; column = 0 ; value ='return'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 296 ; length = 6 line = 13 ; column = 7 ; value ='float4'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 302 ; length = 1 line = 13 ; column = 13 ; value ='('; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 303 ; length = 3 line = 13 ; column = 14 ; value ='0.5'; }
|
||||
{kind = TOKEN_COMMA; ; index = 306 ; length = 1 line = 13 ; column = 17 ; value =','; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 308 ; length = 3 line = 13 ; column = 19 ; value ='0.5'; }
|
||||
{kind = TOKEN_COMMA; ; index = 311 ; length = 1 line = 13 ; column = 22 ; value =','; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 313 ; length = 3 line = 13 ; column = 24 ; value ='0.5'; }
|
||||
{kind = TOKEN_COMMA; ; index = 316 ; length = 1 line = 13 ; column = 27 ; value =','; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 318 ; length = 3 line = 13 ; column = 29 ; value ='1'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 321 ; length = 1 line = 13 ; column = 32 ; value =')'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 322 ; length = 1 line = 13 ; column = 33 ; value =';'; }
|
||||
{kind = TOKEN_RIGHTBRACE; ; index = 325 ; length = 1 line = 14 ; column = 0 ; value ='}'; }
|
||||
{kind = TOKEN_EOF; ; index = 328 ; length = 0 line = 15 ; column = 0 ; value =''; }
|
||||
|
||||
81
test/lex/custom_hint.golden
Normal file
81
test/lex/custom_hint.golden
Normal file
@@ -0,0 +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 =''; }
|
||||
39
test/lex/else_if_after_else.golden
Normal file
39
test/lex/else_if_after_else.golden
Normal file
@@ -0,0 +1,39 @@
|
||||
{kind = TOKEN_VERTEX; ; index = 0 ; length = 6 line = 1 ; column = 0 ; value ='vertex'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 7 ; length = 4 line = 1 ; column = 7 ; value ='main'; }
|
||||
{kind = TOKEN_DOUBLECOLON; ; index = 12 ; length = 2 line = 1 ; column = 12 ; value ='::'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 15 ; length = 1 line = 1 ; column = 15 ; value ='('; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 16 ; length = 3 line = 1 ; column = 16 ; value ='pos'; }
|
||||
{kind = TOKEN_COLON; ; index = 20 ; length = 1 line = 1 ; column = 20 ; value =':'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 22 ; length = 6 line = 1 ; column = 22 ; value ='float3'; }
|
||||
{kind = TOKEN_AT; ; index = 29 ; length = 1 line = 1 ; column = 29 ; value ='@'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 30 ; length = 8 line = 1 ; column = 30 ; value ='position'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 38 ; length = 1 line = 1 ; column = 38 ; value =')'; }
|
||||
{kind = TOKEN_ARROW; ; index = 40 ; length = 2 line = 1 ; column = 40 ; value ='->'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 43 ; length = 6 line = 1 ; column = 43 ; value ='float4'; }
|
||||
{kind = TOKEN_AT; ; index = 50 ; length = 1 line = 1 ; column = 50 ; value ='@'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 51 ; length = 8 line = 1 ; column = 51 ; value ='position'; }
|
||||
{kind = TOKEN_LEFTBRACE; ; index = 60 ; length = 1 line = 1 ; column = 60 ; value ='{'; }
|
||||
{kind = TOKEN_IF; ; index = 64 ; length = 2 line = 2 ; column = 0 ; value ='if'; }
|
||||
{kind = TOKEN_INTLITERAL; ; index = 67 ; length = 1 line = 2 ; column = 3 ; value ='0'; }
|
||||
{kind = TOKEN_GREATER; ; index = 69 ; length = 1 line = 2 ; column = 5 ; value ='>'; }
|
||||
{kind = TOKEN_INTLITERAL; ; index = 71 ; length = 3 line = 2 ; column = 7 ; value ='100'; }
|
||||
{kind = TOKEN_LEFTBRACE; ; index = 75 ; length = 1 line = 2 ; column = 11 ; value ='{'; }
|
||||
{kind = TOKEN_RIGHTBRACE; ; index = 83 ; length = 1 line = 4 ; column = 0 ; value ='}'; }
|
||||
{kind = TOKEN_ELSE; ; index = 85 ; length = 4 line = 4 ; column = 2 ; value ='else'; }
|
||||
{kind = TOKEN_LEFTBRACE; ; index = 90 ; length = 1 line = 4 ; column = 7 ; value ='{'; }
|
||||
{kind = TOKEN_RIGHTBRACE; ; index = 99 ; length = 1 line = 6 ; column = 4 ; value ='}'; }
|
||||
{kind = TOKEN_ELSE; ; index = 101 ; length = 4 line = 6 ; column = 6 ; value ='else'; }
|
||||
{kind = TOKEN_IF; ; index = 106 ; length = 2 line = 6 ; column = 11 ; value ='if'; }
|
||||
{kind = TOKEN_INTLITERAL; ; index = 109 ; length = 1 line = 6 ; column = 14 ; value ='0'; }
|
||||
{kind = TOKEN_GREATER; ; index = 111 ; length = 1 line = 6 ; column = 16 ; value ='>'; }
|
||||
{kind = TOKEN_INTLITERAL; ; index = 113 ; length = 3 line = 6 ; column = 18 ; value ='200'; }
|
||||
{kind = TOKEN_LEFTBRACE; ; index = 117 ; length = 1 line = 6 ; column = 22 ; value ='{'; }
|
||||
{kind = TOKEN_RIGHTBRACE; ; index = 123 ; length = 1 line = 8 ; column = 0 ; value ='}'; }
|
||||
{kind = TOKEN_RETURN; ; index = 127 ; length = 6 line = 9 ; column = 0 ; value ='return'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 134 ; length = 6 line = 9 ; column = 7 ; value ='float4'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 140 ; length = 1 line = 9 ; column = 13 ; value ='('; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 141 ; length = 3 line = 9 ; column = 14 ; value ='0'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 144 ; length = 1 line = 9 ; column = 17 ; value =')'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 145 ; length = 1 line = 9 ; column = 18 ; value =';'; }
|
||||
{kind = TOKEN_RIGHTBRACE; ; index = 148 ; length = 1 line = 10 ; column = 0 ; value ='}'; }
|
||||
{kind = TOKEN_EOF; ; index = 151 ; length = 0 line = 11 ; column = 0 ; value =''; }
|
||||
35
test/lex/float_if_cond.golden
Normal file
35
test/lex/float_if_cond.golden
Normal file
@@ -0,0 +1,35 @@
|
||||
{kind = TOKEN_VERTEX; ; index = 0 ; length = 6 line = 1 ; column = 0 ; value ='vertex'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 7 ; length = 4 line = 1 ; column = 7 ; value ='main'; }
|
||||
{kind = TOKEN_DOUBLECOLON; ; index = 12 ; length = 2 line = 1 ; column = 12 ; value ='::'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 15 ; length = 1 line = 1 ; column = 15 ; value ='('; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 16 ; length = 3 line = 1 ; column = 16 ; value ='pos'; }
|
||||
{kind = TOKEN_COLON; ; index = 20 ; length = 1 line = 1 ; column = 20 ; value =':'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 22 ; length = 6 line = 1 ; column = 22 ; value ='float3'; }
|
||||
{kind = TOKEN_AT; ; index = 29 ; length = 1 line = 1 ; column = 29 ; value ='@'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 30 ; length = 8 line = 1 ; column = 30 ; value ='position'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 38 ; length = 1 line = 1 ; column = 38 ; value =')'; }
|
||||
{kind = TOKEN_ARROW; ; index = 40 ; length = 2 line = 1 ; column = 40 ; value ='->'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 43 ; length = 6 line = 1 ; column = 43 ; value ='float4'; }
|
||||
{kind = TOKEN_AT; ; index = 50 ; length = 1 line = 1 ; column = 50 ; value ='@'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 51 ; length = 8 line = 1 ; column = 51 ; value ='position'; }
|
||||
{kind = TOKEN_LEFTBRACE; ; index = 60 ; length = 1 line = 1 ; column = 60 ; value ='{'; }
|
||||
{kind = TOKEN_IF; ; index = 64 ; length = 2 line = 2 ; column = 0 ; value ='if'; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 67 ; length = 3 line = 2 ; column = 3 ; value ='1'; }
|
||||
{kind = TOKEN_LEFTBRACE; ; index = 71 ; length = 1 line = 2 ; column = 7 ; value ='{'; }
|
||||
{kind = TOKEN_RETURN; ; index = 76 ; length = 6 line = 3 ; column = 0 ; value ='return'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 83 ; length = 6 line = 3 ; column = 7 ; value ='float4'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 89 ; length = 1 line = 3 ; column = 13 ; value ='('; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 90 ; length = 3 line = 3 ; column = 14 ; value ='pos'; }
|
||||
{kind = TOKEN_COMMA; ; index = 93 ; length = 1 line = 3 ; column = 17 ; value =','; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 95 ; length = 3 line = 3 ; column = 19 ; value ='1'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 98 ; length = 1 line = 3 ; column = 22 ; value =')'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 99 ; length = 1 line = 3 ; column = 23 ; value =';'; }
|
||||
{kind = TOKEN_RIGHTBRACE; ; index = 103 ; length = 1 line = 4 ; column = 0 ; value ='}'; }
|
||||
{kind = TOKEN_RETURN; ; index = 107 ; length = 6 line = 5 ; column = 0 ; value ='return'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 114 ; length = 6 line = 5 ; column = 7 ; value ='float4'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 120 ; length = 1 line = 5 ; column = 13 ; value ='('; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 121 ; length = 3 line = 5 ; column = 14 ; value ='0'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 124 ; length = 1 line = 5 ; column = 17 ; value =')'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 125 ; length = 1 line = 5 ; column = 18 ; value =';'; }
|
||||
{kind = TOKEN_RIGHTBRACE; ; index = 128 ; length = 1 line = 6 ; column = 0 ; value ='}'; }
|
||||
{kind = TOKEN_EOF; ; index = 131 ; length = 0 line = 7 ; column = 0 ; value =''; }
|
||||
@@ -1,4 +1,4 @@
|
||||
[1;37mtest/float_suffix.shd:2,12: [31merror: [37mWe don't use 'f' suffixes for floating point values.
|
||||
[1;37mtest/float_suffix.ink:2,12: [31merror: [37mWe don't use 'f' suffixes for floating point values.
|
||||
[36m x : float = 2.0f
|
||||
^^^^
|
||||
[37m
|
||||
25
test/lex/for_i_loop.golden
Normal file
25
test/lex/for_i_loop.golden
Normal file
@@ -0,0 +1,25 @@
|
||||
{kind = TOKEN_VERTEX; ; index = 0 ; length = 6 line = 1 ; column = 0 ; value ='vertex'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 7 ; length = 4 line = 1 ; column = 7 ; value ='main'; }
|
||||
{kind = TOKEN_DOUBLECOLON; ; index = 12 ; length = 2 line = 1 ; column = 12 ; value ='::'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 15 ; length = 1 line = 1 ; column = 15 ; value ='('; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 16 ; length = 1 line = 1 ; column = 16 ; value =')'; }
|
||||
{kind = TOKEN_LEFTBRACE; ; index = 18 ; length = 1 line = 1 ; column = 18 ; value ='{'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 22 ; length = 1 line = 2 ; column = 0 ; value ='x'; }
|
||||
{kind = TOKEN_COLON; ; index = 24 ; length = 1 line = 2 ; column = 2 ; value =':'; }
|
||||
{kind = TOKEN_ASSIGN; ; index = 25 ; length = 1 line = 2 ; column = 3 ; value ='='; }
|
||||
{kind = TOKEN_INTLITERAL; ; index = 27 ; length = 1 line = 2 ; column = 5 ; value ='0'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 28 ; length = 1 line = 2 ; column = 6 ; value =';'; }
|
||||
{kind = TOKEN_FOR; ; index = 32 ; length = 3 line = 3 ; column = 0 ; value ='for'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 36 ; length = 1 line = 3 ; column = 4 ; value ='i'; }
|
||||
{kind = TOKEN_COLON; ; index = 38 ; length = 1 line = 3 ; column = 6 ; value =':'; }
|
||||
{kind = TOKEN_INTLITERAL; ; index = 40 ; length = 1 line = 3 ; column = 8 ; value ='0'; }
|
||||
{kind = TOKEN_DOTDOT; ; index = 41 ; length = 2 line = 3 ; column = 9 ; value ='..'; }
|
||||
{kind = TOKEN_INTLITERAL; ; index = 43 ; length = 2 line = 3 ; column = 11 ; value ='10'; }
|
||||
{kind = TOKEN_LEFTBRACE; ; index = 46 ; length = 1 line = 3 ; column = 14 ; value ='{'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 51 ; length = 1 line = 4 ; column = 0 ; value ='x'; }
|
||||
{kind = TOKEN_PLUSEQUALS; ; index = 53 ; length = 2 line = 4 ; column = 2 ; value ='+='; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 56 ; length = 3 line = 4 ; column = 5 ; value ='1'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 59 ; length = 1 line = 4 ; column = 8 ; value =';'; }
|
||||
{kind = TOKEN_RIGHTBRACE; ; index = 63 ; length = 1 line = 5 ; column = 0 ; value ='}'; }
|
||||
{kind = TOKEN_RIGHTBRACE; ; index = 66 ; length = 1 line = 6 ; column = 0 ; value ='}'; }
|
||||
{kind = TOKEN_EOF; ; index = 69 ; length = 0 line = 7 ; column = 0 ; value =''; }
|
||||
23
test/lex/for_i_one_liner.golden
Normal file
23
test/lex/for_i_one_liner.golden
Normal file
@@ -0,0 +1,23 @@
|
||||
{kind = TOKEN_VERTEX; ; index = 0 ; length = 6 line = 1 ; column = 0 ; value ='vertex'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 7 ; length = 4 line = 1 ; column = 7 ; value ='main'; }
|
||||
{kind = TOKEN_DOUBLECOLON; ; index = 12 ; length = 2 line = 1 ; column = 12 ; value ='::'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 15 ; length = 1 line = 1 ; column = 15 ; value ='('; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 16 ; length = 1 line = 1 ; column = 16 ; value =')'; }
|
||||
{kind = TOKEN_LEFTBRACE; ; index = 18 ; length = 1 line = 1 ; column = 18 ; value ='{'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 22 ; length = 1 line = 2 ; column = 0 ; value ='x'; }
|
||||
{kind = TOKEN_COLON; ; index = 24 ; length = 1 line = 2 ; column = 2 ; value =':'; }
|
||||
{kind = TOKEN_ASSIGN; ; index = 25 ; length = 1 line = 2 ; column = 3 ; value ='='; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 27 ; length = 3 line = 2 ; column = 5 ; value ='0'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 30 ; length = 1 line = 2 ; column = 8 ; value =';'; }
|
||||
{kind = TOKEN_FOR; ; index = 34 ; length = 3 line = 3 ; column = 0 ; value ='for'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 38 ; length = 1 line = 3 ; column = 4 ; value ='i'; }
|
||||
{kind = TOKEN_COLON; ; index = 40 ; length = 1 line = 3 ; column = 6 ; value =':'; }
|
||||
{kind = TOKEN_INTLITERAL; ; index = 42 ; length = 1 line = 3 ; column = 8 ; value ='0'; }
|
||||
{kind = TOKEN_DOTDOT; ; index = 43 ; length = 2 line = 3 ; column = 9 ; value ='..'; }
|
||||
{kind = TOKEN_INTLITERAL; ; index = 45 ; length = 2 line = 3 ; column = 11 ; value ='10'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 48 ; length = 1 line = 3 ; column = 14 ; value ='x'; }
|
||||
{kind = TOKEN_PLUSEQUALS; ; index = 50 ; length = 2 line = 3 ; column = 16 ; value ='+='; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 53 ; length = 3 line = 3 ; column = 19 ; value ='2'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 56 ; length = 1 line = 3 ; column = 22 ; value =';'; }
|
||||
{kind = TOKEN_RIGHTBRACE; ; index = 59 ; length = 1 line = 4 ; column = 0 ; value ='}'; }
|
||||
{kind = TOKEN_EOF; ; index = 62 ; length = 0 line = 5 ; column = 0 ; value =''; }
|
||||
24
test/lex/for_no_iter.golden
Normal file
24
test/lex/for_no_iter.golden
Normal file
@@ -0,0 +1,24 @@
|
||||
{kind = TOKEN_VERTEX; ; index = 0 ; length = 6 line = 1 ; column = 0 ; value ='vertex'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 7 ; length = 4 line = 1 ; column = 7 ; value ='main'; }
|
||||
{kind = TOKEN_DOUBLECOLON; ; index = 12 ; length = 2 line = 1 ; column = 12 ; value ='::'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 15 ; length = 1 line = 1 ; column = 15 ; value ='('; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 16 ; length = 1 line = 1 ; column = 16 ; value =')'; }
|
||||
{kind = TOKEN_LEFTBRACE; ; index = 18 ; length = 1 line = 1 ; column = 18 ; value ='{'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 22 ; length = 1 line = 2 ; column = 0 ; value ='x'; }
|
||||
{kind = TOKEN_COLON; ; index = 24 ; length = 1 line = 2 ; column = 2 ; value =':'; }
|
||||
{kind = TOKEN_ASSIGN; ; index = 25 ; length = 1 line = 2 ; column = 3 ; value ='='; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 27 ; length = 3 line = 2 ; column = 5 ; value ='0'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 30 ; length = 1 line = 2 ; column = 8 ; value =';'; }
|
||||
{kind = TOKEN_FOR; ; index = 34 ; length = 3 line = 3 ; column = 0 ; value ='for'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 38 ; length = 1 line = 3 ; column = 4 ; value ='i'; }
|
||||
{kind = TOKEN_COLON; ; index = 40 ; length = 1 line = 3 ; column = 6 ; value =':'; }
|
||||
{kind = TOKEN_INTLITERAL; ; index = 42 ; length = 1 line = 3 ; column = 8 ; value ='0'; }
|
||||
{kind = TOKEN_DOTDOT; ; index = 43 ; length = 2 line = 3 ; column = 9 ; value ='..'; }
|
||||
{kind = TOKEN_LEFTBRACE; ; index = 46 ; length = 1 line = 3 ; column = 12 ; value ='{'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 51 ; length = 1 line = 4 ; column = 0 ; value ='x'; }
|
||||
{kind = TOKEN_PLUSEQUALS; ; index = 53 ; length = 2 line = 4 ; column = 2 ; value ='+='; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 56 ; length = 3 line = 4 ; column = 5 ; value ='2'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 59 ; length = 1 line = 4 ; column = 8 ; value =';'; }
|
||||
{kind = TOKEN_RIGHTBRACE; ; index = 63 ; length = 1 line = 5 ; column = 0 ; value ='}'; }
|
||||
{kind = TOKEN_RIGHTBRACE; ; index = 66 ; length = 1 line = 6 ; column = 0 ; value ='}'; }
|
||||
{kind = TOKEN_EOF; ; index = 69 ; length = 0 line = 7 ; column = 0 ; value =''; }
|
||||
37
test/lex/if_cond_assign.golden
Normal file
37
test/lex/if_cond_assign.golden
Normal file
@@ -0,0 +1,37 @@
|
||||
{kind = TOKEN_VERTEX; ; index = 0 ; length = 6 line = 1 ; column = 0 ; value ='vertex'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 7 ; length = 4 line = 1 ; column = 7 ; value ='main'; }
|
||||
{kind = TOKEN_DOUBLECOLON; ; index = 12 ; length = 2 line = 1 ; column = 12 ; value ='::'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 15 ; length = 1 line = 1 ; column = 15 ; value ='('; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 16 ; length = 3 line = 1 ; column = 16 ; value ='pos'; }
|
||||
{kind = TOKEN_COLON; ; index = 20 ; length = 1 line = 1 ; column = 20 ; value =':'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 22 ; length = 6 line = 1 ; column = 22 ; value ='float3'; }
|
||||
{kind = TOKEN_AT; ; index = 29 ; length = 1 line = 1 ; column = 29 ; value ='@'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 30 ; length = 8 line = 1 ; column = 30 ; value ='position'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 38 ; length = 1 line = 1 ; column = 38 ; value =')'; }
|
||||
{kind = TOKEN_ARROW; ; index = 40 ; length = 2 line = 1 ; column = 40 ; value ='->'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 43 ; length = 6 line = 1 ; column = 43 ; value ='float4'; }
|
||||
{kind = TOKEN_AT; ; index = 50 ; length = 1 line = 1 ; column = 50 ; value ='@'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 51 ; length = 8 line = 1 ; column = 51 ; value ='position'; }
|
||||
{kind = TOKEN_LEFTBRACE; ; index = 60 ; length = 1 line = 1 ; column = 60 ; value ='{'; }
|
||||
{kind = TOKEN_IF; ; index = 64 ; length = 2 line = 2 ; column = 0 ; value ='if'; }
|
||||
{kind = TOKEN_INTLITERAL; ; index = 67 ; length = 1 line = 2 ; column = 3 ; value ='0'; }
|
||||
{kind = TOKEN_ASSIGN; ; index = 69 ; length = 1 line = 2 ; column = 5 ; value ='='; }
|
||||
{kind = TOKEN_INTLITERAL; ; index = 71 ; length = 3 line = 2 ; column = 7 ; value ='100'; }
|
||||
{kind = TOKEN_LEFTBRACE; ; index = 75 ; length = 1 line = 2 ; column = 11 ; value ='{'; }
|
||||
{kind = TOKEN_RETURN; ; index = 80 ; length = 6 line = 3 ; column = 0 ; value ='return'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 87 ; length = 6 line = 3 ; column = 7 ; value ='float4'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 93 ; length = 1 line = 3 ; column = 13 ; value ='('; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 94 ; length = 3 line = 3 ; column = 14 ; value ='pos'; }
|
||||
{kind = TOKEN_COMMA; ; index = 97 ; length = 1 line = 3 ; column = 17 ; value =','; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 99 ; length = 3 line = 3 ; column = 19 ; value ='1'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 102 ; length = 1 line = 3 ; column = 22 ; value =')'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 103 ; length = 1 line = 3 ; column = 23 ; value =';'; }
|
||||
{kind = TOKEN_RIGHTBRACE; ; index = 107 ; length = 1 line = 4 ; column = 0 ; value ='}'; }
|
||||
{kind = TOKEN_RETURN; ; index = 111 ; length = 6 line = 5 ; column = 0 ; value ='return'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 118 ; length = 6 line = 5 ; column = 7 ; value ='float4'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 124 ; length = 1 line = 5 ; column = 13 ; value ='('; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 125 ; length = 3 line = 5 ; column = 14 ; value ='0'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 128 ; length = 1 line = 5 ; column = 17 ; value =')'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 129 ; length = 1 line = 5 ; column = 18 ; value =';'; }
|
||||
{kind = TOKEN_RIGHTBRACE; ; index = 132 ; length = 1 line = 6 ; column = 0 ; value ='}'; }
|
||||
{kind = TOKEN_EOF; ; index = 135 ; length = 0 line = 7 ; column = 0 ; value =''; }
|
||||
39
test/lex/if_if_if.golden
Normal file
39
test/lex/if_if_if.golden
Normal file
@@ -0,0 +1,39 @@
|
||||
{kind = TOKEN_VERTEX; ; index = 0 ; length = 6 line = 1 ; column = 0 ; value ='vertex'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 7 ; length = 4 line = 1 ; column = 7 ; value ='main'; }
|
||||
{kind = TOKEN_DOUBLECOLON; ; index = 12 ; length = 2 line = 1 ; column = 12 ; value ='::'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 15 ; length = 1 line = 1 ; column = 15 ; value ='('; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 16 ; length = 3 line = 1 ; column = 16 ; value ='pos'; }
|
||||
{kind = TOKEN_COLON; ; index = 20 ; length = 1 line = 1 ; column = 20 ; value =':'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 22 ; length = 6 line = 1 ; column = 22 ; value ='float3'; }
|
||||
{kind = TOKEN_AT; ; index = 29 ; length = 1 line = 1 ; column = 29 ; value ='@'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 30 ; length = 8 line = 1 ; column = 30 ; value ='position'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 38 ; length = 1 line = 1 ; column = 38 ; value =')'; }
|
||||
{kind = TOKEN_ARROW; ; index = 40 ; length = 2 line = 1 ; column = 40 ; value ='->'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 43 ; length = 6 line = 1 ; column = 43 ; value ='float4'; }
|
||||
{kind = TOKEN_AT; ; index = 50 ; length = 1 line = 1 ; column = 50 ; value ='@'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 51 ; length = 8 line = 1 ; column = 51 ; value ='position'; }
|
||||
{kind = TOKEN_LEFTBRACE; ; index = 60 ; length = 1 line = 1 ; column = 60 ; value ='{'; }
|
||||
{kind = TOKEN_IF; ; index = 64 ; length = 2 line = 2 ; column = 0 ; value ='if'; }
|
||||
{kind = TOKEN_IF; ; index = 67 ; length = 2 line = 2 ; column = 3 ; value ='if'; }
|
||||
{kind = TOKEN_IF; ; index = 70 ; length = 2 line = 2 ; column = 6 ; value ='if'; }
|
||||
{kind = TOKEN_INTLITERAL; ; index = 73 ; length = 1 line = 2 ; column = 9 ; value ='0'; }
|
||||
{kind = TOKEN_GREATER; ; index = 75 ; length = 1 line = 2 ; column = 11 ; value ='>'; }
|
||||
{kind = TOKEN_INTLITERAL; ; index = 77 ; length = 3 line = 2 ; column = 13 ; value ='100'; }
|
||||
{kind = TOKEN_LEFTBRACE; ; index = 81 ; length = 1 line = 2 ; column = 17 ; value ='{'; }
|
||||
{kind = TOKEN_RETURN; ; index = 86 ; length = 6 line = 3 ; column = 0 ; value ='return'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 93 ; length = 6 line = 3 ; column = 7 ; value ='float4'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 99 ; length = 1 line = 3 ; column = 13 ; value ='('; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 100 ; length = 3 line = 3 ; column = 14 ; value ='pos'; }
|
||||
{kind = TOKEN_COMMA; ; index = 103 ; length = 1 line = 3 ; column = 17 ; value =','; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 105 ; length = 3 line = 3 ; column = 19 ; value ='1'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 108 ; length = 1 line = 3 ; column = 22 ; value =')'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 109 ; length = 1 line = 3 ; column = 23 ; value =';'; }
|
||||
{kind = TOKEN_RIGHTBRACE; ; index = 113 ; length = 1 line = 4 ; column = 0 ; value ='}'; }
|
||||
{kind = TOKEN_RETURN; ; index = 117 ; length = 6 line = 5 ; column = 0 ; value ='return'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 124 ; length = 6 line = 5 ; column = 7 ; value ='float4'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 130 ; length = 1 line = 5 ; column = 13 ; value ='('; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 131 ; length = 3 line = 5 ; column = 14 ; value ='0'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 134 ; length = 1 line = 5 ; column = 17 ; value =')'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 135 ; length = 1 line = 5 ; column = 18 ; value =';'; }
|
||||
{kind = TOKEN_RIGHTBRACE; ; index = 138 ; length = 1 line = 6 ; column = 0 ; value ='}'; }
|
||||
{kind = TOKEN_EOF; ; index = 141 ; length = 0 line = 7 ; column = 0 ; value =''; }
|
||||
105
test/lex/inferred_types.golden
Normal file
105
test/lex/inferred_types.golden
Normal file
@@ -0,0 +1,105 @@
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 0 ; length = 3 line = 1 ; column = 0 ; value ='bar'; }
|
||||
{kind = TOKEN_DOUBLECOLON; ; index = 4 ; length = 2 line = 1 ; column = 4 ; value ='::'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 7 ; length = 1 line = 1 ; column = 7 ; value ='('; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 8 ; length = 1 line = 1 ; column = 8 ; value =')'; }
|
||||
{kind = TOKEN_ARROW; ; index = 10 ; length = 2 line = 1 ; column = 10 ; value ='->'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 13 ; length = 5 line = 1 ; column = 13 ; value ='float'; }
|
||||
{kind = TOKEN_LEFTBRACE; ; index = 19 ; length = 1 line = 1 ; column = 19 ; value ='{'; }
|
||||
{kind = TOKEN_RETURN; ; index = 23 ; length = 6 line = 2 ; column = 0 ; value ='return'; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 30 ; length = 3 line = 2 ; column = 7 ; value ='5'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 33 ; length = 1 line = 2 ; column = 10 ; value =';'; }
|
||||
{kind = TOKEN_RIGHTBRACE; ; index = 36 ; length = 1 line = 3 ; column = 0 ; value ='}'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 41 ; length = 3 line = 5 ; column = 0 ; value ='foo'; }
|
||||
{kind = TOKEN_DOUBLECOLON; ; index = 45 ; length = 2 line = 5 ; column = 4 ; value ='::'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 48 ; length = 1 line = 5 ; column = 7 ; value ='('; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 49 ; length = 1 line = 5 ; column = 8 ; value =')'; }
|
||||
{kind = TOKEN_ARROW; ; index = 51 ; length = 2 line = 5 ; column = 10 ; value ='->'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 54 ; length = 5 line = 5 ; column = 13 ; value ='float'; }
|
||||
{kind = TOKEN_LEFTBRACE; ; index = 60 ; length = 1 line = 5 ; column = 19 ; value ='{'; }
|
||||
{kind = TOKEN_RETURN; ; index = 64 ; length = 6 line = 6 ; column = 0 ; value ='return'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 71 ; length = 3 line = 6 ; column = 7 ; value ='bar'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 74 ; length = 1 line = 6 ; column = 10 ; value ='('; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 75 ; length = 1 line = 6 ; column = 11 ; value =')'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 76 ; length = 1 line = 6 ; column = 12 ; value =';'; }
|
||||
{kind = TOKEN_RIGHTBRACE; ; index = 79 ; length = 1 line = 7 ; column = 0 ; value ='}'; }
|
||||
{kind = TOKEN_VERTEX; ; index = 84 ; length = 6 line = 9 ; column = 0 ; value ='vertex'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 91 ; length = 4 line = 9 ; column = 7 ; value ='main'; }
|
||||
{kind = TOKEN_DOUBLECOLON; ; index = 96 ; length = 2 line = 9 ; column = 12 ; value ='::'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 99 ; length = 1 line = 9 ; column = 15 ; value ='('; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 100 ; length = 3 line = 9 ; column = 16 ; value ='pos'; }
|
||||
{kind = TOKEN_COLON; ; index = 104 ; length = 1 line = 9 ; column = 20 ; value =':'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 106 ; length = 6 line = 9 ; column = 22 ; value ='float3'; }
|
||||
{kind = TOKEN_AT; ; index = 113 ; length = 1 line = 9 ; column = 29 ; value ='@'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 114 ; length = 8 line = 9 ; column = 30 ; value ='position'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 122 ; length = 1 line = 9 ; column = 38 ; value =')'; }
|
||||
{kind = TOKEN_ARROW; ; index = 124 ; length = 2 line = 9 ; column = 40 ; value ='->'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 127 ; length = 6 line = 9 ; column = 43 ; value ='float4'; }
|
||||
{kind = TOKEN_AT; ; index = 134 ; length = 1 line = 9 ; column = 50 ; value ='@'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 135 ; length = 8 line = 9 ; column = 51 ; value ='position'; }
|
||||
{kind = TOKEN_LEFTBRACE; ; index = 144 ; length = 1 line = 9 ; column = 60 ; value ='{'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 151 ; length = 1 line = 10 ; column = 3 ; value ='f'; }
|
||||
{kind = TOKEN_COLON; ; index = 153 ; length = 1 line = 10 ; column = 5 ; value =':'; }
|
||||
{kind = TOKEN_ASSIGN; ; index = 154 ; length = 1 line = 10 ; column = 6 ; value ='='; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 156 ; length = 3 line = 10 ; column = 8 ; value ='2'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 159 ; length = 1 line = 10 ; column = 11 ; value =';'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 166 ; length = 1 line = 11 ; column = 3 ; value ='i'; }
|
||||
{kind = TOKEN_COLON; ; index = 168 ; length = 1 line = 11 ; column = 5 ; value =':'; }
|
||||
{kind = TOKEN_ASSIGN; ; index = 169 ; length = 1 line = 11 ; column = 6 ; value ='='; }
|
||||
{kind = TOKEN_INTLITERAL; ; index = 171 ; length = 2 line = 11 ; column = 8 ; value ='10'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 173 ; length = 1 line = 11 ; column = 10 ; value =';'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 180 ; length = 1 line = 12 ; column = 3 ; value ='f'; }
|
||||
{kind = TOKEN_ASSIGN; ; index = 182 ; length = 1 line = 12 ; column = 5 ; value ='='; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 184 ; length = 3 line = 12 ; column = 7 ; value ='foo'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 187 ; length = 1 line = 12 ; column = 10 ; value ='('; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 188 ; length = 1 line = 12 ; column = 11 ; value =')'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 189 ; length = 1 line = 12 ; column = 12 ; value =';'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 196 ; length = 2 line = 13 ; column = 3 ; value ='v2'; }
|
||||
{kind = TOKEN_COLON; ; index = 199 ; length = 1 line = 13 ; column = 6 ; value =':'; }
|
||||
{kind = TOKEN_ASSIGN; ; index = 200 ; length = 1 line = 13 ; column = 7 ; value ='='; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 202 ; length = 6 line = 13 ; column = 9 ; value ='float2'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 208 ; length = 1 line = 13 ; column = 15 ; value ='('; }
|
||||
{kind = TOKEN_INTLITERAL; ; index = 209 ; length = 1 line = 13 ; column = 16 ; value ='2'; }
|
||||
{kind = TOKEN_COMMA; ; index = 210 ; length = 1 line = 13 ; column = 17 ; value =','; }
|
||||
{kind = TOKEN_INTLITERAL; ; index = 212 ; length = 1 line = 13 ; column = 19 ; value ='2'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 213 ; length = 1 line = 13 ; column = 20 ; value =')'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 214 ; length = 1 line = 13 ; column = 21 ; value =';'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 221 ; length = 2 line = 14 ; column = 3 ; value ='v3'; }
|
||||
{kind = TOKEN_COLON; ; index = 224 ; length = 1 line = 14 ; column = 6 ; value =':'; }
|
||||
{kind = TOKEN_ASSIGN; ; index = 225 ; length = 1 line = 14 ; column = 7 ; value ='='; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 227 ; length = 6 line = 14 ; column = 9 ; value ='float3'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 233 ; length = 1 line = 14 ; column = 15 ; value ='('; }
|
||||
{kind = TOKEN_INTLITERAL; ; index = 234 ; length = 1 line = 14 ; column = 16 ; value ='2'; }
|
||||
{kind = TOKEN_COMMA; ; index = 235 ; length = 1 line = 14 ; column = 17 ; value =','; }
|
||||
{kind = TOKEN_INTLITERAL; ; index = 237 ; length = 1 line = 14 ; column = 19 ; value ='2'; }
|
||||
{kind = TOKEN_COMMA; ; index = 238 ; length = 1 line = 14 ; column = 20 ; value =','; }
|
||||
{kind = TOKEN_INTLITERAL; ; index = 240 ; length = 1 line = 14 ; column = 22 ; value ='3'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 241 ; length = 1 line = 14 ; column = 23 ; value =')'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 242 ; length = 1 line = 14 ; column = 24 ; value =';'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 249 ; length = 2 line = 15 ; column = 3 ; value ='v4'; }
|
||||
{kind = TOKEN_COLON; ; index = 252 ; length = 1 line = 15 ; column = 6 ; value =':'; }
|
||||
{kind = TOKEN_ASSIGN; ; index = 253 ; length = 1 line = 15 ; column = 7 ; value ='='; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 255 ; length = 6 line = 15 ; column = 9 ; value ='float4'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 261 ; length = 1 line = 15 ; column = 15 ; value ='('; }
|
||||
{kind = TOKEN_INTLITERAL; ; index = 262 ; length = 1 line = 15 ; column = 16 ; value ='4'; }
|
||||
{kind = TOKEN_COMMA; ; index = 263 ; length = 1 line = 15 ; column = 17 ; value =','; }
|
||||
{kind = TOKEN_INTLITERAL; ; index = 265 ; length = 1 line = 15 ; column = 19 ; value ='5'; }
|
||||
{kind = TOKEN_COMMA; ; index = 266 ; length = 1 line = 15 ; column = 20 ; value =','; }
|
||||
{kind = TOKEN_INTLITERAL; ; index = 268 ; length = 1 line = 15 ; column = 22 ; value ='6'; }
|
||||
{kind = TOKEN_COMMA; ; index = 269 ; length = 1 line = 15 ; column = 23 ; value =','; }
|
||||
{kind = TOKEN_INTLITERAL; ; index = 271 ; length = 1 line = 15 ; column = 25 ; value ='7'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 272 ; length = 1 line = 15 ; column = 26 ; value =')'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 273 ; length = 1 line = 15 ; column = 27 ; value =';'; }
|
||||
{kind = TOKEN_RETURN; ; index = 280 ; length = 6 line = 16 ; column = 3 ; value ='return'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 287 ; length = 6 line = 16 ; column = 10 ; value ='float4'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 293 ; length = 1 line = 16 ; column = 16 ; value ='('; }
|
||||
{kind = TOKEN_INTLITERAL; ; index = 294 ; length = 1 line = 16 ; column = 17 ; value ='1'; }
|
||||
{kind = TOKEN_COMMA; ; index = 295 ; length = 1 line = 16 ; column = 18 ; value =','; }
|
||||
{kind = TOKEN_INTLITERAL; ; index = 297 ; length = 1 line = 16 ; column = 20 ; value ='1'; }
|
||||
{kind = TOKEN_COMMA; ; index = 298 ; length = 1 line = 16 ; column = 21 ; value =','; }
|
||||
{kind = TOKEN_INTLITERAL; ; index = 300 ; length = 1 line = 16 ; column = 23 ; value ='1'; }
|
||||
{kind = TOKEN_COMMA; ; index = 301 ; length = 1 line = 16 ; column = 24 ; value =','; }
|
||||
{kind = TOKEN_INTLITERAL; ; index = 303 ; length = 1 line = 16 ; column = 26 ; value ='1'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 304 ; length = 1 line = 16 ; column = 27 ; value =')'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 305 ; length = 1 line = 16 ; column = 28 ; value =';'; }
|
||||
{kind = TOKEN_RIGHTBRACE; ; index = 308 ; length = 1 line = 17 ; column = 0 ; value ='}'; }
|
||||
{kind = TOKEN_EOF; ; index = 309 ; length = 0 line = 17 ; column = 1 ; value =''; }
|
||||
289
test/lex/large_block.golden
Normal file
289
test/lex/large_block.golden
Normal file
@@ -0,0 +1,289 @@
|
||||
{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 = 5 line = 2 ; column = 0 ; value ='color'; }
|
||||
{kind = TOKEN_COLON; ; index = 34 ; length = 1 line = 2 ; column = 14 ; value =':'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 36 ; length = 6 line = 2 ; column = 16 ; value ='float4'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 42 ; length = 1 line = 2 ; column = 22 ; value =';'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 46 ; length = 13 line = 3 ; column = 0 ; value ='rect_position'; }
|
||||
{kind = TOKEN_COLON; ; index = 60 ; length = 1 line = 3 ; column = 14 ; value =':'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 62 ; length = 6 line = 3 ; column = 16 ; value ='float2'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 68 ; length = 1 line = 3 ; column = 22 ; value =';'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 72 ; length = 10 line = 4 ; column = 0 ; value ='rect_scale'; }
|
||||
{kind = TOKEN_COLON; ; index = 86 ; length = 1 line = 4 ; column = 14 ; value =':'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 88 ; length = 6 line = 4 ; column = 16 ; value ='float2'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 94 ; length = 1 line = 4 ; column = 22 ; value =';'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 98 ; length = 10 line = 5 ; column = 0 ; value ='resolution'; }
|
||||
{kind = TOKEN_COLON; ; index = 112 ; length = 1 line = 5 ; column = 14 ; value =':'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 114 ; length = 6 line = 5 ; column = 16 ; value ='float2'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 120 ; length = 1 line = 5 ; column = 22 ; value =';'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 124 ; length = 7 line = 6 ; column = 0 ; value ='texture'; }
|
||||
{kind = TOKEN_COLON; ; index = 138 ; length = 1 line = 6 ; column = 14 ; value =':'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 140 ; length = 9 line = 6 ; column = 16 ; value ='Texture2D'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 149 ; length = 1 line = 6 ; column = 25 ; value =';'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 153 ; length = 7 line = 7 ; column = 0 ; value ='sampler'; }
|
||||
{kind = TOKEN_COLON; ; index = 167 ; length = 1 line = 7 ; column = 14 ; value =':'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 169 ; length = 7 line = 7 ; column = 16 ; value ='Sampler'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 176 ; length = 1 line = 7 ; column = 23 ; value =';'; }
|
||||
{kind = TOKEN_RIGHTBRACE; ; index = 179 ; length = 1 line = 8 ; column = 0 ; value ='}'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 184 ; length = 8 line = 10 ; column = 0 ; value ='PS_Input'; }
|
||||
{kind = TOKEN_DOUBLECOLON; ; index = 193 ; length = 2 line = 10 ; column = 9 ; value ='::'; }
|
||||
{kind = TOKEN_STRUCT; ; index = 196 ; length = 6 line = 10 ; column = 12 ; value ='struct'; }
|
||||
{kind = TOKEN_LEFTBRACE; ; index = 203 ; length = 1 line = 10 ; column = 19 ; value ='{'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 207 ; length = 2 line = 11 ; column = 0 ; value ='uv'; }
|
||||
{kind = TOKEN_COLON; ; index = 210 ; length = 1 line = 11 ; column = 3 ; value =':'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 212 ; length = 6 line = 11 ; column = 5 ; value ='float2'; }
|
||||
{kind = TOKEN_AT; ; index = 219 ; length = 1 line = 11 ; column = 12 ; value ='@'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 220 ; length = 2 line = 11 ; column = 13 ; value ='uv'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 222 ; length = 1 line = 11 ; column = 15 ; value =';'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 226 ; length = 3 line = 12 ; column = 0 ; value ='pos'; }
|
||||
{kind = TOKEN_COLON; ; index = 230 ; length = 1 line = 12 ; column = 4 ; value =':'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 232 ; length = 6 line = 12 ; column = 6 ; value ='float4'; }
|
||||
{kind = TOKEN_AT; ; index = 239 ; length = 1 line = 12 ; column = 13 ; value ='@'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 240 ; length = 3 line = 12 ; column = 14 ; value ='pos'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 243 ; length = 1 line = 12 ; column = 17 ; value =';'; }
|
||||
{kind = TOKEN_RIGHTBRACE; ; index = 246 ; length = 1 line = 13 ; column = 0 ; value ='}'; }
|
||||
{kind = TOKEN_VERTEX; ; index = 251 ; length = 6 line = 15 ; column = 0 ; value ='vertex'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 258 ; length = 4 line = 15 ; column = 7 ; value ='main'; }
|
||||
{kind = TOKEN_DOUBLECOLON; ; index = 263 ; length = 2 line = 15 ; column = 12 ; value ='::'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 266 ; length = 1 line = 15 ; column = 15 ; value ='('; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 267 ; length = 3 line = 15 ; column = 16 ; value ='pos'; }
|
||||
{kind = TOKEN_COLON; ; index = 271 ; length = 1 line = 15 ; column = 20 ; value =':'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 273 ; length = 6 line = 15 ; column = 22 ; value ='float4'; }
|
||||
{kind = TOKEN_AT; ; index = 280 ; length = 1 line = 15 ; column = 29 ; value ='@'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 281 ; length = 8 line = 15 ; column = 30 ; value ='position'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 289 ; length = 1 line = 15 ; column = 38 ; value =')'; }
|
||||
{kind = TOKEN_ARROW; ; index = 291 ; length = 2 line = 15 ; column = 40 ; value ='->'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 294 ; length = 8 line = 15 ; column = 43 ; value ='PS_Input'; }
|
||||
{kind = TOKEN_LEFTBRACE; ; index = 303 ; length = 1 line = 15 ; column = 52 ; value ='{'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 307 ; length = 3 line = 16 ; column = 0 ; value ='res'; }
|
||||
{kind = TOKEN_COLON; ; index = 316 ; length = 1 line = 16 ; column = 9 ; value =':'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 318 ; length = 6 line = 16 ; column = 11 ; value ='float2'; }
|
||||
{kind = TOKEN_ASSIGN; ; index = 325 ; length = 1 line = 16 ; column = 18 ; value ='='; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 327 ; length = 1 line = 16 ; column = 20 ; value ='p'; }
|
||||
{kind = TOKEN_DOT; ; index = 328 ; length = 1 line = 16 ; column = 21 ; value ='.'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 329 ; length = 10 line = 16 ; column = 22 ; value ='resolution'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 339 ; length = 1 line = 16 ; column = 32 ; value =';'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 343 ; length = 5 line = 17 ; column = 0 ; value ='scale'; }
|
||||
{kind = TOKEN_COLON; ; index = 352 ; length = 1 line = 17 ; column = 9 ; value =':'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 354 ; length = 6 line = 17 ; column = 11 ; value ='float2'; }
|
||||
{kind = TOKEN_ASSIGN; ; index = 361 ; length = 1 line = 17 ; column = 18 ; value ='='; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 363 ; length = 1 line = 17 ; column = 20 ; value ='p'; }
|
||||
{kind = TOKEN_DOT; ; index = 364 ; length = 1 line = 17 ; column = 21 ; value ='.'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 365 ; length = 10 line = 17 ; column = 22 ; value ='rect_scale'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 375 ; length = 1 line = 17 ; column = 32 ; value =';'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 379 ; length = 8 line = 18 ; column = 0 ; value ='rect_pos'; }
|
||||
{kind = TOKEN_COLON; ; index = 388 ; length = 1 line = 18 ; column = 9 ; value =':'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 390 ; length = 6 line = 18 ; column = 11 ; value ='float2'; }
|
||||
{kind = TOKEN_ASSIGN; ; index = 397 ; length = 1 line = 18 ; column = 18 ; value ='='; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 399 ; length = 1 line = 18 ; column = 20 ; value ='p'; }
|
||||
{kind = TOKEN_DOT; ; index = 400 ; length = 1 line = 18 ; column = 21 ; value ='.'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 401 ; length = 13 line = 18 ; column = 22 ; value ='rect_position'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 414 ; length = 1 line = 18 ; column = 35 ; value =';'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 415 ; length = 1 line = 18 ; column = 36 ; value =';'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 421 ; length = 6 line = 20 ; column = 0 ; value ='center'; }
|
||||
{kind = TOKEN_COLON; ; index = 428 ; length = 1 line = 20 ; column = 7 ; value =':'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 430 ; length = 6 line = 20 ; column = 9 ; value ='float2'; }
|
||||
{kind = TOKEN_ASSIGN; ; index = 437 ; length = 1 line = 20 ; column = 16 ; value ='='; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 439 ; length = 8 line = 20 ; column = 18 ; value ='rect_pos'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 447 ; length = 1 line = 20 ; column = 26 ; value =';'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 451 ; length = 9 line = 21 ; column = 0 ; value ='half_size'; }
|
||||
{kind = TOKEN_COLON; ; index = 462 ; length = 1 line = 21 ; column = 11 ; value =':'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 464 ; length = 6 line = 21 ; column = 13 ; value ='float2'; }
|
||||
{kind = TOKEN_ASSIGN; ; index = 471 ; length = 1 line = 21 ; column = 20 ; value ='='; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 473 ; length = 6 line = 21 ; column = 22 ; value ='float2'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 479 ; length = 1 line = 21 ; column = 28 ; value ='('; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 480 ; length = 5 line = 21 ; column = 29 ; value ='scale'; }
|
||||
{kind = TOKEN_DOT; ; index = 485 ; length = 1 line = 21 ; column = 34 ; value ='.'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 486 ; length = 1 line = 21 ; column = 35 ; value ='x'; }
|
||||
{kind = TOKEN_SLASH; ; index = 488 ; length = 1 line = 21 ; column = 37 ; value ='/'; }
|
||||
{kind = TOKEN_INTLITERAL; ; index = 490 ; length = 1 line = 21 ; column = 39 ; value ='2'; }
|
||||
{kind = TOKEN_COMMA; ; index = 491 ; length = 1 line = 21 ; column = 40 ; value =','; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 493 ; length = 5 line = 21 ; column = 42 ; value ='scale'; }
|
||||
{kind = TOKEN_DOT; ; index = 498 ; length = 1 line = 21 ; column = 47 ; value ='.'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 499 ; length = 1 line = 21 ; column = 48 ; value ='y'; }
|
||||
{kind = TOKEN_SLASH; ; index = 501 ; length = 1 line = 21 ; column = 50 ; value ='/'; }
|
||||
{kind = TOKEN_INTLITERAL; ; index = 503 ; length = 1 line = 21 ; column = 52 ; value ='2'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 504 ; length = 1 line = 21 ; column = 53 ; value =')'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 505 ; length = 1 line = 21 ; column = 54 ; value =';'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 509 ; length = 7 line = 22 ; column = 0 ; value ='dst_pos'; }
|
||||
{kind = TOKEN_COLON; ; index = 520 ; length = 1 line = 22 ; column = 11 ; value =':'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 522 ; length = 6 line = 22 ; column = 13 ; value ='float4'; }
|
||||
{kind = TOKEN_ASSIGN; ; index = 529 ; length = 1 line = 22 ; column = 20 ; value ='='; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 531 ; length = 6 line = 22 ; column = 22 ; value ='float4'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 537 ; length = 1 line = 22 ; column = 28 ; value ='('; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 538 ; length = 3 line = 22 ; column = 29 ; value ='pos'; }
|
||||
{kind = TOKEN_DOT; ; index = 541 ; length = 1 line = 22 ; column = 32 ; value ='.'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 542 ; length = 1 line = 22 ; column = 33 ; value ='x'; }
|
||||
{kind = TOKEN_STAR; ; index = 544 ; length = 1 line = 22 ; column = 35 ; value ='*'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 546 ; length = 9 line = 22 ; column = 37 ; value ='half_size'; }
|
||||
{kind = TOKEN_DOT; ; index = 555 ; length = 1 line = 22 ; column = 46 ; value ='.'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 556 ; length = 1 line = 22 ; column = 47 ; value ='x'; }
|
||||
{kind = TOKEN_PLUS; ; index = 558 ; length = 1 line = 22 ; column = 49 ; value ='+'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 560 ; length = 6 line = 22 ; column = 51 ; value ='center'; }
|
||||
{kind = TOKEN_DOT; ; index = 566 ; length = 1 line = 22 ; column = 57 ; value ='.'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 567 ; length = 1 line = 22 ; column = 58 ; value ='x'; }
|
||||
{kind = TOKEN_COMMA; ; index = 568 ; length = 1 line = 22 ; column = 59 ; value =','; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 570 ; length = 3 line = 22 ; column = 61 ; value ='pos'; }
|
||||
{kind = TOKEN_DOT; ; index = 573 ; length = 1 line = 22 ; column = 64 ; value ='.'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 574 ; length = 1 line = 22 ; column = 65 ; value ='y'; }
|
||||
{kind = TOKEN_STAR; ; index = 576 ; length = 1 line = 22 ; column = 67 ; value ='*'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 578 ; length = 9 line = 22 ; column = 69 ; value ='half_size'; }
|
||||
{kind = TOKEN_DOT; ; index = 587 ; length = 1 line = 22 ; column = 78 ; value ='.'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 588 ; length = 1 line = 22 ; column = 79 ; value ='y'; }
|
||||
{kind = TOKEN_PLUS; ; index = 590 ; length = 1 line = 22 ; column = 81 ; value ='+'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 592 ; length = 6 line = 22 ; column = 83 ; value ='center'; }
|
||||
{kind = TOKEN_DOT; ; index = 598 ; length = 1 line = 22 ; column = 89 ; value ='.'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 599 ; length = 1 line = 22 ; column = 90 ; value ='y'; }
|
||||
{kind = TOKEN_COMMA; ; index = 600 ; length = 1 line = 22 ; column = 91 ; value =','; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 602 ; length = 3 line = 22 ; column = 93 ; value ='0'; }
|
||||
{kind = TOKEN_COMMA; ; index = 605 ; length = 1 line = 22 ; column = 96 ; value =','; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 607 ; length = 3 line = 22 ; column = 98 ; value ='1'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 610 ; length = 1 line = 22 ; column = 101 ; value =')'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 611 ; length = 1 line = 22 ; column = 102 ; value =';'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 617 ; length = 6 line = 24 ; column = 0 ; value ='result'; }
|
||||
{kind = TOKEN_COLON; ; index = 624 ; length = 1 line = 24 ; column = 7 ; value =':'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 626 ; length = 8 line = 24 ; column = 9 ; value ='PS_Input'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 634 ; length = 1 line = 24 ; column = 17 ; value =';'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 640 ; length = 6 line = 26 ; column = 0 ; value ='src_p0'; }
|
||||
{kind = TOKEN_COLON; ; index = 647 ; length = 1 line = 26 ; column = 7 ; value =':'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 649 ; length = 6 line = 26 ; column = 9 ; value ='float2'; }
|
||||
{kind = TOKEN_ASSIGN; ; index = 656 ; length = 1 line = 26 ; column = 16 ; value ='='; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 658 ; length = 6 line = 26 ; column = 18 ; value ='float2'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 664 ; length = 1 line = 26 ; column = 24 ; value ='('; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 665 ; length = 3 line = 26 ; column = 25 ; value ='0'; }
|
||||
{kind = TOKEN_COMMA; ; index = 668 ; length = 1 line = 26 ; column = 28 ; value =','; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 670 ; length = 3 line = 26 ; column = 30 ; value ='1'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 673 ; length = 1 line = 26 ; column = 33 ; value =')'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 674 ; length = 1 line = 26 ; column = 34 ; value =';'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 678 ; length = 6 line = 27 ; column = 0 ; value ='src_p1'; }
|
||||
{kind = TOKEN_COLON; ; index = 685 ; length = 1 line = 27 ; column = 7 ; value =':'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 687 ; length = 6 line = 27 ; column = 9 ; value ='float2'; }
|
||||
{kind = TOKEN_ASSIGN; ; index = 694 ; length = 1 line = 27 ; column = 16 ; value ='='; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 696 ; length = 6 line = 27 ; column = 18 ; value ='float2'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 702 ; length = 1 line = 27 ; column = 24 ; value ='('; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 703 ; length = 3 line = 27 ; column = 25 ; value ='1'; }
|
||||
{kind = TOKEN_COMMA; ; index = 706 ; length = 1 line = 27 ; column = 28 ; value =','; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 708 ; length = 3 line = 27 ; column = 30 ; value ='0'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 711 ; length = 1 line = 27 ; column = 33 ; value =')'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 712 ; length = 1 line = 27 ; column = 34 ; value =';'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 718 ; length = 13 line = 29 ; column = 0 ; value ='src_half_size'; }
|
||||
{kind = TOKEN_COLON; ; index = 732 ; length = 1 line = 29 ; column = 14 ; value =':'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 734 ; length = 6 line = 29 ; column = 16 ; value ='float2'; }
|
||||
{kind = TOKEN_ASSIGN; ; index = 741 ; length = 1 line = 29 ; column = 23 ; value ='='; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 743 ; length = 1 line = 29 ; column = 25 ; value ='('; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 744 ; length = 6 line = 29 ; column = 26 ; value ='src_p1'; }
|
||||
{kind = TOKEN_MINUS; ; index = 751 ; length = 1 line = 29 ; column = 33 ; value ='-'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 753 ; length = 6 line = 29 ; column = 35 ; value ='src_p0'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 759 ; length = 1 line = 29 ; column = 41 ; value =')'; }
|
||||
{kind = TOKEN_SLASH; ; index = 761 ; length = 1 line = 29 ; column = 43 ; value ='/'; }
|
||||
{kind = TOKEN_INTLITERAL; ; index = 763 ; length = 1 line = 29 ; column = 45 ; value ='2'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 764 ; length = 1 line = 29 ; column = 46 ; value =';'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 768 ; length = 10 line = 30 ; column = 0 ; value ='src_center'; }
|
||||
{kind = TOKEN_COLON; ; index = 782 ; length = 1 line = 30 ; column = 14 ; value =':'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 784 ; length = 6 line = 30 ; column = 16 ; value ='float2'; }
|
||||
{kind = TOKEN_ASSIGN; ; index = 791 ; length = 1 line = 30 ; column = 23 ; value ='='; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 793 ; length = 1 line = 30 ; column = 25 ; value ='('; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 794 ; length = 6 line = 30 ; column = 26 ; value ='src_p1'; }
|
||||
{kind = TOKEN_PLUS; ; index = 801 ; length = 1 line = 30 ; column = 33 ; value ='+'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 803 ; length = 6 line = 30 ; column = 35 ; value ='src_p0'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 809 ; length = 1 line = 30 ; column = 41 ; value =')'; }
|
||||
{kind = TOKEN_SLASH; ; index = 811 ; length = 1 line = 30 ; column = 43 ; value ='/'; }
|
||||
{kind = TOKEN_INTLITERAL; ; index = 813 ; length = 1 line = 30 ; column = 45 ; value ='2'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 814 ; length = 1 line = 30 ; column = 46 ; value =';'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 818 ; length = 7 line = 31 ; column = 0 ; value ='src_pos'; }
|
||||
{kind = TOKEN_COLON; ; index = 832 ; length = 1 line = 31 ; column = 14 ; value =':'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 834 ; length = 6 line = 31 ; column = 16 ; value ='float2'; }
|
||||
{kind = TOKEN_ASSIGN; ; index = 841 ; length = 1 line = 31 ; column = 23 ; value ='='; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 843 ; length = 6 line = 31 ; column = 25 ; value ='float2'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 849 ; length = 1 line = 31 ; column = 31 ; value ='('; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 850 ; length = 3 line = 31 ; column = 32 ; value ='pos'; }
|
||||
{kind = TOKEN_DOT; ; index = 853 ; length = 1 line = 31 ; column = 35 ; value ='.'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 854 ; length = 1 line = 31 ; column = 36 ; value ='x'; }
|
||||
{kind = TOKEN_COMMA; ; index = 855 ; length = 1 line = 31 ; column = 37 ; value =','; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 857 ; length = 3 line = 31 ; column = 39 ; value ='pos'; }
|
||||
{kind = TOKEN_DOT; ; index = 860 ; length = 1 line = 31 ; column = 42 ; value ='.'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 861 ; length = 1 line = 31 ; column = 43 ; value ='y'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 862 ; length = 1 line = 31 ; column = 44 ; value =')'; }
|
||||
{kind = TOKEN_STAR; ; index = 864 ; length = 1 line = 31 ; column = 46 ; value ='*'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 866 ; length = 13 line = 31 ; column = 48 ; value ='src_half_size'; }
|
||||
{kind = TOKEN_PLUS; ; index = 880 ; length = 1 line = 31 ; column = 62 ; value ='+'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 882 ; length = 10 line = 31 ; column = 64 ; value ='src_center'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 892 ; length = 1 line = 31 ; column = 74 ; value =';'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 898 ; length = 6 line = 33 ; column = 0 ; value ='result'; }
|
||||
{kind = TOKEN_DOT; ; index = 904 ; length = 1 line = 33 ; column = 6 ; value ='.'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 905 ; length = 2 line = 33 ; column = 7 ; value ='uv'; }
|
||||
{kind = TOKEN_ASSIGN; ; index = 908 ; length = 1 line = 33 ; column = 10 ; value ='='; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 910 ; length = 6 line = 33 ; column = 12 ; value ='float2'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 916 ; length = 1 line = 33 ; column = 18 ; value ='('; }
|
||||
{kind = TOKEN_INTLITERAL; ; index = 917 ; length = 1 line = 33 ; column = 19 ; value ='1'; }
|
||||
{kind = TOKEN_COMMA; ; index = 918 ; length = 1 line = 33 ; column = 20 ; value =','; }
|
||||
{kind = TOKEN_INTLITERAL; ; index = 920 ; length = 1 line = 33 ; column = 22 ; value ='1'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 921 ; length = 1 line = 33 ; column = 23 ; value =')'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 922 ; length = 1 line = 33 ; column = 24 ; value =';'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 926 ; length = 6 line = 34 ; column = 0 ; value ='result'; }
|
||||
{kind = TOKEN_DOT; ; index = 932 ; length = 1 line = 34 ; column = 6 ; value ='.'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 933 ; length = 3 line = 34 ; column = 7 ; value ='pos'; }
|
||||
{kind = TOKEN_ASSIGN; ; index = 937 ; length = 1 line = 34 ; column = 11 ; value ='='; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 939 ; length = 6 line = 34 ; column = 13 ; value ='float4'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 945 ; length = 1 line = 34 ; column = 19 ; value ='('; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 946 ; length = 3 line = 34 ; column = 20 ; value ='2'; }
|
||||
{kind = TOKEN_STAR; ; index = 950 ; length = 1 line = 34 ; column = 24 ; value ='*'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 952 ; length = 7 line = 34 ; column = 26 ; value ='dst_pos'; }
|
||||
{kind = TOKEN_DOT; ; index = 959 ; length = 1 line = 34 ; column = 33 ; value ='.'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 960 ; length = 1 line = 34 ; column = 34 ; value ='x'; }
|
||||
{kind = TOKEN_SLASH; ; index = 962 ; length = 1 line = 34 ; column = 36 ; value ='/'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 964 ; length = 3 line = 34 ; column = 38 ; value ='res'; }
|
||||
{kind = TOKEN_DOT; ; index = 967 ; length = 1 line = 34 ; column = 41 ; value ='.'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 968 ; length = 1 line = 34 ; column = 42 ; value ='x'; }
|
||||
{kind = TOKEN_MINUS; ; index = 970 ; length = 1 line = 34 ; column = 44 ; value ='-'; }
|
||||
{kind = TOKEN_INTLITERAL; ; index = 972 ; length = 1 line = 34 ; column = 46 ; value ='1'; }
|
||||
{kind = TOKEN_COMMA; ; index = 973 ; length = 1 line = 34 ; column = 47 ; value =','; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 975 ; length = 3 line = 34 ; column = 49 ; value ='2'; }
|
||||
{kind = TOKEN_STAR; ; index = 979 ; length = 1 line = 34 ; column = 53 ; value ='*'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 981 ; length = 7 line = 34 ; column = 55 ; value ='dst_pos'; }
|
||||
{kind = TOKEN_DOT; ; index = 988 ; length = 1 line = 34 ; column = 62 ; value ='.'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 989 ; length = 1 line = 34 ; column = 63 ; value ='y'; }
|
||||
{kind = TOKEN_SLASH; ; index = 991 ; length = 1 line = 34 ; column = 65 ; value ='/'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 993 ; length = 3 line = 34 ; column = 67 ; value ='res'; }
|
||||
{kind = TOKEN_DOT; ; index = 996 ; length = 1 line = 34 ; column = 70 ; value ='.'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 997 ; length = 1 line = 34 ; column = 71 ; value ='y'; }
|
||||
{kind = TOKEN_MINUS; ; index = 999 ; length = 1 line = 34 ; column = 73 ; value ='-'; }
|
||||
{kind = TOKEN_INTLITERAL; ; index = 1001 ; length = 1 line = 34 ; column = 75 ; value ='1'; }
|
||||
{kind = TOKEN_COMMA; ; index = 1002 ; length = 1 line = 34 ; column = 76 ; value =','; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 1004 ; length = 3 line = 34 ; column = 78 ; value ='0'; }
|
||||
{kind = TOKEN_COMMA; ; index = 1007 ; length = 1 line = 34 ; column = 81 ; value =','; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 1009 ; length = 3 line = 34 ; column = 83 ; value ='1'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 1012 ; length = 1 line = 34 ; column = 86 ; value =')'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 1013 ; length = 1 line = 34 ; column = 87 ; value =';'; }
|
||||
{kind = TOKEN_RETURN; ; index = 1019 ; length = 6 line = 36 ; column = 0 ; value ='return'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 1026 ; length = 6 line = 36 ; column = 7 ; value ='result'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 1032 ; length = 1 line = 36 ; column = 13 ; value =';'; }
|
||||
{kind = TOKEN_RIGHTBRACE; ; index = 1035 ; length = 1 line = 37 ; column = 0 ; value ='}'; }
|
||||
{kind = TOKEN_PIXEL; ; index = 1040 ; length = 5 line = 39 ; column = 0 ; value ='pixel'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 1046 ; length = 4 line = 39 ; column = 6 ; value ='main'; }
|
||||
{kind = TOKEN_DOUBLECOLON; ; index = 1051 ; length = 2 line = 39 ; column = 11 ; value ='::'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 1054 ; length = 1 line = 39 ; column = 14 ; value ='('; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 1055 ; length = 5 line = 39 ; column = 15 ; value ='input'; }
|
||||
{kind = TOKEN_COLON; ; index = 1061 ; length = 1 line = 39 ; column = 21 ; value =':'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 1063 ; length = 8 line = 39 ; column = 23 ; value ='PS_Input'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 1071 ; length = 1 line = 39 ; column = 31 ; value =')'; }
|
||||
{kind = TOKEN_ARROW; ; index = 1073 ; length = 2 line = 39 ; column = 33 ; value ='->'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 1076 ; length = 6 line = 39 ; column = 36 ; value ='float4'; }
|
||||
{kind = TOKEN_AT; ; index = 1083 ; length = 1 line = 39 ; column = 43 ; value ='@'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 1084 ; length = 7 line = 39 ; column = 44 ; value ='target0'; }
|
||||
{kind = TOKEN_LEFTBRACE; ; index = 1092 ; length = 1 line = 39 ; column = 52 ; value ='{'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 1096 ; length = 5 line = 40 ; column = 0 ; value ='color'; }
|
||||
{kind = TOKEN_COLON; ; index = 1102 ; length = 1 line = 40 ; column = 6 ; value =':'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 1104 ; length = 6 line = 40 ; column = 8 ; value ='float4'; }
|
||||
{kind = TOKEN_ASSIGN; ; index = 1111 ; length = 1 line = 40 ; column = 15 ; value ='='; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 1113 ; length = 1 line = 40 ; column = 17 ; value ='p'; }
|
||||
{kind = TOKEN_DOT; ; index = 1114 ; length = 1 line = 40 ; column = 18 ; value ='.'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 1115 ; length = 5 line = 40 ; column = 19 ; value ='color'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 1120 ; length = 1 line = 40 ; column = 24 ; value =';'; }
|
||||
{kind = TOKEN_RETURN; ; index = 1124 ; length = 6 line = 41 ; column = 0 ; value ='return'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 1131 ; length = 5 line = 41 ; column = 7 ; value ='color'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 1136 ; length = 1 line = 41 ; column = 12 ; value =';'; }
|
||||
{kind = TOKEN_RIGHTBRACE; ; index = 1139 ; length = 1 line = 42 ; column = 0 ; value ='}'; }
|
||||
{kind = TOKEN_EOF; ; index = 1142 ; length = 0 line = 43 ; column = 0 ; value =''; }
|
||||
BIN
test/lex/load_test.golden
Normal file
BIN
test/lex/load_test.golden
Normal file
Binary file not shown.
64
test/lex/nested_if.golden
Normal file
64
test/lex/nested_if.golden
Normal file
@@ -0,0 +1,64 @@
|
||||
{kind = TOKEN_VERTEX; ; index = 0 ; length = 6 line = 1 ; column = 0 ; value ='vertex'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 7 ; length = 4 line = 1 ; column = 7 ; value ='main'; }
|
||||
{kind = TOKEN_DOUBLECOLON; ; index = 12 ; length = 2 line = 1 ; column = 12 ; value ='::'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 15 ; length = 1 line = 1 ; column = 15 ; value ='('; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 16 ; length = 3 line = 1 ; column = 16 ; value ='pos'; }
|
||||
{kind = TOKEN_COLON; ; index = 20 ; length = 1 line = 1 ; column = 20 ; value =':'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 22 ; length = 6 line = 1 ; column = 22 ; value ='float3'; }
|
||||
{kind = TOKEN_AT; ; index = 29 ; length = 1 line = 1 ; column = 29 ; value ='@'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 30 ; length = 8 line = 1 ; column = 30 ; value ='position'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 38 ; length = 1 line = 1 ; column = 38 ; value =')'; }
|
||||
{kind = TOKEN_ARROW; ; index = 40 ; length = 2 line = 1 ; column = 40 ; value ='->'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 43 ; length = 6 line = 1 ; column = 43 ; value ='float4'; }
|
||||
{kind = TOKEN_AT; ; index = 50 ; length = 1 line = 1 ; column = 50 ; value ='@'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 51 ; length = 8 line = 1 ; column = 51 ; value ='position'; }
|
||||
{kind = TOKEN_LEFTBRACE; ; index = 60 ; length = 1 line = 1 ; column = 60 ; value ='{'; }
|
||||
{kind = TOKEN_IF; ; index = 64 ; length = 2 line = 2 ; column = 0 ; value ='if'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 67 ; length = 3 line = 2 ; column = 3 ; value ='pos'; }
|
||||
{kind = TOKEN_DOT; ; index = 70 ; length = 1 line = 2 ; column = 6 ; value ='.'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 71 ; length = 1 line = 2 ; column = 7 ; value ='x'; }
|
||||
{kind = TOKEN_GREATER; ; index = 73 ; length = 1 line = 2 ; column = 9 ; value ='>'; }
|
||||
{kind = TOKEN_INTLITERAL; ; index = 75 ; length = 3 line = 2 ; column = 11 ; value ='100'; }
|
||||
{kind = TOKEN_LEFTBRACE; ; index = 79 ; length = 1 line = 2 ; column = 15 ; value ='{'; }
|
||||
{kind = TOKEN_IF; ; index = 84 ; length = 2 line = 3 ; column = 0 ; value ='if'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 87 ; length = 3 line = 3 ; column = 3 ; value ='pos'; }
|
||||
{kind = TOKEN_DOT; ; index = 90 ; length = 1 line = 3 ; column = 6 ; value ='.'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 91 ; length = 1 line = 3 ; column = 7 ; value ='x'; }
|
||||
{kind = TOKEN_GREATER; ; index = 93 ; length = 1 line = 3 ; column = 9 ; value ='>'; }
|
||||
{kind = TOKEN_INTLITERAL; ; index = 95 ; length = 2 line = 3 ; column = 11 ; value ='50'; }
|
||||
{kind = TOKEN_LEFTBRACE; ; index = 98 ; length = 1 line = 3 ; column = 14 ; value ='{'; }
|
||||
{kind = TOKEN_RETURN; ; index = 104 ; length = 6 line = 4 ; column = 0 ; value ='return'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 111 ; length = 6 line = 4 ; column = 7 ; value ='float4'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 117 ; length = 1 line = 4 ; column = 13 ; value ='('; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 118 ; length = 3 line = 4 ; column = 14 ; value ='pos'; }
|
||||
{kind = TOKEN_COMMA; ; index = 121 ; length = 1 line = 4 ; column = 17 ; value =','; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 123 ; length = 3 line = 4 ; column = 19 ; value ='1'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 126 ; length = 1 line = 4 ; column = 22 ; value =')'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 127 ; length = 1 line = 4 ; column = 23 ; value =';'; }
|
||||
{kind = TOKEN_RIGHTBRACE; ; index = 132 ; length = 1 line = 5 ; column = 0 ; value ='}'; }
|
||||
{kind = TOKEN_ELSE; ; index = 134 ; length = 4 line = 5 ; column = 2 ; value ='else'; }
|
||||
{kind = TOKEN_LEFTBRACE; ; index = 139 ; length = 1 line = 5 ; column = 7 ; value ='{'; }
|
||||
{kind = TOKEN_RETURN; ; index = 145 ; length = 6 line = 6 ; column = 0 ; value ='return'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 152 ; length = 6 line = 6 ; column = 7 ; value ='float4'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 158 ; length = 1 line = 6 ; column = 13 ; value ='('; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 159 ; length = 3 line = 6 ; column = 14 ; value ='1'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 162 ; length = 1 line = 6 ; column = 17 ; value =')'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 163 ; length = 1 line = 6 ; column = 18 ; value =';'; }
|
||||
{kind = TOKEN_RIGHTBRACE; ; index = 168 ; length = 1 line = 7 ; column = 0 ; value ='}'; }
|
||||
{kind = TOKEN_RETURN; ; index = 173 ; length = 6 line = 8 ; column = 0 ; value ='return'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 180 ; length = 6 line = 8 ; column = 7 ; value ='float4'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 186 ; length = 1 line = 8 ; column = 13 ; value ='('; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 187 ; length = 3 line = 8 ; column = 14 ; value ='pos'; }
|
||||
{kind = TOKEN_COMMA; ; index = 190 ; length = 1 line = 8 ; column = 17 ; value =','; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 192 ; length = 3 line = 8 ; column = 19 ; value ='1'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 195 ; length = 1 line = 8 ; column = 22 ; value =')'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 196 ; length = 1 line = 8 ; column = 23 ; value =';'; }
|
||||
{kind = TOKEN_RIGHTBRACE; ; index = 200 ; length = 1 line = 9 ; column = 0 ; value ='}'; }
|
||||
{kind = TOKEN_RETURN; ; index = 205 ; length = 6 line = 10 ; column = 0 ; value ='return'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 212 ; length = 6 line = 10 ; column = 7 ; value ='float4'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 218 ; length = 1 line = 10 ; column = 13 ; value ='('; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 219 ; length = 3 line = 10 ; column = 14 ; value ='0'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 222 ; length = 1 line = 10 ; column = 17 ; value =')'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 223 ; length = 1 line = 10 ; column = 18 ; value =';'; }
|
||||
{kind = TOKEN_RIGHTBRACE; ; index = 226 ; length = 1 line = 11 ; column = 0 ; value ='}'; }
|
||||
{kind = TOKEN_EOF; ; index = 229 ; length = 0 line = 12 ; column = 0 ; value =''; }
|
||||
35
test/lex/non_bool_cond.golden
Normal file
35
test/lex/non_bool_cond.golden
Normal file
@@ -0,0 +1,35 @@
|
||||
{kind = TOKEN_VERTEX; ; index = 0 ; length = 6 line = 1 ; column = 0 ; value ='vertex'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 7 ; length = 4 line = 1 ; column = 7 ; value ='main'; }
|
||||
{kind = TOKEN_DOUBLECOLON; ; index = 12 ; length = 2 line = 1 ; column = 12 ; value ='::'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 15 ; length = 1 line = 1 ; column = 15 ; value ='('; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 16 ; length = 3 line = 1 ; column = 16 ; value ='pos'; }
|
||||
{kind = TOKEN_COLON; ; index = 20 ; length = 1 line = 1 ; column = 20 ; value =':'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 22 ; length = 6 line = 1 ; column = 22 ; value ='float3'; }
|
||||
{kind = TOKEN_AT; ; index = 29 ; length = 1 line = 1 ; column = 29 ; value ='@'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 30 ; length = 8 line = 1 ; column = 30 ; value ='position'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 38 ; length = 1 line = 1 ; column = 38 ; value =')'; }
|
||||
{kind = TOKEN_ARROW; ; index = 40 ; length = 2 line = 1 ; column = 40 ; value ='->'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 43 ; length = 6 line = 1 ; column = 43 ; value ='float4'; }
|
||||
{kind = TOKEN_AT; ; index = 50 ; length = 1 line = 1 ; column = 50 ; value ='@'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 51 ; length = 8 line = 1 ; column = 51 ; value ='position'; }
|
||||
{kind = TOKEN_LEFTBRACE; ; index = 60 ; length = 1 line = 1 ; column = 60 ; value ='{'; }
|
||||
{kind = TOKEN_IF; ; index = 64 ; length = 2 line = 2 ; column = 0 ; value ='if'; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 67 ; length = 3 line = 2 ; column = 3 ; value ='1'; }
|
||||
{kind = TOKEN_LEFTBRACE; ; index = 71 ; length = 1 line = 2 ; column = 7 ; value ='{'; }
|
||||
{kind = TOKEN_RETURN; ; index = 76 ; length = 6 line = 3 ; column = 0 ; value ='return'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 83 ; length = 6 line = 3 ; column = 7 ; value ='float4'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 89 ; length = 1 line = 3 ; column = 13 ; value ='('; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 90 ; length = 3 line = 3 ; column = 14 ; value ='pos'; }
|
||||
{kind = TOKEN_COMMA; ; index = 93 ; length = 1 line = 3 ; column = 17 ; value =','; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 95 ; length = 3 line = 3 ; column = 19 ; value ='1'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 98 ; length = 1 line = 3 ; column = 22 ; value =')'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 99 ; length = 1 line = 3 ; column = 23 ; value =';'; }
|
||||
{kind = TOKEN_RIGHTBRACE; ; index = 103 ; length = 1 line = 4 ; column = 0 ; value ='}'; }
|
||||
{kind = TOKEN_RETURN; ; index = 107 ; length = 6 line = 5 ; column = 0 ; value ='return'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 114 ; length = 6 line = 5 ; column = 7 ; value ='float4'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 120 ; length = 1 line = 5 ; column = 13 ; value ='('; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 121 ; length = 3 line = 5 ; column = 14 ; value ='0'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 124 ; length = 1 line = 5 ; column = 17 ; value =')'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 125 ; length = 1 line = 5 ; column = 18 ; value =';'; }
|
||||
{kind = TOKEN_RIGHTBRACE; ; index = 128 ; length = 1 line = 6 ; column = 0 ; value ='}'; }
|
||||
{kind = TOKEN_EOF; ; index = 131 ; length = 0 line = 7 ; column = 0 ; value =''; }
|
||||
@@ -1,45 +1,45 @@
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 0 ; length = 5 line = 1 ; column = 0 ; value ='props'; }
|
||||
{kind = TOKEN_COLON; ; index = 6 ; length = 1 line = 1 ; column = 6 ; value =':'; }
|
||||
{kind = TOKEN_PROPERTIES; ; index = 8 ; length = 10 line = 1 ; column = 8 ; value ='properties'; }
|
||||
{kind = TOKEN_LEFTBRACE; ; index = 19 ; length = 1 line = 1 ; column = 19 ; value ='{'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 23 ; length = 5 line = 2 ; column = 0 ; value ='color'; }
|
||||
{kind = TOKEN_COLON; ; index = 29 ; length = 1 line = 2 ; column = 6 ; value =':'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 31 ; length = 6 line = 2 ; column = 8 ; value ='float4'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 37 ; length = 1 line = 2 ; column = 14 ; value =';'; }
|
||||
{kind = TOKEN_RIGHTBRACE; ; index = 40 ; length = 1 line = 3 ; column = 0 ; value ='}'; }
|
||||
{kind = TOKEN_VERTEX; ; index = 45 ; length = 6 line = 5 ; column = 0 ; value ='vertex'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 52 ; length = 4 line = 5 ; column = 7 ; value ='main'; }
|
||||
{kind = TOKEN_DOUBLECOLON; ; index = 57 ; length = 2 line = 5 ; column = 12 ; value ='::'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 60 ; length = 1 line = 5 ; column = 15 ; value ='('; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 61 ; length = 3 line = 5 ; column = 16 ; value ='pos'; }
|
||||
{kind = TOKEN_COLON; ; index = 65 ; length = 1 line = 5 ; column = 20 ; value =':'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 67 ; length = 6 line = 5 ; column = 22 ; value ='float4'; }
|
||||
{kind = TOKEN_AT; ; index = 74 ; length = 1 line = 5 ; column = 29 ; value ='@'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 75 ; length = 8 line = 5 ; column = 30 ; value ='position'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 83 ; length = 1 line = 5 ; column = 38 ; value =')'; }
|
||||
{kind = TOKEN_ARROW; ; index = 85 ; length = 2 line = 5 ; column = 40 ; value ='->'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 88 ; length = 6 line = 5 ; column = 43 ; value ='float4'; }
|
||||
{kind = TOKEN_AT; ; index = 95 ; length = 1 line = 5 ; column = 50 ; value ='@'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 96 ; length = 8 line = 5 ; column = 51 ; value ='position'; }
|
||||
{kind = TOKEN_LEFTBRACE; ; index = 105 ; length = 1 line = 5 ; column = 60 ; value ='{'; }
|
||||
{kind = TOKEN_RETURN; ; index = 109 ; length = 6 line = 6 ; column = 0 ; value ='return'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 116 ; length = 3 line = 6 ; column = 7 ; value ='pos'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 119 ; length = 1 line = 6 ; column = 10 ; value =';'; }
|
||||
{kind = TOKEN_RIGHTBRACE; ; index = 122 ; length = 1 line = 7 ; column = 0 ; value ='}'; }
|
||||
{kind = TOKEN_PIXEL; ; index = 127 ; length = 5 line = 9 ; column = 0 ; value ='pixel'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 133 ; length = 4 line = 9 ; column = 6 ; value ='main'; }
|
||||
{kind = TOKEN_DOUBLECOLON; ; index = 138 ; length = 2 line = 9 ; column = 11 ; value ='::'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 141 ; length = 1 line = 9 ; column = 14 ; value ='('; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 142 ; length = 1 line = 9 ; column = 15 ; value =')'; }
|
||||
{kind = TOKEN_ARROW; ; index = 144 ; length = 2 line = 9 ; column = 17 ; value ='->'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 147 ; length = 6 line = 9 ; column = 20 ; value ='float4'; }
|
||||
{kind = TOKEN_AT; ; index = 154 ; length = 1 line = 9 ; column = 27 ; value ='@'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 155 ; length = 7 line = 9 ; column = 28 ; value ='target0'; }
|
||||
{kind = TOKEN_LEFTBRACE; ; index = 163 ; length = 1 line = 9 ; column = 36 ; value ='{'; }
|
||||
{kind = TOKEN_RETURN; ; index = 169 ; length = 6 line = 10 ; column = 2 ; value ='return'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 176 ; length = 5 line = 10 ; column = 9 ; value ='props'; }
|
||||
{kind = TOKEN_DOT; ; index = 181 ; length = 1 line = 10 ; column = 14 ; value ='.'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 182 ; length = 5 line = 10 ; column = 15 ; value ='color'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 187 ; length = 1 line = 10 ; column = 20 ; value =';'; }
|
||||
{kind = TOKEN_RIGHTBRACE; ; index = 190 ; length = 1 line = 11 ; column = 0 ; value ='}'; }
|
||||
{kind = TOKEN_EOF; ; index = 193 ; length = 0 line = 12 ; column = 0 ; value =''; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 0 ; length = 5 line = 1 ; column = 0 ; value ='props'; }
|
||||
{kind = TOKEN_DOUBLECOLON; ; index = 6 ; length = 2 line = 1 ; column = 6 ; value ='::'; }
|
||||
{kind = TOKEN_PROPERTIES; ; index = 9 ; length = 10 line = 1 ; column = 9 ; value ='properties'; }
|
||||
{kind = TOKEN_LEFTBRACE; ; index = 20 ; length = 1 line = 1 ; column = 20 ; value ='{'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 24 ; length = 5 line = 2 ; column = 0 ; value ='color'; }
|
||||
{kind = TOKEN_COLON; ; index = 30 ; length = 1 line = 2 ; column = 6 ; value =':'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 32 ; length = 6 line = 2 ; column = 8 ; value ='float4'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 38 ; length = 1 line = 2 ; column = 14 ; 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 ='float4'; }
|
||||
{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 = 3 line = 6 ; column = 7 ; value ='pos'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 120 ; length = 1 line = 6 ; column = 10 ; value =';'; }
|
||||
{kind = TOKEN_RIGHTBRACE; ; index = 123 ; length = 1 line = 7 ; column = 0 ; value ='}'; }
|
||||
{kind = TOKEN_PIXEL; ; index = 128 ; length = 5 line = 9 ; column = 0 ; value ='pixel'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 134 ; length = 4 line = 9 ; column = 6 ; value ='main'; }
|
||||
{kind = TOKEN_DOUBLECOLON; ; index = 139 ; length = 2 line = 9 ; column = 11 ; value ='::'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 142 ; length = 1 line = 9 ; column = 14 ; value ='('; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 143 ; length = 1 line = 9 ; column = 15 ; value =')'; }
|
||||
{kind = TOKEN_ARROW; ; index = 145 ; length = 2 line = 9 ; column = 17 ; value ='->'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 148 ; length = 6 line = 9 ; column = 20 ; value ='float4'; }
|
||||
{kind = TOKEN_AT; ; index = 155 ; length = 1 line = 9 ; column = 27 ; value ='@'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 156 ; length = 7 line = 9 ; column = 28 ; value ='target0'; }
|
||||
{kind = TOKEN_LEFTBRACE; ; index = 164 ; length = 1 line = 9 ; column = 36 ; value ='{'; }
|
||||
{kind = TOKEN_RETURN; ; index = 170 ; length = 6 line = 10 ; column = 2 ; value ='return'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 177 ; length = 5 line = 10 ; column = 9 ; value ='props'; }
|
||||
{kind = TOKEN_DOT; ; index = 182 ; length = 1 line = 10 ; column = 14 ; value ='.'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 183 ; length = 5 line = 10 ; column = 15 ; value ='color'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 188 ; length = 1 line = 10 ; column = 20 ; value =';'; }
|
||||
{kind = TOKEN_RIGHTBRACE; ; index = 191 ; length = 1 line = 11 ; column = 0 ; value ='}'; }
|
||||
{kind = TOKEN_EOF; ; index = 194 ; length = 0 line = 12 ; column = 0 ; value =''; }
|
||||
|
||||
65
test/lex/simple_else_if.golden
Normal file
65
test/lex/simple_else_if.golden
Normal file
@@ -0,0 +1,65 @@
|
||||
{kind = TOKEN_VERTEX; ; index = 0 ; length = 6 line = 1 ; column = 0 ; value ='vertex'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 7 ; length = 4 line = 1 ; column = 7 ; value ='main'; }
|
||||
{kind = TOKEN_DOUBLECOLON; ; index = 12 ; length = 2 line = 1 ; column = 12 ; value ='::'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 15 ; length = 1 line = 1 ; column = 15 ; value ='('; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 16 ; length = 3 line = 1 ; column = 16 ; value ='pos'; }
|
||||
{kind = TOKEN_COLON; ; index = 20 ; length = 1 line = 1 ; column = 20 ; value =':'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 22 ; length = 6 line = 1 ; column = 22 ; value ='float3'; }
|
||||
{kind = TOKEN_AT; ; index = 29 ; length = 1 line = 1 ; column = 29 ; value ='@'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 30 ; length = 8 line = 1 ; column = 30 ; value ='position'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 38 ; length = 1 line = 1 ; column = 38 ; value =')'; }
|
||||
{kind = TOKEN_ARROW; ; index = 40 ; length = 2 line = 1 ; column = 40 ; value ='->'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 43 ; length = 6 line = 1 ; column = 43 ; value ='float4'; }
|
||||
{kind = TOKEN_AT; ; index = 50 ; length = 1 line = 1 ; column = 50 ; value ='@'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 51 ; length = 8 line = 1 ; column = 51 ; value ='position'; }
|
||||
{kind = TOKEN_LEFTBRACE; ; index = 60 ; length = 1 line = 1 ; column = 60 ; value ='{'; }
|
||||
{kind = TOKEN_IF; ; index = 64 ; length = 2 line = 2 ; column = 0 ; value ='if'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 67 ; length = 3 line = 2 ; column = 3 ; value ='pos'; }
|
||||
{kind = TOKEN_DOT; ; index = 70 ; length = 1 line = 2 ; column = 6 ; value ='.'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 71 ; length = 1 line = 2 ; column = 7 ; value ='x'; }
|
||||
{kind = TOKEN_GREATER; ; index = 73 ; length = 1 line = 2 ; column = 9 ; value ='>'; }
|
||||
{kind = TOKEN_INTLITERAL; ; index = 75 ; length = 3 line = 2 ; column = 11 ; value ='100'; }
|
||||
{kind = TOKEN_LEFTBRACE; ; index = 79 ; length = 1 line = 2 ; column = 15 ; value ='{'; }
|
||||
{kind = TOKEN_RETURN; ; index = 84 ; length = 6 line = 3 ; column = 0 ; value ='return'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 91 ; length = 6 line = 3 ; column = 7 ; value ='float4'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 97 ; length = 1 line = 3 ; column = 13 ; value ='('; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 98 ; length = 3 line = 3 ; column = 14 ; value ='pos'; }
|
||||
{kind = TOKEN_COMMA; ; index = 101 ; length = 1 line = 3 ; column = 17 ; value =','; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 103 ; length = 3 line = 3 ; column = 19 ; value ='1'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 106 ; length = 1 line = 3 ; column = 22 ; value =')'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 107 ; length = 1 line = 3 ; column = 23 ; value =';'; }
|
||||
{kind = TOKEN_RIGHTBRACE; ; index = 111 ; length = 1 line = 4 ; column = 0 ; value ='}'; }
|
||||
{kind = TOKEN_ELSE; ; index = 113 ; length = 4 line = 4 ; column = 2 ; value ='else'; }
|
||||
{kind = TOKEN_IF; ; index = 118 ; length = 2 line = 4 ; column = 7 ; value ='if'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 121 ; length = 3 line = 4 ; column = 10 ; value ='pos'; }
|
||||
{kind = TOKEN_DOT; ; index = 124 ; length = 1 line = 4 ; column = 13 ; value ='.'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 125 ; length = 1 line = 4 ; column = 14 ; value ='x'; }
|
||||
{kind = TOKEN_GREATER; ; index = 127 ; length = 1 line = 4 ; column = 16 ; value ='>'; }
|
||||
{kind = TOKEN_INTLITERAL; ; index = 129 ; length = 2 line = 4 ; column = 18 ; value ='50'; }
|
||||
{kind = TOKEN_LEFTBRACE; ; index = 132 ; length = 1 line = 4 ; column = 21 ; value ='{'; }
|
||||
{kind = TOKEN_RETURN; ; index = 137 ; length = 6 line = 5 ; column = 0 ; value ='return'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 144 ; length = 6 line = 5 ; column = 7 ; value ='float4'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 150 ; length = 1 line = 5 ; column = 13 ; value ='('; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 151 ; length = 3 line = 5 ; column = 14 ; value ='pos'; }
|
||||
{kind = TOKEN_COMMA; ; index = 154 ; length = 1 line = 5 ; column = 17 ; value =','; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 156 ; length = 3 line = 5 ; column = 19 ; value ='1'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 159 ; length = 1 line = 5 ; column = 22 ; value =')'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 160 ; length = 1 line = 5 ; column = 23 ; value =';'; }
|
||||
{kind = TOKEN_RIGHTBRACE; ; index = 164 ; length = 1 line = 6 ; column = 0 ; value ='}'; }
|
||||
{kind = TOKEN_ELSE; ; index = 166 ; length = 4 line = 6 ; column = 2 ; value ='else'; }
|
||||
{kind = TOKEN_LEFTBRACE; ; index = 171 ; length = 1 line = 6 ; column = 7 ; value ='{'; }
|
||||
{kind = TOKEN_RETURN; ; index = 176 ; length = 6 line = 7 ; column = 0 ; value ='return'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 183 ; length = 6 line = 7 ; column = 7 ; value ='float4'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 189 ; length = 1 line = 7 ; column = 13 ; value ='('; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 190 ; length = 3 line = 7 ; column = 14 ; value ='1'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 193 ; length = 1 line = 7 ; column = 17 ; value =')'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 194 ; length = 1 line = 7 ; column = 18 ; value =';'; }
|
||||
{kind = TOKEN_RIGHTBRACE; ; index = 198 ; length = 1 line = 8 ; column = 0 ; value ='}'; }
|
||||
{kind = TOKEN_RETURN; ; index = 202 ; length = 6 line = 9 ; column = 0 ; value ='return'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 209 ; length = 6 line = 9 ; column = 7 ; value ='float4'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 215 ; length = 1 line = 9 ; column = 13 ; value ='('; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 216 ; length = 3 line = 9 ; column = 14 ; value ='0'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 219 ; length = 1 line = 9 ; column = 17 ; value =')'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 220 ; length = 1 line = 9 ; column = 18 ; value =';'; }
|
||||
{kind = TOKEN_RIGHTBRACE; ; index = 223 ; length = 1 line = 10 ; column = 0 ; value ='}'; }
|
||||
{kind = TOKEN_EOF; ; index = 228 ; length = 0 line = 12 ; column = 0 ; value =''; }
|
||||
37
test/lex/simple_if.golden
Normal file
37
test/lex/simple_if.golden
Normal file
@@ -0,0 +1,37 @@
|
||||
{kind = TOKEN_VERTEX; ; index = 0 ; length = 6 line = 1 ; column = 0 ; value ='vertex'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 7 ; length = 4 line = 1 ; column = 7 ; value ='main'; }
|
||||
{kind = TOKEN_DOUBLECOLON; ; index = 12 ; length = 2 line = 1 ; column = 12 ; value ='::'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 15 ; length = 1 line = 1 ; column = 15 ; value ='('; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 16 ; length = 3 line = 1 ; column = 16 ; value ='pos'; }
|
||||
{kind = TOKEN_COLON; ; index = 20 ; length = 1 line = 1 ; column = 20 ; value =':'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 22 ; length = 6 line = 1 ; column = 22 ; value ='float3'; }
|
||||
{kind = TOKEN_AT; ; index = 29 ; length = 1 line = 1 ; column = 29 ; value ='@'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 30 ; length = 8 line = 1 ; column = 30 ; value ='position'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 38 ; length = 1 line = 1 ; column = 38 ; value =')'; }
|
||||
{kind = TOKEN_ARROW; ; index = 40 ; length = 2 line = 1 ; column = 40 ; value ='->'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 43 ; length = 6 line = 1 ; column = 43 ; value ='float4'; }
|
||||
{kind = TOKEN_AT; ; index = 50 ; length = 1 line = 1 ; column = 50 ; value ='@'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 51 ; length = 8 line = 1 ; column = 51 ; value ='position'; }
|
||||
{kind = TOKEN_LEFTBRACE; ; index = 60 ; length = 1 line = 1 ; column = 60 ; value ='{'; }
|
||||
{kind = TOKEN_IF; ; index = 64 ; length = 2 line = 2 ; column = 0 ; value ='if'; }
|
||||
{kind = TOKEN_INTLITERAL; ; index = 67 ; length = 1 line = 2 ; column = 3 ; value ='0'; }
|
||||
{kind = TOKEN_GREATER; ; index = 69 ; length = 1 line = 2 ; column = 5 ; value ='>'; }
|
||||
{kind = TOKEN_INTLITERAL; ; index = 71 ; length = 3 line = 2 ; column = 7 ; value ='100'; }
|
||||
{kind = TOKEN_LEFTBRACE; ; index = 75 ; length = 1 line = 2 ; column = 11 ; value ='{'; }
|
||||
{kind = TOKEN_RETURN; ; index = 80 ; length = 6 line = 3 ; column = 0 ; value ='return'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 87 ; length = 6 line = 3 ; column = 7 ; value ='float4'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 93 ; length = 1 line = 3 ; column = 13 ; value ='('; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 94 ; length = 3 line = 3 ; column = 14 ; value ='pos'; }
|
||||
{kind = TOKEN_COMMA; ; index = 97 ; length = 1 line = 3 ; column = 17 ; value =','; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 99 ; length = 3 line = 3 ; column = 19 ; value ='1'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 102 ; length = 1 line = 3 ; column = 22 ; value =')'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 103 ; length = 1 line = 3 ; column = 23 ; value =';'; }
|
||||
{kind = TOKEN_RIGHTBRACE; ; index = 107 ; length = 1 line = 4 ; column = 0 ; value ='}'; }
|
||||
{kind = TOKEN_RETURN; ; index = 111 ; length = 6 line = 5 ; column = 0 ; value ='return'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 118 ; length = 6 line = 5 ; column = 7 ; value ='float4'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 124 ; length = 1 line = 5 ; column = 13 ; value ='('; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 125 ; length = 3 line = 5 ; column = 14 ; value ='0'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 128 ; length = 1 line = 5 ; column = 17 ; value =')'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 129 ; length = 1 line = 5 ; column = 18 ; value =';'; }
|
||||
{kind = TOKEN_RIGHTBRACE; ; index = 132 ; length = 1 line = 6 ; column = 0 ; value ='}'; }
|
||||
{kind = TOKEN_EOF; ; index = 135 ; length = 0 line = 7 ; column = 0 ; value =''; }
|
||||
46
test/lex/simple_if_else.golden
Normal file
46
test/lex/simple_if_else.golden
Normal file
@@ -0,0 +1,46 @@
|
||||
{kind = TOKEN_VERTEX; ; index = 0 ; length = 6 line = 1 ; column = 0 ; value ='vertex'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 7 ; length = 4 line = 1 ; column = 7 ; value ='main'; }
|
||||
{kind = TOKEN_DOUBLECOLON; ; index = 12 ; length = 2 line = 1 ; column = 12 ; value ='::'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 15 ; length = 1 line = 1 ; column = 15 ; value ='('; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 16 ; length = 3 line = 1 ; column = 16 ; value ='pos'; }
|
||||
{kind = TOKEN_COLON; ; index = 20 ; length = 1 line = 1 ; column = 20 ; value =':'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 22 ; length = 6 line = 1 ; column = 22 ; value ='float3'; }
|
||||
{kind = TOKEN_AT; ; index = 29 ; length = 1 line = 1 ; column = 29 ; value ='@'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 30 ; length = 8 line = 1 ; column = 30 ; value ='position'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 38 ; length = 1 line = 1 ; column = 38 ; value =')'; }
|
||||
{kind = TOKEN_ARROW; ; index = 40 ; length = 2 line = 1 ; column = 40 ; value ='->'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 43 ; length = 6 line = 1 ; column = 43 ; value ='float4'; }
|
||||
{kind = TOKEN_AT; ; index = 50 ; length = 1 line = 1 ; column = 50 ; value ='@'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 51 ; length = 8 line = 1 ; column = 51 ; value ='position'; }
|
||||
{kind = TOKEN_LEFTBRACE; ; index = 60 ; length = 1 line = 1 ; column = 60 ; value ='{'; }
|
||||
{kind = TOKEN_IF; ; index = 64 ; length = 2 line = 2 ; column = 0 ; value ='if'; }
|
||||
{kind = TOKEN_INTLITERAL; ; index = 67 ; length = 1 line = 2 ; column = 3 ; value ='0'; }
|
||||
{kind = TOKEN_GREATER; ; index = 69 ; length = 1 line = 2 ; column = 5 ; value ='>'; }
|
||||
{kind = TOKEN_INTLITERAL; ; index = 71 ; length = 3 line = 2 ; column = 7 ; value ='100'; }
|
||||
{kind = TOKEN_LEFTBRACE; ; index = 75 ; length = 1 line = 2 ; column = 11 ; value ='{'; }
|
||||
{kind = TOKEN_RETURN; ; index = 80 ; length = 6 line = 3 ; column = 0 ; value ='return'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 87 ; length = 6 line = 3 ; column = 7 ; value ='float4'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 93 ; length = 1 line = 3 ; column = 13 ; value ='('; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 94 ; length = 3 line = 3 ; column = 14 ; value ='pos'; }
|
||||
{kind = TOKEN_COMMA; ; index = 97 ; length = 1 line = 3 ; column = 17 ; value =','; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 99 ; length = 3 line = 3 ; column = 19 ; value ='1'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 102 ; length = 1 line = 3 ; column = 22 ; value =')'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 103 ; length = 1 line = 3 ; column = 23 ; value =';'; }
|
||||
{kind = TOKEN_RIGHTBRACE; ; index = 107 ; length = 1 line = 4 ; column = 0 ; value ='}'; }
|
||||
{kind = TOKEN_ELSE; ; index = 109 ; length = 4 line = 4 ; column = 2 ; value ='else'; }
|
||||
{kind = TOKEN_LEFTBRACE; ; index = 114 ; length = 1 line = 4 ; column = 7 ; value ='{'; }
|
||||
{kind = TOKEN_RETURN; ; index = 119 ; length = 6 line = 5 ; column = 0 ; value ='return'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 126 ; length = 6 line = 5 ; column = 7 ; value ='float4'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 132 ; length = 1 line = 5 ; column = 13 ; value ='('; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 133 ; length = 3 line = 5 ; column = 14 ; value ='1'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 136 ; length = 1 line = 5 ; column = 17 ; value =')'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 137 ; length = 1 line = 5 ; column = 18 ; value =';'; }
|
||||
{kind = TOKEN_RIGHTBRACE; ; index = 141 ; length = 1 line = 6 ; column = 0 ; value ='}'; }
|
||||
{kind = TOKEN_RETURN; ; index = 145 ; length = 6 line = 7 ; column = 0 ; value ='return'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 152 ; length = 6 line = 7 ; column = 7 ; value ='float4'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 158 ; length = 1 line = 7 ; column = 13 ; value ='('; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 159 ; length = 3 line = 7 ; column = 14 ; value ='0'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 162 ; length = 1 line = 7 ; column = 17 ; value =')'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 163 ; length = 1 line = 7 ; column = 18 ; value =';'; }
|
||||
{kind = TOKEN_RIGHTBRACE; ; index = 166 ; length = 1 line = 8 ; column = 0 ; value ='}'; }
|
||||
{kind = TOKEN_EOF; ; index = 169 ; length = 0 line = 9 ; column = 0 ; value =''; }
|
||||
64
test/lex/unary.golden
Normal file
64
test/lex/unary.golden
Normal file
@@ -0,0 +1,64 @@
|
||||
{kind = TOKEN_VERTEX; ; index = 0 ; length = 6 line = 1 ; column = 0 ; value ='vertex'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 7 ; length = 7 line = 1 ; column = 7 ; value ='vs_main'; }
|
||||
{kind = TOKEN_DOUBLECOLON; ; index = 15 ; length = 2 line = 1 ; column = 15 ; value ='::'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 18 ; length = 1 line = 1 ; column = 18 ; value ='('; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 19 ; length = 8 line = 1 ; column = 19 ; value ='position'; }
|
||||
{kind = TOKEN_COLON; ; index = 28 ; length = 1 line = 1 ; column = 28 ; value =':'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 30 ; length = 6 line = 1 ; column = 30 ; value ='float3'; }
|
||||
{kind = TOKEN_AT; ; index = 37 ; length = 1 line = 1 ; column = 37 ; value ='@'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 38 ; length = 8 line = 1 ; column = 38 ; value ='position'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 46 ; length = 1 line = 1 ; column = 46 ; value =')'; }
|
||||
{kind = TOKEN_ARROW; ; index = 48 ; length = 2 line = 1 ; column = 48 ; value ='->'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 51 ; length = 6 line = 1 ; column = 51 ; value ='float4'; }
|
||||
{kind = TOKEN_AT; ; index = 58 ; length = 1 line = 1 ; column = 58 ; value ='@'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 59 ; length = 8 line = 1 ; column = 59 ; value ='position'; }
|
||||
{kind = TOKEN_LEFTBRACE; ; index = 68 ; length = 1 line = 1 ; column = 68 ; value ='{'; }
|
||||
{kind = TOKEN_RETURN; ; index = 75 ; length = 6 line = 2 ; column = 3 ; value ='return'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 82 ; length = 6 line = 2 ; column = 10 ; value ='float4'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 88 ; length = 1 line = 2 ; column = 16 ; value ='('; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 89 ; length = 8 line = 2 ; column = 17 ; value ='position'; }
|
||||
{kind = TOKEN_DOT; ; index = 97 ; length = 1 line = 2 ; column = 25 ; value ='.'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 98 ; length = 1 line = 2 ; column = 26 ; value ='x'; }
|
||||
{kind = TOKEN_COMMA; ; index = 99 ; length = 1 line = 2 ; column = 27 ; value =','; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 101 ; length = 8 line = 2 ; column = 29 ; value ='position'; }
|
||||
{kind = TOKEN_DOT; ; index = 109 ; length = 1 line = 2 ; column = 37 ; value ='.'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 110 ; length = 1 line = 2 ; column = 38 ; value ='y'; }
|
||||
{kind = TOKEN_COMMA; ; index = 111 ; length = 1 line = 2 ; column = 39 ; value =','; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 113 ; length = 8 line = 2 ; column = 41 ; value ='position'; }
|
||||
{kind = TOKEN_DOT; ; index = 121 ; length = 1 line = 2 ; column = 49 ; value ='.'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 122 ; length = 1 line = 2 ; column = 50 ; value ='z'; }
|
||||
{kind = TOKEN_COMMA; ; index = 123 ; length = 1 line = 2 ; column = 51 ; value =','; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 125 ; length = 3 line = 2 ; column = 53 ; value ='1'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 128 ; length = 1 line = 2 ; column = 56 ; value =')'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 129 ; length = 1 line = 2 ; column = 57 ; value =';'; }
|
||||
{kind = TOKEN_RIGHTBRACE; ; index = 132 ; length = 1 line = 3 ; column = 0 ; value ='}'; }
|
||||
{kind = TOKEN_PIXEL; ; index = 137 ; length = 5 line = 5 ; column = 0 ; value ='pixel'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 143 ; length = 7 line = 5 ; column = 6 ; value ='ps_main'; }
|
||||
{kind = TOKEN_DOUBLECOLON; ; index = 151 ; length = 2 line = 5 ; column = 14 ; value ='::'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 154 ; length = 1 line = 5 ; column = 17 ; value ='('; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 155 ; length = 8 line = 5 ; column = 18 ; value ='position'; }
|
||||
{kind = TOKEN_COLON; ; index = 164 ; length = 1 line = 5 ; column = 27 ; value =':'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 166 ; length = 6 line = 5 ; column = 29 ; value ='float4'; }
|
||||
{kind = TOKEN_AT; ; index = 173 ; length = 1 line = 5 ; column = 36 ; value ='@'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 174 ; length = 11 line = 5 ; column = 37 ; value ='outposition'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 185 ; length = 1 line = 5 ; column = 48 ; value =')'; }
|
||||
{kind = TOKEN_ARROW; ; index = 187 ; length = 2 line = 5 ; column = 50 ; value ='->'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 190 ; length = 6 line = 5 ; column = 53 ; value ='float4'; }
|
||||
{kind = TOKEN_AT; ; index = 197 ; length = 1 line = 5 ; column = 60 ; value ='@'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 198 ; length = 6 line = 5 ; column = 61 ; value ='target'; }
|
||||
{kind = TOKEN_LEFTBRACE; ; index = 205 ; length = 1 line = 5 ; column = 68 ; value ='{'; }
|
||||
{kind = TOKEN_RETURN; ; index = 211 ; length = 6 line = 6 ; column = 2 ; value ='return'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 218 ; length = 6 line = 6 ; column = 9 ; value ='float4'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 224 ; length = 1 line = 6 ; column = 15 ; value ='('; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 225 ; length = 3 line = 6 ; column = 16 ; value ='0.5'; }
|
||||
{kind = TOKEN_COMMA; ; index = 228 ; length = 1 line = 6 ; column = 19 ; value =','; }
|
||||
{kind = TOKEN_MINUS; ; index = 230 ; length = 1 line = 6 ; column = 21 ; value ='-'; }
|
||||
{kind = TOKEN_INTLITERAL; ; index = 231 ; length = 1 line = 6 ; column = 22 ; value ='1'; }
|
||||
{kind = TOKEN_COMMA; ; index = 232 ; length = 1 line = 6 ; column = 23 ; value =','; }
|
||||
{kind = TOKEN_INTLITERAL; ; index = 234 ; length = 1 line = 6 ; column = 25 ; value ='0'; }
|
||||
{kind = TOKEN_COMMA; ; index = 235 ; length = 1 line = 6 ; column = 26 ; value =','; }
|
||||
{kind = TOKEN_INTLITERAL; ; index = 237 ; length = 1 line = 6 ; column = 28 ; value ='1'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 238 ; length = 1 line = 6 ; column = 29 ; value =')'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 239 ; length = 1 line = 6 ; column = 30 ; value =';'; }
|
||||
{kind = TOKEN_RIGHTBRACE; ; index = 242 ; length = 1 line = 7 ; column = 0 ; value ='}'; }
|
||||
{kind = TOKEN_EOF; ; index = 243 ; length = 0 line = 7 ; column = 1 ; value =''; }
|
||||
@@ -1,33 +1,49 @@
|
||||
test/assign_arithmetic_expression.shd lex
|
||||
test/basic_property_and_return_value.shd lex
|
||||
test/complicated_computation.shd lex
|
||||
test/constant_buffer.shd lex
|
||||
test/empty_struct.shd lex
|
||||
test/empty_vertex_main.shd lex
|
||||
test/empty_vertex_main_with_position_parameter.shd lex
|
||||
test/field_assignment.shd lex
|
||||
test/field_without_type_specifier.shd lex
|
||||
test/float_suffix.shd lex
|
||||
test/function_call.shd lex
|
||||
test/function_call_out_of_order_declaration.shd lex
|
||||
test/function_call_return.shd lex
|
||||
test/functions_with_same_name.shd lex
|
||||
test/function_with_int_return.shd lex
|
||||
test/meta_block.shd lex
|
||||
test/multiple_functions.shd lex
|
||||
test/multiple_semicolons_everywhere.shd lex
|
||||
test/pass_and_access_struct_fields_in_functions.shd lex
|
||||
test/passthrough.shd lex
|
||||
test/property_rename.shd lex
|
||||
test/redeclared_variable.shd lex
|
||||
test/simple_struct_access.shd lex
|
||||
test/struct_access_primitive_type.shd lex
|
||||
test/struct_within_struct.shd lex
|
||||
test/type_as_variable_name.shd lex
|
||||
test/undeclared_function.shd lex
|
||||
test/undeclared_symbol.shd lex
|
||||
test/unknown_overload.shd lex
|
||||
test/use_builtin_functions.shd lex
|
||||
test/wrong_argument_count.shd lex
|
||||
test/wrong_multiply.shd lex
|
||||
test/wrong_type_for_function.shd lex
|
||||
test/assign_arithmetic_expression.ink lex
|
||||
test/basic_property_and_return_value.ink lex
|
||||
test/builtin_types.ink lex
|
||||
test/complicated_computation.ink lex
|
||||
test/constant_buffer.ink lex
|
||||
test/else_if_after_else.ink lex
|
||||
test/empty_struct.ink lex
|
||||
test/empty_vertex_main.ink lex
|
||||
test/empty_vertex_main_with_position_parameter.ink lex
|
||||
test/field_assignment.ink lex
|
||||
test/field_without_type_specifier.ink lex
|
||||
test/float_suffix.ink lex
|
||||
test/float_if_cond.ink lex
|
||||
test/for_i_loop.ink lex
|
||||
test/for_i_one_liner.ink lex
|
||||
test/for_no_iter.ink lex
|
||||
test/function_call.ink lex
|
||||
test/function_call_out_of_order_declaration.ink lex
|
||||
test/function_call_return.ink lex
|
||||
test/functions_with_same_name.ink lex
|
||||
test/function_with_int_return.ink lex
|
||||
test/if_cond_assign.ink lex
|
||||
test/if_if_if.ink lex
|
||||
test/inferred_types.ink lex
|
||||
test/large_block.ink lex
|
||||
test/meta_block.ink lex
|
||||
test/multiple_functions.ink lex
|
||||
test/multiple_semicolons_everywhere.ink lex
|
||||
test/nested_if.ink lex
|
||||
test/non_bool_cond.ink lex
|
||||
test/pass_and_access_struct_fields_in_functions.ink lex
|
||||
test/passthrough.ink lex
|
||||
test/property_rename.ink lex
|
||||
test/redeclared_variable.ink lex
|
||||
test/simple_else_if.ink lex
|
||||
test/simple_if_else.ink lex
|
||||
test/simple_if.ink lex
|
||||
test/simple_struct_access.ink lex
|
||||
test/struct_access_primitive_type.ink lex
|
||||
test/struct_within_struct.ink lex
|
||||
test/type_as_variable_name.ink lex
|
||||
test/unary.ink lex
|
||||
test/undeclared_function.ink lex
|
||||
test/undeclared_symbol.ink lex
|
||||
test/unknown_overload.ink lex
|
||||
test/use_builtin_functions.ink lex
|
||||
test/wrong_argument_count.ink lex
|
||||
test/wrong_multiply.ink lex
|
||||
test/wrong_type_for_function.ink lex
|
||||
|
||||
5
test/load_test.ink
Normal file
5
test/load_test.ink
Normal file
@@ -0,0 +1,5 @@
|
||||
#load "some_file.ink";
|
||||
|
||||
vertex main :: () {
|
||||
v2 : float2 = float2(2.0, 2.0);
|
||||
}
|
||||
11
test/nested_if.ink
Normal file
11
test/nested_if.ink
Normal file
@@ -0,0 +1,11 @@
|
||||
vertex main :: (pos : float3 @position) -> float4 @position {
|
||||
if pos.x > 100 {
|
||||
if pos.x > 50 {
|
||||
return float4(pos, 1.0);
|
||||
} else {
|
||||
return float4(1.0);
|
||||
}
|
||||
return float4(pos, 1.0);
|
||||
}
|
||||
return float4(0.0);
|
||||
}
|
||||
78
test/night_time.ink
Normal file
78
test/night_time.ink
Normal file
@@ -0,0 +1,78 @@
|
||||
p :: properties {
|
||||
input_tex : Texture2D;
|
||||
tex_sampler : Sampler;
|
||||
|
||||
hour_of_day : float;
|
||||
}
|
||||
|
||||
VS_Input :: struct {
|
||||
pos : float3 @position;
|
||||
uv : float2 @uv;
|
||||
}
|
||||
|
||||
VS_Output :: struct {
|
||||
pos : float4 @outposition;
|
||||
uv : float2 @uv;
|
||||
}
|
||||
|
||||
vertex main :: (input : VS_Input) -> VS_Output {
|
||||
output : VS_Output;
|
||||
output.pos = float4(input.pos, 1.0);
|
||||
output.uv = input.uv;
|
||||
return output;
|
||||
}
|
||||
|
||||
apply_night :: (color : float4) -> float4 {
|
||||
result := color;
|
||||
result -= float4(0.3, 0.2, 0.0, 0.0);
|
||||
result *= 0.8;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
apply_twilight :: (color : float4) -> float4 {
|
||||
result := color;
|
||||
result += float4(0.2, -0.1, 0.1, 0.0);
|
||||
result *= 0.9;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
apply_morning :: (color : float4) -> float4 {
|
||||
return color * 1.3;
|
||||
}
|
||||
|
||||
apply_dawn :: (color : float4) -> float4 {
|
||||
return color;
|
||||
}
|
||||
|
||||
pixel main :: (input : VS_Output) -> float4 @outposition {
|
||||
sampled_color : float4 = sample(p.input_tex, p.tex_sampler, input.uv);
|
||||
|
||||
t := 0.0;
|
||||
a := float4(0, 0, 0, 0);
|
||||
b := float4(0, 0, 0, 0);
|
||||
|
||||
if p.hour_of_day > 16 {
|
||||
t = (p.hour_of_day - 16) / 6;
|
||||
a = apply_twilight(sampled_color);
|
||||
b = apply_night(sampled_color);
|
||||
} else if p.hour_of_day > 12 {
|
||||
t = (p.hour_of_day - 12) / 6;
|
||||
a = sampled_color;
|
||||
b = apply_twilight(sampled_color);
|
||||
} else if p.hour_of_day > 6 {
|
||||
t = (p.hour_of_day - 6) / 6;
|
||||
a = apply_morning(sampled_color);
|
||||
b = sampled_color;
|
||||
} else if p.hour_of_day >= 0 {
|
||||
t = p.hour_of_day / 6;
|
||||
a = apply_night(sampled_color);
|
||||
b = apply_morning(sampled_color);
|
||||
}
|
||||
|
||||
return lerp(a, b, t);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user