The type of state names in the resulting tree; the
grammar itself always produces strings, so only
override this when threading a caller's own state
naming through to compile.
The type of the machine data member; usually omitted.
The FSL code to be evaluated
Optionaloptions: JssmParseOptions
Things to control about the parse. Pass
{ locations: true } to enable opt-in source location
tracking on every AST node. When omitted, an empty options
object is passed through to the parser.
The machine's intermediate representation: a flat JssmParseTree with one node per top-level FSL statement.
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.
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.
This method is mostly for plugin and intermediate tool authors, or people who need to work with the machine's intermediate representation.
Opt-in source locations
Pass
{ locations: true }to attach source-span information to every object node in the AST. Each node gains alocfield of type FslSourceLocation covering its full statement span. Selected nodes also gain curated sub-span fields that pinpoint individual tokens within the statement:from_loc(source state),to_loc(target state, on the nestedseobject),l_action_loc/r_action_loc(action labels).name_loc(state name), plusvalue_locon each color-bearing item inside the declaration block.machine_name,fsl_version, etc.):value_loc(the attribute value token).Without
{ locations: true }the AST is byte-for-byte identical to the default output; nolocor*_locfields are present.