[ragel-users] union operator and thread-local variables

Devin Bayer web at t-0.be
Wed Oct 28 14:55:23 UTC 2009


Hello. I would like to parse a date which can be in one of 
several forms and I want to get the number of a month in a variable.

My problem is that for some input, the month is parsed by both 
alternatives, but I need to get the correct value. If I could 
detect which "thread" I am in, I could throw away the other 
values in an @lerr handler.

This machine demonstrates what I want:

%%{
     machine test;

     action in { puts("mon begins", fpc); }
     action out { puts("mon ends", fpc); }
     action fail { puts("thread failed", fpc); }

     i = digit+;
     day = i " ";
     mon = i >in %out " ";
     time = (i ":" i) @lerr(fail);
     stamp
         = day mon time
         | mon time
         ;

     main := stamp "\n" >{ puts("done"); };
}%%

Is there another way to do this?

Thanks,
Devin Bayer




More information about the ragel-users mailing list