On Thu, Sep 27, 2012 at 10:15 AM, Druzhinin Alexandr
<n...@digitalmars.com> wrote:
> 27.09.2012 14:48, Mirko Pilger пишет:
>
>>> What is the D-way to implement fsm with code generation?

I'm not sure you need code generation. Using D functions literals or
closures already gives you a good part of a FSM:

States are functions, that accept a current 'payload' and return a
tuple consisting of another function and the new payload.
The FSM driver just call the current state on the current payload,
stores the new stat/payload pair and loop until it reaches a terminal
state.

I can search at home to see what I have (if I kept anything), if
you're interested. It's a FSM in 10-20 lines of code, IIRC.

If you really want code generation, could you give us some use case?
std.regex contains a compile-time regex engine that is, in a way, a
FSM on steroids. I have a parser generator project on github that also
does code generation, but both modules are for a particular type of
automata: parsers/matchers, not a generic FSM.

Reply via email to