[ragel-users] Re: Fixing an edge case

Matt Mower s... at mattmower.com
Tue Jan 16 21:55:12 UTC 2007

Hi Adrian,

Many thanks for the recap :)

On 16/01/07, Adrian Thurston <thurs... at cs.queensu.ca> wrote:
> The following code is one way to fix the problem. It's like the above, but
> separates the leaving/eof actions from the non-empty case. When diff2 exits
> after only a diffHeader the empty diff action is executed. Note that here
> diffHeader is unioned with itself. This relies on the fact that ragel
> removes action duplicates from transition lists. Otherwise the actions of
> diffHeader would be doubled up.
> diff2 = (
>         diffHeader %empty_diff %/empty_diff |
>         diffHeader ( binaryDiff | textDiff )
> );

Interesting, so it can track that the leaving action should only
happen when neither of the non-empty diff paths is taken after
reduction? My gut feeling would have been that it would end up
executing them every time. I shall have to graph it and take a look.

> And finally, this is another way to do it. I essentially factor out the
> diffHeader. The "" machine is a single state which has the leaving/eof
> actions embedded into it.
> diff3 = (
>         diffHeader (
>                 "" %empty_diff %/empty_diff |
>                 ( binaryDiff | textDiff )
>         )
> );

Ah, I think that's more what I was intuitively trying to grasp for. Cool.

Thanks again for your help!



Matt Mower :: http://matt.blogs.it/

More information about the ragel-users mailing list