grammatical-parsers-0.3.1: parsers that combine into grammars

Safe HaskellNone
LanguageHaskell2010

Text.Grampa.ContextFree.SortedMemoizing

Synopsis

Documentation

data ResultList g s r Source #

Constructors

ResultList ![ResultsOfLength g s r] !FailureInfo 

Instances

Functor (ResultList g s) Source # 

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 # 

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 # 

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 # 

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 # 

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 # 

Associated Types

type GrammarFunctor (Parser :: ((* -> *) -> *) -> * -> * -> *) :: ((* -> *) -> *) -> * -> * -> * 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 [])

Associated Types

type ResultFunctor (Parser :: ((* -> *) -> *) -> * -> * -> *) :: * -> * Source #

type GrammarConstraint (Parser :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) :: Constraint Source #

MonoidParsing (Parser g) Source # 

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 #

GrammarParsing (Fixed Parser) Source # 

Associated Types

type GrammarFunctor (Fixed Parser :: ((* -> *) -> *) -> * -> * -> *) :: ((* -> *) -> *) -> * -> * -> * Source #

MultiParsing (Fixed Parser) Source #

Parser of general context-free grammars, including left recursion.

parseComplete :: (Rank2.Apply g, Rank2.Traversable g, FactorialMonoid s) =>
                 g (LeftRecursive.'Fixed g s) -> s -> g (Compose ParseResults [])

Associated Types

type ResultFunctor (Fixed Parser :: ((* -> *) -> *) -> * -> * -> *) :: * -> * Source #

type GrammarConstraint (Fixed Parser :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) :: Constraint Source #

Monad (Parser g i) Source # 

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 # 

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 # 

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 # 

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 # 

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 # 

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 # 

Methods

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

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

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 # 

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 # 

Methods

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

MonoidParsing (Fixed Parser g) Source # 
Semigroup x => Semigroup (Parser g s x) Source # 

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 # 

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 #

(Lexical g, LexicalConstraint (Fixed Parser) g s, Show s, TextualMonoid s) => TokenParsing (Fixed Parser g s) # 

Methods

someSpace :: Fixed Parser g s () #

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

semi :: Fixed Parser g s Char #

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

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

AmbiguousParsing (Fixed Parser g s) Source # 

Methods

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

type GrammarFunctor Parser Source # 
type ResultFunctor Parser Source # 
type GrammarConstraint Parser g Source # 
type GrammarFunctor (Fixed Parser) Source # 
type ResultFunctor (Fixed Parser) Source # 
type GrammarConstraint (Fixed Parser) g Source # 

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