mirror of
https://github.com/egormanga/Slang.git
synced 2025-07-31 17:06:58 +03:00
Initial commit
This commit is contained in:
27
tests/example.sl
Normal file
27
tests/example.sl
Normal 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
2
tests/funcdef.sl
Normal file
@@ -0,0 +1,2 @@
|
||||
void f() {}
|
||||
void f(int a?) {}
|
2
tests/opti.sl
Normal file
2
tests/opti.sl
Normal file
@@ -0,0 +1,2 @@
|
||||
int a = 3
|
||||
print(2**a)
|
5
tests/overload.sl
Normal file
5
tests/overload.sl
Normal 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
3
tests/sum.sl
Normal file
@@ -0,0 +1,3 @@
|
||||
int a = 3
|
||||
int b = 5
|
||||
print(a+b)
|
30
tests/test.sl
Normal file
30
tests/test.sl
Normal 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
1
tests/underscore.sl
Normal file
@@ -0,0 +1 @@
|
||||
int _a_b_
|
Reference in New Issue
Block a user