init commit
This commit is contained in:
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
.build
|
||||||
|
*.exe
|
||||||
|
*.rdbg
|
||||||
|
*.pdb
|
||||||
|
*.rdi
|
||||||
369
AST.jai
Normal file
369
AST.jai
Normal file
@@ -0,0 +1,369 @@
|
|||||||
|
/////////////////////////////////////
|
||||||
|
//~ nbr: Node data structure
|
||||||
|
//
|
||||||
|
// [ ] Add a way to infer or get file path from a node
|
||||||
|
|
||||||
|
AST_Kind :: enum {
|
||||||
|
Program;
|
||||||
|
Function;
|
||||||
|
Return;
|
||||||
|
|
||||||
|
// @Incomplete(nb): Should these three really be their own block types?
|
||||||
|
// Maybe they at least shouldn't need to have their own tokens...
|
||||||
|
Properties;
|
||||||
|
Meta;
|
||||||
|
Instance;
|
||||||
|
//==
|
||||||
|
|
||||||
|
// Hint;
|
||||||
|
// Type;
|
||||||
|
// Operator;
|
||||||
|
Call;
|
||||||
|
Struct;
|
||||||
|
FieldList;
|
||||||
|
ArgList;
|
||||||
|
Variable;
|
||||||
|
Binary;
|
||||||
|
Unary;
|
||||||
|
Integer;
|
||||||
|
Float;
|
||||||
|
Expression_Statement;
|
||||||
|
Field;
|
||||||
|
Unnamed_Field;
|
||||||
|
Block;
|
||||||
|
Error;
|
||||||
|
}
|
||||||
|
|
||||||
|
AST_Node :: struct {
|
||||||
|
kind : AST_Kind;
|
||||||
|
|
||||||
|
// @Note(niels): Children nodes can be interpreted as anything useful.
|
||||||
|
// for an if-statement we would have at most 2 children
|
||||||
|
// a property block has a child node for each field declaration etc.
|
||||||
|
children : [..]*AST_Node;
|
||||||
|
parent : *AST_Node;
|
||||||
|
|
||||||
|
// @Note(niels): Every node can have a name, but most nodes don't. A function or field declaration has one,
|
||||||
|
// but an if-statement does not
|
||||||
|
name : string;
|
||||||
|
|
||||||
|
integer_value : int;
|
||||||
|
float_value : float;
|
||||||
|
|
||||||
|
token : Token;
|
||||||
|
|
||||||
|
assignment : bool;
|
||||||
|
|
||||||
|
source_location : Source_Range;
|
||||||
|
|
||||||
|
type_variable : Type_Variable_Handle;
|
||||||
|
|
||||||
|
foreign_declaration : bool;
|
||||||
|
|
||||||
|
// @Incomplete(nb): Change this to just be children and a single token_data field,
|
||||||
|
// then we can add new node types (hint, typespec, operator) and have them
|
||||||
|
// as children instead.
|
||||||
|
hint_tokens : [..]Token;
|
||||||
|
|
||||||
|
vertex_entry_point : bool;
|
||||||
|
pixel_entry_point : bool;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ===========================================================
|
||||||
|
// Pretty printing
|
||||||
|
pretty_print_call :: (node : *AST_Node, indentation : int, builder : *String_Builder) {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
append(builder, ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
pretty_print_arglist :: (node : *AST_Node, indentation : int, builder : *String_Builder) {
|
||||||
|
indent(builder, indentation);
|
||||||
|
append(builder, "[");
|
||||||
|
|
||||||
|
pretty_print_children(node, indentation + 1, builder, flags = .NewLine);
|
||||||
|
|
||||||
|
append(builder, "]");
|
||||||
|
}
|
||||||
|
|
||||||
|
pretty_print_fieldlist :: (node : *AST_Node, indentation : int, builder : *String_Builder) {
|
||||||
|
indent(builder, indentation);
|
||||||
|
|
||||||
|
append(builder, "[");
|
||||||
|
pretty_print_children(node, indentation + 1, builder, flags = .NewLine);
|
||||||
|
|
||||||
|
append(builder, "]");
|
||||||
|
}
|
||||||
|
|
||||||
|
pretty_print_field :: (node : *AST_Node, indentation : int, builder : *String_Builder) {
|
||||||
|
print_to_builder(builder, tprint("(:= %", node.name));
|
||||||
|
|
||||||
|
if node.kind != .Unnamed_Field && node.token.ident_value.count > 0 {
|
||||||
|
print_to_builder(builder, tprint(" %", node.token.ident_value));
|
||||||
|
}
|
||||||
|
|
||||||
|
for hint : node.hint_tokens {
|
||||||
|
if hint.string_value.count > 0 {
|
||||||
|
print_to_builder(builder, " (@%)", hint.string_value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if node.children.count > 0 {
|
||||||
|
append(builder, " ");
|
||||||
|
pretty_print_children(node, indentation, builder);
|
||||||
|
}
|
||||||
|
|
||||||
|
append(builder, ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
Children_Print_Flags :: enum_flags {
|
||||||
|
NewLine :: 1 << 0;
|
||||||
|
Separator :: 1 << 1;
|
||||||
|
Space :: 1 << 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
pretty_print_children :: (parent : *AST_Node, indentation : int, builder : *String_Builder, flags : Children_Print_Flags = .Separator) {
|
||||||
|
if !parent {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
children := parent.children;
|
||||||
|
for child : children {
|
||||||
|
if it_index > 0 {
|
||||||
|
indent(builder, indentation);
|
||||||
|
}
|
||||||
|
|
||||||
|
if !child continue;
|
||||||
|
pretty_print_node(child, 0, builder);
|
||||||
|
|
||||||
|
if it_index != children.count - 1 {
|
||||||
|
if flags & .Separator {
|
||||||
|
append(builder, ",");
|
||||||
|
}
|
||||||
|
|
||||||
|
append(builder, " ");
|
||||||
|
|
||||||
|
if flags & .NewLine {
|
||||||
|
append(builder, "\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
op_to_string :: (oper : Token) -> string {
|
||||||
|
if oper.kind == {
|
||||||
|
case .TOKEN_PLUS;
|
||||||
|
return "+";
|
||||||
|
case .TOKEN_MINUS;
|
||||||
|
return "-";
|
||||||
|
case .TOKEN_STAR;
|
||||||
|
return "*";
|
||||||
|
case .TOKEN_SLASH;
|
||||||
|
return "/";
|
||||||
|
case .TOKEN_ISEQUAL;
|
||||||
|
return "==";
|
||||||
|
case .TOKEN_ASSIGN;
|
||||||
|
return "=";
|
||||||
|
case .TOKEN_ISNOTEQUAL;
|
||||||
|
return "!=";
|
||||||
|
case .TOKEN_LOGICALOR;
|
||||||
|
return "||";
|
||||||
|
case .TOKEN_LOGICALAND;
|
||||||
|
return "&&";
|
||||||
|
case .TOKEN_LESS;
|
||||||
|
return "<";
|
||||||
|
case .TOKEN_LESSEQUALS;
|
||||||
|
return "<=";
|
||||||
|
case .TOKEN_GREATER;
|
||||||
|
return ">";
|
||||||
|
case .TOKEN_GREATEREQUALS;
|
||||||
|
return ">=";
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
pretty_print_binary :: (node : *AST_Node, indentation : int, builder : *String_Builder) {
|
||||||
|
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);
|
||||||
|
append(builder, ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
pretty_print_unary :: (node : *AST_Node, indentation : int, builder : *String_Builder) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
print_return_node :: (node : *AST_Node, indentation : int, builder : *String_Builder) {
|
||||||
|
append(builder, "(return ");
|
||||||
|
|
||||||
|
pretty_print_children(node, 0, builder);
|
||||||
|
|
||||||
|
append(builder, ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
print_expression_statement :: (node : *AST_Node, indentation : int, builder : *String_Builder) {
|
||||||
|
indent(builder, indentation);
|
||||||
|
|
||||||
|
if node.children[0] {
|
||||||
|
pretty_print_node(node.children[0], indentation, builder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pretty_print_node :: (node : *AST_Node, indentation : int, builder : *String_Builder) {
|
||||||
|
if node.kind == {
|
||||||
|
case .Return; {
|
||||||
|
print_return_node(node, indentation, builder);
|
||||||
|
}
|
||||||
|
case .Struct;
|
||||||
|
case .ArgList; {
|
||||||
|
pretty_print_arglist(node, indentation + 2, builder);
|
||||||
|
}
|
||||||
|
case .FieldList; {
|
||||||
|
pretty_print_fieldlist(node, indentation + 2, builder);
|
||||||
|
}
|
||||||
|
case .Field; {
|
||||||
|
pretty_print_field(node, indentation, builder);
|
||||||
|
}
|
||||||
|
case .Unnamed_Field; {
|
||||||
|
pretty_print_field(node, indentation, builder);
|
||||||
|
}
|
||||||
|
case .Block; {
|
||||||
|
pretty_print_children(node, indentation + 2, builder, flags = .NewLine);
|
||||||
|
}
|
||||||
|
case .Binary; {
|
||||||
|
pretty_print_binary(node, indentation, builder);
|
||||||
|
}
|
||||||
|
case .Unary; {
|
||||||
|
pretty_print_unary(node, indentation, builder);
|
||||||
|
}
|
||||||
|
case .Variable; {
|
||||||
|
pretty_print_variable(node, indentation, builder);
|
||||||
|
}
|
||||||
|
case .Expression_Statement; {
|
||||||
|
print_expression_statement(node, indentation, builder);
|
||||||
|
}
|
||||||
|
case .Integer; {
|
||||||
|
print_to_builder(builder, "%", node.integer_value);
|
||||||
|
}
|
||||||
|
case .Float; {
|
||||||
|
print_to_builder(builder, "%", node.float_value);
|
||||||
|
}
|
||||||
|
case .Call; {
|
||||||
|
pretty_print_call(node, indentation, builder);
|
||||||
|
}
|
||||||
|
case .Error; {
|
||||||
|
print_to_builder(builder, "(error \"%\")", node.name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pretty_print_variable :: (node : *AST_Node, indentation : int, builder : *String_Builder) {
|
||||||
|
indent(builder, indentation);
|
||||||
|
print_to_builder(builder, "%", node.name);
|
||||||
|
for child : node.children {
|
||||||
|
if child.kind == .Variable {
|
||||||
|
append(builder, ".");
|
||||||
|
pretty_print_variable(child, indentation, builder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pretty_print_declaration :: (declaration : *AST_Node, indentation : int, builder : *String_Builder) {
|
||||||
|
indent(builder, indentation);
|
||||||
|
append(builder, "(");
|
||||||
|
|
||||||
|
if declaration.foreign_declaration {
|
||||||
|
append(builder, "foreign ");
|
||||||
|
}
|
||||||
|
|
||||||
|
if declaration.kind == .Function {
|
||||||
|
append(builder, "fun ");
|
||||||
|
}
|
||||||
|
|
||||||
|
if declaration.vertex_entry_point {
|
||||||
|
append(builder, "vertex ");
|
||||||
|
}
|
||||||
|
|
||||||
|
if declaration.pixel_entry_point {
|
||||||
|
append(builder, "pixel ");
|
||||||
|
}
|
||||||
|
|
||||||
|
if declaration.kind == .Properties {
|
||||||
|
append(builder, "properties");
|
||||||
|
if declaration.name.count > 0 {
|
||||||
|
print_to_builder(builder, " %", declaration.name);
|
||||||
|
}
|
||||||
|
} else if declaration.kind == .Instance {
|
||||||
|
append(builder, "instance");
|
||||||
|
} else if declaration.kind == .Meta {
|
||||||
|
append(builder, "meta");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if declaration.kind == .Struct {
|
||||||
|
append(builder, "struct ");
|
||||||
|
}
|
||||||
|
print_to_builder(builder, "%", declaration.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
if declaration.kind == .Function && declaration.token.kind == .TOKEN_IDENTIFIER{
|
||||||
|
print_to_builder(builder, " -> %", declaration.token.ident_value);
|
||||||
|
for hint : declaration.hint_tokens {
|
||||||
|
if hint.string_value.count > 0 {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
append(builder, ")");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
pretty_print_ast :: (root : *AST_Node, allocator : Allocator) -> string {
|
||||||
|
builder : String_Builder;
|
||||||
|
init_string_builder(*builder,, allocator);
|
||||||
|
|
||||||
|
indentation := 0;
|
||||||
|
|
||||||
|
append(*builder, "(");
|
||||||
|
append(*builder, "program\t\n");
|
||||||
|
|
||||||
|
indentation += 1;
|
||||||
|
|
||||||
|
declarations := root.children;
|
||||||
|
|
||||||
|
for declaration : declarations {
|
||||||
|
pretty_print_declaration(declaration, indentation, *builder);
|
||||||
|
|
||||||
|
if it_index < declarations.count - 1 {
|
||||||
|
append(*builder, "\n\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
append(*builder, ")");
|
||||||
|
|
||||||
|
return builder_to_string(*builder,, allocator);
|
||||||
|
}
|
||||||
|
|
||||||
|
#scope_file
|
||||||
|
indent :: (builder : *String_Builder, indentation : int) {
|
||||||
|
for 0..indentation - 1 {
|
||||||
|
append(builder, " ");
|
||||||
|
}
|
||||||
|
}
|
||||||
403
Codegen.jai
Normal file
403
Codegen.jai
Normal file
@@ -0,0 +1,403 @@
|
|||||||
|
Output_Language :: enum {
|
||||||
|
HLSL;
|
||||||
|
GLSL;
|
||||||
|
}
|
||||||
|
|
||||||
|
Codegen_State :: struct {
|
||||||
|
path : string;
|
||||||
|
|
||||||
|
scope_stack : Scope_Stack;
|
||||||
|
current_scope : Scope_Handle;
|
||||||
|
|
||||||
|
type_variables : []Type_Variable;
|
||||||
|
root : *AST_Node;
|
||||||
|
|
||||||
|
output_language : Output_Language;
|
||||||
|
|
||||||
|
builder : String_Builder;
|
||||||
|
|
||||||
|
result : Codegen_Result;
|
||||||
|
}
|
||||||
|
|
||||||
|
Codegen_Result :: struct {
|
||||||
|
messages : [..]Compiler_Message;
|
||||||
|
|
||||||
|
had_error : bool;
|
||||||
|
|
||||||
|
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;
|
||||||
|
state.current_scope = cast(Scope_Handle)1;
|
||||||
|
init_string_builder(*state.builder);
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
field := h2tv(state.type_variables, find_result.type_variable);
|
||||||
|
|
||||||
|
indent(state, indentation);
|
||||||
|
print_to_builder(*state.builder, "% ", type_to_string(field));
|
||||||
|
print_to_builder(*state.builder, "%", node.name);
|
||||||
|
|
||||||
|
for i :0..node.children.count - 1 {
|
||||||
|
|
||||||
|
child := node.children[i];
|
||||||
|
|
||||||
|
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]);
|
||||||
|
emit_node(state, child.source_node, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
for hint : node.hint_tokens {
|
||||||
|
if hint.ident_value == "position" {
|
||||||
|
// @Incomplete(nb): Should be a lookup table somewhere
|
||||||
|
append(*state.builder, " : POSITION");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
emit_block :: (state : *Codegen_State, node : *AST_Node, indentation : int) {
|
||||||
|
for statement : node.children {
|
||||||
|
emit_node(state, statement, indentation);
|
||||||
|
|
||||||
|
if it_index < node.children.count {
|
||||||
|
append(*state.builder, ";\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
emit_call :: (state : *Codegen_State, node : *AST_Node, indentation : int) {
|
||||||
|
indent(state, indentation);
|
||||||
|
print_to_builder(*state.builder, "%(", node.name);
|
||||||
|
|
||||||
|
if node.children.count > 0 {
|
||||||
|
args := node.children[0];
|
||||||
|
|
||||||
|
for child : args.children {
|
||||||
|
emit_node(state, child, 0);
|
||||||
|
|
||||||
|
if it_index != args.children.count - 1 {
|
||||||
|
append(*state.builder, ", ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
append(*state.builder, ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
if !find_result {
|
||||||
|
message : Compiler_Message;
|
||||||
|
message.message_kind = .Internal_Error;
|
||||||
|
message.path = state.path;
|
||||||
|
message.message = "Attempting to generate undeclared properties buffer. This should never happen at this stage.";
|
||||||
|
array_add(*state.result.messages, message);
|
||||||
|
}
|
||||||
|
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);
|
||||||
|
|
||||||
|
print_to_builder(*state.builder, "cbuffer __PROPERTIES : register(b%) \n{\n", variable.buffer_index);
|
||||||
|
|
||||||
|
previous_scope := state.current_scope;
|
||||||
|
state.current_scope = variable.scope;
|
||||||
|
|
||||||
|
for child : node.children {
|
||||||
|
if child.kind == .FieldList {
|
||||||
|
for field : child.children {
|
||||||
|
emit_node(state, field, 1);
|
||||||
|
|
||||||
|
append(*state.builder, ";\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
state.current_scope = previous_scope;
|
||||||
|
|
||||||
|
append(*state.builder, "}\n\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
assert(find_result != null, "Attempting to generate undeclared function. This should never happen at this stage.");
|
||||||
|
if !find_result {
|
||||||
|
message : Compiler_Message;
|
||||||
|
message.message_kind = .Internal_Error;
|
||||||
|
message.path = state.path;
|
||||||
|
message.message = "Attempting to generate undeclared function. This should never happen at this stage.";
|
||||||
|
array_add(*state.result.messages, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
for func : find_result.functions {
|
||||||
|
function_variable := h2tv(state.type_variables, func.type_variable);
|
||||||
|
|
||||||
|
indent(state, indentation);
|
||||||
|
|
||||||
|
if function_variable.return_var {
|
||||||
|
return_variable := h2tv(state.type_variables, function_variable.return_var);
|
||||||
|
print_to_builder(*state.builder, "% ", type_to_string(return_variable));
|
||||||
|
} else {
|
||||||
|
append(*state.builder, "void ");
|
||||||
|
}
|
||||||
|
|
||||||
|
print_to_builder(*state.builder, "%", node.name);
|
||||||
|
|
||||||
|
previous_scope := state.current_scope;
|
||||||
|
state.current_scope = function_variable.scope;
|
||||||
|
|
||||||
|
append(*state.builder, "(");
|
||||||
|
|
||||||
|
if node.children.count > 0 && node.children[0].kind == .FieldList {
|
||||||
|
params := node.children[0];
|
||||||
|
|
||||||
|
for child : params.children {
|
||||||
|
emit_node(state, child, 0);
|
||||||
|
|
||||||
|
if it_index != params.children.count - 1 {
|
||||||
|
append(*state.builder, ", ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
append(*state.builder, ")");
|
||||||
|
|
||||||
|
for hint : node.hint_tokens {
|
||||||
|
if hint.ident_value == "position" {
|
||||||
|
// @Incomplete(nb): Should be a lookup table somewhere
|
||||||
|
append(*state.builder, " : SV_POSITION");
|
||||||
|
}
|
||||||
|
|
||||||
|
if starts_with(hint.ident_value, "target") {
|
||||||
|
// @Incomplete(nb): Should be a lookup table somewhere
|
||||||
|
append(*state.builder, " : SV_TARGET");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if emit_body {
|
||||||
|
append(*state.builder, "\n{\n");
|
||||||
|
|
||||||
|
|
||||||
|
if node.children.count > 1 {
|
||||||
|
emit_block(state, node.children[1], indentation + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
append(*state.builder, "}\n");
|
||||||
|
} else {
|
||||||
|
append(*state.builder, ";");
|
||||||
|
}
|
||||||
|
|
||||||
|
append(*state.builder, "\n");
|
||||||
|
|
||||||
|
|
||||||
|
state.current_scope = previous_scope;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
emit_operator :: (state : *Codegen_State, op_kind : Token_Kind) {
|
||||||
|
if op_kind == {
|
||||||
|
case .TOKEN_PLUS; {
|
||||||
|
append(*state.builder, "+");
|
||||||
|
}
|
||||||
|
case .TOKEN_MINUS; {
|
||||||
|
append(*state.builder, "-");
|
||||||
|
}
|
||||||
|
case .TOKEN_STAR; {
|
||||||
|
append(*state.builder, "*");
|
||||||
|
}
|
||||||
|
case .TOKEN_SLASH; {
|
||||||
|
append(*state.builder, "/");
|
||||||
|
}
|
||||||
|
case .TOKEN_ISEQUAL; {
|
||||||
|
append(*state.builder, "==");
|
||||||
|
}
|
||||||
|
case .TOKEN_ASSIGN; {
|
||||||
|
append(*state.builder, "=");
|
||||||
|
}
|
||||||
|
case .TOKEN_ISNOTEQUAL; {
|
||||||
|
append(*state.builder, "!=");
|
||||||
|
}
|
||||||
|
case .TOKEN_LOGICALOR; {
|
||||||
|
append(*state.builder, "||");
|
||||||
|
}
|
||||||
|
case .TOKEN_LOGICALAND; {
|
||||||
|
append(*state.builder, "&&");
|
||||||
|
}
|
||||||
|
case .TOKEN_LESS; {
|
||||||
|
append(*state.builder, "<");
|
||||||
|
}
|
||||||
|
case .TOKEN_LESSEQUALS; {
|
||||||
|
append(*state.builder, "<=");
|
||||||
|
}
|
||||||
|
case .TOKEN_GREATER; {
|
||||||
|
append(*state.builder, ">");
|
||||||
|
}
|
||||||
|
case .TOKEN_GREATEREQUALS; {
|
||||||
|
append(*state.builder, ">=");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
emit_node :: (state : *Codegen_State, node : *AST_Node, indentation : int) {
|
||||||
|
if node.kind == {
|
||||||
|
case .Integer; {
|
||||||
|
print_to_builder(*state.builder, "%", node.integer_value);
|
||||||
|
}
|
||||||
|
case .Float; {
|
||||||
|
print_to_builder(*state.builder, "%f", formatFloat(node.float_value, zero_removal=.ONE_ZERO_AFTER_DECIMAL));
|
||||||
|
}
|
||||||
|
case .Properties; {
|
||||||
|
|
||||||
|
}
|
||||||
|
case .Field; {
|
||||||
|
emit_field(state, node, indentation);
|
||||||
|
}
|
||||||
|
case .Block; {
|
||||||
|
assert(false, "Not implemented yet: block");
|
||||||
|
}
|
||||||
|
case .Variable; {
|
||||||
|
indent(*state.builder, indentation);
|
||||||
|
|
||||||
|
is_properties := node.name == "properties";
|
||||||
|
|
||||||
|
if !is_properties {
|
||||||
|
print_to_builder(*state.builder, "%", node.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
if node.children.count > 0 {
|
||||||
|
if !is_properties {
|
||||||
|
append(*state.builder, ".");
|
||||||
|
}
|
||||||
|
emit_node(state, node.children[0], 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case .Binary; {
|
||||||
|
indent(*state.builder, indentation);
|
||||||
|
lhs := node.children[0];
|
||||||
|
rhs := node.children[1];
|
||||||
|
emit_node(state, lhs, 0);
|
||||||
|
|
||||||
|
append(*state.builder, " ");
|
||||||
|
emit_operator(state, node.token.kind);
|
||||||
|
append(*state.builder, " ");
|
||||||
|
emit_node(state, rhs, 0);
|
||||||
|
}
|
||||||
|
case .Unary; {
|
||||||
|
assert(false, "Not implemented yet: unary");
|
||||||
|
}
|
||||||
|
case .Expression_Statement; {
|
||||||
|
emit_node(state, node.children[0], indentation);
|
||||||
|
}
|
||||||
|
case .Call; {
|
||||||
|
emit_call(state, node, indentation);
|
||||||
|
}
|
||||||
|
case .Return; {
|
||||||
|
indent(*state.builder, indentation);
|
||||||
|
append(*state.builder, "return ");
|
||||||
|
emit_node(state, node.children[0], 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
emit_declaration :: (state : *Codegen_State, node : *AST_Node) {
|
||||||
|
if node.kind == {
|
||||||
|
case .Function; {
|
||||||
|
emit_function(state, node, 0);
|
||||||
|
}
|
||||||
|
case .Properties; {
|
||||||
|
emit_properties(state, node, 0);
|
||||||
|
}
|
||||||
|
case .Struct; {
|
||||||
|
print_to_builder(*state.builder, "struct %", node.name);
|
||||||
|
|
||||||
|
current_scope := state.current_scope;
|
||||||
|
state.current_scope = h2tv(state.type_variables, node.type_variable).scope;
|
||||||
|
|
||||||
|
field_list := node.children[0];
|
||||||
|
|
||||||
|
if field_list.children.count > 0 {
|
||||||
|
append(*state.builder, "\n{\n");
|
||||||
|
} else {
|
||||||
|
append(*state.builder, " {");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
for child : field_list.children {
|
||||||
|
emit_node(state, child, 1);
|
||||||
|
|
||||||
|
if it_index < field_list.children.count {
|
||||||
|
append(*state.builder, ";\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
append(*state.builder, "}\n\n");
|
||||||
|
state.current_scope = current_scope;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
codegen :: (state : *Codegen_State) -> Codegen_Result {
|
||||||
|
found_function : 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if found_struct {
|
||||||
|
append(*state.builder, "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
for variable : state.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);
|
||||||
|
found_function = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if found_function {
|
||||||
|
append(*state.builder, "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
for declaration : state.root.children {
|
||||||
|
if declaration.foreign_declaration {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
emit_declaration(state, declaration);
|
||||||
|
}
|
||||||
|
|
||||||
|
state.result.result_text = builder_to_string(*state.builder);
|
||||||
|
|
||||||
|
print("%\n", state.result.result_text);
|
||||||
|
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);
|
||||||
|
}
|
||||||
150
Error.jai
Normal file
150
Error.jai
Normal file
@@ -0,0 +1,150 @@
|
|||||||
|
Message_Kind :: enum {
|
||||||
|
Log;
|
||||||
|
Warning;
|
||||||
|
Error;
|
||||||
|
Internal_Error;
|
||||||
|
}
|
||||||
|
|
||||||
|
Compiler_Message :: struct {
|
||||||
|
message_kind : Message_Kind;
|
||||||
|
|
||||||
|
message : string;
|
||||||
|
path : string;
|
||||||
|
source_locations : [..]Source_Range;
|
||||||
|
|
||||||
|
report_source_location : bool = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
indent :: (builder : *String_Builder, indentation : int) {
|
||||||
|
for 1..indentation append(builder, " ");
|
||||||
|
}
|
||||||
|
|
||||||
|
newline :: (builder : *String_Builder) {
|
||||||
|
append(builder, "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
green :: (builder : *String_Builder) {
|
||||||
|
append(builder, green());
|
||||||
|
}
|
||||||
|
|
||||||
|
green :: () -> string {
|
||||||
|
return "\x1b[92m";
|
||||||
|
}
|
||||||
|
|
||||||
|
red :: (builder : *String_Builder) {
|
||||||
|
append(builder, red());
|
||||||
|
}
|
||||||
|
|
||||||
|
red :: () -> string {
|
||||||
|
return "\x1b[91m";
|
||||||
|
}
|
||||||
|
|
||||||
|
yellow :: (builder : *String_Builder) {
|
||||||
|
append(builder, yellow());
|
||||||
|
}
|
||||||
|
|
||||||
|
yellow :: () -> string {
|
||||||
|
return "\x1b[93m";
|
||||||
|
}
|
||||||
|
|
||||||
|
cyan :: (builder : *String_Builder) {
|
||||||
|
append(builder, cyan());
|
||||||
|
}
|
||||||
|
|
||||||
|
cyan :: () -> string {
|
||||||
|
return "\x1b[96m";
|
||||||
|
}
|
||||||
|
|
||||||
|
white :: (builder : *String_Builder) {
|
||||||
|
append(builder, white());
|
||||||
|
}
|
||||||
|
|
||||||
|
white :: () -> string {
|
||||||
|
return "\x1b[97m";
|
||||||
|
}
|
||||||
|
|
||||||
|
reset_color :: () -> string {
|
||||||
|
return "\x1b[0m";
|
||||||
|
}
|
||||||
|
|
||||||
|
reset_color :: (builder : *String_Builder) {
|
||||||
|
append(builder, reset_color());
|
||||||
|
}
|
||||||
|
|
||||||
|
add_message :: (messages : *[..]Compiler_Message, text : string, path : string, kind : Message_Kind) {
|
||||||
|
message : Compiler_Message;
|
||||||
|
message.message = text;
|
||||||
|
message.path = path;
|
||||||
|
message.report_source_location = false;
|
||||||
|
message.message_kind = kind;
|
||||||
|
array_add(messages, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
log_message :: (messages : *[..]Compiler_Message, text : string, path : string) {
|
||||||
|
add_message(messages, text, path, .Log);
|
||||||
|
}
|
||||||
|
|
||||||
|
warning_message :: (messages : *[..]Compiler_Message, text : string, path : string) {
|
||||||
|
add_message(messages, text, path, .Warning);
|
||||||
|
}
|
||||||
|
|
||||||
|
error_message :: (messages : *[..]Compiler_Message, text : string, path : string) {
|
||||||
|
add_message(messages, text, path, .Error);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal_error_message :: (messages : *[..]Compiler_Message, text : string, path : string) {
|
||||||
|
add_message(messages, text, path, .Internal_Error);
|
||||||
|
}
|
||||||
|
|
||||||
|
copy_messages :: (source : []Compiler_Message, dest : *[..]Compiler_Message) {
|
||||||
|
for message : source {
|
||||||
|
array_add(dest, message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
report_messages :: (messages : []Compiler_Message) -> string {
|
||||||
|
builder : String_Builder;
|
||||||
|
init_string_builder(*builder);
|
||||||
|
for message : messages {
|
||||||
|
report_message(*builder, message);
|
||||||
|
}
|
||||||
|
return builder_to_string(*builder);
|
||||||
|
}
|
||||||
|
|
||||||
|
report_message :: (builder : *String_Builder, message : Compiler_Message) {
|
||||||
|
report_message(builder, message.path, message.message, message.source_locations, message.message_kind, message.report_source_location);
|
||||||
|
}
|
||||||
|
|
||||||
|
report_message :: (builder : *String_Builder, path : string, message : string, source_locations : []Source_Range, kind : Message_Kind, report_source_location : bool = false) {
|
||||||
|
append(builder, "\x1b[1;37m");
|
||||||
|
if path.count > 0 {
|
||||||
|
print_to_builder(builder, "%:", path);
|
||||||
|
} else {
|
||||||
|
append(builder, "internal:");
|
||||||
|
}
|
||||||
|
print_to_builder(builder, "%,%: ", source_locations[0].main_token.line, source_locations[0].main_token.column);
|
||||||
|
|
||||||
|
if kind == .Log {
|
||||||
|
append(builder, "\x1b[31mlog: ");
|
||||||
|
} else if kind == .Error {
|
||||||
|
append(builder, "\x1b[31merror: ");
|
||||||
|
}
|
||||||
|
|
||||||
|
append(builder, "\x1b[37m");
|
||||||
|
print_to_builder(builder, "%\n", message);
|
||||||
|
append(builder, "\x1b[36m");
|
||||||
|
|
||||||
|
if report_source_location {
|
||||||
|
for location : source_locations {
|
||||||
|
append(builder, "\t");
|
||||||
|
print_from_source_location(builder, location);
|
||||||
|
append(builder, "\n\t");
|
||||||
|
begin := location.begin;
|
||||||
|
|
||||||
|
print_token_pointer(builder, location.main_token);
|
||||||
|
append(builder, "\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
append(builder, "\x1b[37m");
|
||||||
|
}
|
||||||
|
|
||||||
695
Lexing.jai
Normal file
695
Lexing.jai
Normal file
@@ -0,0 +1,695 @@
|
|||||||
|
Lexer :: struct {
|
||||||
|
input : string;
|
||||||
|
cursor : int;
|
||||||
|
start : int;
|
||||||
|
current_line : int;
|
||||||
|
current_column : int;
|
||||||
|
|
||||||
|
result : Lexing_Result;
|
||||||
|
|
||||||
|
path : string;
|
||||||
|
}
|
||||||
|
|
||||||
|
Lexing_Result :: struct {
|
||||||
|
tokens : [..]Token;
|
||||||
|
had_error : bool;
|
||||||
|
messages : [..]Compiler_Message;
|
||||||
|
}
|
||||||
|
|
||||||
|
Token_Kind :: enum {
|
||||||
|
TOKEN_FLOATLITERAL;
|
||||||
|
TOKEN_INTLITERAL;
|
||||||
|
|
||||||
|
TOKEN_LOGICALOR;
|
||||||
|
TOKEN_LOGICALAND;
|
||||||
|
TOKEN_ISEQUAL;
|
||||||
|
TOKEN_ISNOTEQUAL;
|
||||||
|
TOKEN_PLUSEQUALS;
|
||||||
|
TOKEN_MINUSEQUALS;
|
||||||
|
TOKEN_TIMESEQUALS;
|
||||||
|
TOKEN_DIVEQUALS;
|
||||||
|
TOKEN_MODEQUALS;
|
||||||
|
TOKEN_LESSEQUALS;
|
||||||
|
TOKEN_LESS;
|
||||||
|
TOKEN_GREATEREQUALS;
|
||||||
|
TOKEN_GREATER;
|
||||||
|
TOKEN_COLON;
|
||||||
|
TOKEN_DOUBLECOLON;
|
||||||
|
TOKEN_ASSIGN;
|
||||||
|
TOKEN_ARROW;
|
||||||
|
TOKEN_AT;
|
||||||
|
|
||||||
|
TOKEN_PLUS;
|
||||||
|
TOKEN_STAR;
|
||||||
|
TOKEN_SLASH;
|
||||||
|
TOKEN_MOD;
|
||||||
|
TOKEN_MINUS;
|
||||||
|
|
||||||
|
TOKEN_LEFTBRACE;
|
||||||
|
TOKEN_RIGHTBRACE;
|
||||||
|
TOKEN_LEFTBRACKET;
|
||||||
|
TOKEN_RIGHTBRACKET;
|
||||||
|
TOKEN_LEFTPAREN;
|
||||||
|
TOKEN_RIGHTPAREN;
|
||||||
|
TOKEN_SEMICOLON;
|
||||||
|
TOKEN_COMMA;
|
||||||
|
TOKEN_DOT;
|
||||||
|
|
||||||
|
TOKEN_IDENTIFIER;
|
||||||
|
|
||||||
|
// Keywords
|
||||||
|
TOKEN_BOOL;
|
||||||
|
|
||||||
|
TOKEN_CASE;
|
||||||
|
TOKEN_CBUFFER;
|
||||||
|
TOKEN_COLUMNMAJOR;
|
||||||
|
TOKEN_CONST;
|
||||||
|
TOKEN_CONTINUE;
|
||||||
|
|
||||||
|
TOKEN_DEFAULT;
|
||||||
|
TOKEN_DIRECTIVE;
|
||||||
|
TOKEN_DISCARD;
|
||||||
|
TOKEN_DO;
|
||||||
|
TOKEN_DOUBLE;
|
||||||
|
|
||||||
|
TOKEN_ELSE;
|
||||||
|
TOKEN_EXPORT;
|
||||||
|
TOKEN_EXTERN;
|
||||||
|
|
||||||
|
TOKEN_FALSE;
|
||||||
|
TOKEN_FOR;
|
||||||
|
|
||||||
|
TOKEN_HALF;
|
||||||
|
TOKEN_HINT;
|
||||||
|
|
||||||
|
TOKEN_IF;
|
||||||
|
TOKEN_IN;
|
||||||
|
TOKEN_INOUT;
|
||||||
|
TOKEN_INSTANCE;
|
||||||
|
|
||||||
|
TOKEN_MATRIX;
|
||||||
|
TOKEN_META;
|
||||||
|
|
||||||
|
TOKEN_OPTIONAL;
|
||||||
|
TOKEN_OUT;
|
||||||
|
|
||||||
|
TOKEN_PIXEL;
|
||||||
|
TOKEN_PROPERTIES;
|
||||||
|
|
||||||
|
TOKEN_RETURN;
|
||||||
|
TOKEN_REGISTER;
|
||||||
|
|
||||||
|
TOKEN_STRUCT;
|
||||||
|
TOKEN_SWITCH;
|
||||||
|
|
||||||
|
TOKEN_TRUE;
|
||||||
|
|
||||||
|
TOKEN_UNORM;
|
||||||
|
TOKEN_UNSIGNED;
|
||||||
|
TOKEN_UINT;
|
||||||
|
|
||||||
|
TOKEN_VECTOR;
|
||||||
|
TOKEN_VERTEX;
|
||||||
|
TOKEN_VOID;
|
||||||
|
|
||||||
|
TOKEN_WHILE;
|
||||||
|
|
||||||
|
TOKEN_EOF;
|
||||||
|
TOKEN_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
Token :: struct {
|
||||||
|
kind : Token_Kind;
|
||||||
|
union {
|
||||||
|
ident_value : string;
|
||||||
|
integer_value : int;
|
||||||
|
float_value : float;
|
||||||
|
string_value : string;
|
||||||
|
}
|
||||||
|
|
||||||
|
source : *u8;
|
||||||
|
|
||||||
|
line : int;
|
||||||
|
length : int;
|
||||||
|
column : int;
|
||||||
|
index : int;
|
||||||
|
|
||||||
|
error : string;
|
||||||
|
}
|
||||||
|
|
||||||
|
Source_Range :: struct {
|
||||||
|
begin : Token;
|
||||||
|
end : Token;
|
||||||
|
main_token : Token;
|
||||||
|
}
|
||||||
|
|
||||||
|
is_at_end :: (using lexer : *Lexer) -> bool {
|
||||||
|
return input.data[cursor] == #char "\0" || cursor == input.count;
|
||||||
|
}
|
||||||
|
|
||||||
|
peek_char :: (using lexer : *Lexer) -> u8 {
|
||||||
|
return input.data[cursor];
|
||||||
|
}
|
||||||
|
|
||||||
|
peek_next_char :: (using lexer : *Lexer) -> u8 {
|
||||||
|
if is_at_end(lexer) return #char "\0";
|
||||||
|
return input.data[cursor + 1];
|
||||||
|
}
|
||||||
|
|
||||||
|
match_character :: (lexer : *Lexer, expected : u8) -> bool {
|
||||||
|
if is_at_end(lexer) return false;
|
||||||
|
if lexer.input.data[lexer.cursor] != expected return false;
|
||||||
|
|
||||||
|
lexer.cursor += 1;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
identifier :: (lexer : *Lexer) -> *Token {
|
||||||
|
while is_alpha(peek_char(lexer)) || is_digit(peek_char(lexer)) || peek_char(lexer) == #char "_" {
|
||||||
|
advance(lexer);
|
||||||
|
}
|
||||||
|
|
||||||
|
return make_identifier(lexer, identifier_kind(lexer));
|
||||||
|
}
|
||||||
|
|
||||||
|
directive :: (lexer : *Lexer) -> *Token {
|
||||||
|
advance(lexer);
|
||||||
|
while is_alpha(peek_char(lexer)) || is_digit(peek_char(lexer)) || peek_char(lexer) == #char "_" {
|
||||||
|
advance(lexer);
|
||||||
|
}
|
||||||
|
|
||||||
|
return make_directive(lexer);
|
||||||
|
}
|
||||||
|
|
||||||
|
number :: (lexer : *Lexer) -> *Token {
|
||||||
|
while is_digit(peek_char(lexer)) advance(lexer);
|
||||||
|
|
||||||
|
is_float := false;
|
||||||
|
|
||||||
|
if peek_char(lexer) == #char "." && is_digit(peek_next_char(lexer)) {
|
||||||
|
is_float = true;
|
||||||
|
advance(lexer);
|
||||||
|
f_suffix := false;
|
||||||
|
while is_digit(peek_char(lexer)) {
|
||||||
|
advance(lexer);
|
||||||
|
}
|
||||||
|
if peek_char(lexer) == #char "f" {
|
||||||
|
advance(lexer);
|
||||||
|
record_error(lexer, "We don't use 'f' suffixes for floating point values.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if is_float {
|
||||||
|
return make_float(lexer);
|
||||||
|
}
|
||||||
|
return make_int(lexer);
|
||||||
|
}
|
||||||
|
|
||||||
|
identifier_kind :: (using lexer : *Lexer) -> Token_Kind {
|
||||||
|
length := cursor - lexer.start;
|
||||||
|
|
||||||
|
index := start;
|
||||||
|
identifier : string;
|
||||||
|
identifier.data = *input.data[start];
|
||||||
|
identifier.count = length;
|
||||||
|
|
||||||
|
if identifier == "bool" return .TOKEN_BOOL;
|
||||||
|
if identifier == "case" return .TOKEN_CASE;
|
||||||
|
if identifier == "columnmajor" return .TOKEN_COLUMNMAJOR;
|
||||||
|
if identifier == "const" return .TOKEN_CONST;
|
||||||
|
if identifier == "continue" return .TOKEN_CONTINUE;
|
||||||
|
if identifier == "default" return .TOKEN_DEFAULT;
|
||||||
|
if identifier == "directive" return .TOKEN_DIRECTIVE;
|
||||||
|
if identifier == "discard" return .TOKEN_DIRECTIVE;
|
||||||
|
if identifier == "discard" return .TOKEN_DISCARD;
|
||||||
|
if identifier == "do" return .TOKEN_DO;
|
||||||
|
if identifier == "double" return .TOKEN_DOUBLE;
|
||||||
|
if identifier == "else" return .TOKEN_ELSE;
|
||||||
|
if identifier == "export" return .TOKEN_EXPORT;
|
||||||
|
if identifier == "extern" return .TOKEN_EXTERN;
|
||||||
|
if identifier == "false" return .TOKEN_FALSE;
|
||||||
|
if identifier == "for" return .TOKEN_FOR;
|
||||||
|
if identifier == "half" return .TOKEN_HALF;
|
||||||
|
if identifier == "hint" return .TOKEN_HINT;
|
||||||
|
if identifier == "if" return .TOKEN_IF;
|
||||||
|
if identifier == "in" return .TOKEN_IN;
|
||||||
|
if identifier == "inout" return .TOKEN_INOUT;
|
||||||
|
if identifier == "instance" return .TOKEN_INSTANCE;
|
||||||
|
if identifier == "matrix" return .TOKEN_MATRIX;
|
||||||
|
if identifier == "meta" return .TOKEN_META;
|
||||||
|
if identifier == "optional" return .TOKEN_OPTIONAL;
|
||||||
|
if identifier == "out" return .TOKEN_OUT;
|
||||||
|
if identifier == "pixel" return .TOKEN_PIXEL;
|
||||||
|
if identifier == "properties" return .TOKEN_PROPERTIES;
|
||||||
|
if identifier == "return" return .TOKEN_RETURN;
|
||||||
|
if identifier == "register" return .TOKEN_REGISTER;
|
||||||
|
if identifier == "struct" return .TOKEN_STRUCT;
|
||||||
|
if identifier == "switch" return .TOKEN_SWITCH;
|
||||||
|
if identifier == "true" return .TOKEN_TRUE;
|
||||||
|
if identifier == "unorm" return .TOKEN_UNORM;
|
||||||
|
if identifier == "unsigned" return .TOKEN_UNSIGNED;
|
||||||
|
if identifier == "uint" return .TOKEN_UINT;
|
||||||
|
if identifier == "vector" return .TOKEN_VECTOR;
|
||||||
|
if identifier == "vertex" return .TOKEN_VERTEX;
|
||||||
|
if identifier == "void" return .TOKEN_VOID;
|
||||||
|
if identifier == "while" return .TOKEN_WHILE;
|
||||||
|
|
||||||
|
return .TOKEN_IDENTIFIER;
|
||||||
|
}
|
||||||
|
|
||||||
|
error_token :: (lexer : *Lexer, message : string) -> *Token {
|
||||||
|
token : *Token = new_token(lexer, .TOKEN_ERROR);
|
||||||
|
|
||||||
|
lexer.result.had_error = true;
|
||||||
|
token.error = copy_string(message);
|
||||||
|
|
||||||
|
return token;
|
||||||
|
}
|
||||||
|
|
||||||
|
record_error :: (lexer : *Lexer, message : string) {
|
||||||
|
error : Compiler_Message;
|
||||||
|
error.message_kind = .Error;
|
||||||
|
error.message = message;
|
||||||
|
error.path = lexer.path;
|
||||||
|
|
||||||
|
token := error_token(lexer, message);
|
||||||
|
source_location : Source_Range;
|
||||||
|
source_location.main_token = token;
|
||||||
|
|
||||||
|
token.length += token.column;
|
||||||
|
token.source -= token.column;
|
||||||
|
token.column = 0;
|
||||||
|
|
||||||
|
source_location.begin = token;
|
||||||
|
length := source_location.begin.column;
|
||||||
|
|
||||||
|
source_location.end = token;
|
||||||
|
|
||||||
|
array_add(*error.source_locations, source_location);
|
||||||
|
|
||||||
|
lexer.result.had_error = true;
|
||||||
|
array_add(*lexer.result.messages, error);
|
||||||
|
}
|
||||||
|
|
||||||
|
make_int :: (lexer : *Lexer) -> *Token {
|
||||||
|
token : *Token = new_token(lexer, .TOKEN_INTLITERAL);
|
||||||
|
|
||||||
|
str : string = .{ count = token.length,
|
||||||
|
data = *lexer.input.data[lexer.start] };
|
||||||
|
value, ok := string_to_int(str);
|
||||||
|
|
||||||
|
if ok {
|
||||||
|
token.integer_value = value;
|
||||||
|
}
|
||||||
|
return token;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
make_float :: (lexer : *Lexer) -> *Token {
|
||||||
|
token : *Token = new_token(lexer, .TOKEN_FLOATLITERAL);
|
||||||
|
|
||||||
|
str : string = .{ count = token.length,
|
||||||
|
data = *lexer.input.data[lexer.start] };
|
||||||
|
value, ok := string_to_float(str);
|
||||||
|
if ok {
|
||||||
|
token.float_value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
return token;
|
||||||
|
}
|
||||||
|
|
||||||
|
make_string :: () {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
new_token :: (lexer : *Lexer, kind : Token_Kind) -> *Token {
|
||||||
|
length := lexer.cursor - lexer.start;
|
||||||
|
token : Token;
|
||||||
|
token.kind = kind;
|
||||||
|
token.line = lexer.current_line;
|
||||||
|
token.length = length;
|
||||||
|
token.column = lexer.current_column;
|
||||||
|
token.index = lexer.cursor - token.length;
|
||||||
|
|
||||||
|
if token.length > 0 {
|
||||||
|
token.source = *lexer.input[token.index];
|
||||||
|
} else {
|
||||||
|
token.source = *lexer.input[token.index - 1];
|
||||||
|
}
|
||||||
|
lexer.current_column += length;
|
||||||
|
|
||||||
|
array_add(*lexer.result.tokens, token);
|
||||||
|
return *lexer.result.tokens[lexer.result.tokens.count - 1];
|
||||||
|
}
|
||||||
|
|
||||||
|
make_directive :: (lexer : *Lexer) -> *Token {
|
||||||
|
lexer.start += 1;
|
||||||
|
return make_identifier(lexer, .TOKEN_DIRECTIVE);
|
||||||
|
}
|
||||||
|
|
||||||
|
make_identifier :: (lexer : *Lexer, kind : Token_Kind) -> *Token {
|
||||||
|
token : *Token = new_token(lexer, kind);
|
||||||
|
|
||||||
|
name : string = .{ count = token.length,
|
||||||
|
data = *lexer.input.data[lexer.start] };
|
||||||
|
token.ident_value = name;
|
||||||
|
|
||||||
|
return token;
|
||||||
|
}
|
||||||
|
|
||||||
|
make_token :: (lexer : *Lexer, token_kind : Token_Kind) -> *Token {
|
||||||
|
return new_token(lexer, token_kind);
|
||||||
|
}
|
||||||
|
|
||||||
|
skip_whitespace :: (lexer : *Lexer) {
|
||||||
|
while true {
|
||||||
|
c := peek_char(lexer);
|
||||||
|
|
||||||
|
if c == {
|
||||||
|
case #char " "; {
|
||||||
|
lexer.current_column += 1;
|
||||||
|
advance(lexer);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
case #char "\r"; #through;
|
||||||
|
case #char "\t"; {
|
||||||
|
advance(lexer);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
case #char "\n"; {
|
||||||
|
advance(lexer);
|
||||||
|
lexer.current_line += 1;
|
||||||
|
lexer.current_column = 0;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
case #char "/"; {
|
||||||
|
next := peek_next_char(lexer);
|
||||||
|
if next == #char "/" {
|
||||||
|
while peek_char(lexer) != #char "\n" && !is_at_end(lexer) {
|
||||||
|
advance(lexer);
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
advance :: (using lexer : *Lexer) -> u8 {
|
||||||
|
c := input.data[cursor];
|
||||||
|
cursor += 1;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
scan_next_token :: (lexer : *Lexer) -> *Token {
|
||||||
|
skip_whitespace(lexer);
|
||||||
|
lexer.start = lexer.cursor;
|
||||||
|
|
||||||
|
if is_at_end(lexer) return make_token(lexer, .TOKEN_EOF);
|
||||||
|
|
||||||
|
c := advance(lexer);
|
||||||
|
|
||||||
|
if c == #char "#" return directive(lexer);
|
||||||
|
if is_alpha(c) return identifier(lexer);
|
||||||
|
if is_digit(c) return number(lexer);
|
||||||
|
|
||||||
|
if c == {
|
||||||
|
case #char "+"; {
|
||||||
|
if match_character(lexer, #char "=") return make_token(lexer, .TOKEN_PLUSEQUALS);
|
||||||
|
return make_token(lexer, .TOKEN_PLUS);
|
||||||
|
}
|
||||||
|
case #char "-"; {
|
||||||
|
if match_character(lexer, #char "=") return make_token(lexer, .TOKEN_MINUSEQUALS);
|
||||||
|
if match_character(lexer, #char ">") return make_token(lexer, .TOKEN_ARROW);
|
||||||
|
return make_token(lexer, .TOKEN_MINUS);
|
||||||
|
}
|
||||||
|
case #char "*"; {
|
||||||
|
if match_character(lexer, #char "=") return make_token(lexer, .TOKEN_TIMESEQUALS);
|
||||||
|
return make_token(lexer, .TOKEN_STAR);
|
||||||
|
}
|
||||||
|
case #char "/"; {
|
||||||
|
if match_character(lexer, #char "=") return make_token(lexer, .TOKEN_DIVEQUALS);
|
||||||
|
return make_token(lexer, .TOKEN_SLASH);
|
||||||
|
}
|
||||||
|
case #char "%"; {
|
||||||
|
if match_character(lexer, #char "=") return make_token(lexer, .TOKEN_MODEQUALS);
|
||||||
|
return make_token(lexer, .TOKEN_MOD);
|
||||||
|
}
|
||||||
|
case #char ":"; {
|
||||||
|
if match_character(lexer, #char ":") return make_token(lexer, .TOKEN_DOUBLECOLON);
|
||||||
|
return make_token(lexer, .TOKEN_COLON);
|
||||||
|
}
|
||||||
|
case #char "@"; {
|
||||||
|
return make_token(lexer, .TOKEN_AT);
|
||||||
|
}
|
||||||
|
case #char "|"; {
|
||||||
|
if match_character(lexer, #char "|") return make_token(lexer, .TOKEN_LOGICALOR);
|
||||||
|
}
|
||||||
|
case #char "&"; {
|
||||||
|
if match_character(lexer, #char "&") return make_token(lexer, .TOKEN_LOGICALAND);
|
||||||
|
}
|
||||||
|
case #char "!"; {
|
||||||
|
if match_character(lexer, #char "=") return make_token(lexer, .TOKEN_ISNOTEQUAL);
|
||||||
|
}
|
||||||
|
case #char "="; {
|
||||||
|
if match_character(lexer, #char "=") return make_token(lexer, .TOKEN_ISEQUAL);
|
||||||
|
return make_token(lexer, .TOKEN_ASSIGN);
|
||||||
|
}
|
||||||
|
case #char ">"; {
|
||||||
|
if match_character(lexer, #char "=") return make_token(lexer, .TOKEN_GREATEREQUALS);
|
||||||
|
return make_token(lexer, .TOKEN_GREATER);
|
||||||
|
}
|
||||||
|
case #char "<"; {
|
||||||
|
if match_character(lexer, #char "=") return make_token(lexer, .TOKEN_LESSEQUALS);
|
||||||
|
return make_token(lexer, .TOKEN_LESS);
|
||||||
|
}
|
||||||
|
case #char "{"; {
|
||||||
|
return make_token(lexer, .TOKEN_LEFTBRACE);
|
||||||
|
}
|
||||||
|
case #char "}"; {
|
||||||
|
return make_token(lexer, .TOKEN_RIGHTBRACE);
|
||||||
|
}
|
||||||
|
case #char "("; {
|
||||||
|
return make_token(lexer, .TOKEN_LEFTPAREN);
|
||||||
|
}
|
||||||
|
case #char ")"; {
|
||||||
|
return make_token(lexer, .TOKEN_RIGHTPAREN);
|
||||||
|
}
|
||||||
|
case #char "["; {
|
||||||
|
return make_token(lexer, .TOKEN_LEFTBRACKET);
|
||||||
|
}
|
||||||
|
case #char "]"; {
|
||||||
|
return make_token(lexer, .TOKEN_RIGHTBRACKET);
|
||||||
|
}
|
||||||
|
case #char ";"; return make_token(lexer, .TOKEN_SEMICOLON);
|
||||||
|
case #char ","; return make_token(lexer, .TOKEN_COMMA);
|
||||||
|
case #char "."; return make_token(lexer, .TOKEN_DOT);
|
||||||
|
}
|
||||||
|
|
||||||
|
s : string = .{ count = 1, data = *c };
|
||||||
|
record_error(lexer, tprint("Invalid token: %", s));
|
||||||
|
return null;
|
||||||
|
// return error_token(lexer, tprint("Invalid token: %", s));
|
||||||
|
}
|
||||||
|
|
||||||
|
pretty_print_token :: (token : *Token, builder : *String_Builder) {
|
||||||
|
MAX :: 18;
|
||||||
|
kind_name := enum_names(Token_Kind)[cast(int)token.kind];
|
||||||
|
diff := MAX - kind_name.count;
|
||||||
|
|
||||||
|
print_to_builder(builder, "{kind = %; ", token.kind);
|
||||||
|
for i : 0..diff - 1 {
|
||||||
|
append(builder, " ");
|
||||||
|
}
|
||||||
|
|
||||||
|
append_to_length :: (builder : *String_Builder, number : int) {
|
||||||
|
if number < 10 {
|
||||||
|
append(builder, " ");
|
||||||
|
} else if number < 100 {
|
||||||
|
append(builder, " ");
|
||||||
|
} else if number < 1000 {
|
||||||
|
append(builder, " ");
|
||||||
|
} else if number < 10000 {
|
||||||
|
append(builder, " ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
print_to_builder(builder, "; index = %", token.index);
|
||||||
|
append_to_length(builder, token.index);
|
||||||
|
|
||||||
|
print_to_builder(builder, "; length = %", token.length);
|
||||||
|
append_to_length(builder, token.length);
|
||||||
|
|
||||||
|
print_to_builder(builder, "line = %", token.line);
|
||||||
|
append_to_length(builder, token.line);
|
||||||
|
|
||||||
|
print_to_builder(builder, "; column = %", token.column);
|
||||||
|
append_to_length(builder, token.column);
|
||||||
|
|
||||||
|
append(builder, "; value ='");
|
||||||
|
value_length : int;
|
||||||
|
if token.kind == .TOKEN_IDENTIFIER {
|
||||||
|
print_to_builder(builder, "%", token.ident_value);
|
||||||
|
} else if token.kind == .TOKEN_INTLITERAL {
|
||||||
|
print_to_builder(builder, "%", token.integer_value);
|
||||||
|
} else if token.kind == .TOKEN_FLOATLITERAL {
|
||||||
|
print_to_builder(builder, "%", token.float_value);
|
||||||
|
} else if token.kind == .TOKEN_ERROR {
|
||||||
|
print_to_builder(builder, "%", token.error);
|
||||||
|
} else {
|
||||||
|
source : string = .{ count = token.length,
|
||||||
|
data = token.source };
|
||||||
|
print_to_builder(builder, "%", source);
|
||||||
|
}
|
||||||
|
append(builder, "'; }\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
pretty_print_tokens :: (lexer : *Lexer, allocator : Allocator) -> string {
|
||||||
|
builder : String_Builder;
|
||||||
|
|
||||||
|
init_string_builder(*builder,, allocator);
|
||||||
|
|
||||||
|
token : *Token = scan_next_token(lexer);
|
||||||
|
while token && token.kind != .TOKEN_EOF {
|
||||||
|
pretty_print_token(token, *builder);
|
||||||
|
token = scan_next_token(lexer);
|
||||||
|
}
|
||||||
|
|
||||||
|
return builder_to_string(*builder,, allocator);
|
||||||
|
}
|
||||||
|
|
||||||
|
pretty_print_tokens :: (tokens : []Token, allocator : Allocator) -> string {
|
||||||
|
builder : String_Builder;
|
||||||
|
|
||||||
|
init_string_builder(*builder,, allocator);
|
||||||
|
|
||||||
|
for token : tokens {
|
||||||
|
pretty_print_token(*token, *builder);
|
||||||
|
}
|
||||||
|
return builder_to_string(*builder,, allocator);
|
||||||
|
}
|
||||||
|
|
||||||
|
output_as_code_string :: (lexer : *Lexer, allocator : *Allocator) -> string {
|
||||||
|
builder : String_Builder;
|
||||||
|
|
||||||
|
new_context := context;
|
||||||
|
new_context.allocator = allocator;
|
||||||
|
push_context new_context {
|
||||||
|
init_string_builder(*builder); // @Incomplete: Consider passing builder as argument
|
||||||
|
|
||||||
|
token : *Token = scan_next_token(lexer);
|
||||||
|
while token && token.kind != .TOKEN_EOF {
|
||||||
|
token = scan_next_token(lexer);
|
||||||
|
}
|
||||||
|
|
||||||
|
return builder_to_string(*builder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
print_token_pointer :: (builder : *String_Builder, token : Token) {
|
||||||
|
for i : 0..token.column - 1 {
|
||||||
|
append(builder, " ");
|
||||||
|
}
|
||||||
|
|
||||||
|
for i : 0..token.length - 1 {
|
||||||
|
append(builder, "^");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
print_from_source_location :: (builder : *String_Builder, source_location : Source_Range, indentation : int = 0) {
|
||||||
|
current := source_location.begin;
|
||||||
|
begin := source_location.begin;
|
||||||
|
end := source_location.end;
|
||||||
|
begin_pos := 0;
|
||||||
|
token_string : string;
|
||||||
|
count := end.index - begin.index + end.length;
|
||||||
|
|
||||||
|
if indentation > 0 {
|
||||||
|
indent(builder, indentation);
|
||||||
|
for 0..count - 1 {
|
||||||
|
c := begin.source[it];
|
||||||
|
if c == #char "\n" {
|
||||||
|
append(builder, "\n");
|
||||||
|
indent(builder, indentation);
|
||||||
|
} else {
|
||||||
|
s : string;
|
||||||
|
s.count = 1;
|
||||||
|
s.data = *c;
|
||||||
|
print_to_builder(builder, "%", s);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
token_string = .{ count = count, data = begin.source };
|
||||||
|
indent(builder, indentation);
|
||||||
|
print_to_builder(builder, "%", token_string);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
print_from_source_location :: (source_location : Source_Range, allocator := context.allocator, indentation : int = 0) -> string {
|
||||||
|
builder : String_Builder;
|
||||||
|
init_string_builder(*builder,, allocator);
|
||||||
|
print_from_source_location(*builder, source_location);
|
||||||
|
return builder_to_string(*builder,, allocator);
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
read_input_from_string :: (lexer : *Lexer, input : string) -> bool {
|
||||||
|
lexer.input = input;
|
||||||
|
lexer.cursor = 0;
|
||||||
|
lexer.start = 0;
|
||||||
|
lexer.current_line = 1;
|
||||||
|
lexer.current_column = 0;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
read_input_from_file :: (lexer : *Lexer, file_path : string) -> bool {
|
||||||
|
assert(file_path != "");
|
||||||
|
|
||||||
|
value, success := read_entire_file(file_path, true, true);
|
||||||
|
if !success {
|
||||||
|
free(value);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
lexer.path = copy_string(file_path);
|
||||||
|
lexer.input = value;
|
||||||
|
lexer.cursor = 0;
|
||||||
|
lexer.start = 0;
|
||||||
|
lexer.current_line = 1;
|
||||||
|
lexer.current_column = 0;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
#import "Basic";
|
||||||
1001
Parsing.jai
Normal file
1001
Parsing.jai
Normal file
File diff suppressed because it is too large
Load Diff
2118
Semantic_Analysis.jai
Normal file
2118
Semantic_Analysis.jai
Normal file
File diff suppressed because it is too large
Load Diff
762
Test.jai
Normal file
762
Test.jai
Normal file
@@ -0,0 +1,762 @@
|
|||||||
|
/////////////////////////////////////
|
||||||
|
//~ 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
29
example.shd
Normal file
29
example.shd
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
property {
|
||||||
|
mix_amount : float;
|
||||||
|
projection : float4x4; @camera_projection
|
||||||
|
view : float4x4; @camera_view
|
||||||
|
}
|
||||||
|
|
||||||
|
PSInput :: struct {
|
||||||
|
position : @position
|
||||||
|
normal : @normal
|
||||||
|
light_view_position : @extra // TEXCOORD3?
|
||||||
|
frag_pos : @extra // TEXCOORD4?
|
||||||
|
}
|
||||||
|
|
||||||
|
PSOutput :: struct {
|
||||||
|
color : float4; @target0;
|
||||||
|
emission : float4; @target1;
|
||||||
|
}
|
||||||
|
|
||||||
|
vertex main :: (position : float3 @position, uv : float2 @uv, normal : float3 @normal) -> PSInput {
|
||||||
|
ps_input : PSInput;
|
||||||
|
|
||||||
|
return ps_input;
|
||||||
|
}
|
||||||
|
|
||||||
|
pixel main :: (input : PSInput) -> float4 {
|
||||||
|
ps_out : PSOutput;
|
||||||
|
|
||||||
|
return ps_out;
|
||||||
|
}
|
||||||
252
hlsl_builtin.jai
Normal file
252
hlsl_builtin.jai
Normal file
@@ -0,0 +1,252 @@
|
|||||||
|
HLSL_BULTIN :: #string DONE
|
||||||
|
|
||||||
|
float2 :: struct {
|
||||||
|
x : float;
|
||||||
|
y : float;
|
||||||
|
}
|
||||||
|
|
||||||
|
float3 :: struct {
|
||||||
|
x : float;
|
||||||
|
y : float;
|
||||||
|
z : float;
|
||||||
|
}
|
||||||
|
|
||||||
|
float4 :: struct {
|
||||||
|
x : float;
|
||||||
|
y : float;
|
||||||
|
z : float;
|
||||||
|
w : float;
|
||||||
|
}
|
||||||
|
|
||||||
|
float4x4 :: struct {
|
||||||
|
m11 : float;
|
||||||
|
m12 : float;
|
||||||
|
m13 : float;
|
||||||
|
m14 : float;
|
||||||
|
m21 : float;
|
||||||
|
m22 : float;
|
||||||
|
m23 : float;
|
||||||
|
m24 : float;
|
||||||
|
m31 : float;
|
||||||
|
m32 : float;
|
||||||
|
m33 : float;
|
||||||
|
m34 : float;
|
||||||
|
m41 : float;
|
||||||
|
m42 : float;
|
||||||
|
m43 : float;
|
||||||
|
m44 : float;
|
||||||
|
}
|
||||||
|
|
||||||
|
int2 :: struct {
|
||||||
|
x : int;
|
||||||
|
y : int;
|
||||||
|
}
|
||||||
|
|
||||||
|
int3 :: struct {
|
||||||
|
x : int;
|
||||||
|
y : int;
|
||||||
|
z : int;
|
||||||
|
}
|
||||||
|
|
||||||
|
int4 :: struct {
|
||||||
|
x : int;
|
||||||
|
y : int;
|
||||||
|
z : int;
|
||||||
|
w : int;
|
||||||
|
}
|
||||||
|
|
||||||
|
int4x4 :: struct {
|
||||||
|
m11 : int;
|
||||||
|
m12 : int;
|
||||||
|
m13 : int;
|
||||||
|
m14 : int;
|
||||||
|
m21 : int;
|
||||||
|
m22 : int;
|
||||||
|
m23 : int;
|
||||||
|
m24 : int;
|
||||||
|
m31 : int;
|
||||||
|
m32 : int;
|
||||||
|
m33 : int;
|
||||||
|
m34 : int;
|
||||||
|
m41 : int;
|
||||||
|
m42 : int;
|
||||||
|
m43 : int;
|
||||||
|
m44 : int;
|
||||||
|
}
|
||||||
|
|
||||||
|
//~ nbr: Constructors
|
||||||
|
#foreign float2 :: (float, float) -> float2;
|
||||||
|
#foreign float3 :: (float, float, float) -> float3;
|
||||||
|
#foreign float4 :: (float, float, float, float) -> float4;
|
||||||
|
|
||||||
|
//~ nbr: Vectors
|
||||||
|
#foreign cross :: (float3, float3) -> float3;
|
||||||
|
#foreign distance :: (float2, float2) -> float;
|
||||||
|
#foreign distance :: (float3, float3) -> float;
|
||||||
|
#foreign distance :: (float4, float4) -> float;
|
||||||
|
|
||||||
|
#foreign dot :: (float2, float2) -> float;
|
||||||
|
#foreign dot :: (float3, float3) -> float;
|
||||||
|
#foreign dot :: (float4, float4) -> float;
|
||||||
|
|
||||||
|
#foreign normalize :: (float2) -> float2;
|
||||||
|
#foreign normalize :: (float3) -> float3;
|
||||||
|
#foreign normalize :: (float4) -> float4;
|
||||||
|
|
||||||
|
#foreign transpose :: (float4x4) -> float4x4;
|
||||||
|
|
||||||
|
//~ nbr: Multiplies
|
||||||
|
#foreign mul :: (float2, float2) -> float2;
|
||||||
|
#foreign mul :: (float3, float3) -> float3;
|
||||||
|
#foreign mul :: (float4, float4) -> float4;
|
||||||
|
#foreign mul :: (float4x4, float4x4) -> float4x4;
|
||||||
|
|
||||||
|
//~ nbr: General
|
||||||
|
#foreign abs :: (float) -> float;
|
||||||
|
#foreign abs :: (float2) -> float2;
|
||||||
|
#foreign abs :: (float3) -> float3;
|
||||||
|
#foreign abs :: (float4) -> float4;
|
||||||
|
#foreign abs :: (float4x4) -> float4x4;
|
||||||
|
|
||||||
|
#foreign min :: (float) -> float;
|
||||||
|
#foreign min :: (float2) -> float2;
|
||||||
|
#foreign min :: (float3) -> float3;
|
||||||
|
#foreign min :: (float4) -> float4;
|
||||||
|
#foreign min :: (float4x4) -> float4x4;
|
||||||
|
|
||||||
|
#foreign max :: (float) -> float;
|
||||||
|
#foreign max :: (float2) -> float2;
|
||||||
|
#foreign max :: (float3) -> float3;
|
||||||
|
#foreign max :: (float4) -> float4;
|
||||||
|
#foreign max :: (float4x4) -> float4x4;
|
||||||
|
|
||||||
|
#foreign ceil :: (float) -> float;
|
||||||
|
#foreign ceil :: (float2) -> float2;
|
||||||
|
#foreign ceil :: (float3) -> float3;
|
||||||
|
#foreign ceil :: (float4) -> float4;
|
||||||
|
#foreign ceil :: (float4x4) -> float4x4;
|
||||||
|
|
||||||
|
#foreign floor :: (float) -> float;
|
||||||
|
#foreign floor :: (float2) -> float2;
|
||||||
|
#foreign floor :: (float3) -> float3;
|
||||||
|
#foreign floor :: (float4) -> float4;
|
||||||
|
#foreign floor :: (float4x4) -> float4x4;
|
||||||
|
|
||||||
|
#foreign round :: (float) -> float;
|
||||||
|
#foreign round :: (float2) -> float2;
|
||||||
|
#foreign round :: (float3) -> float3;
|
||||||
|
#foreign round :: (float4) -> float4;
|
||||||
|
#foreign round :: (float4x4) -> float4x4;
|
||||||
|
|
||||||
|
#foreign clamp :: (float, float, float) -> float;
|
||||||
|
#foreign clamp :: (float2, float2, float2) -> float2;
|
||||||
|
#foreign clamp :: (float3, float3, float3) -> float3;
|
||||||
|
#foreign clamp :: (float4, float4, float4) -> float4;
|
||||||
|
#foreign clamp :: (float4x4, float4x4, float4x4) -> float4x4;
|
||||||
|
|
||||||
|
#foreign log :: (float) -> float;
|
||||||
|
#foreign log :: (float2) -> float2;
|
||||||
|
#foreign log :: (float3) -> float3;
|
||||||
|
#foreign log :: (float4) -> float4;
|
||||||
|
#foreign log :: (float4x4) -> float4x4;
|
||||||
|
|
||||||
|
#foreign log2 :: (float) -> float;
|
||||||
|
#foreign log2 :: (float2) -> float2;
|
||||||
|
#foreign log2 :: (float3) -> float3;
|
||||||
|
#foreign log2 :: (float4) -> float4;
|
||||||
|
#foreign log2 :: (float4x4) -> float4x4;
|
||||||
|
|
||||||
|
#foreign log10 :: (float) -> float;
|
||||||
|
#foreign log10 :: (float2) -> float2;
|
||||||
|
#foreign log10 :: (float3) -> float3;
|
||||||
|
#foreign log10 :: (float4) -> float4;
|
||||||
|
#foreign log10 :: (float4x4) -> float4x4;
|
||||||
|
|
||||||
|
#foreign pow :: (float, float, float) -> float;
|
||||||
|
#foreign pow :: (float2, float2, float2) -> float2;
|
||||||
|
#foreign pow :: (float3, float3, float3) -> float3;
|
||||||
|
#foreign pow :: (float4, float4, float4) -> float4;
|
||||||
|
#foreign pow :: (float4x4, float4x4, float4x4) -> float4x4;
|
||||||
|
|
||||||
|
#foreign smoothstep :: (float, float, float) -> float;
|
||||||
|
#foreign smoothstep :: (float2, float2, float2) -> float2;
|
||||||
|
#foreign smoothstep :: (float3, float3, float3) -> float3;
|
||||||
|
#foreign smoothstep :: (float4, float4, float4) -> float4;
|
||||||
|
#foreign smoothstep :: (float4x4, float4x4, float4x4) -> float4x4;
|
||||||
|
|
||||||
|
#foreign step :: (float, float) -> float;
|
||||||
|
#foreign step :: (float2, float2) -> float2;
|
||||||
|
#foreign step :: (float3, float3) -> float3;
|
||||||
|
#foreign step :: (float4, float4) -> float4;
|
||||||
|
#foreign step :: (float4x4, float4x4) -> float4x4;
|
||||||
|
|
||||||
|
#foreign sqrt :: (float) -> float;
|
||||||
|
#foreign sqrt :: (float2) -> float2;
|
||||||
|
#foreign sqrt :: (float3) -> float3;
|
||||||
|
#foreign sqrt :: (float4) -> float4;
|
||||||
|
#foreign sqrt :: (float4x4) -> float4x4;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//~ nbr: Trigonometry
|
||||||
|
#foreign cos :: (float) -> float;
|
||||||
|
#foreign cos :: (float2) -> float2;
|
||||||
|
#foreign cos :: (float3) -> float3;
|
||||||
|
#foreign cos :: (float4) -> float4;
|
||||||
|
#foreign cos :: (float4x4) -> float4x4;
|
||||||
|
|
||||||
|
#foreign cosh :: (float) -> float;
|
||||||
|
#foreign cosh :: (float2) -> float2;
|
||||||
|
#foreign cosh :: (float3) -> float3;
|
||||||
|
#foreign cosh :: (float4) -> float4;
|
||||||
|
#foreign cosh :: (float4x4) -> float4x4;
|
||||||
|
|
||||||
|
#foreign acos :: (float) -> float;
|
||||||
|
#foreign acos :: (float2) -> float2;
|
||||||
|
#foreign acos :: (float3) -> float3;
|
||||||
|
#foreign acos :: (float4) -> float4;
|
||||||
|
#foreign acos :: (float4x4) -> float4x4;
|
||||||
|
|
||||||
|
#foreign sin :: (float) -> float;
|
||||||
|
#foreign sin :: (float2) -> float2;
|
||||||
|
#foreign sin :: (float3) -> float3;
|
||||||
|
#foreign sin :: (float4) -> float4;
|
||||||
|
#foreign sin :: (float4x4) -> float4x4;
|
||||||
|
|
||||||
|
#foreign sinh :: (float) -> float;
|
||||||
|
#foreign sinh :: (float2) -> float2;
|
||||||
|
#foreign sinh :: (float3) -> float3;
|
||||||
|
#foreign sinh :: (float4) -> float4;
|
||||||
|
#foreign sinh :: (float4x4) -> float4x4;
|
||||||
|
|
||||||
|
#foreign asin :: (float) -> float;
|
||||||
|
#foreign asin :: (float2) -> float2;
|
||||||
|
#foreign asin :: (float3) -> float3;
|
||||||
|
#foreign asin :: (float4) -> float4;
|
||||||
|
#foreign asin :: (float4x4) -> float4x4;
|
||||||
|
|
||||||
|
#foreign tan :: (float) -> float;
|
||||||
|
#foreign tan :: (float2) -> float2;
|
||||||
|
#foreign tan :: (float3) -> float3;
|
||||||
|
#foreign tan :: (float4) -> float4;
|
||||||
|
#foreign tan :: (float4x4) -> float4x4;
|
||||||
|
|
||||||
|
#foreign tanh :: (float) -> float;
|
||||||
|
#foreign tanh :: (float2) -> float2;
|
||||||
|
#foreign tanh :: (float3) -> float3;
|
||||||
|
#foreign tanh :: (float4) -> float4;
|
||||||
|
#foreign tanh :: (float4x4) -> float4x4;
|
||||||
|
|
||||||
|
#foreign atan :: (float) -> float;
|
||||||
|
#foreign atan :: (float2) -> float2;
|
||||||
|
#foreign atan :: (float3) -> float3;
|
||||||
|
#foreign atan :: (float4) -> float4;
|
||||||
|
#foreign atan :: (float4x4) -> float4x4;
|
||||||
|
|
||||||
|
#foreign atan2 :: (float, float) -> float;
|
||||||
|
#foreign atan2 :: (float2, float2) -> float2;
|
||||||
|
#foreign atan2 :: (float3, float3) -> float3;
|
||||||
|
#foreign atan2 :: (float4, float4) -> float4;
|
||||||
|
#foreign atan2 :: (float4x4, float4x4) -> float4x4;
|
||||||
|
|
||||||
|
DONE
|
||||||
408
module.jai
Normal file
408
module.jai
Normal file
@@ -0,0 +1,408 @@
|
|||||||
|
#load "Lexing.jai";
|
||||||
|
#load "Error.jai";
|
||||||
|
#load "Parsing.jai";
|
||||||
|
#load "Semantic_Analysis.jai";
|
||||||
|
#load "Codegen.jai";
|
||||||
|
|
||||||
|
|
||||||
|
add_define :: (env : *Environment, key : string) {
|
||||||
|
for define : env.defines {
|
||||||
|
if define == key {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
array_add(*env.defines, key);
|
||||||
|
}
|
||||||
|
|
||||||
|
remove_define :: (env : *Environment, key : string) {
|
||||||
|
for define : env.defines {
|
||||||
|
if define == key {
|
||||||
|
env.defines[it_index] = env.defines[env.defines.count - 1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Environment :: struct {
|
||||||
|
defines : [..]string;
|
||||||
|
}
|
||||||
|
|
||||||
|
Shader_Compiler :: struct {
|
||||||
|
environment : Environment;
|
||||||
|
}
|
||||||
|
|
||||||
|
Field_Kind :: enum {
|
||||||
|
Int :: 0;
|
||||||
|
Half :: 1;
|
||||||
|
Float :: 2;
|
||||||
|
Double :: 3;
|
||||||
|
Texture2D :: 8;
|
||||||
|
Sampler :: 9;
|
||||||
|
|
||||||
|
Function;
|
||||||
|
Struct;
|
||||||
|
Array;
|
||||||
|
}
|
||||||
|
|
||||||
|
Field_Type :: struct {
|
||||||
|
kind : Field_Kind;
|
||||||
|
|
||||||
|
name : string; //@Note(niels): for structs
|
||||||
|
|
||||||
|
children : [..]Field;
|
||||||
|
}
|
||||||
|
|
||||||
|
Hint_Kind :: enum {
|
||||||
|
None;
|
||||||
|
|
||||||
|
Position;
|
||||||
|
Target;
|
||||||
|
|
||||||
|
Custom;
|
||||||
|
}
|
||||||
|
|
||||||
|
Field_Hint :: struct {
|
||||||
|
kind : Hint_Kind;
|
||||||
|
|
||||||
|
target_index : int;
|
||||||
|
custom_hint_name : string;
|
||||||
|
}
|
||||||
|
|
||||||
|
Field :: struct {
|
||||||
|
name : string;
|
||||||
|
|
||||||
|
type : Field_Type;
|
||||||
|
hints : [..]Field_Hint;
|
||||||
|
}
|
||||||
|
|
||||||
|
Entry_Point :: struct {
|
||||||
|
name : string;
|
||||||
|
|
||||||
|
function_input : [..]Field;
|
||||||
|
return_value : Field;
|
||||||
|
}
|
||||||
|
|
||||||
|
Shader_Variant :: struct {
|
||||||
|
text : string;
|
||||||
|
|
||||||
|
vertex_entry_point : struct {
|
||||||
|
name : string;
|
||||||
|
|
||||||
|
input : [..]Field;
|
||||||
|
}
|
||||||
|
|
||||||
|
pixel_entry_point : struct {
|
||||||
|
name : string;
|
||||||
|
|
||||||
|
return_value : Field;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Property_Field :: struct {
|
||||||
|
base_field : Field;
|
||||||
|
|
||||||
|
// @Incomplete(nb): Editor information, min max, etc.
|
||||||
|
// This should also be compiled out for ship
|
||||||
|
}
|
||||||
|
|
||||||
|
Properties :: struct {
|
||||||
|
fields : [..]Property_Field;
|
||||||
|
|
||||||
|
buffer_index : u32;
|
||||||
|
}
|
||||||
|
|
||||||
|
Shader_Variant_Collection :: struct {
|
||||||
|
properties : Properties;
|
||||||
|
|
||||||
|
variants : [..]Shader_Variant;
|
||||||
|
}
|
||||||
|
|
||||||
|
Compilation_Result :: struct {
|
||||||
|
messages : [..]Compiler_Message;
|
||||||
|
|
||||||
|
had_error : bool;
|
||||||
|
|
||||||
|
collection : Shader_Variant_Collection;
|
||||||
|
}
|
||||||
|
|
||||||
|
pretty_print_field :: (field : *Field) -> string {
|
||||||
|
builder : String_Builder;
|
||||||
|
init_string_builder(*builder,, temp);
|
||||||
|
|
||||||
|
pretty_print_field(*builder, field);
|
||||||
|
|
||||||
|
return builder_to_string(*builder);
|
||||||
|
}
|
||||||
|
|
||||||
|
Min_Field_Name :: 10;
|
||||||
|
|
||||||
|
pretty_print_field :: (builder : *String_Builder, field : *Field) {
|
||||||
|
if field.name.count > 0 {
|
||||||
|
print_to_builder(builder, "% ", field.name);
|
||||||
|
append(builder, "- ");
|
||||||
|
} else {
|
||||||
|
append(builder, "return - ");
|
||||||
|
}
|
||||||
|
|
||||||
|
type := field.type;
|
||||||
|
|
||||||
|
if type.kind == {
|
||||||
|
case .Int; {
|
||||||
|
append(builder, "int");
|
||||||
|
}
|
||||||
|
case .Half; {
|
||||||
|
append(builder, "half");
|
||||||
|
}
|
||||||
|
case .Float; {
|
||||||
|
append(builder, "float");
|
||||||
|
}
|
||||||
|
case .Double; {
|
||||||
|
append(builder, "double");
|
||||||
|
}
|
||||||
|
case .Texture2D; {
|
||||||
|
append(builder, "texture2D");
|
||||||
|
}
|
||||||
|
case .Sampler; {
|
||||||
|
append(builder, "sampler");
|
||||||
|
}
|
||||||
|
case .Struct; {
|
||||||
|
print_to_builder(builder, "struct : % {", type.name);
|
||||||
|
|
||||||
|
for *child : type.children {
|
||||||
|
pretty_print_field(builder, child);
|
||||||
|
if it_index < type.children.count - 1 {
|
||||||
|
append(builder, " ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
append(builder, "} ");
|
||||||
|
}
|
||||||
|
case .Array; {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for hint : field.hints {
|
||||||
|
if hint.kind == {
|
||||||
|
case .Position; {
|
||||||
|
append(builder, "(@position)");
|
||||||
|
}
|
||||||
|
case .Target; {
|
||||||
|
print_to_builder(builder, "(@target%)", hint.target_index);
|
||||||
|
}
|
||||||
|
case .Custom; {
|
||||||
|
print_to_builder(builder, "(@%)", hint.custom_hint_name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if it_index != field.hints.count - 1 {
|
||||||
|
append(builder, ", ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type_variable_to_field :: (checker : *Semantic_Checker, variable : Type_Variable_Handle) -> Field {
|
||||||
|
return type_variable_to_field(checker, h2tv(checker, variable));
|
||||||
|
}
|
||||||
|
|
||||||
|
type_variable_to_field :: (checker : *Semantic_Checker, variable : *Type_Variable) -> Field {
|
||||||
|
field : Field;
|
||||||
|
|
||||||
|
field.name = variable.name;
|
||||||
|
|
||||||
|
type : Field_Type;
|
||||||
|
|
||||||
|
if variable.type == {
|
||||||
|
case .Int; {
|
||||||
|
type.kind = Field_Kind.Int;
|
||||||
|
}
|
||||||
|
case .Half; {
|
||||||
|
type.kind = Field_Kind.Half;
|
||||||
|
}
|
||||||
|
case .Float; {
|
||||||
|
type.kind = Field_Kind.Float;
|
||||||
|
}
|
||||||
|
case .Double; {
|
||||||
|
type.kind = Field_Kind.Double;
|
||||||
|
}
|
||||||
|
case .Texture2D; {
|
||||||
|
type.kind = Field_Kind.Texture2D;
|
||||||
|
}
|
||||||
|
case .Sampler; {
|
||||||
|
type.kind = Field_Kind.Sampler;
|
||||||
|
}
|
||||||
|
case .Struct; {
|
||||||
|
type.kind = Field_Kind.Struct;
|
||||||
|
|
||||||
|
find_result := find_symbol(checker, variable.typename, xx 1);
|
||||||
|
assert(find_result != null, "Internal compiler error\n");
|
||||||
|
|
||||||
|
type_var := h2tv(checker, find_result.type_variable);
|
||||||
|
|
||||||
|
for i : 0..type_var.child_count - 1 {
|
||||||
|
child := type_var.children[i];
|
||||||
|
child_field := type_variable_to_field(checker, h2tv(checker, child));
|
||||||
|
array_add(*type.children, child_field);
|
||||||
|
}
|
||||||
|
|
||||||
|
type.name = variable.typename;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for hint : variable.source_node.hint_tokens {
|
||||||
|
field_hint : Field_Hint;
|
||||||
|
|
||||||
|
if hint.ident_value == "position" {
|
||||||
|
// @Incomplete(nb): Should be a lookup table somewhere
|
||||||
|
field_hint.kind = .Position;
|
||||||
|
} else if starts_with(hint.ident_value, "target") {
|
||||||
|
// @Incomplete(nb): Should be a lookup table somewhere
|
||||||
|
index_str : string;
|
||||||
|
index_str.data = *hint.ident_value.data[7];
|
||||||
|
index_str.count = 1;
|
||||||
|
|
||||||
|
result, ok, remainder := string_to_int(index_str);
|
||||||
|
if ok {
|
||||||
|
field_hint.target_index = result;
|
||||||
|
}
|
||||||
|
field_hint.kind = .Target;
|
||||||
|
} else {
|
||||||
|
// @Incomplete(nb): custo hints
|
||||||
|
}
|
||||||
|
array_add(*field.hints, field_hint);
|
||||||
|
}
|
||||||
|
|
||||||
|
field.type = type;
|
||||||
|
|
||||||
|
return field;
|
||||||
|
}
|
||||||
|
|
||||||
|
compile_file :: (compiler : *Shader_Compiler, path : string) -> Compilation_Result {
|
||||||
|
result : Compilation_Result;
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
lex_result := lex(*lexer,, *temp);
|
||||||
|
if lex_result.had_error {
|
||||||
|
copy_messages(lex_result.messages, *result.messages);
|
||||||
|
result.had_error = true;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
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.vertex_entry_point {
|
||||||
|
variant.vertex_entry_point.name = checker.vertex_entry_point.name;
|
||||||
|
|
||||||
|
type_variable := h2tv(*checker, checker.vertex_entry_point.type_variable);
|
||||||
|
assert(type_variable.type == .Function);
|
||||||
|
|
||||||
|
node := type_variable.source_node;
|
||||||
|
if node.children.count > 0 {
|
||||||
|
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);
|
||||||
|
print("%\n", pretty_print_field(*field));
|
||||||
|
array_add(*variant.vertex_entry_point.input, field);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
find_result := find_symbol(*check_result.scope_stack, "properties", xx 1);
|
||||||
|
if find_result {
|
||||||
|
property_variable := h2tv(check_result.type_variables, find_result.type_variable);
|
||||||
|
|
||||||
|
for i : 0..property_variable.child_count - 1 {
|
||||||
|
child := property_variable.children[i];
|
||||||
|
field := type_variable_to_field(*checker, h2tv(*checker, child));
|
||||||
|
prop_field : Property_Field;
|
||||||
|
prop_field.base_field = field;
|
||||||
|
array_add(*result.collection.properties.fields, prop_field);
|
||||||
|
}
|
||||||
|
result.collection.properties.buffer_index = property_variable.buffer_index;
|
||||||
|
}
|
||||||
|
|
||||||
|
if checker.pixel_entry_point {
|
||||||
|
variant.pixel_entry_point.name = checker.pixel_entry_point.name;
|
||||||
|
|
||||||
|
type_variable := h2tv(*checker, checker.pixel_entry_point.type_variable);
|
||||||
|
assert(type_variable.type == .Function);
|
||||||
|
|
||||||
|
field := type_variable_to_field(*checker, type_variable.return_var);
|
||||||
|
for hint : type_variable.source_node.hint_tokens {
|
||||||
|
field_hint : Field_Hint;
|
||||||
|
|
||||||
|
if hint.ident_value == "position" {
|
||||||
|
// @Incomplete(nb): Should be a lookup table somewhere
|
||||||
|
field_hint.kind = .Position;
|
||||||
|
} else if starts_with(hint.ident_value, "target") {
|
||||||
|
// @Incomplete(nb): Should be a lookup table somewhere
|
||||||
|
index_str : string;
|
||||||
|
index_str.data = *hint.ident_value.data[7];
|
||||||
|
index_str.count = 1;
|
||||||
|
|
||||||
|
result, ok, remainder := string_to_int(index_str);
|
||||||
|
if ok {
|
||||||
|
field_hint.target_index = result;
|
||||||
|
}
|
||||||
|
field_hint.kind = .Target;
|
||||||
|
} else {
|
||||||
|
// @Incomplete(nb): custo hints
|
||||||
|
}
|
||||||
|
array_add(*field.hints, field_hint);
|
||||||
|
}
|
||||||
|
|
||||||
|
variant.pixel_entry_point.return_value = field;
|
||||||
|
print("%\n", pretty_print_field(*field));
|
||||||
|
}
|
||||||
|
|
||||||
|
array_add(*result.collection.variants, variant);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
12
test/all.suite
Normal file
12
test/all.suite
Normal file
@@ -0,0 +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
|
||||||
3
test/assign_arithmetic_expression.shd
Normal file
3
test/assign_arithmetic_expression.shd
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
vertex main :: () {
|
||||||
|
x : float = 2.0 + 5.0;
|
||||||
|
}
|
||||||
11
test/basic_property_and_return_value.shd
Normal file
11
test/basic_property_and_return_value.shd
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
properties {
|
||||||
|
color : float4;
|
||||||
|
}
|
||||||
|
|
||||||
|
vertex main :: (pos : float3 @position) -> float3 @position {
|
||||||
|
return pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
pixel main :: () -> float4 @target0 {
|
||||||
|
return properties.color;
|
||||||
|
}
|
||||||
5
test/codegen/assign_arithmetic_expression.golden
Normal file
5
test/codegen/assign_arithmetic_expression.golden
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
void vs_main()
|
||||||
|
{
|
||||||
|
float x = 2.0f + 5.0f;
|
||||||
|
}
|
||||||
|
|
||||||
15
test/codegen/basic_property_and_return_value.golden
Normal file
15
test/codegen/basic_property_and_return_value.golden
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
cbuffer __PROPERTIES : register(b0)
|
||||||
|
{
|
||||||
|
float4 color;
|
||||||
|
}
|
||||||
|
|
||||||
|
float3 vs_main(float3 pos : POSITION) : SV_POSITION
|
||||||
|
{
|
||||||
|
return pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
float4 ps_main() : SV_TARGET
|
||||||
|
{
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
7
test/codegen/complicated_computation.golden
Normal file
7
test/codegen/complicated_computation.golden
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
void vs_main()
|
||||||
|
{
|
||||||
|
float x = 5.0f;
|
||||||
|
float y = 3000.0f;
|
||||||
|
float z = y * y + x;
|
||||||
|
}
|
||||||
|
|
||||||
4
test/codegen/empty_struct.golden
Normal file
4
test/codegen/empty_struct.golden
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
struct Foo;
|
||||||
|
|
||||||
|
struct Foo {}
|
||||||
|
|
||||||
4
test/codegen/empty_vertex_main.golden
Normal file
4
test/codegen/empty_vertex_main.golden
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
void vs_main()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
float3 vs_main(float3 pos : POSITION)
|
||||||
|
{
|
||||||
|
return pos;
|
||||||
|
}
|
||||||
|
|
||||||
7
test/codegen/field_assignment.golden
Normal file
7
test/codegen/field_assignment.golden
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
float4 vs_main(float4 pos : POSITION) : SV_POSITION
|
||||||
|
{
|
||||||
|
float x = 5.0f;
|
||||||
|
x = 7.0f;
|
||||||
|
return pos;
|
||||||
|
}
|
||||||
|
|
||||||
12
test/codegen/function_call.golden
Normal file
12
test/codegen/function_call.golden
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
int foo();
|
||||||
|
|
||||||
|
int foo()
|
||||||
|
{
|
||||||
|
return 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
void vs_main()
|
||||||
|
{
|
||||||
|
foo();
|
||||||
|
}
|
||||||
|
|
||||||
11
test/codegen/function_call_out_of_order_declaration.golden
Normal file
11
test/codegen/function_call_out_of_order_declaration.golden
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
void foo();
|
||||||
|
|
||||||
|
void vs_main()
|
||||||
|
{
|
||||||
|
foo();
|
||||||
|
}
|
||||||
|
|
||||||
|
void foo()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
9
test/codegen/function_call_return.golden
Normal file
9
test/codegen/function_call_return.golden
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
void vs_main()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
float4 ps_main() : SV_TARGET
|
||||||
|
{
|
||||||
|
return float4(1, 1, 1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
15
test/codegen/meta_block.golden
Normal file
15
test/codegen/meta_block.golden
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
cbuffer __PROPERTIES : register(b0)
|
||||||
|
{
|
||||||
|
float4 color;
|
||||||
|
}
|
||||||
|
|
||||||
|
float3 vs_main(float3 pos : POSITION, float2 uv) : SV_POSITION
|
||||||
|
{
|
||||||
|
return pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
float4 ps_main() : SV_TARGET
|
||||||
|
{
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
19
test/codegen/multiple_functions.golden
Normal file
19
test/codegen/multiple_functions.golden
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
int foo();
|
||||||
|
float bar();
|
||||||
|
|
||||||
|
int foo()
|
||||||
|
{
|
||||||
|
return 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
float bar()
|
||||||
|
{
|
||||||
|
return 1235.0f * 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
void vs_main()
|
||||||
|
{
|
||||||
|
int x = foo();
|
||||||
|
float y = bar();
|
||||||
|
}
|
||||||
|
|
||||||
19
test/codegen/multiple_semicolons_everywhere.golden
Normal file
19
test/codegen/multiple_semicolons_everywhere.golden
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
float4 foo();
|
||||||
|
|
||||||
|
float3 vs_main(float3 pos : POSITION) : SV_POSITION
|
||||||
|
{
|
||||||
|
return pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
float4 foo()
|
||||||
|
{
|
||||||
|
return float4(1.0f, 1.0f, 1.0f, 1.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
float4 ps_main() : SV_TARGET
|
||||||
|
{
|
||||||
|
float4 y = foo();
|
||||||
|
float4 color = y;
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
struct Foo;
|
||||||
|
|
||||||
|
float foo(Foo f);
|
||||||
|
|
||||||
|
struct Foo
|
||||||
|
{
|
||||||
|
float some_data;
|
||||||
|
}
|
||||||
|
|
||||||
|
float foo(Foo f)
|
||||||
|
{
|
||||||
|
return f.some_data * 2.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
void vs_main()
|
||||||
|
{
|
||||||
|
Foo f;
|
||||||
|
f.some_data = 4.0f;
|
||||||
|
float d = foo(f);
|
||||||
|
}
|
||||||
|
|
||||||
10
test/codegen/passthrough.golden
Normal file
10
test/codegen/passthrough.golden
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
float3 vs_main(float3 pos : POSITION) : SV_POSITION
|
||||||
|
{
|
||||||
|
return pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
float4 ps_main() : SV_TARGET
|
||||||
|
{
|
||||||
|
return float4(1.0f, 1.0f, 1.0f, 1.0f);
|
||||||
|
}
|
||||||
|
|
||||||
8
test/codegen/precedence_test.golden
Normal file
8
test/codegen/precedence_test.golden
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
void vs_main()
|
||||||
|
{
|
||||||
|
float x = 2;
|
||||||
|
float y = 5;
|
||||||
|
float z = 10;
|
||||||
|
float w = x * y + y * z - x / y * x;
|
||||||
|
}
|
||||||
|
|
||||||
13
test/codegen/simple_struct_access.golden
Normal file
13
test/codegen/simple_struct_access.golden
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
struct Data;
|
||||||
|
|
||||||
|
struct Data
|
||||||
|
{
|
||||||
|
float4 color;
|
||||||
|
}
|
||||||
|
|
||||||
|
void vs_main()
|
||||||
|
{
|
||||||
|
Data d;
|
||||||
|
float4 x = d.color;
|
||||||
|
}
|
||||||
|
|
||||||
20
test/codegen/struct_within_struct.golden
Normal file
20
test/codegen/struct_within_struct.golden
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
struct Foo;
|
||||||
|
struct Bar;
|
||||||
|
|
||||||
|
struct Foo
|
||||||
|
{
|
||||||
|
float4 color;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Bar
|
||||||
|
{
|
||||||
|
Foo t;
|
||||||
|
}
|
||||||
|
|
||||||
|
void vs_main()
|
||||||
|
{
|
||||||
|
Foo f;
|
||||||
|
Bar b;
|
||||||
|
b.t = f;
|
||||||
|
}
|
||||||
|
|
||||||
5
test/codegen/use_builtin_functions.golden
Normal file
5
test/codegen/use_builtin_functions.golden
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
void vs_main()
|
||||||
|
{
|
||||||
|
float4 f = float4(1, 1, 1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
19
test/codegen_all.suite
Normal file
19
test/codegen_all.suite
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
test/assign_arithmetic_expression.shd codegen
|
||||||
|
test/basic_property_and_return_value.shd codegen
|
||||||
|
test/complicated_computation.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
|
||||||
20
test/compile_all.suite
Normal file
20
test/compile_all.suite
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
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
|
||||||
6
test/complicated_computation.shd
Normal file
6
test/complicated_computation.shd
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
vertex main :: () {
|
||||||
|
x : float = 5.0;
|
||||||
|
y : float = 3000.0;
|
||||||
|
|
||||||
|
z : float = y * y + x;
|
||||||
|
}
|
||||||
3
test/empty_struct.shd
Normal file
3
test/empty_struct.shd
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
Foo :: struct {}
|
||||||
|
|
||||||
|
|
||||||
3
test/empty_vertex_main.shd
Normal file
3
test/empty_vertex_main.shd
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
vertex main :: () {
|
||||||
|
|
||||||
|
}
|
||||||
3
test/empty_vertex_main_with_position_parameter.shd
Normal file
3
test/empty_vertex_main_with_position_parameter.shd
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
vertex main :: (pos : float3 @position) -> float3 {
|
||||||
|
return pos;
|
||||||
|
}
|
||||||
6
test/field_assignment.shd
Normal file
6
test/field_assignment.shd
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
vertex main :: (pos : float4 @position) -> float4 @position {
|
||||||
|
x : float = 5.0;
|
||||||
|
x = 7.0;
|
||||||
|
|
||||||
|
return pos;
|
||||||
|
}
|
||||||
3
test/field_without_type_specifier.shd
Normal file
3
test/field_without_type_specifier.shd
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
vertex main :: () {
|
||||||
|
x := 5.0;
|
||||||
|
}
|
||||||
3
test/float_suffix.shd
Normal file
3
test/float_suffix.shd
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
vertex main :: () {
|
||||||
|
x : float = 2.0f;
|
||||||
|
}
|
||||||
7
test/function_call.shd
Normal file
7
test/function_call.shd
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
foo :: () -> int {
|
||||||
|
return 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
vertex main :: () {
|
||||||
|
foo();
|
||||||
|
}
|
||||||
7
test/function_call_out_of_order_declaration.shd
Normal file
7
test/function_call_out_of_order_declaration.shd
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
vertex main :: () {
|
||||||
|
foo();
|
||||||
|
}
|
||||||
|
|
||||||
|
foo :: () {
|
||||||
|
|
||||||
|
}
|
||||||
7
test/function_call_return.shd
Normal file
7
test/function_call_return.shd
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
vertex main :: () {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
pixel main :: () -> float4 @target0 {
|
||||||
|
return float4(1, 1, 1, 1);
|
||||||
|
}
|
||||||
3
test/function_with_int_return.shd
Normal file
3
test/function_with_int_return.shd
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
vertex main :: (pos : float3) -> int {
|
||||||
|
|
||||||
|
}
|
||||||
7
test/functions_with_same_name.shd
Normal file
7
test/functions_with_same_name.shd
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
foo :: () {}
|
||||||
|
foo :: () {}
|
||||||
|
bar :: () {}
|
||||||
|
|
||||||
|
vertex main :: () {
|
||||||
|
|
||||||
|
}
|
||||||
16
test/lex/assign_arithmetic_expression.golden
Normal file
16
test/lex/assign_arithmetic_expression.golden
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
{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_IDENTIFIER; ; index = 26 ; length = 5 line = 2 ; column = 4 ; value ='float'; }
|
||||||
|
{kind = TOKEN_ASSIGN; ; index = 32 ; length = 1 line = 2 ; column = 10 ; value ='='; }
|
||||||
|
{kind = TOKEN_FLOATLITERAL; ; index = 34 ; length = 3 line = 2 ; column = 12 ; value ='2'; }
|
||||||
|
{kind = TOKEN_PLUS; ; index = 38 ; length = 1 line = 2 ; column = 16 ; value ='+'; }
|
||||||
|
{kind = TOKEN_FLOATLITERAL; ; index = 40 ; length = 3 line = 2 ; column = 18 ; value ='5'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 43 ; length = 1 line = 2 ; column = 21 ; value =';'; }
|
||||||
|
{kind = TOKEN_RIGHTBRACE; ; index = 46 ; length = 1 line = 3 ; column = 0 ; value ='}'; }
|
||||||
|
{kind = TOKEN_EOF; ; index = 49 ; length = 0 line = 4 ; column = 0 ; value =''; }
|
||||||
43
test/lex/basic_property_and_return_value.golden
Normal file
43
test/lex/basic_property_and_return_value.golden
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
{kind = TOKEN_PROPERTIES; ; index = 0 ; length = 10 line = 1 ; column = 0 ; value ='properties'; }
|
||||||
|
{kind = TOKEN_LEFTBRACE; ; index = 11 ; length = 1 line = 1 ; column = 11 ; value ='{'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 15 ; length = 5 line = 2 ; column = 0 ; value ='color'; }
|
||||||
|
{kind = TOKEN_COLON; ; index = 21 ; length = 1 line = 2 ; column = 6 ; value =':'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 23 ; length = 6 line = 2 ; column = 8 ; value ='float4'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 29 ; length = 1 line = 2 ; column = 14 ; value =';'; }
|
||||||
|
{kind = TOKEN_RIGHTBRACE; ; index = 32 ; length = 1 line = 3 ; column = 0 ; value ='}'; }
|
||||||
|
{kind = TOKEN_VERTEX; ; index = 37 ; length = 6 line = 5 ; column = 0 ; value ='vertex'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 44 ; length = 4 line = 5 ; column = 7 ; value ='main'; }
|
||||||
|
{kind = TOKEN_DOUBLECOLON; ; index = 49 ; length = 2 line = 5 ; column = 12 ; value ='::'; }
|
||||||
|
{kind = TOKEN_LEFTPAREN; ; index = 52 ; length = 1 line = 5 ; column = 15 ; value ='('; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 53 ; length = 3 line = 5 ; column = 16 ; value ='pos'; }
|
||||||
|
{kind = TOKEN_COLON; ; index = 57 ; length = 1 line = 5 ; column = 20 ; value =':'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 59 ; length = 6 line = 5 ; column = 22 ; value ='float3'; }
|
||||||
|
{kind = TOKEN_AT; ; index = 66 ; length = 1 line = 5 ; column = 29 ; value ='@'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 67 ; length = 8 line = 5 ; column = 30 ; value ='position'; }
|
||||||
|
{kind = TOKEN_RIGHTPAREN; ; index = 75 ; length = 1 line = 5 ; column = 38 ; value =')'; }
|
||||||
|
{kind = TOKEN_ARROW; ; index = 77 ; length = 2 line = 5 ; column = 40 ; value ='->'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 80 ; length = 6 line = 5 ; column = 43 ; value ='float3'; }
|
||||||
|
{kind = TOKEN_AT; ; index = 87 ; length = 1 line = 5 ; column = 50 ; value ='@'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 88 ; length = 8 line = 5 ; column = 51 ; value ='position'; }
|
||||||
|
{kind = TOKEN_LEFTBRACE; ; index = 97 ; length = 1 line = 5 ; column = 60 ; value ='{'; }
|
||||||
|
{kind = TOKEN_RETURN; ; index = 103 ; length = 6 line = 6 ; column = 2 ; value ='return'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 110 ; length = 3 line = 6 ; column = 9 ; value ='pos'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 113 ; length = 1 line = 6 ; column = 12 ; value =';'; }
|
||||||
|
{kind = TOKEN_RIGHTBRACE; ; index = 116 ; length = 1 line = 7 ; column = 0 ; value ='}'; }
|
||||||
|
{kind = TOKEN_PIXEL; ; index = 121 ; length = 5 line = 9 ; column = 0 ; value ='pixel'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 127 ; length = 4 line = 9 ; column = 6 ; value ='main'; }
|
||||||
|
{kind = TOKEN_DOUBLECOLON; ; index = 132 ; length = 2 line = 9 ; column = 11 ; value ='::'; }
|
||||||
|
{kind = TOKEN_LEFTPAREN; ; index = 135 ; length = 1 line = 9 ; column = 14 ; value ='('; }
|
||||||
|
{kind = TOKEN_RIGHTPAREN; ; index = 136 ; length = 1 line = 9 ; column = 15 ; value =')'; }
|
||||||
|
{kind = TOKEN_ARROW; ; index = 138 ; length = 2 line = 9 ; column = 17 ; value ='->'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 141 ; length = 6 line = 9 ; column = 20 ; value ='float4'; }
|
||||||
|
{kind = TOKEN_AT; ; index = 148 ; length = 1 line = 9 ; column = 27 ; value ='@'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 149 ; length = 7 line = 9 ; column = 28 ; value ='target0'; }
|
||||||
|
{kind = TOKEN_LEFTBRACE; ; index = 157 ; length = 1 line = 9 ; column = 36 ; value ='{'; }
|
||||||
|
{kind = TOKEN_RETURN; ; index = 163 ; length = 6 line = 10 ; column = 2 ; value ='return'; }
|
||||||
|
{kind = TOKEN_PROPERTIES; ; index = 170 ; length = 10 line = 10 ; column = 9 ; value ='properties'; }
|
||||||
|
{kind = TOKEN_DOT; ; index = 180 ; length = 1 line = 10 ; column = 19 ; value ='.'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 181 ; length = 5 line = 10 ; column = 20 ; value ='color'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 186 ; length = 1 line = 10 ; column = 25 ; value =';'; }
|
||||||
|
{kind = TOKEN_RIGHTBRACE; ; index = 189 ; length = 1 line = 11 ; column = 0 ; value ='}'; }
|
||||||
|
{kind = TOKEN_EOF; ; index = 192 ; length = 0 line = 12 ; column = 0 ; value =''; }
|
||||||
30
test/lex/complicated_computation.golden
Normal file
30
test/lex/complicated_computation.golden
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
{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_IDENTIFIER; ; index = 26 ; length = 5 line = 2 ; column = 4 ; value ='float'; }
|
||||||
|
{kind = TOKEN_ASSIGN; ; index = 32 ; length = 1 line = 2 ; column = 10 ; value ='='; }
|
||||||
|
{kind = TOKEN_FLOATLITERAL; ; index = 34 ; length = 3 line = 2 ; column = 12 ; value ='5'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 37 ; length = 1 line = 2 ; column = 15 ; value =';'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 41 ; length = 1 line = 3 ; column = 0 ; value ='y'; }
|
||||||
|
{kind = TOKEN_COLON; ; index = 43 ; length = 1 line = 3 ; column = 2 ; value =':'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 45 ; length = 5 line = 3 ; column = 4 ; value ='float'; }
|
||||||
|
{kind = TOKEN_ASSIGN; ; index = 51 ; length = 1 line = 3 ; column = 10 ; value ='='; }
|
||||||
|
{kind = TOKEN_FLOATLITERAL; ; index = 53 ; length = 6 line = 3 ; column = 12 ; value ='3000'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 59 ; length = 1 line = 3 ; column = 18 ; value =';'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 65 ; length = 1 line = 5 ; column = 0 ; value ='z'; }
|
||||||
|
{kind = TOKEN_COLON; ; index = 67 ; length = 1 line = 5 ; column = 2 ; value =':'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 69 ; length = 5 line = 5 ; column = 4 ; value ='float'; }
|
||||||
|
{kind = TOKEN_ASSIGN; ; index = 75 ; length = 1 line = 5 ; column = 10 ; value ='='; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 77 ; length = 1 line = 5 ; column = 12 ; value ='y'; }
|
||||||
|
{kind = TOKEN_STAR; ; index = 79 ; length = 1 line = 5 ; column = 14 ; value ='*'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 81 ; length = 1 line = 5 ; column = 16 ; value ='y'; }
|
||||||
|
{kind = TOKEN_PLUS; ; index = 83 ; length = 1 line = 5 ; column = 18 ; value ='+'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 85 ; length = 1 line = 5 ; column = 20 ; value ='x'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 86 ; length = 1 line = 5 ; column = 21 ; value =';'; }
|
||||||
|
{kind = TOKEN_RIGHTBRACE; ; index = 89 ; length = 1 line = 6 ; column = 0 ; value ='}'; }
|
||||||
|
{kind = TOKEN_EOF; ; index = 92 ; length = 0 line = 7 ; column = 0 ; value =''; }
|
||||||
6
test/lex/empty_struct.golden
Normal file
6
test/lex/empty_struct.golden
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 0 ; length = 3 line = 1 ; column = 0 ; value ='Foo'; }
|
||||||
|
{kind = TOKEN_DOUBLECOLON; ; index = 4 ; length = 2 line = 1 ; column = 4 ; value ='::'; }
|
||||||
|
{kind = TOKEN_STRUCT; ; index = 7 ; length = 6 line = 1 ; column = 7 ; value ='struct'; }
|
||||||
|
{kind = TOKEN_LEFTBRACE; ; index = 14 ; length = 1 line = 1 ; column = 14 ; value ='{'; }
|
||||||
|
{kind = TOKEN_RIGHTBRACE; ; index = 15 ; length = 1 line = 1 ; column = 15 ; value ='}'; }
|
||||||
|
{kind = TOKEN_EOF; ; index = 22 ; length = 0 line = 4 ; column = 0 ; value =''; }
|
||||||
8
test/lex/empty_vertex_main.golden
Normal file
8
test/lex/empty_vertex_main.golden
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{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_RIGHTBRACE; ; index = 23 ; length = 1 line = 3 ; column = 0 ; value ='}'; }
|
||||||
|
{kind = TOKEN_EOF; ; index = 24 ; length = 0 line = 3 ; column = 1 ; value =''; }
|
||||||
18
test/lex/empty_vertex_main_with_position_parameter.golden
Normal file
18
test/lex/empty_vertex_main_with_position_parameter.golden
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
{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 ='float3'; }
|
||||||
|
{kind = TOKEN_LEFTBRACE; ; index = 50 ; length = 1 line = 1 ; column = 50 ; value ='{'; }
|
||||||
|
{kind = TOKEN_RETURN; ; index = 54 ; length = 6 line = 2 ; column = 0 ; value ='return'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 61 ; length = 3 line = 2 ; column = 7 ; value ='pos'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 64 ; length = 1 line = 2 ; column = 10 ; value =';'; }
|
||||||
|
{kind = TOKEN_RIGHTBRACE; ; index = 67 ; length = 1 line = 3 ; column = 0 ; value ='}'; }
|
||||||
|
{kind = TOKEN_EOF; ; index = 70 ; length = 0 line = 4 ; column = 0 ; value =''; }
|
||||||
30
test/lex/field_assignment.golden
Normal file
30
test/lex/field_assignment.golden
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
{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 ='float4'; }
|
||||||
|
{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_IDENTIFIER; ; index = 64 ; length = 1 line = 2 ; column = 0 ; value ='x'; }
|
||||||
|
{kind = TOKEN_COLON; ; index = 66 ; length = 1 line = 2 ; column = 2 ; value =':'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 68 ; length = 5 line = 2 ; column = 4 ; value ='float'; }
|
||||||
|
{kind = TOKEN_ASSIGN; ; index = 74 ; length = 1 line = 2 ; column = 10 ; value ='='; }
|
||||||
|
{kind = TOKEN_FLOATLITERAL; ; index = 76 ; length = 3 line = 2 ; column = 12 ; value ='5'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 79 ; length = 1 line = 2 ; column = 15 ; value =';'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 83 ; length = 1 line = 3 ; column = 0 ; value ='x'; }
|
||||||
|
{kind = TOKEN_ASSIGN; ; index = 85 ; length = 1 line = 3 ; column = 2 ; value ='='; }
|
||||||
|
{kind = TOKEN_FLOATLITERAL; ; index = 87 ; length = 3 line = 3 ; column = 4 ; value ='7'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 90 ; length = 1 line = 3 ; column = 7 ; value =';'; }
|
||||||
|
{kind = TOKEN_RETURN; ; index = 96 ; length = 6 line = 5 ; column = 0 ; value ='return'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 103 ; length = 3 line = 5 ; column = 7 ; value ='pos'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 106 ; length = 1 line = 5 ; column = 10 ; value =';'; }
|
||||||
|
{kind = TOKEN_RIGHTBRACE; ; index = 109 ; length = 1 line = 6 ; column = 0 ; value ='}'; }
|
||||||
|
{kind = TOKEN_EOF; ; index = 112 ; length = 0 line = 7 ; column = 0 ; value =''; }
|
||||||
13
test/lex/field_without_type_specifier.golden
Normal file
13
test/lex/field_without_type_specifier.golden
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
{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 ='5'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 30 ; length = 1 line = 2 ; column = 8 ; value =';'; }
|
||||||
|
{kind = TOKEN_RIGHTBRACE; ; index = 33 ; length = 1 line = 3 ; column = 0 ; value ='}'; }
|
||||||
|
{kind = TOKEN_EOF; ; index = 36 ; length = 0 line = 4 ; column = 0 ; value =''; }
|
||||||
4
test/lex/float_suffix.golden
Normal file
4
test/lex/float_suffix.golden
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
[1;37mtest/float_suffix.shd:2,12: [31merror: [37mWe don't use 'f' suffixes for floating point values.
|
||||||
|
[36m x : float = 2.0f
|
||||||
|
^^^^
|
||||||
|
[37m
|
||||||
40
test/lex/foreign_function.golden
Normal file
40
test/lex/foreign_function.golden
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
{kind = TOKEN_DIRECTIVE; ; index = 1 ; length = 7 line = 1 ; column = 0 ; value ='foreign'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 9 ; length = 6 line = 1 ; column = 8 ; value ='float2'; }
|
||||||
|
{kind = TOKEN_DOUBLECOLON; ; index = 16 ; length = 2 line = 1 ; column = 15 ; value ='::'; }
|
||||||
|
{kind = TOKEN_LEFTPAREN; ; index = 19 ; length = 1 line = 1 ; column = 18 ; value ='('; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 20 ; length = 5 line = 1 ; column = 19 ; value ='float'; }
|
||||||
|
{kind = TOKEN_COMMA; ; index = 25 ; length = 1 line = 1 ; column = 24 ; value =','; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 27 ; length = 5 line = 1 ; column = 26 ; value ='float'; }
|
||||||
|
{kind = TOKEN_RIGHTPAREN; ; index = 32 ; length = 1 line = 1 ; column = 31 ; value =')'; }
|
||||||
|
{kind = TOKEN_ARROW; ; index = 34 ; length = 2 line = 1 ; column = 33 ; value ='->'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 37 ; length = 6 line = 1 ; column = 36 ; value ='float2'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 43 ; length = 1 line = 1 ; column = 42 ; value =';'; }
|
||||||
|
{kind = TOKEN_DIRECTIVE; ; index = 47 ; length = 7 line = 2 ; column = 0 ; value ='foreign'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 55 ; length = 6 line = 2 ; column = 8 ; value ='float3'; }
|
||||||
|
{kind = TOKEN_DOUBLECOLON; ; index = 62 ; length = 2 line = 2 ; column = 15 ; value ='::'; }
|
||||||
|
{kind = TOKEN_LEFTPAREN; ; index = 65 ; length = 1 line = 2 ; column = 18 ; value ='('; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 66 ; length = 5 line = 2 ; column = 19 ; value ='float'; }
|
||||||
|
{kind = TOKEN_COMMA; ; index = 71 ; length = 1 line = 2 ; column = 24 ; value =','; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 73 ; length = 5 line = 2 ; column = 26 ; value ='float'; }
|
||||||
|
{kind = TOKEN_COMMA; ; index = 78 ; length = 1 line = 2 ; column = 31 ; value =','; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 80 ; length = 5 line = 2 ; column = 33 ; value ='float'; }
|
||||||
|
{kind = TOKEN_RIGHTPAREN; ; index = 85 ; length = 1 line = 2 ; column = 38 ; value =')'; }
|
||||||
|
{kind = TOKEN_ARROW; ; index = 87 ; length = 2 line = 2 ; column = 40 ; value ='->'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 90 ; length = 6 line = 2 ; column = 43 ; value ='float3'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 96 ; length = 1 line = 2 ; column = 49 ; value =';'; }
|
||||||
|
{kind = TOKEN_DIRECTIVE; ; index = 100 ; length = 7 line = 3 ; column = 0 ; value ='foreign'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 108 ; length = 6 line = 3 ; column = 8 ; value ='float4'; }
|
||||||
|
{kind = TOKEN_DOUBLECOLON; ; index = 115 ; length = 2 line = 3 ; column = 15 ; value ='::'; }
|
||||||
|
{kind = TOKEN_LEFTPAREN; ; index = 118 ; length = 1 line = 3 ; column = 18 ; value ='('; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 119 ; length = 5 line = 3 ; column = 19 ; value ='float'; }
|
||||||
|
{kind = TOKEN_COMMA; ; index = 124 ; length = 1 line = 3 ; column = 24 ; value =','; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 126 ; length = 5 line = 3 ; column = 26 ; value ='float'; }
|
||||||
|
{kind = TOKEN_COMMA; ; index = 131 ; length = 1 line = 3 ; column = 31 ; value =','; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 133 ; length = 5 line = 3 ; column = 33 ; value ='float'; }
|
||||||
|
{kind = TOKEN_COMMA; ; index = 138 ; length = 1 line = 3 ; column = 38 ; value =','; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 140 ; length = 5 line = 3 ; column = 40 ; value ='float'; }
|
||||||
|
{kind = TOKEN_RIGHTPAREN; ; index = 145 ; length = 1 line = 3 ; column = 45 ; value =')'; }
|
||||||
|
{kind = TOKEN_ARROW; ; index = 147 ; length = 2 line = 3 ; column = 47 ; value ='->'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 150 ; length = 6 line = 3 ; column = 50 ; value ='float4'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 156 ; length = 1 line = 3 ; column = 56 ; value =';'; }
|
||||||
|
{kind = TOKEN_EOF; ; index = 159 ; length = 0 line = 4 ; column = 0 ; value =''; }
|
||||||
96
test/lex/foreign_overload.golden
Normal file
96
test/lex/foreign_overload.golden
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
{kind = TOKEN_DIRECTIVE; ; index = 1 ; length = 7 line = 1 ; column = 0 ; value ='foreign'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 9 ; length = 3 line = 1 ; column = 8 ; value ='mul'; }
|
||||||
|
{kind = TOKEN_DOUBLECOLON; ; index = 13 ; length = 2 line = 1 ; column = 12 ; value ='::'; }
|
||||||
|
{kind = TOKEN_LEFTPAREN; ; index = 16 ; length = 1 line = 1 ; column = 15 ; value ='('; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 17 ; length = 6 line = 1 ; column = 16 ; value ='float2'; }
|
||||||
|
{kind = TOKEN_COMMA; ; index = 23 ; length = 1 line = 1 ; column = 22 ; value =','; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 25 ; length = 6 line = 1 ; column = 24 ; value ='float2'; }
|
||||||
|
{kind = TOKEN_RIGHTPAREN; ; index = 31 ; length = 1 line = 1 ; column = 30 ; value =')'; }
|
||||||
|
{kind = TOKEN_ARROW; ; index = 33 ; length = 2 line = 1 ; column = 32 ; value ='->'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 36 ; length = 6 line = 1 ; column = 35 ; value ='float2'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 42 ; length = 1 line = 1 ; column = 41 ; value =';'; }
|
||||||
|
{kind = TOKEN_DIRECTIVE; ; index = 46 ; length = 7 line = 2 ; column = 0 ; value ='foreign'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 54 ; length = 3 line = 2 ; column = 8 ; value ='mul'; }
|
||||||
|
{kind = TOKEN_DOUBLECOLON; ; index = 58 ; length = 2 line = 2 ; column = 12 ; value ='::'; }
|
||||||
|
{kind = TOKEN_LEFTPAREN; ; index = 61 ; length = 1 line = 2 ; column = 15 ; value ='('; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 62 ; length = 6 line = 2 ; column = 16 ; value ='float3'; }
|
||||||
|
{kind = TOKEN_COMMA; ; index = 68 ; length = 1 line = 2 ; column = 22 ; value =','; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 70 ; length = 6 line = 2 ; column = 24 ; value ='float3'; }
|
||||||
|
{kind = TOKEN_RIGHTPAREN; ; index = 76 ; length = 1 line = 2 ; column = 30 ; value =')'; }
|
||||||
|
{kind = TOKEN_ARROW; ; index = 78 ; length = 2 line = 2 ; column = 32 ; value ='->'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 81 ; length = 6 line = 2 ; column = 35 ; value ='float3'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 87 ; length = 1 line = 2 ; column = 41 ; value =';'; }
|
||||||
|
{kind = TOKEN_DIRECTIVE; ; index = 91 ; length = 7 line = 3 ; column = 0 ; value ='foreign'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 99 ; length = 3 line = 3 ; column = 8 ; value ='mul'; }
|
||||||
|
{kind = TOKEN_DOUBLECOLON; ; index = 103 ; length = 2 line = 3 ; column = 12 ; value ='::'; }
|
||||||
|
{kind = TOKEN_LEFTPAREN; ; index = 106 ; length = 1 line = 3 ; column = 15 ; value ='('; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 107 ; length = 6 line = 3 ; column = 16 ; value ='float4'; }
|
||||||
|
{kind = TOKEN_COMMA; ; index = 113 ; length = 1 line = 3 ; column = 22 ; value =','; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 115 ; length = 6 line = 3 ; column = 24 ; value ='float4'; }
|
||||||
|
{kind = TOKEN_RIGHTPAREN; ; index = 121 ; length = 1 line = 3 ; column = 30 ; value =')'; }
|
||||||
|
{kind = TOKEN_ARROW; ; index = 123 ; length = 2 line = 3 ; column = 32 ; value ='->'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 126 ; length = 6 line = 3 ; column = 35 ; value ='float4'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 132 ; length = 1 line = 3 ; column = 41 ; value =';'; }
|
||||||
|
{kind = TOKEN_DIRECTIVE; ; index = 136 ; length = 7 line = 4 ; column = 0 ; value ='foreign'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 144 ; length = 3 line = 4 ; column = 8 ; value ='mul'; }
|
||||||
|
{kind = TOKEN_DOUBLECOLON; ; index = 148 ; length = 2 line = 4 ; column = 12 ; value ='::'; }
|
||||||
|
{kind = TOKEN_LEFTPAREN; ; index = 151 ; length = 1 line = 4 ; column = 15 ; value ='('; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 152 ; length = 8 line = 4 ; column = 16 ; value ='float4x4'; }
|
||||||
|
{kind = TOKEN_COMMA; ; index = 160 ; length = 1 line = 4 ; column = 24 ; value =','; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 162 ; length = 8 line = 4 ; column = 26 ; value ='float4x4'; }
|
||||||
|
{kind = TOKEN_RIGHTPAREN; ; index = 170 ; length = 1 line = 4 ; column = 34 ; value =')'; }
|
||||||
|
{kind = TOKEN_ARROW; ; index = 172 ; length = 2 line = 4 ; column = 36 ; value ='->'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 175 ; length = 8 line = 4 ; column = 39 ; value ='float4x4'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 183 ; length = 1 line = 4 ; column = 47 ; value =';'; }
|
||||||
|
{kind = TOKEN_DIRECTIVE; ; index = 189 ; length = 7 line = 6 ; column = 0 ; value ='foreign'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 197 ; length = 6 line = 6 ; column = 8 ; value ='float2'; }
|
||||||
|
{kind = TOKEN_DOUBLECOLON; ; index = 204 ; length = 2 line = 6 ; column = 15 ; value ='::'; }
|
||||||
|
{kind = TOKEN_LEFTPAREN; ; index = 207 ; length = 1 line = 6 ; column = 18 ; value ='('; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 208 ; length = 5 line = 6 ; column = 19 ; value ='float'; }
|
||||||
|
{kind = TOKEN_COMMA; ; index = 213 ; length = 1 line = 6 ; column = 24 ; value =','; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 215 ; length = 5 line = 6 ; column = 26 ; value ='float'; }
|
||||||
|
{kind = TOKEN_RIGHTPAREN; ; index = 220 ; length = 1 line = 6 ; column = 31 ; value =')'; }
|
||||||
|
{kind = TOKEN_ARROW; ; index = 222 ; length = 2 line = 6 ; column = 33 ; value ='->'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 225 ; length = 6 line = 6 ; column = 36 ; value ='float2'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 231 ; length = 1 line = 6 ; column = 42 ; value =';'; }
|
||||||
|
{kind = TOKEN_VERTEX; ; index = 236 ; length = 6 line = 8 ; column = 0 ; value ='vertex'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 243 ; length = 4 line = 8 ; column = 7 ; value ='main'; }
|
||||||
|
{kind = TOKEN_DOUBLECOLON; ; index = 248 ; length = 2 line = 8 ; column = 12 ; value ='::'; }
|
||||||
|
{kind = TOKEN_LEFTPAREN; ; index = 251 ; length = 1 line = 8 ; column = 15 ; value ='('; }
|
||||||
|
{kind = TOKEN_RIGHTPAREN; ; index = 252 ; length = 1 line = 8 ; column = 16 ; value =')'; }
|
||||||
|
{kind = TOKEN_LEFTBRACE; ; index = 254 ; length = 1 line = 8 ; column = 18 ; value ='{'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 258 ; length = 2 line = 9 ; column = 0 ; value ='v1'; }
|
||||||
|
{kind = TOKEN_COLON; ; index = 261 ; length = 1 line = 9 ; column = 3 ; value =':'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 263 ; length = 6 line = 9 ; column = 5 ; value ='float2'; }
|
||||||
|
{kind = TOKEN_ASSIGN; ; index = 270 ; length = 1 line = 9 ; column = 12 ; value ='='; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 272 ; length = 6 line = 9 ; column = 14 ; value ='float2'; }
|
||||||
|
{kind = TOKEN_LEFTPAREN; ; index = 278 ; length = 1 line = 9 ; column = 20 ; value ='('; }
|
||||||
|
{kind = TOKEN_FLOATLITERAL; ; index = 279 ; length = 3 line = 9 ; column = 21 ; value ='1'; }
|
||||||
|
{kind = TOKEN_COMMA; ; index = 282 ; length = 1 line = 9 ; column = 24 ; value =','; }
|
||||||
|
{kind = TOKEN_FLOATLITERAL; ; index = 284 ; length = 3 line = 9 ; column = 26 ; value ='1'; }
|
||||||
|
{kind = TOKEN_RIGHTPAREN; ; index = 287 ; length = 1 line = 9 ; column = 29 ; value =')'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 288 ; length = 1 line = 9 ; column = 30 ; value =';'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 292 ; length = 2 line = 10 ; column = 0 ; value ='v2'; }
|
||||||
|
{kind = TOKEN_COLON; ; index = 295 ; length = 1 line = 10 ; column = 3 ; value =':'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 297 ; length = 6 line = 10 ; column = 5 ; value ='float2'; }
|
||||||
|
{kind = TOKEN_ASSIGN; ; index = 304 ; length = 1 line = 10 ; column = 12 ; value ='='; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 306 ; length = 6 line = 10 ; column = 14 ; value ='float2'; }
|
||||||
|
{kind = TOKEN_LEFTPAREN; ; index = 312 ; length = 1 line = 10 ; column = 20 ; value ='('; }
|
||||||
|
{kind = TOKEN_FLOATLITERAL; ; index = 313 ; length = 3 line = 10 ; column = 21 ; value ='3'; }
|
||||||
|
{kind = TOKEN_COMMA; ; index = 316 ; length = 1 line = 10 ; column = 24 ; value =','; }
|
||||||
|
{kind = TOKEN_FLOATLITERAL; ; index = 318 ; length = 3 line = 10 ; column = 26 ; value ='3'; }
|
||||||
|
{kind = TOKEN_RIGHTPAREN; ; index = 321 ; length = 1 line = 10 ; column = 29 ; value =')'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 322 ; length = 1 line = 10 ; column = 30 ; value =';'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 328 ; length = 2 line = 12 ; column = 0 ; value ='v3'; }
|
||||||
|
{kind = TOKEN_COLON; ; index = 331 ; length = 1 line = 12 ; column = 3 ; value =':'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 333 ; length = 6 line = 12 ; column = 5 ; value ='float2'; }
|
||||||
|
{kind = TOKEN_ASSIGN; ; index = 340 ; length = 1 line = 12 ; column = 12 ; value ='='; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 342 ; length = 3 line = 12 ; column = 14 ; value ='mul'; }
|
||||||
|
{kind = TOKEN_LEFTPAREN; ; index = 345 ; length = 1 line = 12 ; column = 17 ; value ='('; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 346 ; length = 2 line = 12 ; column = 18 ; value ='v1'; }
|
||||||
|
{kind = TOKEN_COMMA; ; index = 348 ; length = 1 line = 12 ; column = 20 ; value =','; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 350 ; length = 2 line = 12 ; column = 22 ; value ='v2'; }
|
||||||
|
{kind = TOKEN_RIGHTPAREN; ; index = 352 ; length = 1 line = 12 ; column = 24 ; value =')'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 353 ; length = 1 line = 12 ; column = 25 ; value =';'; }
|
||||||
|
{kind = TOKEN_RIGHTBRACE; ; index = 356 ; length = 1 line = 13 ; column = 0 ; value ='}'; }
|
||||||
|
{kind = TOKEN_EOF; ; index = 359 ; length = 0 line = 14 ; column = 0 ; value =''; }
|
||||||
23
test/lex/function_call.golden
Normal file
23
test/lex/function_call.golden
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 0 ; length = 3 line = 1 ; column = 0 ; value ='foo'; }
|
||||||
|
{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 = 3 line = 1 ; column = 13 ; value ='int'; }
|
||||||
|
{kind = TOKEN_LEFTBRACE; ; index = 17 ; length = 1 line = 1 ; column = 17 ; value ='{'; }
|
||||||
|
{kind = TOKEN_RETURN; ; index = 21 ; length = 6 line = 2 ; column = 0 ; value ='return'; }
|
||||||
|
{kind = TOKEN_INTLITERAL; ; index = 28 ; length = 1 line = 2 ; column = 7 ; value ='4'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 29 ; length = 1 line = 2 ; column = 8 ; value =';'; }
|
||||||
|
{kind = TOKEN_RIGHTBRACE; ; index = 32 ; length = 1 line = 3 ; column = 0 ; value ='}'; }
|
||||||
|
{kind = TOKEN_VERTEX; ; index = 37 ; length = 6 line = 5 ; column = 0 ; value ='vertex'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 44 ; length = 4 line = 5 ; column = 7 ; value ='main'; }
|
||||||
|
{kind = TOKEN_DOUBLECOLON; ; index = 49 ; length = 2 line = 5 ; column = 12 ; value ='::'; }
|
||||||
|
{kind = TOKEN_LEFTPAREN; ; index = 52 ; length = 1 line = 5 ; column = 15 ; value ='('; }
|
||||||
|
{kind = TOKEN_RIGHTPAREN; ; index = 53 ; length = 1 line = 5 ; column = 16 ; value =')'; }
|
||||||
|
{kind = TOKEN_LEFTBRACE; ; index = 55 ; length = 1 line = 5 ; column = 18 ; value ='{'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 59 ; length = 3 line = 6 ; column = 0 ; value ='foo'; }
|
||||||
|
{kind = TOKEN_LEFTPAREN; ; index = 62 ; length = 1 line = 6 ; column = 3 ; value ='('; }
|
||||||
|
{kind = TOKEN_RIGHTPAREN; ; index = 63 ; length = 1 line = 6 ; column = 4 ; value =')'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 64 ; length = 1 line = 6 ; column = 5 ; value =';'; }
|
||||||
|
{kind = TOKEN_RIGHTBRACE; ; index = 67 ; length = 1 line = 7 ; column = 0 ; value ='}'; }
|
||||||
|
{kind = TOKEN_EOF; ; index = 70 ; length = 0 line = 8 ; column = 0 ; value =''; }
|
||||||
18
test/lex/function_call_out_of_order_declaration.golden
Normal file
18
test/lex/function_call_out_of_order_declaration.golden
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
{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 = 3 line = 2 ; column = 0 ; value ='foo'; }
|
||||||
|
{kind = TOKEN_LEFTPAREN; ; index = 25 ; length = 1 line = 2 ; column = 3 ; value ='('; }
|
||||||
|
{kind = TOKEN_RIGHTPAREN; ; index = 26 ; length = 1 line = 2 ; column = 4 ; value =')'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 27 ; length = 1 line = 2 ; column = 5 ; value =';'; }
|
||||||
|
{kind = TOKEN_RIGHTBRACE; ; index = 30 ; length = 1 line = 3 ; column = 0 ; value ='}'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 35 ; length = 3 line = 5 ; column = 0 ; value ='foo'; }
|
||||||
|
{kind = TOKEN_DOUBLECOLON; ; index = 39 ; length = 2 line = 5 ; column = 4 ; value ='::'; }
|
||||||
|
{kind = TOKEN_LEFTPAREN; ; index = 42 ; length = 1 line = 5 ; column = 7 ; value ='('; }
|
||||||
|
{kind = TOKEN_RIGHTPAREN; ; index = 43 ; length = 1 line = 5 ; column = 8 ; value =')'; }
|
||||||
|
{kind = TOKEN_LEFTBRACE; ; index = 45 ; length = 1 line = 5 ; column = 10 ; value ='{'; }
|
||||||
|
{kind = TOKEN_RIGHTBRACE; ; index = 50 ; length = 1 line = 7 ; column = 0 ; value ='}'; }
|
||||||
|
{kind = TOKEN_EOF; ; index = 53 ; length = 0 line = 8 ; column = 0 ; value =''; }
|
||||||
31
test/lex/function_call_return.golden
Normal file
31
test/lex/function_call_return.golden
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
{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_RIGHTBRACE; ; index = 23 ; length = 1 line = 3 ; column = 0 ; value ='}'; }
|
||||||
|
{kind = TOKEN_PIXEL; ; index = 28 ; length = 5 line = 5 ; column = 0 ; value ='pixel'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 34 ; length = 4 line = 5 ; column = 6 ; value ='main'; }
|
||||||
|
{kind = TOKEN_DOUBLECOLON; ; index = 39 ; length = 2 line = 5 ; column = 11 ; value ='::'; }
|
||||||
|
{kind = TOKEN_LEFTPAREN; ; index = 42 ; length = 1 line = 5 ; column = 14 ; value ='('; }
|
||||||
|
{kind = TOKEN_RIGHTPAREN; ; index = 43 ; length = 1 line = 5 ; column = 15 ; value =')'; }
|
||||||
|
{kind = TOKEN_ARROW; ; index = 45 ; length = 2 line = 5 ; column = 17 ; value ='->'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 48 ; length = 6 line = 5 ; column = 20 ; value ='float4'; }
|
||||||
|
{kind = TOKEN_AT; ; index = 55 ; length = 1 line = 5 ; column = 27 ; value ='@'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 56 ; length = 7 line = 5 ; column = 28 ; value ='target0'; }
|
||||||
|
{kind = TOKEN_LEFTBRACE; ; index = 64 ; length = 1 line = 5 ; column = 36 ; value ='{'; }
|
||||||
|
{kind = TOKEN_RETURN; ; index = 68 ; length = 6 line = 6 ; column = 0 ; value ='return'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 75 ; length = 6 line = 6 ; column = 7 ; value ='float4'; }
|
||||||
|
{kind = TOKEN_LEFTPAREN; ; index = 81 ; length = 1 line = 6 ; column = 13 ; value ='('; }
|
||||||
|
{kind = TOKEN_INTLITERAL; ; index = 82 ; length = 1 line = 6 ; column = 14 ; value ='1'; }
|
||||||
|
{kind = TOKEN_COMMA; ; index = 83 ; length = 1 line = 6 ; column = 15 ; value =','; }
|
||||||
|
{kind = TOKEN_INTLITERAL; ; index = 85 ; length = 1 line = 6 ; column = 17 ; value ='1'; }
|
||||||
|
{kind = TOKEN_COMMA; ; index = 86 ; length = 1 line = 6 ; column = 18 ; value =','; }
|
||||||
|
{kind = TOKEN_INTLITERAL; ; index = 88 ; length = 1 line = 6 ; column = 20 ; value ='1'; }
|
||||||
|
{kind = TOKEN_COMMA; ; index = 89 ; length = 1 line = 6 ; column = 21 ; value =','; }
|
||||||
|
{kind = TOKEN_INTLITERAL; ; index = 91 ; length = 1 line = 6 ; column = 23 ; value ='1'; }
|
||||||
|
{kind = TOKEN_RIGHTPAREN; ; index = 92 ; length = 1 line = 6 ; column = 24 ; value =')'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 93 ; length = 1 line = 6 ; column = 25 ; value =';'; }
|
||||||
|
{kind = TOKEN_RIGHTBRACE; ; index = 96 ; length = 1 line = 7 ; column = 0 ; value ='}'; }
|
||||||
|
{kind = TOKEN_EOF; ; index = 99 ; length = 0 line = 8 ; column = 0 ; value =''; }
|
||||||
13
test/lex/function_with_int_return.golden
Normal file
13
test/lex/function_with_int_return.golden
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
{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_RIGHTPAREN; ; index = 28 ; length = 1 line = 1 ; column = 28 ; value =')'; }
|
||||||
|
{kind = TOKEN_ARROW; ; index = 30 ; length = 2 line = 1 ; column = 30 ; value ='->'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 33 ; length = 3 line = 1 ; column = 33 ; value ='int'; }
|
||||||
|
{kind = TOKEN_LEFTBRACE; ; index = 37 ; length = 1 line = 1 ; column = 37 ; value ='{'; }
|
||||||
|
{kind = TOKEN_RIGHTBRACE; ; index = 43 ; length = 1 line = 3 ; column = 0 ; value ='}'; }
|
||||||
|
{kind = TOKEN_EOF; ; index = 46 ; length = 0 line = 4 ; column = 0 ; value =''; }
|
||||||
26
test/lex/functions_with_same_name.golden
Normal file
26
test/lex/functions_with_same_name.golden
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 0 ; length = 3 line = 1 ; column = 0 ; value ='foo'; }
|
||||||
|
{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_LEFTBRACE; ; index = 10 ; length = 1 line = 1 ; column = 10 ; value ='{'; }
|
||||||
|
{kind = TOKEN_RIGHTBRACE; ; index = 11 ; length = 1 line = 1 ; column = 11 ; value ='}'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 14 ; length = 3 line = 2 ; column = 0 ; value ='foo'; }
|
||||||
|
{kind = TOKEN_DOUBLECOLON; ; index = 18 ; length = 2 line = 2 ; column = 4 ; value ='::'; }
|
||||||
|
{kind = TOKEN_LEFTPAREN; ; index = 21 ; length = 1 line = 2 ; column = 7 ; value ='('; }
|
||||||
|
{kind = TOKEN_RIGHTPAREN; ; index = 22 ; length = 1 line = 2 ; column = 8 ; value =')'; }
|
||||||
|
{kind = TOKEN_LEFTBRACE; ; index = 24 ; length = 1 line = 2 ; column = 10 ; value ='{'; }
|
||||||
|
{kind = TOKEN_RIGHTBRACE; ; index = 25 ; length = 1 line = 2 ; column = 11 ; value ='}'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 28 ; length = 3 line = 3 ; column = 0 ; value ='bar'; }
|
||||||
|
{kind = TOKEN_DOUBLECOLON; ; index = 32 ; length = 2 line = 3 ; column = 4 ; value ='::'; }
|
||||||
|
{kind = TOKEN_LEFTPAREN; ; index = 35 ; length = 1 line = 3 ; column = 7 ; value ='('; }
|
||||||
|
{kind = TOKEN_RIGHTPAREN; ; index = 36 ; length = 1 line = 3 ; column = 8 ; value =')'; }
|
||||||
|
{kind = TOKEN_LEFTBRACE; ; index = 38 ; length = 1 line = 3 ; column = 10 ; value ='{'; }
|
||||||
|
{kind = TOKEN_RIGHTBRACE; ; index = 39 ; length = 1 line = 3 ; column = 11 ; value ='}'; }
|
||||||
|
{kind = TOKEN_VERTEX; ; index = 44 ; length = 6 line = 5 ; column = 0 ; value ='vertex'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 51 ; length = 4 line = 5 ; column = 7 ; value ='main'; }
|
||||||
|
{kind = TOKEN_DOUBLECOLON; ; index = 56 ; length = 2 line = 5 ; column = 12 ; value ='::'; }
|
||||||
|
{kind = TOKEN_LEFTPAREN; ; index = 59 ; length = 1 line = 5 ; column = 15 ; value ='('; }
|
||||||
|
{kind = TOKEN_RIGHTPAREN; ; index = 60 ; length = 1 line = 5 ; column = 16 ; value =')'; }
|
||||||
|
{kind = TOKEN_LEFTBRACE; ; index = 62 ; length = 1 line = 5 ; column = 18 ; value ='{'; }
|
||||||
|
{kind = TOKEN_RIGHTBRACE; ; index = 67 ; length = 1 line = 7 ; column = 0 ; value ='}'; }
|
||||||
|
{kind = TOKEN_EOF; ; index = 70 ; length = 0 line = 8 ; column = 0 ; value =''; }
|
||||||
60
test/lex/meta_block.golden
Normal file
60
test/lex/meta_block.golden
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
{kind = TOKEN_META; ; index = 0 ; length = 4 line = 1 ; column = 0 ; value ='meta'; }
|
||||||
|
{kind = TOKEN_LEFTBRACE; ; index = 5 ; length = 1 line = 1 ; column = 5 ; value ='{'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 9 ; length = 4 line = 2 ; column = 0 ; value ='name'; }
|
||||||
|
{kind = TOKEN_COLON; ; index = 18 ; length = 1 line = 2 ; column = 9 ; value =':'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 20 ; length = 8 line = 2 ; column = 11 ; value ='LitBasic'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 28 ; length = 1 line = 2 ; column = 19 ; value =';'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 32 ; length = 8 line = 3 ; column = 0 ; value ='category'; }
|
||||||
|
{kind = TOKEN_COLON; ; index = 41 ; length = 1 line = 3 ; column = 9 ; value =':'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 43 ; length = 5 line = 3 ; column = 11 ; value ='Scene'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 48 ; length = 1 line = 3 ; column = 16 ; value =';'; }
|
||||||
|
{kind = TOKEN_RIGHTBRACE; ; index = 51 ; length = 1 line = 4 ; column = 0 ; value ='}'; }
|
||||||
|
{kind = TOKEN_PROPERTIES; ; index = 56 ; length = 10 line = 6 ; column = 0 ; value ='properties'; }
|
||||||
|
{kind = TOKEN_LEFTBRACE; ; index = 67 ; length = 1 line = 6 ; column = 11 ; value ='{'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 71 ; length = 5 line = 7 ; column = 0 ; value ='color'; }
|
||||||
|
{kind = TOKEN_COLON; ; index = 77 ; length = 1 line = 7 ; column = 6 ; value =':'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 79 ; length = 6 line = 7 ; column = 8 ; value ='float4'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 85 ; length = 1 line = 7 ; column = 14 ; value =';'; }
|
||||||
|
{kind = TOKEN_RIGHTBRACE; ; index = 88 ; length = 1 line = 8 ; column = 0 ; value ='}'; }
|
||||||
|
{kind = TOKEN_VERTEX; ; index = 93 ; length = 6 line = 10 ; column = 0 ; value ='vertex'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 100 ; length = 4 line = 10 ; column = 7 ; value ='main'; }
|
||||||
|
{kind = TOKEN_DOUBLECOLON; ; index = 105 ; length = 2 line = 10 ; column = 12 ; value ='::'; }
|
||||||
|
{kind = TOKEN_LEFTPAREN; ; index = 108 ; length = 1 line = 10 ; column = 15 ; value ='('; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 109 ; length = 3 line = 10 ; column = 16 ; value ='pos'; }
|
||||||
|
{kind = TOKEN_COLON; ; index = 113 ; length = 1 line = 10 ; column = 20 ; value =':'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 115 ; length = 6 line = 10 ; column = 22 ; value ='float3'; }
|
||||||
|
{kind = TOKEN_AT; ; index = 122 ; length = 1 line = 10 ; column = 29 ; value ='@'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 123 ; length = 8 line = 10 ; column = 30 ; value ='position'; }
|
||||||
|
{kind = TOKEN_COMMA; ; index = 131 ; length = 1 line = 10 ; column = 38 ; value =','; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 133 ; length = 2 line = 10 ; column = 40 ; value ='uv'; }
|
||||||
|
{kind = TOKEN_COLON; ; index = 136 ; length = 1 line = 10 ; column = 43 ; value =':'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 138 ; length = 6 line = 10 ; column = 45 ; value ='float2'; }
|
||||||
|
{kind = TOKEN_AT; ; index = 145 ; length = 1 line = 10 ; column = 52 ; value ='@'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 146 ; length = 2 line = 10 ; column = 53 ; value ='uv'; }
|
||||||
|
{kind = TOKEN_RIGHTPAREN; ; index = 148 ; length = 1 line = 10 ; column = 55 ; value =')'; }
|
||||||
|
{kind = TOKEN_ARROW; ; index = 150 ; length = 2 line = 10 ; column = 57 ; value ='->'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 153 ; length = 6 line = 10 ; column = 60 ; value ='float3'; }
|
||||||
|
{kind = TOKEN_AT; ; index = 160 ; length = 1 line = 10 ; column = 67 ; value ='@'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 161 ; length = 8 line = 10 ; column = 68 ; value ='position'; }
|
||||||
|
{kind = TOKEN_LEFTBRACE; ; index = 170 ; length = 1 line = 10 ; column = 77 ; value ='{'; }
|
||||||
|
{kind = TOKEN_RETURN; ; index = 174 ; length = 6 line = 11 ; column = 0 ; value ='return'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 181 ; length = 3 line = 11 ; column = 7 ; value ='pos'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 184 ; length = 1 line = 11 ; column = 10 ; value =';'; }
|
||||||
|
{kind = TOKEN_RIGHTBRACE; ; index = 187 ; length = 1 line = 12 ; column = 0 ; value ='}'; }
|
||||||
|
{kind = TOKEN_PIXEL; ; index = 192 ; length = 5 line = 14 ; column = 0 ; value ='pixel'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 198 ; length = 4 line = 14 ; column = 6 ; value ='main'; }
|
||||||
|
{kind = TOKEN_DOUBLECOLON; ; index = 203 ; length = 2 line = 14 ; column = 11 ; value ='::'; }
|
||||||
|
{kind = TOKEN_LEFTPAREN; ; index = 206 ; length = 1 line = 14 ; column = 14 ; value ='('; }
|
||||||
|
{kind = TOKEN_RIGHTPAREN; ; index = 207 ; length = 1 line = 14 ; column = 15 ; value =')'; }
|
||||||
|
{kind = TOKEN_ARROW; ; index = 209 ; length = 2 line = 14 ; column = 17 ; value ='->'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 212 ; length = 6 line = 14 ; column = 20 ; value ='float4'; }
|
||||||
|
{kind = TOKEN_AT; ; index = 219 ; length = 1 line = 14 ; column = 27 ; value ='@'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 220 ; length = 7 line = 14 ; column = 28 ; value ='target0'; }
|
||||||
|
{kind = TOKEN_LEFTBRACE; ; index = 228 ; length = 1 line = 14 ; column = 36 ; value ='{'; }
|
||||||
|
{kind = TOKEN_RETURN; ; index = 232 ; length = 6 line = 15 ; column = 0 ; value ='return'; }
|
||||||
|
{kind = TOKEN_PROPERTIES; ; index = 239 ; length = 10 line = 15 ; column = 7 ; value ='properties'; }
|
||||||
|
{kind = TOKEN_DOT; ; index = 249 ; length = 1 line = 15 ; column = 17 ; value ='.'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 250 ; length = 5 line = 15 ; column = 18 ; value ='color'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 255 ; length = 1 line = 15 ; column = 23 ; value =';'; }
|
||||||
|
{kind = TOKEN_RIGHTBRACE; ; index = 258 ; length = 1 line = 16 ; column = 0 ; value ='}'; }
|
||||||
|
{kind = TOKEN_EOF; ; index = 261 ; length = 0 line = 17 ; column = 0 ; value =''; }
|
||||||
48
test/lex/multiple_functions.golden
Normal file
48
test/lex/multiple_functions.golden
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 0 ; length = 3 line = 1 ; column = 0 ; value ='foo'; }
|
||||||
|
{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 = 3 line = 1 ; column = 13 ; value ='int'; }
|
||||||
|
{kind = TOKEN_LEFTBRACE; ; index = 17 ; length = 1 line = 1 ; column = 17 ; value ='{'; }
|
||||||
|
{kind = TOKEN_RETURN; ; index = 21 ; length = 6 line = 2 ; column = 0 ; value ='return'; }
|
||||||
|
{kind = TOKEN_INTLITERAL; ; index = 28 ; length = 1 line = 2 ; column = 7 ; value ='5'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 29 ; length = 1 line = 2 ; column = 8 ; value =';'; }
|
||||||
|
{kind = TOKEN_RIGHTBRACE; ; index = 32 ; length = 1 line = 3 ; column = 0 ; value ='}'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 37 ; length = 3 line = 5 ; column = 0 ; value ='bar'; }
|
||||||
|
{kind = TOKEN_DOUBLECOLON; ; index = 41 ; length = 2 line = 5 ; column = 4 ; value ='::'; }
|
||||||
|
{kind = TOKEN_LEFTPAREN; ; index = 44 ; length = 1 line = 5 ; column = 7 ; value ='('; }
|
||||||
|
{kind = TOKEN_RIGHTPAREN; ; index = 45 ; length = 1 line = 5 ; column = 8 ; value =')'; }
|
||||||
|
{kind = TOKEN_ARROW; ; index = 47 ; length = 2 line = 5 ; column = 10 ; value ='->'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 50 ; length = 5 line = 5 ; column = 13 ; value ='float'; }
|
||||||
|
{kind = TOKEN_LEFTBRACE; ; index = 56 ; length = 1 line = 5 ; column = 19 ; value ='{'; }
|
||||||
|
{kind = TOKEN_RETURN; ; index = 60 ; length = 6 line = 6 ; column = 0 ; value ='return'; }
|
||||||
|
{kind = TOKEN_FLOATLITERAL; ; index = 67 ; length = 6 line = 6 ; column = 7 ; value ='1235'; }
|
||||||
|
{kind = TOKEN_STAR; ; index = 74 ; length = 1 line = 6 ; column = 14 ; value ='*'; }
|
||||||
|
{kind = TOKEN_INTLITERAL; ; index = 76 ; length = 3 line = 6 ; column = 16 ; value ='500'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 79 ; length = 1 line = 6 ; column = 19 ; value =';'; }
|
||||||
|
{kind = TOKEN_RIGHTBRACE; ; index = 82 ; length = 1 line = 7 ; column = 0 ; value ='}'; }
|
||||||
|
{kind = TOKEN_VERTEX; ; index = 87 ; length = 6 line = 9 ; column = 0 ; value ='vertex'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 94 ; length = 4 line = 9 ; column = 7 ; value ='main'; }
|
||||||
|
{kind = TOKEN_DOUBLECOLON; ; index = 99 ; length = 2 line = 9 ; column = 12 ; value ='::'; }
|
||||||
|
{kind = TOKEN_LEFTPAREN; ; index = 102 ; length = 1 line = 9 ; column = 15 ; value ='('; }
|
||||||
|
{kind = TOKEN_RIGHTPAREN; ; index = 103 ; length = 1 line = 9 ; column = 16 ; value =')'; }
|
||||||
|
{kind = TOKEN_LEFTBRACE; ; index = 105 ; length = 1 line = 9 ; column = 18 ; value ='{'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 109 ; length = 1 line = 10 ; column = 0 ; value ='x'; }
|
||||||
|
{kind = TOKEN_COLON; ; index = 111 ; length = 1 line = 10 ; column = 2 ; value =':'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 113 ; length = 3 line = 10 ; column = 4 ; value ='int'; }
|
||||||
|
{kind = TOKEN_ASSIGN; ; index = 117 ; length = 1 line = 10 ; column = 8 ; value ='='; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 119 ; length = 3 line = 10 ; column = 10 ; value ='foo'; }
|
||||||
|
{kind = TOKEN_LEFTPAREN; ; index = 122 ; length = 1 line = 10 ; column = 13 ; value ='('; }
|
||||||
|
{kind = TOKEN_RIGHTPAREN; ; index = 123 ; length = 1 line = 10 ; column = 14 ; value =')'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 124 ; length = 1 line = 10 ; column = 15 ; value =';'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 128 ; length = 1 line = 11 ; column = 0 ; value ='y'; }
|
||||||
|
{kind = TOKEN_COLON; ; index = 130 ; length = 1 line = 11 ; column = 2 ; value =':'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 132 ; length = 5 line = 11 ; column = 4 ; value ='float'; }
|
||||||
|
{kind = TOKEN_ASSIGN; ; index = 138 ; length = 1 line = 11 ; column = 10 ; value ='='; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 140 ; length = 3 line = 11 ; column = 12 ; value ='bar'; }
|
||||||
|
{kind = TOKEN_LEFTPAREN; ; index = 143 ; length = 1 line = 11 ; column = 15 ; value ='('; }
|
||||||
|
{kind = TOKEN_RIGHTPAREN; ; index = 144 ; length = 1 line = 11 ; column = 16 ; value =')'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 145 ; length = 1 line = 11 ; column = 17 ; value =';'; }
|
||||||
|
{kind = TOKEN_RIGHTBRACE; ; index = 148 ; length = 1 line = 12 ; column = 0 ; value ='}'; }
|
||||||
|
{kind = TOKEN_EOF; ; index = 151 ; length = 0 line = 13 ; column = 0 ; value =''; }
|
||||||
77
test/lex/multiple_semicolons_everywhere.golden
Normal file
77
test/lex/multiple_semicolons_everywhere.golden
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
{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 ='float3'; }
|
||||||
|
{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_RETURN; ; index = 64 ; length = 6 line = 2 ; column = 0 ; value ='return'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 71 ; length = 3 line = 2 ; column = 7 ; value ='pos'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 74 ; length = 1 line = 2 ; column = 10 ; value =';'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 75 ; length = 1 line = 2 ; column = 11 ; value =';'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 76 ; length = 1 line = 2 ; column = 12 ; value =';'; }
|
||||||
|
{kind = TOKEN_RIGHTBRACE; ; index = 79 ; length = 1 line = 3 ; column = 0 ; value ='}'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 84 ; length = 3 line = 5 ; column = 0 ; value ='foo'; }
|
||||||
|
{kind = TOKEN_DOUBLECOLON; ; index = 88 ; length = 2 line = 5 ; column = 4 ; value ='::'; }
|
||||||
|
{kind = TOKEN_LEFTPAREN; ; index = 91 ; length = 1 line = 5 ; column = 7 ; value ='('; }
|
||||||
|
{kind = TOKEN_RIGHTPAREN; ; index = 92 ; length = 1 line = 5 ; column = 8 ; value =')'; }
|
||||||
|
{kind = TOKEN_ARROW; ; index = 94 ; length = 2 line = 5 ; column = 10 ; value ='->'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 97 ; length = 6 line = 5 ; column = 13 ; value ='float4'; }
|
||||||
|
{kind = TOKEN_LEFTBRACE; ; index = 104 ; length = 1 line = 5 ; column = 20 ; value ='{'; }
|
||||||
|
{kind = TOKEN_RETURN; ; index = 108 ; length = 6 line = 6 ; column = 0 ; value ='return'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 115 ; length = 6 line = 6 ; column = 7 ; value ='float4'; }
|
||||||
|
{kind = TOKEN_LEFTPAREN; ; index = 121 ; length = 1 line = 6 ; column = 13 ; value ='('; }
|
||||||
|
{kind = TOKEN_FLOATLITERAL; ; index = 122 ; length = 3 line = 6 ; column = 14 ; value ='1'; }
|
||||||
|
{kind = TOKEN_COMMA; ; index = 125 ; length = 1 line = 6 ; column = 17 ; value =','; }
|
||||||
|
{kind = TOKEN_FLOATLITERAL; ; index = 127 ; length = 3 line = 6 ; column = 19 ; value ='1'; }
|
||||||
|
{kind = TOKEN_COMMA; ; index = 130 ; length = 1 line = 6 ; column = 22 ; value =','; }
|
||||||
|
{kind = TOKEN_FLOATLITERAL; ; index = 132 ; length = 3 line = 6 ; column = 24 ; value ='1'; }
|
||||||
|
{kind = TOKEN_COMMA; ; index = 135 ; length = 1 line = 6 ; column = 27 ; value =','; }
|
||||||
|
{kind = TOKEN_FLOATLITERAL; ; index = 137 ; length = 3 line = 6 ; column = 29 ; value ='1'; }
|
||||||
|
{kind = TOKEN_RIGHTPAREN; ; index = 140 ; length = 1 line = 6 ; column = 32 ; value =')'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 141 ; length = 1 line = 6 ; column = 33 ; value =';'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 142 ; length = 1 line = 6 ; column = 34 ; value =';'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 143 ; length = 1 line = 6 ; column = 35 ; value =';'; }
|
||||||
|
{kind = TOKEN_RIGHTBRACE; ; index = 146 ; length = 1 line = 7 ; column = 0 ; value ='}'; }
|
||||||
|
{kind = TOKEN_PIXEL; ; index = 151 ; length = 5 line = 9 ; column = 0 ; value ='pixel'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 157 ; length = 4 line = 9 ; column = 6 ; value ='main'; }
|
||||||
|
{kind = TOKEN_DOUBLECOLON; ; index = 162 ; length = 2 line = 9 ; column = 11 ; value ='::'; }
|
||||||
|
{kind = TOKEN_LEFTPAREN; ; index = 165 ; length = 1 line = 9 ; column = 14 ; value ='('; }
|
||||||
|
{kind = TOKEN_RIGHTPAREN; ; index = 166 ; length = 1 line = 9 ; column = 15 ; value =')'; }
|
||||||
|
{kind = TOKEN_ARROW; ; index = 168 ; length = 2 line = 9 ; column = 17 ; value ='->'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 171 ; length = 6 line = 9 ; column = 20 ; value ='float4'; }
|
||||||
|
{kind = TOKEN_AT; ; index = 178 ; length = 1 line = 9 ; column = 27 ; value ='@'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 179 ; length = 7 line = 9 ; column = 28 ; value ='target0'; }
|
||||||
|
{kind = TOKEN_LEFTBRACE; ; index = 187 ; length = 1 line = 9 ; column = 36 ; value ='{'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 191 ; length = 1 line = 10 ; column = 0 ; value ='y'; }
|
||||||
|
{kind = TOKEN_COLON; ; index = 193 ; length = 1 line = 10 ; column = 2 ; value =':'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 195 ; length = 6 line = 10 ; column = 4 ; value ='float4'; }
|
||||||
|
{kind = TOKEN_ASSIGN; ; index = 202 ; length = 1 line = 10 ; column = 11 ; value ='='; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 204 ; length = 3 line = 10 ; column = 13 ; value ='foo'; }
|
||||||
|
{kind = TOKEN_LEFTPAREN; ; index = 207 ; length = 1 line = 10 ; column = 16 ; value ='('; }
|
||||||
|
{kind = TOKEN_RIGHTPAREN; ; index = 208 ; length = 1 line = 10 ; column = 17 ; value =')'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 209 ; length = 1 line = 10 ; column = 18 ; value =';'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 210 ; length = 1 line = 10 ; column = 19 ; value =';'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 211 ; length = 1 line = 10 ; column = 20 ; value =';'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 212 ; length = 1 line = 10 ; column = 21 ; value =';'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 216 ; length = 1 line = 11 ; column = 0 ; value =';'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 217 ; length = 1 line = 11 ; column = 1 ; value =';'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 221 ; length = 5 line = 12 ; column = 0 ; value ='color'; }
|
||||||
|
{kind = TOKEN_COLON; ; index = 227 ; length = 1 line = 12 ; column = 6 ; value =':'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 229 ; length = 6 line = 12 ; column = 8 ; value ='float4'; }
|
||||||
|
{kind = TOKEN_ASSIGN; ; index = 236 ; length = 1 line = 12 ; column = 15 ; value ='='; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 238 ; length = 1 line = 12 ; column = 17 ; value ='y'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 239 ; length = 1 line = 12 ; column = 18 ; value =';'; }
|
||||||
|
{kind = TOKEN_RETURN; ; index = 243 ; length = 6 line = 13 ; column = 0 ; value ='return'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 250 ; length = 5 line = 13 ; column = 7 ; value ='color'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 255 ; length = 1 line = 13 ; column = 12 ; value =';'; }
|
||||||
|
{kind = TOKEN_RIGHTBRACE; ; index = 258 ; length = 1 line = 14 ; column = 0 ; value ='}'; }
|
||||||
|
{kind = TOKEN_EOF; ; index = 261 ; length = 0 line = 15 ; column = 0 ; value =''; }
|
||||||
54
test/lex/pass_and_access_struct_fields_in_functions.golden
Normal file
54
test/lex/pass_and_access_struct_fields_in_functions.golden
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 0 ; length = 3 line = 1 ; column = 0 ; value ='Foo'; }
|
||||||
|
{kind = TOKEN_DOUBLECOLON; ; index = 4 ; length = 2 line = 1 ; column = 4 ; value ='::'; }
|
||||||
|
{kind = TOKEN_STRUCT; ; index = 7 ; length = 6 line = 1 ; column = 7 ; value ='struct'; }
|
||||||
|
{kind = TOKEN_LEFTBRACE; ; index = 14 ; length = 1 line = 1 ; column = 14 ; value ='{'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 18 ; length = 9 line = 2 ; column = 0 ; value ='some_data'; }
|
||||||
|
{kind = TOKEN_COLON; ; index = 28 ; length = 1 line = 2 ; column = 10 ; value =':'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 30 ; length = 5 line = 2 ; column = 12 ; value ='float'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 35 ; length = 1 line = 2 ; column = 17 ; value =';'; }
|
||||||
|
{kind = TOKEN_RIGHTBRACE; ; index = 38 ; length = 1 line = 3 ; column = 0 ; value ='}'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 43 ; length = 3 line = 5 ; column = 0 ; value ='foo'; }
|
||||||
|
{kind = TOKEN_DOUBLECOLON; ; index = 47 ; length = 2 line = 5 ; column = 4 ; value ='::'; }
|
||||||
|
{kind = TOKEN_LEFTPAREN; ; index = 50 ; length = 1 line = 5 ; column = 7 ; value ='('; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 51 ; length = 1 line = 5 ; column = 8 ; value ='f'; }
|
||||||
|
{kind = TOKEN_COLON; ; index = 53 ; length = 1 line = 5 ; column = 10 ; value =':'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 55 ; length = 3 line = 5 ; column = 12 ; value ='Foo'; }
|
||||||
|
{kind = TOKEN_RIGHTPAREN; ; index = 58 ; length = 1 line = 5 ; column = 15 ; value =')'; }
|
||||||
|
{kind = TOKEN_ARROW; ; index = 60 ; length = 2 line = 5 ; column = 17 ; value ='->'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 63 ; length = 5 line = 5 ; column = 20 ; value ='float'; }
|
||||||
|
{kind = TOKEN_LEFTBRACE; ; index = 69 ; length = 1 line = 5 ; column = 26 ; value ='{'; }
|
||||||
|
{kind = TOKEN_RETURN; ; index = 73 ; length = 6 line = 6 ; column = 0 ; value ='return'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 80 ; length = 1 line = 6 ; column = 7 ; value ='f'; }
|
||||||
|
{kind = TOKEN_DOT; ; index = 81 ; length = 1 line = 6 ; column = 8 ; value ='.'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 82 ; length = 9 line = 6 ; column = 9 ; value ='some_data'; }
|
||||||
|
{kind = TOKEN_STAR; ; index = 92 ; length = 1 line = 6 ; column = 19 ; value ='*'; }
|
||||||
|
{kind = TOKEN_FLOATLITERAL; ; index = 94 ; length = 3 line = 6 ; column = 21 ; value ='2'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 97 ; length = 1 line = 6 ; column = 24 ; value =';'; }
|
||||||
|
{kind = TOKEN_RIGHTBRACE; ; index = 100 ; length = 1 line = 7 ; column = 0 ; value ='}'; }
|
||||||
|
{kind = TOKEN_VERTEX; ; index = 105 ; length = 6 line = 9 ; column = 0 ; value ='vertex'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 112 ; length = 4 line = 9 ; column = 7 ; value ='main'; }
|
||||||
|
{kind = TOKEN_DOUBLECOLON; ; index = 117 ; length = 2 line = 9 ; column = 12 ; value ='::'; }
|
||||||
|
{kind = TOKEN_LEFTPAREN; ; index = 120 ; length = 1 line = 9 ; column = 15 ; value ='('; }
|
||||||
|
{kind = TOKEN_RIGHTPAREN; ; index = 121 ; length = 1 line = 9 ; column = 16 ; value =')'; }
|
||||||
|
{kind = TOKEN_LEFTBRACE; ; index = 123 ; length = 1 line = 9 ; column = 18 ; value ='{'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 127 ; length = 1 line = 10 ; column = 0 ; value ='f'; }
|
||||||
|
{kind = TOKEN_COLON; ; index = 129 ; length = 1 line = 10 ; column = 2 ; value =':'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 131 ; length = 3 line = 10 ; column = 4 ; value ='Foo'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 134 ; length = 1 line = 10 ; column = 7 ; value =';'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 138 ; length = 1 line = 11 ; column = 0 ; value ='f'; }
|
||||||
|
{kind = TOKEN_DOT; ; index = 139 ; length = 1 line = 11 ; column = 1 ; value ='.'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 140 ; length = 9 line = 11 ; column = 2 ; value ='some_data'; }
|
||||||
|
{kind = TOKEN_ASSIGN; ; index = 150 ; length = 1 line = 11 ; column = 12 ; value ='='; }
|
||||||
|
{kind = TOKEN_FLOATLITERAL; ; index = 152 ; length = 3 line = 11 ; column = 14 ; value ='4'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 155 ; length = 1 line = 11 ; column = 17 ; value =';'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 159 ; length = 1 line = 12 ; column = 0 ; value ='d'; }
|
||||||
|
{kind = TOKEN_COLON; ; index = 161 ; length = 1 line = 12 ; column = 2 ; value =':'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 163 ; length = 5 line = 12 ; column = 4 ; value ='float'; }
|
||||||
|
{kind = TOKEN_ASSIGN; ; index = 169 ; length = 1 line = 12 ; column = 10 ; value ='='; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 171 ; length = 3 line = 12 ; column = 12 ; value ='foo'; }
|
||||||
|
{kind = TOKEN_LEFTPAREN; ; index = 174 ; length = 1 line = 12 ; column = 15 ; value ='('; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 175 ; length = 1 line = 12 ; column = 16 ; value ='f'; }
|
||||||
|
{kind = TOKEN_RIGHTPAREN; ; index = 176 ; length = 1 line = 12 ; column = 17 ; value =')'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 177 ; length = 1 line = 12 ; column = 18 ; value =';'; }
|
||||||
|
{kind = TOKEN_RIGHTBRACE; ; index = 180 ; length = 1 line = 13 ; column = 0 ; value ='}'; }
|
||||||
|
{kind = TOKEN_EOF; ; index = 183 ; length = 0 line = 14 ; column = 0 ; value =''; }
|
||||||
43
test/lex/passthrough.golden
Normal file
43
test/lex/passthrough.golden
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
{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 ='float3'; }
|
||||||
|
{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_RETURN; ; index = 64 ; length = 6 line = 2 ; column = 0 ; value ='return'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 71 ; length = 3 line = 2 ; column = 7 ; value ='pos'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 74 ; length = 1 line = 2 ; column = 10 ; value =';'; }
|
||||||
|
{kind = TOKEN_RIGHTBRACE; ; index = 77 ; length = 1 line = 3 ; column = 0 ; value ='}'; }
|
||||||
|
{kind = TOKEN_PIXEL; ; index = 82 ; length = 5 line = 5 ; column = 0 ; value ='pixel'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 88 ; length = 4 line = 5 ; column = 6 ; value ='main'; }
|
||||||
|
{kind = TOKEN_DOUBLECOLON; ; index = 93 ; length = 2 line = 5 ; column = 11 ; value ='::'; }
|
||||||
|
{kind = TOKEN_LEFTPAREN; ; index = 96 ; length = 1 line = 5 ; column = 14 ; value ='('; }
|
||||||
|
{kind = TOKEN_RIGHTPAREN; ; index = 97 ; length = 1 line = 5 ; column = 15 ; value =')'; }
|
||||||
|
{kind = TOKEN_ARROW; ; index = 99 ; length = 2 line = 5 ; column = 17 ; value ='->'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 102 ; length = 6 line = 5 ; column = 20 ; value ='float4'; }
|
||||||
|
{kind = TOKEN_AT; ; index = 109 ; length = 1 line = 5 ; column = 27 ; value ='@'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 110 ; length = 7 line = 5 ; column = 28 ; value ='target0'; }
|
||||||
|
{kind = TOKEN_LEFTBRACE; ; index = 118 ; length = 1 line = 5 ; column = 36 ; value ='{'; }
|
||||||
|
{kind = TOKEN_RETURN; ; index = 122 ; length = 6 line = 6 ; column = 0 ; value ='return'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 129 ; length = 6 line = 6 ; column = 7 ; value ='float4'; }
|
||||||
|
{kind = TOKEN_LEFTPAREN; ; index = 135 ; length = 1 line = 6 ; column = 13 ; value ='('; }
|
||||||
|
{kind = TOKEN_FLOATLITERAL; ; index = 136 ; length = 3 line = 6 ; column = 14 ; value ='1'; }
|
||||||
|
{kind = TOKEN_COMMA; ; index = 139 ; length = 1 line = 6 ; column = 17 ; value =','; }
|
||||||
|
{kind = TOKEN_FLOATLITERAL; ; index = 141 ; length = 3 line = 6 ; column = 19 ; value ='1'; }
|
||||||
|
{kind = TOKEN_COMMA; ; index = 144 ; length = 1 line = 6 ; column = 22 ; value =','; }
|
||||||
|
{kind = TOKEN_FLOATLITERAL; ; index = 146 ; length = 3 line = 6 ; column = 24 ; value ='1'; }
|
||||||
|
{kind = TOKEN_COMMA; ; index = 149 ; length = 1 line = 6 ; column = 27 ; value =','; }
|
||||||
|
{kind = TOKEN_FLOATLITERAL; ; index = 151 ; length = 3 line = 6 ; column = 29 ; value ='1'; }
|
||||||
|
{kind = TOKEN_RIGHTPAREN; ; index = 154 ; length = 1 line = 6 ; column = 32 ; value =')'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 155 ; length = 1 line = 6 ; column = 33 ; value =';'; }
|
||||||
|
{kind = TOKEN_RIGHTBRACE; ; index = 158 ; length = 1 line = 7 ; column = 0 ; value ='}'; }
|
||||||
|
{kind = TOKEN_EOF; ; index = 161 ; length = 0 line = 8 ; column = 0 ; value =''; }
|
||||||
50
test/lex/precedence_test.golden
Normal file
50
test/lex/precedence_test.golden
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
{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_IDENTIFIER; ; index = 26 ; length = 5 line = 2 ; column = 4 ; value ='float'; }
|
||||||
|
{kind = TOKEN_ASSIGN; ; index = 32 ; length = 1 line = 2 ; column = 10 ; value ='='; }
|
||||||
|
{kind = TOKEN_FLOATLITERAL; ; index = 34 ; length = 3 line = 2 ; column = 12 ; value ='2'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 37 ; length = 1 line = 2 ; column = 15 ; value =';'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 41 ; length = 1 line = 3 ; column = 0 ; value ='y'; }
|
||||||
|
{kind = TOKEN_COLON; ; index = 43 ; length = 1 line = 3 ; column = 2 ; value =':'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 45 ; length = 5 line = 3 ; column = 4 ; value ='float'; }
|
||||||
|
{kind = TOKEN_ASSIGN; ; index = 51 ; length = 1 line = 3 ; column = 10 ; value ='='; }
|
||||||
|
{kind = TOKEN_FLOATLITERAL; ; index = 53 ; length = 3 line = 3 ; column = 12 ; value ='5'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 56 ; length = 1 line = 3 ; column = 15 ; value =';'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 60 ; length = 1 line = 4 ; column = 0 ; value ='z'; }
|
||||||
|
{kind = TOKEN_COLON; ; index = 62 ; length = 1 line = 4 ; column = 2 ; value =':'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 64 ; length = 5 line = 4 ; column = 4 ; value ='float'; }
|
||||||
|
{kind = TOKEN_ASSIGN; ; index = 70 ; length = 1 line = 4 ; column = 10 ; value ='='; }
|
||||||
|
{kind = TOKEN_FLOATLITERAL; ; index = 72 ; length = 4 line = 4 ; column = 12 ; value ='10'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 76 ; length = 1 line = 4 ; column = 16 ; value =';'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 82 ; length = 1 line = 6 ; column = 0 ; value ='w'; }
|
||||||
|
{kind = TOKEN_COLON; ; index = 84 ; length = 1 line = 6 ; column = 2 ; value =':'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 86 ; length = 5 line = 6 ; column = 4 ; value ='float'; }
|
||||||
|
{kind = TOKEN_ASSIGN; ; index = 92 ; length = 1 line = 6 ; column = 10 ; value ='='; }
|
||||||
|
{kind = TOKEN_LEFTPAREN; ; index = 94 ; length = 1 line = 6 ; column = 12 ; value ='('; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 95 ; length = 1 line = 6 ; column = 13 ; value ='x'; }
|
||||||
|
{kind = TOKEN_STAR; ; index = 97 ; length = 1 line = 6 ; column = 15 ; value ='*'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 99 ; length = 1 line = 6 ; column = 17 ; value ='y'; }
|
||||||
|
{kind = TOKEN_RIGHTPAREN; ; index = 100 ; length = 1 line = 6 ; column = 18 ; value =')'; }
|
||||||
|
{kind = TOKEN_PLUS; ; index = 102 ; length = 1 line = 6 ; column = 20 ; value ='+'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 104 ; length = 1 line = 6 ; column = 22 ; value ='y'; }
|
||||||
|
{kind = TOKEN_STAR; ; index = 106 ; length = 1 line = 6 ; column = 24 ; value ='*'; }
|
||||||
|
{kind = TOKEN_LEFTPAREN; ; index = 108 ; length = 1 line = 6 ; column = 26 ; value ='('; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 109 ; length = 1 line = 6 ; column = 27 ; value ='z'; }
|
||||||
|
{kind = TOKEN_MINUS; ; index = 111 ; length = 1 line = 6 ; column = 29 ; value ='-'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 113 ; length = 1 line = 6 ; column = 31 ; value ='x'; }
|
||||||
|
{kind = TOKEN_SLASH; ; index = 115 ; length = 1 line = 6 ; column = 33 ; value ='/'; }
|
||||||
|
{kind = TOKEN_LEFTPAREN; ; index = 117 ; length = 1 line = 6 ; column = 35 ; value ='('; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 118 ; length = 1 line = 6 ; column = 36 ; value ='y'; }
|
||||||
|
{kind = TOKEN_STAR; ; index = 120 ; length = 1 line = 6 ; column = 38 ; value ='*'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 122 ; length = 1 line = 6 ; column = 40 ; value ='x'; }
|
||||||
|
{kind = TOKEN_RIGHTPAREN; ; index = 123 ; length = 1 line = 6 ; column = 41 ; value =')'; }
|
||||||
|
{kind = TOKEN_RIGHTPAREN; ; index = 124 ; length = 1 line = 6 ; column = 42 ; value =')'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 125 ; length = 1 line = 6 ; column = 43 ; value =';'; }
|
||||||
|
{kind = TOKEN_RIGHTBRACE; ; index = 128 ; length = 1 line = 7 ; column = 0 ; value ='}'; }
|
||||||
|
{kind = TOKEN_EOF; ; index = 131 ; length = 0 line = 8 ; column = 0 ; value =''; }
|
||||||
45
test/lex/property_rename.golden
Normal file
45
test/lex/property_rename.golden
Normal file
@@ -0,0 +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 =''; }
|
||||||
20
test/lex/redeclared_variable.golden
Normal file
20
test/lex/redeclared_variable.golden
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
{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_IDENTIFIER; ; index = 26 ; length = 5 line = 2 ; column = 4 ; value ='float'; }
|
||||||
|
{kind = TOKEN_ASSIGN; ; index = 32 ; length = 1 line = 2 ; column = 10 ; value ='='; }
|
||||||
|
{kind = TOKEN_FLOATLITERAL; ; index = 34 ; length = 3 line = 2 ; column = 12 ; value ='1'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 37 ; length = 1 line = 2 ; column = 15 ; value =';'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 41 ; length = 1 line = 3 ; column = 0 ; value ='x'; }
|
||||||
|
{kind = TOKEN_COLON; ; index = 43 ; length = 1 line = 3 ; column = 2 ; value =':'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 45 ; length = 5 line = 3 ; column = 4 ; value ='float'; }
|
||||||
|
{kind = TOKEN_ASSIGN; ; index = 51 ; length = 1 line = 3 ; column = 10 ; value ='='; }
|
||||||
|
{kind = TOKEN_FLOATLITERAL; ; index = 53 ; length = 3 line = 3 ; column = 12 ; value ='5'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 56 ; length = 1 line = 3 ; column = 15 ; 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 =''; }
|
||||||
29
test/lex/simple_struct_access.golden
Normal file
29
test/lex/simple_struct_access.golden
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 0 ; length = 4 line = 1 ; column = 0 ; value ='Data'; }
|
||||||
|
{kind = TOKEN_DOUBLECOLON; ; index = 5 ; length = 2 line = 1 ; column = 5 ; value ='::'; }
|
||||||
|
{kind = TOKEN_STRUCT; ; index = 8 ; length = 6 line = 1 ; column = 8 ; value ='struct'; }
|
||||||
|
{kind = TOKEN_LEFTBRACE; ; index = 15 ; length = 1 line = 1 ; column = 15 ; value ='{'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 19 ; length = 5 line = 2 ; column = 0 ; value ='color'; }
|
||||||
|
{kind = TOKEN_COLON; ; index = 25 ; length = 1 line = 2 ; column = 6 ; value =':'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 27 ; length = 6 line = 2 ; column = 8 ; value ='float4'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 33 ; length = 1 line = 2 ; column = 14 ; value =';'; }
|
||||||
|
{kind = TOKEN_RIGHTBRACE; ; index = 36 ; length = 1 line = 3 ; column = 0 ; value ='}'; }
|
||||||
|
{kind = TOKEN_VERTEX; ; index = 41 ; length = 6 line = 5 ; column = 0 ; value ='vertex'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 48 ; length = 4 line = 5 ; column = 7 ; value ='main'; }
|
||||||
|
{kind = TOKEN_DOUBLECOLON; ; index = 53 ; length = 2 line = 5 ; column = 12 ; value ='::'; }
|
||||||
|
{kind = TOKEN_LEFTPAREN; ; index = 56 ; length = 1 line = 5 ; column = 15 ; value ='('; }
|
||||||
|
{kind = TOKEN_RIGHTPAREN; ; index = 57 ; length = 1 line = 5 ; column = 16 ; value =')'; }
|
||||||
|
{kind = TOKEN_LEFTBRACE; ; index = 59 ; length = 1 line = 5 ; column = 18 ; value ='{'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 63 ; length = 1 line = 6 ; column = 0 ; value ='d'; }
|
||||||
|
{kind = TOKEN_COLON; ; index = 65 ; length = 1 line = 6 ; column = 2 ; value =':'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 67 ; length = 4 line = 6 ; column = 4 ; value ='Data'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 71 ; length = 1 line = 6 ; column = 8 ; value =';'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 75 ; length = 1 line = 7 ; column = 0 ; value ='x'; }
|
||||||
|
{kind = TOKEN_COLON; ; index = 77 ; length = 1 line = 7 ; column = 2 ; value =':'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 79 ; length = 6 line = 7 ; column = 4 ; value ='float4'; }
|
||||||
|
{kind = TOKEN_ASSIGN; ; index = 86 ; length = 1 line = 7 ; column = 11 ; value ='='; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 88 ; length = 1 line = 7 ; column = 13 ; value ='d'; }
|
||||||
|
{kind = TOKEN_DOT; ; index = 89 ; length = 1 line = 7 ; column = 14 ; value ='.'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 90 ; length = 5 line = 7 ; column = 15 ; value ='color'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 95 ; length = 1 line = 7 ; column = 20 ; value =';'; }
|
||||||
|
{kind = TOKEN_RIGHTBRACE; ; index = 98 ; length = 1 line = 8 ; column = 0 ; value ='}'; }
|
||||||
|
{kind = TOKEN_EOF; ; index = 101 ; length = 0 line = 9 ; column = 0 ; value =''; }
|
||||||
20
test/lex/struct_access_primitive_type.golden
Normal file
20
test/lex/struct_access_primitive_type.golden
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
{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_IDENTIFIER; ; index = 26 ; length = 3 line = 2 ; column = 4 ; value ='int'; }
|
||||||
|
{kind = TOKEN_ASSIGN; ; index = 30 ; length = 1 line = 2 ; column = 8 ; value ='='; }
|
||||||
|
{kind = TOKEN_INTLITERAL; ; index = 32 ; length = 1 line = 2 ; column = 10 ; value ='5'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 33 ; length = 1 line = 2 ; column = 11 ; value =';'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 37 ; length = 1 line = 3 ; column = 0 ; value ='x'; }
|
||||||
|
{kind = TOKEN_DOT; ; index = 38 ; length = 1 line = 3 ; column = 1 ; value ='.'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 39 ; length = 1 line = 3 ; column = 2 ; value ='d'; }
|
||||||
|
{kind = TOKEN_ASSIGN; ; index = 41 ; length = 1 line = 3 ; column = 4 ; value ='='; }
|
||||||
|
{kind = TOKEN_INTLITERAL; ; index = 43 ; length = 1 line = 3 ; column = 6 ; value ='4'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 44 ; length = 1 line = 3 ; column = 7 ; value =';'; }
|
||||||
|
{kind = TOKEN_RIGHTBRACE; ; index = 47 ; length = 1 line = 4 ; column = 0 ; value ='}'; }
|
||||||
|
{kind = TOKEN_EOF; ; index = 50 ; length = 0 line = 5 ; column = 0 ; value =''; }
|
||||||
167
test/lex/struct_field_access_test.golden
Normal file
167
test/lex/struct_field_access_test.golden
Normal file
@@ -0,0 +1,167 @@
|
|||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 0 ; length = 10 line = 1 ; column = 0 ; value ='Vertex_Out'; }
|
||||||
|
{kind = TOKEN_DOUBLECOLON; ; index = 11 ; length = 2 line = 1 ; column = 11 ; value ='::'; }
|
||||||
|
{kind = TOKEN_STRUCT; ; index = 14 ; length = 6 line = 1 ; column = 14 ; value ='struct'; }
|
||||||
|
{kind = TOKEN_LEFTBRACE; ; index = 21 ; length = 1 line = 1 ; column = 21 ; value ='{'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 25 ; length = 8 line = 2 ; column = 0 ; value ='position'; }
|
||||||
|
{kind = TOKEN_COLON; ; index = 34 ; length = 1 line = 2 ; column = 9 ; value =':'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 36 ; length = 6 line = 2 ; column = 11 ; value ='float3'; }
|
||||||
|
{kind = TOKEN_AT; ; index = 43 ; length = 1 line = 2 ; column = 18 ; value ='@'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 44 ; length = 8 line = 2 ; column = 19 ; value ='position'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 52 ; length = 1 line = 2 ; column = 27 ; value =';'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 56 ; length = 6 line = 3 ; column = 0 ; value ='normal'; }
|
||||||
|
{kind = TOKEN_COLON; ; index = 65 ; length = 1 line = 3 ; column = 9 ; value =':'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 67 ; length = 6 line = 3 ; column = 11 ; value ='float3'; }
|
||||||
|
{kind = TOKEN_AT; ; index = 74 ; length = 1 line = 3 ; column = 18 ; value ='@'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 75 ; length = 6 line = 3 ; column = 19 ; value ='normal'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 81 ; length = 1 line = 3 ; column = 25 ; value =';'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 85 ; length = 2 line = 4 ; column = 0 ; value ='uv'; }
|
||||||
|
{kind = TOKEN_COLON; ; index = 94 ; length = 1 line = 4 ; column = 9 ; value =':'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 96 ; length = 6 line = 4 ; column = 11 ; value ='float3'; }
|
||||||
|
{kind = TOKEN_AT; ; index = 103 ; length = 1 line = 4 ; column = 18 ; value ='@'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 104 ; length = 2 line = 4 ; column = 19 ; value ='uv'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 106 ; length = 1 line = 4 ; column = 21 ; value =';'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 110 ; length = 8 line = 5 ; column = 0 ; value ='frag_pos'; }
|
||||||
|
{kind = TOKEN_COLON; ; index = 119 ; length = 1 line = 5 ; column = 9 ; value =':'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 121 ; length = 6 line = 5 ; column = 11 ; value ='float3'; }
|
||||||
|
{kind = TOKEN_AT; ; index = 128 ; length = 1 line = 5 ; column = 18 ; value ='@'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 129 ; length = 6 line = 5 ; column = 19 ; value ='interp'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 135 ; length = 1 line = 5 ; column = 25 ; value =';'; }
|
||||||
|
{kind = TOKEN_RIGHTBRACE; ; index = 138 ; length = 1 line = 6 ; column = 0 ; value ='}'; }
|
||||||
|
{kind = TOKEN_INSTANCE; ; index = 143 ; length = 8 line = 8 ; column = 0 ; value ='instance'; }
|
||||||
|
{kind = TOKEN_LEFTBRACE; ; index = 152 ; length = 1 line = 8 ; column = 9 ; value ='{'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 156 ; length = 5 line = 9 ; column = 0 ; value ='model'; }
|
||||||
|
{kind = TOKEN_COLON; ; index = 162 ; length = 1 line = 9 ; column = 6 ; value =':'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 164 ; length = 8 line = 9 ; column = 8 ; value ='float4x4'; }
|
||||||
|
{kind = TOKEN_AT; ; index = 173 ; length = 1 line = 9 ; column = 17 ; value ='@'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 174 ; length = 5 line = 9 ; column = 18 ; value ='model'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 179 ; length = 1 line = 9 ; column = 23 ; value =';'; }
|
||||||
|
{kind = TOKEN_RIGHTBRACE; ; index = 182 ; length = 1 line = 10 ; column = 0 ; value ='}'; }
|
||||||
|
{kind = TOKEN_VERTEX; ; index = 187 ; length = 6 line = 12 ; column = 0 ; value ='vertex'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 194 ; length = 4 line = 12 ; column = 7 ; value ='main'; }
|
||||||
|
{kind = TOKEN_DOUBLECOLON; ; index = 199 ; length = 2 line = 12 ; column = 12 ; value ='::'; }
|
||||||
|
{kind = TOKEN_LEFTPAREN; ; index = 202 ; length = 1 line = 12 ; column = 15 ; value ='('; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 203 ; length = 8 line = 12 ; column = 16 ; value ='position'; }
|
||||||
|
{kind = TOKEN_COLON; ; index = 212 ; length = 1 line = 12 ; column = 25 ; value =':'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 214 ; length = 6 line = 12 ; column = 27 ; value ='float3'; }
|
||||||
|
{kind = TOKEN_AT; ; index = 221 ; length = 1 line = 12 ; column = 34 ; value ='@'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 222 ; length = 8 line = 12 ; column = 35 ; value ='position'; }
|
||||||
|
{kind = TOKEN_COMMA; ; index = 230 ; length = 1 line = 12 ; column = 43 ; value =','; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 232 ; length = 2 line = 12 ; column = 45 ; value ='uv'; }
|
||||||
|
{kind = TOKEN_COLON; ; index = 235 ; length = 1 line = 12 ; column = 48 ; value =':'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 237 ; length = 6 line = 12 ; column = 50 ; value ='float2'; }
|
||||||
|
{kind = TOKEN_AT; ; index = 244 ; length = 1 line = 12 ; column = 57 ; value ='@'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 245 ; length = 2 line = 12 ; column = 58 ; value ='uv'; }
|
||||||
|
{kind = TOKEN_COMMA; ; index = 247 ; length = 1 line = 12 ; column = 60 ; value =','; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 249 ; length = 6 line = 12 ; column = 62 ; value ='normal'; }
|
||||||
|
{kind = TOKEN_COLON; ; index = 256 ; length = 1 line = 12 ; column = 69 ; value =':'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 258 ; length = 6 line = 12 ; column = 71 ; value ='float3'; }
|
||||||
|
{kind = TOKEN_AT; ; index = 265 ; length = 1 line = 12 ; column = 78 ; value ='@'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 266 ; length = 6 line = 12 ; column = 79 ; value ='normal'; }
|
||||||
|
{kind = TOKEN_RIGHTPAREN; ; index = 272 ; length = 1 line = 12 ; column = 85 ; value =')'; }
|
||||||
|
{kind = TOKEN_ARROW; ; index = 274 ; length = 2 line = 12 ; column = 87 ; value ='->'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 277 ; length = 10 line = 12 ; column = 90 ; value ='Vertex_Out'; }
|
||||||
|
{kind = TOKEN_LEFTBRACE; ; index = 288 ; length = 1 line = 12 ; column = 101 ; value ='{'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 292 ; length = 5 line = 13 ; column = 0 ; value ='v_out'; }
|
||||||
|
{kind = TOKEN_COLON; ; index = 298 ; length = 1 line = 13 ; column = 6 ; value =':'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 300 ; length = 10 line = 13 ; column = 8 ; value ='Vertex_Out'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 310 ; length = 1 line = 13 ; column = 18 ; value =';'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 316 ; length = 5 line = 15 ; column = 0 ; value ='v_out'; }
|
||||||
|
{kind = TOKEN_DOT; ; index = 321 ; length = 1 line = 15 ; column = 5 ; value ='.'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 322 ; length = 8 line = 15 ; column = 6 ; value ='position'; }
|
||||||
|
{kind = TOKEN_ASSIGN; ; index = 331 ; length = 1 line = 15 ; column = 15 ; value ='='; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 333 ; length = 3 line = 15 ; column = 17 ; value ='mul'; }
|
||||||
|
{kind = TOKEN_LEFTPAREN; ; index = 336 ; length = 1 line = 15 ; column = 20 ; value ='('; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 337 ; length = 8 line = 15 ; column = 21 ; value ='position'; }
|
||||||
|
{kind = TOKEN_COMMA; ; index = 345 ; length = 1 line = 15 ; column = 29 ; value =','; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 347 ; length = 5 line = 15 ; column = 31 ; value ='model'; }
|
||||||
|
{kind = TOKEN_RIGHTPAREN; ; index = 352 ; length = 1 line = 15 ; column = 36 ; value =')'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 353 ; length = 1 line = 15 ; column = 37 ; value =';'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 357 ; length = 5 line = 16 ; column = 0 ; value ='v_out'; }
|
||||||
|
{kind = TOKEN_DOT; ; index = 362 ; length = 1 line = 16 ; column = 5 ; value ='.'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 363 ; length = 6 line = 16 ; column = 6 ; value ='normal'; }
|
||||||
|
{kind = TOKEN_ASSIGN; ; index = 372 ; length = 1 line = 16 ; column = 15 ; value ='='; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 374 ; length = 6 line = 16 ; column = 17 ; value ='normal'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 380 ; length = 1 line = 16 ; column = 23 ; value =';'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 384 ; length = 5 line = 17 ; column = 0 ; value ='v_out'; }
|
||||||
|
{kind = TOKEN_DOT; ; index = 389 ; length = 1 line = 17 ; column = 5 ; value ='.'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 390 ; length = 2 line = 17 ; column = 6 ; value ='uv'; }
|
||||||
|
{kind = TOKEN_ASSIGN; ; index = 399 ; length = 1 line = 17 ; column = 15 ; value ='='; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 401 ; length = 2 line = 17 ; column = 17 ; value ='uv'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 403 ; length = 1 line = 17 ; column = 19 ; value =';'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 407 ; length = 5 line = 18 ; column = 0 ; value ='v_out'; }
|
||||||
|
{kind = TOKEN_DOT; ; index = 412 ; length = 1 line = 18 ; column = 5 ; value ='.'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 413 ; length = 8 line = 18 ; column = 6 ; value ='frag_pos'; }
|
||||||
|
{kind = TOKEN_ASSIGN; ; index = 422 ; length = 1 line = 18 ; column = 15 ; value ='='; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 424 ; length = 8 line = 18 ; column = 17 ; value ='position'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 432 ; length = 1 line = 18 ; column = 25 ; value =';'; }
|
||||||
|
{kind = TOKEN_RETURN; ; index = 438 ; length = 6 line = 20 ; column = 0 ; value ='return'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 445 ; length = 5 line = 20 ; column = 7 ; value ='v_out'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 450 ; length = 1 line = 20 ; column = 12 ; value =';'; }
|
||||||
|
{kind = TOKEN_RIGHTBRACE; ; index = 453 ; length = 1 line = 21 ; column = 0 ; value ='}'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 458 ; length = 9 line = 23 ; column = 0 ; value ='Pixel_Out'; }
|
||||||
|
{kind = TOKEN_DOUBLECOLON; ; index = 468 ; length = 2 line = 23 ; column = 10 ; value ='::'; }
|
||||||
|
{kind = TOKEN_STRUCT; ; index = 471 ; length = 6 line = 23 ; column = 13 ; value ='struct'; }
|
||||||
|
{kind = TOKEN_LEFTBRACE; ; index = 478 ; length = 1 line = 23 ; column = 20 ; value ='{'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 482 ; length = 5 line = 24 ; column = 0 ; value ='color'; }
|
||||||
|
{kind = TOKEN_COLON; ; index = 491 ; length = 1 line = 24 ; column = 9 ; value =':'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 493 ; length = 6 line = 24 ; column = 11 ; value ='float4'; }
|
||||||
|
{kind = TOKEN_AT; ; index = 500 ; length = 1 line = 24 ; column = 18 ; value ='@'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 501 ; length = 7 line = 24 ; column = 19 ; value ='target0'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 508 ; length = 1 line = 24 ; column = 26 ; value =';'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 512 ; length = 8 line = 25 ; column = 0 ; value ='emission'; }
|
||||||
|
{kind = TOKEN_COLON; ; index = 521 ; length = 1 line = 25 ; column = 9 ; value =':'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 523 ; length = 6 line = 25 ; column = 11 ; value ='float4'; }
|
||||||
|
{kind = TOKEN_AT; ; index = 530 ; length = 1 line = 25 ; column = 18 ; value ='@'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 531 ; length = 7 line = 25 ; column = 19 ; value ='target1'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 538 ; length = 1 line = 25 ; column = 26 ; value =';'; }
|
||||||
|
{kind = TOKEN_RIGHTBRACE; ; index = 541 ; length = 1 line = 26 ; column = 0 ; value ='}'; }
|
||||||
|
{kind = TOKEN_PIXEL; ; index = 546 ; length = 5 line = 28 ; column = 0 ; value ='pixel'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 552 ; length = 4 line = 28 ; column = 6 ; value ='main'; }
|
||||||
|
{kind = TOKEN_DOUBLECOLON; ; index = 557 ; length = 2 line = 28 ; column = 11 ; value ='::'; }
|
||||||
|
{kind = TOKEN_LEFTPAREN; ; index = 560 ; length = 1 line = 28 ; column = 14 ; value ='('; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 561 ; length = 4 line = 28 ; column = 15 ; value ='v_in'; }
|
||||||
|
{kind = TOKEN_COLON; ; index = 566 ; length = 1 line = 28 ; column = 20 ; value =':'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 568 ; length = 10 line = 28 ; column = 22 ; value ='Vertex_Out'; }
|
||||||
|
{kind = TOKEN_RIGHTPAREN; ; index = 578 ; length = 1 line = 28 ; column = 32 ; value =')'; }
|
||||||
|
{kind = TOKEN_ARROW; ; index = 580 ; length = 2 line = 28 ; column = 34 ; value ='->'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 583 ; length = 9 line = 28 ; column = 37 ; value ='Pixel_Out'; }
|
||||||
|
{kind = TOKEN_LEFTBRACE; ; index = 593 ; length = 1 line = 28 ; column = 47 ; value ='{'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 597 ; length = 5 line = 29 ; column = 0 ; value ='p_out'; }
|
||||||
|
{kind = TOKEN_COLON; ; index = 603 ; length = 1 line = 29 ; column = 6 ; value =':'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 605 ; length = 9 line = 29 ; column = 8 ; value ='Pixel_Out'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 614 ; length = 1 line = 29 ; column = 17 ; value =';'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 620 ; length = 5 line = 31 ; column = 0 ; value ='p_out'; }
|
||||||
|
{kind = TOKEN_DOT; ; index = 625 ; length = 1 line = 31 ; column = 5 ; value ='.'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 626 ; length = 5 line = 31 ; column = 6 ; value ='color'; }
|
||||||
|
{kind = TOKEN_ASSIGN; ; index = 635 ; length = 1 line = 31 ; column = 15 ; value ='='; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 637 ; length = 6 line = 31 ; column = 17 ; value ='float4'; }
|
||||||
|
{kind = TOKEN_LEFTPAREN; ; index = 643 ; length = 1 line = 31 ; column = 23 ; value ='('; }
|
||||||
|
{kind = TOKEN_INTLITERAL; ; index = 644 ; length = 1 line = 31 ; column = 24 ; value ='1'; }
|
||||||
|
{kind = TOKEN_COMMA; ; index = 645 ; length = 1 line = 31 ; column = 25 ; value =','; }
|
||||||
|
{kind = TOKEN_FLOATLITERAL; ; index = 647 ; length = 3 line = 31 ; column = 27 ; value ='0.5'; }
|
||||||
|
{kind = TOKEN_COMMA; ; index = 650 ; length = 1 line = 31 ; column = 30 ; value =','; }
|
||||||
|
{kind = TOKEN_INTLITERAL; ; index = 652 ; length = 1 line = 31 ; column = 32 ; value ='1'; }
|
||||||
|
{kind = TOKEN_COMMA; ; index = 653 ; length = 1 line = 31 ; column = 33 ; value =','; }
|
||||||
|
{kind = TOKEN_INTLITERAL; ; index = 655 ; length = 1 line = 31 ; column = 35 ; value ='1'; }
|
||||||
|
{kind = TOKEN_RIGHTPAREN; ; index = 656 ; length = 1 line = 31 ; column = 36 ; value =')'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 657 ; length = 1 line = 31 ; column = 37 ; value =';'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 661 ; length = 5 line = 32 ; column = 0 ; value ='p_out'; }
|
||||||
|
{kind = TOKEN_DOT; ; index = 666 ; length = 1 line = 32 ; column = 5 ; value ='.'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 667 ; length = 8 line = 32 ; column = 6 ; value ='emission'; }
|
||||||
|
{kind = TOKEN_ASSIGN; ; index = 676 ; length = 1 line = 32 ; column = 15 ; value ='='; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 678 ; length = 6 line = 32 ; column = 17 ; value ='float4'; }
|
||||||
|
{kind = TOKEN_LEFTPAREN; ; index = 684 ; length = 1 line = 32 ; column = 23 ; value ='('; }
|
||||||
|
{kind = TOKEN_FLOATLITERAL; ; index = 685 ; length = 3 line = 32 ; column = 24 ; value ='2'; }
|
||||||
|
{kind = TOKEN_COMMA; ; index = 688 ; length = 1 line = 32 ; column = 27 ; value =','; }
|
||||||
|
{kind = TOKEN_FLOATLITERAL; ; index = 690 ; length = 3 line = 32 ; column = 29 ; value ='2'; }
|
||||||
|
{kind = TOKEN_COMMA; ; index = 693 ; length = 1 line = 32 ; column = 32 ; value =','; }
|
||||||
|
{kind = TOKEN_FLOATLITERAL; ; index = 695 ; length = 3 line = 32 ; column = 34 ; value ='2'; }
|
||||||
|
{kind = TOKEN_COMMA; ; index = 698 ; length = 1 line = 32 ; column = 37 ; value =','; }
|
||||||
|
{kind = TOKEN_FLOATLITERAL; ; index = 700 ; length = 3 line = 32 ; column = 39 ; value ='2'; }
|
||||||
|
{kind = TOKEN_RIGHTPAREN; ; index = 703 ; length = 1 line = 32 ; column = 42 ; value =')'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 704 ; length = 1 line = 32 ; column = 43 ; value =';'; }
|
||||||
|
{kind = TOKEN_RETURN; ; index = 710 ; length = 6 line = 34 ; column = 0 ; value ='return'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 717 ; length = 5 line = 34 ; column = 7 ; value ='p_out'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 722 ; length = 1 line = 34 ; column = 12 ; value =';'; }
|
||||||
|
{kind = TOKEN_RIGHTBRACE; ; index = 725 ; length = 1 line = 35 ; column = 0 ; value ='}'; }
|
||||||
|
{kind = TOKEN_EOF; ; index = 728 ; length = 0 line = 36 ; column = 0 ; value =''; }
|
||||||
40
test/lex/struct_within_struct.golden
Normal file
40
test/lex/struct_within_struct.golden
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 0 ; length = 3 line = 1 ; column = 0 ; value ='Foo'; }
|
||||||
|
{kind = TOKEN_DOUBLECOLON; ; index = 4 ; length = 2 line = 1 ; column = 4 ; value ='::'; }
|
||||||
|
{kind = TOKEN_STRUCT; ; index = 7 ; length = 6 line = 1 ; column = 7 ; value ='struct'; }
|
||||||
|
{kind = TOKEN_LEFTBRACE; ; index = 14 ; length = 1 line = 1 ; column = 14 ; value ='{'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 18 ; length = 5 line = 2 ; column = 0 ; value ='color'; }
|
||||||
|
{kind = TOKEN_COLON; ; index = 24 ; length = 1 line = 2 ; column = 6 ; value =':'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 26 ; length = 6 line = 2 ; column = 8 ; value ='float4'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 32 ; length = 1 line = 2 ; column = 14 ; value =';'; }
|
||||||
|
{kind = TOKEN_RIGHTBRACE; ; index = 35 ; length = 1 line = 3 ; column = 0 ; value ='}'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 40 ; length = 3 line = 5 ; column = 0 ; value ='Bar'; }
|
||||||
|
{kind = TOKEN_DOUBLECOLON; ; index = 44 ; length = 2 line = 5 ; column = 4 ; value ='::'; }
|
||||||
|
{kind = TOKEN_STRUCT; ; index = 47 ; length = 6 line = 5 ; column = 7 ; value ='struct'; }
|
||||||
|
{kind = TOKEN_LEFTBRACE; ; index = 54 ; length = 1 line = 5 ; column = 14 ; value ='{'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 61 ; length = 1 line = 6 ; column = 4 ; value ='t'; }
|
||||||
|
{kind = TOKEN_COLON; ; index = 63 ; length = 1 line = 6 ; column = 6 ; value =':'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 65 ; length = 3 line = 6 ; column = 8 ; value ='Foo'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 68 ; length = 1 line = 6 ; column = 11 ; value =';'; }
|
||||||
|
{kind = TOKEN_RIGHTBRACE; ; index = 71 ; length = 1 line = 7 ; column = 0 ; value ='}'; }
|
||||||
|
{kind = TOKEN_VERTEX; ; index = 76 ; length = 6 line = 9 ; column = 0 ; value ='vertex'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 83 ; length = 4 line = 9 ; column = 7 ; value ='main'; }
|
||||||
|
{kind = TOKEN_DOUBLECOLON; ; index = 88 ; length = 2 line = 9 ; column = 12 ; value ='::'; }
|
||||||
|
{kind = TOKEN_LEFTPAREN; ; index = 91 ; length = 1 line = 9 ; column = 15 ; value ='('; }
|
||||||
|
{kind = TOKEN_RIGHTPAREN; ; index = 92 ; length = 1 line = 9 ; column = 16 ; value =')'; }
|
||||||
|
{kind = TOKEN_LEFTBRACE; ; index = 94 ; length = 1 line = 9 ; column = 18 ; value ='{'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 98 ; length = 1 line = 10 ; column = 0 ; value ='f'; }
|
||||||
|
{kind = TOKEN_COLON; ; index = 100 ; length = 1 line = 10 ; column = 2 ; value =':'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 102 ; length = 3 line = 10 ; column = 4 ; value ='Foo'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 105 ; length = 1 line = 10 ; column = 7 ; value =';'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 109 ; length = 1 line = 11 ; column = 0 ; value ='b'; }
|
||||||
|
{kind = TOKEN_COLON; ; index = 111 ; length = 1 line = 11 ; column = 2 ; value =':'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 113 ; length = 3 line = 11 ; column = 4 ; value ='Bar'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 116 ; length = 1 line = 11 ; column = 7 ; value =';'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 120 ; length = 1 line = 12 ; column = 0 ; value ='b'; }
|
||||||
|
{kind = TOKEN_DOT; ; index = 121 ; length = 1 line = 12 ; column = 1 ; value ='.'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 122 ; length = 1 line = 12 ; column = 2 ; value ='t'; }
|
||||||
|
{kind = TOKEN_ASSIGN; ; index = 124 ; length = 1 line = 12 ; column = 4 ; value ='='; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 126 ; length = 1 line = 12 ; column = 6 ; value ='f'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 127 ; length = 1 line = 12 ; column = 7 ; value =';'; }
|
||||||
|
{kind = TOKEN_RIGHTBRACE; ; index = 130 ; length = 1 line = 13 ; column = 0 ; value ='}'; }
|
||||||
|
{kind = TOKEN_EOF; ; index = 133 ; length = 0 line = 14 ; column = 0 ; value =''; }
|
||||||
7
test/lex/type_as_function_name.golden
Normal file
7
test/lex/type_as_function_name.golden
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 0 ; length = 3 line = 1 ; column = 0 ; value ='int'; }
|
||||||
|
{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_LEFTBRACE; ; index = 10 ; length = 1 line = 1 ; column = 10 ; value ='{'; }
|
||||||
|
{kind = TOKEN_RIGHTBRACE; ; index = 11 ; length = 1 line = 1 ; column = 11 ; value ='}'; }
|
||||||
|
{kind = TOKEN_EOF; ; index = 14 ; length = 0 line = 2 ; column = 0 ; value =''; }
|
||||||
14
test/lex/type_as_variable_name.golden
Normal file
14
test/lex/type_as_variable_name.golden
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
{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 = 3 line = 2 ; column = 0 ; value ='int'; }
|
||||||
|
{kind = TOKEN_COLON; ; index = 26 ; length = 1 line = 2 ; column = 4 ; value =':'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 28 ; length = 5 line = 2 ; column = 6 ; value ='float'; }
|
||||||
|
{kind = TOKEN_ASSIGN; ; index = 34 ; length = 1 line = 2 ; column = 12 ; value ='='; }
|
||||||
|
{kind = TOKEN_FLOATLITERAL; ; index = 36 ; length = 3 line = 2 ; column = 14 ; value ='4'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 39 ; length = 1 line = 2 ; column = 17 ; value =';'; }
|
||||||
|
{kind = TOKEN_RIGHTBRACE; ; index = 42 ; length = 1 line = 3 ; column = 0 ; value ='}'; }
|
||||||
|
{kind = TOKEN_EOF; ; index = 45 ; length = 0 line = 4 ; column = 0 ; value =''; }
|
||||||
12
test/lex/undeclared_function.golden
Normal file
12
test/lex/undeclared_function.golden
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
{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 = 3 line = 2 ; column = 0 ; value ='foo'; }
|
||||||
|
{kind = TOKEN_LEFTPAREN; ; index = 25 ; length = 1 line = 2 ; column = 3 ; value ='('; }
|
||||||
|
{kind = TOKEN_RIGHTPAREN; ; index = 26 ; length = 1 line = 2 ; column = 4 ; value =')'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 27 ; length = 1 line = 2 ; column = 5 ; value =';'; }
|
||||||
|
{kind = TOKEN_RIGHTBRACE; ; index = 30 ; length = 1 line = 3 ; column = 0 ; value ='}'; }
|
||||||
|
{kind = TOKEN_EOF; ; index = 33 ; length = 0 line = 4 ; column = 0 ; value =''; }
|
||||||
14
test/lex/undeclared_symbol.golden
Normal file
14
test/lex/undeclared_symbol.golden
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
{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 ='b'; }
|
||||||
|
{kind = TOKEN_COLON; ; index = 24 ; length = 1 line = 2 ; column = 2 ; value =':'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 26 ; length = 3 line = 2 ; column = 4 ; value ='int'; }
|
||||||
|
{kind = TOKEN_ASSIGN; ; index = 30 ; length = 1 line = 2 ; column = 8 ; value ='='; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 32 ; length = 1 line = 2 ; column = 10 ; value ='f'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 33 ; length = 1 line = 2 ; column = 11 ; value =';'; }
|
||||||
|
{kind = TOKEN_RIGHTBRACE; ; index = 36 ; length = 1 line = 3 ; column = 0 ; value ='}'; }
|
||||||
|
{kind = TOKEN_EOF; ; index = 39 ; length = 0 line = 4 ; column = 0 ; value =''; }
|
||||||
51
test/lex/unknown_overload.golden
Normal file
51
test/lex/unknown_overload.golden
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 0 ; length = 3 line = 1 ; column = 0 ; value ='foo'; }
|
||||||
|
{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_IDENTIFIER; ; index = 8 ; length = 2 line = 1 ; column = 8 ; value ='v1'; }
|
||||||
|
{kind = TOKEN_COLON; ; index = 11 ; length = 1 line = 1 ; column = 11 ; value =':'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 13 ; length = 6 line = 1 ; column = 13 ; value ='float3'; }
|
||||||
|
{kind = TOKEN_COMMA; ; index = 19 ; length = 1 line = 1 ; column = 19 ; value =','; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 21 ; length = 2 line = 1 ; column = 21 ; value ='v2'; }
|
||||||
|
{kind = TOKEN_COLON; ; index = 24 ; length = 1 line = 1 ; column = 24 ; value =':'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 26 ; length = 6 line = 1 ; column = 26 ; value ='float3'; }
|
||||||
|
{kind = TOKEN_RIGHTPAREN; ; index = 32 ; length = 1 line = 1 ; column = 32 ; value =')'; }
|
||||||
|
{kind = TOKEN_LEFTBRACE; ; index = 34 ; length = 1 line = 1 ; column = 34 ; value ='{'; }
|
||||||
|
{kind = TOKEN_RIGHTBRACE; ; index = 35 ; length = 1 line = 1 ; column = 35 ; value ='}'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 38 ; length = 3 line = 2 ; column = 0 ; value ='foo'; }
|
||||||
|
{kind = TOKEN_DOUBLECOLON; ; index = 42 ; length = 2 line = 2 ; column = 4 ; value ='::'; }
|
||||||
|
{kind = TOKEN_LEFTPAREN; ; index = 45 ; length = 1 line = 2 ; column = 7 ; value ='('; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 46 ; length = 2 line = 2 ; column = 8 ; value ='v1'; }
|
||||||
|
{kind = TOKEN_COLON; ; index = 49 ; length = 1 line = 2 ; column = 11 ; value =':'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 51 ; length = 6 line = 2 ; column = 13 ; value ='float2'; }
|
||||||
|
{kind = TOKEN_COMMA; ; index = 57 ; length = 1 line = 2 ; column = 19 ; value =','; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 59 ; length = 2 line = 2 ; column = 21 ; value ='v2'; }
|
||||||
|
{kind = TOKEN_COLON; ; index = 62 ; length = 1 line = 2 ; column = 24 ; value =':'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 64 ; length = 6 line = 2 ; column = 26 ; value ='float2'; }
|
||||||
|
{kind = TOKEN_COMMA; ; index = 70 ; length = 1 line = 2 ; column = 32 ; value =','; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 72 ; length = 2 line = 2 ; column = 34 ; value ='v3'; }
|
||||||
|
{kind = TOKEN_COLON; ; index = 75 ; length = 1 line = 2 ; column = 37 ; value =':'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 77 ; length = 6 line = 2 ; column = 39 ; value ='float2'; }
|
||||||
|
{kind = TOKEN_RIGHTPAREN; ; index = 83 ; length = 1 line = 2 ; column = 45 ; value =')'; }
|
||||||
|
{kind = TOKEN_LEFTBRACE; ; index = 85 ; length = 1 line = 2 ; column = 47 ; value ='{'; }
|
||||||
|
{kind = TOKEN_RIGHTBRACE; ; index = 86 ; length = 1 line = 2 ; column = 48 ; value ='}'; }
|
||||||
|
{kind = TOKEN_VERTEX; ; index = 91 ; length = 6 line = 4 ; column = 0 ; value ='vertex'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 98 ; length = 4 line = 4 ; column = 7 ; value ='main'; }
|
||||||
|
{kind = TOKEN_DOUBLECOLON; ; index = 103 ; length = 2 line = 4 ; column = 12 ; value ='::'; }
|
||||||
|
{kind = TOKEN_LEFTPAREN; ; index = 106 ; length = 1 line = 4 ; column = 15 ; value ='('; }
|
||||||
|
{kind = TOKEN_RIGHTPAREN; ; index = 107 ; length = 1 line = 4 ; column = 16 ; value =')'; }
|
||||||
|
{kind = TOKEN_LEFTBRACE; ; index = 109 ; length = 1 line = 4 ; column = 18 ; value ='{'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 113 ; length = 1 line = 5 ; column = 0 ; value ='v'; }
|
||||||
|
{kind = TOKEN_COLON; ; index = 115 ; length = 1 line = 5 ; column = 2 ; value =':'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 117 ; length = 5 line = 5 ; column = 4 ; value ='float'; }
|
||||||
|
{kind = TOKEN_ASSIGN; ; index = 123 ; length = 1 line = 5 ; column = 10 ; value ='='; }
|
||||||
|
{kind = TOKEN_FLOATLITERAL; ; index = 125 ; length = 3 line = 5 ; column = 12 ; value ='2'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 128 ; length = 1 line = 5 ; column = 15 ; value =';'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 132 ; length = 3 line = 6 ; column = 0 ; value ='foo'; }
|
||||||
|
{kind = TOKEN_LEFTPAREN; ; index = 135 ; length = 1 line = 6 ; column = 3 ; value ='('; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 136 ; length = 1 line = 6 ; column = 4 ; value ='v'; }
|
||||||
|
{kind = TOKEN_COMMA; ; index = 137 ; length = 1 line = 6 ; column = 5 ; value =','; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 139 ; length = 1 line = 6 ; column = 7 ; value ='v'; }
|
||||||
|
{kind = TOKEN_RIGHTPAREN; ; index = 140 ; length = 1 line = 6 ; column = 8 ; value =')'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 141 ; length = 1 line = 6 ; column = 9 ; value =';'; }
|
||||||
|
{kind = TOKEN_RIGHTBRACE; ; index = 144 ; length = 1 line = 7 ; column = 0 ; value ='}'; }
|
||||||
|
{kind = TOKEN_EOF; ; index = 147 ; length = 0 line = 8 ; column = 0 ; value =''; }
|
||||||
23
test/lex/use_builtin_functions.golden
Normal file
23
test/lex/use_builtin_functions.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 ='f'; }
|
||||||
|
{kind = TOKEN_COLON; ; index = 24 ; length = 1 line = 2 ; column = 2 ; value =':'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 26 ; length = 6 line = 2 ; column = 4 ; value ='float4'; }
|
||||||
|
{kind = TOKEN_ASSIGN; ; index = 33 ; length = 1 line = 2 ; column = 11 ; value ='='; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 35 ; length = 6 line = 2 ; column = 13 ; value ='float4'; }
|
||||||
|
{kind = TOKEN_LEFTPAREN; ; index = 41 ; length = 1 line = 2 ; column = 19 ; value ='('; }
|
||||||
|
{kind = TOKEN_INTLITERAL; ; index = 42 ; length = 1 line = 2 ; column = 20 ; value ='1'; }
|
||||||
|
{kind = TOKEN_COMMA; ; index = 43 ; length = 1 line = 2 ; column = 21 ; value =','; }
|
||||||
|
{kind = TOKEN_INTLITERAL; ; index = 45 ; length = 1 line = 2 ; column = 23 ; value ='1'; }
|
||||||
|
{kind = TOKEN_COMMA; ; index = 46 ; length = 1 line = 2 ; column = 24 ; value =','; }
|
||||||
|
{kind = TOKEN_INTLITERAL; ; index = 48 ; length = 1 line = 2 ; column = 26 ; value ='1'; }
|
||||||
|
{kind = TOKEN_COMMA; ; index = 49 ; length = 1 line = 2 ; column = 27 ; value =','; }
|
||||||
|
{kind = TOKEN_INTLITERAL; ; index = 51 ; length = 1 line = 2 ; column = 29 ; value ='1'; }
|
||||||
|
{kind = TOKEN_RIGHTPAREN; ; index = 52 ; length = 1 line = 2 ; column = 30 ; value =')'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 53 ; length = 1 line = 2 ; column = 31 ; value =';'; }
|
||||||
|
{kind = TOKEN_RIGHTBRACE; ; index = 56 ; length = 1 line = 3 ; column = 0 ; value ='}'; }
|
||||||
|
{kind = TOKEN_EOF; ; index = 59 ; length = 0 line = 4 ; column = 0 ; value =''; }
|
||||||
73
test/lex/wrong_argument_count.golden
Normal file
73
test/lex/wrong_argument_count.golden
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 0 ; length = 3 line = 1 ; column = 0 ; value ='foo'; }
|
||||||
|
{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_IDENTIFIER; ; index = 8 ; length = 1 line = 1 ; column = 8 ; value ='x'; }
|
||||||
|
{kind = TOKEN_COLON; ; index = 10 ; length = 1 line = 1 ; column = 10 ; value =':'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 12 ; length = 5 line = 1 ; column = 12 ; value ='float'; }
|
||||||
|
{kind = TOKEN_COMMA; ; index = 17 ; length = 1 line = 1 ; column = 17 ; value =','; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 19 ; length = 1 line = 1 ; column = 19 ; value ='y'; }
|
||||||
|
{kind = TOKEN_COLON; ; index = 21 ; length = 1 line = 1 ; column = 21 ; value =':'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 23 ; length = 5 line = 1 ; column = 23 ; value ='float'; }
|
||||||
|
{kind = TOKEN_COMMA; ; index = 28 ; length = 1 line = 1 ; column = 28 ; value =','; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 30 ; length = 1 line = 1 ; column = 30 ; value ='z'; }
|
||||||
|
{kind = TOKEN_COLON; ; index = 32 ; length = 1 line = 1 ; column = 32 ; value =':'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 34 ; length = 5 line = 1 ; column = 34 ; value ='float'; }
|
||||||
|
{kind = TOKEN_RIGHTPAREN; ; index = 39 ; length = 1 line = 1 ; column = 39 ; value =')'; }
|
||||||
|
{kind = TOKEN_ARROW; ; index = 41 ; length = 2 line = 1 ; column = 41 ; value ='->'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 44 ; length = 5 line = 1 ; column = 44 ; value ='float'; }
|
||||||
|
{kind = TOKEN_LEFTBRACE; ; index = 50 ; length = 1 line = 1 ; column = 50 ; value ='{'; }
|
||||||
|
{kind = TOKEN_RETURN; ; index = 54 ; length = 6 line = 2 ; column = 0 ; value ='return'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 61 ; length = 1 line = 2 ; column = 7 ; value ='x'; }
|
||||||
|
{kind = TOKEN_STAR; ; index = 63 ; length = 1 line = 2 ; column = 9 ; value ='*'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 65 ; length = 1 line = 2 ; column = 11 ; value ='y'; }
|
||||||
|
{kind = TOKEN_STAR; ; index = 67 ; length = 1 line = 2 ; column = 13 ; value ='*'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 69 ; length = 1 line = 2 ; column = 15 ; value ='z'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 70 ; length = 1 line = 2 ; column = 16 ; value =';'; }
|
||||||
|
{kind = TOKEN_RIGHTBRACE; ; index = 73 ; length = 1 line = 3 ; column = 0 ; value ='}'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 76 ; length = 3 line = 4 ; column = 0 ; value ='foo'; }
|
||||||
|
{kind = TOKEN_DOUBLECOLON; ; index = 80 ; length = 2 line = 4 ; column = 4 ; value ='::'; }
|
||||||
|
{kind = TOKEN_LEFTPAREN; ; index = 83 ; length = 1 line = 4 ; column = 7 ; value ='('; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 84 ; length = 1 line = 4 ; column = 8 ; value ='x'; }
|
||||||
|
{kind = TOKEN_COLON; ; index = 86 ; length = 1 line = 4 ; column = 10 ; value =':'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 88 ; length = 5 line = 4 ; column = 12 ; value ='float'; }
|
||||||
|
{kind = TOKEN_COMMA; ; index = 93 ; length = 1 line = 4 ; column = 17 ; value =','; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 95 ; length = 1 line = 4 ; column = 19 ; value ='y'; }
|
||||||
|
{kind = TOKEN_COLON; ; index = 97 ; length = 1 line = 4 ; column = 21 ; value =':'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 99 ; length = 5 line = 4 ; column = 23 ; value ='float'; }
|
||||||
|
{kind = TOKEN_COMMA; ; index = 104 ; length = 1 line = 4 ; column = 28 ; value =','; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 106 ; length = 1 line = 4 ; column = 30 ; value ='z'; }
|
||||||
|
{kind = TOKEN_COLON; ; index = 108 ; length = 1 line = 4 ; column = 32 ; value =':'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 110 ; length = 5 line = 4 ; column = 34 ; value ='float'; }
|
||||||
|
{kind = TOKEN_COMMA; ; index = 115 ; length = 1 line = 4 ; column = 39 ; value =','; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 117 ; length = 1 line = 4 ; column = 41 ; value ='w'; }
|
||||||
|
{kind = TOKEN_COLON; ; index = 119 ; length = 1 line = 4 ; column = 43 ; value =':'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 121 ; length = 5 line = 4 ; column = 45 ; value ='float'; }
|
||||||
|
{kind = TOKEN_RIGHTPAREN; ; index = 126 ; length = 1 line = 4 ; column = 50 ; value =')'; }
|
||||||
|
{kind = TOKEN_ARROW; ; index = 128 ; length = 2 line = 4 ; column = 52 ; value ='->'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 131 ; length = 5 line = 4 ; column = 55 ; value ='float'; }
|
||||||
|
{kind = TOKEN_LEFTBRACE; ; index = 137 ; length = 1 line = 4 ; column = 61 ; value ='{'; }
|
||||||
|
{kind = TOKEN_RETURN; ; index = 141 ; length = 6 line = 5 ; column = 0 ; value ='return'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 148 ; length = 1 line = 5 ; column = 7 ; value ='x'; }
|
||||||
|
{kind = TOKEN_STAR; ; index = 150 ; length = 1 line = 5 ; column = 9 ; value ='*'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 152 ; length = 1 line = 5 ; column = 11 ; value ='y'; }
|
||||||
|
{kind = TOKEN_STAR; ; index = 154 ; length = 1 line = 5 ; column = 13 ; value ='*'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 156 ; length = 1 line = 5 ; column = 15 ; value ='z'; }
|
||||||
|
{kind = TOKEN_STAR; ; index = 158 ; length = 1 line = 5 ; column = 17 ; value ='*'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 160 ; length = 1 line = 5 ; column = 19 ; value ='w'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 161 ; length = 1 line = 5 ; column = 20 ; value =';'; }
|
||||||
|
{kind = TOKEN_RIGHTBRACE; ; index = 164 ; length = 1 line = 6 ; column = 0 ; value ='}'; }
|
||||||
|
{kind = TOKEN_VERTEX; ; index = 169 ; length = 6 line = 8 ; column = 0 ; value ='vertex'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 176 ; length = 4 line = 8 ; column = 7 ; value ='main'; }
|
||||||
|
{kind = TOKEN_DOUBLECOLON; ; index = 181 ; length = 2 line = 8 ; column = 12 ; value ='::'; }
|
||||||
|
{kind = TOKEN_LEFTPAREN; ; index = 184 ; length = 1 line = 8 ; column = 15 ; value ='('; }
|
||||||
|
{kind = TOKEN_RIGHTPAREN; ; index = 185 ; length = 1 line = 8 ; column = 16 ; value =')'; }
|
||||||
|
{kind = TOKEN_LEFTBRACE; ; index = 187 ; length = 1 line = 8 ; column = 18 ; value ='{'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 191 ; length = 3 line = 9 ; column = 0 ; value ='foo'; }
|
||||||
|
{kind = TOKEN_LEFTPAREN; ; index = 194 ; length = 1 line = 9 ; column = 3 ; value ='('; }
|
||||||
|
{kind = TOKEN_FLOATLITERAL; ; index = 195 ; length = 3 line = 9 ; column = 4 ; value ='2'; }
|
||||||
|
{kind = TOKEN_COMMA; ; index = 198 ; length = 1 line = 9 ; column = 7 ; value =','; }
|
||||||
|
{kind = TOKEN_FLOATLITERAL; ; index = 200 ; length = 3 line = 9 ; column = 9 ; value ='3'; }
|
||||||
|
{kind = TOKEN_RIGHTPAREN; ; index = 203 ; length = 1 line = 9 ; column = 12 ; value =')'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 204 ; length = 1 line = 9 ; column = 13 ; value =';'; }
|
||||||
|
{kind = TOKEN_RIGHTBRACE; ; index = 207 ; length = 1 line = 10 ; column = 0 ; value ='}'; }
|
||||||
|
{kind = TOKEN_EOF; ; index = 212 ; length = 0 line = 12 ; column = 0 ; value =''; }
|
||||||
54
test/lex/wrong_multiply.golden
Normal file
54
test/lex/wrong_multiply.golden
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
{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 ='float4'; }
|
||||||
|
{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_IDENTIFIER; ; index = 64 ; length = 3 line = 2 ; column = 0 ; value ='res'; }
|
||||||
|
{kind = TOKEN_COLON; ; index = 68 ; length = 1 line = 2 ; column = 4 ; value =':'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 70 ; length = 6 line = 2 ; column = 6 ; value ='float2'; }
|
||||||
|
{kind = TOKEN_ASSIGN; ; index = 77 ; length = 1 line = 2 ; column = 13 ; value ='='; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 79 ; length = 6 line = 2 ; column = 15 ; value ='float2'; }
|
||||||
|
{kind = TOKEN_LEFTPAREN; ; index = 85 ; length = 1 line = 2 ; column = 21 ; value ='('; }
|
||||||
|
{kind = TOKEN_FLOATLITERAL; ; index = 86 ; length = 3 line = 2 ; column = 22 ; value ='2'; }
|
||||||
|
{kind = TOKEN_COMMA; ; index = 89 ; length = 1 line = 2 ; column = 25 ; value =','; }
|
||||||
|
{kind = TOKEN_FLOATLITERAL; ; index = 91 ; length = 3 line = 2 ; column = 27 ; value ='2'; }
|
||||||
|
{kind = TOKEN_RIGHTPAREN; ; index = 94 ; length = 1 line = 2 ; column = 30 ; value =')'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 95 ; length = 1 line = 2 ; column = 31 ; value =';'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 99 ; length = 3 line = 3 ; column = 0 ; value ='foo'; }
|
||||||
|
{kind = TOKEN_COLON; ; index = 103 ; length = 1 line = 3 ; column = 4 ; value =':'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 105 ; length = 5 line = 3 ; column = 6 ; value ='float'; }
|
||||||
|
{kind = TOKEN_ASSIGN; ; index = 111 ; length = 1 line = 3 ; column = 12 ; value ='='; }
|
||||||
|
{kind = TOKEN_FLOATLITERAL; ; index = 113 ; length = 3 line = 3 ; column = 14 ; value ='1'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 116 ; length = 1 line = 3 ; column = 17 ; value =';'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 120 ; length = 6 line = 4 ; column = 0 ; value ='result'; }
|
||||||
|
{kind = TOKEN_COLON; ; index = 127 ; length = 1 line = 4 ; column = 7 ; value =':'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 129 ; length = 6 line = 4 ; column = 9 ; value ='float4'; }
|
||||||
|
{kind = TOKEN_ASSIGN; ; index = 136 ; length = 1 line = 4 ; column = 16 ; value ='='; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 138 ; length = 6 line = 4 ; column = 18 ; value ='float4'; }
|
||||||
|
{kind = TOKEN_LEFTPAREN; ; index = 144 ; length = 1 line = 4 ; column = 24 ; value ='('; }
|
||||||
|
{kind = TOKEN_FLOATLITERAL; ; index = 145 ; length = 3 line = 4 ; column = 25 ; value ='1'; }
|
||||||
|
{kind = TOKEN_COMMA; ; index = 148 ; length = 1 line = 4 ; column = 28 ; value =','; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 150 ; length = 3 line = 4 ; column = 30 ; value ='foo'; }
|
||||||
|
{kind = TOKEN_STAR; ; index = 154 ; length = 1 line = 4 ; column = 34 ; value ='*'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 156 ; length = 3 line = 4 ; column = 36 ; value ='res'; }
|
||||||
|
{kind = TOKEN_COMMA; ; index = 159 ; length = 1 line = 4 ; column = 39 ; value =','; }
|
||||||
|
{kind = TOKEN_FLOATLITERAL; ; index = 161 ; length = 3 line = 4 ; column = 41 ; value ='0'; }
|
||||||
|
{kind = TOKEN_COMMA; ; index = 164 ; length = 1 line = 4 ; column = 44 ; value =','; }
|
||||||
|
{kind = TOKEN_FLOATLITERAL; ; index = 166 ; length = 3 line = 4 ; column = 46 ; value ='1'; }
|
||||||
|
{kind = TOKEN_RIGHTPAREN; ; index = 169 ; length = 1 line = 4 ; column = 49 ; value =')'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 170 ; length = 1 line = 4 ; column = 50 ; value =';'; }
|
||||||
|
{kind = TOKEN_RETURN; ; index = 174 ; length = 6 line = 5 ; column = 0 ; value ='return'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 181 ; length = 6 line = 5 ; column = 7 ; value ='result'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 187 ; length = 1 line = 5 ; column = 13 ; value =';'; }
|
||||||
|
{kind = TOKEN_RIGHTBRACE; ; index = 190 ; length = 1 line = 6 ; column = 0 ; value ='}'; }
|
||||||
|
{kind = TOKEN_EOF; ; index = 193 ; length = 0 line = 7 ; column = 0 ; value =''; }
|
||||||
73
test/lex/wrong_type_for_function.golden
Normal file
73
test/lex/wrong_type_for_function.golden
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
{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 ='float3'; }
|
||||||
|
{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_RETURN; ; index = 64 ; length = 6 line = 2 ; column = 0 ; value ='return'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 71 ; length = 3 line = 2 ; column = 7 ; value ='pos'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 74 ; length = 1 line = 2 ; column = 10 ; value =';'; }
|
||||||
|
{kind = TOKEN_RIGHTBRACE; ; index = 77 ; length = 1 line = 3 ; column = 0 ; value ='}'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 82 ; length = 3 line = 5 ; column = 0 ; value ='foo'; }
|
||||||
|
{kind = TOKEN_DOUBLECOLON; ; index = 86 ; length = 2 line = 5 ; column = 4 ; value ='::'; }
|
||||||
|
{kind = TOKEN_LEFTPAREN; ; index = 89 ; length = 1 line = 5 ; column = 7 ; value ='('; }
|
||||||
|
{kind = TOKEN_RIGHTPAREN; ; index = 90 ; length = 1 line = 5 ; column = 8 ; value =')'; }
|
||||||
|
{kind = TOKEN_ARROW; ; index = 92 ; length = 2 line = 5 ; column = 10 ; value ='->'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 95 ; length = 6 line = 5 ; column = 13 ; value ='float2'; }
|
||||||
|
{kind = TOKEN_LEFTBRACE; ; index = 102 ; length = 1 line = 5 ; column = 20 ; value ='{'; }
|
||||||
|
{kind = TOKEN_RETURN; ; index = 106 ; length = 6 line = 6 ; column = 0 ; value ='return'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 113 ; length = 6 line = 6 ; column = 7 ; value ='float2'; }
|
||||||
|
{kind = TOKEN_LEFTPAREN; ; index = 119 ; length = 1 line = 6 ; column = 13 ; value ='('; }
|
||||||
|
{kind = TOKEN_FLOATLITERAL; ; index = 120 ; length = 3 line = 6 ; column = 14 ; value ='1'; }
|
||||||
|
{kind = TOKEN_COMMA; ; index = 123 ; length = 1 line = 6 ; column = 17 ; value =','; }
|
||||||
|
{kind = TOKEN_FLOATLITERAL; ; index = 125 ; length = 3 line = 6 ; column = 19 ; value ='1'; }
|
||||||
|
{kind = TOKEN_RIGHTPAREN; ; index = 128 ; length = 1 line = 6 ; column = 22 ; value =')'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 129 ; length = 1 line = 6 ; column = 23 ; value =';'; }
|
||||||
|
{kind = TOKEN_RIGHTBRACE; ; index = 132 ; length = 1 line = 7 ; column = 0 ; value ='}'; }
|
||||||
|
{kind = TOKEN_PIXEL; ; index = 137 ; length = 5 line = 9 ; column = 0 ; value ='pixel'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 143 ; length = 4 line = 9 ; column = 6 ; value ='main'; }
|
||||||
|
{kind = TOKEN_DOUBLECOLON; ; index = 148 ; length = 2 line = 9 ; column = 11 ; value ='::'; }
|
||||||
|
{kind = TOKEN_LEFTPAREN; ; index = 151 ; length = 1 line = 9 ; column = 14 ; value ='('; }
|
||||||
|
{kind = TOKEN_RIGHTPAREN; ; index = 152 ; length = 1 line = 9 ; column = 15 ; value =')'; }
|
||||||
|
{kind = TOKEN_ARROW; ; index = 154 ; length = 2 line = 9 ; column = 17 ; value ='->'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 157 ; length = 6 line = 9 ; column = 20 ; value ='float4'; }
|
||||||
|
{kind = TOKEN_AT; ; index = 164 ; length = 1 line = 9 ; column = 27 ; value ='@'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 165 ; length = 7 line = 9 ; column = 28 ; value ='target0'; }
|
||||||
|
{kind = TOKEN_LEFTBRACE; ; index = 173 ; length = 1 line = 9 ; column = 36 ; value ='{'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 177 ; length = 1 line = 10 ; column = 0 ; value ='y'; }
|
||||||
|
{kind = TOKEN_COLON; ; index = 179 ; length = 1 line = 10 ; column = 2 ; value =':'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 181 ; length = 6 line = 10 ; column = 4 ; value ='float2'; }
|
||||||
|
{kind = TOKEN_ASSIGN; ; index = 188 ; length = 1 line = 10 ; column = 11 ; value ='='; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 190 ; length = 3 line = 10 ; column = 13 ; value ='foo'; }
|
||||||
|
{kind = TOKEN_LEFTPAREN; ; index = 193 ; length = 1 line = 10 ; column = 16 ; value ='('; }
|
||||||
|
{kind = TOKEN_RIGHTPAREN; ; index = 194 ; length = 1 line = 10 ; column = 17 ; value =')'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 195 ; length = 1 line = 10 ; column = 18 ; value =';'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 199 ; length = 5 line = 11 ; column = 0 ; value ='color'; }
|
||||||
|
{kind = TOKEN_COLON; ; index = 205 ; length = 1 line = 11 ; column = 6 ; value =':'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 207 ; length = 6 line = 11 ; column = 8 ; value ='float4'; }
|
||||||
|
{kind = TOKEN_ASSIGN; ; index = 214 ; length = 1 line = 11 ; column = 15 ; value ='='; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 216 ; length = 6 line = 11 ; column = 17 ; value ='float4'; }
|
||||||
|
{kind = TOKEN_LEFTPAREN; ; index = 222 ; length = 1 line = 11 ; column = 23 ; value ='('; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 223 ; length = 1 line = 11 ; column = 24 ; value ='y'; }
|
||||||
|
{kind = TOKEN_COMMA; ; index = 224 ; length = 1 line = 11 ; column = 25 ; value =','; }
|
||||||
|
{kind = TOKEN_FLOATLITERAL; ; index = 226 ; length = 3 line = 11 ; column = 27 ; value ='1'; }
|
||||||
|
{kind = TOKEN_COMMA; ; index = 229 ; length = 1 line = 11 ; column = 30 ; value =','; }
|
||||||
|
{kind = TOKEN_FLOATLITERAL; ; index = 231 ; length = 3 line = 11 ; column = 32 ; value ='1'; }
|
||||||
|
{kind = TOKEN_COMMA; ; index = 234 ; length = 1 line = 11 ; column = 35 ; value =','; }
|
||||||
|
{kind = TOKEN_FLOATLITERAL; ; index = 236 ; length = 3 line = 11 ; column = 37 ; value ='1'; }
|
||||||
|
{kind = TOKEN_RIGHTPAREN; ; index = 239 ; length = 1 line = 11 ; column = 40 ; value =')'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 240 ; length = 1 line = 11 ; column = 41 ; value =';'; }
|
||||||
|
{kind = TOKEN_RETURN; ; index = 244 ; length = 6 line = 12 ; column = 0 ; value ='return'; }
|
||||||
|
{kind = TOKEN_IDENTIFIER; ; index = 251 ; length = 5 line = 12 ; column = 7 ; value ='color'; }
|
||||||
|
{kind = TOKEN_SEMICOLON; ; index = 256 ; length = 1 line = 12 ; column = 12 ; value =';'; }
|
||||||
|
{kind = TOKEN_RIGHTBRACE; ; index = 259 ; length = 1 line = 13 ; column = 0 ; value ='}'; }
|
||||||
|
{kind = TOKEN_EOF; ; index = 262 ; length = 0 line = 14 ; column = 0 ; value =''; }
|
||||||
32
test/lex_all.suite
Normal file
32
test/lex_all.suite
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
test/assign_arithmetic_expression.shd lex
|
||||||
|
test/basic_property_and_return_value.shd lex
|
||||||
|
test/complicated_computation.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
|
||||||
16
test/meta_block.shd
Normal file
16
test/meta_block.shd
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
meta {
|
||||||
|
name : LitBasic;
|
||||||
|
category : Scene;
|
||||||
|
}
|
||||||
|
|
||||||
|
properties {
|
||||||
|
color : float4;
|
||||||
|
}
|
||||||
|
|
||||||
|
vertex main :: (pos : float3 @position, uv : float2 @uv) -> float3 @position {
|
||||||
|
return pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
pixel main :: () -> float4 @target0 {
|
||||||
|
return properties.color;
|
||||||
|
}
|
||||||
12
test/multiple_functions.shd
Normal file
12
test/multiple_functions.shd
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
foo :: () -> int {
|
||||||
|
return 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
bar :: () -> float {
|
||||||
|
return 1235.0 * 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
vertex main :: () {
|
||||||
|
x : int = foo();
|
||||||
|
y : float = bar();
|
||||||
|
}
|
||||||
14
test/multiple_semicolons_everywhere.shd
Normal file
14
test/multiple_semicolons_everywhere.shd
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
vertex main :: (pos : float3 @position) -> float3 @position {
|
||||||
|
return pos;;;
|
||||||
|
}
|
||||||
|
|
||||||
|
foo :: () -> float4 {
|
||||||
|
return float4(1.0, 1.0, 1.0, 1.0);;;
|
||||||
|
}
|
||||||
|
|
||||||
|
pixel main :: () -> float4 @target0 {
|
||||||
|
y : float4 = foo();;;;
|
||||||
|
;;
|
||||||
|
color : float4 = y;
|
||||||
|
return color;
|
||||||
|
}
|
||||||
4
test/parse/assign_arithmetic_expression.golden
Normal file
4
test/parse/assign_arithmetic_expression.golden
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
(program
|
||||||
|
(fun vertex vs_main
|
||||||
|
[]
|
||||||
|
(:= x float (+ 2 5))))
|
||||||
11
test/parse/basic_property_and_return_value.golden
Normal file
11
test/parse/basic_property_and_return_value.golden
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
(program
|
||||||
|
(properties
|
||||||
|
[(:= color float4)])
|
||||||
|
|
||||||
|
(fun vertex vs_main -> float3 (@position)
|
||||||
|
[(:= pos float3 (@position))]
|
||||||
|
(return pos))
|
||||||
|
|
||||||
|
(fun pixel ps_main -> float4 (@target0)
|
||||||
|
[]
|
||||||
|
(return properties.color)))
|
||||||
6
test/parse/complicated_computation.golden
Normal file
6
test/parse/complicated_computation.golden
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
(program
|
||||||
|
(fun vertex vs_main
|
||||||
|
[]
|
||||||
|
(:= x float 5)
|
||||||
|
(:= y float 3000)
|
||||||
|
(:= z float (+ (* y y) x))))
|
||||||
3
test/parse/empty_struct.golden
Normal file
3
test/parse/empty_struct.golden
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
(program
|
||||||
|
(struct Foo
|
||||||
|
[]))
|
||||||
3
test/parse/empty_vertex_main.golden
Normal file
3
test/parse/empty_vertex_main.golden
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
(program
|
||||||
|
(fun vertex vs_main
|
||||||
|
[]))
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
(program
|
||||||
|
(fun vertex vs_main -> float3
|
||||||
|
[(:= pos float3 (@position))]
|
||||||
|
(return pos)))
|
||||||
5
test/parse/field_assignment.golden
Normal file
5
test/parse/field_assignment.golden
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
(program
|
||||||
|
(fun vertex vs_main -> float4 (@position)
|
||||||
|
[(:= pos float4 (@position))]
|
||||||
|
(:= x float 5)
|
||||||
|
(= x 7)))
|
||||||
4
test/parse/field_without_type_specifier.golden
Normal file
4
test/parse/field_without_type_specifier.golden
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
[1;37mtest/field_without_type_specifier.shd:2,0: [31merror: [37mExpected type specifier after field name.
|
||||||
|
[96mx := 5.0;
|
||||||
|
^
|
||||||
|
[36m[37m
|
||||||
15
test/parse/foreign_function.golden
Normal file
15
test/parse/foreign_function.golden
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
(program
|
||||||
|
(foreign fun float2 -> float2
|
||||||
|
[(:= float)
|
||||||
|
(:= float)])
|
||||||
|
|
||||||
|
(foreign fun float3 -> float3
|
||||||
|
[(:= float)
|
||||||
|
(:= float)
|
||||||
|
(:= float)])
|
||||||
|
|
||||||
|
(foreign fun float4 -> float4
|
||||||
|
[(:= float)
|
||||||
|
(:= float)
|
||||||
|
(:= float)
|
||||||
|
(:= float)]))
|
||||||
26
test/parse/foreign_overload.golden
Normal file
26
test/parse/foreign_overload.golden
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
(program
|
||||||
|
(foreign fun mul -> float2
|
||||||
|
[(:= float2)
|
||||||
|
(:= float2)])
|
||||||
|
|
||||||
|
(foreign fun mul -> float3
|
||||||
|
[(:= float3)
|
||||||
|
(:= float3)])
|
||||||
|
|
||||||
|
(foreign fun mul -> float4
|
||||||
|
[(:= float4)
|
||||||
|
(:= float4)])
|
||||||
|
|
||||||
|
(foreign fun mul -> float4x4
|
||||||
|
[(:= float4x4)
|
||||||
|
(:= float4x4)])
|
||||||
|
|
||||||
|
(foreign fun float2 -> float2
|
||||||
|
[(:= float)
|
||||||
|
(:= float)])
|
||||||
|
|
||||||
|
(fun vertex vs_main
|
||||||
|
[]
|
||||||
|
(:= v1 float2 (float2 1 1))
|
||||||
|
(:= v2 float2 (float2 3 3))
|
||||||
|
(:= v3 float2 (mul v1 v2))))
|
||||||
8
test/parse/function_call.golden
Normal file
8
test/parse/function_call.golden
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
(program
|
||||||
|
(fun foo -> int
|
||||||
|
[]
|
||||||
|
(return 4))
|
||||||
|
|
||||||
|
(fun vertex vs_main
|
||||||
|
[]
|
||||||
|
(foo)))
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user