On Mon, May 2, 2011 at 4:37 PM, Kaspar Schiess <[email protected]> wrote:

>
> To add a really not well thought out remark: Could this kind of code be
> eliminated through a single meta rule? Like one that says:
>
>        expression_of(term, [%w(&& ||), %w(* /), %w(+ -)])
>
> The expression_of method would take term and build a hierarchy of binary
> rules that encode precedence in PEG-style. It would be so much easier to
> read...


Sounds interesting... I considered doing this myself using a custom
function, but gave up because I didn't really know what I was doing, plus
the old way is sort of familiar looking. I've got my expression grammar down
to the usual rules and about 10 transformations....there's some slightly
hairy stuff to do with stitching chains of binary operators together
(especially in the presence of parentheses), but it works and is passing
tests.



> Left recursion elimination in the engine seems suddenly less
> elegant to me.
>

Ah yes, I was going to ask about the imminent  left-recursive parslet....

But maybe such a thing cannot be created for reasons not obvious to me
> right now. Anyone biting?


I can see 'expression_of' causing people to wonder why right-associative
operators aren't working, doing it by hand at least makes this reasonably
obvious. I skipped around the problem by not having any ;)

cheers

ant

Reply via email to