mirror of
https://github.com/mrkkrp/megaparsec.git
synced 2024-11-24 03:52:07 +03:00
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:
parent
fc5abbc7fc
commit
110859b9c2
@ -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.
|
||||
|
@ -65,6 +65,7 @@ module Text.Megaparsec
|
||||
, unexpected
|
||||
, (<?>)
|
||||
, label
|
||||
, hidden
|
||||
, try
|
||||
, lookAhead
|
||||
, notFollowedBy
|
||||
|
@ -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.
|
||||
--
|
||||
|
Loading…
Reference in New Issue
Block a user