[ragel-users] Re: Some Ragel Ideas

Adrian Thurston thurs... at cs.queensu.ca
Wed Feb 14 05:31:44 UTC 2007


Hey Steve,

Steve Horne wrote:
> It should be possible to do this without a parse tree rewrite, though
> - think of the recursion as a 'goto' rather than as a structured loop.
> 
> Any tail call results in a special annotation in the state model. When
> this machine gets inserted into the appropriately named larger
> machine, the annotations are detected and result in appropriate
> epsilon -like transitions being added, linking back to the larger
> machines start state. At least, I think that would work.

Ah, I see. Yes I think that could work in Ragel. Indirect recursion 
could be made to work by traversing the machine definition stack upwards 
to search for currently active references "higher up" when the parse 
tree is interpreted.

> Equivalence would be tested as Ragel compiles the machine, and one of
> the two equivalent models would then be discarded. The idea is
> redundant definition with compile-time validation, not a run-time
> mechanism.

Yeah, that could also be made to work. Actions would pose an additional 
challenge, but I don't think they would prevent it from working. If 
you're serious about this talk to me off list and I can give you some 
pointers. The question is whether or not there would be enough of a 
benefit to justify working on it.

> I'm a little confused about user-defined embedding types, though - how
> would they be used?

I'm thinking like this;

embedding buffer_and_exec(m, a) { m >buf_clear $buf_append %a }

main = foo <-buffer_and_exec{ print buf; }

Regards,
  Adrian



More information about the ragel-users mailing list