[ragel-users] Nested machines to make a HSM?

Adrian Thurston thurs... at cs.queensu.ca
Fri Jul 18 23:27:47 UTC 2008


Hi Chuck,

If you were to design your state machine using the comma and epsilon
operators you would run into the problem of referencing names that are
not in the current machine.

If you were to use fgoto though you could take this approach.

-Adrian

Chuck Remes wrote:
> I'm currently reading "Practical Statecharts in C/C++" by Miro Samek  
> which was suggested on this list some months ago. It is blowing my mind.
> 
> I'm curious to know if it is possible to use ragel to nest multiple  
> machines so that behavior is inherited as described in that book.
> 
> If you haven't read the book, I'll give a quickie explanation. Imagine  
> an oven that has 4 states:
> 
> Heating
> 	Baking
> 	Toasting
> Door Open
> 
> The Baking and Toasting states are substates of the Heating superstate  
> because they exhibit different behavior though both require the  
> heating element to be on. If the machine is in the Toasting state and  
> it receives a door opened event, it transitions to Door Open. Toasting  
> has no exit action of its own; it inherits an exit action  
> (TurnOffHeatingElement) from its superstate, Heating.
> 
> So, much like we have encapsulation and inheritance in OOP, a  
> hierarchical state machine allows substates to inherit behavior from  
> superstates. Here endeth the quickie overview. I hope it made some  
> sense.
> 
> Is this kind of inheritance (or chain of responsibility-ish) behavior  
> possible in ragel? If so, how would one achieve it?
> 
> cr
> 
> 



More information about the ragel-users mailing list