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

Erik de Castro Lopo mle+cl at mega-nerd.com
Mon Dec 29 12:07:36 EST 2008


Erik de Castro Lopo wrote:

>     binaryOp :: String -> (SourcePos -> a -> a -> a) -> E.Assoc -> E.Operator Char st a
>     binaryOp name con assoc =
>         E.Infix (reservedOp name >>
>             getPosition >>=
>             return . con) assoc

Replacing reservedOp above with:

    reservedOpNf :: String -> CharParser st ()
    reservedOpNf name = try (reservedOp name >> notFollowedBy (oneOf "|&="))

fixed the problem.

Cheers,
Erik
-- 
-----------------------------------------------------------------
Erik de Castro Lopo
-----------------------------------------------------------------
"If dolphins are so smart, why do they live in igloos?" -Eric Cartman


More information about the Haskell-Cafe mailing list