Safe Haskell | None |
---|---|
Language | Haskell2010 |
A context-free memoizing parser that can handle left-recursive grammars.
Synopsis
- data Fixed p g s a
- type Parser = Fixed Parser
- data SeparatedParser p (g :: (Type -> Type) -> Type) s a
- = FrontParser (p g s a)
- | CycleParser {
- cycleParser :: p g s a
- backParser :: p g s a
- appendResultsArrow :: ResultAppend p g s a
- dependencies :: Dependencies g
- | BackParser {
- backParser :: p g s a
- longest :: Fixed Parser g s a -> Fixed Parser g [(s, g (ResultList g s))] a
- peg :: Ord s => Fixed Parser g [(s, g (ResultList g s))] a -> Fixed Parser g s a
- terminalPEG :: (Monoid s, Ord s) => Fixed Parser g s a -> Fixed Parser g s a
- liftPositive :: p g s a -> Fixed p g s a
- liftPure :: Alternative (p g s) => p g s a -> Fixed p g s a
- mapPrimitive :: forall p g s a b. AmbiguityDecidable b => (p g s a -> p g s b) -> Fixed p g s a -> Fixed p g s b
- 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, FallibleResults rl, s ~ ParserInput (p g s)) => g (SeparatedParser p g s) -> s -> [(s, g (GrammarFunctor (p g s)))]
- 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)
Documentation
A transformer that adds left-recursive powers to a memoizing parser p
over grammar g
Instances
data SeparatedParser p (g :: (Type -> Type) -> Type) s a Source #
A type of parsers analyzed for their left-recursion class
FrontParser (p g s a) | a parser that doesn't start with any |
CycleParser | a left-recursive parser that may add to the set of parse results every time it's run |
| |
BackParser | a parser that depends on other non-terminals but is not left-recursive |
|
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 :: Ord s => 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, Ord 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 :: forall p g s a b. AmbiguityDecidable b => (p g s a -> p g s b) -> Fixed p g s a -> Fixed p g s b 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, FallibleResults 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 left-recursive and other 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 #
Analyze the grammar's production interdependencies and produce a SeparatedParser
from each production's parser.