ic_fluent_resize_20_filledCreated with Sketch.
Skip to content

Codegen Architecture Overview

Dialect Overview

DialectBase classOutputArchitectureRuntime depsInstance type
JavaScriptJavaScriptCodegenSingle .jsClass, extends GenericAutomata@yantrix/coreClass instance
TypeScriptTypeScriptCodegenSingle .tsClass, extends GenericAutomata@yantrix/coreClass instance
PureJavaScriptPureJavaScriptCodegenSingle .jsFunctional factory, zero importsInline builtinsPlain object with getters
PureTypeScriptPureTypeScriptCodegen.js + .d.tsFunctional factory + type declarationsInline builtinsTyped plain object
PythonPythonCodegen (standalone)Single .pyFunctional factory, zero importspydash (runtime peer)Dict with lambda accessors

Inheritance: JavaScriptCodegen is the base for TypeScriptCodegen (adds hasTypes: true), PureJavaScriptCodegen (adds inlined builtins, no imports), and PureTypeScriptCodegen (adds hasTypes: true on top of PureJS). PythonCodegen is a standalone class with its own expression system.

createEventBus signature differs by dialect group:

  • Class-based (JS, TS): accepts constructors - FSMs: Record<string, new () => GenericAutomata>
  • Factory-based (PureJS, PureTS): accepts factory functions - FSMs: Record<string, () => TInstance>

Yantrix Code Generation Pipeline

ic_fluent_resize_20_filledCreated with Sketch.

Figure 1: The code generation pipeline in Yantrix: the CLI reads a Mermaid state diagram and Yantrix notes, parses them with mermaid-parser and YantrixParser, runs the codegen module to build dictionaries, reducers and the automaton class, and finally writes the generated automaton code to a file