
12 Feb
2010
12 Feb
'10
4:30 p.m.
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.