[Haskell-cafe] Parsec: Help needed with simple parser

Albert Y. C. Lai trebla at vex.net
Mon Apr 9 22:42:46 EDT 2007

Joel Reymont wrote:
> My expression is x + 1 where x can be either "Close", or "Close[N]" or 
> "Close[N] of DataM where N and M are positive integers. What happens in 
> my case is that 1 + x parses fine but x + 1 doesn't. In fact, I would be 
> fine with parsing Close + such that it ignores the plus and returns the 
> parse.

Does "option" help? Like:

     string "Close"
     option () (bracketN >> option () ofDataM)

where bracketN parses [N], ofDataM parses " of DataM".

More information about the Haskell-Cafe mailing list