question about parsing integers and floats with Parsec

Jan Kort
Fri, 16 Aug 2002 16:29:36 +0200

"Harris, Andrew" wrote:
> Hi -
>         This isn't a pure "Haskell" question, but I'm trying to use the
> Parsec library to parse out space separated numbers, which could be integers
> or floats and either positive or negative.  I was using the "naturalOrFloat"
> lexeme parser from the ParsecToken module, until I realized that it doesn't
> seem to handle negative integers.  I've been poking with trying to pair the
> integer and float lexeme parsers with try() blocks, but I ain't no parsing
> expert and am not making good progress.

Hi Andrew,

I don't know much about Parsec, but "natural" means
positive integers only. Isn't there an "integerOrFloat" ?

As for the program in your other mail, "float" and
"integer" contain both positive and negative numbers,
so you shouldn't have to check for the minus sign.