-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add testsuite/driver for Parser (#10)
* Add testsuite/driver for Parser * Update workflow
- Loading branch information
Showing
23 changed files
with
395 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,3 +65,4 @@ testcases/string | |
testcases/string.xsharp.bc | ||
testcases/string.xsharp.o | ||
LLVMIR/test/temp | ||
XSharp/test/Parser/temp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
void main() | ||
{ | ||
i32 n; | ||
n = inputI32(); | ||
|
||
i32 i=0; | ||
i32 a=1; | ||
i32 b=1; | ||
i32 c=1; | ||
u8 d = 0; | ||
while (i<n){ | ||
a = c = (-a)+b*c/66; | ||
a = b % 3 / 2 + 4 + (b = 4); | ||
b = c; | ||
i=i+1; | ||
} | ||
print(a); | ||
print(b); | ||
print(c); | ||
print(-c); | ||
print(!(c == -1)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
func [main]()->[void] { | ||
Var n:i32 | ||
[n] = [call inputI32()] | ||
Var i:i32 = 0 | ||
Var a:i32 = 1 | ||
Var b:i32 = 1 | ||
Var c:i32 = 1 | ||
Var d:u8 = 0 | ||
while([i] < [n]){ | ||
[a] = [[c] = [[-[a]] + [[[b] * [c]] / [66]]]] | ||
[a] = [[[[[b] % [3]] / [2]] + [4]] + [[b] = [4]]] | ||
[b] = [c] | ||
[i] = [[i] + [1]] | ||
} | ||
call print(a) | ||
call print(b) | ||
call print(c) | ||
call print(-[c]) | ||
call print(![[c] == [-[1]]]) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
class Foo{ | ||
|
||
new(){ | ||
self.age = 0; | ||
} | ||
|
||
new(i32 a){ | ||
self.age = a; | ||
} | ||
|
||
void setAge(i32 age){ | ||
self.age = age; | ||
} | ||
|
||
i32 getAge(){ | ||
return self.age; | ||
} | ||
|
||
i32 age; | ||
|
||
} | ||
|
||
|
||
i32 main() | ||
{ | ||
i64 n = inputI32(); | ||
|
||
Foo[] c = new Foo[](n); | ||
|
||
i64 i = n; | ||
while(i-1>=0) | ||
{ | ||
c[i - 1] = new Foo(inputI32()); | ||
i = i - 1; | ||
} | ||
|
||
double sum = 0; | ||
i = n; | ||
while(i - 1 >= 0){ | ||
sum = sum + c[i - 1].getAge(); | ||
i = i - 1; | ||
} | ||
|
||
print("Average age is:"); | ||
print(sum / n); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
Class Foo { | ||
field : constructor(){{ | ||
[self.age] = [0] | ||
}} | ||
field : constructor(Var a:i32){{ | ||
[self.age] = [a] | ||
}} | ||
field : Var age:i32 | ||
field : Foo::func [setAge](Var age:i32)->[void] { | ||
[self.age] = [age] | ||
} | ||
field : Foo::func [getAge]()->[i32] { | ||
return self.age | ||
} | ||
} | ||
func [main]()->[i32] { | ||
Var n:i64 = call inputI32() | ||
Var c:Array<Foo, 1> = call Array<Foo, 1>(n) | ||
Var i:i64 = n | ||
while([[i] - [1]] >= [0]){ | ||
[[i] - [1] in c] = [call Foo(call inputI32())] | ||
[i] = [[i] - [1]] | ||
} | ||
Var sum:double = 0 | ||
[i] = [n] | ||
while([[i] - [1]] >= [0]){ | ||
[sum] = [[sum] + [call [i] - [1] in c.getAge()]] | ||
[i] = [[i] - [1]] | ||
} | ||
call print("Average age is:") | ||
call print([sum] / [n]) | ||
return 0 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
void main(){ | ||
print("Hello,World!"); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
func [main]()->[void] { | ||
call print("Hello,World!") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
|
||
i64 main() | ||
{ | ||
i32 i = inputI32(); | ||
if(i == 3){ | ||
print(0); | ||
if(i > 4){ | ||
print(2); | ||
}else{ | ||
print(3); | ||
} | ||
}else{ | ||
print(1); | ||
} | ||
print(12); | ||
return 10; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
func [main]()->[i64] { | ||
Var i:i32 = call inputI32() | ||
If ([i] == [3]) { | ||
call print(0) | ||
If ([i] > [4]) { | ||
call print(2) | ||
} Else { | ||
call print(3) | ||
} | ||
} Else { | ||
call print(1) | ||
} | ||
call print(12) | ||
return 10 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
boolean isPrime(i32 x){ | ||
if(x <= 1) | ||
return false; | ||
i32 i = 2; | ||
while(i*i <= x){ | ||
if(x%i == 0){return false;} | ||
i=i+1; | ||
} | ||
return true; | ||
} | ||
|
||
i32 main() | ||
{ | ||
boolean a = true; | ||
while(a){ | ||
i32 x = inputI32(); | ||
print(isPrime(x)); | ||
} | ||
return 32; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
func [isPrime](Var x:i32)->[boolean] { | ||
If([x] <= [1])return false | ||
Var i:i32 = 2 | ||
while([[i] * [i]] <= [x]){ | ||
If([[x] % [i]] == [0]){ | ||
return false | ||
} | ||
[i] = [[i] + [1]] | ||
} | ||
return true | ||
} | ||
func [main]()->[i32] { | ||
Var a:boolean = true | ||
while(a){ | ||
Var x:i32 = call inputI32() | ||
call print(call isPrime(x)) | ||
} | ||
return 32 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
i32 fib(i32 n){ | ||
if(n <= 0) | ||
return -3; | ||
if(n==1 || n==2) | ||
return 1; | ||
return fib(n-1) + fib(n-2); | ||
} | ||
|
||
i32 main() { | ||
print(fib(inputI32())); | ||
return 3; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
func [fib](Var n:i32)->[i32] { | ||
If([n] <= [0])return -[3] | ||
If([[n] == [1]] || [[n] == [2]])return 1 | ||
return [call fib([n] - [1])] + [call fib([n] - [2])] | ||
} | ||
func [main]()->[i32] { | ||
call print(call fib(call inputI32())) | ||
return 3 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
class string extends A{ | ||
char[] data; | ||
|
||
new(char[] chars) { | ||
self.data = new char[](chars.length); | ||
i64 i = 0; | ||
while(i < chars.length) { | ||
self.data[i] = chars[i]; | ||
i = i + 1; | ||
} | ||
} | ||
|
||
char charAt(i64 index) { | ||
return self.data[index]; | ||
} | ||
|
||
char[] getData(){ | ||
print(self.data.length); | ||
return self.data; | ||
} | ||
} | ||
|
||
i32 main(){ | ||
string a = new string("H,world!\n"); | ||
print("H,world!\n"[1]); | ||
print(a.getData()); | ||
a.getData()[3] = '$'; | ||
print(a.charAt(3)); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
Class string extends A{ | ||
field : constructor(Var chars:Array<char, 1>){{ | ||
[self.data] = [call Array<char, 1>(chars.length)] | ||
Var i:i64 = 0 | ||
while([i] < [chars.length]){ | ||
[i in self.data] = [i in chars] | ||
[i] = [[i] + [1]] | ||
} | ||
}} | ||
field : Var data:Array<char, 1> | ||
field : string::func [charAt](Var index:i64)->[char] { | ||
return index in self.data | ||
} | ||
field : string::func [getData]()->[Array<char, 1>] { | ||
call print(self.data.length) | ||
return self.data | ||
} | ||
} | ||
func [main]()->[i32] { | ||
Var a:string = call string("H,world! | ||
") | ||
call print(1 in "H,world! | ||
") | ||
call print(call a.getData()) | ||
[3 in call a.getData()] = ['$'] | ||
call print(call a.charAt(3)) | ||
return 0 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
i64 add(i32 a,i32 b){ | ||
return a+b; | ||
} | ||
|
||
i32 main() | ||
{ | ||
print(2); | ||
print(2+1.1); | ||
print(2/1.1); | ||
print((2==1.1)||true); | ||
return 21; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
func [add](Var a:i32,Var b:i32)->[i64] { | ||
return [a] + [b] | ||
} | ||
func [main]()->[i32] { | ||
call print(2) | ||
call print([2] + [1.100000]) | ||
call print([2] / [1.100000]) | ||
call print([[2] == [1.100000]] || [true]) | ||
return 21 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.