grammatical-parsers-0.5: parsers that combine into grammars
Safe HaskellNone
LanguageHaskell2010

Text.Grampa.ContextFree.SortedMemoizing.Transformer

Synopsis

Documentation

data FailureInfo s Source #

Constructors

FailureInfo Int [Expected s] 

Instances

Instances details
Eq s => Eq (FailureInfo s) Source # 
Instance details

Defined in Text.Grampa.Internal

Show s => Show (FailureInfo s) Source # 
Instance details

Defined in Text.Grampa.Internal

Semigroup (FailureInfo s) Source # 
Instance details

Defined in Text.Grampa.Internal

Monoid (FailureInfo s) Source # 
Instance details

Defined in Text.Grampa.Internal

data ResultListT m g s r Source #

Constructors

ResultList 

Fields

Instances

Instances details
FallibleWithExpectations (ResultListT m g) Source # 
Instance details

Defined in Text.Grampa.ContextFree.LeftRecursive.Transformer

Functor m => Functor (ResultListT m g s) Source # 
Instance details

Defined in Text.Grampa.ContextFree.SortedMemoizing.Transformer

Methods

fmap :: (a -> b) -> ResultListT m g s a -> ResultListT m g s b #

(<$) :: a -> ResultListT m g s b -> ResultListT m g s a #

Applicative m => Applicative (ResultListT m g s) Source # 
Instance details

Defined in Text.Grampa.ContextFree.SortedMemoizing.Transformer

Methods

pure :: a -> ResultListT m g s a #

(<*>) :: ResultListT m g s (a -> b) -> ResultListT m g s a -> ResultListT m g s b #

liftA2 :: (a -> b -> c) -> ResultListT m g s a -> ResultListT m g s b -> ResultListT m g s c #

(*>) :: ResultListT m g s a -> ResultListT m g s b -> ResultListT m g s b #

(<*) :: ResultListT m g s a -> ResultListT m g s b -> ResultListT m g s a #

Applicative m => Alternative (ResultListT m g s) Source # 
Instance details

Defined in Text.Grampa.ContextFree.SortedMemoizing.Transformer

Methods

empty :: ResultListT m g s a #

(<|>) :: ResultListT m g s a -> ResultListT m g s a -> ResultListT m g s a #

some :: ResultListT m g s a -> ResultListT m g s [a] #

many :: ResultListT m g s a -> ResultListT m g s [a] #

Semigroup (ResultListT m g s r) Source # 
Instance details

Defined in Text.Grampa.ContextFree.SortedMemoizing.Transformer

Methods

(<>) :: ResultListT m g s r -> ResultListT m g s r -> ResultListT m g s r #

sconcat :: NonEmpty (ResultListT m g s r) -> ResultListT m g s r #

stimes :: Integral b => b -> ResultListT m g s r -> ResultListT m g s r #

Monoid (ResultListT m g s r) Source # 
Instance details

Defined in Text.Grampa.ContextFree.SortedMemoizing.Transformer

Methods

mempty :: ResultListT m g s r #

mappend :: ResultListT m g s r -> ResultListT m g s r -> ResultListT m g s r #

mconcat :: [ResultListT m g s r] -> ResultListT m g s r #

newtype ParserT m g s r Source #

Parser for a context-free grammar with packrat-like sharing that carries a monadic computation as part of the parse result.

Constructors

Parser 

Fields

Instances

Instances details
(Monad m, Traversable m) => Monad (ParserT m g s) Source # 
Instance details

Defined in Text.Grampa.ContextFree.SortedMemoizing.Transformer

Methods

(>>=) :: ParserT m g s a -> (a -> ParserT m g s b) -> ParserT m g s b #

(>>) :: ParserT m g s a -> ParserT m g s b -> ParserT m g s b #

return :: a -> ParserT m g s a #

Functor m => Functor (ParserT m g s) Source # 
Instance details

Defined in Text.Grampa.ContextFree.SortedMemoizing.Transformer

Methods

fmap :: (a -> b) -> ParserT m g s a -> ParserT m g s b #

(<$) :: a -> ParserT m g s b -> ParserT m g s a #

Applicative m => Applicative (ParserT m g s) Source # 
Instance details

Defined in Text.Grampa.ContextFree.SortedMemoizing.Transformer

Methods

pure :: a -> ParserT m g s a #

(<*>) :: ParserT m g s (a -> b) -> ParserT m g s a -> ParserT m g s b #

liftA2 :: (a -> b -> c) -> ParserT m g s a -> ParserT m g s b -> ParserT m g s c #

(*>) :: ParserT m g s a -> ParserT m g s b -> ParserT m g s b #

(<*) :: ParserT m g s a -> ParserT m g s b -> ParserT m g s a #

Applicative m => Alternative (ParserT m g s) Source # 
Instance details

Defined in Text.Grampa.ContextFree.SortedMemoizing.Transformer

Methods

empty :: ParserT m g s a #

(<|>) :: ParserT m g s a -> ParserT m g s a -> ParserT m g s a #

some :: ParserT m g s a -> ParserT m g s [a] #

many :: ParserT m g s a -> ParserT m g s [a] #

(Foldable m, Monad m, Traversable m) => MonadPlus (ParserT m g s) Source # 
Instance details

Defined in Text.Grampa.ContextFree.SortedMemoizing.Transformer

Methods

mzero :: ParserT m g s a #

mplus :: ParserT m g s a -> ParserT m g s a -> ParserT m g s a #

(Applicative m, MonoidNull s) => DeterministicParsing (ParserT m g s) Source # 
Instance details

Defined in Text.Grampa.ContextFree.SortedMemoizing.Transformer

Methods

(<<|>) :: ParserT m g s a -> ParserT m g s a -> ParserT m g s a #

takeOptional :: ParserT m g s a -> ParserT m g s (Maybe a) #

takeMany :: ParserT m g s a -> ParserT m g s [a] #

takeSome :: ParserT m g s a -> ParserT m g s [a] #

concatAll :: Monoid a => ParserT m g s a -> ParserT m g s a #

skipAll :: ParserT m g s a -> ParserT m g s () #

(Applicative m, LeftReductive s, FactorialMonoid s) => InputParsing (ParserT m g s) Source # 
Instance details

Defined in Text.Grampa.ContextFree.SortedMemoizing.Transformer

Associated Types

type ParserInput (ParserT m g s) #

Methods

getInput :: ParserT m g s (ParserInput (ParserT m g s)) #

getSourcePos :: ParserT m g s Position #

anyToken :: ParserT m g s (ParserInput (ParserT m g s)) #

take :: Int -> ParserT m g s (ParserInput (ParserT m g s)) #

satisfy :: (ParserInput (ParserT m g s) -> Bool) -> ParserT m g s (ParserInput (ParserT m g s)) #

notSatisfy :: (ParserInput (ParserT m g s) -> Bool) -> ParserT m g s () #

scan :: state -> (state -> ParserInput (ParserT m g s) -> Maybe state) -> ParserT m g s (ParserInput (ParserT m g s)) #

string :: ParserInput (ParserT m g s) -> ParserT m g s (ParserInput (ParserT m g s)) #

takeWhile :: (ParserInput (ParserT m g s) -> Bool) -> ParserT m g s (ParserInput (ParserT m g s)) #

takeWhile1 :: (ParserInput (ParserT m g s) -> Bool) -> ParserT m g s (ParserInput (ParserT m g s)) #

(Applicative m, Show s, TextualMonoid s) => InputCharParsing (ParserT m g s) Source # 
Instance details

Defined in Text.Grampa.ContextFree.SortedMemoizing.Transformer

Methods

satisfyCharInput :: (Char -> Bool) -> ParserT m g s (ParserInput (ParserT m g s)) #

notSatisfyChar :: (Char -> Bool) -> ParserT m g s () #

scanChars :: state -> (state -> Char -> Maybe state) -> ParserT m g s (ParserInput (ParserT m g s)) #

takeCharsWhile :: (Char -> Bool) -> ParserT m g s (ParserInput (ParserT m g s)) #

takeCharsWhile1 :: (Char -> Bool) -> ParserT m g s (ParserInput (ParserT m g s)) #

(Applicative m, LeftReductive s, FactorialMonoid s) => ConsumedInputParsing (ParserT m g s) Source # 
Instance details

Defined in Text.Grampa.ContextFree.SortedMemoizing.Transformer

Methods

match :: ParserT m g s a -> ParserT m g s (ParserInput (ParserT m g s), a) #

(Applicative m, MonoidNull s) => LookAheadParsing (ParserT m g s) Source # 
Instance details

Defined in Text.Grampa.ContextFree.SortedMemoizing.Transformer

Methods

lookAhead :: ParserT m g s a -> ParserT m g s a #

(Applicative m, Show s, TextualMonoid s) => CharParsing (ParserT m g s) Source # 
Instance details

Defined in Text.Grampa.ContextFree.SortedMemoizing.Transformer

Methods

satisfy :: (Char -> Bool) -> ParserT m g s Char #

char :: Char -> ParserT m g s Char #

notChar :: Char -> ParserT m g s Char #

anyChar :: ParserT m g s Char #

string :: String -> ParserT m g s String #

text :: Text -> ParserT m g s Text #

(Applicative m, MonoidNull s) => Parsing (ParserT m g s) Source # 
Instance details

Defined in Text.Grampa.ContextFree.SortedMemoizing.Transformer

Methods

try :: ParserT m g s a -> ParserT m g s a #

(<?>) :: ParserT m g s a -> String -> ParserT m g s a #

skipMany :: ParserT m g s a -> ParserT m g s () #

skipSome :: ParserT m g s a -> ParserT m g s () #

unexpected :: String -> ParserT m g s a #

eof :: ParserT m g s () #

notFollowedBy :: Show a => ParserT m g s a -> ParserT m g s () #

(Applicative m, Eq (m ())) => AmbiguousParsing (ParserT m g s) Source # 
Instance details

Defined in Text.Grampa.ContextFree.SortedMemoizing.Transformer

Methods

ambiguous :: ParserT m g s a -> ParserT m g s (Ambiguous a) Source #

(Applicative m, Eq s, LeftReductive s, FactorialMonoid s, Functor g) => GrammarParsing (ParserT m g s) Source # 
Instance details

Defined in Text.Grampa.ContextFree.SortedMemoizing.Transformer

Associated Types

type ParserGrammar (ParserT m g s) :: (Type -> Type) -> Type Source #

type GrammarFunctor (ParserT m g s) :: Type -> Type Source #

Methods

parsingResult :: ParserInput (ParserT m g s) -> GrammarFunctor (ParserT m g s) a -> ResultFunctor (ParserT m g s) (ParserInput (ParserT m g s), a) Source #

nonTerminal :: (g0 ~ ParserGrammar (ParserT m g s), GrammarConstraint (ParserT m g s) g0) => (g0 (GrammarFunctor (ParserT m g s)) -> GrammarFunctor (ParserT m g s) a) -> ParserT m g s a Source #

selfReferring :: (g0 ~ ParserGrammar (ParserT m g s), GrammarConstraint (ParserT m g s) g0, Distributive g0) => g0 (ParserT m g s) Source #

fixGrammar :: (g0 ~ ParserGrammar (ParserT m g s), GrammarConstraint (ParserT m g s) g0, Distributive g0) => (g0 (ParserT m g s) -> g0 (ParserT m g s)) -> g0 (ParserT m g s) Source #

recursive :: ParserT m g s a -> ParserT m g s a Source #

(Applicative m, LeftReductive s, FactorialMonoid s) => MultiParsing (ParserT m g s) Source #

Memoizing parser guarantees O(n²) performance for grammars with unambiguous productions, but provides no left recursion support.

parseComplete :: (Rank2.Functor g, FactorialMonoid s) =>
                 g (Memoizing.Parser g s) -> s -> g (Compose (ParseResults s) [])
Instance details

Defined in Text.Grampa.ContextFree.SortedMemoizing.Transformer

Associated Types

type ResultFunctor (ParserT m g s) :: Type -> Type Source #

type GrammarConstraint (ParserT m g s) g Source #

Methods

parseComplete :: (ParserInput (ParserT m g s) ~ s0, GrammarConstraint (ParserT m g s) g0, Eq s0, FactorialMonoid s0) => g0 (ParserT m g s) -> s0 -> g0 (ResultFunctor (ParserT m g s)) Source #

parsePrefix :: (ParserInput (ParserT m g s) ~ s0, GrammarConstraint (ParserT m g s) g0, Eq s0, FactorialMonoid s0) => g0 (ParserT m g s) -> s0 -> g0 (Compose (ResultFunctor (ParserT m g s)) ((,) s0)) Source #

(Applicative m, Semigroup x) => Semigroup (ParserT m g s x) Source # 
Instance details

Defined in Text.Grampa.ContextFree.SortedMemoizing.Transformer

Methods

(<>) :: ParserT m g s x -> ParserT m g s x -> ParserT m g s x #

sconcat :: NonEmpty (ParserT m g s x) -> ParserT m g s x #

stimes :: Integral b => b -> ParserT m g s x -> ParserT m g s x #

(Applicative m, Monoid x) => Monoid (ParserT m g s x) Source # 
Instance details

Defined in Text.Grampa.ContextFree.SortedMemoizing.Transformer

Methods

mempty :: ParserT m g s x #

mappend :: ParserT m g s x -> ParserT m g s x -> ParserT m g s x #

mconcat :: [ParserT m g s x] -> ParserT m g s x #

type ParserInput (ParserT m g s) Source # 
Instance details

Defined in Text.Grampa.ContextFree.SortedMemoizing.Transformer

type ParserInput (ParserT m g s) = s
type ParserGrammar (ParserT m g s) Source # 
Instance details

Defined in Text.Grampa.ContextFree.SortedMemoizing.Transformer

type ParserGrammar (ParserT m g s) = g
type GrammarFunctor (ParserT m g s) Source # 
Instance details

Defined in Text.Grampa.ContextFree.SortedMemoizing.Transformer

type GrammarFunctor (ParserT m g s) = ResultListT m g s
type ResultFunctor (ParserT m g s) Source # 
Instance details

Defined in Text.Grampa.ContextFree.SortedMemoizing.Transformer

type GrammarConstraint (ParserT m g s) g' Source # 
Instance details

Defined in Text.Grampa.ContextFree.SortedMemoizing.Transformer

type GrammarConstraint (ParserT m g s) g' = (g ~ g', Functor g)

(<<|>) :: DeterministicParsing m => m a -> m a -> m a infixl 3 #

Left-biased choice: if the left alternative succeeds, the right one is never tried.

lift :: m a -> ParserT m g s a Source #

Lift a parse-free computation into the parser.

tmap :: (m a -> m b) -> ParserT m g s a -> ParserT m g s b Source #

Modify the computation carried by the parser.

longest :: ParserT Identity g s a -> Parser g [(s, g (ResultListT Identity g s))] a Source #

Turns a context-free parser into a backtracking PEG parser that consumes the longest possible prefix of the list of input tails, opposite of peg

peg :: Applicative m => Parser g [(s, g (ResultListT m g s))] a -> ParserT m g s a Source #

Turns a backtracking PEG parser of the list of input tails into a context-free parser, opposite of longest

terminalPEG :: (Applicative m, Monoid s) => Parser g s a -> ParserT m g s a Source #

Turns a backtracking PEG parser into a context-free parser