[ragel-users] How to avoid % action being called when the match continues? [SOLVED]

Iñaki Baz Castillo ibc at aliax.net
Sat Dec 5 00:07:01 UTC 2009


El Sábado, 5 de Diciembre de 2009, Iñaki Baz Castillo escribió:
> Hi, I have a simple grammar:
> 
>   pchar     = ALPHA | DIGIT | ("%" HEXDIG HEXDIG);
>   L_BRACKET = "%5b";
>   node_name = ( pchar )+ -- L_BRACKET
>   step      = node_name %command L_BRACKET .....
> 
> As you can see, when parsing "step" Ragel calls "command" action when
> L_BRACKET is detected. However, if any other hex-escaped appears into
> node_name then Ragel runs "command" action and then continues still into
> "node_name".
> 
> This is: when Ragel is parsing "node_name" and founds "%" (even if it's
>  "%99" rather than "%5b") then it runs "command" action. I expected that
>  Ragel wouldn't run the leaving action as it remains into node_name.
> 
> Why doe Ragel run the % leaving action when finding "%"? perhaps because
>  Ragel must take the decision per byte without reading more than one byte?
>  If so, is there any way to avoid "command" action being called several
>  times for the same node_name?
> 
> To clarify: if "step" is:
>   qqq%00www%11eee%5bzzz
> 
> then Ragel calls "command" action 3 times (each times it finds "%").

Ok, I've solved it by adding a "boolean" variable (well, a "int" as there is 
no boolean into C) so when running "command" action I just perform the code if 
the variable is 1 and then set it to 0.


-- 
Iñaki Baz Castillo <ibc at aliax.net>




More information about the ragel-users mailing list