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

Text.Grampa.PEG.Packrat

Description

Packrat parser

Synopsis

Documentation

newtype Parser g s r Source #

Parser type for Parsing Expression Grammars that uses an improved packrat algorithm, with O(1) performance bounds but with worse constants and more memory consumption than the backtracking Parser. The parse function returns an input prefix parse paired with the remaining input suffix.

Constructors

Parser 

Fields

Instances

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

Defined in Text.Grampa.PEG.Packrat

Methods

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

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

return :: a -> Parser g s a #

Functor (Parser g s) Source # 
Instance details

Defined in Text.Grampa.PEG.Packrat

Methods

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

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

Applicative (Parser g s) Source # 
Instance details

Defined in Text.Grampa.PEG.Packrat

Methods

pure :: a -> Parser g s a #

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

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

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

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

Alternative (Parser g s) Source # 
Instance details

Defined in Text.Grampa.PEG.Packrat

Methods

empty :: Parser g s a #

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

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

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

MonadPlus (Parser g s) Source # 
Instance details

Defined in Text.Grampa.PEG.Packrat

Methods

mzero :: Parser g s a #

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

FactorialMonoid s => DeterministicParsing (Parser g s) Source #

Every PEG parser is deterministic all the time.

Instance details

Defined in Text.Grampa.PEG.Packrat

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.PEG.Packrat

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.PEG.Packrat

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

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

Defined in Text.Grampa.PEG.Packrat

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.PEG.Packrat

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 #

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

Defined in Text.Grampa.PEG.Packrat

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

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

Defined in Text.Grampa.PEG.Packrat

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 #

Packrat parser

parseComplete :: (Rank2.Functor g, FactorialMonoid s) =>
                 g (Packrat.Parser g s) -> s -> g (ParseResults s)
Instance details

Defined in Text.Grampa.PEG.Packrat

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.PEG.Packrat

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.PEG.Packrat

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.PEG.Packrat

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

Defined in Text.Grampa.PEG.Packrat

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

Defined in Text.Grampa.PEG.Packrat

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

Defined in Text.Grampa.PEG.Packrat

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

Defined in Text.Grampa.PEG.Packrat

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

data Result g s v Source #

Constructors

Parsed 

Fields

NoParse (FailureInfo s) 

Instances

Instances details
Functor (Result g s) Source # 
Instance details

Defined in Text.Grampa.PEG.Packrat

Methods

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

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

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

Defined in Text.Grampa.PEG.Packrat

Methods

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

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