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

Text.Grampa.ContextFree.LeftRecursive

Synopsis

Documentation

data Fixed p g s a Source #

Instances

Instances details
(Alternative (p g s), Monad (p g s)) => Monad (Fixed p g s) Source # 
Instance details

Defined in Text.Grampa.ContextFree.LeftRecursive

Methods

(>>=) :: Fixed p g s a -> (a -> Fixed p g s b) -> Fixed p g s b #

(>>) :: Fixed p g s a -> Fixed p g s b -> Fixed p g s b #

return :: a -> Fixed p g s a #

Functor (p g s) => Functor (Fixed p g s) Source # 
Instance details

Defined in Text.Grampa.ContextFree.LeftRecursive

Methods

fmap :: (a -> b) -> Fixed p g s a -> Fixed p g s b #

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

Alternative (p g s) => Applicative (Fixed p g s) Source # 
Instance details

Defined in Text.Grampa.ContextFree.LeftRecursive

Methods

pure :: a -> Fixed p g s a #

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

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

(*>) :: Fixed p g s a -> Fixed p g s b -> Fixed p g s b #

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

Alternative (p g s) => Alternative (Fixed p g s) Source # 
Instance details

Defined in Text.Grampa.ContextFree.LeftRecursive

Methods

empty :: Fixed p g s a #

(<|>) :: Fixed p g s a -> Fixed p g s a -> Fixed p g s a #

some :: Fixed p g s a -> Fixed p g s [a] #

many :: Fixed p g s a -> Fixed p g s [a] #

MonadPlus (p g s) => MonadPlus (Fixed p g s) Source # 
Instance details

Defined in Text.Grampa.ContextFree.LeftRecursive

Methods

mzero :: Fixed p g s a #

mplus :: Fixed p g s a -> Fixed p g s a -> Fixed p g s a #

(InputParsing (Fixed p g s), DeterministicParsing (p g s)) => DeterministicParsing (Fixed p g s) Source # 
Instance details

Defined in Text.Grampa.ContextFree.LeftRecursive

Methods

(<<|>) :: Fixed p g s a -> Fixed p g s a -> Fixed p g s a #

takeOptional :: Fixed p g s a -> Fixed p g s (Maybe a) #

takeMany :: Fixed p g s a -> Fixed p g s [a] #

takeSome :: Fixed p g s a -> Fixed p g s [a] #

concatAll :: Monoid a => Fixed p g s a -> Fixed p g s a #

skipAll :: Fixed p g s a -> Fixed p g s () #

(LeftReductive s, FactorialMonoid s, InputParsing (p g s), ParserInput (p g s) ~ s) => InputParsing (Fixed p g s) Source # 
Instance details

Defined in Text.Grampa.ContextFree.LeftRecursive

Associated Types

type ParserInput (Fixed p g s) #

Methods

getInput :: Fixed p g s (ParserInput (Fixed p g s)) #

getSourcePos :: Fixed p g s Position #

anyToken :: Fixed p g s (ParserInput (Fixed p g s)) #

take :: Int -> Fixed p g s (ParserInput (Fixed p g s)) #

satisfy :: (ParserInput (Fixed p g s) -> Bool) -> Fixed p g s (ParserInput (Fixed p g s)) #

notSatisfy :: (ParserInput (Fixed p g s) -> Bool) -> Fixed p g s () #

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

string :: ParserInput (Fixed p g s) -> Fixed p g s (ParserInput (Fixed p g s)) #

takeWhile :: (ParserInput (Fixed p g s) -> Bool) -> Fixed p g s (ParserInput (Fixed p g s)) #

takeWhile1 :: (ParserInput (Fixed p g s) -> Bool) -> Fixed p g s (ParserInput (Fixed p g s)) #

(Show s, TextualMonoid s, InputCharParsing (p g s), ParserInput (p g s) ~ s) => InputCharParsing (Fixed p g s) Source # 
Instance details

Defined in Text.Grampa.ContextFree.LeftRecursive

Methods

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

notSatisfyChar :: (Char -> Bool) -> Fixed p g s () #

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

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

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

(LeftReductive s, FactorialMonoid s, ConsumedInputParsing (p g s), ParserInput (p g s) ~ s) => ConsumedInputParsing (Fixed p g s) Source # 
Instance details

Defined in Text.Grampa.ContextFree.LeftRecursive

Methods

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

(LookAheadParsing (p g s), InputParsing (Fixed p g s)) => LookAheadParsing (Fixed p g s) Source # 
Instance details

Defined in Text.Grampa.ContextFree.LeftRecursive

Methods

lookAhead :: Fixed p g s a -> Fixed p g s a #

(CharParsing (p g s), InputCharParsing (Fixed p g s), TextualMonoid s, s ~ ParserInput (Fixed p g s), Show s) => CharParsing (Fixed p g s) Source # 
Instance details

Defined in Text.Grampa.ContextFree.LeftRecursive

Methods

satisfy :: (Char -> Bool) -> Fixed p g s Char #

char :: Char -> Fixed p g s Char #

notChar :: Char -> Fixed p g s Char #

anyChar :: Fixed p g s Char #

string :: String -> Fixed p g s String #

text :: Text -> Fixed p g s Text #

(Parsing (p g s), InputParsing (Fixed p g s)) => Parsing (Fixed p g s) Source # 
Instance details

Defined in Text.Grampa.ContextFree.LeftRecursive

Methods

try :: Fixed p g s a -> Fixed p g s a #

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

skipMany :: Fixed p g s a -> Fixed p g s () #

skipSome :: Fixed p g s a -> Fixed p g s () #

unexpected :: String -> Fixed p g s a #

eof :: Fixed p g s () #

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

AmbiguousParsing (p g s) => AmbiguousParsing (Fixed p g s) Source # 
Instance details

Defined in Text.Grampa.ContextFree.LeftRecursive

Methods

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

(Eq s, LeftReductive s, FactorialMonoid s, Alternative (p g s), TailsParsing (p g s), GrammarConstraint (p g s) g, ParserGrammar (p g s) ~ g, Functor (ResultFunctor (p g s)), s ~ ParserInput (p g s), GrammarFunctor (p g s) ~ rl s, FallibleWithExpectations rl, AmbiguousAlternative (GrammarFunctor (p g s))) => GrammarParsing (Fixed p g s) Source # 
Instance details

Defined in Text.Grampa.ContextFree.LeftRecursive

Associated Types

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

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

Methods

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

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

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

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

recursive :: Fixed p g s a -> Fixed p g s a Source #

(Eq s, LeftReductive s, FactorialMonoid s, Alternative (p g s), TailsParsing (p g s), GrammarConstraint (p g s) g, ParserGrammar (p g s) ~ g, Functor (ResultFunctor (p g s)), s ~ ParserInput (p g s), GrammarFunctor (p g s) ~ rl s, FallibleWithExpectations rl, AmbiguousAlternative (GrammarFunctor (p g s))) => MultiParsing (Fixed p g s) 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 s) [])
Instance details

Defined in Text.Grampa.ContextFree.LeftRecursive

Associated Types

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

type GrammarConstraint (Fixed p g s) g Source #

Methods

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

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

(Alternative (p g s), Semigroup x) => Semigroup (Fixed p g s x) Source # 
Instance details

Defined in Text.Grampa.ContextFree.LeftRecursive

Methods

(<>) :: Fixed p g s x -> Fixed p g s x -> Fixed p g s x #

sconcat :: NonEmpty (Fixed p g s x) -> Fixed p g s x #

stimes :: Integral b => b -> Fixed p g s x -> Fixed p g s x #

(Alternative (p g s), Monoid x) => Monoid (Fixed p g s x) Source # 
Instance details

Defined in Text.Grampa.ContextFree.LeftRecursive

Methods

mempty :: Fixed p g s x #

mappend :: Fixed p g s x -> Fixed p g s x -> Fixed p g s x #

mconcat :: [Fixed p g s x] -> Fixed p g s x #

type ParserInput (Fixed p g s) Source # 
Instance details

Defined in Text.Grampa.ContextFree.LeftRecursive

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

Defined in Text.Grampa.ContextFree.LeftRecursive

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

Defined in Text.Grampa.ContextFree.LeftRecursive

type GrammarFunctor (Fixed p g s)
type ResultFunctor (Fixed p g s) Source # 
Instance details

Defined in Text.Grampa.ContextFree.LeftRecursive

type ResultFunctor (Fixed p g s) = ResultFunctor (p g s)
type GrammarConstraint (Fixed p g s) g' Source # 
Instance details

Defined in Text.Grampa.ContextFree.LeftRecursive

type GrammarConstraint (Fixed p g s) g' = (GrammarConstraint (p g s) g', g ~ g', Apply g, Distributive g, Traversable g)

data SeparatedParser p (g :: (* -> *) -> *) s a Source #

Constructors

FrontParser (p g s a) 
CycleParser 

Fields

BackParser 

Fields

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

Turns a backtracking PEG parser into a context-free parser

liftPositive :: p g s a -> Fixed p g s a Source #

Lifts a primitive positive parser (i.e., one that always consumes some input) into a left-recursive one

liftPure :: Alternative (p g s) => p g s a -> Fixed p g s a Source #

Lifts a primitive pure parser (i.e., one that consumes no input) into a left-recursive one

mapPrimitive :: (p g s a -> p g s a) -> Fixed p g s a -> Fixed p g s a Source #

parseSeparated :: forall p g rl s. (Apply g, Foldable g, Eq s, FactorialMonoid s, LeftReductive s, TailsParsing (p g s), GrammarConstraint (p g s) g, GrammarFunctor (p g s) ~ rl s, FallibleWithExpectations rl, s ~ ParserInput (p g s)) => g (SeparatedParser p g s) -> s -> [(s, g (GrammarFunctor (p g s)))] Source #

Parse the given input using a context-free grammar separated into two parts: the first specifying all the left-recursive productions, the second all others. The first function argument specifies the left-recursive dependencies among the grammar productions.

separated :: forall p g s. (Alternative (p g s), Apply g, Distributive g, Traversable g, AmbiguousAlternative (GrammarFunctor (p g s))) => g (Fixed p g s) -> g (SeparatedParser p g s) Source #