[ragel-users] Using Ragel for state machine
Adrian Thurston
thurston at complang.org
Sat Oct 10 00:20:34 UTC 2009
You're going to have trouble using that recursive style. A ragel state
machine definition represents a set of states that is substituted in
place where it is referenced. This precludes recursive definitions.
Another way to look at the problem is to note that regular languages do
not support recursion, and ragel (at the core) is a means of defining
regular languages.
It looks like you can rearrange this grammar without recursion to
something like:
main := ( pressUser+ insertUsb removeUsb )*;
-Adrian
Neil Webster wrote:
> Hi,
>
> Is it possible to generate a state machine from the code below? I am
> getting stuck with using engines before they have been defined and as
> far as I can figure out, no matter how I order things this will still
> happen.
>
> %%{
>
> machine adcpState ;
>
> pressUser = 1;
> insertUsb = 2;
> removeUsb = 3;
>
> Idle = pressUser Recording ;
>
> MassStorage = removeUsb Idle ;
>
> Recording = pressUser Idle
> | insertUsb MassStorage
> ;
>
> main := Idle ;
>
> write data;
>
> }%%
>
>
>
>
> _______________________________________________
> ragel-users mailing list
> ragel-users at complang.org
> http://www.complang.org/mailman/listinfo/ragel-users
More information about the ragel-users
mailing list