[Haskell-cafe] Re: Infix and postfix operators in Parsec

Christian Maeder Christian.Maeder at dfki.de
Fri Feb 12 11:54:49 EST 2010


It seems that the case of identical postfix and infix operators was not
considered. So I recommend to write something from scratch.

Cheers Christian

Xinyu Jiang schrieb:
> I'm writing a parser for a Haskell-style language, and when I need to
> use the same symbol for infix, prefix and postfix operators, the
> combinator "buildExpressionParser" seems not to work as intended. For
> example, in:
> 
> (1)x + y
> (2)x +
> (3)+ x
> 
> If I set the priority of the postfix version of "+" to be higher than
> the infix version, the parser cannot recognize (1), for it stops at the
> end of "x +". And if the priority of postfix "+" is lower, Parsec
> complains about (2) by returning an error message which expects
> something after "+".
> 
> Is there some way to get over this problem, and let me be able to still
> benifit from the expression mechanism in Parsec. Or should I write these
> stuff from scratch? Thanks.


More information about the Haskell-Cafe mailing list