How do I add code generation support for another language, or modify exiting language? #374
-
|
I'm really digging StateSmith! I would like to support another programming language, but I couldn't find where the state machine code is generated from in the repositories. Where do I find it? Also, does it use a templating facility like T4, or mustache? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
Awesome! The current code generation has two stages.
The algorithm is all about how the state machine code works. Does it use function pointers? Switch statements? A table? See more here: https://github.com/StateSmith/StateSmith/wiki/Algorithms The GIL is just a restricted subset of C# so that we can use Roslyn tools to aid in transpiling. I will help get you started. This will be our first community added language! 🎉 Step 0Open a new issue with the language to support. Step 1 - manual code translationLet's start simple. We'll manually create the desired output for a tiny hierarchical state machine.
@startuml LightSm
state OFF
state ON_GROUP {
state ON1
state ON2
}
' ////////// STATE HANDLERS //////////
[*] -> OFF
OFF: enter / off();
OFF --> ON1: INC
ON_GROUP --> OFF: OFF
ON1: enter / blueLaser();
ON1 --> ON2: INC
ON1 --> OFF: DIM
ON2: enter / yellowLaser();
ON2: enter / count = 0;
ON2: 1. INC / count++;
ON2 --> ON1: DIM
@endumlI'm excited to see us support a new language :) Thanks! |
Beta Was this translation helpful? Give feedback.

Awesome!
The current code generation has two stages.
The algorithm is all about how the state machine code works. Does it use function pointers? Switch statements? A table? See more here: https://github.com/StateSmith/StateSmith/wiki/Algorithms
The GIL is just a restricted subset of C# so that we can use Roslyn tools to aid in transpiling.
I will help get you started. This will be our first community added language! 🎉
Step 0
Open a new issue with the language to support.
Step 1 - manual code translation
Let's start simple. We'll manually creat…