| Copyright | (C) 2016-2025 David M. Johnson (@dmjio) |
|---|---|
| License | BSD3-style (see the file LICENSE) |
| Maintainer | David M. Johnson <code@dmj.io> |
| Stability | experimental |
| Portability | non-portable |
| Safe Haskell | None |
| Language | Haskell2010 |
Miso.Util.Parser
Contents
Description
Synopsis
- type Parser token a = ParserT () [token] [] a
- newtype ParserT r token (m :: Type -> Type) a = Parser {
- runParserT :: r -> token -> m (a, token)
- data ParseError a token
- = UnexpectedParse [token]
- | LexicalError LexerError
- | Ambiguous [(a, [token])]
- | NoParses token
- | EmptyStream
- parse :: Parser token a -> [token] -> Either (ParseError a token) a
- satisfy :: (a -> Bool) -> ParserT r [a] [] a
- peek :: Parser a a
- token_ :: Eq token => token -> Parser token token
- errorOut :: errorToken -> ParserT r errorToken [] ()
- allTokens :: ParserT r a [] a
- modifyTokens :: (t -> t) -> ParserT r t [] ()
- askParser :: ParserT r token [] r
Types
type Parser token a = ParserT () [token] [] a Source #
Convenience synonym when defining parser combinators
newtype ParserT r token (m :: Type -> Type) a Source #
Core type for parsing
Constructors
| Parser | |
Fields
| |
Instances
| Alternative (ParserT r token []) Source # | |
| Applicative (ParserT r token []) Source # | |
Defined in Miso.Util.Parser Methods pure :: a -> ParserT r token [] a # (<*>) :: ParserT r token [] (a -> b) -> ParserT r token [] a -> ParserT r token [] b # liftA2 :: (a -> b -> c) -> ParserT r token [] a -> ParserT r token [] b -> ParserT r token [] c # (*>) :: ParserT r token [] a -> ParserT r token [] b -> ParserT r token [] b # (<*) :: ParserT r token [] a -> ParserT r token [] b -> ParserT r token [] a # | |
| Functor (ParserT r token []) Source # | |
| Monad (ParserT r token []) Source # | |
| MonadFail (ParserT r token []) Source # | |
data ParseError a token Source #
A type for expressing failure during parsing.
Constructors
| UnexpectedParse [token] | |
| LexicalError LexerError | |
| Ambiguous [(a, [token])] | |
| NoParses token | |
| EmptyStream |
Instances
| (Show a, Show token) => Show (ParseError a token) Source # | |
Defined in Miso.Util.Parser Methods showsPrec :: Int -> ParseError a token -> ShowS # show :: ParseError a token -> String # showList :: [ParseError a token] -> ShowS # | |
| (Eq a, Eq token) => Eq (ParseError a token) Source # | |
Defined in Miso.Util.Parser Methods (==) :: ParseError a token -> ParseError a token -> Bool # (/=) :: ParseError a token -> ParseError a token -> Bool # | |
Combinators
parse :: Parser token a -> [token] -> Either (ParseError a token) a Source #
Executes a parser against a series of tokens.
satisfy :: (a -> Bool) -> ParserT r [a] [] a Source #
Predicate combinator used as a base to construct other high-level parser combinators.
token_ :: Eq token => token -> Parser token token Source #
Smart constructor for building a token parser combinator
modifyTokens :: (t -> t) -> ParserT r t [] () Source #
Modifies tokens