AST
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

121 lines
1.7 KiB

fun f() 42 f()
if (1) 2
if (0) 2
if (1) 2 else 3
if (0) 2 else 3
var a = 0
while (a < 10) print(a= a + 1)
print(111)
print(222)
print(101) || print(202) || print(303)
print(404) && print(505) && print(606)
0b100
0100
100
0x100
0b1110 | 0b0111;
0b1110 ^ 0b0111;
0b1110 & 0b0111;
!42;
!!42;
-42;
~42;
!0;
-0;
~0;
fun doit(a, b) print(a < b, a <= b, a == b, a != b, a >= b, a > b)
doit(0, 0)
doit(0, 1)
doit(0, 2)
doit(1, 0)
doit(1, 1)
doit(1, 2)
doit(2, 0)
doit(2, 1)
doit(2, 2)
1 << 10
65536 >> 8
fun f(n) if (n < 2) 1 else 1 + f(n-1) + f(n-2)
// comment
f(15)
fun f() {
var i = 0;
while (i < 10) print(i = i + 1);
}
/* multi
line
comment */
var i = 0;
while (i < 1000000) i = i + 1;
do print(i); while ((i = i + 1) < 10);
i= 5;
do print(i); while ((i = i + 1) < 10);
for (var x= 100; x < 105; x= x + 1) print(x);
print(x);
for (i= 200; i < 205; i= i + 1) print(i);
print(i);
switch (3) {
case 0: print('zero');
case 1: print('one');
case 2: print('two');
case 3: print('three');
case 4: print('four');
case 5: print('five');
}
switch (#three) {
case #zero: print(0);
case #one: print(1);
case #two: print(2);
case #three: print(3);
case #four: print(4);
case #five: print(5);
}
switch (#nine) {
case #zero: print(0);
case #one: print(1);
case #two: print(2);
case #three: print(3);
case #four: print(4);
case #five: print(5);
}
switch (#nine) {
case #zero: print(0);
case #one: print(1);
case #two: print(2);
case #three: print(3);
case #four: print(4);
default: print(666);
case #five: print(5);
}
print('newline\nanother\012another\x0aanother\u000a')
print('\nmoriturus te saluto\n') && exit(0)