[ragel-users] Ragel for network protocols?

Adrian Thurston thurs... at cs.queensu.ca
Wed Nov 8 19:20:32 UTC 2006


Hi St├ęphane,

The mechanism for building machines with the state chart paradigm is hidden 
away in the language. You use the following operators

label:  make labels
->      draw epsilon operations
,       join machines together without transitions
()      grouping comes in handy

You always need a start label for a join to work and if you want any final 
states you need to make them explicitly by drawing an epsilon transition to 
the implicitly created "final" state.

Note that if you're feeling adventurous, OPEN and CLOSE can be arbitrary 
regular expressions.

%%{
	machine foo;

	OPEN = 0;
	CLOSE = 1;

	main :=
		start:
		door_closed: (
			OPEN -> door_open -> final
		),
		door_open: (
			CLOSE -> door_closed
		);
}%%


St├ęphane Bortzmeyer wrote:
> I'm trying to experiment with Ragel for specifying network protocols,
> which are often described as state machines.
> 
> All the Ragel examples I can find are for parsers, not for protocol
> state machines. Reading the documentation, I still cannot write a
> state machine for a protocol as simple as:
> 
>                         Open
>                        /        \
>                        /          \
>  +--------------+            \  +-------------+
>  |                     |            > |                   |
>  | Door-closed  |              |  Door-open |
>  +--------------+               +-------------+
>                        ^            /
>                          \          /
>                           \        /
>                          Close
> 
> Any sample code somewhere?
> 
> 



More information about the ragel-users mailing list