grammatical-parsers-0.3.2: parsers that combine into grammars

Safe HaskellNone
LanguageHaskell2010

Text.Grampa.ContextFree.Memoizing

Synopsis

Documentation

data ResultList g s r Source #

Constructors

ResultList !(BinTree (ResultInfo g s r)) !FailureInfo 
Instances
Functor (ResultList g s) Source # 
Instance details

Defined in Text.Grampa.ContextFree.Memoizing

Methods

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

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

Show1 (ResultList g s) Source # 
Instance details

Defined in Text.Grampa.ContextFree.Memoizing

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 r => Show (ResultList g s r) Source # 
Instance details

Defined in Text.Grampa.ContextFree.Memoizing

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.ContextFree.Memoizing

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.ContextFree.Memoizing

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
GrammarParsing Parser Source # 
Instance details

Defined in Text.Grampa.ContextFree.Memoizing

Associated Types

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

MultiParsing Parser 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 [])
Instance details

Defined in Text.Grampa.ContextFree.Memoizing

MonoidParsing (Parser g) Source # 
Instance details

Defined in Text.Grampa.ContextFree.Memoizing

Methods

endOfInput :: FactorialMonoid s => Parser g s () Source #

getInput :: FactorialMonoid s => Parser g s s Source #

anyToken :: FactorialMonoid s => Parser g s s Source #

satisfy :: FactorialMonoid s => (s -> Bool) -> Parser g s s Source #

satisfyChar :: TextualMonoid s => (Char -> Bool) -> Parser g s Char Source #

satisfyCharInput :: TextualMonoid s => (Char -> Bool) -> Parser g s s Source #

notSatisfy :: FactorialMonoid s => (s -> Bool) -> Parser g s () Source #

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

scan :: FactorialMonoid t => s -> (s -> t -> Maybe s) -> Parser g t t Source #

scanChars :: TextualMonoid t => s -> (s -> Char -> Maybe s) -> Parser g t t Source #

string :: (FactorialMonoid s, LeftReductiveMonoid s, Show s) => s -> Parser g s s Source #

takeWhile :: FactorialMonoid s => (s -> Bool) -> Parser g s s Source #

takeWhile1 :: FactorialMonoid s => (s -> Bool) -> Parser g s s Source #

takeCharsWhile :: TextualMonoid s => (Char -> Bool) -> Parser g s s Source #

takeCharsWhile1 :: TextualMonoid s => (Char -> Bool) -> Parser g s s Source #

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

Monad (Parser g i) Source # 
Instance details

Defined in Text.Grampa.ContextFree.Memoizing

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 #

fail :: String -> Parser g i a #

Functor (Parser g i) Source # 
Instance details

Defined in Text.Grampa.ContextFree.Memoizing

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.Memoizing

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.Memoizing

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.Memoizing

Methods

mzero :: Parser g s a #

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

(Lexical g, LexicalConstraint Parser g s, Show s, TextualMonoid s) => TokenParsing (Parser g s) Source # 
Instance details

Defined in Text.Grampa.ContextFree.Memoizing

Methods

someSpace :: Parser g s () #

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

semi :: Parser g s Char #

highlight :: Highlight -> Parser g s a -> Parser g s a #

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

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

Defined in Text.Grampa.ContextFree.Memoizing

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.Memoizing

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.Memoizing

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 () #

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

Defined in Text.Grampa.ContextFree.Memoizing

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.Memoizing

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 GrammarFunctor Parser Source # 
Instance details

Defined in Text.Grampa.ContextFree.Memoizing

type ResultFunctor Parser Source # 
Instance details

Defined in Text.Grampa.ContextFree.Memoizing

type GrammarConstraint Parser g Source # 
Instance details

Defined in Text.Grampa.ContextFree.Memoizing

data BinTree a Source #

Constructors

Fork !(BinTree a) !(BinTree a) 
Leaf !a 
EmptyTree 
Instances
Functor BinTree Source # 
Instance details

Defined in Text.Grampa.Internal

Methods

fmap :: (a -> b) -> BinTree a -> BinTree b #

(<$) :: a -> BinTree b -> BinTree a #

Foldable BinTree Source # 
Instance details

Defined in Text.Grampa.Internal

Methods

fold :: Monoid m => BinTree m -> m #

foldMap :: Monoid m => (a -> m) -> BinTree a -> m #

foldr :: (a -> b -> b) -> b -> BinTree a -> b #

foldr' :: (a -> b -> b) -> b -> BinTree a -> b #

foldl :: (b -> a -> b) -> b -> BinTree a -> b #

foldl' :: (b -> a -> b) -> b -> BinTree a -> b #

foldr1 :: (a -> a -> a) -> BinTree a -> a #

foldl1 :: (a -> a -> a) -> BinTree a -> a #

toList :: BinTree a -> [a] #

null :: BinTree a -> Bool #

length :: BinTree a -> Int #

elem :: Eq a => a -> BinTree a -> Bool #

maximum :: Ord a => BinTree a -> a #

minimum :: Ord a => BinTree a -> a #

sum :: Num a => BinTree a -> a #

product :: Num a => BinTree a -> a #

Show a => Show (BinTree a) Source # 
Instance details

Defined in Text.Grampa.Internal

Methods

showsPrec :: Int -> BinTree a -> ShowS #

show :: BinTree a -> String #

showList :: [BinTree a] -> ShowS #

Semigroup (BinTree a) Source # 
Instance details

Defined in Text.Grampa.Internal

Methods

(<>) :: BinTree a -> BinTree a -> BinTree a #

sconcat :: NonEmpty (BinTree a) -> BinTree a #

stimes :: Integral b => b -> BinTree a -> BinTree a #

Monoid (BinTree a) Source # 
Instance details

Defined in Text.Grampa.Internal

Methods

mempty :: BinTree a #

mappend :: BinTree a -> BinTree a -> BinTree a #

mconcat :: [BinTree a] -> BinTree a #

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

reparseTails :: Functor g => g (Parser g s) -> [(s, g (ResultList g s))] -> [(s, g (ResultList g s))] Source #

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