MODULE Case;
IMPORT log;
TYPE
Msg = RECORD END;
Start = RECORD(Msg) END;
Next = RECORD(Msg) exist: BOOLEAN; val: INTEGER END;
Range = RECORD i: INTEGER END;
PROCEDURE Do(VAR r: Range; VAR m: Msg);
BEGIN
CASE m OF
Start: r.i := 0 |
Next: m.exist := r.i < 7; IF m.exist THEN m.val := r.i; INC(r.i) END
END
END Do;
PROCEDURE Go*;
VAR r: Range; start: Start; next: Next;
BEGIN
Do(r, start);
Do(r, next);
WHILE next.exist DO
log.in(next.val);
Do(r, next)
END
END Go;
END Case.