Initial commit

This commit is contained in:
egormanga
2019-08-28 21:24:54 +03:00
commit 7badd31e42
23 changed files with 2760 additions and 0 deletions

27
tests/example.sl Normal file
View File

@@ -0,0 +1,27 @@
# this is a comment
#| and that is a
multiline one. |#
const u32 n = 123123 # n is of type const u32
const i64 m = 10**18 # m is of type const i64
const int z = 2**128 # z is of type const int (unsized)
const auto q = 2**256 # q is of type const int
char f(str x) { # f() is of type char, x is of type str
auto c = x[1] # c is of type char
return c
}
auto g(str x) { # g() is of type char, x is of type str
return x[0] # retval is of type char
}
int h(int x) = x+1 # h() is of type int, x is of type int
void main() {
print(h(n), \
f('123asd') + g('32') + 1) #--> «123124 f»
print(q/z/2**96) #--> «4294967296.0»
}
main()

2
tests/funcdef.sl Normal file
View File

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

2
tests/opti.sl Normal file
View File

@@ -0,0 +1,2 @@
int a = 3
print(2**a)

5
tests/overload.sl Normal file
View File

@@ -0,0 +1,5 @@
int f(int x) = x+1
int f(int x, int y) = x+y+1
print(f(1))
print(f(1, 2))

3
tests/sum.sl Normal file
View File

@@ -0,0 +1,3 @@
int a = 3
int b = 5
print(a+b)

30
tests/test.sl Normal file
View File

@@ -0,0 +1,30 @@
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)
void main() {
int z = sum(3, 2)
b = 2**100
b *= 2
print(not a)
print(a, b, c)
int test() = 2*2
print(sum(b, test()))
for i in (0 to 5) print(i)
else print(0)
int i = 5
while (i) {print(i); i -= 1;} else print('ВСЁ!')
}
main()

1
tests/underscore.sl Normal file
View File

@@ -0,0 +1 @@
int _a_b_