Nested machines to make a HSM?

Chuck Remes cremes.devl... at mac.com
Fri Jul 11 17:16:26 UTC 2008


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