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

Text.Grampa.ContextFree.SortedMemoizing

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 ResultList g s r Source #

Constructors

ResultList ![ResultsOfLength g s r] !(FailureInfo s) 

Instances

Instances details
FallibleWithExpectations (ResultList g) Source # 
Instance details

Defined in Text.Grampa.ContextFree.LeftRecursive

Functor (ResultList g s) Source # 
Instance details

Defined in Text.Grampa.Internal

Methods

fmap :: (a -> b) -> ResultList g s a -> ResultList g s b #

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

Applicative (ResultList g s) Source # 
Instance details

Defined in Text.Grampa.Internal

Methods

pure :: a -> ResultList g s a #

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

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

(*>) :: ResultList g s a -> ResultList g s b -> ResultList g s b #

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

Alternative (ResultList g s) Source # 
Instance details

Defined in Text.Grampa.Internal

Methods

empty :: ResultList g s a #

(<|>) :: ResultList g s a -> ResultList g s a -> ResultList g s a #

some :: ResultList g s a -> ResultList g s [a] #

many :: ResultList g s a -> ResultList g s [a] #

Show s => Show1 (ResultList g s) Source # 
Instance details

Defined in Text.Grampa.Internal

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> ResultList g s a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [ResultList g s a] -> ShowS #

(Show s, Show r) => Show (ResultList g s r) Source # 
Instance details

Defined in Text.Grampa.Internal

Methods

showsPrec :: Int -> ResultList g s r -> ShowS #

show :: ResultList g s r -> String #

showList :: [ResultList g s r] -> ShowS #

Semigroup (ResultList g s r) Source # 
Instance details

Defined in Text.Grampa.Internal

Methods

(<>) :: ResultList g s r -> ResultList g s r -> ResultList g s r #

sconcat :: NonEmpty (ResultList g s r) -> ResultList g s r #

stimes :: Integral b => b -> ResultList g s r -> ResultList g s r #

Monoid (ResultList g s r) Source # 
Instance details

Defined in Text.Grampa.Internal

Methods

mempty :: ResultList g s r #

mappend :: ResultList g s r -> ResultList g s r -> ResultList g s r #

mconcat :: [ResultList g s r] -> ResultList g s r #

newtype Parser g s r Source #

Parser for a context-free grammar with packrat-like sharing of parse results. It does not support left-recursive grammars.

Constructors

Parser 

Fields

Instances

Instances details
Monad (Parser g i) Source # 
Instance details

Defined in Text.Grampa.ContextFree.SortedMemoizing

Methods

(>>=) :: Parser g i a -> (a -> Parser g i b) -> Parser g i b #

(>>) :: Parser g i a -> Parser g i b -> Parser g i b #

return :: a -> Parser g i a #

Functor (Parser g i) Source # 
Instance details

Defined in Text.Grampa.ContextFree.SortedMemoizing

Methods

fmap :: (a -> b) -> Parser g i a -> Parser g i b #

(<$) :: a -> Parser g i b -> Parser g i a #

Applicative (Parser g i) Source # 
Instance details

Defined in Text.Grampa.ContextFree.SortedMemoizing

Methods

pure :: a -> Parser g i a #

(<*>) :: Parser g i (a -> b) -> Parser g i a -> Parser g i b #

liftA2 :: (a -> b -> c) -> Parser g i a -> Parser g i b -> Parser g i c #

(*>) :: Parser g i a -> Parser g i b -> Parser g i b #

(<*) :: Parser g i a -> Parser g i b -> Parser g i a #

Alternative (Parser g i) Source # 
Instance details

Defined in Text.Grampa.ContextFree.SortedMemoizing

Methods

empty :: Parser g i a #

(<|>) :: Parser g i a -> Parser g i a -> Parser g i a #

some :: Parser g i a -> Parser g i [a] #

many :: Parser g i a -> Parser g i [a] #

MonadPlus (Parser g s) Source # 
Instance details

Defined in Text.Grampa.ContextFree.SortedMemoizing

Methods

mzero :: Parser g s a #

mplus :: Parser g s a -> Parser g s a -> Parser g s a #

MonoidNull s => DeterministicParsing (Parser g s) Source # 
Instance details

Defined in Text.Grampa.ContextFree.SortedMemoizing

Methods

(<<|>) :: Parser g s a -> Parser g s a -> Parser g s a #

takeOptional :: Parser g s a -> Parser g s (Maybe a) #

takeMany :: Parser g s a -> Parser g s [a] #

takeSome :: Parser g s a -> Parser g s [a] #

concatAll :: Monoid a => Parser g s a -> Parser g s a #

skipAll :: Parser g s a -> Parser g s () #

(LeftReductive s, FactorialMonoid s) => InputParsing (Parser g s) Source # 
Instance details

Defined in Text.Grampa.ContextFree.SortedMemoizing

Associated Types

type ParserInput (Parser g s) #

Methods

getInput :: Parser g s (ParserInput (Parser g s)) #

getSourcePos :: Parser g s Position #

anyToken :: Parser g s (ParserInput (Parser g s)) #

take :: Int -> Parser g s (ParserInput (Parser g s)) #

satisfy :: (ParserInput (Parser g s) -> Bool) -> Parser g s (ParserInput (Parser g s)) #

notSatisfy :: (ParserInput (Parser g s) -> Bool) -> Parser g s () #

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

string :: ParserInput (Parser g s) -> Parser g s (ParserInput (Parser g s)) #

takeWhile :: (ParserInput (Parser g s) -> Bool) -> Parser g s (ParserInput (Parser g s)) #

takeWhile1 :: (ParserInput (Parser g s) -> Bool) -> Parser g s (ParserInput (Parser g s)) #

(Show s, TextualMonoid s) => InputCharParsing (Parser g s) Source # 
Instance details

Defined in Text.Grampa.ContextFree.SortedMemoizing

Methods

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

notSatisfyChar :: (Char -> Bool) -> Parser g s () #

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

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

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

(LeftReductive s, FactorialMonoid s) => ConsumedInputParsing (Parser g s) Source # 
Instance details

Defined in Text.Grampa.ContextFree.SortedMemoizing

Methods

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

MonoidNull s => LookAheadParsing (Parser g s) Source # 
Instance details

Defined in Text.Grampa.ContextFree.SortedMemoizing

Methods

lookAhead :: Parser g s a -> Parser g s a #

(Show s, TextualMonoid s) => CharParsing (Parser g s) Source # 
Instance details

Defined in Text.Grampa.ContextFree.SortedMemoizing

Methods

satisfy :: (Char -> Bool) -> Parser g s Char #

char :: Char -> Parser g s Char #

notChar :: Char -> Parser g s Char #

anyChar :: Parser g s Char #

string :: String -> Parser g s String #

text :: Text -> Parser g s Text #

MonoidNull s => Parsing (Parser g s) Source # 
Instance details

Defined in Text.Grampa.ContextFree.SortedMemoizing

Methods

try :: Parser g s a -> Parser g s a #

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

skipMany :: Parser g s a -> Parser g s () #

skipSome :: Parser g s a -> Parser g s () #

unexpected :: String -> Parser g s a #

eof :: Parser g s () #

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

AmbiguousParsing (Parser g s) Source # 
Instance details

Defined in Text.Grampa.ContextFree.SortedMemoizing

Methods

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

(Eq s, LeftReductive s, FactorialMonoid s) => GrammarParsing (Parser g s) Source # 
Instance details

Defined in Text.Grampa.ContextFree.SortedMemoizing

Associated Types

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

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

Methods

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

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

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

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

recursive :: Parser g s a -> Parser g s a Source #

(LeftReductive s, FactorialMonoid s) => MultiParsing (Parser 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

Associated Types

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

type GrammarConstraint (Parser g s) g Source #

Methods

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

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

Semigroup x => Semigroup (Parser g s x) Source # 
Instance details

Defined in Text.Grampa.ContextFree.SortedMemoizing

Methods

(<>) :: Parser g s x -> Parser g s x -> Parser g s x #

sconcat :: NonEmpty (Parser g s x) -> Parser g s x #

stimes :: Integral b => b -> Parser g s x -> Parser g s x #

Monoid x => Monoid (Parser g s x) Source # 
Instance details

Defined in Text.Grampa.ContextFree.SortedMemoizing

Methods

mempty :: Parser g s x #

mappend :: Parser g s x -> Parser g s x -> Parser g s x #

mconcat :: [Parser g s x] -> Parser g s x #

type ParserInput (Parser g s) Source # 
Instance details

Defined in Text.Grampa.ContextFree.SortedMemoizing

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

Defined in Text.Grampa.ContextFree.SortedMemoizing

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

Defined in Text.Grampa.ContextFree.SortedMemoizing

type ResultFunctor (Parser g s) Source # 
Instance details

Defined in Text.Grampa.ContextFree.SortedMemoizing

type GrammarConstraint (Parser g s) g' Source # 
Instance details

Defined in Text.Grampa.ContextFree.SortedMemoizing

type GrammarConstraint (Parser g s) g' = (g ~ g', Functor g)

longest :: Parser g s a -> Parser g [(s, g (ResultList 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 :: Parser g [(s, g (ResultList g s))] a -> Parser g s a Source #

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

terminalPEG :: Monoid s => Parser g s a -> Parser g s a Source #

Turns a backtracking PEG parser into a context-free parser