digitalmars.D.learn - Finite state machine in D
- Druzhinin Alexandr (5/5) Sep 26 2012 Hello
- Mirko Pilger (2/3) Sep 27 2012 you might have a look at ragel:
- Druzhinin Alexandr (7/10) Sep 27 2012 I had. It's good but is too fat for my purpose - simple fsm
- Philippe Sigaud (16/18) Sep 27 2012 I'm not sure you need code generation. Using D functions literals or
- Druzhinin Alexandr (3/12) Sep 27 2012 yes, I'm interested. Thanks in advance.
- Philippe Sigaud (9/12) Sep 27 2012 Here is an example:
- Druzhinin Alexandr (3/10) Sep 29 2012 Oh, there's a lot to know. ) Thank you!
Hello Could someone help me with FSM (like boost MSM but simpler and in D of course) - where should I start from? I found good paper about FSM implementation in c++ (with type list and so on), but I'm not sure it is applicable in D. What is the D-way to implement fsm with code generation?
Sep 26 2012
What is the D-way to implement fsm with code generation?you might have a look at ragel: http://www.complang.org/ragel/
Sep 27 2012
27.09.2012 14:48, Mirko Pilger пишет:I had. It's good but is too fat for my purpose - simple fsm implementation in D without third party's instruments (for simple use). My question was inspired when I saw several fsm implementation in c++, but I didn't find D implementation to compare with. And now I'm writing my own. This writing seems to be very useful - I've found new advantages of D over C++ =)What is the D-way to implement fsm with code generation?you might have a look at ragel: http://www.complang.org/ragel/
Sep 27 2012
On Thu, Sep 27, 2012 at 10:15 AM, Druzhinin Alexandr <news digitalmars.com> wrote:27.09.2012 14:48, Mirko Pilger =D0=BF=D0=B8=D1=88=D0=B5=D1=82: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.What is the D-way to implement fsm with code generation?
Sep 27 2012
27.09.2012 18:15, Philippe Sigaud пишет: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.yes, I'm interested. Thanks in advance. What about code generation - I just want to learn how to do it, so
Sep 27 2012
On Thu, Sep 27, 2012 at 2:39 PM, Druzhinin Alexandr <news digitalmars.com> wrote:Here is an example: http://dpaste.dzfl.pl/81a63163yes, I'm interested. Thanks in advance.What about code generation - I just want to learn how to do it, soSeeing your code in another thread, yes code generation could help here. I have a template tutorial (a bit light on code generation) that might help you on this. https://github.com/PhilippeSigaud/D-templates-tutorial/blob/master/dtemplates.pdf?raw=true (this will download a pdf)
Sep 27 2012
28.09.2012 01:24, Philippe Sigaud пишет:Here is an example: http://dpaste.dzfl.pl/81a63163it's really interesting for me.Seeing your code in another thread, yes code generation could help here. I have a template tutorial (a bit light on code generation) that might help you on this. https://github.com/PhilippeSigaud/D-templates-tutorial/blob/master/dtemplates.pdf?raw=true (this will download a pdf)Oh, there's a lot to know. ) Thank you!
Sep 29 2012