Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Memory fault - where am I?


devel / comp.lang.forth / A very simple DSL for state-machines,

SubjectAuthor
o A very simple DSL for state-machines,Ron AARON

1
A very simple DSL for state-machines,

<si9ou0$87q$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=14716&group=comp.lang.forth#14716

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: clf...@8th-dev.com (Ron AARON)
Newsgroups: comp.lang.forth
Subject: A very simple DSL for state-machines,
Date: Mon, 20 Sep 2021 13:48:31 +0300
Organization: A noiseless patient Spider
Lines: 35
Message-ID: <si9ou0$87q$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 20 Sep 2021 10:48:32 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="ab55566961aa4ec3a8ee65c32bae866f";
logging-data="8442"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18rnCIrVJpCu6agC9kzcPrp"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.14.0
Cancel-Lock: sha1:nzVVYYkSAbsApPqSEHqw6n574as=
Content-Language: en-US
X-Mozilla-News-Host: snews://news.eternal-september.org:563
 by: Ron AARON - Mon, 20 Sep 2021 10:48 UTC

and a SM manager, in 8th:

https://8th-dev.com/forum/index.php/topic,2379.0.html

A SM is defined as simply as:

with: sm

sm:
:: init init-action
-> a foo
-> b bar
:: foo foo-action
etc...
sm;

The states are defined after '::', as the name of the state and the word
to invoke when "sm:act" is invoked on the state-machine (in that state).

The transitions are defined with '->' and the name of the 'verb' causing
the transition, and the new state after the transition.

In this implementation, the last defined state is assumed as the target
of any transitions, until the next state is defined.

An advantage of this particular approach is that the actions don't need
to be defined before the state-machine is, as they are "found" at
runtime. A possible refinement would be to 'compile' the machine by
doing the action look-up once, prior to using the machine.

Transitions are effected with the word 'sm:next', and actions are
performed with 'sm:act'.

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor