Skip to content

Instantly share code, notes, and snippets.

@senier
Created May 30, 2023 09:09
Show Gist options
  • Save senier/dc396550c9a4879c0fee80949f21120a to your computer and use it in GitHub Desktop.
Save senier/dc396550c9a4879c0fee80949f21120a to your computer and use it in GitHub Desktop.
package Alt is
type Alt_Cond is (Alt_B => 1, Alt_C => 2) with Size => 8;
generic
session FSM is
Alt_Cond : Alt_Cond;
begin
state Init is
begin
Alt_Cond := Alt_B;
transition
goto A
end Init;
state A is
begin
transition
goto B
if Alt_Cond = Alt_B
goto C
if Alt_Cond = Alt_C
goto Init
end A;
state B is
begin
Alt_Cond := Alt_C;
transition
goto A
end B;
state C is
begin
Alt_Cond := Alt_B;
transition
goto A
end C;
end FSM;
end Alt;
State: Init
State: A
State: B
State: A
State: C
State: A
State: B
State: A
State: C
State: A
...
with RFLX.Alt.FSM;
procedure Useit
is
type Context is new RFLX.Alt.FSM.Context with null record;
Ctx : Context;
begin
RFLX.Alt.FSM.Initialize (Ctx);
while RFLX.Alt.FSM.Active (Ctx) loop
RFLX.Alt.FSM.Run (Ctx);
end loop;
end Useit;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment