Text.Parsing.Parser.Combinators
- Package
- purescript-parsing
- Repository
- purescript-contrib/purescript-parsing
Combinators for creating parsers.
Notes
A few of the known combinators from Parsec are missing in this module. That is because they have already been defined in other libraries.
Text.Parsec.many = Data.(Array|List).many
Text.Parsec.many1 = Data.(Array|List).some
Text.Parsec.(<|>) = Control.Alt.alt (<|>)
Because Strings are not Char Arrays in PureScript many
and some
on Char Parsers need to
be used in conjunction with Data.String.fromCharArray
to achieve "Parsec-like" results.
Text.Parsec.many (char 'x') <=> fromCharArray <$> Data.Array.many (char 'x')
#withErrorMessage Source
withErrorMessage :: forall a s m. Monad m => ParserT s m a -> String -> ParserT s m a
Provide an error message in the case of failure.
#(<?>) Source
Operator alias for Text.Parsing.Parser.Combinators.withErrorMessage (left-associative / precedence 3)
#asErrorMessage Source
asErrorMessage :: forall a s m. Monad m => String -> ParserT s m a -> ParserT s m a
Flipped (<?>)
.
#(<??>) Source
Operator alias for Text.Parsing.Parser.Combinators.asErrorMessage (left-associative / precedence 3)
#optionMaybe Source
optionMaybe :: forall a s m. Monad m => ParserT s m a -> ParserT s m (Maybe a)
pure Nothing
in the case where a parser fails without consuming input.
#tryRethrow Source
tryRethrow :: forall a s m. Monad m => ParserT s m a -> ParserT s m a
Like try
, but will reannotate the error location to the try
point.
#notFollowedBy Source
notFollowedBy :: forall m a s. Monad m => ParserT s m a -> ParserT s m Unit
Fail if the specified parser matches.