Wooo! Fixed up remaining bugs in new syntax!
This commit is contained in:
@@ -4,13 +4,13 @@ __if_comp__ __C__ simple_passthrough """
|
||||
int diff = 7;
|
||||
"""
|
||||
|
||||
|void| print_it() {
|
||||
fun print_it(): void {
|
||||
__if_comp__ __C__ simple_passthrough """
|
||||
printf("diff_file: %d\n", diff);
|
||||
"""
|
||||
}
|
||||
|
||||
|void| print_it(|int| i) {
|
||||
fun print_it(i: int): void {
|
||||
__if_comp__ __C__ simple_passthrough(i = i::) """
|
||||
printf("diff_file: %d\n", i);
|
||||
"""
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
|int| sameVar;
|
||||
|int| sameFun() { return 5; }
|
||||
var sameVar: int;
|
||||
fun sameFun(): int { return 5; }
|
||||
typedef classTester {
|
||||
|int| method() { return 8; }
|
||||
fun method(): int { return 8; }
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
|int| sameVar;
|
||||
|int| sameFun() { return 6; }
|
||||
var sameVar: int;
|
||||
fun sameFun(): int { return 6; }
|
||||
typedef classTester {
|
||||
|int| method() { return 9; }
|
||||
fun method(): int { return 9; }
|
||||
}
|
||||
|
||||
@@ -1,27 +1,27 @@
|
||||
|int| qualified_variable = 7;
|
||||
|int| qualified_func() { return 9; }
|
||||
var qualified_variable: int = 7;
|
||||
fun qualified_func(): int { return 9; }
|
||||
|
||||
typedef qualified_class {
|
||||
|int| number;
|
||||
|qualified_class*| construct(|int| num) {
|
||||
var number: int;
|
||||
fun construct(num: int): qualified_class* {
|
||||
number = num;
|
||||
return this;
|
||||
}
|
||||
|int| get() {
|
||||
fun get(): int {
|
||||
return number;
|
||||
}
|
||||
};
|
||||
|
||||
typedef template <T> qualified_container {
|
||||
|T| data;
|
||||
|qualified_container<T>*| construct(|T| dataIn) {
|
||||
typedef qualified_container<T> {
|
||||
var data: T;
|
||||
fun construct(dataIn: T): qualified_container<T>* {
|
||||
data = dataIn;
|
||||
}
|
||||
|T| get() {
|
||||
fun get(): T {
|
||||
return data;
|
||||
}
|
||||
};
|
||||
|
||||
template<T> |T| qualified_id(|T| it) {
|
||||
fun qualified_id<T>(it: T): T {
|
||||
return it;
|
||||
}
|
||||
|
||||
@@ -1,27 +1,27 @@
|
||||
|int| unqualifed_variable = 8;
|
||||
|int| unqualified_func() { return 10; }
|
||||
var unqualifed_variable: int = 8;
|
||||
fun unqualified_func(): int { return 10; }
|
||||
|
||||
typedef unqualified_class {
|
||||
|int| number;
|
||||
|unqualified_class*| construct(|int| num) {
|
||||
var number: int;
|
||||
fun construct(num: int): unqualified_class* {
|
||||
number = num;
|
||||
return this;
|
||||
}
|
||||
|int| get() {
|
||||
fun get(): int {
|
||||
return number;
|
||||
}
|
||||
};
|
||||
|
||||
typedef template <T> unqualified_container {
|
||||
|T| data;
|
||||
|unqualified_container<T>*| construct(|T| dataIn) {
|
||||
typedef unqualified_container<T> {
|
||||
var data: T;
|
||||
fun construct(dataIn: T): unqualified_container<T>* {
|
||||
data = dataIn;
|
||||
}
|
||||
|T| get() {
|
||||
fun get(): T {
|
||||
return data;
|
||||
}
|
||||
};
|
||||
|
||||
template<T> |T| unqualified_id(|T| it) {
|
||||
fun unqualified_id<T>(it: T): T {
|
||||
return it;
|
||||
}
|
||||
|
||||
@@ -1,44 +1,44 @@
|
||||
import io:*;
|
||||
|
||||
typedef Vec2 {
|
||||
|int| x;
|
||||
|int| y;
|
||||
var x: int;
|
||||
var y: int;
|
||||
|
||||
|void| print() {
|
||||
fun print(): void {
|
||||
print(x);
|
||||
print(" ");
|
||||
print(y);
|
||||
}
|
||||
|
||||
|Vec2| add(|Vec2| other) {
|
||||
|Vec2| toReturn;
|
||||
fun add(other: Vec2): Vec2 {
|
||||
var toReturn: Vec2;
|
||||
toReturn.x = x + other.x;
|
||||
toReturn.y = y + other.y;
|
||||
print();
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
|Vec2| subtract(|Vec2| other) {
|
||||
|Vec2| toReturn;
|
||||
fun subtract(other: Vec2): Vec2 {
|
||||
var toReturn: Vec2;
|
||||
toReturn.x = x - other.x;
|
||||
toReturn.y = y - other.y;
|
||||
print();
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
|Vec2| operator+(|Vec2| other) {
|
||||
fun operator+(other: Vec2): Vec2 {
|
||||
return add(other);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|Vec2| operator-(|Vec2| lhs, |Vec2| rhs) {
|
||||
fun operator-(lhs: Vec2, rhs: Vec2): Vec2 {
|
||||
return lhs.subtract(rhs);
|
||||
}
|
||||
|
||||
|int| main() {
|
||||
|Vec2| vector1;
|
||||
|Vec2| vector2;
|
||||
fun main(): int {
|
||||
var vector1: Vec2;
|
||||
var vector2: Vec2;
|
||||
vector1.x = 3;
|
||||
vector1.y = 9;
|
||||
vector2 = vector1;
|
||||
@@ -48,13 +48,13 @@ typedef Vec2 {
|
||||
vector3.y = vector1.y + vector2.y;
|
||||
vector2.print();
|
||||
*/
|
||||
|Vec2| addition = vector1 + vector2;
|
||||
var addition: Vec2 = vector1 + vector2;
|
||||
print("\n");
|
||||
addition.print();
|
||||
print("\nSubtraction\n");
|
||||
vector2.x = 100;
|
||||
vector2.y = 70;
|
||||
|Vec2| subtraction = vector1 - vector2;
|
||||
var subtraction: Vec2 = vector1 - vector2;
|
||||
print("\n");
|
||||
print(subtraction.x); print(" "); print(subtraction.y);
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import io:*;
|
||||
|
||||
|int| fibanacci(|int| num) {
|
||||
fun fibanacci(num: int): int {
|
||||
if (num < 2)
|
||||
return 1;
|
||||
return fibanacci(num-1) + fibanacci(num-2);
|
||||
}
|
||||
|
||||
|int| main() {
|
||||
fun main(): int {
|
||||
print(fibanacci(4));
|
||||
print("\n");
|
||||
return 0;
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
import io;
|
||||
|int| main() {
|
||||
fun main(): void {
|
||||
io::println("Spam");
|
||||
|int| x = 4;
|
||||
var x: int = 4;
|
||||
x += 3;
|
||||
x++;
|
||||
|int| y = 6;
|
||||
|int| z = x + y;
|
||||
|int| q = z+z;
|
||||
|int| q2 = z*3;
|
||||
|int| q3 = y + y;
|
||||
var y :int = 6;
|
||||
var z :int = x + y;
|
||||
var q :int = z+z;
|
||||
var q2:int = z*3;
|
||||
var q3:int = y + y;
|
||||
io::println(q3);
|
||||
io::println(z);
|
||||
io::println(q);
|
||||
for (|int| i = 0; i < 20; i++;) z++;
|
||||
for (var i:int = 0; i < 20; i++;) z++;
|
||||
if (z > 20) io::println("We'll find out.");
|
||||
io::println(z);
|
||||
}
|
||||
|
||||
@@ -6,15 +6,15 @@ __if_comp__ __C__ simple_passthrough """
|
||||
int same = 5;
|
||||
"""
|
||||
|
||||
|int| main() {
|
||||
fun main(): int {
|
||||
|
||||
__if_comp__ __C__ simple_passthrough """
|
||||
printf("same_file: %d\n", same);
|
||||
"""
|
||||
|
||||
c_passthrough_diff::print_it();
|
||||
|int| i = 7;
|
||||
|int| j = 6;
|
||||
var i: int = 7;
|
||||
var j: int = 6;
|
||||
__if_comp__ __C__ simple_passthrough(i = i, j = j : j = j:) """
|
||||
j = i + j;
|
||||
"""
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import vector:*;
|
||||
import io:*;
|
||||
|
||||
template <T> |T| test(|vector<T>| a) {
|
||||
fun test<T>(a: vector<T>): T {
|
||||
return a.at(0);
|
||||
}
|
||||
|
||||
|int| main() {
|
||||
|vector<int>| a.construct();
|
||||
fun main(): int {
|
||||
var a.construct(): vector<int>;
|
||||
a.addEnd(2);
|
||||
println(test<int>(a));
|
||||
return 0;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* Comment first! */
|
||||
import io:*;
|
||||
|
||||
|int| main() {
|
||||
fun main(): int {
|
||||
println(1337) /*how bout now*/
|
||||
println(42) //or now
|
||||
return 0;
|
||||
|
||||
@@ -2,24 +2,24 @@ import io:*;
|
||||
import mem:*;
|
||||
|
||||
typedef ClassWithConstructor {
|
||||
|int| data;
|
||||
|ClassWithConstructor*| construct(|int| inData) {
|
||||
var data: int;
|
||||
fun construct(inData: int): ClassWithConstructor* {
|
||||
data = inData;
|
||||
return this;
|
||||
}
|
||||
|void| printData() {
|
||||
fun printData(): void {
|
||||
println(data);
|
||||
}
|
||||
};
|
||||
|
||||
|int| main() {
|
||||
|ClassWithConstructor| object.construct(4);
|
||||
fun main(): int {
|
||||
var object.construct(4): ClassWithConstructor;
|
||||
//ClassWithConstructor object;
|
||||
//object.construct(4);
|
||||
object.printData();
|
||||
|int| a = 8;
|
||||
var a: int = 8;
|
||||
println(a);
|
||||
|ClassWithConstructor*| objPtr = new<ClassWithConstructor>()->construct(11);
|
||||
var objPtr: ClassWithConstructor* = new<ClassWithConstructor>()->construct(11);
|
||||
objPtr->printData();
|
||||
delete<ClassWithConstructor>(objPtr);
|
||||
return 0;
|
||||
|
||||
@@ -1,27 +1,27 @@
|
||||
import io:*;
|
||||
|
||||
typedef DestructorPrint {
|
||||
|char*| myStr;
|
||||
|DestructorPrint*| construct(|char*| str) {
|
||||
var myStr: char*;
|
||||
fun construct(str: char*): DestructorPrint* {
|
||||
myStr = str;
|
||||
return this;
|
||||
}
|
||||
|void| destruct() {
|
||||
fun destruct(): void {
|
||||
println(myStr);
|
||||
}
|
||||
};
|
||||
|
||||
typedef NoDistruction {
|
||||
|int| a;
|
||||
|void| dummyFunc() {}
|
||||
var a: int;
|
||||
fun dummyFunc(): void {}
|
||||
};
|
||||
|
||||
|void| indirPrint() {
|
||||
|DestructorPrint| testObj.construct("Hello Destructors!");
|
||||
|NoDistruction| dummy;
|
||||
fun indirPrint(): void {
|
||||
var testObj.construct("Hello Destructors!"): DestructorPrint;
|
||||
var dummy: NoDistruction;
|
||||
}
|
||||
|
||||
|int| main() {
|
||||
fun main(): int {
|
||||
indirPrint();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import io:*;
|
||||
|
||||
|
||||
|int| main() {
|
||||
fun main(): int {
|
||||
if (1>2) {
|
||||
println("Wrong");
|
||||
} else {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import io;
|
||||
|
||||
|void| nothing() {}
|
||||
fun nothing(): void {}
|
||||
|
||||
|int| main() {
|
||||
fun main(): int {
|
||||
nothing();
|
||||
io::println("It was nothing");
|
||||
return 0;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import io:*;
|
||||
|
||||
template <T,J> |void| addAndPrint(|T| a, |J| b) {
|
||||
fun addAndPrint<T,J>(a: T, b: J): void {
|
||||
print(a+b);
|
||||
}
|
||||
|
||||
|int| main() {
|
||||
fun main(): int {
|
||||
|
||||
addAndPrint<int,double>(10,12.14159);
|
||||
print("\n");
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
import io:*;
|
||||
|
||||
|int| ret1() {
|
||||
fun ret1(): int {
|
||||
return ret2() / 2;
|
||||
}
|
||||
|
||||
|
||||
|int| main() {
|
||||
fun main(): int {
|
||||
print(ret1());
|
||||
print(ret2());
|
||||
print("\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|int| ret2() {
|
||||
fun ret2(): int {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import io;
|
||||
|
||||
template <T> |T| addAndPrint(|T| a, |T| b) {
|
||||
fun addAndPrint<T>(a: T, b: T): T {
|
||||
io::print(a+b);
|
||||
return a+b;
|
||||
}
|
||||
|
||||
|int| main() {
|
||||
fun main(): int {
|
||||
addAndPrint<int>(10,12);
|
||||
io::print("\n");
|
||||
|
||||
|
||||
@@ -2,11 +2,11 @@ import mem:*;
|
||||
import io:*;
|
||||
|
||||
typedef AnObject {
|
||||
|int| a;
|
||||
|int| b;
|
||||
|char*| c;
|
||||
var a: int;
|
||||
var b: int;
|
||||
var c: char*;
|
||||
|
||||
|void| print() {
|
||||
fun print(): void {
|
||||
print(a+b);
|
||||
print("\n");
|
||||
print(c);
|
||||
@@ -15,8 +15,8 @@ typedef AnObject {
|
||||
};
|
||||
|
||||
|
||||
|int| main() {
|
||||
|AnObject*| ptr = new<AnObject>();
|
||||
fun main(): int {
|
||||
var ptr: AnObject* = new<AnObject>();
|
||||
ptr->a = 4;
|
||||
ptr->b = 7;
|
||||
ptr->c = "Hello decent memory! Quite a nice feeling\n";
|
||||
|
||||
@@ -1,25 +1,25 @@
|
||||
import io:*;
|
||||
|
||||
typedef firstObject {
|
||||
|int| objectNum;
|
||||
|int| other;
|
||||
|void| print() {
|
||||
var objectNum: int;
|
||||
var other: int;
|
||||
fun print(): void {
|
||||
print(other);
|
||||
}
|
||||
|void| printInd() {
|
||||
fun printInd(): void {
|
||||
print();
|
||||
}
|
||||
};
|
||||
|
||||
typedef Int int;
|
||||
|
||||
|Int| aliasNum;
|
||||
var aliasNum: Int;
|
||||
|
||||
|int| main() {
|
||||
|firstObject| wooObject;
|
||||
fun main(): int {
|
||||
var wooObject: firstObject;
|
||||
wooObject.objectNum = 7;
|
||||
print(wooObject.objectNum);
|
||||
|firstObject*| objPtr = &wooObject;
|
||||
var objPtr: firstObject* = &wooObject;
|
||||
objPtr->objectNum = 42;
|
||||
print(objPtr->objectNum);
|
||||
print("\n");
|
||||
|
||||
@@ -2,30 +2,30 @@ import io:*;
|
||||
import trivial_container:*;
|
||||
|
||||
typedef RegularObject {
|
||||
|int| num;
|
||||
|trivialContainer<char*>| innerContainer;
|
||||
|void| set(|char*| message, |int| number) {
|
||||
var num: int;
|
||||
var innerContainer: trivialContainer<char*>;
|
||||
fun set(message: char*, number: int): void {
|
||||
innerContainer.data = message;
|
||||
num = number;
|
||||
}
|
||||
|char*| get() {
|
||||
fun get(): char* {
|
||||
return innerContainer.data;
|
||||
}
|
||||
|void| print() {
|
||||
fun print(): void {
|
||||
print(num);
|
||||
innerContainer.print();
|
||||
}
|
||||
};
|
||||
|
||||
typedef MyIntContainer trivialContainer<int>;
|
||||
|MyIntContainer| roundabout;
|
||||
|RegularObject| outsideDec;
|
||||
var roundabout: MyIntContainer;
|
||||
var outsideDec: RegularObject;
|
||||
|
||||
|void| print(|trivialContainer<char*>| toPrint) {
|
||||
fun print(toPrint: trivialContainer<char*>): void {
|
||||
print(toPrint.data);
|
||||
}
|
||||
|
||||
|int| main() {
|
||||
fun main(): int {
|
||||
roundabout.data = 4;
|
||||
outsideDec.set("Hello!", 5);
|
||||
roundabout.print();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import io:*;
|
||||
|
||||
|
||||
|int| main() {
|
||||
fun main(): int {
|
||||
if (1 != 2)
|
||||
println("Correct");
|
||||
}
|
||||
|
||||
@@ -2,16 +2,16 @@ import io;
|
||||
import scopeQualified;
|
||||
import scopeUnqualified : * ;
|
||||
|
||||
|int| main() {
|
||||
fun main(): int {
|
||||
io::println("Qualified io!");
|
||||
|
||||
// Defined in scopeQualified
|
||||
io::println(scopeQualified::qualified_variable);
|
||||
io::println(scopeQualified::qualified_func());
|
||||
|scopeQualified::qualified_class| qClass.construct(11);
|
||||
var qClass.construct(11): scopeQualified::qualified_class;
|
||||
io::println(qClass.get());
|
||||
|
||||
|scopeQualified::qualified_container<char*>| sayQualified.construct("Qualified Container!");
|
||||
var sayQualified.construct("Qualified Container!"): scopeQualified::qualified_container<char*>;
|
||||
io::println(sayQualified.get());
|
||||
io::println(scopeQualified::qualified_id<char*>("Even template functions qualified!"));
|
||||
|
||||
@@ -21,10 +21,10 @@ import scopeUnqualified : * ;
|
||||
// Defined in scopeUnqualified
|
||||
io::println(unqualifed_variable);
|
||||
io::println(unqualified_func());
|
||||
|unqualified_class| uqClass.construct(12);
|
||||
var uqClass.construct(12): unqualified_class;
|
||||
io::println(uqClass.get());
|
||||
|
||||
|unqualified_container<char*>| sayUnqualified.construct("Unqualified Container!");
|
||||
var sayUnqualified.construct("Unqualified Container!"): unqualified_container<char*>;
|
||||
io::println(sayUnqualified.get());
|
||||
io::println(unqualified_id<char*>("Even template functions unqualified!"));
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import io:*
|
||||
|
||||
|int| main() {
|
||||
fun main(): int {
|
||||
println("no semicolons!")
|
||||
if (1 < 2) println("still no!")
|
||||
println("and again")
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
import io:*;
|
||||
|
||||
typedef objectA {
|
||||
|int| a;
|
||||
var a: int;
|
||||
};
|
||||
|
||||
typedef BigObject {
|
||||
|objectA| a;
|
||||
|objectB| b;
|
||||
|int| add() {
|
||||
var a: objectA;
|
||||
var b: objectB;
|
||||
fun add(): int {
|
||||
return a.a + b.b;
|
||||
}
|
||||
};
|
||||
|
||||
typedef objectB {
|
||||
|int| b;
|
||||
var b: int;
|
||||
};
|
||||
|
||||
|
||||
|int| main() {
|
||||
|BigObject| c;
|
||||
fun main(): int {
|
||||
var c: BigObject;
|
||||
c.a.a = 4;
|
||||
c.b.b = 8;
|
||||
print(c.add());
|
||||
|
||||
@@ -2,23 +2,23 @@ import io:*
|
||||
import sameNameOne
|
||||
import sameNameTwo
|
||||
|
||||
|int| sameVar;
|
||||
|int| sameFun() { return 4; }
|
||||
var sameVar: int;
|
||||
fun sameFun(): int { return 4; }
|
||||
|
||||
typedef classTester {
|
||||
|int| method() {
|
||||
fun method(): int {
|
||||
return 7
|
||||
}
|
||||
}
|
||||
|
||||
|int| main() {
|
||||
fun main(): int {
|
||||
sameVar = 1
|
||||
sameNameOne::sameVar = 2
|
||||
sameNameTwo::sameVar = 3
|
||||
|
||||
|classTester| class1;
|
||||
|sameNameOne::classTester| class2;
|
||||
|sameNameTwo::classTester| class3;
|
||||
var class1: classTester;
|
||||
var class2: sameNameOne::classTester;
|
||||
var class3: sameNameTwo::classTester;
|
||||
|
||||
println(sameVar)
|
||||
println(sameNameOne::sameVar)
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import io:*;
|
||||
|
||||
|int| addAndPrintInt(|int| a, |int| b) {
|
||||
fun addAndPrintInt(a: int, b: int): int {
|
||||
print(a+b);
|
||||
return a+b;
|
||||
}
|
||||
|
||||
|int| main() {
|
||||
fun main(): int {
|
||||
|
||||
print(addAndPrintInt(7,12));
|
||||
print("\n");
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import io;
|
||||
|
||||
|
||||
typedef template <T,J> TemplateTest {
|
||||
|T| a;
|
||||
|J| b;
|
||||
|void| print() {
|
||||
typedef TemplateTest<T,J> {
|
||||
var a: T;
|
||||
var b: J;
|
||||
fun print(): void {
|
||||
io::print("a: ");
|
||||
io::print(a);
|
||||
io::print("\n");
|
||||
@@ -14,10 +14,10 @@ typedef template <T,J> TemplateTest {
|
||||
}
|
||||
};
|
||||
|
||||
|int| main() {
|
||||
fun main(): int {
|
||||
|
||||
|TemplateTest<int, char*>| test;
|
||||
|TemplateTest<char*, char*>| test2;
|
||||
var test: TemplateTest<int, char*>;
|
||||
var test2: TemplateTest<char*, char*>;
|
||||
test.a = 24;
|
||||
test.b = "Hello World";
|
||||
test2.a = "Pi incoming";
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import io;
|
||||
|
||||
|
||||
typedef template <T> TemplateTest {
|
||||
|int| a;
|
||||
|T| b;
|
||||
|void| print() {
|
||||
typedef TemplateTest<T> {
|
||||
var a: int;
|
||||
var b: T;
|
||||
fun print(): void {
|
||||
io::print("a: ");
|
||||
io::print(a);
|
||||
io::print("\n");
|
||||
@@ -14,10 +14,10 @@ typedef template <T> TemplateTest {
|
||||
}
|
||||
};
|
||||
|
||||
|int| main() {
|
||||
fun main(): int {
|
||||
|
||||
|TemplateTest<int>| test;
|
||||
|TemplateTest<char*>| test2;
|
||||
var test: TemplateTest<int>;
|
||||
var test2: TemplateTest<char*>;
|
||||
test.a = 5;
|
||||
test.b = 7;
|
||||
test2.a = 9;
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
import io;
|
||||
|
||||
typedef FirstObject {
|
||||
|int| objectNum;
|
||||
|void| PrintSelf(|int| a) {
|
||||
var objectNum: int;
|
||||
fun PrintSelf(a: int): void {
|
||||
io::print(objectNum);
|
||||
io::print(a);
|
||||
}
|
||||
};
|
||||
|
||||
|int| main() {
|
||||
|FirstObject| wooObject;
|
||||
fun main(): int {
|
||||
var wooObject: FirstObject;
|
||||
wooObject.objectNum = 5;
|
||||
wooObject.PrintSelf(7);
|
||||
io::print("\n");
|
||||
|
||||
@@ -2,8 +2,8 @@ import io;
|
||||
import string;
|
||||
|
||||
|
||||
|int| main() {
|
||||
|string::string| str.construct("hello strings");
|
||||
fun main(): int {
|
||||
var str.construct("hello strings"): string::string;
|
||||
io::println(str);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import io:*;
|
||||
import trivial_container:*;
|
||||
|
||||
typedef template <T> TemplateTest {
|
||||
|int| a;
|
||||
|T| b;
|
||||
|trivialContainer<T>| c;
|
||||
|void| print() {
|
||||
typedef TemplateTest<T> {
|
||||
var a: int;
|
||||
var b: T;
|
||||
var c: trivialContainer<T>;
|
||||
fun print(): void {
|
||||
print("a: ");
|
||||
print(a);
|
||||
print("\n");
|
||||
@@ -19,17 +19,17 @@ typedef template <T> TemplateTest {
|
||||
|
||||
typedef MyInt int;
|
||||
|
||||
|MyInt| c;
|
||||
var c: MyInt;
|
||||
|
||||
|
||||
template <T> |T| addAndPrint(|T| a, |T| b) {
|
||||
fun addAndPrint<T>(a: T, b: T): T {
|
||||
print(a+b);
|
||||
return a+b;
|
||||
}
|
||||
|
||||
|int| main() {
|
||||
|TemplateTest<int>| test;
|
||||
|TemplateTest<char*>| test2;
|
||||
fun main(): int {
|
||||
var test: TemplateTest<int>;
|
||||
var test2: TemplateTest<char*>;
|
||||
test.a = 5;
|
||||
test.b = 7;
|
||||
test.c.data = 1337;
|
||||
@@ -40,7 +40,7 @@ template <T> |T| addAndPrint(|T| a, |T| b) {
|
||||
test.print();
|
||||
test2.print();
|
||||
|
||||
|trivialContainer<char*>| testImport;
|
||||
var testImport: trivialContainer<char*>;
|
||||
testImport.data = "From another file! Whoh!";
|
||||
testImport.print();
|
||||
print("\n");
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import io:*;
|
||||
import mem:*;
|
||||
|
||||
|int| main() {
|
||||
|int| b;
|
||||
|int*| a = &b;
|
||||
fun main(): int {
|
||||
var b: int;
|
||||
var a: int* = &b;
|
||||
a [ 0 ] = 7;
|
||||
print(a [ 0 ] );
|
||||
print(*a);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import io;
|
||||
|
||||
|int| a = 42;
|
||||
var a: int = 42;
|
||||
|
||||
|int| main() {
|
||||
fun main(): int {
|
||||
io::println(a);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -7,19 +7,19 @@ typedef Trait2 (SecondTrait) {};
|
||||
typedef TwoTrait (FirstTrait, SecondTrait) {};
|
||||
typedef AlreadySpecilized (FirstTrait, SecondTrait) {};
|
||||
|
||||
template <T> |void| OneTwoFunc(|T| obj) {
|
||||
fun OneTwoFunc<T>(obj: T): void {
|
||||
println("No Traits");
|
||||
}
|
||||
|
||||
template <T(FirstTrait)> |void| OneTwoFunc(|T| obj) {
|
||||
fun OneTwoFunc<T(FirstTrait)>(obj: T): void {
|
||||
println("First Trait");
|
||||
}
|
||||
|
||||
template <T(SecondTrait)> |void| OneTwoFunc(|T| obj) {
|
||||
fun OneTwoFunc<T(SecondTrait)>(obj: T): void {
|
||||
println("Second Trait");
|
||||
}
|
||||
|
||||
template <T(FirstTrait, SecondTrait)> |void| OneTwoFunc(|T| obj) {
|
||||
fun OneTwoFunc<T(FirstTrait, SecondTrait)>(obj: T): void {
|
||||
println("Both Traits");
|
||||
}
|
||||
/*
|
||||
@@ -30,10 +30,10 @@ template <AlreadySpecilized> |void| OneTwoFunc(|AlreadySpecilized| obj) {
|
||||
//This should work for objects too!
|
||||
//To test, we cycle the mapping of traits
|
||||
|
||||
typedef template<T> OneTwoObj (FirstTrait) {};
|
||||
typedef template<T(FirstTrait)> OneTwoObj (SecondTrait) {};
|
||||
typedef template<T(SecondTrait)> OneTwoObj (FirstTrait, SecondTrait) {};
|
||||
typedef template<T(FirstTrait, SecondTrait)> OneTwoObj {};
|
||||
typedef OneTwoObj<T> (FirstTrait) {};
|
||||
typedef OneTwoObj<T(FirstTrait)> (SecondTrait) {};
|
||||
typedef OneTwoObj<T(SecondTrait)> (FirstTrait, SecondTrait) {};
|
||||
typedef OneTwoObj<T(FirstTrait, SecondTrait)> {};
|
||||
/*
|
||||
*typedef template<AlreadySpecilized> OneTwoObj {
|
||||
* void proveSpecilized() {
|
||||
@@ -42,12 +42,12 @@ typedef template<T(FirstTrait, SecondTrait)> OneTwoObj {};
|
||||
*};
|
||||
*/
|
||||
|
||||
|int| main() {
|
||||
|NoTraits| a;
|
||||
|Trait1| b;
|
||||
|Trait2| c;
|
||||
|TwoTrait| d;
|
||||
|AlreadySpecilized| e;
|
||||
fun main(): int {
|
||||
var a: NoTraits;
|
||||
var b: Trait1;
|
||||
var c: Trait2;
|
||||
var d: TwoTrait;
|
||||
var e: AlreadySpecilized;
|
||||
|
||||
OneTwoFunc<NoTraits>(a);
|
||||
OneTwoFunc<Trait1>(b);
|
||||
@@ -57,10 +57,10 @@ typedef template<T(FirstTrait, SecondTrait)> OneTwoObj {};
|
||||
|
||||
println();
|
||||
|
||||
|OneTwoObj<NoTraits>| alpha;
|
||||
|OneTwoObj<Trait1>| beta;
|
||||
|OneTwoObj<Trait2>| gamma;
|
||||
|OneTwoObj<TwoTrait>| delta;
|
||||
var alpha: OneTwoObj<NoTraits>;
|
||||
var beta: OneTwoObj<Trait1>;
|
||||
var gamma: OneTwoObj<Trait2>;
|
||||
var delta: OneTwoObj<TwoTrait>;
|
||||
// |OneTwoObj<AlreadySpecilized>| epsilon;
|
||||
|
||||
OneTwoFunc<OneTwoObj<NoTraits>>(alpha);
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import io:*;
|
||||
import math:*;
|
||||
|
||||
|int| main()
|
||||
fun main(): int
|
||||
{
|
||||
|double| ans;
|
||||
|double| STD_PI = 4.0*atan(1.0);
|
||||
var ans: double;
|
||||
var STD_PI: double = 4.0*atan(1.0);
|
||||
println(STD_PI);
|
||||
|
||||
/*
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
import io;
|
||||
|
||||
typedef ClassWithConstructor {
|
||||
|int| data;
|
||||
|ClassWithConstructor*| construct(|int| inData) {
|
||||
var data: int;
|
||||
fun construct(inData: int): ClassWithConstructor* {
|
||||
data = inData;
|
||||
return this;
|
||||
}
|
||||
|void| printData() {
|
||||
fun printData(): void {
|
||||
io::println(data);
|
||||
}
|
||||
};
|
||||
|
||||
|int| main() {
|
||||
|ClassWithConstructor| object.construct(4);
|
||||
fun main(): int {
|
||||
var object.construct(4): ClassWithConstructor;
|
||||
object.printData();
|
||||
|int| a = 8;
|
||||
var a :int = 8;
|
||||
io::println(a);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -3,25 +3,25 @@ import mem:*;
|
||||
import vector:*;
|
||||
|
||||
typedef AbleToBeDestroyed (Destructable) {
|
||||
|void| destruct() {
|
||||
fun destruct(): void {
|
||||
println("Destroyed!");
|
||||
}
|
||||
};
|
||||
|
||||
|int| main() {
|
||||
|vector<int>| intVec.construct();
|
||||
fun main(): int {
|
||||
var intVec.construct(): vector<int>;
|
||||
intVec.addEnd(1);
|
||||
intVec.addEnd(3);
|
||||
intVec.addEnd(3);
|
||||
intVec.addEnd(7);
|
||||
println(intVec.size);
|
||||
for (|int| i = 0; i < intVec.size; i++;)
|
||||
for (var i: int = 0; i < intVec.size; i++;)
|
||||
print(intVec.at(i));
|
||||
|
||||
println();
|
||||
|
||||
|vector<AbleToBeDestroyed>*| desVec = new<vector<AbleToBeDestroyed>>()->construct();
|
||||
|AbleToBeDestroyed| testDestruct;
|
||||
var desVec: vector<AbleToBeDestroyed>* = new<vector<AbleToBeDestroyed>>()->construct();
|
||||
var testDestruct: AbleToBeDestroyed;
|
||||
desVec->addEnd(testDestruct);
|
||||
delete<vector<AbleToBeDestroyed>>(desVec);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user