Alpha: this compiler is under active development and updates will break your projects. Not recommended for real use yet.
Skip to content

Commands and handlers ​

The dispatcher picks a handler by the node's type.

Backend - Walking the ASTDispatcherdispatch(node, ctx)CommandHandlergenerate(node, ctx)TreeCommandHandlerCodegenContextlinesemit(line, info)DatapackfileslineInfoRenders every generatedvanilla command.by node.typeemit()saved to

Handlers never import each other. To compile a child body (an if branch, a click command), a handler makes a scratch CodegenContext with the same dispatcher and dispatches into it. A one-line result goes inline; a longer one becomes a child function.

Diagrams ​

Emit Pattern - Handlers never import each otherIfHandlerscratchDispatcherSayHandlerIfHandlerscratchCodegenContextDispatcherSayHandlerIfHandlerscratchCodegenContextDispatcherSayHandlernew context for the branchdispatch(say node)generate()emit("say High")one line -> inline itmore -> "function ns:zzzprivate/main/if_0"Owns the handler map, so no handlerimports another and commands/ has no cycles.
Handlers compile child bodies through the dispatchergenerateFunctionDispatcherhandler.generategenerateFunctionDispatcherhandler.generategenerateFunctionDispatcherhandler.generateeach nodegenerate()child body (if branch, loop …)

Released under the MIT License · Credits
These docs were written with AI; the layout and every page have been reviewed by a human.