miso
Copyright(C) 2016-2025 David M. Johnson (@dmjio)
LicenseBSD3-style (see the file LICENSE)
MaintainerDavid M. Johnson <code@dmj.io>
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

Miso.Util.Parser

Description

 
Synopsis

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

Instances details
Alternative (ParserT r token []) Source # 
Instance details

Defined in Miso.Util.Parser

Methods

empty :: ParserT r token [] a #

(<|>) :: ParserT r token [] a -> ParserT r token [] a -> ParserT r token [] a #

some :: ParserT r token [] a -> ParserT r token [] [a] #

many :: ParserT r token [] a -> ParserT r token [] [a] #

Applicative (ParserT r token []) Source # 
Instance details

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 # 
Instance details

Defined in Miso.Util.Parser

Methods

fmap :: (a -> b) -> ParserT r token [] a -> ParserT r token [] b #

(<$) :: a -> ParserT r token [] b -> ParserT r token [] a #

Monad (ParserT r token []) Source # 
Instance details

Defined in Miso.Util.Parser

Methods

(>>=) :: ParserT r token [] a -> (a -> ParserT r token [] b) -> ParserT r token [] b #

(>>) :: ParserT r token [] a -> ParserT r token [] b -> ParserT r token [] b #

return :: a -> ParserT r token [] a #

MonadFail (ParserT r token []) Source # 
Instance details

Defined in Miso.Util.Parser

Methods

fail :: String -> ParserT r token [] a #

data ParseError a token Source #

A type for expressing failure during parsing.

Constructors

UnexpectedParse [token] 
LexicalError LexerError 
Ambiguous [(a, [token])] 
NoParses token 
EmptyStream 

Instances

Instances details
(Show a, Show token) => Show (ParseError a token) Source # 
Instance details

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 # 
Instance details

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.

peek :: Parser a a Source #

Views the next token without consuming input

token_ :: Eq token => token -> Parser token token Source #

Smart constructor for building a token parser combinator

errorOut :: errorToken -> ParserT r errorToken [] () Source #

Parser combinator that always fails

allTokens :: ParserT r a [] a Source #

Returns all input from a parser

modifyTokens :: (t -> t) -> ParserT r t [] () Source #

Modifies tokens

askParser :: ParserT r token [] r Source #

Retrieves read-only state from a Parser