Guile State Machine Compiler Reference Manual

For Guile-SMC 0.5.2

Artyom V. Poptsov

This manual documents Guile-SMC version 0.5.2.

Copyright (C) 2021 Artyom V. Poptsov

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled “GNU Free Documentation License.”

[ < ] [ > ]   [Contents] [Index] [ ? ]

The Guile-SMC Reference Manual

This manual documents Guile-SMC version 0.5.2.

Copyright (C) 2021 Artyom V. Poptsov

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled “GNU Free Documentation License.”

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1 Introduction

Guile-SMC is a state machine compiler for GNU Guile.

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

2 Installation

Guile-SMC sources are available from GitHub at This section describes requirements of Guile-SMC and installation process.

Guile-SMC depends on the following packages:

Get the sources of Guile-Deck from GitHub using Git (a good introduction to Git is Pro Git book, which is available online):

$ git clone

Configure the sources:

$ cd guile-smc/
$ autoreconf -vif
$ ./configure

Build and install the library:

$ make
$ make install

For a basic explanation of the installation of the package, see the ‘INSTALL’ file.

important You probably want to call configure with the ‘--with-guilesitedir’ option so that this package is installed in Guile’s default path. But, if you don’t know where your Guile site directory is, run configure without the option, and it will give you a suggestion.

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3 API Reference

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.1 FSM

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.1.1 The main class

Class: <fsm> [#:description=#f] [#:debug-mode?=#f] [#:transition-table='()] [#:event-source=(labmda (context) #t)] [#:current-state=#f]

The main class that describes a finite state machine.

#:current-state (state <state>)

required Current FSM state.

#:description (str <string>)

Optional custom human-readable description for the finite-state machine.

#:debug-mode? (enabled? <boolean>)

Is the debug mode enabled?

#:transition-table (table <list>)

A transition table.

#:event-source (proc <procedure>)

Global state machine event source.

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.1.2 Public API

Scheme Procedure: fsm? object

Check if an object is an <fsm> instance.

Scheme Procedure: fsm-state-add! (fsm <fsm>) (state <state>)

Add a new state to the fsm state table.

Scheme Procedure: fsm-state (fsm <fsm>) (name <symbol>)

Lookup a state by its name from the state table of fsm.

Scheme Procedure: transition-list->hash-table (fsm <fsm>) (transition-list <list>)

Convert a transition-list to a hash table.

Scheme Procedure: hash-table->transition-list table

Convert a hash table to a transition list of the following form:

   '(((name        . state1)
      (description . "description")
      (transitions . ((guard-procedure      action-procedure      next-state)
                      (guard-procedure      action-procedure      next-state)
                      (guard-procedure      action-procedure      next-state))))
     (state1 ...))

Return the transition list.

Scheme Procedure: fsm-transition-add! (self <fsm>) (state-name <symbol>) (tguard <procedure>) (action <procedure>) (next-state-name <top>)

Add a new transition to a state named next-state-name, guarded by a tguard with the specified transition action.

next-state-mame must be a name of a state that is already present in the FSM transition table, or #f (which means that the transition is final.)

Scheme Procedure: fsm-state-description-add! (self <fsm>) (state-name <symbol>) (description <string>)

Add a new description to a state state-name.

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ] Executing a FSM

Scheme Procedure: fsm-step! (fsm <fsm>) event context
Scheme Procedure: fsm-step! (fsm <fsm>) context

Perform a single fsm step on the specified event and a context.

If event parameter is missing, then fsm will always use event sources specific for each state during the execution.

Returns two values: new state and new context.

Scheme Procedure: fsm-run! (fsm <fsm>) event-source context
Scheme Procedure: fsm-run! (fsm <fsm>) context

Run an fsm with the given context return the new context.

event-source must be a procedure that accepts a context as a single parameter.

If event-source parameter is missing, then then fsm will always use event sources specific for each state during the execution.

context can be any Scheme object.

Return the context after fsm execution.

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ] Getting information about an FSM

Scheme Procedure: fsm-state-count (fsm <fsm>)

Calculate the number of states in a finite state machine fsm. Return the number of states.

Scheme Procedure: fsm-transition-count (self <fsm>)

Calculate the total transition count for a finite state machine fsm. Return the number of transitions.

Scheme Procedure: fsm-incoming-transition-count self state [#:include-recurrent-links?=#f]

Calculate the incoming transition count for a state. Optionally the procedure can include recurrent links of a state to itself in the calculation if include-recurrent-links? is set to #t.

Scheme Procedure: fsm-state-reachable? (fsm <fsm>) (state <state>)

Check if a state is reachable in the finite state machine fsm.

Scheme Procedure: fsm-validate (fsm <fsm>)

Validate the finite state machine fsm and return the list of errors. If the list is empty then no errors were found.

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ] Logging

Scheme Procedure: fsm-log-transition (from <state>) (to <state>)
Scheme Procedure: fsm-log-transition (from <state>) (to <symbol>)
Scheme Procedure: fsm-log-transition (from <state>) (to <boolean>)

Log state transitions.

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.2 PlantUML

The (smc puml) module contains a parser implementation for PlantUML format.

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.2.1 The PlantUML context

Class: <puml-context> #:module [#:keep-going?=#f]

A module which contains state machine procedures.

#:keep-going? (value <boolean>)

Whether the parser should keep going when a procedure cannot be resolved or not.

When set to #t, the parser remembers all unresolved procedures but keeps going without issuing an error. All unresolved procedures are replaced with default variants (guard:t for guards, action:no-op for actions.)

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.2.2 Public API

Scheme Procedure: puml-context-fsm (context <puml-context>)

Get the context output finite state machine.

Scheme Procedure: puml-context-module (context <puml-context>)

Get the context module.

Scheme Procedure: puml->fsm port [#:module=(current-module)] [#:keep-going?=#f] [#:debug-mode?=#f]

Read a FSM description from a port in the PlantUML format and convert it to Guile-SMC <fsm> instance.

Scheme Procedure: puml-string->fsm port [#:module=(current-module)] [#:keep-going?=#f] [#:debug-mode?=#f]

Convert a string in the PlantUML format and to Guile-SMC <fsm> instance.

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ] Resolver status

Scheme Procedure: puml-context-resolved-procedures (puml-context <puml-context>)

Return a <set> of resolved procedures. Each element of the set is a pair, where car of the pair is a module from which a procedure is resolved, and cdr is a resolved procedure.

Scheme Procedure: puml-context-unresolved-procedures (puml-context <puml-context>)

Return a <set> of unresolved procedures. Each element of the set an unresolved procedure name.

Scheme Procedure: puml-context-print-resolver-status (puml-context <puml-context>) (port <port>)

Pretty-print a puml-context resolver status to the specified port.

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.2.3 Internal procedures

Scheme Procedure: resolve-procedure context proc-name default

This procedure tries to resolve a procedure proc-name in the provided modules of a context. When no procedure available with the given name, returns default procedure.

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.3 Compiler

The Guile-SMC finite state machines generated from a PlantUML format can be used for their purpose “as is”. But it can be costly to read a PlantUML FSM (Finite-State Machine) description each time a program run.

To solve this problem Guile-SMC provides a compiler that can translate the internal representation of a state machine into a Scheme code.

The procedures below are defined in (smc compiler) module.

Scheme Procedure: fsm-compile fsm [#:fsm-name='custom-fsm] [#:fsm-module=#f] [#:extra-modules='()] [#:target='guile] [#:output-port=(current-output-port)]

Compile a fsm into a Scheme module.

Named parameters:

#:fsm-name (name <symbol>)

Set the name for the output finite state machine. Basically the name turns to the FSM class (like <custom-fsm> for the default value.)

#:fsm-module (module <list>)
#:fsm-module (module <boolean>)

The module to place the output FSM into. The value must be a list like (my-parser my-fsm) or #f if the define-module part should be omitted.

#:extra-modules (modules-list <list>)

A list of extra modules that required to run the output FSM. These modules are added to to the output FSM module requirements.

#:output-port (port <port>)

The port to write the output FSM to.

#:target (value <symbol>)

The compilation target. Allowed values are:


This is the default mode. The output FSM will depend on Guile-SMC and won’t work if it is not installed on a target system.


This target allows to create a single file FSM that does not depend on Guile-SMC in any way.

The compiler collects the required code from Guile-SMC and then removes all unused parts from it, then the code is being printed to a output-port.


Copy Guile-SMC core modules to a directory with the same name as the fsm-name and re-write all the modules such that each Guile-SMC module that is used by the output FSM points to the directory.

This allows to create a FSM that does not depend on presence of Guile-SMC on a target system while keep the default Guile-SMC output FSM format.

Usage example:

(fsm-compile (puml->fsm (current-input-port)
                        #:module (puml-modules '((context))))
             #:fsm-name      'custom-fsm
             #:fsm-module    '(custom-fsm)
             #:extra-modules '((context)))

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.3.1 Examples

For more examples, take a look into ‘examples/compiler’ directory in the project repository.

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.4 Version

(smc version) contains procedures that allow to acquire information about the Guile-SMC version in the Semantic Versioning format.

Guile-SMC version consists of three parts: MAJOR.MINOR.PATCH

The procedures below allow to get any of the version part or the version as a whole.

Scheme Procedure: smc-version

Return the Guile-SMC version as a list of the following form:

Scheme Procedure: smc-version/string

Get the raw Guile-SMC version as a string.

Scheme Procedure: smc-version/major

Get the “MAJOR” part of the Guile-SMC version.

Scheme Procedure: smc-version/minor

Get the “MINOR” part of the Guile-SMC version.

Scheme Procedure: smc-version/patch

Get the “PATCH” part of the Guile-SMC version.

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.5 Log

(smc core log) module contains Guile-SMC logging facilities.

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.5.1 The Precise Logger

Class: <precise-logger>

Guile-SMC precise logger that prints log with microsecond accuracy.

Scheme Procedure: precise-logger? x

Check if x is a <precise-logger> instance.

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.5.2 Log Drivers

Guile-SMC allows to set different log drivers (or handlers). It uses <system-log> by default.

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ] System Log

Class: <system-log>

This is a log handler which writes logs to the syslog.

Scheme Procedure: system-log? x

Check if x is a <system-log> instance.

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ] Precise Port Log

Class: <precise-port-log>

Microsecond version of <port-log> from (logging port-log).

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ] Standard Error Log

Class: <stderr-log>

Log driver that logs to the standard error port.

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ] Null Log

Class: <null-log>

Log driver that logs to the standard error port.

Scheme Procedure: null-log? x

Check if x is a <null-log> instance.

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.5.3 Logging Initialization and Configuration

Scheme Procedure: smc-log-init! (log-driver <string>) (log-options <list>)

Initialize Guile-SMC logging to the specified log-driver with log-options list.

Known log drivers:

Return value is undefined.

Scheme Procedure: log-use-stderr! (value <boolean>)

Change whether the logger must print messages to the stderr as well as to syslog, or not.

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.5.4 Helper Procedures

Scheme Procedure: %precise-log-formatter lvl time str

The precise log formatter for <precise-logger>.

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.5.5 Logging Procedures

Scheme Procedure: smc-log level fmt . args
Scheme Procedure: log-error fmt . args
Scheme Procedure: log-warning fmt . args
Scheme Procedure: log-info fmt . args
Scheme Procedure: log-debug fmt . args

Log a formatted message of a specified logging level to syslog.

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.6 State

The (smc core state) module contains FSM state implementation. The state term is very important in the realm of finite-state machines as the FSMs consist of states and transitions between them.

A state can take one of two forms: it can be either a associative list or an instance of <state> class. There are converters between these forms.

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.6.1 Actions

Basically an action is a procedure that is called when some event happen.

The main Guile-SMC allow to attach actions to transitions as well as to the state entry/exit events.

Note that a state does not run its entry/exit actions when state-run method is called because it has insufficient information about when to call entry/exit action procedures. Those procedures are run by a FSM that owns the state.

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.6.2 Default entry/exit actions

Scheme Procedure: %default-entry-action context

Default state entry action that just returns a context.

Scheme Procedure: %default-exit-action context

Default state exit action that just returns a context.

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.6.3 The main class

Class: <state> #:name [#:description=#f] [#:event-source=#f] [#:entry-action=%default-entry-action] [#:exit-action=%default-exit-action] [#:transitions=#f]

This class describes an FSM state.

Constructor parameters:

#:name (name <string>)

required Name of this state.

#:description (description <string>)

Description of this state.

#:event-source (proc <procedure>)

A procedure that returns an event.

It called by the FSM the state belongs to as follows:

(proc context)
#:entry-action (proc <procedure>)

A procedure that is called by the FSM the state belongs to when a transition occurs to this state from another state, before running the transition table. Note that the procedure is not called on self-transitions.

The procedure MUST return a context, which is passed to the transition table execution.

The procedure called as follows:

(proc context)
#:exit-action (proc <procedure>)

A procedure that is called by the FSM the state belongs to when a transition occurs from this state to another state, before running the transition table. Note that the procedure is not called on self-transitions.

The procedure MUST return a context.

The procedure called as follows:

(proc context)
#:transitions (transitions <list>)

The transitions for this state.

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.6.4 Public API

Scheme Procedure: state? object

Check if object is an instance of the <state> class.

Scheme Procedure: equal? state-1 state-2

Check if state-1 is equal to state-2.

Scheme Procedure: state-name (state <state>)

Get the state name as a <string>.

Scheme Procedure: state-name (state <symbol>)

Special version of procedure that return the symbol itself.

Scheme Procedure: state-has-event-source? (state <state>)

Check if a state has an event source.

Scheme Procedure: state-description (state <state>)

Get the state description as a <string> if it is available, return #f otherwise.

Scheme Procedure: state-event-source (state <state>)

Get the state event source procedure.

Scheme Procedure: state-event-source-set! (state <state>)

Set the state event source procedure.

Scheme Procedure: state-entry-action (state <state>)

Get the state entry action procedure.

Scheme Procedure: state-entry-action-set! (state <state>)

Set the state entry action procedure.

Scheme Procedure: state-exit-action (state <state>)

Get the state exit action procedure.

Scheme Procedure: state-exit-action-set! (state <state>)

Set the state exit action procedure.

Scheme Procedure: state-transitions (state <state>)

Get the state transitions as a list.

Scheme Procedure: state-transition-add! (state <state>) (tguard <procedure>) (action <procedure>) next-state

Add a new transition to the state.

A transition consists of a transition guard tguard (which must be a predicate) and a transition action.

Scheme Procedure: state-transition-count (state <state>)
Scheme Procedure: state-transition-count (state <state>) to

Get the transitions count for a state.

Scheme Procedure: state-transition-count/foreign (state <state>)

Get the foreign transitions count for a state. A foreign transition is a transition that points to another state.

Scheme Procedure: state-recurrent-links-count (state <state>)

Get the number of recurrent links (that is, links that point to the state itself) for a state.

Scheme Procedure: state-has-recurrent-links? (state <state>)

Check if a state has recurrent links.

Scheme Procedure: state-final-transitions (state <state>)

Get the number of final transitions for a state.

Scheme Procedure: state-has-final-transitions? (state <state>)

Check if a state has any final transitions.

Scheme Procedure: state-dead-end? (state <state>)

Check if a state is a dead-end state. A state is considered a dead-end if it has no foreign transitions, has recurrent links and has no final transitions.

Scheme Procedure: state-run (state <state>) event context

Run a state. Returns two values: next state (or #f) and new context.

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ] State as a list

State serialized to an associative list of the following form:

   `((name         . state-name)
     (description  . "State description")
     (event-source . ,event-source:state-name)
     (entry-action . ,some-entry-action)
      (,guard:...    ,action:...    next-state-name-1)
      (,guard:...    ,action:...    next-state-name-1)
      (,guard:...    ,action:...    next-state-name-2)))
Scheme Procedure: state:name state
Scheme Procedure: state:description state
Scheme Procedure: state:transitions state
Scheme Procedure: state:event-source state
Scheme Procedure: state:entry-action state
Scheme Procedure: state:exit-action state

Get the corresponding element of a state alist.

Scheme Procedure: state:event-source/name state

Get the name of a state event source procedure. Returns #f when no event source is set.

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ] List/state conversion

Scheme Procedure: list->state (lst <list>)

Convert a list lst to a <state> instance, return the new state.

Scheme Procedure: state->list (state <state>)

Convert a state to an associative list.

Scheme Procedure: state->list/serialized (state <state>)

Convert a state to an associative list, replace all the procedures with their names.

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.7 Transition

The (smc core transition) module contains the implementation of FSM transition class.

In the realm of finite-state machines a transition is a set of actions to be executed when a condition is fulfilled or when an event is received.

A Guile-SMC transition instance contains a transition guard that allows the transition to happen. When the guard returns #t (that is, when the transition condition specified by the guard is fulfilled) a transition action is performed.

Each Guile-SMC transition has single next state that points to the next state to which transition switches the parent finite-state machine.

A single transition take the following form:

(list guard:some-guard action:some-action 'state1)

The first part of the transition in the example is guard:some-guard that represent a Guile-SMC guard procedure.

The second part is action:some-action – the transition action that is performed when the guard returns #t.

The third part is 'state-1 – the next state to which the transition will switch the parent FSM.

Note that the next state can be either a state name (as a Guile symbol) or a reference to a <state> instance.

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.7.1 Transition Accessors

A Guile-SMC transition content can be conveniently accessed by means of the following procedures.

Scheme Procedure: transition:guard (transition <list>)

Get the transition guard procedure.

Scheme Procedure: transition:action (transition <list>)

Get the transition action procedure.

Scheme Procedure: transition:next-state (transition <list>)

Get the transition next state.

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.7.2 Transition Table

Guile-SMC transitions are grouped into transition tables. Let’s take a look at the following example:

(list (list guard:some-guard action:action-1 'state1)
      (list guard:#t         action:action-2 'state2))

This transition table consists of two possible transitions: to state-1 and to state-2. In the closer look this form resembles classic state-transition tables:

current state | input            | output (action) | next state
state-2       | guard:some-guard | action:action-1 | state-1
state-2       | guard:#t         | action:action-2 | state-2

In the above example of Guile-SMC transition table there’s no “current state” as a <state> instance holds its transition table so there’s no need to store the current state in the transition table itself.

Scheme Procedure: transition-table-count (predicate <procedure>) (tlist <list>)

Return number of the elements in the tlist transition table for which predicate returns #t.

predicate is called on each transition.

To get the total number of transitions in a transition table pass (const #t) procedure as predicate:

(transition-table-count (const #t) some-transition-table)
Scheme Procedure: transition-table-run (tlist <list>) event context

Run a tlist transition table on the specified event and a context, return two values: the next state and a new context.

If no guards returned #t the procedure returns #f as the next state.

Scheme Procedure: transition-table-append (tlist <list>) @

(tguard <procedure>) @ (action <procedure>) @ next-state)

Append a new transition to the end of a tlist transition table. Return a new transition table with the new transition.

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.8 Context

(smc context context) contains the implementation of a generic context that can be used with an FSM to provide a memory. Also a context module usually provides event sources, guards, actions and other vital procedures for a FSM to work.

Custom contexts are required for some FSMs that need store some extra state (e.g. number of characters read by the parser.)

Guile-SMC can use any Scheme object as the context for a finite-state machine.

Class: <context> [#:debug-mode?=#f]

The main class.

This class holds two kinds of stack memory: a buffer to store events (data chunks) and a stanza that store a logical unit of data.

Scheme Procedure: context? x

Check if an x is a <context> instance.

Scheme Procedure: context-buffer-clear! (context <context>)

Clear the context buffer.

Scheme Procedure: context-stanza-clear! (context <context>)

Clear the context stanza.

Scheme Procedure: context-clear! (context <context>)

Clear both the context buffer and the current context stanza.

Scheme Procedure: action:store context event

Store an event into a context buffer.

Scheme Procedure: action:update-stanza context event

Store an event into a context stanza.

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.8.1 Character Context

(smc context char-context) contains an implementation of a character context that can be used to handle a stream of characters.

Class: <char-context> [#:debug-mode?=#f]

The main class.

Scheme Procedure: char-context-counter (ctx <char-context>)

Returns the value of the character counter of a context ctx.

Scheme Procedure: char-context-row-number (ctx <char-context>)

Returns the current row number for a context ctx.

Scheme Procedure: char-context-col-number (ctx <char-context>)

Returns the current column number for a context ctx.

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ] Guards

Each transition path in a FSM is guarded by a guard, when a guard returns #t the FSM transitions to the next state guarded by the guard and a transition action is performed.

Scheme Procedure: guard:asterisk? ctx ch
Scheme Procedure: guard:equals-sign? ctx ch
Scheme Procedure: guard:newline? ctx ch
Scheme Procedure: guard:hyphen-minus? ctx ch
Scheme Procedure: guard:space? ctx ch
Scheme Procedure: guard:less-than-sign? ctx ch
Scheme Procedure: guard:letter? ctx ch
Scheme Procedure: guard:more-than-sign? ctx ch
Scheme Procedure: guard:colon? ctx ch
Scheme Procedure: guard:semicolon? ctx ch
Scheme Procedure: guard:eof-object? ctx ch
Scheme Procedure: guard:single-quote? ctx ch
Scheme Procedure: guard:left-square-bracket? ctx ch
Scheme Procedure: guard:right-square-bracket? ctx ch
Scheme Procedure: guard:at-symbol? ctx ch

These procedures check if a ch is a specific symbol.

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ] Actions

An action can be attached to a state transition (thus producing a transition action) or to a state itself (in the form of either entry action or exit action.)

A transition action is performed when its transition guard returns #t.

Scheme Procedure: action:no-op context event

This is “no operation” action that just returns the context as is.

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ] Character Context

Class: <char-context>

A context to handle streams of characters.

Scheme Procedure: char-context-port (context <char-context>)
Scheme Procedure: char-context-counter (context <char-context>)

Get the context character counter.

Scheme Procedure: char-context-row (context <char-context>)
Scheme Procedure: char-context-col (context <char-context>)
Scheme Procedure: char-context-update-counters! (context <char-context>)
Scheme Procedure: event-source (context <char-context>)
Scheme Procedure: context-log-error ctx fmt . rest
Scheme Procedure: context-log-warning ctx fmt . rest
Scheme Procedure: context-log-info ctx fmt . rest
Scheme Procedure: context-log-debug ctx fmt . rest

Context logging procedures.

Scheme Procedure: action:syntax-error ctx ch

Throw a syntactic error with the current symbol ch, row, column and the context ctx.

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4 Command-Line Interface

Guile-SMC has a CLI (Command-Line Interface) that provides access to its features. It is built upon (smc cli) module that contains API (Application Programming Interface) for the tool.

The CLI tool is called simply ‘smc’. Please see smc --help output or man smc for usage information.

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.1 The Compiler

The state machine compiler allows to compile state machines from a formal description (currently only PlantUML format is supported.)

The compiler can be invoked by smc compile command.

You can get the actual help message for smc compile by passing it the --help option.

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.1.1 Compilation Targets

A Guile-SMC compilation target changes the compiler behavior so it produces the code in different form.

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ] guile target

The default compilation target. The code produced by the compiler for this target is dependent on the Guile-SMC.

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ] guile-standalone target

This compilation target produces GNU Guile FSM code in a single file that does not dependent on Guile-SMC.

All required Guile-SMC procedures will be copied to the output stream, and the extra procedures that are not used in the output code are removed by pruning.

The output code is similar to hand-crafted recursive code that a Scheme programmer could write given the knowledge of automata-based programming.

Here’s an example of an output FSM (without the auxiliary code copied from Guile-SMC that normally goes before this procedure):

(define (run-fsm context)
  (define (DEFAULT context)
    "Count parenthesis."
    (let ((event (event-source context)))
      (cond ((guard:eof-object? context event)
             (let ((context (action:validate context event)))
               (log-debug "[~a] -> [*]" 'DEFAULT)
            ((guard:semicolon? context event)
             (let ((context (action:no-op context event)))
               (log-debug "[~a] -> [~a]" 'DEFAULT 'COMMENT)
               (COMMENT context)))
            ((guard:double-quote? context event)
             (let ((context (action:no-op context event)))
               (log-debug "[~a] -> [~a]" 'DEFAULT 'STRING)
               (STRING context)))
            ((#{guard:#t}# context event)
             (let ((context (action:count context event)))
               (DEFAULT context))))))
  (define (STRING context)
    "Skip a string."
    (let ((event (event-source context)))
      (cond ((guard:double-quote? context event)
             (let ((context (action:no-op context event)))
               (log-debug "[~a] -> [~a]" 'STRING 'DEFAULT)
               (DEFAULT context)))
            ((#{guard:#t}# context event)
             (let ((context (action:no-op context event)))
               (STRING context))))))
  (define (COMMENT context)
    "Skip a comment."
    (let ((event (event-source context)))
      (cond ((guard:newline? context event)
             (let ((context (action:no-op context event)))
               (log-debug "[~a] -> [~a]" 'COMMENT 'DEFAULT)
               (DEFAULT context)))
            ((#{guard:#t}# context event)
             (let ((context (action:no-op context event)))
               (COMMENT context))))))
  (DEFAULT context))

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ] guile-standalone-copy target

The compiler can be configured in such way that it will copy all the modules that are needed to run the output FSM so the FSM will not depend on Guile-SMC.

For example, let’s imagine that we have the following file set:

├── context.scm
├── fsm.puml
├── main.scm

0 directories, 4 files

The ‘context.scm’ contains all actions, guards and event sources for FSM to run:

(define-module (context)
  #:use-module (opp goops)
  #:use-module (ice-9 textual-ports)
  #:use-module (smc context char-context)
  #:re-export (guard:#t
  #:export (event-source

(define-method (event-source (ctx <number>))
  (get-char (current-input-port)))

(define (action:count ctx char)
   ((char=? char #\()
    (+ ctx 1))
   ((char=? char #\))
    (- ctx 1))

(define (action:validate ctx char)
  (unless (zero? ctx)
    (error "Parenthesis mismatch" ctx))

The ‘fsm.puml’ file contains the FSM description in the PlantUML format:

[*] --> DEFAULT
DEFAULT: Count parenthesis.
DEFAULT --> [*]: guard:eof-object? -> action:validate
DEFAULT --> COMMENT: guard:semicolon?
DEFAULT --> STRING: guard:double-quote?
DEFAULT --> DEFAULT: guard:#t -> action:count

COMMENT: Skip a comment.
COMMENT --> DEFAULT: guard:newline?

STRING: Skip a string.
STRING --> DEFAULT: guard:double-quote?

Now let’s compile the FSM, using the guile-standalone target:

$ cat fsm.puml | /usr/bin/smc compile -L . -U "((context))" -m "(custom-fsm)" \
    --target guile-standalone-copy > custom-fsm.scm

Now the project root directory looks like this:

$ tree
├── context.scm
├── custom-fsm
│   ├── context.scm
│   └── smc
│       ├── context
│       │   ├── char-context.scm
│       │   └── context.scm
│       ├── core
│       │   ├── common.scm
│       │   ├── log.scm
│       │   ├── state.scm
│       │   └── transition.scm
│       └── fsm.scm
├── custom-fsm.scm
├── fsm.puml
├── main.scm

4 directories, 13 files

custom-fsm’ directory contains all the required Guile-SMC modules that the output FSM needs to run, plus the extra modules (like (context)) specified for the compiler.

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.2 The Context Generator and Analyzer

smc context allows to generate and analyze Guile-SMC FSM contexts.

There are two modes of context generation: the command either can generate a custom context stub based on an input PlantUML state machine description, or generate a standalone (intermediate) context that can be used by custom contexts to relax the dependency on Guile-SMC modules (and allow to compile custom FSMs in standalone mode in the future.)

When --resolve option is provided the command prints to the standard output the list of resolved and unresolved procedures based on the input PlantUML file.

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.3 The Profiler

The profiler allows to analyze state machines using its logs (traces) and thus provides facilities to detect bottlenecks in state machines in terms of running time.

Usage example:

$ smc profile fsm.log
Total transitions: 99
Total time:        14925 us
  read: 3158 us (21.1591 %)
  read_state_transition_guard: 1663 us (11.1424 %)
  read_state_transition_to: 1483 us (9.9363 %)
  read_word: 1259 us (8.4355 %)
  read_state_description: 1014 us (6.7940 %)
  read_state_right_arrow: 839 us (5.6214 %)
  search_state_transition_to: 670 us (4.4891 %)
  search_state_transition: 638 us (4.2747 %)
  read_state_transition_action: 536 us (3.5913 %)
  read_start_tag: 535 us (3.5846 %)
  search_state_transition_guard: 428 us (2.8677 %)
  read_state: 178 us (1.1926 %)
  search_state_transition_action: 139 us (.9313 %)
  read_state_action_arrow: 139 us (.9313 %)
  search_state_action_arrow: 132 us (.8844 %)
  read_end_tag: 125 us (.8375 %)

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.4 The Finite State Machine Runner

The state machine runner allows to run a state in ad hoc fashion with the minimum amount of supporting code:

$ smc run --help
Usage: smc run [options] <puml-file>

Run a state machine.

  --help, -h        Print this message and exit.
  --eval, -e <procedure>
                    Eval a procedure with the resulting context as a parameter.
                    Example value:
                      "(lambda (context) (display context))"
  --load-path, -L <load-path>
                    Add an extra load path.
  --context-thunk, -C <procedure>
                    A thunk that produces the initial value for an FSM context.
                    Example value: "(lambda () 0)"
  --modules, -U <modules>
                    Load additional modules.  The value must be the same
                    as for 'use-modules'.  Example value:
                      "((smc context char-context) (smc puml-context))"
  --validate        Validate the output FSM and print the validation result.
                    The exit code is 0 if the validation is passed,
                    and a non-zero value otherwise.
  --log-file <file> Log file to use.  Pass "-" as the file to use the standard
                    error stream (stderr.)
                    'smc run' logs to syslog by default.
  --debug           Enable the debug mode.

Usage example:

$ smc run -L . -U "((context))" -C "(lambda () 0)" fsm.puml

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.5 Programming API

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.5.1 (smc cli command-compile)

Scheme Procedure: command-compile args

Handle smc compile command.

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.5.2 (smc cli command-context)

Scheme Procedure: command-context args

Handle smc context command.

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.5.3 (smc cli command-profile)

Scheme Procedure: command-profile args

Handle smc profile command.

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.5.4 (smc cli command-run)

Scheme Procedure: command-run args

Handle smc run command.

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

Appendix A GNU Free Documentation License

Version 1.3, 3 November 2008

Copyright © 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.

Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.

    The purpose of this License is to make a manual, textbook, or other functional and useful document free in the sense of freedom: to assure everyone the effective freedom to copy and redistribute it, with or without modifying it, either commercially or noncommercially. Secondarily, this License preserves for the author and publisher a way to get credit for their work, while not being considered responsible for modifications made by others.

    This License is a kind of “copyleft”, which means that derivative works of the document must themselves be free in the same sense. It complements the GNU General Public License, which is a copyleft license designed for free software.

    We have designed this License in order to use it for manuals for free software, because free software needs free documentation: a free program should come with manuals providing the same freedoms that the software does. But this License is not limited to software manuals; it can be used for any textual work, regardless of subject matter or whether it is published as a printed book. We recommend this License principally for works whose purpose is instruction or reference.


    This License applies to any manual or other work, in any medium, that contains a notice placed by the copyright holder saying it can be distributed under the terms of this License. Such a notice grants a world-wide, royalty-free license, unlimited in duration, to use that work under the conditions stated herein. The “Document”, below, refers to any such manual or work. Any member of the public is a licensee, and is addressed as “you”. You accept the license if you copy, modify or distribute the work in a way requiring permission under copyright law.

    A “Modified Version” of the Document means any work containing the Document or a portion of it, either copied verbatim, or with modifications and/or translated into another language.

    A “Secondary Section” is a named appendix or a front-matter section of the Document that deals exclusively with the relationship of the publishers or authors of the Document to the Document’s overall subject (or to related matters) and contains nothing that could fall directly within that overall subject. (Thus, if the Document is in part a textbook of mathematics, a Secondary Section may not explain any mathematics.) The relationship could be a matter of historical connection with the subject or with related matters, or of legal, commercial, philosophical, ethical or political position regarding them.

    The “Invariant Sections” are certain Secondary Sections whose titles are designated, as being those of Invariant Sections, in the notice that says that the Document is released under this License. If a section does not fit the above definition of Secondary then it is not allowed to be designated as Invariant. The Document may contain zero Invariant Sections. If the Document does not identify any Invariant Sections then there are none.

    The “Cover Texts” are certain short passages of text that are listed, as Front-Cover Texts or Back-Cover Texts, in the notice that says that the Document is released under this License. A Front-Cover Text may be at most 5 words, and a Back-Cover Text may be at most 25 words.

    A “Transparent” copy of the Document means a machine-readable copy, represented in a format whose specification is available to the general public, that is suitable for revising the document straightforwardly with generic text editors or (for images composed of pixels) generic paint programs or (for drawings) some widely available drawing editor, and that is suitable for input to text formatters or for automatic translation to a variety of formats suitable for input to text formatters. A copy made in an otherwise Transparent file format whose markup, or absence of markup, has been arranged to thwart or discourage subsequent modification by readers is not Transparent. An image format is not Transparent if used for any substantial amount of text. A copy that is not “Transparent” is called “Opaque”.

    Examples of suitable formats for Transparent copies include plain ASCII without markup, Texinfo input format, LaTeX input format, SGML or XML using a publicly available DTD, and standard-conforming simple HTML, PostScript or PDF designed for human modification. Examples of transparent image formats include PNG, XCF and JPG. Opaque formats include proprietary formats that can be read and edited only by proprietary word processors, SGML or XML for which the DTD and/or processing tools are not generally available, and the machine-generated HTML, PostScript or PDF produced by some word processors for output purposes only.

    The “Title Page” means, for a printed book, the title page itself, plus such following pages as are needed to hold, legibly, the material this License requires to appear in the title page. For works in formats which do not have any title page as such, “Title Page” means the text near the most prominent appearance of the work’s title, preceding the beginning of the body of the text.

    The “publisher” means any person or entity that distributes copies of the Document to the public.

    A section “Entitled XYZ” means a named subunit of the Document whose title either is precisely XYZ or contains XYZ in parentheses following text that translates XYZ in another language. (Here XYZ stands for a specific section name mentioned below, such as “Acknowledgements”, “Dedications”, “Endorsements”, or “History”.) To “Preserve the Title” of such a section when you modify the Document means that it remains a section “Entitled XYZ” according to this definition.

    The Document may include Warranty Disclaimers next to the notice which states that this License applies to the Document. These Warranty Disclaimers are considered to be included by reference in this License, but only as regards disclaiming warranties: any other implication that these Warranty Disclaimers may have is void and has no effect on the meaning of this License.


    You may copy and distribute the Document in any medium, either commercially or noncommercially, provided that this License, the copyright notices, and the license notice saying this License applies to the Document are reproduced in all copies, and that you add no other conditions whatsoever to those of this License. You may not use technical measures to obstruct or control the reading or further copying of the copies you make or distribute. However, you may accept compensation in exchange for copies. If you distribute a large enough number of copies you must also follow the conditions in section 3.

    You may also lend copies, under the same conditions stated above, and you may publicly display copies.


    If you publish printed copies (or copies in media that commonly have printed covers) of the Document, numbering more than 100, and the Document’s license notice requires Cover Texts, you must enclose the copies in covers that carry, clearly and legibly, all these Cover Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on the back cover. Both covers must also clearly and legibly identify you as the publisher of these copies. The front cover must present the full title with all words of the title equally prominent and visible. You may add other material on the covers in addition. Copying with changes limited to the covers, as long as they preserve the title of the Document and satisfy these conditions, can be treated as verbatim copying in other respects.

    If the required texts for either cover are too voluminous to fit legibly, you should put the first ones listed (as many as fit reasonably) on the actual cover, and continue the rest onto adjacent pages.

    If you publish or distribute Opaque copies of the Document numbering more than 100, you must either include a machine-readable Transparent copy along with each Opaque copy, or state in or with each Opaque copy a computer-network location from which the general network-using public has access to download using public-standard network protocols a complete Transparent copy of the Document, free of added material. If you use the latter option, you must take reasonably prudent steps, when you begin distribution of Opaque copies in quantity, to ensure that this Transparent copy will remain thus accessible at the stated location until at least one year after the last time you distribute an Opaque copy (directly or through your agents or retailers) of that edition to the public.

    It is requested, but not required, that you contact the authors of the Document well before redistributing any large number of copies, to give them a chance to provide you with an updated version of the Document.


    You may copy and distribute a Modified Version of the Document under the conditions of sections 2 and 3 above, provided that you release the Modified Version under precisely this License, with the Modified Version filling the role of the Document, thus licensing distribution and modification of the Modified Version to whoever possesses a copy of it. In addition, you must do these things in the Modified Version:

    1. Use in the Title Page (and on the covers, if any) a title distinct from that of the Document, and from those of previous versions (which should, if there were any, be listed in the History section of the Document). You may use the same title as a previous version if the original publisher of that version gives permission.
    2. List on the Title Page, as authors, one or more persons or entities responsible for authorship of the modifications in the Modified Version, together with at least five of the principal authors of the Document (all of its principal authors, if it has fewer than five), unless they release you from this requirement.
    3. State on the Title page the name of the publisher of the Modified Version, as the publisher.
    4. Preserve all the copyright notices of the Document.
    5. Add an appropriate copyright notice for your modifications adjacent to the other copyright notices.
    6. Include, immediately after the copyright notices, a license notice giving the public permission to use the Modified Version under the terms of this License, in the form shown in the Addendum below.
    7. Preserve in that license notice the full lists of Invariant Sections and required Cover Texts given in the Document’s license notice.
    8. Include an unaltered copy of this License.
    9. Preserve the section Entitled “History”, Preserve its Title, and add to it an item stating at least the title, year, new authors, and publisher of the Modified Version as given on the Title Page. If there is no section Entitled “History” in the Document, create one stating the title, year, authors, and publisher of the Document as given on its Title Page, then add an item describing the Modified Version as stated in the previous sentence.
    10. Preserve the network location, if any, given in the Document for public access to a Transparent copy of the Document, and likewise the network locations given in the Document for previous versions it was based on. These may be placed in the “History” section. You may omit a network location for a work that was published at least four years before the Document itself, or if the original publisher of the version it refers to gives permission.
    11. For any section Entitled “Acknowledgements” or “Dedications”, Preserve the Title of the section, and preserve in the section all the substance and tone of each of the contributor acknowledgements and/or dedications given therein.
    12. Preserve all the Invariant Sections of the Document, unaltered in their text and in their titles. Section numbers or the equivalent are not considered part of the section titles.
    13. Delete any section Entitled “Endorsements”. Such a section may not be included in the Modified Version.
    14. Do not retitle any existing section to be Entitled “Endorsements” or to conflict in title with any Invariant Section.
    15. Preserve any Warranty Disclaimers.

    If the Modified Version includes new front-matter sections or appendices that qualify as Secondary Sections and contain no material copied from the Document, you may at your option designate some or all of these sections as invariant. To do this, add their titles to the list of Invariant Sections in the Modified Version’s license notice. These titles must be distinct from any other section titles.

    You may add a section Entitled “Endorsements”, provided it contains nothing but endorsements of your Modified Version by various parties—for example, statements of peer review or that the text has been approved by an organization as the authoritative definition of a standard.

    You may add a passage of up to five words as a Front-Cover Text, and a passage of up to 25 words as a Back-Cover Text, to the end of the list of Cover Texts in the Modified Version. Only one passage of Front-Cover Text and one of Back-Cover Text may be added by (or through arrangements made by) any one entity. If the Document already includes a cover text for the same cover, previously added by you or by arrangement made by the same entity you are acting on behalf of, you may not add another; but you may replace the old one, on explicit permission from the previous publisher that added the old one.

    The author(s) and publisher(s) of the Document do not by this License give permission to use their names for publicity for or to assert or imply endorsement of any Modified Version.


    You may combine the Document with other documents released under this License, under the terms defined in section 4 above for modified versions, provided that you include in the combination all of the Invariant Sections of all of the original documents, unmodified, and list them all as Invariant Sections of your combined work in its license notice, and that you preserve all their Warranty Disclaimers.

    The combined work need only contain one copy of this License, and multiple identical Invariant Sections may be replaced with a single copy. If there are multiple Invariant Sections with the same name but different contents, make the title of each such section unique by adding at the end of it, in parentheses, the name of the original author or publisher of that section if known, or else a unique number. Make the same adjustment to the section titles in the list of Invariant Sections in the license notice of the combined work.

    In the combination, you must combine any sections Entitled “History” in the various original documents, forming one section Entitled “History”; likewise combine any sections Entitled “Acknowledgements”, and any sections Entitled “Dedications”. You must delete all sections Entitled “Endorsements.”


    You may make a collection consisting of the Document and other documents released under this License, and replace the individual copies of this License in the various documents with a single copy that is included in the collection, provided that you follow the rules of this License for verbatim copying of each of the documents in all other respects.

    You may extract a single document from such a collection, and distribute it individually under this License, provided you insert a copy of this License into the extracted document, and follow this License in all other respects regarding verbatim copying of that document.


    A compilation of the Document or its derivatives with other separate and independent documents or works, in or on a volume of a storage or distribution medium, is called an “aggregate” if the copyright resulting from the compilation is not used to limit the legal rights of the compilation’s users beyond what the individual works permit. When the Document is included in an aggregate, this License does not apply to the other works in the aggregate which are not themselves derivative works of the Document.

    If the Cover Text requirement of section 3 is applicable to these copies of the Document, then if the Document is less than one half of the entire aggregate, the Document’s Cover Texts may be placed on covers that bracket the Document within the aggregate, or the electronic equivalent of covers if the Document is in electronic form. Otherwise they must appear on printed covers that bracket the whole aggregate.


    Translation is considered a kind of modification, so you may distribute translations of the Document under the terms of section 4. Replacing Invariant Sections with translations requires special permission from their copyright holders, but you may include translations of some or all Invariant Sections in addition to the original versions of these Invariant Sections. You may include a translation of this License, and all the license notices in the Document, and any Warranty Disclaimers, provided that you also include the original English version of this License and the original versions of those notices and disclaimers. In case of a disagreement between the translation and the original version of this License or a notice or disclaimer, the original version will prevail.

    If a section in the Document is Entitled “Acknowledgements”, “Dedications”, or “History”, the requirement (section 4) to Preserve its Title (section 1) will typically require changing the actual title.


    You may not copy, modify, sublicense, or distribute the Document except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, or distribute it is void, and will automatically terminate your rights under this License.

    However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation.

    Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice.

    Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, receipt of a copy of some or all of the same material does not give you any rights to use it.


    The Free Software Foundation may publish new, revised versions of the GNU Free Documentation License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. See

    Each version of the License is given a distinguishing version number. If the Document specifies that a particular numbered version of this License “or any later version” applies to it, you have the option of following the terms and conditions either of that specified version or of any later version that has been published (not as a draft) by the Free Software Foundation. If the Document does not specify a version number of this License, you may choose any version ever published (not as a draft) by the Free Software Foundation. If the Document specifies that a proxy can decide which future versions of this License can be used, that proxy’s public statement of acceptance of a version permanently authorizes you to choose that version for the Document.


    “Massive Multiauthor Collaboration Site” (or “MMC Site”) means any World Wide Web server that publishes copyrightable works and also provides prominent facilities for anybody to edit those works. A public wiki that anybody can edit is an example of such a server. A “Massive Multiauthor Collaboration” (or “MMC”) contained in the site means any set of copyrightable works thus published on the MMC site.

    “CC-BY-SA” means the Creative Commons Attribution-Share Alike 3.0 license published by Creative Commons Corporation, a not-for-profit corporation with a principal place of business in San Francisco, California, as well as future copyleft versions of that license published by that same organization.

    “Incorporate” means to publish or republish a Document, in whole or in part, as part of another Document.

    An MMC is “eligible for relicensing” if it is licensed under this License, and if all works that were first published under this License somewhere other than this MMC, and subsequently incorporated in whole or in part into the MMC, (1) had no cover texts or invariant sections, and (2) were thus incorporated prior to November 1, 2008.

    The operator of an MMC Site may republish an MMC contained in the site under CC-BY-SA on the same site at any time before August 1, 2009, provided the MMC is eligible for relicensing.

ADDENDUM: How to use this License for your documents

To use this License in a document you have written, include a copy of the License in the document and put the following copyright and license notices just after the title page:

  Copyright (C)  year  your name.
  Permission is granted to copy, distribute and/or modify this document
  under the terms of the GNU Free Documentation License, Version 1.3
  or any later version published by the Free Software Foundation;
  with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
  Texts.  A copy of the license is included in the section entitled ``GNU
  Free Documentation License''.

If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts, replace the “with…Texts.” line with this:

    with the Invariant Sections being list their titles, with
    the Front-Cover Texts being list, and with the Back-Cover Texts
    being list.

If you have Invariant Sections without Cover Texts, or some other combination of the three, merge those two alternatives to suit the situation.

If your document contains nontrivial examples of program code, we recommend releasing these examples in parallel under your choice of free software license, such as the GNU General Public License, to permit their use in free software.

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

Type Index

Jump to:   <
Index Entry  Section

<char-context> 3.8.1 Character Context
<char-context> Character Context
<context> 3.8 Context
<fsm> 3.1.1 The main class
<null-log> Null Log
<precise-logger> 3.5.1 The Precise Logger
<precise-port-log> Precise Port Log
<puml-context> 3.2.1 The PlantUML context
<state> 3.6.3 The main class
<stderr-log> Standard Error Log
<system-log> System Log

Jump to:   <

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

Procedure Index

Jump to:   %  
A   C   E   F   G   H   L   N   P   R   S   T  
Index Entry  Section

%default-entry-action 3.6.2 Default entry/exit actions
%default-exit-action 3.6.2 Default entry/exit actions
%precise-log-formatter 3.5.4 Helper Procedures

action:no-op Actions
action:store 3.8 Context
action:syntax-error Character Context
action:update-stanza 3.8 Context

char-context-col Character Context
char-context-col-number 3.8.1 Character Context
char-context-counter 3.8.1 Character Context
char-context-counter Character Context
char-context-port Character Context
char-context-row Character Context
char-context-row-number 3.8.1 Character Context
char-context-update-counters! Character Context
command-compile 4.5.1 (smc cli command-compile)
command-context 4.5.2 (smc cli command-context)
command-profile 4.5.3 (smc cli command-profile)
command-run 4.5.4 (smc cli command-run)
context-buffer-clear! 3.8 Context
context-clear! 3.8 Context
context-log-debug Character Context
context-log-error Character Context
context-log-info Character Context
context-log-warning Character Context
context-stanza-clear! 3.8 Context
context? 3.8 Context

equal? 3.6.4 Public API
event-source Character Context

fsm-compile 3.3 Compiler
fsm-incoming-transition-count Getting information about an FSM
fsm-log-transition Logging
fsm-log-transition Logging
fsm-log-transition Logging
fsm-run! Executing a FSM
fsm-run! Executing a FSM
fsm-state 3.1.2 Public API
fsm-state-add! 3.1.2 Public API
fsm-state-count Getting information about an FSM
fsm-state-description-add! 3.1.2 Public API
fsm-state-reachable? Getting information about an FSM
fsm-step! Executing a FSM
fsm-step! Executing a FSM
fsm-transition-add! 3.1.2 Public API
fsm-transition-count Getting information about an FSM
fsm-validate Getting information about an FSM
fsm? 3.1.2 Public API

guard:asterisk? Guards
guard:at-symbol? Guards
guard:colon? Guards
guard:eof-object? Guards
guard:equals-sign? Guards
guard:hyphen-minus? Guards
guard:left-square-bracket? Guards
guard:less-than-sign? Guards
guard:letter? Guards
guard:more-than-sign? Guards
guard:newline? Guards
guard:right-square-bracket? Guards
guard:semicolon? Guards
guard:single-quote? Guards
guard:space? Guards

hash-table->transition-list 3.1.2 Public API

list->state List/state conversion
log-debug 3.5.5 Logging Procedures
log-error 3.5.5 Logging Procedures
log-info 3.5.5 Logging Procedures
log-use-stderr! 3.5.3 Logging Initialization and Configuration
log-warning 3.5.5 Logging Procedures

null-log? Null Log

precise-logger? 3.5.1 The Precise Logger
puml->fsm 3.2.2 Public API
puml-context-fsm 3.2.2 Public API
puml-context-module 3.2.2 Public API
puml-context-print-resolver-status Resolver status
puml-context-resolved-procedures Resolver status
puml-context-unresolved-procedures Resolver status
puml-string->fsm 3.2.2 Public API

resolve-procedure 3.2.3 Internal procedures

smc-log 3.5.5 Logging Procedures
smc-log-init! 3.5.3 Logging Initialization and Configuration
smc-version 3.4 Version
smc-version/major 3.4 Version
smc-version/minor 3.4 Version
smc-version/patch 3.4 Version
smc-version/string 3.4 Version
state->list List/state conversion
state->list/serialized List/state conversion
state-dead-end? 3.6.4 Public API
state-description 3.6.4 Public API
state-entry-action 3.6.4 Public API
state-entry-action-set! 3.6.4 Public API
state-event-source 3.6.4 Public API
state-event-source-set! 3.6.4 Public API
state-exit-action 3.6.4 Public API
state-exit-action-set! 3.6.4 Public API
state-final-transitions 3.6.4 Public API
state-has-event-source? 3.6.4 Public API
state-has-final-transitions? 3.6.4 Public API
state-has-recurrent-links? 3.6.4 Public API
state-name 3.6.4 Public API
state-name 3.6.4 Public API
state-recurrent-links-count 3.6.4 Public API
state-run 3.6.4 Public API
state-transition-add! 3.6.4 Public API
state-transition-count 3.6.4 Public API
state-transition-count 3.6.4 Public API
state-transition-count/foreign 3.6.4 Public API
state-transitions 3.6.4 Public API
state:description State as a list
state:entry-action State as a list
state:event-source State as a list
state:event-source/name State as a list
state:exit-action State as a list
state:name State as a list
state:transitions State as a list
state? 3.6.4 Public API
system-log? System Log

transition-list->hash-table 3.1.2 Public API
transition-table-append 3.7.2 Transition Table
transition-table-count 3.7.2 Transition Table
transition-table-run 3.7.2 Transition Table
transition:action 3.7.1 Transition Accessors
transition:guard 3.7.1 Transition Accessors
transition:next-state 3.7.1 Transition Accessors

Jump to:   %  
A   C   E   F   G   H   L   N   P   R   S   T  

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

Concept Index

Jump to:   A   B   C   F   G   P   S   T   V  
Index Entry  Section

Action Guards

Buffer 3.8 Context

CLI 4 Command-Line Interface
Compilation Targets 4.1.1 Compilation Targets
Compiler 3.3 Compiler
Context 3.8 Context

FSM logging Logging

Guard 3.8.1 Character Context

Profiler 4.3 The Profiler

Stanza 3.8 Context
State 3.6 State

Transition 3.7 Transition
Transition Action 3.7 Transition
Transition Guard 3.7 Transition
Transition Next State 3.7 Transition
Transition Table 3.7.2 Transition Table

Versioning 3.4 Version

Jump to:   A   B   C   F   G   P   S   T   V  

[Top] [Contents] [Index] [ ? ]

Table of Contents

[Top] [Contents] [Index] [ ? ]

About This Document

This document was generated on September 11, 2022 using texi2html 5.0.

The buttons in the navigation panels have the following meaning:

Button Name Go to From 1.2.3 go to
[ << ] FastBack Beginning of this chapter or previous chapter 1
[ < ] Back Previous section in reading order 1.2.2
[ Up ] Up Up section 1.2
[ > ] Forward Next section in reading order 1.2.4
[ >> ] FastForward Next chapter 2
[Top] Top Cover (top) of document  
[Contents] Contents Table of contents  
[Index] Index Index  
[ ? ] About About (help)  

where the Example assumes that the current position is at Subsubsection One-Two-Three of a document of the following structure:

This document was generated on September 11, 2022 using texi2html 5.0.