The arrow to be evaluated
Return the direction of an arrow - right
, left
, or both
.
import { arrow_left_kind } from 'jssm';
arrow_left_kind('<-'); // 'legal'
arrow_left_kind('<='); // 'main'
arrow_left_kind('<~'); // 'forced'
arrow_left_kind('<->'); // 'legal'
arrow_left_kind('->'); // 'none'
The arrow to be evaluated
Return the direction of an arrow - right
, left
, or both
.
import { arrow_left_kind } from 'jssm';
arrow_left_kind('->'); // 'legal'
arrow_left_kind('=>'); // 'main'
arrow_left_kind('~>'); // 'forced'
arrow_left_kind('<->'); // 'legal'
arrow_left_kind('<-'); // 'none'
The arrow to be evaluated
Compile a machine's JSON intermediate representation to a config object. If you're using this (probably don't,) you're probably also using parse to get the IR, and the object constructor {@link Machine.construct} to turn the config object into a workable machine.
import { parse, compile, Machine } from 'jssm';
const intermediate = parse('a -> b;');
// [ {key:'transition', from:'a', se:{kind:'->',to:'b'}} ]
const cfg = compile(intermediate);
// { start_states:['a'], transitions: [{ from:'a', to:'b', kind:'legal', forced_only:false, main_path:false }] }
const machine = new Machine(cfg);
// Machine { _instance_name: undefined, _state: 'a', ...
This method is mostly for plugin and intermediate tool authors, or people who need to work with the machine's intermediate representation.
Most people looking at this want either the sm
operator or method from
,
which perform all the steps in the chain. The library's author mostly uses
operator sm
, and mostly falls back to .from
when needing to parse
strings dynamically instead of from template literals.
Operator sm:
import { sm } from 'jssm';
const lswitch = sm`on <=> off;`;
Method from:
import * as jssm from 'jssm';
const toggle = jssm.from('up <=> down;');
The type of the machine data member; usually omitted
The parse tree to be boiled down into a machine config
Create a state machine from an implementation string. This is one of the two main paths for working with JSSM, alongside sm.
Use this method when you want to conveniently pull a state machine from a
string dynamically. Use operator sm
when you just want to work with a
template expression.
import * as jssm from 'jssm';
const lswitch = jssm.from('on <=> off;');
The type of the machine data member; usually omitted
The FSL code to evaluate
Extra non-code configuration to pass at creation time
The type of the machine data member; usually omitted
The FSL code to be evaluated and built into a machine config
This method wraps the parser call that comes from the peg grammar, parse. Generally neither this nor that should be used directly unless you mean to develop plugins or extensions for the machine.
Parses the intermediate representation of a compiled string down to a machine configuration object. If you're using this (probably don't,) you're probably also using compile and Machine.constructor.
import { parse, compile, Machine } from 'jssm';
const intermediate = wrap_parse('a -> b;', {});
// [ {key:'transition', from:'a', se:{kind:'->',to:'b'}} ]
const cfg = compile(intermediate);
// { start_states:['a'], transitions: [{ from:'a', to:'b', kind:'legal', forced_only:false, main_path:false }] }
const machine = new Machine(cfg);
// Machine { _instance_name: undefined, _state: 'a', ...
This method is mostly for plugin and intermediate tool authors, or people who need to work with the machine's intermediate representation.
Most people looking at this want either the sm
operator or method from
,
which perform all the steps in the chain. The library's author mostly uses
operator sm
, and mostly falls back to .from
when needing to parse
strings dynamically instead of from template literals.
Operator sm:
import { sm } from 'jssm';
const lswitch = sm`on <=> off;`;
Method from:
import * as jssm from 'jssm';
const toggle = jssm.from('up <=> down;');
wrap_parse
itself is an internal convenience method for alting out an
object as the options call. Not generally meant for external use.
The FSL code to be evaluated
Things to control about the instance
Create a state machine from a template string. This is one of the two main paths for working with JSSM, alongside from.
Use this method when you want to work directly and conveniently with a
constant template expression. Use .from
when you want to pull from
dynamic strings.
import * as jssm from 'jssm';
const lswitch = jssm.from('on <=> off;');
The type of the machine data member; usually omitted
The assembled code
The mechanic for template argument insertion
An internal method meant to take a series of declarations and fold them into a single multi-faceted declaration, in the process of building a state. Not generally meant for external use.
Generated using TypeDoc
Return the direction of an arrow -
right
,left
, orboth
.