Generate native code from SCXML state machines for Java, JavaScript, C#, C, Python, Go, and Structured Text.
Generate production-ready transpiled code from an SCXML state machine.
Call scxml_status first to check which backends are running:
Choose target — ask the user which language:
java — Gradle project, Rhino/GraalJS ECMAScriptjs / javascript — Node.js project, native JS enginecsharp — .NET project, Jint ECMAScriptc — CMake project, JerryScript ECMAScript (or bare-metal)python — pip project, dukpy ECMAScriptgo — Go module, Goja ECMAScriptst — IEC 61131-3 Structured Text for PLCs (CODESYS, TwinCAT, OpenPLC)Choose datamodel (if not already set in the SCXML):
ecmascript — default, 100% W3C compliant across all targetsnull — no variables, pure event-drivenxpath — Java only, XPath 2.0 expressionsnative-{target} — type-safe language-native variables (e.g., native-java, native-csharp, native-c, native-python, native-go, native-st)Generate project with scxml_generate_project:
tracingMode: "full" for trace recording in generated codebuildCommand and runCommandaction_execute entriesplcPlatform option:
codesys (default) — 3rd edition with METHODsiec-strict — no pragmas or access modifiersopenplc — 2nd edition with standalone FUNCTIONs (no METHODs)Build and run:
buildCommand (e.g., gradle build, dotnet build, cmake .. && make)runCommand (e.g., gradle run, dotnet run, ./build/main)--events ev1 ev2 for batch mode and --verbose for loggingCompare traces (if simulator trace exists):
scxml_compare_traces(expectedName="simulator-trace", actualName="java-trace", normalize=true)mode: "state-sequence" for state-only comparisonmode: "structural" to ignore loop count differencesscxml_generate with codeOnly: true for just the state machine code (no project scaffolding)SCXML_PLATFORM_BARE_METALsm.start() neededSendById(EVT_*) for O(1) event dispatch (available on Java, Go, C#, Python, C)getAllEvents(), getEnabledEvents(), getEventsForState(id), getEnabledEventsForState(id)