Huge work; i'm too tired to write commit message for all of it. Pleez let me sleep acouple of hours. Made most tests work. Started SBC.

This commit is contained in:
egormanga
2020-03-18 07:00:12 +03:00
parent 7badd31e42
commit 27d951227d
51 changed files with 3004 additions and 717 deletions

37
tests/class.sl Normal file
View File

@@ -0,0 +1,37 @@
class Test {
int a = 1
init {
.a = 3
}
constr () {
.a = 5
}
constr (int a) {
.a = a
}
}
main {
stdio.println(Test.a)
Test t
stdio.println(t.a)
t.a = 2
stdio.println(t.a)
delete t
Test t = Test()
stdio.println(t.a)
delete t
Test t = Test(7)
stdio.println(t.a)
delete t
#Test t(10)
#stdio.println(t.a)
#delete t
}

View File

@@ -18,10 +18,8 @@ auto g(str x) { # g() is of type char, x is of type str
int h(int x) = x+1 # h() is of type int, x is of type int
void main() {
print(h(n), \
main {
stdio.println(h(n), \ # comment here too
f('123asd') + g('32') + 1) #--> «123124 f»
print(q/z/2**96) #--> «4294967296.0»
stdio.println(q/z/2**96) #--> «4294967296.0»
}
main()

8
tests/fib.sl Normal file
View File

@@ -0,0 +1,8 @@
int fib(int n) {
if (n < 2) {return 1}
return fib(n-1) + fib(n-2)
}
main {
stdio.println(fib(3))
}

5
tests/fmap.sl Normal file
View File

@@ -0,0 +1,5 @@
void f(int x) = stdio.println(x)
main {
f.map([int: 1, 2, 3])
}

6
tests/for.sl Normal file
View File

@@ -0,0 +1,6 @@
main {
for i in (0 to 5) {
stdio.println(i)
stdio.println(i+2)
}
}

View File

@@ -1,2 +1,2 @@
void f() {}
void f(int a?) {}
void f(int a?) {}

10
tests/list.sl Normal file
View File

@@ -0,0 +1,10 @@
list l = [int: 1, 2, 3]
main {
#int i = 0
#while (i < 3) {
for i in (0 to 3) {
stdio.println(i, l[i])
#i -=- 1
}
}

4
tests/nl.sl Normal file
View File

@@ -0,0 +1,4 @@
main {
stdio.println(1, #|
|# 2)
}

View File

@@ -1,2 +1,5 @@
int a = 3
print(2**a)
main {
stdio.println(2**a)
}

View File

@@ -1,5 +1,7 @@
int f(int x) = x+1
int f(int x, int y) = x+y+1
print(f(1))
print(f(1, 2))
main {
stdio.println(f(1))
stdio.println(f(1, 2))
}

3
tests/println.sl Normal file
View File

@@ -0,0 +1,3 @@
main {
stdio.println('test')
}

6
tests/redefine.sl Normal file
View File

@@ -0,0 +1,6 @@
main {
int a
a = 3
a, b := (int a, char 'b')
stdio.println(a, b)
}

4
tests/strcat.sl Normal file
View File

@@ -0,0 +1,4 @@
str a = "a"
str b = "B"
str c = a+b
stdio.println(c)

View File

@@ -1,3 +1,4 @@
int a = 3
int b = 5
print(a+b)
i8 a = 3
i8 b = 5
i8 c = a+b
stdio.println(c)

View File

@@ -2,29 +2,27 @@ const int a = 3
int b = 2; int c = 0; int x = 9
int sum(int a, int z) = a + z
print(sum(a, b & 3))
print(1)
print(1, 2)
print('a')
print(2*(3)+-2*(5+1)/2)
print(-2*x**(2+2)*a*b+10*c)
print(*'a'+'b'*2)
print(-2-2-2-2-2-2-2-2)
stdio.println(sum(a, b & 3))
stdio.println(1)
stdio.println(1, 2)
stdio.println('a')
stdio.println(2*(3)+-2*(5+1)/2)
stdio.println(-2*x**(2+2)*a*b+10*c)
stdio.println(*'a'+'b'*2)
stdio.println(-2-2-2-2-2-2-2-2)
void main() {
main {
int z = sum(3, 2)
b = 2**100
b *= 2
print(not a)
print(a, b, c)
stdio.println(not a)
stdio.println(a, b, c)
int test() = 2*2
print(sum(b, test()))
stdio.println(sum(b, test()))
for i in (0 to 5) print(i)
else print(0)
for i in 0 to 5 stdio.println(i)
else stdio.println(0)
int i = 5
while (i) {print(i); i -= 1;} else print('ВСЁ!')
while i {stdio.println(i); i -= 1;} else stdio.println('ВСЁ!')
}
main()

4
tests/wrongnl.sl Normal file
View File

@@ -0,0 +1,4 @@
main {
stdio.println(1, \ 2,
3)
}