New tests shows that I had wrong assumption about workings of this
particular function. This is not a problem, though, complete test-suite
will eliminate this sort of nuisance soon.
These functions are now re-exported from ‘Control.Applicative’
module. ‘many’ and ‘some’ are now part of ‘Alternative’ instance of
‘ParsecT’.
Note that these functions are re-exported only in ‘Text.MegaParsec’
module, but not in ‘Text.MegaParsec.Prim’ to avoid duplication of
floating doc-strings. Others internal modules now just casually import
‘Control.Applicative’ for their needs.
Note that ‘many1’ was renamed to ‘some’, the same is done for other
parsers that had ‘many1’ part in their names (for consistency).
Changed how numbers are parsed because they were parsed in a naïf and
hairy way. Added tests for #2 and #3 (in old Parsec project these are
number 35 and 39 respectively).
* Since Haskell report doesn't say anything about sign, I've made
‘integer’ and ‘float’ parse numbers without sign.
* Removed ‘natural’ parser, it's equal to new ‘integer’ now.
* Renamed ‘naturalOrFloat’ → ‘number’ — this doesn't parse sign too.
* Added new combinator ‘signed’ to parse all sorts of signed numbers.
* For the sake of convenience I've added ‘integer'’, ‘float'’, and
‘number'’ combinators that also can parse signed numbers out of box.
Example
Before:
Prelude Text.Parsec> parseTest (string "abcd") "abbe"
parse error at (line 1, column 1):
unexpected "b"
expecting "abcd"
After:
*Main> parseTest (string "abcd") "abbe"
parse error at (line 1, column 3):
unexpected "b"
expecting "cd"
Before this patch, 'b' was reported to be found at 1:1, which is clearly not the
case. After this patch, we correctly report the location of the wrong token, and
also report missing tokens starting from that position.
This fixes a regression introduced by:
Sun Feb 20 18:24:22 EET 2011 Roman Cheplyaka <roma@ro-che.info>
* Choose the longest match when merging error messages
The source of the regression is that parsec sometimes generates dummy (aka
"unknown") error messages when no actual error has occurred.
So, when merging errors, before simply looking at the positions we should check
if one of them is unknown and just ignore it.
Reported by Matthias Hörmann.