raz / conform / run / Generic.raz

27 lines · 919 B · raw · history · last change 264716cb

1module Generic;
2import Out, Stack, Ints := Pile(I64), More := Pile(I64), Strs := Pile([]const U8);
3import SYSTEM;
4
5proc yes(b: BOOL);
6begin
7 if b then Out.str("true"); else Out.str("false"); end;
8end;
9
10proc main*;
11var l: Strs.Pile; v: I64; s: []const U8; ok: BOOL;
12begin
13 ok := Ints.push(Stack.p, 7);
14 ok := More.push(Stack.p, 8); (* two imports, one instance: one pile *)
15 Out.int(Stack.top()); Out.char(' '); Out.int(Stack.p^.len); Out.char(' '); yes(ok); Out.ln;
16 v, ok := Ints.pop(Stack.p);
17 Out.int(v); Out.char(' '); Out.int(Stack.p^.len); Out.ln;
18 ok := Strs.push(SYSTEM.ADR(l), "b");
19 ok := Strs.push(SYSTEM.ADR(l), "a");
20 s, ok := Strs.pop(SYSTEM.ADR(l));
21 Out.str(s); Out.str(Strs.top(SYSTEM.ADR(l))); yes(ok); Out.ln;
22 s, ok := Strs.pop(SYSTEM.ADR(l));
23 s, ok := Strs.pop(SYSTEM.ADR(l));
24 Out.char('['); Out.str(s); Out.str("] "); yes(ok); Out.ln;
25end;
26
27end Generic.