Make a parser that parses any number of values and then one extra value to combine in right-to-left (last-to-first) order.
Note: This can fail if pOper and pRight can consume same tokens. You'll have to make an ahead guard to prevent it from consuming the last token.
pOper
pRight
Use rightAssoc2 if the grammar has an explicit operator between values.
Implementation is based on ab and reduceRight.
A parser for each consecutive value. Result type is a transformation operation for the accumulator.
A parser for the last value, also defines the result type (accumulator).
Make a parser that parses any number of values and then one extra value to combine in right-to-left (last-to-first) order.
Note: This can fail if
pOper
andpRight
can consume same tokens. You'll have to make an ahead guard to prevent it from consuming the last token.Use rightAssoc2 if the grammar has an explicit operator between values.
Implementation is based on ab and reduceRight.