Some bugfixes/added errors, convert most to not use simple_passthrough
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
kraken="kraken"
|
kraken="kraken"
|
||||||
bootstrap_commits=(cf46fb13afe66ba475db9725e9269c9c1cd3bbc3 2cd43e5a217318c70097334b3598d2924f64b362 2051f54b559ac5edf67277d4f1134aca2cb9215d ecbbcb4eda56e2467efb0a04e7d668b95856aa4b)
|
bootstrap_commits=(cf46fb13afe66ba475db9725e9269c9c1cd3bbc3 2cd43e5a217318c70097334b3598d2924f64b362 2051f54b559ac5edf67277d4f1134aca2cb9215d ecbbcb4eda56e2467efb0a04e7d668b95856aa4b d126cbf24ba8b26e3814e2260d555ecaee86508c)
|
||||||
|
|
||||||
# Echo version string to a file included by kraken.krak
|
# Echo version string to a file included by kraken.krak
|
||||||
# There is a default version string in the file in case kraken is not built with captain
|
# There is a default version string in the file in case kraken is not built with captain
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ fun main(argc: int, argv: **char):int {
|
|||||||
println("Generating C")
|
println("Generating C")
|
||||||
/*println("NOW DOING C_GENERATOR")*/
|
/*println("NOW DOING C_GENERATOR")*/
|
||||||
var c_generator.construct(): c_generator
|
var c_generator.construct(): c_generator
|
||||||
var c_output_pair = c_generator.generate_c(importer.name_ast_map)
|
var c_output_pair = c_generator.generate_c(importer.name_ast_map, importer.ast_pass.ast_to_syntax)
|
||||||
var kraken_c_output_name = kraken_file_name + ".c"
|
var kraken_c_output_name = kraken_file_name + ".c"
|
||||||
write_file(kraken_c_output_name, c_output_pair.first)
|
write_file(kraken_c_output_name, c_output_pair.first)
|
||||||
/*println(string("linker string: ") + c_output_pair.second)*/
|
/*println(string("linker string: ") + c_output_pair.second)*/
|
||||||
|
|||||||
@@ -615,7 +615,7 @@ obj ast_transformation (Object) {
|
|||||||
identifier->identifier.type = get_ast_type(expression)->clone_without_ref()
|
identifier->identifier.type = get_ast_type(expression)->clone_without_ref()
|
||||||
}
|
}
|
||||||
if (!identifier->identifier.type) error(node, "declaration statement with no type or expression from which to inference type")
|
if (!identifier->identifier.type) error(node, "declaration statement with no type or expression from which to inference type")
|
||||||
if (identifier->identifier.type->is_none()) error(node, "declaration statement with bad type")
|
if (identifier->identifier.type->is_none() || (identifier->identifier.type->indirection == 0 && identifier->identifier.type->is_void())) error(node, "declaration statement with bad type")
|
||||||
var declaration = ast_declaration_statement_ptr(identifier, expression)
|
var declaration = ast_declaration_statement_ptr(identifier, expression)
|
||||||
// ok, deal with the possible init position method call
|
// ok, deal with the possible init position method call
|
||||||
if (identifiers.size == 2) {
|
if (identifiers.size == 2) {
|
||||||
@@ -716,9 +716,13 @@ obj ast_transformation (Object) {
|
|||||||
}
|
}
|
||||||
fun transform_return_statement(node: *tree<symbol>, scope: *ast_node, template_replacements: map<string, *type>): *ast_node {
|
fun transform_return_statement(node: *tree<symbol>, scope: *ast_node, template_replacements: map<string, *type>): *ast_node {
|
||||||
var return_value = get_node("boolean_expression", node)
|
var return_value = get_node("boolean_expression", node)
|
||||||
|
var to_ret: *ast_node
|
||||||
if (return_value)
|
if (return_value)
|
||||||
return ast_return_statement_ptr(transform(return_value, scope, template_replacements))
|
to_ret = ast_return_statement_ptr(transform(return_value, scope, template_replacements))
|
||||||
return ast_return_statement_ptr(null<ast_node>())
|
else
|
||||||
|
to_ret = ast_return_statement_ptr(null<ast_node>())
|
||||||
|
ast_to_syntax.set(to_ret, node)
|
||||||
|
return to_ret
|
||||||
}
|
}
|
||||||
fun transform_branching_statement(node: *tree<symbol>, scope: *ast_node): *ast_node {
|
fun transform_branching_statement(node: *tree<symbol>, scope: *ast_node): *ast_node {
|
||||||
if (node->data.name == "break_statement")
|
if (node->data.name == "break_statement")
|
||||||
@@ -778,8 +782,8 @@ obj ast_transformation (Object) {
|
|||||||
parameters = get_nodes("intrinsic_parameter", node).map(fun(child: *tree<symbol>): string return concat_symbol_tree(child);)
|
parameters = get_nodes("intrinsic_parameter", node).map(fun(child: *tree<symbol>): string return concat_symbol_tree(child);)
|
||||||
if (get_nodes("type", node).size)
|
if (get_nodes("type", node).size)
|
||||||
type_parameters = get_nodes("type", node).map(fun(child: *tree<symbol>): *type return transform_type(child, scope, template_replacements);)
|
type_parameters = get_nodes("type", node).map(fun(child: *tree<symbol>): *type return transform_type(child, scope, template_replacements);)
|
||||||
/*return ast_compiler_intrinsic_ptr(concat_symbol_tree(get_node("identifier", node)), parameters, type_parameters, type_ptr(base_type::ulong_int()))*/
|
return ast_compiler_intrinsic_ptr(concat_symbol_tree(get_node("identifier", node)), parameters, type_parameters, type_ptr(base_type::ulong_int()))
|
||||||
return ast_compiler_intrinsic_ptr(concat_symbol_tree(get_node("identifier", node)), parameters, type_parameters, type_ptr(base_type::integer()))
|
/*return ast_compiler_intrinsic_ptr(concat_symbol_tree(get_node("identifier", node)), parameters, type_parameters, type_ptr(base_type::integer()))*/
|
||||||
}
|
}
|
||||||
fun transform_lambda(node: *tree<symbol>, scope: *ast_node, template_replacements: map<string, *type>): *ast_node {
|
fun transform_lambda(node: *tree<symbol>, scope: *ast_node, template_replacements: map<string, *type>): *ast_node {
|
||||||
var function_node = second_pass_function(node, scope, template_replacements, false)
|
var function_node = second_pass_function(node, scope, template_replacements, false)
|
||||||
|
|||||||
@@ -75,6 +75,7 @@ obj code_triple (Object) {
|
|||||||
|
|
||||||
obj c_generator (Object) {
|
obj c_generator (Object) {
|
||||||
var id_counter: int
|
var id_counter: int
|
||||||
|
var ast_to_syntax: map<*ast_node, *tree<symbol>>
|
||||||
var ast_name_map: map<*ast_node, string>
|
var ast_name_map: map<*ast_node, string>
|
||||||
var closure_struct_map: map<set<*ast_node>, string>
|
var closure_struct_map: map<set<*ast_node>, string>
|
||||||
var function_type_map: map<type, string>
|
var function_type_map: map<type, string>
|
||||||
@@ -86,6 +87,7 @@ obj c_generator (Object) {
|
|||||||
var linker_string: string
|
var linker_string: string
|
||||||
fun construct(): *c_generator {
|
fun construct(): *c_generator {
|
||||||
id_counter = 0
|
id_counter = 0
|
||||||
|
ast_to_syntax.construct()
|
||||||
ast_name_map.construct()
|
ast_name_map.construct()
|
||||||
closure_struct_map.construct()
|
closure_struct_map.construct()
|
||||||
function_type_map.construct()
|
function_type_map.construct()
|
||||||
@@ -144,6 +146,7 @@ obj c_generator (Object) {
|
|||||||
}
|
}
|
||||||
fun copy_construct(old: *c_generator) {
|
fun copy_construct(old: *c_generator) {
|
||||||
id_counter = old->id_counter
|
id_counter = old->id_counter
|
||||||
|
ast_to_syntax.copy_construct(&old->ast_to_syntax)
|
||||||
ast_name_map.copy_construct(&old->ast_name_map)
|
ast_name_map.copy_construct(&old->ast_name_map)
|
||||||
closure_struct_map.copy_construct(&old->closure_struct_map)
|
closure_struct_map.copy_construct(&old->closure_struct_map)
|
||||||
function_type_map.copy_construct(&old->function_type_map)
|
function_type_map.copy_construct(&old->function_type_map)
|
||||||
@@ -159,6 +162,7 @@ obj c_generator (Object) {
|
|||||||
copy_construct(&other)
|
copy_construct(&other)
|
||||||
}
|
}
|
||||||
fun destruct() {
|
fun destruct() {
|
||||||
|
ast_to_syntax.destruct()
|
||||||
ast_name_map.destruct()
|
ast_name_map.destruct()
|
||||||
closure_struct_map.destruct()
|
closure_struct_map.destruct()
|
||||||
function_type_map.destruct()
|
function_type_map.destruct()
|
||||||
@@ -205,8 +209,9 @@ obj c_generator (Object) {
|
|||||||
return make_pair(type_to_c(backing.type->return_type) + " " + decorated_name + "(" + parameter_types + ");\n",
|
return make_pair(type_to_c(backing.type->return_type) + " " + decorated_name + "(" + parameter_types + ");\n",
|
||||||
type_to_c(backing.type->return_type) + " " + decorated_name + "(" + parameters + ")")
|
type_to_c(backing.type->return_type) + " " + decorated_name + "(" + parameters + ")")
|
||||||
}
|
}
|
||||||
fun generate_c(name_ast_map: map<string, pair<*tree<symbol>,*ast_node>>): pair<string,string> {
|
fun generate_c(name_ast_map: map<string, pair<*tree<symbol>,*ast_node>>, ast_to_syntax_in: map<*ast_node, *tree<symbol>> ): pair<string,string> {
|
||||||
var prequal: string = "#include <stdbool.h>\n#include <stdlib.h>\n#include <stdio.h>\n"
|
ast_to_syntax = ast_to_syntax_in
|
||||||
|
var prequal: string = "#include <stdbool.h>\n"
|
||||||
var plain_typedefs: string = "\n/**Plain Typedefs**/\n"
|
var plain_typedefs: string = "\n/**Plain Typedefs**/\n"
|
||||||
var top_level_c_passthrough: string = ""
|
var top_level_c_passthrough: string = ""
|
||||||
var variable_extern_declarations: string = ""
|
var variable_extern_declarations: string = ""
|
||||||
@@ -371,8 +376,7 @@ obj c_generator (Object) {
|
|||||||
ast_node::declaration_statement(backing) variable_declarations += generate_declaration_statement(child, null<ast_node>(), null<ast_node>(), null<stack<pair<bool,stack<*ast_node>>>>(), false).one_string() + ";\n" // false - don't do defer
|
ast_node::declaration_statement(backing) variable_declarations += generate_declaration_statement(child, null<ast_node>(), null<ast_node>(), null<stack<pair<bool,stack<*ast_node>>>>(), false).one_string() + ";\n" // false - don't do defer
|
||||||
ast_node::function(backing) {
|
ast_node::function(backing) {
|
||||||
// check for and add to parameters if a closure
|
// check for and add to parameters if a closure
|
||||||
if (!backing.is_extern)
|
generate_function_definition(child, null<ast_node>(), false)
|
||||||
generate_function_definition(child, null<ast_node>(), false)
|
|
||||||
}
|
}
|
||||||
ast_node::template(backing) {
|
ast_node::template(backing) {
|
||||||
backing.instantiated.for_each(fun(node: *ast_node) {
|
backing.instantiated.for_each(fun(node: *ast_node) {
|
||||||
@@ -446,7 +450,8 @@ obj c_generator (Object) {
|
|||||||
structs += "};\n"
|
structs += "};\n"
|
||||||
})
|
})
|
||||||
|
|
||||||
return make_pair(prequal+plain_typedefs+top_level_c_passthrough+variable_extern_declarations+structs+function_typedef_string+closure_struct_definitions+function_prototypes+variable_declarations+function_definitions + "\n", linker_string)
|
/*return make_pair(prequal+plain_typedefs+top_level_c_passthrough+variable_extern_declarations+structs+function_typedef_string+closure_struct_definitions+function_prototypes+variable_declarations+function_definitions + "\n", linker_string)*/
|
||||||
|
return make_pair(prequal+plain_typedefs+function_typedef_string+top_level_c_passthrough+variable_extern_declarations+structs+closure_struct_definitions+function_prototypes+variable_declarations+function_definitions + "\n", linker_string)
|
||||||
}
|
}
|
||||||
fun get_closure_struct_type(closed_variables: set<*ast_node>): string {
|
fun get_closure_struct_type(closed_variables: set<*ast_node>): string {
|
||||||
if (!closure_struct_map.contains_key(closed_variables)) {
|
if (!closure_struct_map.contains_key(closed_variables)) {
|
||||||
@@ -599,7 +604,7 @@ obj c_generator (Object) {
|
|||||||
to_ret.pre = generate_declaration_statement(declaration, enclosing_object, enclosing_func, defer_stack, false).one_string() + ";\n"
|
to_ret.pre = generate_declaration_statement(declaration, enclosing_object, enclosing_func, defer_stack, false).one_string() + ";\n"
|
||||||
if ((function_return_type->is_object() || return_value_type->is_object()) && !function_return_type->equality(return_value_type, false))
|
if ((function_return_type->is_object() || return_value_type->is_object()) && !function_return_type->equality(return_value_type, false))
|
||||||
// note the clone with decreased indirection because of the clone with increased indirection above
|
// note the clone with decreased indirection because of the clone with increased indirection above
|
||||||
error(string("return type does not match: ") + function_return_type->to_string() + ", " + return_value_type->to_string());
|
error(ast_to_syntax[node], string("return type does not match: ") + function_return_type->to_string() + ", " + return_value_type->to_string());
|
||||||
if (!function_return_type->is_ref && return_value_type->indirection == 0 && (return_value_type->is_adt() || (return_value_type->is_object() && has_method(return_value_type->type_def, "copy_construct", vector(return_value_type->clone_with_indirection(1)))))) {
|
if (!function_return_type->is_ref && return_value_type->indirection == 0 && (return_value_type->is_adt() || (return_value_type->is_object() && has_method(return_value_type->type_def, "copy_construct", vector(return_value_type->clone_with_indirection(1)))))) {
|
||||||
to_ret.pre += generate_statement(ast_statement_ptr(make_method_call(temp_ident, "copy_construct", vector(make_operator_call("&", vector(return_value))))), enclosing_object, enclosing_func, defer_stack).one_string()
|
to_ret.pre += generate_statement(ast_statement_ptr(make_method_call(temp_ident, "copy_construct", vector(make_operator_call("&", vector(return_value))))), enclosing_object, enclosing_func, defer_stack).one_string()
|
||||||
} else {
|
} else {
|
||||||
@@ -724,7 +729,7 @@ obj c_generator (Object) {
|
|||||||
if (as_value) {
|
if (as_value) {
|
||||||
var closed_vars = node->function.closed_variables
|
var closed_vars = node->function.closed_variables
|
||||||
if (closed_vars.size() == 0)
|
if (closed_vars.size() == 0)
|
||||||
return code_triple(string("((") + type_to_c(node->function.type) + "){(void*)NULL,(void*)" + get_name(node) + "})")
|
return code_triple(string("((") + type_to_c(node->function.type) + "){(void*)0,(void*)" + get_name(node) + "})")
|
||||||
var temp_closure_struct = string("closure_struct_temp") + get_id()
|
var temp_closure_struct = string("closure_struct_temp") + get_id()
|
||||||
var to_ret = code_triple()
|
var to_ret = code_triple()
|
||||||
var closure_type_str = get_closure_struct_type(closed_vars)
|
var closure_type_str = get_closure_struct_type(closed_vars)
|
||||||
|
|||||||
@@ -4,9 +4,7 @@ __if_comp__ __C__ simple_passthrough(::"-pthread") """
|
|||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def pthread_t float
|
fun pthread_create(thrd : *ulong, strt_routine : fun() : void) : int {
|
||||||
|
|
||||||
fun pthread_create(thrd : *pthread_t, strt_routine : fun() : void) : int {
|
|
||||||
__if_comp__ __C__ {
|
__if_comp__ __C__ {
|
||||||
simple_passthrough(thrd,strt_routine::) """
|
simple_passthrough(thrd,strt_routine::) """
|
||||||
pthread_attr_t attr;
|
pthread_attr_t attr;
|
||||||
@@ -20,7 +18,7 @@ fun pthread_create(thrd : *pthread_t, strt_routine : fun() : void) : int {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
fun pthread_join(thrd : *pthread_t) : int {
|
fun pthread_join(thrd : *ulong) : int {
|
||||||
__if_comp__ __C__ { simple_passthrough(thrd::) """
|
__if_comp__ __C__ { simple_passthrough(thrd::) """
|
||||||
pthread_t thread = *((pthread_t*)thrd);
|
pthread_t thread = *((pthread_t*)thrd);
|
||||||
return pthread_join(thread, NULL);
|
return pthread_join(thread, NULL);
|
||||||
@@ -48,7 +46,7 @@ obj future<T> {
|
|||||||
var status : int
|
var status : int
|
||||||
var psy : fun() : T
|
var psy : fun() : T
|
||||||
var wrapper : fun() : void
|
var wrapper : fun() : void
|
||||||
var thread : pthread_t
|
var thread : ulong
|
||||||
|
|
||||||
fun construct(in : fun() : T) : *future<T> {
|
fun construct(in : fun() : T) : *future<T> {
|
||||||
status = 0
|
status = 0
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ obj hash_map<T,U> (Object, Serializable) {
|
|||||||
/*io::println((this) cast int)*/
|
/*io::println((this) cast int)*/
|
||||||
/*io::print("size of data:")*/
|
/*io::print("size of data:")*/
|
||||||
/*io::println(data.size)*/
|
/*io::println(data.size)*/
|
||||||
var key_hash = util::hash(key)
|
var key_hash = (util::hash(key)) cast int
|
||||||
if (!data[key_hash%data.size].contains_key(key)) {
|
if (!data[key_hash%data.size].contains_key(key)) {
|
||||||
size++
|
size++
|
||||||
if (size > data.size) {
|
if (size > data.size) {
|
||||||
@@ -75,7 +75,7 @@ obj hash_map<T,U> (Object, Serializable) {
|
|||||||
for (var i = 0; i < size*2; i++;)
|
for (var i = 0; i < size*2; i++;)
|
||||||
new_data.addEnd(map::map<T,U>())
|
new_data.addEnd(map::map<T,U>())
|
||||||
for_each(fun(key: T, value: U) {
|
for_each(fun(key: T, value: U) {
|
||||||
new_data[util::hash(key)%new_data.size].set(key, value)
|
new_data[(util::hash(key)) cast int%new_data.size].set(key, value)
|
||||||
})
|
})
|
||||||
data = new_data
|
data = new_data
|
||||||
}
|
}
|
||||||
@@ -83,10 +83,10 @@ obj hash_map<T,U> (Object, Serializable) {
|
|||||||
data[key_hash%data.size].set(key, value)
|
data[key_hash%data.size].set(key, value)
|
||||||
}
|
}
|
||||||
fun get(key: T): ref U {
|
fun get(key: T): ref U {
|
||||||
return data[util::hash(key)%data.size].get(key)
|
return data[(util::hash(key)) cast int%data.size].get(key)
|
||||||
}
|
}
|
||||||
fun contains_key(key: T): bool {
|
fun contains_key(key: T): bool {
|
||||||
return data[util::hash(key)%data.size].contains_key(key)
|
return data[(util::hash(key)) cast int%data.size].contains_key(key)
|
||||||
}
|
}
|
||||||
fun contains_value(value: U): bool {
|
fun contains_value(value: U): bool {
|
||||||
for (var i = 0; i < data.size; i++;) {
|
for (var i = 0; i < data.size; i++;) {
|
||||||
@@ -103,7 +103,7 @@ obj hash_map<T,U> (Object, Serializable) {
|
|||||||
io::println("trying to reverse get a value that is not in the hash_map")
|
io::println("trying to reverse get a value that is not in the hash_map")
|
||||||
}
|
}
|
||||||
fun remove(key: T) {
|
fun remove(key: T) {
|
||||||
data[util::hash(key)%data.size].remove(key)
|
data[(util::hash(key)) cast int%data.size].remove(key)
|
||||||
}
|
}
|
||||||
fun for_each(func: fun(T, U):void) {
|
fun for_each(func: fun(T, U):void) {
|
||||||
for (var i = 0; i < data.size; i++;)
|
for (var i = 0; i < data.size; i++;)
|
||||||
|
|||||||
153
stdlib/io.krak
153
stdlib/io.krak
@@ -2,10 +2,6 @@ import string;
|
|||||||
import vector;
|
import vector;
|
||||||
import mem:*
|
import mem:*
|
||||||
|
|
||||||
__if_comp__ __C__ simple_passthrough """
|
|
||||||
#include <stdio.h>
|
|
||||||
"""
|
|
||||||
|
|
||||||
fun println() : void {
|
fun println() : void {
|
||||||
print("\n");
|
print("\n");
|
||||||
}
|
}
|
||||||
@@ -15,35 +11,18 @@ fun println<T>(toPrint: T) : void {
|
|||||||
print("\n")
|
print("\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
fun print<T>(toPrint: *T) : void{
|
fun print<T>(toPrint: *T)
|
||||||
__if_comp__ __C__ {
|
print((toPrint) cast ulong)
|
||||||
simple_passthrough(toPrint = toPrint::) """
|
|
||||||
printf("%p", (void*)toPrint);
|
|
||||||
fflush(0);
|
|
||||||
"""
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
ext fun printf(fmt_str: *char, to_print: *char): int
|
||||||
|
ext fun fflush(file: int): int
|
||||||
fun print(toPrint: *char) : void {
|
fun print(toPrint: *char) : void {
|
||||||
__if_comp__ __C__ {
|
printf("%s", toPrint)
|
||||||
simple_passthrough(toPrint = toPrint::) """
|
fflush(0)
|
||||||
printf("%s", toPrint);
|
|
||||||
fflush(0);
|
|
||||||
"""
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun print(toPrint: char) : void {
|
fun print(toPrint: char) : void
|
||||||
__if_comp__ __C__ {
|
print(string::string(toPrint))
|
||||||
simple_passthrough(toPrint = toPrint::) """
|
|
||||||
printf("%c", toPrint);
|
|
||||||
fflush(0);
|
|
||||||
"""
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
fun print(toPrint: string::string) : void {
|
fun print(toPrint: string::string) : void {
|
||||||
var charArr = toPrint.toCharArray()
|
var charArr = toPrint.toCharArray()
|
||||||
@@ -59,52 +38,39 @@ fun print(toPrint: bool): void {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fun print(toPrint: int): void {
|
fun print(toPrint: int): void
|
||||||
__if_comp__ __C__ {
|
print(string::to_string(toPrint))
|
||||||
simple_passthrough(toPrint = toPrint::) """
|
fun print(toPrint: ulong): void
|
||||||
printf("%d", toPrint);
|
print(string::to_string(toPrint))
|
||||||
fflush(0);
|
|
||||||
"""
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
fun print(toPrint: float): void {
|
ext fun sprintf(to_str: *char, format: *char, d: double)
|
||||||
__if_comp__ __C__ {
|
fun print(toPrint: float)
|
||||||
simple_passthrough(toPrint = toPrint::) """
|
print((toPrint) cast double)
|
||||||
printf("%f", toPrint);
|
|
||||||
fflush(0);
|
|
||||||
"""
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
fun print(toPrint: double) : void{
|
fun print(toPrint: double) {
|
||||||
__if_comp__ __C__ {
|
var int_str = new<char>((#sizeof<double>) cast int)
|
||||||
simple_passthrough(toPrint = toPrint::) """
|
sprintf(int_str, "%f", toPrint)
|
||||||
printf("%f", toPrint);
|
print(int_str)
|
||||||
fflush(0);
|
delete(int_str)
|
||||||
"""
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ok, just some DEAD simple file io for now
|
// Ok, just some DEAD simple file io for now
|
||||||
|
ext fun fopen(path: *char, mode: *char): *void
|
||||||
|
ext fun fclose(file: *void): int
|
||||||
|
ext fun fprintf(file: *void, format: *char, data: *char): int
|
||||||
|
ext fun ftell(file: *void): long
|
||||||
|
ext fun fseek(file: *void, offset: long, whence: int): int
|
||||||
|
ext fun fread(ptr: *void, size: ulong, nmemb: ulong, file: *void): ulong
|
||||||
|
ext fun fwrite(ptr: *void, size: ulong, nmemb: ulong, file: *void): ulong
|
||||||
fun file_exists(path: string::string): bool {
|
fun file_exists(path: string::string): bool {
|
||||||
var char_path = path.toCharArray()
|
var char_path = path.toCharArray()
|
||||||
defer delete(char_path)
|
defer delete(char_path)
|
||||||
var result = false
|
var fp = fopen(char_path, "r")
|
||||||
__if_comp__ __C__ {
|
if (fp) {
|
||||||
simple_passthrough(char_path:result:) """
|
fclose(fp)
|
||||||
bool result = false;
|
return true
|
||||||
FILE *fp = fopen(char_path, "r");
|
|
||||||
if (fp) {
|
|
||||||
result = true;
|
|
||||||
fclose(fp);
|
|
||||||
}
|
|
||||||
"""
|
|
||||||
}
|
}
|
||||||
return result
|
return false
|
||||||
}
|
}
|
||||||
fun read_file(path: string::string): string::string {
|
fun read_file(path: string::string): string::string {
|
||||||
if (!file_exists(path))
|
if (!file_exists(path))
|
||||||
@@ -117,40 +83,25 @@ fun write_file(path: string::string, data: string::string) {
|
|||||||
defer delete(char_path)
|
defer delete(char_path)
|
||||||
var char_data = data.toCharArray()
|
var char_data = data.toCharArray()
|
||||||
defer delete(char_data)
|
defer delete(char_data)
|
||||||
__if_comp__ __C__ {
|
var fp = fopen(char_path, "w")
|
||||||
simple_passthrough(char_path,char_data::) """
|
fprintf(fp, "%s", char_data)
|
||||||
FILE *fp = fopen(char_path, "w");
|
fclose(fp)
|
||||||
fprintf(fp, "%s", char_data);
|
|
||||||
fclose(fp);
|
|
||||||
"""
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
fun read_file_binary(path: string::string): vector::vector<char> {
|
fun read_file_binary(path: string::string): vector::vector<char> {
|
||||||
var char_path = path.toCharArray()
|
var char_path = path.toCharArray()
|
||||||
defer delete(char_path)
|
defer delete(char_path)
|
||||||
var data: *char
|
var fp = fopen(char_path, "r")
|
||||||
var size: int
|
fseek(fp, (0) cast long, 2)// fseek(fp, 0L, SEEK_END)
|
||||||
__if_comp__ __C__ {
|
var size = ftell(fp)
|
||||||
simple_passthrough(char_path = char_path:data = data, size = size:) """
|
fseek(fp, (0) cast long, 0)//fseek(fp, 0L, SEEK_SET)
|
||||||
FILE *fp = fopen(char_path, "r");
|
var data = new<char>((size+1) cast int)
|
||||||
fseek(fp, 0L, SEEK_END);
|
var readSize = fread((data) cast *void, (1) cast ulong, (size) cast ulong, fp)
|
||||||
long size = ftell(fp);
|
fclose(fp)
|
||||||
fseek(fp, 0L, SEEK_SET);
|
data[readSize] = 0
|
||||||
char *data = malloc(size+1);
|
var toRet.construct((size) cast int): vector::vector<char>
|
||||||
size_t readSize = fread(data, 1, size, fp);
|
|
||||||
data[readSize] = 0;
|
|
||||||
fclose(fp);
|
|
||||||
"""
|
|
||||||
}
|
|
||||||
var toRet.construct(size): vector::vector<char>
|
|
||||||
for (var i = 0; i < size; i++;)
|
for (var i = 0; i < size; i++;)
|
||||||
toRet.add(data[i])
|
toRet.add(data[i])
|
||||||
|
delete(data)
|
||||||
__if_comp__ __C__ {
|
|
||||||
simple_passthrough(data = data::) """
|
|
||||||
free(data);
|
|
||||||
"""
|
|
||||||
}
|
|
||||||
return toRet
|
return toRet
|
||||||
}
|
}
|
||||||
fun write_file_binary(path: string::string, vdata: vector::vector<char>) {
|
fun write_file_binary(path: string::string, vdata: vector::vector<char>) {
|
||||||
@@ -158,13 +109,9 @@ fun write_file_binary(path: string::string, vdata: vector::vector<char>) {
|
|||||||
defer delete(char_path)
|
defer delete(char_path)
|
||||||
var data = vdata.getBackingMemory()
|
var data = vdata.getBackingMemory()
|
||||||
var size = vdata.size
|
var size = vdata.size
|
||||||
__if_comp__ __C__ {
|
var fp = fopen(char_path, "w")
|
||||||
simple_passthrough(char_path, data, size::) """
|
fwrite((data) cast *void, (1) cast ulong, (size) cast ulong, fp)
|
||||||
FILE *fp = fopen(char_path, "w");
|
fclose(fp)
|
||||||
fwrite(data, 1, size, fp);
|
|
||||||
fclose(fp);
|
|
||||||
"""
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun BoldRed(): void{
|
fun BoldRed(): void{
|
||||||
@@ -195,7 +142,3 @@ fun Reset(): void{
|
|||||||
print("\033[0m");
|
print("\033[0m");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
146
stdlib/math.krak
146
stdlib/math.krak
@@ -1,139 +1,27 @@
|
|||||||
__if_comp__ __C__ simple_passthrough(::"-lm") """
|
|
||||||
#include <math.h>
|
|
||||||
"""
|
|
||||||
|
|
||||||
fun fibanacci(num: int): int {
|
fun fibanacci(num: int): int {
|
||||||
if (num < 2)
|
var l1 = 1
|
||||||
return 1;
|
var l2 = 1
|
||||||
return fibanacci(num-1) + fibanacci(num-2);
|
for (var i = 0; i < num; i++;) {
|
||||||
|
var next = l1 + l2
|
||||||
|
l2 = l1
|
||||||
|
l1 = next
|
||||||
|
}
|
||||||
|
return l1
|
||||||
}
|
}
|
||||||
|
|
||||||
/*********************
|
/*********************
|
||||||
* Trig Functions
|
* Trig Functions
|
||||||
********************/
|
********************/
|
||||||
|
|
||||||
fun atan(arg: double): double
|
ext fun atan(arg: double): double
|
||||||
{
|
ext fun atan2(x: double, y: double): double
|
||||||
var ans: double = 0;
|
ext fun acos(arg: double): double
|
||||||
__if_comp__ __C__{
|
ext fun asin(arg: double): double
|
||||||
simple_passthrough(arg = arg, ans = ans : ans = ans :) """
|
ext fun tan(arg: double): double
|
||||||
ans = atan(arg);
|
ext fun cos(arg: double): double
|
||||||
"""
|
ext fun sin(arg: double): double
|
||||||
}//end C wrapper
|
|
||||||
|
|
||||||
return ans;
|
|
||||||
}//end atan function
|
|
||||||
|
|
||||||
fun atan2(x: double, y: double): double
|
|
||||||
{
|
|
||||||
var ans: double = 0;
|
|
||||||
__if_comp__ __C__{
|
|
||||||
simple_passthrough(x = x, y = y, ans = ans : ans = ans :) """
|
|
||||||
ans = atan2(x,y);
|
|
||||||
"""
|
|
||||||
}//end C wrapper
|
|
||||||
|
|
||||||
return ans;
|
|
||||||
}//end atan2 function
|
|
||||||
|
|
||||||
fun acos(arg: double): double
|
|
||||||
{
|
|
||||||
var ans: double = 0;
|
|
||||||
__if_comp__ __C__{
|
|
||||||
simple_passthrough(arg = arg, ans = ans : ans = ans :) """
|
|
||||||
ans = acos(arg);
|
|
||||||
"""
|
|
||||||
}//end C wrapper
|
|
||||||
|
|
||||||
return ans;
|
|
||||||
}//end acos function
|
|
||||||
|
|
||||||
fun asin(arg: double): double
|
|
||||||
{
|
|
||||||
var ans: double = 0;
|
|
||||||
__if_comp__ __C__{
|
|
||||||
simple_passthrough(arg = arg, ans = ans : ans = ans :) """
|
|
||||||
ans = asin(arg);
|
|
||||||
"""
|
|
||||||
}//end C wrapper
|
|
||||||
|
|
||||||
return ans;
|
|
||||||
}//end asin function
|
|
||||||
|
|
||||||
fun tan(arg: double): double
|
|
||||||
{
|
|
||||||
var ans: double = 0;
|
|
||||||
__if_comp__ __C__{
|
|
||||||
simple_passthrough(arg = arg, ans = ans : ans = ans :) """
|
|
||||||
ans = tan(arg);
|
|
||||||
"""
|
|
||||||
}//end C wrapper
|
|
||||||
|
|
||||||
return ans;
|
|
||||||
}//end tan function
|
|
||||||
|
|
||||||
fun cos(arg: double): double
|
|
||||||
{
|
|
||||||
var ans: double = 0;
|
|
||||||
__if_comp__ __C__{
|
|
||||||
simple_passthrough(arg = arg, ans = ans : ans = ans :) """
|
|
||||||
ans = cos(arg);
|
|
||||||
"""
|
|
||||||
}//end C wrapper
|
|
||||||
|
|
||||||
return ans;
|
|
||||||
}//end cos function
|
|
||||||
|
|
||||||
fun sin(arg: double): double
|
|
||||||
{
|
|
||||||
var ans: double = 0;
|
|
||||||
__if_comp__ __C__{
|
|
||||||
simple_passthrough(arg = arg, ans = ans : ans = ans :) """
|
|
||||||
ans = sin(arg);
|
|
||||||
"""
|
|
||||||
}//end C wrapper
|
|
||||||
|
|
||||||
return ans;
|
|
||||||
}//end sin function
|
|
||||||
|
|
||||||
fun mod(x: double, y: double): double
|
fun mod(x: double, y: double): double
|
||||||
{
|
{
|
||||||
var ans: double;
|
var intAns = x / y;
|
||||||
var intAns: int;
|
return x - intAns*y;
|
||||||
|
|
||||||
intAns = x / y;
|
|
||||||
ans = x - intAns*y;
|
|
||||||
|
|
||||||
return ans;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val M_PI = acos(-1);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
|
|
||||||
fun null<T>(): *T {
|
ext fun malloc(size: ulong): *void
|
||||||
return (0) cast *T
|
|
||||||
}
|
|
||||||
|
|
||||||
ext fun malloc(size: int): *void
|
|
||||||
ext fun free(size: *void)
|
ext fun free(size: *void)
|
||||||
|
|
||||||
|
fun null<T>(): *T
|
||||||
|
return (0) cast *T
|
||||||
|
|
||||||
fun new<T>(count: int): *T
|
fun new<T>(count: int): *T
|
||||||
return (malloc( #sizeof<T> * count )) cast *T
|
return (malloc( (#sizeof<T> * count ) cast ulong )) cast *T
|
||||||
|
|
||||||
fun new<T>(): *T
|
fun new<T>(): *T
|
||||||
return new<T>(1)
|
return new<T>(1)
|
||||||
|
|||||||
@@ -7,22 +7,7 @@ fun system(call_string: string):int {
|
|||||||
delete(c_call_string)
|
delete(c_call_string)
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
fun system(call_string: *char): int {
|
ext fun system(call_string: *char): int
|
||||||
__if_comp__ __C__ {
|
ext fun exit(code: int):void
|
||||||
simple_passthrough(call_string::) """
|
|
||||||
return system(call_string);
|
|
||||||
"""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun exit() exit(0);
|
fun exit() exit(0);
|
||||||
fun exit(code: int) {
|
|
||||||
__if_comp__ __C__ {
|
|
||||||
simple_passthrough(code::) """
|
|
||||||
exit(code);
|
|
||||||
"""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ fun unserialize<T>(it: ref vector::vector<char>): T {
|
|||||||
return unserialize<T>(it, 0).first
|
return unserialize<T>(it, 0).first
|
||||||
}
|
}
|
||||||
fun unserialize<T>(it: ref vector::vector<char>, pos: int): util::pair<T,int> {
|
fun unserialize<T>(it: ref vector::vector<char>, pos: int): util::pair<T,int> {
|
||||||
return util::make_pair(*(it.getBackingMemory()+pos) cast *T, pos + #sizeof<T>)
|
return util::make_pair(*(it.getBackingMemory()+pos) cast *T, pos + (#sizeof<T>) cast int)
|
||||||
}
|
}
|
||||||
fun unserialize<T(Serializable)>(it: ref vector::vector<char>, pos: int): util::pair<T,int> {
|
fun unserialize<T(Serializable)>(it: ref vector::vector<char>, pos: int): util::pair<T,int> {
|
||||||
var toRet: T
|
var toRet: T
|
||||||
|
|||||||
@@ -1,59 +0,0 @@
|
|||||||
|
|
||||||
fun println() {
|
|
||||||
print("\n")
|
|
||||||
}
|
|
||||||
fun println(to_print: *char) {
|
|
||||||
print(to_print)
|
|
||||||
print("\n")
|
|
||||||
}
|
|
||||||
fun println(to_print: char) {
|
|
||||||
print(to_print)
|
|
||||||
print("\n")
|
|
||||||
}
|
|
||||||
fun println(to_print: int) {
|
|
||||||
print(to_print)
|
|
||||||
print("\n")
|
|
||||||
}
|
|
||||||
fun println(to_print: float) {
|
|
||||||
print(to_print)
|
|
||||||
print("\n")
|
|
||||||
}
|
|
||||||
fun println(to_print: double) {
|
|
||||||
print(to_print)
|
|
||||||
print("\n")
|
|
||||||
}
|
|
||||||
fun println(to_print: bool) {
|
|
||||||
print(to_print)
|
|
||||||
print("\n")
|
|
||||||
}
|
|
||||||
fun print(to_print: *char) {
|
|
||||||
__if_comp__ __C__ simple_passthrough(to_print::) """
|
|
||||||
printf("%s", to_print);
|
|
||||||
"""
|
|
||||||
}
|
|
||||||
fun print(to_print: char) {
|
|
||||||
__if_comp__ __C__ simple_passthrough(to_print::) """
|
|
||||||
printf("%c", to_print);
|
|
||||||
"""
|
|
||||||
}
|
|
||||||
fun print(to_print: int) {
|
|
||||||
__if_comp__ __C__ simple_passthrough(to_print::) """
|
|
||||||
printf("%d", to_print);
|
|
||||||
"""
|
|
||||||
}
|
|
||||||
|
|
||||||
fun print(to_print: float) {
|
|
||||||
__if_comp__ __C__ simple_passthrough(to_print::) """
|
|
||||||
printf("%f", to_print);
|
|
||||||
"""
|
|
||||||
}
|
|
||||||
fun print(to_print: double) {
|
|
||||||
__if_comp__ __C__ simple_passthrough(to_print::) """
|
|
||||||
printf("%f", to_print);
|
|
||||||
"""
|
|
||||||
}
|
|
||||||
fun print(to_print: bool) {
|
|
||||||
if (to_print) print("true")
|
|
||||||
else print("false")
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -2,16 +2,41 @@ import vector
|
|||||||
import util
|
import util
|
||||||
import mem
|
import mem
|
||||||
import serialize
|
import serialize
|
||||||
|
import io
|
||||||
|
|
||||||
fun to_string(in: int): string {
|
fun to_string(in: uchar): string
|
||||||
var dest = mem::new<char>(#sizeof<int> * 8)
|
return to_string_num(in)
|
||||||
defer mem::delete(dest)
|
fun to_string(in: short): string
|
||||||
__if_comp__ __C__ {
|
return to_string_num(in)
|
||||||
simple_passthrough(dest = dest, in = in::) """
|
fun to_string(in: ushort): string
|
||||||
sprintf(dest, "%d", in);
|
return to_string_num(in)
|
||||||
"""
|
fun to_string(in: int): string
|
||||||
}
|
return to_string_num(in)
|
||||||
var ret = string(dest)
|
fun to_string(in: uint): string
|
||||||
|
return to_string_num(in)
|
||||||
|
fun to_string(in: long): string
|
||||||
|
return to_string_num(in)
|
||||||
|
fun to_string(in: ulong): string
|
||||||
|
return to_string_num(in)
|
||||||
|
|
||||||
|
fun to_string_num<T>(in: T): string {
|
||||||
|
if (in == 0)
|
||||||
|
return string("0")
|
||||||
|
var ret = string()
|
||||||
|
var pos = 0
|
||||||
|
var is_neg = false
|
||||||
|
if (in > 0) {
|
||||||
|
pos = in
|
||||||
|
} else {
|
||||||
|
pos = -in
|
||||||
|
is_neg = true
|
||||||
|
}
|
||||||
|
while (pos) {
|
||||||
|
ret = string((pos%10 + '0') cast char) + ret
|
||||||
|
pos = pos / 10
|
||||||
|
}
|
||||||
|
if (is_neg)
|
||||||
|
return string("-") + ret
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,12 +27,18 @@ fun min<T>(a: T, b: T): T {
|
|||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
fun hash<T(Hashable)>(item: T): int return item.hash()
|
fun hash<T(Hashable)>(item: T): ulong return item.hash()
|
||||||
fun hash<T>(item: *T): int return (item) cast int
|
fun hash<T>(item: *T): ulong return (item) cast ulong
|
||||||
fun hash(item: int): int return item
|
fun hash(item: char): ulong return item
|
||||||
fun hash(item: char): int return item
|
fun hash(item: uchar): ulong return item
|
||||||
|
fun hash(item: short): ulong return item
|
||||||
|
fun hash(item: ushort): ulong return item
|
||||||
|
fun hash(item: int): ulong return item
|
||||||
|
fun hash(item: uint): ulong return item
|
||||||
|
fun hash(item: long): ulong return item
|
||||||
|
fun hash(item: ulong): ulong return item
|
||||||
// default hash
|
// default hash
|
||||||
fun hash<T>(item: T): int {
|
fun hash<T>(item: T): ulong {
|
||||||
io::println("using empty hash - please do not do!")
|
io::println("using empty hash - please do not do!")
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
@@ -95,8 +101,7 @@ obj pair<T,U> (Object, Serializable, Hashable) {
|
|||||||
return second_pair.second
|
return second_pair.second
|
||||||
}
|
}
|
||||||
|
|
||||||
fun hash():int return hash(first) ^ hash(second)
|
fun hash():ulong return hash(first) ^ hash(second)
|
||||||
/*fun hash():int return 0*/
|
|
||||||
|
|
||||||
// the old unnecessary template to prevent generation
|
// the old unnecessary template to prevent generation
|
||||||
// if not used trick (in this case, changing out U with V)
|
// if not used trick (in this case, changing out U with V)
|
||||||
|
|||||||
@@ -1,121 +0,0 @@
|
|||||||
import io:*
|
|
||||||
import grammer:*
|
|
||||||
import parser:*
|
|
||||||
import lexer:*
|
|
||||||
import string:*
|
|
||||||
import util:*
|
|
||||||
import symbol:*
|
|
||||||
import tree:*
|
|
||||||
import serialize:*
|
|
||||||
|
|
||||||
fun main():int {
|
|
||||||
|
|
||||||
/*var a.construct(): grammer*/
|
|
||||||
// delay construction until unserialization or copy_construction now
|
|
||||||
var a: grammer
|
|
||||||
|
|
||||||
var file_name = string("../krakenGrammer.kgm")
|
|
||||||
/*var file_name = string("../simplifiedKrakenGrammer.kgm")*/
|
|
||||||
/*var file_name = string("grammer.kgm")*/
|
|
||||||
|
|
||||||
var compiled_name = file_name + string(".comp_new")
|
|
||||||
var file_contents = read_file(file_name)
|
|
||||||
var loaded_and_valid = false
|
|
||||||
|
|
||||||
if (file_exists(compiled_name)) {
|
|
||||||
println("cached file exists")
|
|
||||||
var pos = 0
|
|
||||||
var binary = read_file_binary(compiled_name)
|
|
||||||
println("read file!")
|
|
||||||
var cached_contents = string()
|
|
||||||
println("made tmp string!")
|
|
||||||
unpack(cached_contents, pos) = unserialize<string>(binary, pos)
|
|
||||||
println("unserialized the string!")
|
|
||||||
if (cached_contents == file_contents) {
|
|
||||||
println("loaded_and_valid, using cached version!")
|
|
||||||
loaded_and_valid = true
|
|
||||||
/*unpack(a, pos) = unserialize<grammer>(binary, pos)*/
|
|
||||||
// avoid extra copies
|
|
||||||
pos = a.unserialize(binary, pos)
|
|
||||||
println("finished unserializeing!!")
|
|
||||||
} else {
|
|
||||||
println("file contents do not match:")
|
|
||||||
println("CACHED:")
|
|
||||||
println(cached_contents)
|
|
||||||
println("REAL:")
|
|
||||||
println(file_contents)
|
|
||||||
println("END")
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
println("cached file does not exist")
|
|
||||||
}
|
|
||||||
if (!loaded_and_valid) {
|
|
||||||
println("Not loaded_and_valid, re-generating and writing out")
|
|
||||||
/*a = load_grammer(file_contents)*/
|
|
||||||
// copy construct now
|
|
||||||
a.copy_construct(&load_grammer(file_contents))
|
|
||||||
println("grammer loaded, calculate_first_set")
|
|
||||||
a.calculate_first_set()
|
|
||||||
println("grammer loaded, calculate_state_automaton")
|
|
||||||
a.calculate_state_automaton()
|
|
||||||
println("calculated, writing out")
|
|
||||||
write_file_binary(compiled_name, serialize(file_contents) + serialize(a))
|
|
||||||
println("done writing")
|
|
||||||
}
|
|
||||||
/*println(a.to_string())*/
|
|
||||||
var doFirstSet = fun() {
|
|
||||||
println("///////////////////START FIRST SET/////////////")
|
|
||||||
println("//TERMINALS//")
|
|
||||||
a.terminals.for_each( fun(terminal: util::pair<symbol::symbol, regex::regex>) {
|
|
||||||
var set_str = string::string("{ ")
|
|
||||||
a.first_set_map[terminal.first].for_each( fun(sym: symbol::symbol) {
|
|
||||||
set_str += sym.to_string() + ", "
|
|
||||||
})
|
|
||||||
set_str += "}"
|
|
||||||
print(terminal.first.to_string() + " first: " + set_str + "\n")
|
|
||||||
})
|
|
||||||
println("//NON TERMINALS//")
|
|
||||||
a.non_terminals.for_each( fun(non_terminal: symbol::symbol) {
|
|
||||||
var set_str = string::string("{ ")
|
|
||||||
a.first_set_map[non_terminal].for_each( fun(sym: symbol::symbol) {
|
|
||||||
set_str += sym.to_string() + ", "
|
|
||||||
})
|
|
||||||
set_str += "}"
|
|
||||||
print(non_terminal.to_string() + " first: " + set_str + "\n")
|
|
||||||
println()
|
|
||||||
})
|
|
||||||
println("///////////////////END FIRST SET/////////////")
|
|
||||||
}
|
|
||||||
/*doFirstSet()*/
|
|
||||||
|
|
||||||
println(a.to_string())
|
|
||||||
a.parse_table.print_string()
|
|
||||||
var lex = lexer(a.terminals)
|
|
||||||
|
|
||||||
lex.set_input(read_file(string("to_parse.krak")))
|
|
||||||
/*lex.set_input(string("ccdahas spacedhas*/
|
|
||||||
/*returndaaaaaaaaaaaaaa"))*/
|
|
||||||
//lex.set_input(string("hibyed"))
|
|
||||||
println("woo lexing:")
|
|
||||||
range(8).for_each(fun(i: int) { println(lex.next().to_string()); } )
|
|
||||||
/*range(80).for_each(fun(i: int) { println(lex.next().to_string()); } )*/
|
|
||||||
|
|
||||||
|
|
||||||
var parse.construct(a): parser
|
|
||||||
/*var result = parse.parse_input(string("a"), string("fun name"))*/
|
|
||||||
/*var result = parse.parse_input(read_file(string("test_adt.krak")), string("fun name"))*/
|
|
||||||
var result = parse.parse_input(read_file(string("to_parse.krak")), string("fun name"))
|
|
||||||
/*var result = parse.parse_input(string("inport a;"), string("fun name"))*/
|
|
||||||
/*var result = parse.parse_input(string("fun main():int { return 0; }"), string("fun name"))*/
|
|
||||||
/*var result = parse.parse_input(string("ad"), string("fun name"))*/
|
|
||||||
/*var result = parse.parse_input(string("hibyed"), string("fun name"))*/
|
|
||||||
/*var result = parse.parse_input(string("hmmhmmend"), string("fun name"))*/
|
|
||||||
/*var result = parse.parse_input(string("hid"), string("fun name"))*/
|
|
||||||
println("the tree")
|
|
||||||
println(syntax_tree_to_dot(result))
|
|
||||||
write_file(string("syntax_tree.dot"), syntax_tree_to_dot(result))
|
|
||||||
/*var parse.construct(): parser*/
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
3.141593
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
krakenPath="../build/kraken"
|
|
||||||
#testDir=${1:-"../tests"}
|
|
||||||
testDir="."
|
|
||||||
ext=${2:-"krak"}
|
|
||||||
|
|
||||||
fileList=""
|
|
||||||
for dir in `find ${testDir} -type f -name "test_*.${ext}"`; do
|
|
||||||
filename=$(basename ${dir})
|
|
||||||
filename="${filename%.*}"
|
|
||||||
fileList+=\ $testDir\/$filename
|
|
||||||
done
|
|
||||||
|
|
||||||
${krakenPath} "--test" ${fileList}
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import simple_print:*;
|
import io:*;
|
||||||
|
|
||||||
obj Vec2 {
|
obj Vec2 {
|
||||||
var x: int;
|
var x: int;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import simple_print:*;
|
import io:*;
|
||||||
|
|
||||||
fun fibanacci(num: int): int {
|
fun fibanacci(num: int): int {
|
||||||
if (num < 2)
|
if (num < 2)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import simple_print:*
|
import io:*
|
||||||
|
|
||||||
fun retVoid() {
|
fun retVoid() {
|
||||||
println("Woooo")
|
println("Woooo")
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import simple_print:*
|
import io:*
|
||||||
|
|
||||||
fun main(): int {
|
fun main(): int {
|
||||||
simple_print::println("Spam");
|
io::println("Spam");
|
||||||
var x: int = 4;
|
var x: int = 4;
|
||||||
x += 3;
|
x += 3;
|
||||||
x++;
|
x++;
|
||||||
@@ -10,16 +10,16 @@ fun main(): int {
|
|||||||
var q :int = z+z;
|
var q :int = z+z;
|
||||||
var q2:int = z*3;
|
var q2:int = z*3;
|
||||||
var q3:int = y + y;
|
var q3:int = y + y;
|
||||||
simple_print::println(q3);
|
io::println(q3);
|
||||||
simple_print::println(z);
|
io::println(z);
|
||||||
simple_print::println(q);
|
io::println(q);
|
||||||
for (var i:int = 0; i < 20; i++;) z++;
|
for (var i:int = 0; i < 20; i++;) z++;
|
||||||
if (z > 20) simple_print::println("We'll find out.");
|
if (z > 20) io::println("We'll find out.");
|
||||||
simple_print::println(z);
|
io::println(z);
|
||||||
var boolean = false
|
var boolean = false
|
||||||
if ( z > 20 && !boolean)
|
if ( z > 20 && !boolean)
|
||||||
simple_print::println("woo not")
|
io::println("woo not")
|
||||||
simple_print::println('b' == 'a')
|
io::println('b' == 'a')
|
||||||
println(3|5)
|
println(3|5)
|
||||||
println(3^5)
|
println(3^5)
|
||||||
println(3&5)
|
println(3&5)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import simple_print:*
|
import io:*
|
||||||
|
|
||||||
obj BracketAssign {
|
obj BracketAssign {
|
||||||
fun operator[]=(index:int, rhs:int) {
|
fun operator[]=(index:int, rhs:int) {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import simple_print:*
|
import io:*
|
||||||
|
|
||||||
fun main():int {
|
fun main():int {
|
||||||
for (var i = 1; i < 10; i++;) {
|
for (var i = 1; i < 10; i++;) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*here*/
|
/*here*/
|
||||||
/*here*/import /*here*/simple_print/*here*/:/*here*/*/*here*/
|
/*here*/import /*here*/io/*here*/:/*here*/*/*here*/
|
||||||
/*here*/
|
/*here*/
|
||||||
/*here*/fun/*here*/ main/*here*/(/*here*/)/*here*/:/*here*/ int/*here*/ {/*here*/
|
/*here*/fun/*here*/ main/*here*/(/*here*/)/*here*/:/*here*/ int/*here*/ {/*here*/
|
||||||
/*here*/ println/*here*/( /*here*/1 /*here*/ )/*here*/
|
/*here*/ println/*here*/( /*here*/1 /*here*/ )/*here*/
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import simple_print:*
|
import io:*
|
||||||
import vector:*
|
import vector:*
|
||||||
|
|
||||||
fun onlyMatch(vec: vector<int>, matchWith: int): vector<int> {
|
fun onlyMatch(vec: vector<int>, matchWith: int): vector<int> {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import vector:*;
|
import vector:*;
|
||||||
import simple_print:*;
|
import io:*;
|
||||||
|
|
||||||
fun test<T>(a: vector<T>): T {
|
fun test<T>(a: vector<T>): T {
|
||||||
return a.at(0);
|
return a.at(0);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import simple_print:*
|
import io:*
|
||||||
|
|
||||||
fun func(it: ref int) {
|
fun func(it: ref int) {
|
||||||
it++
|
it++
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* Comment first! */
|
/* Comment first! */
|
||||||
import simple_print:*;
|
import io:*;
|
||||||
|
|
||||||
fun main(): int {
|
fun main(): int {
|
||||||
println(1337) /*how bout now*/
|
println(1337) /*how bout now*/
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import simple_print:*
|
import io:*
|
||||||
|
|
||||||
fun Comparable<T>(): Comparable<T> {
|
fun Comparable<T>(): Comparable<T> {
|
||||||
var toRet : Comparable<T>
|
var toRet : Comparable<T>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import simple_print:*
|
import io:*
|
||||||
|
|
||||||
fun main(): int {
|
fun main(): int {
|
||||||
println(#sizeof<char>)
|
println(#sizeof<char>)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import simple_print:*
|
import io:*
|
||||||
|
|
||||||
fun main():int {
|
fun main():int {
|
||||||
println((65) cast char)
|
println((65) cast char)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import simple_print:*;
|
import io:*;
|
||||||
import mem:*;
|
import mem:*;
|
||||||
|
|
||||||
obj ClassWithConstructor {
|
obj ClassWithConstructor {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import simple_print:*
|
import io:*
|
||||||
|
|
||||||
obj wDestructor {
|
obj wDestructor {
|
||||||
var data: *char
|
var data: *char
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import simple_print:*;
|
import io:*;
|
||||||
|
|
||||||
|
|
||||||
fun main(): int {
|
fun main(): int {
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import simple_print;
|
import io;
|
||||||
|
|
||||||
fun nothing(): void {}
|
fun nothing(): void {}
|
||||||
|
|
||||||
fun main(): int {
|
fun main(): int {
|
||||||
nothing();
|
nothing();
|
||||||
simple_print::println("It was nothing");
|
io::println("It was nothing");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ ext fun printf(format_str: *char, actual_str: *char): int
|
|||||||
|
|
||||||
fun main():int {
|
fun main():int {
|
||||||
printf("%s", "Hello extern!\n")
|
printf("%s", "Hello extern!\n")
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import simple_print:*;
|
import io:*;
|
||||||
|
|
||||||
fun addAndPrint<T,J>(a: T, b: J): void {
|
fun addAndPrint<T,J>(a: T, b: J): void {
|
||||||
print(a+b);
|
print(a+b);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import simple_print:*
|
import io:*
|
||||||
|
|
||||||
obj FuncObj {
|
obj FuncObj {
|
||||||
fun operator()(a:int, b:*char): void {
|
fun operator()(a:int, b:*char): void {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import simple_print:*;
|
import io:*;
|
||||||
|
|
||||||
fun ret1(): int {
|
fun ret1(): int {
|
||||||
return ret2() / 2;
|
return ret2() / 2;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import simple_print:*
|
import io:*
|
||||||
|
|
||||||
obj Traited(Traits) {}
|
obj Traited(Traits) {}
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
import simple_print;
|
import io;
|
||||||
|
|
||||||
fun addAndPrint<T>(a: T, b: T): T {
|
fun addAndPrint<T>(a: T, b: T): T {
|
||||||
simple_print::print(a+b);
|
io::print(a+b);
|
||||||
return a+b;
|
return a+b;
|
||||||
}
|
}
|
||||||
|
|
||||||
fun main(): int {
|
fun main(): int {
|
||||||
addAndPrint<int>(10,12);
|
addAndPrint<int>(10,12);
|
||||||
simple_print::print("\n");
|
io::print("\n");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import simple_print:*
|
import io:*
|
||||||
|
|
||||||
fun test(): void {
|
fun test(): void {
|
||||||
println(9)
|
println(9)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import simple_print:*
|
import io:*
|
||||||
|
|
||||||
fun do_num(it: int) {
|
fun do_num(it: int) {
|
||||||
print("int: ")
|
print("int: ")
|
||||||
|
|||||||
BIN
tests/test_math
Executable file
BIN
tests/test_math
Executable file
Binary file not shown.
7
tests/test_math.expected_results
Normal file
7
tests/test_math.expected_results
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
atan = 3.141593
|
||||||
|
atan2 = 0.000000
|
||||||
|
acos = 0.000000
|
||||||
|
asin = 3.141593
|
||||||
|
tan = 0.990050
|
||||||
|
cos = 1.000000
|
||||||
|
sin = 0.000000
|
||||||
@@ -1,13 +1,10 @@
|
|||||||
import simple_print:*;
|
import io:*
|
||||||
import math:*;
|
import math:*
|
||||||
|
|
||||||
fun main(): int
|
fun main(): int
|
||||||
{
|
{
|
||||||
|
var STD_PI = 3.12159265
|
||||||
var ans: double;
|
var ans: double;
|
||||||
var STD_PI: double = 4.0*atan(1.0);
|
|
||||||
println(STD_PI);
|
|
||||||
|
|
||||||
/*
|
|
||||||
ans = 4.0*atan(1.0);
|
ans = 4.0*atan(1.0);
|
||||||
print("atan = ");
|
print("atan = ");
|
||||||
println(ans);
|
println(ans);
|
||||||
@@ -35,6 +32,5 @@ fun main(): int
|
|||||||
ans = sin(0.0);
|
ans = sin(0.0);
|
||||||
print("sin = ");
|
print("sin = ");
|
||||||
println(ans);
|
println(ans);
|
||||||
*/
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import mem:*;
|
import mem:*;
|
||||||
import simple_print:*;
|
import io:*;
|
||||||
|
|
||||||
obj AnObject {
|
obj AnObject {
|
||||||
var a: int;
|
var a: int;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import simple_print:*;
|
import io:*;
|
||||||
|
|
||||||
obj firstObject {
|
obj firstObject {
|
||||||
var objectNum: int;
|
var objectNum: int;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import simple_print:*;
|
import io:*;
|
||||||
import trivial_container:*;
|
import trivial_container:*;
|
||||||
|
|
||||||
obj RegularObject {
|
obj RegularObject {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import simple_print:*
|
import io:*
|
||||||
|
|
||||||
fun main():int {
|
fun main():int {
|
||||||
println("multi
|
println("multi
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import simple_print:*;
|
import io:*;
|
||||||
|
|
||||||
|
|
||||||
fun main(): int {
|
fun main(): int {
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
Qualified simple_print!
|
Qualified io!
|
||||||
7
|
7
|
||||||
9
|
9
|
||||||
11
|
11
|
||||||
Qualified Container!
|
Qualified Container!
|
||||||
Even template functions qualified!
|
Even template functions qualified!
|
||||||
|
|
||||||
Unqualified simple_print!
|
Unqualified io!
|
||||||
8
|
8
|
||||||
10
|
10
|
||||||
12
|
12
|
||||||
|
|||||||
@@ -1,32 +1,32 @@
|
|||||||
import simple_print;
|
import io;
|
||||||
import scopeQualified;
|
import scopeQualified;
|
||||||
import scopeUnqualified : * ;
|
import scopeUnqualified : * ;
|
||||||
|
|
||||||
fun main(): int {
|
fun main(): int {
|
||||||
simple_print::println("Qualified simple_print!");
|
io::println("Qualified io!");
|
||||||
|
|
||||||
// Defined in scopeQualified
|
// Defined in scopeQualified
|
||||||
simple_print::println(scopeQualified::qualified_variable);
|
io::println(scopeQualified::qualified_variable);
|
||||||
simple_print::println(scopeQualified::qualified_func());
|
io::println(scopeQualified::qualified_func());
|
||||||
var qClass.construct(11): scopeQualified::qualified_class;
|
var qClass.construct(11): scopeQualified::qualified_class;
|
||||||
simple_print::println(qClass.get());
|
io::println(qClass.get());
|
||||||
|
|
||||||
var sayQualified.construct("Qualified Container!"): scopeQualified::qualified_container<*char>;
|
var sayQualified.construct("Qualified Container!"): scopeQualified::qualified_container<*char>;
|
||||||
simple_print::println(sayQualified.get());
|
io::println(sayQualified.get());
|
||||||
simple_print::println(scopeQualified::qualified_id<*char>("Even template functions qualified!"));
|
io::println(scopeQualified::qualified_id<*char>("Even template functions qualified!"));
|
||||||
|
|
||||||
simple_print::println();
|
io::println();
|
||||||
|
|
||||||
simple_print::println("Unqualified simple_print!");
|
io::println("Unqualified io!");
|
||||||
// Defined in scopeUnqualified
|
// Defined in scopeUnqualified
|
||||||
simple_print::println(unqualifed_variable);
|
io::println(unqualifed_variable);
|
||||||
simple_print::println(unqualified_func());
|
io::println(unqualified_func());
|
||||||
var uqClass.construct(12): unqualified_class;
|
var uqClass.construct(12): unqualified_class;
|
||||||
simple_print::println(uqClass.get());
|
io::println(uqClass.get());
|
||||||
|
|
||||||
var sayUnqualified.construct("Unqualified Container!"): unqualified_container<*char>;
|
var sayUnqualified.construct("Unqualified Container!"): unqualified_container<*char>;
|
||||||
simple_print::println(sayUnqualified.get());
|
io::println(sayUnqualified.get());
|
||||||
simple_print::println(unqualified_id<*char>("Even template functions unqualified!"));
|
io::println(unqualified_id<*char>("Even template functions unqualified!"));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import simple_print:*
|
import io:*
|
||||||
|
|
||||||
fun main(): int {
|
fun main(): int {
|
||||||
println("no semicolons!")
|
println("no semicolons!")
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import simple_print:*
|
import io:*
|
||||||
|
|
||||||
obj ConTest {
|
obj ConTest {
|
||||||
var a: int
|
var a: int
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import simple_print:*;
|
import io:*;
|
||||||
|
|
||||||
obj objectA {
|
obj objectA {
|
||||||
var a: int;
|
var a: int;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import simple_print:*
|
import io:*
|
||||||
|
|
||||||
fun oneLine1():void println(7)
|
fun oneLine1():void println(7)
|
||||||
fun oneLine2():int return 8
|
fun oneLine2():int return 8
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import simple_print:*
|
import io:*
|
||||||
|
|
||||||
fun main():int {
|
fun main():int {
|
||||||
var message = "thingy: "
|
var message = "thingy: "
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import simple_print:*
|
import io:*
|
||||||
|
|
||||||
obj test_cons(Object) {
|
obj test_cons(Object) {
|
||||||
fun construct(): *test_cons {
|
fun construct(): *test_cons {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import simple_print:*
|
import io:*
|
||||||
import sameNameOne
|
import sameNameOne
|
||||||
import sameNameTwo
|
import sameNameTwo
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import simple_print:*
|
import io:*
|
||||||
|
|
||||||
fun is_true():bool {
|
fun is_true():bool {
|
||||||
return true
|
return true
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import simple_print:*
|
import io:*
|
||||||
|
|
||||||
fun addAndPrintInt(a: int, b: int): int {
|
fun addAndPrintInt(a: int, b: int): int {
|
||||||
print(a+b);
|
print(a+b);
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
import simple_print;
|
import io;
|
||||||
|
|
||||||
|
|
||||||
obj TemplateTest<T,J> {
|
obj TemplateTest<T,J> {
|
||||||
var a: T;
|
var a: T;
|
||||||
var b: J;
|
var b: J;
|
||||||
fun print(): void {
|
fun print(): void {
|
||||||
simple_print::print("a: ");
|
io::print("a: ");
|
||||||
simple_print::print(a);
|
io::print(a);
|
||||||
simple_print::print("\n");
|
io::print("\n");
|
||||||
simple_print::print("b: ");
|
io::print("b: ");
|
||||||
simple_print::print(b);
|
io::print(b);
|
||||||
simple_print::print("\n");
|
io::print("\n");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
import simple_print;
|
import io;
|
||||||
|
|
||||||
|
|
||||||
obj TemplateTest<T> {
|
obj TemplateTest<T> {
|
||||||
var a: int;
|
var a: int;
|
||||||
var b: T;
|
var b: T;
|
||||||
fun print(): void {
|
fun print(): void {
|
||||||
simple_print::print("a: ");
|
io::print("a: ");
|
||||||
simple_print::print(a);
|
io::print(a);
|
||||||
simple_print::print("\n");
|
io::print("\n");
|
||||||
simple_print::print("b: ");
|
io::print("b: ");
|
||||||
simple_print::print(b);
|
io::print(b);
|
||||||
simple_print::print("\n");
|
io::print("\n");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import simple_print;
|
import io;
|
||||||
|
|
||||||
obj FirstObject {
|
obj FirstObject {
|
||||||
var objectNum: int;
|
var objectNum: int;
|
||||||
fun PrintSelf(a: int): void {
|
fun PrintSelf(a: int): void {
|
||||||
simple_print::print(objectNum);
|
io::print(objectNum);
|
||||||
simple_print::print(a);
|
io::print(a);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -12,6 +12,6 @@ fun main(): int {
|
|||||||
var wooObject: FirstObject;
|
var wooObject: FirstObject;
|
||||||
wooObject.objectNum = 5;
|
wooObject.objectNum = 5;
|
||||||
wooObject.PrintSelf(7);
|
wooObject.PrintSelf(7);
|
||||||
simple_print::print("\n");
|
io::print("\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import simple_print:*
|
import io:*
|
||||||
|
|
||||||
obj templd<T> {
|
obj templd<T> {
|
||||||
var data: T
|
var data: T
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import simple_print:*;
|
import io:*;
|
||||||
import trivial_container:*;
|
import trivial_container:*;
|
||||||
|
|
||||||
obj TemplateTest<T> {
|
obj TemplateTest<T> {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import simple_print:*
|
import io:*
|
||||||
|
|
||||||
obj it {
|
obj it {
|
||||||
fun operator+<U>(other: U): it {
|
fun operator+<U>(other: U): it {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import simple_print:*
|
import io:*
|
||||||
|
|
||||||
obj Object<T> {
|
obj Object<T> {
|
||||||
var data: T
|
var data: T
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import simple_print:*;
|
import io:*;
|
||||||
|
|
||||||
fun main(): int {
|
fun main(): int {
|
||||||
var b: int;
|
var b: int;
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import simple_print;
|
import io;
|
||||||
|
|
||||||
var a: int = 42;
|
var a: int = 42;
|
||||||
var b = "hi";
|
var b = "hi";
|
||||||
|
|
||||||
fun main(): int {
|
fun main(): int {
|
||||||
simple_print::println(a);
|
io::println(a);
|
||||||
simple_print::println(b);
|
io::println(b);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import simple_print:*;
|
import io:*;
|
||||||
|
|
||||||
obj NoTraits {};
|
obj NoTraits {};
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import simple_print;
|
import io;
|
||||||
|
|
||||||
obj ClassWithConstructor {
|
obj ClassWithConstructor {
|
||||||
var data: int;
|
var data: int;
|
||||||
@@ -7,7 +7,7 @@ obj ClassWithConstructor {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
fun printData(): void {
|
fun printData(): void {
|
||||||
simple_print::println(data);
|
io::println(data);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -15,6 +15,6 @@ fun main(): int {
|
|||||||
var object.construct(4): ClassWithConstructor;
|
var object.construct(4): ClassWithConstructor;
|
||||||
object.printData();
|
object.printData();
|
||||||
var a :int = 8;
|
var a :int = 8;
|
||||||
simple_print::println(a);
|
io::println(a);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import util:*
|
import util:*
|
||||||
import simple_print:*
|
import io:*
|
||||||
|
|
||||||
obj test(Object) {
|
obj test(Object) {
|
||||||
var counter:int
|
var counter:int
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import simple_print;
|
import io;
|
||||||
|
|
||||||
obj trivialContainer<T> {
|
obj trivialContainer<T> {
|
||||||
var data: T;
|
var data: T;
|
||||||
fun print(): void {
|
fun print(): void {
|
||||||
simple_print::print(data);
|
io::print(data);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user