From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: poptsov.artyom@gmail.com (Artyom V. Poptsov) Newsgroups: gmane.lisp.guile.user Subject: [ANN] GNU Guile State Machine Compiler (Guile-SMC) Date: Sat, 24 Apr 2021 21:43:38 +0300 Message-ID: <87lf97seud.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="36527"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) To: Guile Users' Mailing List Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Sat Apr 24 20:43:58 2021 Return-path: Envelope-to: guile-user@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1laNG2-0009Mb-CA for guile-user@m.gmane-mx.org; Sat, 24 Apr 2021 20:43:58 +0200 Original-Received: from localhost ([::1]:45806 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1laNG1-0001Ok-CW for guile-user@m.gmane-mx.org; Sat, 24 Apr 2021 14:43:57 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:51174) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1laNFr-0001OZ-Np for guile-user@gnu.org; Sat, 24 Apr 2021 14:43:47 -0400 Original-Received: from mail-lj1-x22d.google.com ([2a00:1450:4864:20::22d]:34549) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1laNFp-0000M2-JB for guile-user@gnu.org; Sat, 24 Apr 2021 14:43:47 -0400 Original-Received: by mail-lj1-x22d.google.com with SMTP id o5so26234193ljc.1 for ; Sat, 24 Apr 2021 11:43:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:user-agent:mime-version; bh=mtQrCYKivGv888VBjS0OkPZRgktsF4VeDdYaFQfeYUs=; b=S8o7HPIF18mBSD0i/wTj4R7623eYMW/D+AdCSEwvDABwyIqNoQrfzJG1aPW0Q42IZf YEuiNjUgVUSIpGVWVL2xVE03TSDzzra9vOzw633pCQ0FZv3n167iJ01UKXwfSIBe7QnK D4nndl0LSgrByl+Eeeie5O6+27puP39BOIdGTvTLu+xSbtjfQfgksKv26aIDaPoBefWr +epu+QSwOR8yoyFoMqvdvMtiAGn9xF8TgG0QwYAz7jqMdjfyiyxgH590A16JWh+9WwEz x1AijjnkGP/knuWYzPVSCYEfssfwNTG8fFnZzMLvGOrp1UDO30EiCVZJqwGgdNJlVBX6 tUmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:user-agent :mime-version; bh=mtQrCYKivGv888VBjS0OkPZRgktsF4VeDdYaFQfeYUs=; b=NE5mCO/9xiuyGTyVPecVLEc5W0zlChkxqNar6ZIBDdADuH2rt5EjPwMA6oUQougK7s Og2pvF+ab+PvOmdm9zd9M7gw3RewjnG20h0TQhPlQfxDRlg4EMe6P97XcWrgtyKdwNJR GeMJYtCmFJCFo7xilr1JEGV2+qW+RuOXp/DnbSFfjezaEaq3Bcji0dDK/nbkEBUSza4B HkEmVJpUNUsf18PKGMaKa+dfZ+mJnlXXqbibECu2wRGci92tHgRxqmh5JMmy9lPNMtuq wG9C2tbBLR7Nrg959yRFbRipG/ZrfTvPGzAFzph57rky4P3u6R6pzzPhOz05hJnBKfdf Y6Mw== X-Gm-Message-State: AOAM533AYYpB4TFJz/a9YsvcbAWRqFrdGDUYaCsy8XhEdIBWagMsXM01 30wruEeQYgsaUcT2gauji2kwDcdR/2X32ade X-Google-Smtp-Source: ABdhPJziQ8wKIoaLMT1+skQ5b1ucxgns+VlEcB6eiyuhKRpdclWbZuEP5B1kbotfKMcqF9tJJpFaSw== X-Received: by 2002:a2e:9495:: with SMTP id c21mr6770025ljh.287.1619289823369; Sat, 24 Apr 2021 11:43:43 -0700 (PDT) Original-Received: from elephant ([5.164.212.245]) by smtp.gmail.com with ESMTPSA id m5sm889087lfl.303.2021.04.24.11.43.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Apr 2021 11:43:42 -0700 (PDT) Received-SPF: pass client-ip=2a00:1450:4864:20::22d; envelope-from=poptsov.artyom@gmail.com; helo=mail-lj1-x22d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.io gmane.lisp.guile.user:17446 Archived-At: --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable 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, =2D Artyom References: 1: https://github.com/artyom-poptsov/guile-dsv 2: https://github.com/artyom-poptsov/guile-ics 3: http://www.plantuml.com/ =2D-=20 Artyom "avp" Poptsov CADR Hackerspace co-founder: https://cadrspace.ru/ GPG: D0C2 EAC1 3310 822D 98DE B57C E9C5 A2D9 0898 A02F --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCgAdFiEE0MLqwTMQgi2Y3rV86cWi2QiYoC8FAmCEZtoACgkQ6cWi2QiY oC94Zgf/eQ2gCdKFzl1T/59kT8oVLSJbMp/2TwVlXW/7lYi+uVxJqO50gSLFZfrk DC9VRkeim2ezAxyhPAWdC6sgqPlUqT6cvdDxPGWk35atUVlpCiLhevOE2IEaPr1w F6scMpEhQm7aH37a1pwHIj0Z+r26sCS0b1llEXsRE3canxS6SzhfC+1arko3E/nI Qg2Lnq3+CJDVZJlgfeccHcPzVVCCA79CKCdeOA/ccoATWhU/K5WxJdADs7qgIi7d 3CF8oBqAdRSwY9r7h41TuB/KHLE7lvpUy09dWX5pRqT0f9Dv+SOX0dDgv/yHl7m7 aY3X5sFEt8BNaVoAwcVB8ArmVryQ4A== =rvp3 -----END PGP SIGNATURE----- --=-=-=--