unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: poptsov.artyom@gmail.com (Artyom V. Poptsov)
To: Guile Users' Mailing List <guile-user@gnu.org>
Subject: [ANN] GNU Guile State Machine Compiler (Guile-SMC)
Date: Sat, 24 Apr 2021 21:43:38 +0300	[thread overview]
Message-ID: <87lf97seud.fsf@gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 2493 bytes --]

Hello Guilers!

I heard some of you like finite state machines.  If you love FSM as much
as I do, you may want to take a look on my Guile state machine compiler
(Guile-SMC):
  https://github.com/artyom-poptsov/guile-smc

With Guile-SMC, you can generate state machines using state machines,
and then you can use generated state machines to parse other stuff.

Why?  Because I noticed that I'm repeating myself each time I'm writing
a parser -- and I hand-crafted several of them already[1, 2] (as you may
know.)  Personally I think that it's an unfortunate situation that we,
Guilers, don't have a proper tool for that.  I'm hoping that Guile-SMC
will be able to fill this gap.

Some technical details:

Guile-SMC uses PlantUML[3] format for FSM description.  It reads this
format and produces a Scheme representation of a FSM that can be applied
to another format.

(It's still possible to use Guile-SMC to manually write state machines
using a syntax that loosely resembles state transition tables.  You can
find an example of it in 'modules/smc/puml.scm' file.)

The internal Guile-SMC representation of a FSM consists of a hash-table
for fast state lookup; in turn, each state holds links to other states
that it transitions to, essentially producing a directed graph.

Each transition consists of a guard (a predicate that is used to check
if the transition can be made), an action (a procedure that does the
work) and a target state to transition to if the guard returns #t.

There's an example of a PlantUML parser that generates a state machine
from it and applies it to PlantUML format itself that in turn produces a
new state machine (which is pretty cool as far as I understand.)

Also there's a basic state machine validator that reports dead-ends and
unreachable states.

It should be possible to produce a Scheme code from the intermediate
representation -- that will remove PlantUML-to-Scheme compilation time
from an application cold-boot time.

This is a work-in-progress though and some API is still in development,
so please be patient and report any problems.  Suggestions are very
welcome too.

Thanks,

- Artyom


References:
1: https://github.com/artyom-poptsov/guile-dsv
2: https://github.com/artyom-poptsov/guile-ics
3: http://www.plantuml.com/

-- 
Artyom "avp" Poptsov <poptsov.artyom@gmail.com>
CADR Hackerspace co-founder: https://cadrspace.ru/
GPG: D0C2 EAC1 3310 822D 98DE  B57C E9C5 A2D9 0898 A02F

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

             reply	other threads:[~2021-04-24 18:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-24 18:43 Artyom V. Poptsov [this message]
2021-04-25 13:40 ` [ANN] GNU Guile State Machine Compiler (Guile-SMC) Matt Wette

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87lf97seud.fsf@gmail.com \
    --to=poptsov.artyom@gmail.com \
    --cc=guile-user@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).