3 ms·
I wrote a hierarchical state machine generator years ago that did all of that by simply calling an interface when entering/leaving/staying in a state (tick). Re
by deterministic 4y ago
I wrote a hierarchical state machine generator years ago that did all of that by simply calling an interface when entering/leaving/staying in a state (tick). Recursively calling the interface when pushing/popping a hierarchy of states. I used it to implement a commercial game. It worked great! It did everything I needed (and more) without having to mix source code in the spec files.
I also implemented a code generator that I am using at work to generate C++/Java parsers from the same (BNF style) spec file. Again without adding source code to the spec files. The generated parsers are used in production and has been for years. The generated code is super clean. With a clear separation between the generated code and the code using it. It would be easy to generate (say) Typescript as well without touching the spec files.
But of course there might be scenarios that you need that I have never needed where embedding source code is necessary. I just haven’t seen any situation where that is required in my 30+ years career.
I always write my own code generators by the way. It’s great fun, it’s easy, and I can make it perfectly fit what I need. And it makes other developers think I am some sort of genius because they don’t know how easy it is :)