The type of the machine data member; usually omitted
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;');
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 Machine.constructor to turn the config object into a workable machine.
This method is mostly for plugin and intermediate tool authors, or people who need to work with the machine's intermediate representation.
Source-location-aware error reporting
compile()ignoreslocand*_locfields during machine construction — the resulting config is identical whether or not the tree was parsed with{ locations: true }. However, when those fields are present,compile()attaches the offending node's source span to any semantic JssmError it throws, via the error'ssource_locationfield (type FslSourceLocation). This lets downstream tooling (e.g. a CodeMirror 6 linter) map the error to a precise editor range without any additional source-scanning.