kschiess / parslet

A small PEG based parser library. See the Hacking page in the Wiki as well.
kschiess.github.com/parslet
MIT License
809 stars 95 forks source link

follow a different rule for each operand in an operator? #180

Closed igravious closed 7 years ago

igravious commented 7 years ago

I have

rule(:application) {
    infix_expression(function_or_argument, [str(' '), 1, :left]){ |l,o,r| { :app => {:l => l, :o => o, :r => r} } }
}

But what I actually want is for the function rule to be followed for the left hand side and the argument rule to be followed for the right.

Is there a simple way of doing this that I'm not seeing?

kschiess commented 7 years ago

Not that I know of. Is this really an infix expression? Maybe a more traditional parser would be appropriate here?

igravious commented 7 years ago

It's an infix expression in the lambda calculus. Concatenation via white-space is a left associative operator.

kschiess commented 7 years ago

Well then you seem to know it all. I suggest you ask on stack overflow, answers are really good there.