Some Ragel Ideas

Steve Horne stephenhorne... at
Tue Feb 13 09:48:12 UTC 2007

Is this an appropriate place to discuss Kelbt?

Also, here's a few Ragel extension ideas - none are things I need ATM
(barring perhaps the third one), just nice ideas.

First off, could Ragel be extended to handle tail recursion? Direct
tail recursion would be sufficient. Indirect tail recursion even
better, but I imagine quite difficult.

For example, consider the following...

main := case1 main? | case2 main | case3 | case4;

This can be translated to a non-recursive form, of course, giving...

main := (case1 | case2)* (case1 | case3 | case4);

But depending on the context, the tail recursive form may be clearer
and better describe the intent, or may be closer to the way the
requirements are specified. Note, for example, that the recursive
spec. only references each 'case' once, whereas the non-recursive
version mentions 'case1' twice (in the loop, and as a possible

Second, how about an equivalence assertion operator?

The idea here is that two different specifications of a machine could
represent two 'theories' of how it would work. If the two theories
give different results, display an error message.

In combination with the recursion support, for instance, this would
allow the same machine to be described both ways for readability and
validation purposes. Anyone trying to understand the machine could
read either specification.

Third, Ragel seems to have a lot of cryptic operators. For those of us
who will only be using it occasionally, it might be a bit more
friendly if the less standard/obvious ones were given explicitly named
equivalents. Perhaps something similar to...

  "{*" identifier args* "*}"

... could be treated as a kind of S-expression alternative form for
some operators (esp. action operators and guarded forms).

For actions, rather than nesting { and }, a separator might be

  {* on_enter action_name  *}
  {* on_enter : <action code>  *}

One idea I have in mind involves a kind of paranoid library, that
checks whether calls to it match the required protocol - a file
creation library that knows when the caller has misbehaved in such a
way that a corrupt file has been created.

More information about the ragel-users mailing list