Another interesting thing I have been thinking about is explicit
tail-call elimination through the raise children operator in order to
move my TPDL-like grammars closer to PEG grammars.

This would work well for me as a maintain my own production rule stack
on the heap and so for tail-recursion with the '^' raise children
operator I would simply stay in the same frame and restart the
application of the production (in a similar way to growing left
recursion). For non-recursive tail calls I would simply change the
current stack frame in place so that it's production information is
representative of the new call but its the tree that is rooted at the
production does not change.

This would be a major benefit as it would mean that having a deep tree
of children needing to be raised would have no penalty and it also
means that I have a nice one-to-one relationship with the PEG closure
operator, *.

Best Regards,

Peter Goodman,
http://ioreader.com
70 Winston Circle,
Montreal, Quebec
H9S 4X6



2009/6/11 Michaeljohn Clement <m...@mjclement.com>:
> Peter Goodman wrote:
>> I'm curious: do you do any form of reductions on the tree to derive out
>> semantically meaningful lists that would otherwise be defined through
>> left/right recursion? If so, is that a post-processing step that you apply?
>
> No, but I implemented repetition operators *, +, and {m,n} so I don't
> have many occurrences of repetition through recursion in my grammars.
>
> However, I've always found repetition through recursion elegant and I
> like the idea of removing unnecessary primitives from the language and
> reasoning about a reduced core.  I found the A ← a ^A notation quite
> nice in this regard and I know there have been places where I would
> have wanted to write something like it in a grammar to indicate that
> a rule has no semantic payload and only exists to group other rules
> or tidy up the grammar in some way or to express recursion.  Adding
> prefix operators like that to the rule names was something I hadn't
> considered so I'll give that some thought when I extend what I have.
>
>> I apologize for the direct email without cc to the list; I am
>> unfamiliar with mailing lists.
>
> Oh, no problem.  Happens all the time.  :-)
>
> Regards,
>
> --
> Michaeljohn Clement
> http://inimino.org/~inimino/blog/
>

_______________________________________________
PEG mailing list
PEG@lists.csail.mit.edu
https://lists.csail.mit.edu/mailman/listinfo/peg

Reply via email to