guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ANN] GNU Guile State Machine Compiler (Guile-SMC)


From: Artyom V. Poptsov
Subject: [ANN] GNU Guile State Machine Compiler (Guile-SMC)
Date: Sat, 24 Apr 2021 21:43:38 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux)

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: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]