[Haskell-cafe] Re: Parsec : Problems with operator precedence (solution)

Erik de Castro Lopo mle+cl at mega-nerd.com
Fri Jan 2 22:14:40 EST 2009

Benedikt Huber wrote:

> There is an easy, better solution, modifying the lexer:
>  > lexer = makeTokenParser $ emptyDef
>  >           { L.reservedOpNames = words "&& || & | ^" }
>  > reservedOp = P.reservedOp lexer
>  > identifier = P.identifier lexer
>  > ...
> I'd try to avoid 'try', if possible.

Hi Benedikt,

I did try that (reservedOpNames as a list of operators as strings)
but that interferred rather badly with another part of the parser
which handles raw inline XML like this (yes, utterly horrid):

     var xdata = <xml>sucks</xml> ;

Because I had the XML parsing working when I hit the operator precedence
problem I worked towards a solution that didn't break the XML rather
than do the right thing to fix the operator precedence and then have to
fix the XML part.

Erik de Castro Lopo
"how am I expected to quit smoking if I have to deal with NT
every day" -- Ben Raia

More information about the Haskell-Cafe mailing list