added new primitive combinator ‘hidden’

Added new primitive combinator ‘hidden p’ which hides “expected” tokens
in error message when parser ‘p’ fails.
This commit is contained in:
mrkkrp 2015-08-20 01:08:20 +06:00
parent fc5abbc7fc
commit 110859b9c2
3 changed files with 11 additions and 0 deletions

View File

@ -89,6 +89,9 @@
* Fixed bug with `notFollowedBy` always succeeded with parsers that don't
consume input, see #6.
* Added new primitive combinator `hidden p` which hides “expected” tokens in
error message when parser `p` fails.
* Added comprehensive QuickCheck test suite.
* Added benchmarks.

View File

@ -65,6 +65,7 @@ module Text.Megaparsec
, unexpected
, (<?>)
, label
, hidden
, try
, lookAhead
, notFollowedBy

View File

@ -31,6 +31,7 @@ module Text.Megaparsec.Prim
, unexpected
, (<?>)
, label
, hidden
, try
, lookAhead
, notFollowedBy
@ -467,6 +468,12 @@ label p l = ParsecT $ \s cok cerr eok eerr ->
eerr' err = eerr $ setErrorMessage (Expected l) err
in unParser p s cok' cerr eok' eerr'
-- | @hidden p@ behaves just like parser @p@, but it doesn't show any “expected”
-- tokens in error message when @p@ fails.
hidden :: ParsecT s u m a -> ParsecT s u m a
hidden p = label p ""
-- | The parser @try p@ behaves like parser @p@, except that it
-- pretends that it hasn't consumed any input when an error occurs.
--