elna/example.elna

102 lines
1.2 KiB
Plaintext

type
T = array 5 of Int,
R = record
x: Int;
y: Int
end;
proc test_string();
var s: String;
begin
s := "Test string.";
writei("");
writei(s)
end;
proc test_array();
var a: T, x_3: Int;
begin
a[0] := 2;
a[1] := 5;
writei("");
writei("Test array:");
x_3 := 0;
while x_3 < 2 do
begin
writei(a[x_3]);
x_3 := x_3 + 1
end
end;
proc test_pointer();
var x_2: Int, p: ^Int;
begin
x_2 := 5;
p := @x_2;
writei("");
writei("Test pointer:");
writei(p);
writei(p^)
end;
proc test_record();
var r: R;
begin
writei("");
writei("Test record:");
r.x := 4;
r.y := 8;
writei(r.y)
end;
proc test_primitive();
var c: Char, z: Float;
begin
c := 'x';
z := 8.2;
writei("");
writei("Test primitives:");
writei(c);
writei(z)
end;
proc test_const();
const t = 5;
var x_1: Int;
begin
x_1 := t;
writei("");
writei("Test const:");
writei(x_1)
end;
proc test_if();
var y: Bool;
begin
y := false;
writei("");
if y then
writei("Test if: True")
else
writei("Test if: False")
end;
begin
test_primitive();
test_string();
test_array();
test_pointer();
test_record();
test_const();
test_if()
end.