{-# LANGUAGE ConstraintKinds, CPP, FlexibleContexts, FlexibleInstances, GADTs, GeneralizedNewtypeDeriving, InstanceSigs,
RankNTypes, ScopedTypeVariables, StandaloneDeriving, TypeApplications, TypeFamilies, TypeOperators,
UndecidableInstances #-}
module Text.Grampa.Internal.LeftRecursive (Fixed(..), SeparatedParser(..),
autochain, asLeaf, liftPositive, liftPure, mapPrimitive,
parseSeparated, separated)
where
import Control.Applicative
import Control.Monad (Monad(..), MonadPlus(..), void)
#if MIN_VERSION_base(4,13,0)
import Control.Monad (MonadFail(fail))
#endif
import Control.Monad.Trans.State.Lazy (State, evalState)
import qualified Control.Monad.Trans.State.Lazy as State
import Data.Functor.Compose (Compose(..))
import Data.Kind (Type)
import Data.Maybe (isJust)
import Data.Semigroup (Semigroup(..))
import Data.Monoid (Monoid(mempty), All(..), Any(..))
import Data.Monoid.Null (MonoidNull(null))
import Data.Monoid.Factorial (FactorialMonoid)
import Data.Monoid.Textual (TextualMonoid)
import Data.Semigroup.Cancellative (LeftReductive)
import qualified Data.Monoid.Factorial as Factorial
import qualified Data.Monoid.Textual as Textual
import Data.String (fromString)
import Data.Type.Equality ((:~:)(Refl))
import Witherable (Filterable(mapMaybe))
import qualified Text.Parser.Char as Char
import Text.Parser.Char (CharParsing)
import Text.Parser.Combinators (Parsing(..))
import Text.Parser.LookAhead (LookAheadParsing(..))
import qualified Rank2
import Text.Grampa.Class (GrammarParsing(..), InputParsing(..), InputCharParsing(..), MultiParsing(..),
AmbiguousParsing(..), CommittedParsing(..), ConsumedInputParsing(..),
DeterministicParsing(..),
TailsParsing(parseTails, parseAllTails),
ParseResults, ParseFailure(..), FailureDescription(..), Pos)
import Text.Grampa.Internal (FallibleResults(..),
AmbiguousAlternative(ambiguousOr), AmbiguityDecidable(..), AmbiguityWitness(..),
ParserFlags (ParserFlags, nullable, dependsOn),
Dependencies (DynamicDependencies, StaticDependencies),
TraceableParsing(..))
import Text.Grampa.Internal.Storable (Storable1(reuse1), Storable11(reuse11, store11))
import Prelude hiding (cycle, null, span, take, takeWhile)
type ResultAppend p (g :: (Type -> Type) -> Type) s =
GrammarFunctor (p g s) Rank2.~> GrammarFunctor (p g s) Rank2.~> GrammarFunctor (p g s)
data Fixed p g s a =
Parser {
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete, forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct, forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0, forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1, forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
indirect :: p g s a,
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> ChoiceTree (Fixed p g s a)
choices :: ChoiceTree (Fixed p g s a),
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> Maybe (AmbiguityWitness a)
isAmbiguous :: Maybe (AmbiguityWitness a),
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants :: g (Const (ParserFlags g)) -> ParserFlags g}
| DirectParser {
complete, direct0, direct1 :: p g s a}
| PositiveDirectParser {
complete :: p g s a}
data ChoiceTree a =
Leaf a
| SymmetricChoice (ChoiceTree a) (ChoiceTree a)
| LeftBiasedChoice (ChoiceTree a) (ChoiceTree a)
deriving Int -> ChoiceTree a -> ShowS
forall a. Show a => Int -> ChoiceTree a -> ShowS
forall a. Show a => [ChoiceTree a] -> ShowS
forall a. Show a => ChoiceTree a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ChoiceTree a] -> ShowS
$cshowList :: forall a. Show a => [ChoiceTree a] -> ShowS
show :: ChoiceTree a -> String
$cshow :: forall a. Show a => ChoiceTree a -> String
showsPrec :: Int -> ChoiceTree a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> ChoiceTree a -> ShowS
Show
instance Functor ChoiceTree where
fmap :: forall a b. (a -> b) -> ChoiceTree a -> ChoiceTree b
fmap a -> b
f (Leaf a
a) = forall a. a -> ChoiceTree a
Leaf (a -> b
f a
a)
fmap a -> b
f (SymmetricChoice ChoiceTree a
a ChoiceTree a
b) = forall a. ChoiceTree a -> ChoiceTree a -> ChoiceTree a
SymmetricChoice (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f ChoiceTree a
a) (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f ChoiceTree a
b)
fmap a -> b
f (LeftBiasedChoice ChoiceTree a
a ChoiceTree a
b) = forall a. ChoiceTree a -> ChoiceTree a -> ChoiceTree a
LeftBiasedChoice (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f ChoiceTree a
a) (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f ChoiceTree a
b)
instance Foldable ChoiceTree where
foldMap :: forall m a. Monoid m => (a -> m) -> ChoiceTree a -> m
foldMap a -> m
f (Leaf a
a) = a -> m
f a
a
foldMap a -> m
f (SymmetricChoice ChoiceTree a
a ChoiceTree a
b) = forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap a -> m
f ChoiceTree a
a forall a. Semigroup a => a -> a -> a
<> forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap a -> m
f ChoiceTree a
b
foldMap a -> m
f (LeftBiasedChoice ChoiceTree a
a ChoiceTree a
b) = forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap a -> m
f ChoiceTree a
a forall a. Semigroup a => a -> a -> a
<> forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap a -> m
f ChoiceTree a
b
collapseChoices :: (Alternative p, DeterministicParsing p) => ChoiceTree (p a) -> p a
collapseChoices :: forall (p :: * -> *) a.
(Alternative p, DeterministicParsing p) =>
ChoiceTree (p a) -> p a
collapseChoices (SymmetricChoice ChoiceTree (p a)
p ChoiceTree (p a)
q) = forall (p :: * -> *) a.
(Alternative p, DeterministicParsing p) =>
ChoiceTree (p a) -> p a
collapseChoices ChoiceTree (p a)
p forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> forall (p :: * -> *) a.
(Alternative p, DeterministicParsing p) =>
ChoiceTree (p a) -> p a
collapseChoices ChoiceTree (p a)
q
collapseChoices (LeftBiasedChoice ChoiceTree (p a)
p ChoiceTree (p a)
q) = forall (p :: * -> *) a.
(Alternative p, DeterministicParsing p) =>
ChoiceTree (p a) -> p a
collapseChoices ChoiceTree (p a)
p forall (m :: * -> *) a. DeterministicParsing m => m a -> m a -> m a
<<|> forall (p :: * -> *) a.
(Alternative p, DeterministicParsing p) =>
ChoiceTree (p a) -> p a
collapseChoices ChoiceTree (p a)
q
collapseChoices (Leaf p a
p) = p a
p
data SeparatedParser p (g :: (Type -> Type) -> Type) s a =
FrontParser (p g s a)
| CycleParser {
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
SeparatedParser p g s a -> p g s a
cycleParser :: p g s a,
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
SeparatedParser p g s a -> p g s a
backParser :: p g s a,
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
SeparatedParser p g s a -> ResultAppend p g s a
appendResultsArrow :: ResultAppend p g s a,
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
SeparatedParser p g s a -> Dependencies g
dependencies :: Dependencies g}
| BackParser {
backParser :: p g s a}
newtype Union (g :: (Type -> Type) -> Type) = Union{forall (g :: (* -> *) -> *). Union g -> g (Const Bool)
getUnion :: g (Const Bool)}
instance (Rank2.Apply g, Rank2.Distributive g) => Semigroup (Union g) where
Union g (Const Bool)
g1 <> :: Union g -> Union g -> Union g
<> Union g (Const Bool)
g2 = forall (g :: (* -> *) -> *). g (Const Bool) -> Union g
Union (forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *)
(r :: k -> *).
Apply g =>
(forall (a :: k). p a -> q a -> r a) -> g p -> g q -> g r
Rank2.liftA2 forall x. Const Bool x -> Const Bool x -> Const Bool x
union g (Const Bool)
g1 g (Const Bool)
g2)
instance (Rank2.Apply g, Rank2.Distributive g) => Monoid (Union g) where
mempty :: Union g
mempty = forall (g :: (* -> *) -> *). g (Const Bool) -> Union g
Union (forall {k1} (g :: (k1 -> *) -> *) (m :: * -> *) (p :: k1 -> *)
(q :: k1 -> *).
(Distributive g, Functor m) =>
(forall (a :: k1). m (p a) -> q a) -> m (g p) -> g q
Rank2.cotraverse (forall {k} a (b :: k). a -> Const a b
Const forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall {k} a (b :: k). Const a b -> a
getConst) (forall {k} a (b :: k). a -> Const a b
Const Bool
False))
mappend :: Union g -> Union g -> Union g
mappend = forall a. Semigroup a => a -> a -> a
(<>)
asLeaf :: Fixed p g s a -> Fixed p g s a
asLeaf :: forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> Fixed p g s a
asLeaf p :: Fixed p g s a
p@Parser{} = Fixed p g s a
p'
where p' :: Fixed p g s a
p' = Fixed p g s a
p{choices :: ChoiceTree (Fixed p g s a)
choices= forall a. a -> ChoiceTree a
Leaf Fixed p g s a
p'}
asLeaf Fixed p g s a
p = Fixed p g s a
p
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
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
mapPrimitive p g s a -> p g s b
f p :: Fixed p g s a
p@PositiveDirectParser{} = PositiveDirectParser{complete :: p g s b
complete= p g s a -> p g s b
f (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p)}
mapPrimitive p g s a -> p g s b
f p :: Fixed p g s a
p@DirectParser{} = DirectParser{complete :: p g s b
complete= p g s a -> p g s b
f (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p),
direct0 :: p g s b
direct0= p g s a -> p g s b
f (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
p),
direct1 :: p g s b
direct1= p g s a -> p g s b
f (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
p)}
mapPrimitive p g s a -> p g s b
f p :: Fixed p g s a
p@Parser{} = forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> Fixed p g s a
asLeaf Parser{
complete :: p g s b
complete= p g s a -> p g s b
f (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p),
choices :: ChoiceTree (Fixed p g s b)
choices= forall a. HasCallStack => a
undefined,
isAmbiguous :: Maybe (AmbiguityWitness b)
isAmbiguous= forall a. AmbiguityDecidable a => Maybe (AmbiguityWitness a)
ambiguityWitness @b,
cyclicDescendants :: g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants Fixed p g s a
p,
indirect :: p g s b
indirect= p g s a -> p g s b
f (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
indirect Fixed p g s a
p),
direct :: p g s b
direct= p g s a -> p g s b
f (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct Fixed p g s a
p),
direct0 :: p g s b
direct0= p g s a -> p g s b
f (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
p),
direct1 :: p g s b
direct1= p g s a -> p g s b
f (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
p)}
general, general' :: (Rank2.Apply g, Alternative (p g s)) => Fixed p g s a -> Fixed p g s a
general :: forall (g :: (* -> *) -> *) (p :: ((* -> *) -> *) -> * -> * -> *) s
a.
(Apply g, Alternative (p g s)) =>
Fixed p g s a -> Fixed p g s a
general Fixed p g s a
p = Parser{
complete :: p g s a
complete= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p,
direct :: p g s a
direct = forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct Fixed p g s a
p',
direct0 :: p g s a
direct0= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
p',
direct1 :: p g s a
direct1= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
p',
indirect :: p g s a
indirect= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
indirect Fixed p g s a
p',
choices :: ChoiceTree (Fixed p g s a)
choices= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> ChoiceTree (Fixed p g s a)
choices Fixed p g s a
p',
isAmbiguous :: Maybe (AmbiguityWitness a)
isAmbiguous= case Fixed p g s a
p
of Parser{isAmbiguous :: forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> Maybe (AmbiguityWitness a)
isAmbiguous= Maybe (AmbiguityWitness a)
a} -> Maybe (AmbiguityWitness a)
a
Fixed p g s a
_ -> forall a. Maybe a
Nothing,
cyclicDescendants :: g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants Fixed p g s a
p'}
where p' :: Fixed p g s a
p' = forall (g :: (* -> *) -> *) (p :: ((* -> *) -> *) -> * -> * -> *) s
a.
(Apply g, Alternative (p g s)) =>
Fixed p g s a -> Fixed p g s a
general' Fixed p g s a
p
general' :: forall (g :: (* -> *) -> *) (p :: ((* -> *) -> *) -> * -> * -> *) s
a.
(Apply g, Alternative (p g s)) =>
Fixed p g s a -> Fixed p g s a
general' p :: Fixed p g s a
p@PositiveDirectParser{} = forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> Fixed p g s a
asLeaf Parser{
complete :: p g s a
complete= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p,
direct :: p g s a
direct = forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p,
direct0 :: p g s a
direct0= forall (f :: * -> *) a. Alternative f => f a
empty,
direct1 :: p g s a
direct1= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p,
indirect :: p g s a
indirect= forall (f :: * -> *) a. Alternative f => f a
empty,
choices :: ChoiceTree (Fixed p g s a)
choices= forall a. HasCallStack => a
undefined,
isAmbiguous :: Maybe (AmbiguityWitness a)
isAmbiguous= forall a. Maybe a
Nothing,
cyclicDescendants :: g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants= \g (Const (ParserFlags g))
cd-> forall (g :: (* -> *) -> *).
Bool -> Dependencies g -> ParserFlags g
ParserFlags Bool
False (forall (g :: (* -> *) -> *). g (Const Bool) -> Dependencies g
StaticDependencies forall a b. (a -> b) -> a -> b
$ forall a b. a -> b -> a
const (forall {k} a (b :: k). a -> Const a b
Const Bool
False) forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *).
Functor g =>
(forall (a :: k). p a -> q a) -> g p -> g q
Rank2.<$> g (Const (ParserFlags g))
cd)}
general' p :: Fixed p g s a
p@DirectParser{} = forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> Fixed p g s a
asLeaf Parser{
complete :: p g s a
complete= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p,
direct :: p g s a
direct = forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p,
direct0 :: p g s a
direct0= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
p,
direct1 :: p g s a
direct1= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
p,
indirect :: p g s a
indirect= forall (f :: * -> *) a. Alternative f => f a
empty,
choices :: ChoiceTree (Fixed p g s a)
choices= forall a. HasCallStack => a
undefined,
isAmbiguous :: Maybe (AmbiguityWitness a)
isAmbiguous= forall a. Maybe a
Nothing,
cyclicDescendants :: g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants= \g (Const (ParserFlags g))
cd-> forall (g :: (* -> *) -> *).
Bool -> Dependencies g -> ParserFlags g
ParserFlags Bool
True (forall (g :: (* -> *) -> *). g (Const Bool) -> Dependencies g
StaticDependencies forall a b. (a -> b) -> a -> b
$ forall a b. a -> b -> a
const (forall {k} a (b :: k). a -> Const a b
Const Bool
False) forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *).
Functor g =>
(forall (a :: k). p a -> q a) -> g p -> g q
Rank2.<$> g (Const (ParserFlags g))
cd)}
general' p :: Fixed p g s a
p@Parser{} = Fixed p g s a
p
type LeftRecParsing p g s f = (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), FallibleResults f,
Storable1 (GrammarFunctor (p g s)) (ParserFlags g),
Storable1 (GrammarFunctor (p g s)) Bool,
AmbiguousAlternative (GrammarFunctor (p g s)))
instance (Rank2.Apply g, GrammarFunctor (p g s) ~ f s, LeftRecParsing p g s f) => MultiParsing (Fixed p g s) where
type GrammarConstraint (Fixed p g s) g' = (GrammarConstraint (p g s) g', g ~ g',
Rank2.Apply g, Rank2.Distributive g, Rank2.Traversable g)
type ResultFunctor (Fixed p g s) = ResultFunctor (p g s)
parsePrefix :: forall s (g :: (* -> *) -> *).
(ParserInput (Fixed p g s) ~ s, GrammarConstraint (Fixed p g s) g,
Eq s, FactorialMonoid s) =>
g (Fixed p g s)
-> s -> g (Compose (ResultFunctor (Fixed p g s)) ((,) s))
parsePrefix g (Fixed p g s)
g s
input
| Just g (p g s)
directs <- forall {k} (g :: (k -> *) -> *) (m :: * -> *) (p :: k -> *)
(q :: k -> *).
(Traversable g, Applicative m) =>
(forall (a :: k). p a -> m (q a)) -> g p -> m (g q)
Rank2.traverse forall {p :: ((* -> *) -> *) -> * -> * -> *} {g :: (* -> *) -> *}
{s} {a}.
SeparatedParser p g s a -> Maybe (p g s a)
getDirect g (SeparatedParser p g s)
g' = forall (m :: * -> *) s (g :: (* -> *) -> *).
(MultiParsing m, ParserInput m ~ s, GrammarConstraint m g, Eq s,
FactorialMonoid s) =>
g m -> s -> g (Compose (ResultFunctor m) ((,) s))
parsePrefix g (p g s)
directs s
input
| Bool
otherwise = forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *).
Functor g =>
(forall (a :: k). p a -> q a) -> g p -> g q
Rank2.fmap (forall {k} {k1} (f :: k -> *) (g :: k1 -> k) (a :: k1).
f (g a) -> Compose f g a
Compose forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *) a.
GrammarParsing m =>
ParserInput m
-> GrammarFunctor m a -> ResultFunctor m (ParserInput m, a)
parsingResult @(p g s) s
input) (forall a b. (a, b) -> b
snd forall a b. (a -> b) -> a -> b
$ forall a. [a] -> a
head forall a b. (a -> b) -> a -> b
$ 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)))]
parseSeparated g (SeparatedParser p g s)
g' s
input)
where g' :: g (SeparatedParser p g s)
g' = 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)
separated g (Fixed p g s)
g
getDirect :: SeparatedParser p g s a -> Maybe (p g s a)
getDirect (FrontParser p g s a
p) = forall a. a -> Maybe a
Just p g s a
p
getDirect (BackParser p g s a
p) = forall a. a -> Maybe a
Just p g s a
p
getDirect CycleParser{} = forall a. Maybe a
Nothing
{-# INLINE parsePrefix #-}
parseComplete :: forall s (g :: (* -> *) -> *).
(ParserInput (Fixed p g s) ~ s, GrammarConstraint (Fixed p g s) g,
Eq s, FactorialMonoid s) =>
g (Fixed p g s) -> s -> g (ResultFunctor (Fixed p g s))
parseComplete g (Fixed p g s)
g s
input
| Just g (p g s)
directs <- forall {k} (g :: (k -> *) -> *) (m :: * -> *) (p :: k -> *)
(q :: k -> *).
(Traversable g, Applicative m) =>
(forall (a :: k). p a -> m (q a)) -> g p -> m (g q)
Rank2.traverse forall {p :: ((* -> *) -> *) -> * -> * -> *} {g :: (* -> *) -> *}
{s} {a}.
SeparatedParser p g s a -> Maybe (p g s a)
getDirect g (SeparatedParser p g s)
g' = forall (m :: * -> *) s (g :: (* -> *) -> *).
(MultiParsing m, ParserInput m ~ s, GrammarConstraint m g, Eq s,
FactorialMonoid s) =>
g m -> s -> g (ResultFunctor m)
parseComplete g (p g s)
directs s
input
| Bool
otherwise = forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *).
Functor g =>
(forall (a :: k). p a -> q a) -> g p -> g q
Rank2.fmap ((forall a b. (a, b) -> b
snd forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *) a.
GrammarParsing m =>
ParserInput m
-> GrammarFunctor m a -> ResultFunctor m (ParserInput m, a)
parsingResult @(p g s) s
input)
forall a b. (a -> b) -> a -> b
$ forall a b. (a, b) -> b
snd forall a b. (a -> b) -> a -> b
$ forall a. [a] -> a
head forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) (g :: (* -> *) -> *).
(TailsParsing m, GrammarConstraint m g, Functor g) =>
g m
-> [(ParserInput m, g (GrammarFunctor m))]
-> [(ParserInput m, g (GrammarFunctor m))]
parseAllTails g (p g s)
close forall a b. (a -> b) -> a -> b
$ 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)))]
parseSeparated g (SeparatedParser p g s)
g' s
input
where g' :: g (SeparatedParser p g s)
g' = 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)
separated g (Fixed p g s)
g
getDirect :: SeparatedParser p g s a -> Maybe (p g s a)
getDirect (FrontParser p g s a
p) = forall a. a -> Maybe a
Just p g s a
p
getDirect (BackParser p g s a
p) = forall a. a -> Maybe a
Just p g s a
p
getDirect CycleParser{} = forall a. Maybe a
Nothing
close :: g (p g s)
close :: g (p g s)
close = forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *).
Functor g =>
(forall (a :: k). p a -> q a) -> g p -> g q
Rank2.fmap (forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* forall (m :: * -> *). Parsing m => m ()
eof) forall (m :: * -> *) (g :: (* -> *) -> *).
(GrammarParsing m, g ~ ParserGrammar m, GrammarConstraint m g,
Distributive g) =>
g m
selfReferring
{-# INLINE parseComplete #-}
instance (Rank2.Apply g, GrammarFunctor (p g s) ~ f s, LeftRecParsing p g s f) => GrammarParsing (Fixed p g s) where
type ParserGrammar (Fixed p g s) = g
type GrammarFunctor (Fixed p g s) = GrammarFunctor (p g s)
parsingResult :: s -> GrammarFunctor (p g s) a -> ResultFunctor (p g s) (s, a)
parsingResult :: forall a.
s -> GrammarFunctor (p g s) a -> ResultFunctor (p g s) (s, a)
parsingResult s
s = forall (m :: * -> *) a.
GrammarParsing m =>
ParserInput m
-> GrammarFunctor m a -> ResultFunctor m (ParserInput m, a)
parsingResult @(p g s) s
s
nonTerminal :: (Rank2.Apply g, Rank2.Distributive g, Rank2.Traversable g) =>
(g (GrammarFunctor (p g s)) -> GrammarFunctor (p g s) a) -> Fixed p g s a
nonTerminal :: forall a.
(Apply g, Distributive g, Traversable g) =>
(g (GrammarFunctor (p g s)) -> GrammarFunctor (p g s) a)
-> Fixed p g s a
nonTerminal g (GrammarFunctor (p g s)) -> GrammarFunctor (p g s) a
f = forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> Fixed p g s a
asLeaf Parser{
complete :: p g s a
complete= p g s a
ind,
direct :: p g s a
direct= forall (f :: * -> *) a. Alternative f => f a
empty,
direct0 :: p g s a
direct0= forall (f :: * -> *) a. Alternative f => f a
empty,
direct1 :: p g s a
direct1= forall (f :: * -> *) a. Alternative f => f a
empty,
indirect :: p g s a
indirect= p g s a
ind,
choices :: ChoiceTree (Fixed p g s a)
choices= forall a. HasCallStack => a
undefined,
isAmbiguous :: Maybe (AmbiguityWitness a)
isAmbiguous= forall a. Maybe a
Nothing,
cyclicDescendants :: g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants= forall (s :: * -> *) a b. Storable1 s a => s b -> a
reuse1 forall b c a. (b -> c) -> (a -> b) -> a -> c
. g (GrammarFunctor (p g s)) -> GrammarFunctor (p g s) a
f forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *).
Functor g =>
(forall (a :: k). p a -> q a) -> g p -> g q
Rank2.fmap forall (s :: * -> *) (t :: * -> *) a b.
Storable11 s t =>
t a -> s b
store11 forall b c a. (b -> c) -> (a -> b) -> a -> c
. g (Const (ParserFlags g)) -> g (Const (ParserFlags g))
addSelf}
where ind :: p g s a
ind = forall (m :: * -> *) (g :: (* -> *) -> *) a.
(GrammarParsing m, g ~ ParserGrammar m, GrammarConstraint m g) =>
(g (GrammarFunctor m) -> GrammarFunctor m a) -> m a
nonTerminal g (GrammarFunctor (p g s)) -> GrammarFunctor (p g s) a
f
addSelf :: g (Const (ParserFlags g)) -> g (Const (ParserFlags g))
addSelf g (Const (ParserFlags g))
g = forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *)
(r :: k -> *).
Apply g =>
(forall (a :: k). p a -> q a -> r a) -> g p -> g q -> g r
Rank2.liftA2 forall b.
Const (g (Const Bool)) b
-> Const (ParserFlags g) b -> Const (ParserFlags g) b
adjust forall (g :: (* -> *) -> *).
(Distributive g, Traversable g) =>
g (Const (g (Const Bool)))
bits g (Const (ParserFlags g))
g
adjust :: forall b. Const (g (Const Bool)) b -> Const (ParserFlags g) b -> Const (ParserFlags g) b
adjust :: forall b.
Const (g (Const Bool)) b
-> Const (ParserFlags g) b -> Const (ParserFlags g) b
adjust (Const g (Const Bool)
bit) (Const (ParserFlags Bool
n (StaticDependencies g (Const Bool)
d))) =
forall {k} a (b :: k). a -> Const a b
Const ParserFlags{
nullable :: Bool
nullable= Bool
n,
dependsOn :: Dependencies g
dependsOn= forall (g :: (* -> *) -> *). g (Const Bool) -> Dependencies g
StaticDependencies (forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *)
(r :: k -> *).
Apply g =>
(forall (a :: k). p a -> q a -> r a) -> g p -> g q -> g r
Rank2.liftA2 forall x. Const Bool x -> Const Bool x -> Const Bool x
union g (Const Bool)
bit g (Const Bool)
d)}
adjust Const (g (Const Bool)) b
_ flags :: Const (ParserFlags g) b
flags@(Const (ParserFlags Bool
_ Dependencies g
DynamicDependencies)) = Const (ParserFlags g) b
flags
{-# INLINE nonTerminal #-}
recursive :: forall a. Fixed p g s a -> Fixed p g s a
recursive = forall (g :: (* -> *) -> *) (p :: ((* -> *) -> *) -> * -> * -> *) s
a.
(Apply g, Alternative (p g s)) =>
Fixed p g s a -> Fixed p g s a
general
chainRecursive :: forall (g :: (* -> *) -> *) (f :: * -> *) a.
(g ~ ParserGrammar (Fixed p g s), f ~ GrammarFunctor (Fixed p g s),
GrammarConstraint (Fixed p g s) g) =>
(f a -> g f -> g f)
-> Fixed p g s a -> Fixed p g s a -> Fixed p g s a
chainRecursive = forall (g :: (* -> *) -> *) (p :: ((* -> *) -> *) -> * -> * -> *) s
(f :: * -> *) (rl :: * -> * -> *) a.
(Apply g, GrammarFunctor (p g s) ~ f, f ~ rl s,
LeftRecParsing p g s rl) =>
((f a -> g f -> g f) -> p g s a -> p g s a -> p g s a)
-> (f a -> g f -> g f)
-> Fixed p g s a
-> Fixed p g s a
-> Fixed p g s a
chainWith forall (m :: * -> *) (g :: (* -> *) -> *) (f :: * -> *) a.
(GrammarParsing m, g ~ ParserGrammar m, f ~ GrammarFunctor m,
GrammarConstraint m g) =>
(f a -> g f -> g f) -> m a -> m a -> m a
chainRecursive
{-# INLINABLE chainRecursive #-}
chainLongestRecursive :: forall (g :: (* -> *) -> *) (f :: * -> *) a.
(g ~ ParserGrammar (Fixed p g s), f ~ GrammarFunctor (Fixed p g s),
GrammarConstraint (Fixed p g s) g) =>
(f a -> g f -> g f)
-> Fixed p g s a -> Fixed p g s a -> Fixed p g s a
chainLongestRecursive = forall (g :: (* -> *) -> *) (p :: ((* -> *) -> *) -> * -> * -> *) s
(f :: * -> *) (rl :: * -> * -> *) a.
(Apply g, GrammarFunctor (p g s) ~ f, f ~ rl s,
LeftRecParsing p g s rl) =>
((f a -> g f -> g f) -> p g s a -> p g s a -> p g s a)
-> (f a -> g f -> g f)
-> Fixed p g s a
-> Fixed p g s a
-> Fixed p g s a
chainWith forall (m :: * -> *) (g :: (* -> *) -> *) (f :: * -> *) a.
(GrammarParsing m, g ~ ParserGrammar m, f ~ GrammarFunctor m,
GrammarConstraint m g) =>
(f a -> g f -> g f) -> m a -> m a -> m a
chainLongestRecursive
{-# INLINABLE chainLongestRecursive #-}
chainWith :: (Rank2.Apply g, GrammarFunctor (p g s) ~ f, f ~ rl s, LeftRecParsing p g s rl)
=> ((f a -> g f -> g f) -> p g s a -> p g s a -> p g s a)
-> ((f a -> g f -> g f) -> Fixed p g s a -> Fixed p g s a -> Fixed p g s a)
chainWith :: forall (g :: (* -> *) -> *) (p :: ((* -> *) -> *) -> * -> * -> *) s
(f :: * -> *) (rl :: * -> * -> *) a.
(Apply g, GrammarFunctor (p g s) ~ f, f ~ rl s,
LeftRecParsing p g s rl) =>
((f a -> g f -> g f) -> p g s a -> p g s a -> p g s a)
-> (f a -> g f -> g f)
-> Fixed p g s a
-> Fixed p g s a
-> Fixed p g s a
chainWith (f a -> g f -> g f) -> p g s a -> p g s a -> p g s a
f f a -> g f -> g f
assign = Fixed p g s a -> Fixed p g s a -> Fixed p g s a
chain
where chain :: Fixed p g s a -> Fixed p g s a -> Fixed p g s a
chain Fixed p g s a
base recurse :: Fixed p g s a
recurse@Parser{} = forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> Fixed p g s a
asLeaf Parser{
complete :: p g s a
complete= (f a -> g f -> g f) -> p g s a -> p g s a -> p g s a
f f a -> g f -> g f
assign (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
base) (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
recurse),
direct :: p g s a
direct= (f a -> g f -> g f) -> p g s a -> p g s a -> p g s a
f f a -> g f -> g f
assign (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct Fixed p g s a
base) (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
recurse),
direct0 :: p g s a
direct0= (f a -> g f -> g f) -> p g s a -> p g s a -> p g s a
f f a -> g f -> g f
assign (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
base) (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
recurse),
direct1 :: p g s a
direct1= (f a -> g f -> g f) -> p g s a -> p g s a -> p g s a
f f a -> g f -> g f
assign (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
base) (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
recurse),
indirect :: p g s a
indirect= (f a -> g f -> g f) -> p g s a -> p g s a -> p g s a
f f a -> g f -> g f
assign (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
indirect Fixed p g s a
base) (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
recurse),
choices :: ChoiceTree (Fixed p g s a)
choices= forall a. HasCallStack => a
undefined,
isAmbiguous :: Maybe (AmbiguityWitness a)
isAmbiguous= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> Maybe (AmbiguityWitness a)
isAmbiguous Fixed p g s a
base forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> Maybe (AmbiguityWitness a)
isAmbiguous Fixed p g s a
recurse,
cyclicDescendants :: g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants= \g (Const (ParserFlags g))
deps-> let ParserFlags Bool
pn Dependencies g
pd = forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants Fixed p g s a
base g (Const (ParserFlags g))
deps
ParserFlags Bool
qn Dependencies g
qd = forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants Fixed p g s a
recurse g (Const (ParserFlags g))
deps
qd' :: Dependencies g
qd' = case Dependencies g
qd
of Dependencies g
DynamicDependencies -> forall (g :: (* -> *) -> *). Dependencies g
DynamicDependencies
StaticDependencies g (Const Bool)
g -> forall (g :: (* -> *) -> *). g (Const Bool) -> Dependencies g
StaticDependencies (g (Const Bool) -> g (Const Bool)
clearOwnDep g (Const Bool)
g)
in forall (g :: (* -> *) -> *).
Bool -> Dependencies g -> ParserFlags g
ParserFlags (Bool
pn Bool -> Bool -> Bool
&& Bool
qn) (forall (g :: (* -> *) -> *).
Apply g =>
Dependencies g -> Dependencies g -> Dependencies g
depUnion Dependencies g
pd Dependencies g
qd')}
chain Fixed p g s a
base Fixed p g s a
recurse = Fixed p g s a
recurse forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Fixed p g s a
base
clearOwnDep :: g (Const Bool) -> g (Const Bool)
clearOwnDep = forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *).
Functor g =>
(forall (a :: k). p a -> q a) -> g p -> g q
Rank2.fmap forall (s :: * -> *) (t :: * -> *) b a.
Storable11 s t =>
s b -> t a
reuse11 forall b c a. (b -> c) -> (a -> b) -> a -> c
. f a -> g f -> g f
assign (forall (s :: * -> *) (t :: * -> *) a b.
Storable11 s t =>
t a -> s b
store11 forall a b. (a -> b) -> a -> b
$ forall {k} a (b :: k). a -> Const a b
Const Bool
False) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *).
Functor g =>
(forall (a :: k). p a -> q a) -> g p -> g q
Rank2.fmap forall (s :: * -> *) (t :: * -> *) a b.
Storable11 s t =>
t a -> s b
store11
{-# INLINE chainWith #-}
bits :: forall (g :: (Type -> Type) -> Type). (Rank2.Distributive g, Rank2.Traversable g) => g (Const (g (Const Bool)))
bits :: forall (g :: (* -> *) -> *).
(Distributive g, Traversable g) =>
g (Const (g (Const Bool)))
bits = g (Const Int)
start seq :: forall a b. a -> b -> b
`seq` forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *).
Functor g =>
(forall (a :: k). p a -> q a) -> g p -> g q
Rank2.fmap forall a. Const Int a -> Const (g (Const Bool)) a
oneBit g (Const Int)
start
where start :: g (Const Int)
start = forall s a. State s a -> s -> a
evalState (forall {k} (g :: (k -> *) -> *) (m :: * -> *) (p :: k -> *)
(q :: k -> *).
(Traversable g, Applicative m) =>
(forall (a :: k). p a -> m (q a)) -> g p -> m (g q)
Rank2.traverse forall (f :: * -> *) a. f a -> State Int (Const Int a)
next (forall (g :: (* -> *) -> *) (f :: * -> *).
(Distributive g, Monad f) =>
f (g f) -> g f
Rank2.distributeJoin forall a. Maybe a
Nothing)) Int
0
oneBit :: Const Int a -> Const (g (Const Bool)) a
next :: f a -> State Int (Const Int a)
oneBit :: forall a. Const Int a -> Const (g (Const Bool)) a
oneBit (Const Int
i) = forall {k} a (b :: k). a -> Const a b
Const (forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *).
Functor g =>
(forall (a :: k). p a -> q a) -> g p -> g q
Rank2.fmap (forall {k} a (b :: k). a -> Const a b
Const forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int
i forall a. Eq a => a -> a -> Bool
==) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall {k} a (b :: k). Const a b -> a
getConst) g (Const Int)
start)
next :: forall (f :: * -> *) a. f a -> State Int (Const Int a)
next f a
_ = do {Int
i <- forall (m :: * -> *) s. Monad m => StateT s m s
State.get; let {i' :: Int
i' = forall a. Enum a => a -> a
succ Int
i}; seq :: forall a b. a -> b -> b
seq Int
i' (forall (m :: * -> *) s. Monad m => s -> StateT s m ()
State.put Int
i'); forall (m :: * -> *) a. Monad m => a -> m a
return (forall {k} a (b :: k). a -> Const a b
Const Int
i)}
instance Functor (p g s) => Functor (Fixed p g s) where
fmap :: forall a b. (a -> b) -> Fixed p g s a -> Fixed p g s b
fmap a -> b
f (PositiveDirectParser p g s a
p) = forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
p g s a -> Fixed p g s a
PositiveDirectParser (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f p g s a
p)
fmap a -> b
f p :: Fixed p g s a
p@DirectParser{} = DirectParser{
complete :: p g s b
complete= forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p),
direct0 :: p g s b
direct0= forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
p),
direct1 :: p g s b
direct1= forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
p)}
fmap a -> b
f p :: Fixed p g s a
p@Parser{} = Fixed p g s a
p{
complete :: p g s b
complete= forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p),
direct :: p g s b
direct= forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct Fixed p g s a
p),
direct0 :: p g s b
direct0= forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
p),
direct1 :: p g s b
direct1= forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
p),
indirect :: p g s b
indirect= forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
indirect Fixed p g s a
p),
choices :: ChoiceTree (Fixed p g s b)
choices= forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> ChoiceTree (Fixed p g s a)
choices Fixed p g s a
p,
isAmbiguous :: Maybe (AmbiguityWitness b)
isAmbiguous= forall a. Maybe a
Nothing}
{-# INLINABLE fmap #-}
instance (Rank2.Apply g, Alternative (p g s)) => Applicative (Fixed p g s) where
pure :: forall a. a -> Fixed p g s a
pure a
a = DirectParser{complete :: p g s a
complete= forall (f :: * -> *) a. Applicative f => a -> f a
pure a
a,
direct0 :: p g s a
direct0= forall (f :: * -> *) a. Applicative f => a -> f a
pure a
a,
direct1 :: p g s a
direct1= forall (f :: * -> *) a. Alternative f => f a
empty}
p :: Fixed p g s (a -> b)
p@PositiveDirectParser{} <*> :: forall a b. Fixed p g s (a -> b) -> Fixed p g s a -> Fixed p g s b
<*> Fixed p g s a
q = PositiveDirectParser{
complete :: p g s b
complete= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s (a -> b)
p forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
q}
p :: Fixed p g s (a -> b)
p@DirectParser{} <*> q :: Fixed p g s a
q@PositiveDirectParser{} = PositiveDirectParser{
complete :: p g s b
complete= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s (a -> b)
p forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
q}
p :: Fixed p g s (a -> b)
p@DirectParser{} <*> q :: Fixed p g s a
q@DirectParser{} = DirectParser{
complete :: p g s b
complete= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s (a -> b)
p forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
q,
direct0 :: p g s b
direct0= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s (a -> b)
p forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
q,
direct1 :: p g s b
direct1= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s (a -> b)
p forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
q forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s (a -> b)
p forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
q}
Fixed p g s (a -> b)
p <*> q :: Fixed p g s a
q@Parser{} = forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> Fixed p g s a
asLeaf Parser{
complete :: p g s b
complete= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s (a -> b)
p' forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
q,
direct :: p g s b
direct= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s (a -> b)
p' forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct Fixed p g s a
q forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s (a -> b)
p' forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
q,
direct0 :: p g s b
direct0= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s (a -> b)
p' forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
q,
direct1 :: p g s b
direct1= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s (a -> b)
p' forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
q forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s (a -> b)
p' forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
q,
indirect :: p g s b
indirect= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s (a -> b)
p' forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
indirect Fixed p g s a
q forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
indirect Fixed p g s (a -> b)
p' forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
q,
choices :: ChoiceTree (Fixed p g s b)
choices= forall a. HasCallStack => a
undefined,
isAmbiguous :: Maybe (AmbiguityWitness b)
isAmbiguous= forall a. Maybe a
Nothing,
cyclicDescendants :: g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants= \g (Const (ParserFlags g))
deps-> let
pcd :: ParserFlags g
pcd@(ParserFlags Bool
pn Dependencies g
pd) = forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants Fixed p g s (a -> b)
p' g (Const (ParserFlags g))
deps
ParserFlags Bool
qn Dependencies g
qd = forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants Fixed p g s a
q g (Const (ParserFlags g))
deps
in if Bool
pn
then forall (g :: (* -> *) -> *).
Bool -> Dependencies g -> ParserFlags g
ParserFlags Bool
qn (forall (g :: (* -> *) -> *).
Apply g =>
Dependencies g -> Dependencies g -> Dependencies g
depUnion Dependencies g
pd Dependencies g
qd)
else ParserFlags g
pcd}
where p' :: Fixed p g s (a -> b)
p'@Parser{} = forall (g :: (* -> *) -> *) (p :: ((* -> *) -> *) -> * -> * -> *) s
a.
(Apply g, Alternative (p g s)) =>
Fixed p g s a -> Fixed p g s a
general' Fixed p g s (a -> b)
p
Fixed p g s (a -> b)
p <*> Fixed p g s a
q = forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> Fixed p g s a
asLeaf Parser{
complete :: p g s b
complete= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s (a -> b)
p' forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
q',
direct :: p g s b
direct= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct Fixed p g s (a -> b)
p' forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
q',
direct0 :: p g s b
direct0= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s (a -> b)
p' forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
q',
direct1 :: p g s b
direct1= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s (a -> b)
p' forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
q' forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s (a -> b)
p' forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
q',
indirect :: p g s b
indirect= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
indirect Fixed p g s (a -> b)
p' forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
q',
choices :: ChoiceTree (Fixed p g s b)
choices= forall a. HasCallStack => a
undefined,
isAmbiguous :: Maybe (AmbiguityWitness b)
isAmbiguous= forall a. Maybe a
Nothing,
cyclicDescendants :: g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants= \g (Const (ParserFlags g))
deps-> let
pcd :: ParserFlags g
pcd@(ParserFlags Bool
pn Dependencies g
pd) = forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants Fixed p g s (a -> b)
p' g (Const (ParserFlags g))
deps
ParserFlags Bool
qn Dependencies g
qd = forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants Fixed p g s a
q' g (Const (ParserFlags g))
deps
in if Bool
pn
then forall (g :: (* -> *) -> *).
Bool -> Dependencies g -> ParserFlags g
ParserFlags Bool
qn (forall (g :: (* -> *) -> *).
Apply g =>
Dependencies g -> Dependencies g -> Dependencies g
depUnion Dependencies g
pd Dependencies g
qd)
else ParserFlags g
pcd}
where p' :: Fixed p g s (a -> b)
p'@Parser{} = forall (g :: (* -> *) -> *) (p :: ((* -> *) -> *) -> * -> * -> *) s
a.
(Apply g, Alternative (p g s)) =>
Fixed p g s a -> Fixed p g s a
general' Fixed p g s (a -> b)
p
q' :: Fixed p g s a
q'@Parser{} = forall (g :: (* -> *) -> *) (p :: ((* -> *) -> *) -> * -> * -> *) s
a.
(Apply g, Alternative (p g s)) =>
Fixed p g s a -> Fixed p g s a
general' Fixed p g s a
q
{-# INLINABLE pure #-}
{-# INLINABLE (<*>) #-}
instance (Rank2.Apply g, Alternative (p g s)) => Alternative (Fixed p g s) where
empty :: forall a. Fixed p g s a
empty = PositiveDirectParser{complete :: p g s a
complete= forall (f :: * -> *) a. Alternative f => f a
empty}
p :: Fixed p g s a
p@PositiveDirectParser{} <|> :: forall a. Fixed p g s a -> Fixed p g s a -> Fixed p g s a
<|> q :: Fixed p g s a
q@PositiveDirectParser{} = PositiveDirectParser{complete :: p g s a
complete= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
q}
p :: Fixed p g s a
p@PositiveDirectParser{} <|> q :: Fixed p g s a
q@DirectParser{} = DirectParser{
complete :: p g s a
complete= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
q,
direct0 :: p g s a
direct0 = forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
q,
direct1 :: p g s a
direct1= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
q}
p :: Fixed p g s a
p@DirectParser{} <|> q :: Fixed p g s a
q@PositiveDirectParser{} = DirectParser{
complete :: p g s a
complete= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
q,
direct0 :: p g s a
direct0 = forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
p,
direct1 :: p g s a
direct1= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
p forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
q}
p :: Fixed p g s a
p@DirectParser{} <|> q :: Fixed p g s a
q@DirectParser{} = DirectParser{
complete :: p g s a
complete= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
q,
direct0 :: p g s a
direct0 = forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
p forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
q,
direct1 :: p g s a
direct1= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
p forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
q}
Fixed p g s a
p <|> Fixed p g s a
q = Parser{complete :: p g s a
complete= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p' forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
q',
direct :: p g s a
direct= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct Fixed p g s a
p' forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct Fixed p g s a
q',
direct0 :: p g s a
direct0= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
p' forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
q',
direct1 :: p g s a
direct1= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
p' forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
q',
indirect :: p g s a
indirect= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
indirect Fixed p g s a
p' forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
indirect Fixed p g s a
q',
choices :: ChoiceTree (Fixed p g s a)
choices= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> ChoiceTree (Fixed p g s a)
choices Fixed p g s a
p' forall a. ChoiceTree a -> ChoiceTree a -> ChoiceTree a
`SymmetricChoice` forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> ChoiceTree (Fixed p g s a)
choices Fixed p g s a
q',
isAmbiguous :: Maybe (AmbiguityWitness a)
isAmbiguous= forall a. Maybe a
Nothing,
cyclicDescendants :: g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants= \g (Const (ParserFlags g))
deps-> let
ParserFlags Bool
pn Dependencies g
pd = forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants Fixed p g s a
p' g (Const (ParserFlags g))
deps
ParserFlags Bool
qn Dependencies g
qd = forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants Fixed p g s a
q' g (Const (ParserFlags g))
deps
in forall (g :: (* -> *) -> *).
Bool -> Dependencies g -> ParserFlags g
ParserFlags (Bool
pn Bool -> Bool -> Bool
|| Bool
qn) (forall (g :: (* -> *) -> *).
Apply g =>
Dependencies g -> Dependencies g -> Dependencies g
depUnion Dependencies g
pd Dependencies g
qd)}
where p' :: Fixed p g s a
p'@Parser{} = forall (g :: (* -> *) -> *) (p :: ((* -> *) -> *) -> * -> * -> *) s
a.
(Apply g, Alternative (p g s)) =>
Fixed p g s a -> Fixed p g s a
general Fixed p g s a
p
q' :: Fixed p g s a
q'@Parser{} = forall (g :: (* -> *) -> *) (p :: ((* -> *) -> *) -> * -> * -> *) s
a.
(Apply g, Alternative (p g s)) =>
Fixed p g s a -> Fixed p g s a
general Fixed p g s a
q
many :: forall a. Fixed p g s a -> Fixed p g s [a]
many (PositiveDirectParser p g s a
p) = DirectParser{
complete :: p g s [a]
complete= forall (f :: * -> *) a. Alternative f => f a -> f [a]
many p g s a
p,
direct0 :: p g s [a]
direct0= forall (f :: * -> *) a. Applicative f => a -> f a
pure [],
direct1 :: p g s [a]
direct1= forall (f :: * -> *) a. Alternative f => f a -> f [a]
some p g s a
p}
many p :: Fixed p g s a
p@DirectParser{} = DirectParser{
complete :: p g s [a]
complete= forall (f :: * -> *) a. Alternative f => f a -> f [a]
many (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p),
direct0 :: p g s [a]
direct0= forall (f :: * -> *) a. Applicative f => a -> f a
pure [] forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> (forall a. a -> [a] -> [a]
:[]) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
p,
direct1 :: p g s [a]
direct1= (:) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
p forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Alternative f => f a -> f [a]
many (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p)}
many p :: Fixed p g s a
p@Parser{} = forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> Fixed p g s a
asLeaf Parser{
complete :: p g s [a]
complete= p g s [a]
mcp,
direct :: p g s [a]
direct= p g s [a]
d0 forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> p g s [a]
d1,
direct0 :: p g s [a]
direct0= p g s [a]
d0,
direct1 :: p g s [a]
direct1= p g s [a]
d1,
indirect :: p g s [a]
indirect= (:) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
indirect Fixed p g s a
p forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> p g s [a]
mcp,
choices :: ChoiceTree (Fixed p g s [a])
choices= forall a. HasCallStack => a
undefined,
isAmbiguous :: Maybe (AmbiguityWitness [a])
isAmbiguous= forall a. Maybe a
Nothing,
cyclicDescendants :: g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants= \g (Const (ParserFlags g))
deps-> (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants Fixed p g s a
p g (Const (ParserFlags g))
deps){nullable :: Bool
nullable= Bool
True}}
where d0 :: p g s [a]
d0 = forall (f :: * -> *) a. Applicative f => a -> f a
pure [] forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> (forall a. a -> [a] -> [a]
:[]) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
p
d1 :: p g s [a]
d1 = (:) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
p forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> p g s [a]
mcp
mcp :: p g s [a]
mcp = forall (f :: * -> *) a. Alternative f => f a -> f [a]
many (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p)
some :: forall a. Fixed p g s a -> Fixed p g s [a]
some (PositiveDirectParser p g s a
p) = PositiveDirectParser{complete :: p g s [a]
complete= forall (f :: * -> *) a. Alternative f => f a -> f [a]
some p g s a
p}
some p :: Fixed p g s a
p@DirectParser{} = DirectParser{
complete :: p g s [a]
complete= forall (f :: * -> *) a. Alternative f => f a -> f [a]
some (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p),
direct0 :: p g s [a]
direct0= (forall a. a -> [a] -> [a]
:[]) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
p,
direct1 :: p g s [a]
direct1= (:) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
p forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Alternative f => f a -> f [a]
many (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p)}
some p :: Fixed p g s a
p@Parser{} = forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> Fixed p g s a
asLeaf Parser{
complete :: p g s [a]
complete= forall (f :: * -> *) a. Alternative f => f a -> f [a]
some (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p),
direct :: p g s [a]
direct= p g s [a]
d0 forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> p g s [a]
d1,
direct0 :: p g s [a]
direct0= p g s [a]
d0,
direct1 :: p g s [a]
direct1= p g s [a]
d1,
indirect :: p g s [a]
indirect= (:) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
indirect Fixed p g s a
p forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Alternative f => f a -> f [a]
many (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p),
choices :: ChoiceTree (Fixed p g s [a])
choices= forall a. HasCallStack => a
undefined,
isAmbiguous :: Maybe (AmbiguityWitness [a])
isAmbiguous= forall a. Maybe a
Nothing,
cyclicDescendants :: g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants Fixed p g s a
p}
where d0 :: p g s [a]
d0 = (forall a. a -> [a] -> [a]
:[]) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
p
d1 :: p g s [a]
d1= (:) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
p forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Alternative f => f a -> f [a]
many (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p)
{-# INLINABLE (<|>) #-}
{-# INLINABLE many #-}
{-# INLINABLE some #-}
instance Filterable (p g s) => Filterable (Fixed p g s) where
mapMaybe :: forall a b. (a -> Maybe b) -> Fixed p g s a -> Fixed p g s b
mapMaybe a -> Maybe b
f (PositiveDirectParser p g s a
p) = forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
p g s a -> Fixed p g s a
PositiveDirectParser (forall (f :: * -> *) a b.
Filterable f =>
(a -> Maybe b) -> f a -> f b
mapMaybe a -> Maybe b
f p g s a
p)
mapMaybe a -> Maybe b
f p :: Fixed p g s a
p@DirectParser{} = DirectParser{
complete :: p g s b
complete= forall (f :: * -> *) a b.
Filterable f =>
(a -> Maybe b) -> f a -> f b
mapMaybe a -> Maybe b
f (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p),
direct0 :: p g s b
direct0= forall (f :: * -> *) a b.
Filterable f =>
(a -> Maybe b) -> f a -> f b
mapMaybe a -> Maybe b
f (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
p),
direct1 :: p g s b
direct1= forall (f :: * -> *) a b.
Filterable f =>
(a -> Maybe b) -> f a -> f b
mapMaybe a -> Maybe b
f (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
p)}
mapMaybe a -> Maybe b
f p :: Fixed p g s a
p@Parser{} = Fixed p g s a
p{
complete :: p g s b
complete= forall (f :: * -> *) a b.
Filterable f =>
(a -> Maybe b) -> f a -> f b
mapMaybe a -> Maybe b
f (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p),
direct :: p g s b
direct= forall (f :: * -> *) a b.
Filterable f =>
(a -> Maybe b) -> f a -> f b
mapMaybe a -> Maybe b
f (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct Fixed p g s a
p),
direct0 :: p g s b
direct0= forall (f :: * -> *) a b.
Filterable f =>
(a -> Maybe b) -> f a -> f b
mapMaybe a -> Maybe b
f (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
p),
direct1 :: p g s b
direct1= forall (f :: * -> *) a b.
Filterable f =>
(a -> Maybe b) -> f a -> f b
mapMaybe a -> Maybe b
f (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
p),
indirect :: p g s b
indirect= forall (f :: * -> *) a b.
Filterable f =>
(a -> Maybe b) -> f a -> f b
mapMaybe a -> Maybe b
f (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
indirect Fixed p g s a
p),
choices :: ChoiceTree (Fixed p g s b)
choices= forall (f :: * -> *) a b.
Filterable f =>
(a -> Maybe b) -> f a -> f b
mapMaybe a -> Maybe b
f forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> ChoiceTree (Fixed p g s a)
choices Fixed p g s a
p,
isAmbiguous :: Maybe (AmbiguityWitness b)
isAmbiguous= forall a. Maybe a
Nothing}
{-# INLINABLE mapMaybe #-}
complement :: Const Bool x -> Const Bool x
complement :: forall x. Const Bool x -> Const Bool x
complement (Const Bool
a) = forall {k} a (b :: k). a -> Const a b
Const (Bool -> Bool
not Bool
a)
intersection :: Const Bool x -> Const Bool x -> Const Bool x
intersection :: forall x. Const Bool x -> Const Bool x -> Const Bool x
intersection (Const Bool
True) Const Bool x
x = Const Bool x
x
intersection (Const Bool
False) Const Bool x
_ = forall {k} a (b :: k). a -> Const a b
Const Bool
False
union :: Const Bool x -> Const Bool x -> Const Bool x
union :: forall x. Const Bool x -> Const Bool x -> Const Bool x
union (Const Bool
False) Const Bool x
x = Const Bool x
x
union (Const Bool
True) Const Bool x
_ = forall {k} a (b :: k). a -> Const a b
Const Bool
True
depUnion :: Rank2.Apply g => Dependencies g -> Dependencies g -> Dependencies g
depUnion :: forall (g :: (* -> *) -> *).
Apply g =>
Dependencies g -> Dependencies g -> Dependencies g
depUnion (StaticDependencies g (Const Bool)
d1) (StaticDependencies g (Const Bool)
d2) = forall (g :: (* -> *) -> *). g (Const Bool) -> Dependencies g
StaticDependencies (forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *)
(r :: k -> *).
Apply g =>
(forall (a :: k). p a -> q a -> r a) -> g p -> g q -> g r
Rank2.liftA2 forall x. Const Bool x -> Const Bool x -> Const Bool x
union g (Const Bool)
d1 g (Const Bool)
d2)
depUnion Dependencies g
_ Dependencies g
_ = forall (g :: (* -> *) -> *). Dependencies g
DynamicDependencies
instance (Rank2.Apply g, Alternative (p g s), Monad (p g s)) => Monad (Fixed p g s) where
return :: forall a. a -> Fixed p g s a
return = forall (f :: * -> *) a. Applicative f => a -> f a
pure
>> :: forall a b. Fixed p g s a -> Fixed p g s b -> Fixed p g s b
(>>) = forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
(*>)
PositiveDirectParser p g s a
p >>= :: forall a b. Fixed p g s a -> (a -> Fixed p g s b) -> Fixed p g s b
>>= a -> Fixed p g s b
cont = forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
p g s a -> Fixed p g s a
PositiveDirectParser (p g s a
p forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Fixed p g s b
cont)
p :: Fixed p g s a
p@DirectParser{} >>= a -> Fixed p g s b
cont = forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> Fixed p g s a
asLeaf Parser{
complete :: p g s b
complete= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Fixed p g s b
cont,
direct :: p g s b
direct= p g s b
d0 forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> p g s b
d1,
direct0 :: p g s b
direct0= p g s b
d0,
direct1 :: p g s b
direct1= p g s b
d1,
indirect :: p g s b
indirect= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
p forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
indirect forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (g :: (* -> *) -> *) (p :: ((* -> *) -> *) -> * -> * -> *) s
a.
(Apply g, Alternative (p g s)) =>
Fixed p g s a -> Fixed p g s a
general' forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Fixed p g s b
cont,
choices :: ChoiceTree (Fixed p g s b)
choices= forall a. HasCallStack => a
undefined,
isAmbiguous :: Maybe (AmbiguityWitness b)
isAmbiguous= forall a. Maybe a
Nothing,
cyclicDescendants :: g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants= forall a b. a -> b -> a
const (forall (g :: (* -> *) -> *).
Bool -> Dependencies g -> ParserFlags g
ParserFlags Bool
True forall (g :: (* -> *) -> *). Dependencies g
DynamicDependencies)}
where d0 :: p g s b
d0 = forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
p forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (g :: (* -> *) -> *) (p :: ((* -> *) -> *) -> * -> * -> *) s
a.
(Apply g, Alternative (p g s)) =>
Fixed p g s a -> Fixed p g s a
general' forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Fixed p g s b
cont
d1 :: p g s b
d1 = (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
p forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (g :: (* -> *) -> *) (p :: ((* -> *) -> *) -> * -> * -> *) s
a.
(Apply g, Alternative (p g s)) =>
Fixed p g s a -> Fixed p g s a
general' forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Fixed p g s b
cont) forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
p forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Fixed p g s b
cont)
Fixed p g s a
p >>= a -> Fixed p g s b
cont = forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> Fixed p g s a
asLeaf Parser{
complete :: p g s b
complete= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Fixed p g s b
cont,
direct :: p g s b
direct= p g s b
d0 forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> p g s b
d1,
direct0 :: p g s b
direct0= p g s b
d0,
direct1 :: p g s b
direct1= p g s b
d1,
indirect :: p g s b
indirect= (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
indirect Fixed p g s a
p forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Fixed p g s b
cont) forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
p forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
indirect forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (g :: (* -> *) -> *) (p :: ((* -> *) -> *) -> * -> * -> *) s
a.
(Apply g, Alternative (p g s)) =>
Fixed p g s a -> Fixed p g s a
general' forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Fixed p g s b
cont),
choices :: ChoiceTree (Fixed p g s b)
choices= forall a. HasCallStack => a
undefined,
isAmbiguous :: Maybe (AmbiguityWitness b)
isAmbiguous= forall a. Maybe a
Nothing,
cyclicDescendants :: g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants= \g (Const (ParserFlags g))
cd->
let pcd :: ParserFlags g
pcd@(ParserFlags Bool
pn Dependencies g
_) = forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants Fixed p g s a
p' g (Const (ParserFlags g))
cd
in if Bool
pn
then forall (g :: (* -> *) -> *).
Bool -> Dependencies g -> ParserFlags g
ParserFlags Bool
True forall (g :: (* -> *) -> *). Dependencies g
DynamicDependencies
else ParserFlags g
pcd}
where d0 :: p g s b
d0 = forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
p forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (g :: (* -> *) -> *) (p :: ((* -> *) -> *) -> * -> * -> *) s
a.
(Apply g, Alternative (p g s)) =>
Fixed p g s a -> Fixed p g s a
general' forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Fixed p g s b
cont
d1 :: p g s b
d1 = (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
p forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (g :: (* -> *) -> *) (p :: ((* -> *) -> *) -> * -> * -> *) s
a.
(Apply g, Alternative (p g s)) =>
Fixed p g s a -> Fixed p g s a
general' forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Fixed p g s b
cont) forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
p forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Fixed p g s b
cont)
p' :: Fixed p g s a
p'@Parser{} = forall (g :: (* -> *) -> *) (p :: ((* -> *) -> *) -> * -> * -> *) s
a.
(Apply g, Alternative (p g s)) =>
Fixed p g s a -> Fixed p g s a
general' Fixed p g s a
p
#if MIN_VERSION_base(4,13,0)
instance (Rank2.Apply g, Alternative (p g s), MonadFail (p g s)) => MonadFail (Fixed p g s) where
#endif
fail :: forall a. String -> Fixed p g s a
fail String
msg = PositiveDirectParser{complete :: p g s a
complete= forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
msg}
instance (Rank2.Apply g, MonadPlus (p g s)) => MonadPlus (Fixed p g s) where
mzero :: forall a. Fixed p g s a
mzero = forall (f :: * -> *) a. Alternative f => f a
empty
mplus :: forall a. Fixed p g s a -> Fixed p g s a -> Fixed p g s a
mplus = forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
(<|>)
instance (Rank2.Apply g, Alternative (p g s), Semigroup x) => Semigroup (Fixed p g s x) where
<> :: Fixed p g s x -> Fixed p g s x -> Fixed p g s x
(<>) = forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 forall a. Semigroup a => a -> a -> a
(<>)
instance (Rank2.Apply g, Alternative (p g s), Monoid x) => Monoid (Fixed p g s x) where
mempty :: Fixed p g s x
mempty = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a. Monoid a => a
mempty
mappend :: Fixed p g s x -> Fixed p g s x -> Fixed p g s x
mappend = forall a. Semigroup a => a -> a -> a
(<>)
primitive :: p g s a -> p g s a -> p g s a -> Fixed p g s a
primitive :: forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
p g s a -> p g s a -> p g s a -> Fixed p g s a
primitive p g s a
d0 p g s a
d1 p g s a
d = DirectParser{complete :: p g s a
complete= p g s a
d,
direct0 :: p g s a
direct0= p g s a
d0,
direct1 :: p g s a
direct1= p g s a
d1}
{-# INLINE primitive #-}
liftPositive :: p g s a -> Fixed p g s a
liftPositive :: forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
p g s a -> Fixed p g s a
liftPositive p g s a
p = PositiveDirectParser{complete :: p g s a
complete= p g s a
p}
{-# INLINE liftPositive #-}
liftPure :: Alternative (p g s) => p g s a -> Fixed p g s a
liftPure :: forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Alternative (p g s) =>
p g s a -> Fixed p g s a
liftPure p g s a
p = DirectParser{complete :: p g s a
complete= p g s a
p,
direct0 :: p g s a
direct0= p g s a
p,
direct1 :: p g s a
direct1= forall (f :: * -> *) a. Alternative f => f a
empty}
{-# INLINE liftPure #-}
instance (Rank2.Apply g, Parsing (p g s), InputParsing (Fixed p g s)) => Parsing (Fixed p g s) where
eof :: Fixed p g s ()
eof = forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
p g s a -> p g s a -> p g s a -> Fixed p g s a
primitive forall (m :: * -> *). Parsing m => m ()
eof forall (f :: * -> *) a. Alternative f => f a
empty forall (m :: * -> *). Parsing m => m ()
eof
try :: forall a. Fixed p g s a -> Fixed p g s a
try (PositiveDirectParser p g s a
p) = forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
p g s a -> Fixed p g s a
PositiveDirectParser (forall (m :: * -> *) a. Parsing m => m a -> m a
try p g s a
p)
try p :: Fixed p g s a
p@DirectParser{} = DirectParser{
complete :: p g s a
complete= forall (m :: * -> *) a. Parsing m => m a -> m a
try (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p),
direct0 :: p g s a
direct0= forall (m :: * -> *) a. Parsing m => m a -> m a
try (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
p),
direct1 :: p g s a
direct1= forall (m :: * -> *) a. Parsing m => m a -> m a
try (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
p)}
try p :: Fixed p g s a
p@Parser{} = forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> Fixed p g s a
asLeaf Fixed p g s a
p{
complete :: p g s a
complete= forall (m :: * -> *) a. Parsing m => m a -> m a
try (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p),
direct :: p g s a
direct= forall (m :: * -> *) a. Parsing m => m a -> m a
try (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct Fixed p g s a
p),
direct0 :: p g s a
direct0= forall (m :: * -> *) a. Parsing m => m a -> m a
try (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
p),
direct1 :: p g s a
direct1= forall (m :: * -> *) a. Parsing m => m a -> m a
try (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
p),
indirect :: p g s a
indirect= forall (m :: * -> *) a. Parsing m => m a -> m a
try (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
indirect Fixed p g s a
p)}
PositiveDirectParser p g s a
p <?> :: forall a. Fixed p g s a -> String -> Fixed p g s a
<?> String
msg = forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
p g s a -> Fixed p g s a
PositiveDirectParser (p g s a
p forall (m :: * -> *) a. Parsing m => m a -> String -> m a
<?> String
msg)
p :: Fixed p g s a
p@DirectParser{} <?> String
msg = DirectParser{
complete :: p g s a
complete= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p forall (m :: * -> *) a. Parsing m => m a -> String -> m a
<?> String
msg,
direct0 :: p g s a
direct0= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
p forall (m :: * -> *) a. Parsing m => m a -> String -> m a
<?> String
msg,
direct1 :: p g s a
direct1= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
p forall (m :: * -> *) a. Parsing m => m a -> String -> m a
<?> String
msg}
p :: Fixed p g s a
p@Parser{} <?> String
msg = forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> Fixed p g s a
asLeaf Fixed p g s a
p{
complete :: p g s a
complete= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p forall (m :: * -> *) a. Parsing m => m a -> String -> m a
<?> String
msg,
direct :: p g s a
direct= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct Fixed p g s a
p forall (m :: * -> *) a. Parsing m => m a -> String -> m a
<?> String
msg,
direct0 :: p g s a
direct0= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
p forall (m :: * -> *) a. Parsing m => m a -> String -> m a
<?> String
msg,
direct1 :: p g s a
direct1= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
p forall (m :: * -> *) a. Parsing m => m a -> String -> m a
<?> String
msg,
indirect :: p g s a
indirect= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
indirect Fixed p g s a
p forall (m :: * -> *) a. Parsing m => m a -> String -> m a
<?> String
msg}
notFollowedBy :: forall a. Show a => Fixed p g s a -> Fixed p g s ()
notFollowedBy p :: Fixed p g s a
p@PositiveDirectParser{} = DirectParser{
complete :: p g s ()
complete= forall (m :: * -> *) a. (Parsing m, Show a) => m a -> m ()
notFollowedBy (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p),
direct0 :: p g s ()
direct0= forall (m :: * -> *) a. (Parsing m, Show a) => m a -> m ()
notFollowedBy (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p),
direct1 :: p g s ()
direct1= forall (f :: * -> *) a. Alternative f => f a
empty}
notFollowedBy p :: Fixed p g s a
p@DirectParser{} = DirectParser{
complete :: p g s ()
complete= forall (m :: * -> *) a. (Parsing m, Show a) => m a -> m ()
notFollowedBy (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p),
direct0 :: p g s ()
direct0= forall (m :: * -> *) a. (Parsing m, Show a) => m a -> m ()
notFollowedBy (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p),
direct1 :: p g s ()
direct1= forall (f :: * -> *) a. Alternative f => f a
empty}
notFollowedBy p :: Fixed p g s a
p@Parser{} = forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> Fixed p g s a
asLeaf Parser{
complete :: p g s ()
complete= forall (m :: * -> *) a. (Parsing m, Show a) => m a -> m ()
notFollowedBy (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p),
direct :: p g s ()
direct= forall (m :: * -> *) a. (Parsing m, Show a) => m a -> m ()
notFollowedBy (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct Fixed p g s a
p),
direct0 :: p g s ()
direct0= forall (m :: * -> *) a. (Parsing m, Show a) => m a -> m ()
notFollowedBy (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct Fixed p g s a
p),
direct1 :: p g s ()
direct1= forall (f :: * -> *) a. Alternative f => f a
empty,
indirect :: p g s ()
indirect= forall (m :: * -> *) a. (Parsing m, Show a) => m a -> m ()
notFollowedBy (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
indirect Fixed p g s a
p),
choices :: ChoiceTree (Fixed p g s ())
choices= forall a. HasCallStack => a
undefined,
isAmbiguous :: Maybe (AmbiguityWitness ())
isAmbiguous= forall a. Maybe a
Nothing,
cyclicDescendants :: g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants= \g (Const (ParserFlags g))
deps-> (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants Fixed p g s a
p g (Const (ParserFlags g))
deps){nullable :: Bool
nullable= Bool
True}}
unexpected :: forall a. String -> Fixed p g s a
unexpected String
msg = forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
p g s a -> Fixed p g s a
liftPositive (forall (m :: * -> *) a. Parsing m => String -> m a
unexpected String
msg)
instance (Rank2.Apply g, InputParsing (Fixed p g s), DeterministicParsing (p g s)) =>
DeterministicParsing (Fixed p g s) where
p :: Fixed p g s a
p@DirectParser{} <<|> :: forall a. Fixed p g s a -> Fixed p g s a -> Fixed p g s a
<<|> q :: Fixed p g s a
q@PositiveDirectParser{} = DirectParser{
complete :: p g s a
complete= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p forall (m :: * -> *) a. DeterministicParsing m => m a -> m a -> m a
<<|> forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
q,
direct0 :: p g s a
direct0 = forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
p,
direct1 :: p g s a
direct1= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
p forall (m :: * -> *) a. DeterministicParsing m => m a -> m a -> m a
<<|> forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
q}
p :: Fixed p g s a
p@DirectParser{} <<|> q :: Fixed p g s a
q@DirectParser{} = DirectParser{
complete :: p g s a
complete= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p forall (m :: * -> *) a. DeterministicParsing m => m a -> m a -> m a
<<|> forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
q,
direct0 :: p g s a
direct0 = forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
p forall (m :: * -> *) a. DeterministicParsing m => m a -> m a -> m a
<<|> forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
q,
direct1 :: p g s a
direct1= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
p forall (m :: * -> *) a. DeterministicParsing m => m a -> m a -> m a
<<|> forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
q}
Fixed p g s a
p <<|> Fixed p g s a
q = Parser{complete :: p g s a
complete= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p' forall (m :: * -> *) a. DeterministicParsing m => m a -> m a -> m a
<<|> forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
q',
direct :: p g s a
direct= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct Fixed p g s a
p' forall (m :: * -> *) a. DeterministicParsing m => m a -> m a -> m a
<<|> forall (m :: * -> *) a. (Parsing m, Show a) => m a -> m ()
notFollowedBy (forall (f :: * -> *) a. Functor f => f a -> f ()
void forall a b. (a -> b) -> a -> b
$ forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p') forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct Fixed p g s a
q',
direct0 :: p g s a
direct0= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
p' forall (m :: * -> *) a. DeterministicParsing m => m a -> m a -> m a
<<|> forall (m :: * -> *) a. (Parsing m, Show a) => m a -> m ()
notFollowedBy (forall (f :: * -> *) a. Functor f => f a -> f ()
void forall a b. (a -> b) -> a -> b
$ forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p') forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
q',
direct1 :: p g s a
direct1= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
p' forall (m :: * -> *) a. DeterministicParsing m => m a -> m a -> m a
<<|> forall (m :: * -> *) a. (Parsing m, Show a) => m a -> m ()
notFollowedBy (forall (f :: * -> *) a. Functor f => f a -> f ()
void forall a b. (a -> b) -> a -> b
$ forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p') forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
q',
indirect :: p g s a
indirect= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
indirect Fixed p g s a
p' forall (m :: * -> *) a. DeterministicParsing m => m a -> m a -> m a
<<|> forall (m :: * -> *) a. (Parsing m, Show a) => m a -> m ()
notFollowedBy (forall (f :: * -> *) a. Functor f => f a -> f ()
void forall a b. (a -> b) -> a -> b
$ forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p') forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
indirect Fixed p g s a
q',
choices :: ChoiceTree (Fixed p g s a)
choices= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> ChoiceTree (Fixed p g s a)
choices Fixed p g s a
p' forall a. ChoiceTree a -> ChoiceTree a -> ChoiceTree a
`LeftBiasedChoice` forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> ChoiceTree (Fixed p g s a)
choices Fixed p g s a
q',
isAmbiguous :: Maybe (AmbiguityWitness a)
isAmbiguous= forall a. Maybe a
Nothing,
cyclicDescendants :: g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants= \g (Const (ParserFlags g))
deps-> let
ParserFlags Bool
pn Dependencies g
pd = forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants Fixed p g s a
p' g (Const (ParserFlags g))
deps
ParserFlags Bool
qn Dependencies g
qd = forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants Fixed p g s a
q' g (Const (ParserFlags g))
deps
in forall (g :: (* -> *) -> *).
Bool -> Dependencies g -> ParserFlags g
ParserFlags (Bool
pn Bool -> Bool -> Bool
|| Bool
qn) (forall (g :: (* -> *) -> *).
Apply g =>
Dependencies g -> Dependencies g -> Dependencies g
depUnion Dependencies g
pd Dependencies g
qd)}
where p' :: Fixed p g s a
p'@Parser{} = forall (g :: (* -> *) -> *) (p :: ((* -> *) -> *) -> * -> * -> *) s
a.
(Apply g, Alternative (p g s)) =>
Fixed p g s a -> Fixed p g s a
general Fixed p g s a
p
q' :: Fixed p g s a
q'@Parser{} = forall (g :: (* -> *) -> *) (p :: ((* -> *) -> *) -> * -> * -> *) s
a.
(Apply g, Alternative (p g s)) =>
Fixed p g s a -> Fixed p g s a
general Fixed p g s a
q
takeSome :: forall a. Fixed p g s a -> Fixed p g s [a]
takeSome Fixed p g s a
p = (:) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Fixed p g s a
p forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (m :: * -> *) a. DeterministicParsing m => m a -> m [a]
takeMany Fixed p g s a
p
takeMany :: forall a. Fixed p g s a -> Fixed p g s [a]
takeMany (PositiveDirectParser p g s a
p) = DirectParser{
complete :: p g s [a]
complete = forall (m :: * -> *) a. DeterministicParsing m => m a -> m [a]
takeMany p g s a
p,
direct0 :: p g s [a]
direct0= [] forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ forall (m :: * -> *) a. (Parsing m, Show a) => m a -> m ()
notFollowedBy (forall (f :: * -> *) a. Functor f => f a -> f ()
void p g s a
p),
direct1 :: p g s [a]
direct1= forall (m :: * -> *) a. DeterministicParsing m => m a -> m [a]
takeSome p g s a
p}
takeMany p :: Fixed p g s a
p@DirectParser{} = DirectParser{
complete :: p g s [a]
complete = forall (m :: * -> *) a. DeterministicParsing m => m a -> m [a]
takeMany (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p),
direct0 :: p g s [a]
direct0= (forall a. a -> [a] -> [a]
:[]) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
p forall (m :: * -> *) a. DeterministicParsing m => m a -> m a -> m a
<<|> [] forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ forall (m :: * -> *) a. (Parsing m, Show a) => m a -> m ()
notFollowedBy (forall (f :: * -> *) a. Functor f => f a -> f ()
void forall a b. (a -> b) -> a -> b
$ forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p),
direct1 :: p g s [a]
direct1= (:) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
p forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (m :: * -> *) a. DeterministicParsing m => m a -> m [a]
takeMany (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p)}
takeMany p :: Fixed p g s a
p@Parser{} = forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> Fixed p g s a
asLeaf Parser{
complete :: p g s [a]
complete= p g s [a]
mcp,
direct :: p g s [a]
direct= p g s [a]
d1 forall (m :: * -> *) a. DeterministicParsing m => m a -> m a -> m a
<<|> p g s [a]
d0,
direct0 :: p g s [a]
direct0= p g s [a]
d0,
direct1 :: p g s [a]
direct1= p g s [a]
d1,
indirect :: p g s [a]
indirect= (:) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
indirect Fixed p g s a
p forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> p g s [a]
mcp,
choices :: ChoiceTree (Fixed p g s [a])
choices= forall a. HasCallStack => a
undefined,
isAmbiguous :: Maybe (AmbiguityWitness [a])
isAmbiguous= forall a. Maybe a
Nothing,
cyclicDescendants :: g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants= \g (Const (ParserFlags g))
deps-> (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants Fixed p g s a
p g (Const (ParserFlags g))
deps){nullable :: Bool
nullable= Bool
True}}
where d0 :: p g s [a]
d0 = (forall a. a -> [a] -> [a]
:[]) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
p forall (m :: * -> *) a. DeterministicParsing m => m a -> m a -> m a
<<|> [] forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ forall (m :: * -> *) a. (Parsing m, Show a) => m a -> m ()
notFollowedBy (forall (f :: * -> *) a. Functor f => f a -> f ()
void forall a b. (a -> b) -> a -> b
$ forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct Fixed p g s a
p)
d1 :: p g s [a]
d1 = (:) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
p forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> p g s [a]
mcp
mcp :: p g s [a]
mcp = forall (m :: * -> *) a. DeterministicParsing m => m a -> m [a]
takeMany (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p)
skipAll :: forall a. Fixed p g s a -> Fixed p g s ()
skipAll (PositiveDirectParser p g s a
p) = DirectParser{
complete :: p g s ()
complete = forall (m :: * -> *) a. DeterministicParsing m => m a -> m ()
skipAll p g s a
p,
direct0 :: p g s ()
direct0= () forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ forall (m :: * -> *) a. (Parsing m, Show a) => m a -> m ()
notFollowedBy (forall (f :: * -> *) a. Functor f => f a -> f ()
void p g s a
p),
direct1 :: p g s ()
direct1= p g s a
p forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> forall (m :: * -> *) a. DeterministicParsing m => m a -> m ()
skipAll p g s a
p}
skipAll p :: Fixed p g s a
p@DirectParser{} = DirectParser{
complete :: p g s ()
complete = forall (m :: * -> *) a. DeterministicParsing m => m a -> m ()
skipAll (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p),
direct0 :: p g s ()
direct0= forall (f :: * -> *) a. Functor f => f a -> f ()
void (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
p) forall (m :: * -> *) a. DeterministicParsing m => m a -> m a -> m a
<<|> forall (m :: * -> *) a. (Parsing m, Show a) => m a -> m ()
notFollowedBy (forall (f :: * -> *) a. Functor f => f a -> f ()
void forall a b. (a -> b) -> a -> b
$ forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p),
direct1 :: p g s ()
direct1= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
p forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> forall (m :: * -> *) a. DeterministicParsing m => m a -> m ()
skipAll (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p)}
skipAll p :: Fixed p g s a
p@Parser{} = forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> Fixed p g s a
asLeaf Parser{
complete :: p g s ()
complete= p g s ()
mcp,
direct :: p g s ()
direct= p g s ()
d1 forall (m :: * -> *) a. DeterministicParsing m => m a -> m a -> m a
<<|> p g s ()
d0,
direct0 :: p g s ()
direct0= p g s ()
d0,
direct1 :: p g s ()
direct1= p g s ()
d1,
indirect :: p g s ()
indirect= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
indirect Fixed p g s a
p forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> p g s ()
mcp,
choices :: ChoiceTree (Fixed p g s ())
choices= forall a. HasCallStack => a
undefined,
isAmbiguous :: Maybe (AmbiguityWitness ())
isAmbiguous= forall a. Maybe a
Nothing,
cyclicDescendants :: g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants= \g (Const (ParserFlags g))
deps-> (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants Fixed p g s a
p g (Const (ParserFlags g))
deps){nullable :: Bool
nullable= Bool
True}}
where d0 :: p g s ()
d0 = () forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
p forall (m :: * -> *) a. DeterministicParsing m => m a -> m a -> m a
<<|> forall (m :: * -> *) a. (Parsing m, Show a) => m a -> m ()
notFollowedBy (forall (f :: * -> *) a. Functor f => f a -> f ()
void forall a b. (a -> b) -> a -> b
$ forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct Fixed p g s a
p)
d1 :: p g s ()
d1 = forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
p forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> p g s ()
mcp
mcp :: p g s ()
mcp = forall (m :: * -> *) a. DeterministicParsing m => m a -> m ()
skipAll (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p)
instance (Rank2.Apply g, CommittedParsing (p g s), CommittedResults (p g s) ~ ParseResults s) =>
CommittedParsing (Fixed p g s) where
type CommittedResults (Fixed p g s) = ParseResults s
commit :: forall a.
Fixed p g s a -> Fixed p g s (CommittedResults (Fixed p g s) a)
commit (PositiveDirectParser p g s a
p) = forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
p g s a -> Fixed p g s a
PositiveDirectParser (forall (m :: * -> *) a.
CommittedParsing m =>
m a -> m (CommittedResults m a)
commit p g s a
p)
commit p :: Fixed p g s a
p@DirectParser{} = DirectParser{
complete :: p g s (Either (ParseFailure (Down Int) s) a)
complete = forall (m :: * -> *) a.
CommittedParsing m =>
m a -> m (CommittedResults m a)
commit (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p),
direct0 :: p g s (Either (ParseFailure (Down Int) s) a)
direct0= forall (m :: * -> *) a.
CommittedParsing m =>
m a -> m (CommittedResults m a)
commit (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
p),
direct1 :: p g s (Either (ParseFailure (Down Int) s) a)
direct1= forall (m :: * -> *) a.
CommittedParsing m =>
m a -> m (CommittedResults m a)
commit (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
p)}
commit p :: Fixed p g s a
p@Parser{} = forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> Fixed p g s a
asLeaf Parser{
complete :: p g s (Either (ParseFailure (Down Int) s) a)
complete= forall (m :: * -> *) a.
CommittedParsing m =>
m a -> m (CommittedResults m a)
commit (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p),
direct :: p g s (Either (ParseFailure (Down Int) s) a)
direct= forall (m :: * -> *) a.
CommittedParsing m =>
m a -> m (CommittedResults m a)
commit (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct Fixed p g s a
p),
direct0 :: p g s (Either (ParseFailure (Down Int) s) a)
direct0= forall (m :: * -> *) a.
CommittedParsing m =>
m a -> m (CommittedResults m a)
commit (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
p),
direct1 :: p g s (Either (ParseFailure (Down Int) s) a)
direct1= forall (m :: * -> *) a.
CommittedParsing m =>
m a -> m (CommittedResults m a)
commit (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
p),
indirect :: p g s (Either (ParseFailure (Down Int) s) a)
indirect= forall (m :: * -> *) a.
CommittedParsing m =>
m a -> m (CommittedResults m a)
commit (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
indirect Fixed p g s a
p),
choices :: ChoiceTree (Fixed p g s (Either (ParseFailure (Down Int) s) a))
choices= forall a. HasCallStack => a
undefined,
isAmbiguous :: Maybe (AmbiguityWitness (Either (ParseFailure (Down Int) s) a))
isAmbiguous= forall a. Maybe a
Nothing,
cyclicDescendants :: g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants Fixed p g s a
p}
admit :: Fixed p g s (CommittedResults (Fixed p g s) a) -> Fixed p g s a
admit :: forall a.
Fixed p g s (CommittedResults (Fixed p g s) a) -> Fixed p g s a
admit (PositiveDirectParser p g s (CommittedResults (Fixed p g s) a)
p) = forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
p g s a -> Fixed p g s a
PositiveDirectParser (forall (m :: * -> *) a.
CommittedParsing m =>
m (CommittedResults m a) -> m a
admit p g s (CommittedResults (Fixed p g s) a)
p)
admit p :: Fixed p g s (CommittedResults (Fixed p g s) a)
p@DirectParser{} = DirectParser{
complete :: p g s a
complete = forall (m :: * -> *) a.
CommittedParsing m =>
m (CommittedResults m a) -> m a
admit (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s (CommittedResults (Fixed p g s) a)
p),
direct0 :: p g s a
direct0= forall (m :: * -> *) a.
CommittedParsing m =>
m (CommittedResults m a) -> m a
admit (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s (CommittedResults (Fixed p g s) a)
p),
direct1 :: p g s a
direct1= forall (m :: * -> *) a.
CommittedParsing m =>
m (CommittedResults m a) -> m a
admit (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s (CommittedResults (Fixed p g s) a)
p)}
admit p :: Fixed p g s (CommittedResults (Fixed p g s) a)
p@Parser{} = forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> Fixed p g s a
asLeaf Parser{
complete :: p g s a
complete= forall (m :: * -> *) a.
CommittedParsing m =>
m (CommittedResults m a) -> m a
admit (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s (CommittedResults (Fixed p g s) a)
p),
direct :: p g s a
direct= forall (m :: * -> *) a.
CommittedParsing m =>
m (CommittedResults m a) -> m a
admit (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct Fixed p g s (CommittedResults (Fixed p g s) a)
p),
direct0 :: p g s a
direct0= forall (m :: * -> *) a.
CommittedParsing m =>
m (CommittedResults m a) -> m a
admit (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s (CommittedResults (Fixed p g s) a)
p),
direct1 :: p g s a
direct1= forall (m :: * -> *) a.
CommittedParsing m =>
m (CommittedResults m a) -> m a
admit (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s (CommittedResults (Fixed p g s) a)
p),
indirect :: p g s a
indirect= forall (m :: * -> *) a.
CommittedParsing m =>
m (CommittedResults m a) -> m a
admit (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
indirect Fixed p g s (CommittedResults (Fixed p g s) a)
p),
choices :: ChoiceTree (Fixed p g s a)
choices= forall a. HasCallStack => a
undefined,
isAmbiguous :: Maybe (AmbiguityWitness a)
isAmbiguous= forall a. Maybe a
Nothing,
cyclicDescendants :: g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants Fixed p g s (CommittedResults (Fixed p g s) a)
p}
instance (Rank2.Apply g, LookAheadParsing (p g s), InputParsing (Fixed p g s)) => LookAheadParsing (Fixed p g s) where
lookAhead :: forall a. Fixed p g s a -> Fixed p g s a
lookAhead p :: Fixed p g s a
p@PositiveDirectParser{} = DirectParser{
complete :: p g s a
complete= forall (m :: * -> *) a. LookAheadParsing m => m a -> m a
lookAhead (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p),
direct0 :: p g s a
direct0= forall (m :: * -> *) a. LookAheadParsing m => m a -> m a
lookAhead (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p),
direct1 :: p g s a
direct1= forall (f :: * -> *) a. Alternative f => f a
empty}
lookAhead p :: Fixed p g s a
p@DirectParser{} = DirectParser{
complete :: p g s a
complete= forall (m :: * -> *) a. LookAheadParsing m => m a -> m a
lookAhead (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p),
direct0 :: p g s a
direct0= forall (m :: * -> *) a. LookAheadParsing m => m a -> m a
lookAhead (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p),
direct1 :: p g s a
direct1= forall (f :: * -> *) a. Alternative f => f a
empty}
lookAhead p :: Fixed p g s a
p@Parser{} = forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> Fixed p g s a
asLeaf Parser{
complete :: p g s a
complete= forall (m :: * -> *) a. LookAheadParsing m => m a -> m a
lookAhead (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p),
direct :: p g s a
direct= forall (m :: * -> *) a. LookAheadParsing m => m a -> m a
lookAhead (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct Fixed p g s a
p),
direct0 :: p g s a
direct0= forall (m :: * -> *) a. LookAheadParsing m => m a -> m a
lookAhead (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct Fixed p g s a
p),
direct1 :: p g s a
direct1= forall (f :: * -> *) a. Alternative f => f a
empty,
isAmbiguous :: Maybe (AmbiguityWitness a)
isAmbiguous= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> Maybe (AmbiguityWitness a)
isAmbiguous Fixed p g s a
p,
indirect :: p g s a
indirect= forall (m :: * -> *) a. LookAheadParsing m => m a -> m a
lookAhead (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
indirect Fixed p g s a
p),
choices :: ChoiceTree (Fixed p g s a)
choices= forall a. HasCallStack => a
undefined,
cyclicDescendants :: g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants= \g (Const (ParserFlags g))
deps-> (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants Fixed p g s a
p g (Const (ParserFlags g))
deps){nullable :: Bool
nullable= Bool
True}}
instance (Rank2.Apply g, LeftReductive s, FactorialMonoid s, InputParsing (p g s), ParserInput (p g s) ~ s) =>
InputParsing (Fixed p g s) where
type ParserInput (Fixed p g s) = s
getInput :: Fixed p g s (ParserInput (Fixed p g s))
getInput = forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
p g s a -> p g s a -> p g s a -> Fixed p g s a
primitive forall (m :: * -> *). InputParsing m => m (ParserInput m)
getInput forall (f :: * -> *) a. Alternative f => f a
empty forall (m :: * -> *). InputParsing m => m (ParserInput m)
getInput
anyToken :: Fixed p g s (ParserInput (Fixed p g s))
anyToken = forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
p g s a -> Fixed p g s a
liftPositive forall (m :: * -> *). InputParsing m => m (ParserInput m)
anyToken
satisfy :: (ParserInput (Fixed p g s) -> Bool)
-> Fixed p g s (ParserInput (Fixed p g s))
satisfy ParserInput (Fixed p g s) -> Bool
predicate = forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
p g s a -> Fixed p g s a
liftPositive (forall (m :: * -> *).
InputParsing m =>
(ParserInput m -> Bool) -> m (ParserInput m)
satisfy ParserInput (Fixed p g s) -> Bool
predicate)
notSatisfy :: (ParserInput (Fixed p g s) -> Bool) -> Fixed p g s ()
notSatisfy ParserInput (Fixed p g s) -> Bool
predicate = forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
p g s a -> p g s a -> p g s a -> Fixed p g s a
primitive (forall (m :: * -> *).
InputParsing m =>
(ParserInput m -> Bool) -> m ()
notSatisfy ParserInput (Fixed p g s) -> Bool
predicate) forall (f :: * -> *) a. Alternative f => f a
empty (forall (m :: * -> *).
InputParsing m =>
(ParserInput m -> Bool) -> m ()
notSatisfy ParserInput (Fixed p g s) -> Bool
predicate)
scan :: forall state.
state
-> (state -> ParserInput (Fixed p g s) -> Maybe state)
-> Fixed p g s (ParserInput (Fixed p g s))
scan state
s0 state -> ParserInput (Fixed p g s) -> Maybe state
f = forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
p g s a -> p g s a -> p g s a -> Fixed p g s a
primitive (forall a. Monoid a => a
mempty forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ forall (m :: * -> *).
InputParsing m =>
(ParserInput m -> Bool) -> m ()
notSatisfy s -> Bool
test) (forall (m :: * -> *) a. LookAheadParsing m => m a -> m a
lookAhead (forall (m :: * -> *).
InputParsing m =>
(ParserInput m -> Bool) -> m (ParserInput m)
satisfy s -> Bool
test) forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> p g s (ParserInput (p g s))
p) p g s (ParserInput (p g s))
p
where p :: p g s (ParserInput (p g s))
p = forall (m :: * -> *) state.
InputParsing m =>
state
-> (state -> ParserInput m -> Maybe state) -> m (ParserInput m)
scan state
s0 state -> ParserInput (Fixed p g s) -> Maybe state
f
test :: s -> Bool
test = forall a. Maybe a -> Bool
isJust forall b c a. (b -> c) -> (a -> b) -> a -> c
. state -> ParserInput (Fixed p g s) -> Maybe state
f state
s0
string :: ParserInput (Fixed p g s)
-> Fixed p g s (ParserInput (Fixed p g s))
string ParserInput (Fixed p g s)
s
| forall m. MonoidNull m => m -> Bool
null ParserInput (Fixed p g s)
s = forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
p g s a -> p g s a -> p g s a -> Fixed p g s a
primitive (forall (m :: * -> *).
InputParsing m =>
ParserInput m -> m (ParserInput m)
string ParserInput (Fixed p g s)
s) forall (f :: * -> *) a. Alternative f => f a
empty (forall (m :: * -> *).
InputParsing m =>
ParserInput m -> m (ParserInput m)
string ParserInput (Fixed p g s)
s)
| Bool
otherwise = forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
p g s a -> Fixed p g s a
liftPositive (forall (m :: * -> *).
InputParsing m =>
ParserInput m -> m (ParserInput m)
string ParserInput (Fixed p g s)
s)
take :: Int -> Fixed p g s (ParserInput (Fixed p g s))
take Int
0 = forall a. Monoid a => a
mempty
take Int
n = forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
p g s a -> Fixed p g s a
liftPositive (forall (m :: * -> *). InputParsing m => Int -> m (ParserInput m)
take Int
n)
takeWhile :: (ParserInput (Fixed p g s) -> Bool)
-> Fixed p g s (ParserInput (Fixed p g s))
takeWhile ParserInput (Fixed p g s) -> Bool
predicate = forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
p g s a -> p g s a -> p g s a -> Fixed p g s a
primitive (forall a. Monoid a => a
mempty forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ forall (m :: * -> *).
InputParsing m =>
(ParserInput m -> Bool) -> m ()
notSatisfy ParserInput (Fixed p g s) -> Bool
predicate)
(forall (m :: * -> *).
InputParsing m =>
(ParserInput m -> Bool) -> m (ParserInput m)
takeWhile1 ParserInput (Fixed p g s) -> Bool
predicate) (forall (m :: * -> *).
InputParsing m =>
(ParserInput m -> Bool) -> m (ParserInput m)
takeWhile ParserInput (Fixed p g s) -> Bool
predicate)
takeWhile1 :: (ParserInput (Fixed p g s) -> Bool)
-> Fixed p g s (ParserInput (Fixed p g s))
takeWhile1 ParserInput (Fixed p g s) -> Bool
predicate = forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
p g s a -> Fixed p g s a
liftPositive (forall (m :: * -> *).
InputParsing m =>
(ParserInput m -> Bool) -> m (ParserInput m)
takeWhile1 ParserInput (Fixed p g s) -> Bool
predicate)
{-# INLINABLE string #-}
instance (Rank2.Apply g, LeftReductive s, FactorialMonoid s, Show s,
TraceableParsing (p g s), ParserInput (p g s) ~ s) =>
TraceableParsing (Fixed p g s) where
traceInput :: forall a.
(ParserInput (Fixed p g s) -> String)
-> Fixed p g s a -> Fixed p g s a
traceInput ParserInput (Fixed p g s) -> String
description p :: Fixed p g s a
p@PositiveDirectParser{} = Fixed p g s a
p{
complete :: p g s a
complete= forall (m :: * -> *) a.
TraceableParsing m =>
(ParserInput m -> String) -> m a -> m a
traceInput (\ParserInput (p g s)
s-> String
"direct+ " forall a. Semigroup a => a -> a -> a
<> ParserInput (Fixed p g s) -> String
description ParserInput (p g s)
s) (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p)}
traceInput ParserInput (Fixed p g s) -> String
description p :: Fixed p g s a
p@DirectParser{} = Fixed p g s a
p{
complete :: p g s a
complete= forall (m :: * -> *) a.
TraceableParsing m =>
(ParserInput m -> String) -> m a -> m a
traceInput (\ParserInput (p g s)
s-> String
"direct " forall a. Semigroup a => a -> a -> a
<> ParserInput (Fixed p g s) -> String
description ParserInput (p g s)
s) (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p),
direct0 :: p g s a
direct0= forall (m :: * -> *) a.
TraceableParsing m =>
(ParserInput m -> String) -> m a -> m a
traceInput (\ParserInput (p g s)
s-> String
"direct0 " forall a. Semigroup a => a -> a -> a
<> ParserInput (Fixed p g s) -> String
description ParserInput (p g s)
s) (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
p),
direct1 :: p g s a
direct1= forall (m :: * -> *) a.
TraceableParsing m =>
(ParserInput m -> String) -> m a -> m a
traceInput (\ParserInput (p g s)
s-> String
"direct1 " forall a. Semigroup a => a -> a -> a
<> ParserInput (Fixed p g s) -> String
description ParserInput (p g s)
s) (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
p)}
traceInput ParserInput (Fixed p g s) -> String
description p :: Fixed p g s a
p@Parser{} = forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> Fixed p g s a
asLeaf Fixed p g s a
p{
complete :: p g s a
complete= String -> p g s a -> p g s a
traceBy String
"complete" (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p),
direct :: p g s a
direct= String -> p g s a -> p g s a
traceBy String
"direct" (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct Fixed p g s a
p),
direct0 :: p g s a
direct0= String -> p g s a -> p g s a
traceBy String
"direct0" (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
p),
direct1 :: p g s a
direct1= String -> p g s a -> p g s a
traceBy String
"direct1" (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
p),
indirect :: p g s a
indirect= String -> p g s a -> p g s a
traceBy String
"indirect" (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
indirect Fixed p g s a
p)}
where traceBy :: String -> p g s a -> p g s a
traceBy String
mode = forall (m :: * -> *) a.
TraceableParsing m =>
(ParserInput m -> String) -> m a -> m a
traceInput (\ParserInput (p g s)
s-> String
"(" forall a. Semigroup a => a -> a -> a
<> String
mode forall a. Semigroup a => a -> a -> a
<> String
") " forall a. Semigroup a => a -> a -> a
<> ParserInput (Fixed p g s) -> String
description ParserInput (p g s)
s)
instance (Rank2.Apply g, LeftReductive s, FactorialMonoid s,
ConsumedInputParsing (p g s), ParserInput (p g s) ~ s) => ConsumedInputParsing (Fixed p g s) where
match :: forall a.
Fixed p g s a -> Fixed p g s (ParserInput (Fixed p g s), a)
match (PositiveDirectParser p g s a
p) = forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
p g s a -> Fixed p g s a
PositiveDirectParser (forall (m :: * -> *) a.
ConsumedInputParsing m =>
m a -> m (ParserInput m, a)
match p g s a
p)
match p :: Fixed p g s a
p@DirectParser{} = DirectParser{
complete :: p g s (s, a)
complete= forall (m :: * -> *) a.
ConsumedInputParsing m =>
m a -> m (ParserInput m, a)
match (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p),
direct0 :: p g s (s, a)
direct0 = forall (m :: * -> *) a.
ConsumedInputParsing m =>
m a -> m (ParserInput m, a)
match (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
p),
direct1 :: p g s (s, a)
direct1 = forall (m :: * -> *) a.
ConsumedInputParsing m =>
m a -> m (ParserInput m, a)
match (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
p)}
match p :: Fixed p g s a
p@Parser{} = forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> Fixed p g s a
asLeaf Parser{
complete :: p g s (s, a)
complete= forall (m :: * -> *) a.
ConsumedInputParsing m =>
m a -> m (ParserInput m, a)
match (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p),
direct :: p g s (s, a)
direct = forall (m :: * -> *) a.
ConsumedInputParsing m =>
m a -> m (ParserInput m, a)
match (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct Fixed p g s a
p),
direct0 :: p g s (s, a)
direct0 = forall (m :: * -> *) a.
ConsumedInputParsing m =>
m a -> m (ParserInput m, a)
match (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
p),
direct1 :: p g s (s, a)
direct1 = forall (m :: * -> *) a.
ConsumedInputParsing m =>
m a -> m (ParserInput m, a)
match (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
p),
indirect :: p g s (s, a)
indirect= forall (m :: * -> *) a.
ConsumedInputParsing m =>
m a -> m (ParserInput m, a)
match (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
indirect Fixed p g s a
p),
choices :: ChoiceTree (Fixed p g s (s, a))
choices= forall a. HasCallStack => a
undefined,
isAmbiguous :: Maybe (AmbiguityWitness (s, a))
isAmbiguous= forall a. Maybe a
Nothing,
cyclicDescendants :: g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants Fixed p g s a
p}
instance (Rank2.Apply g, Show s, TextualMonoid s, InputCharParsing (p g s), ParserInput (p g s) ~ s) =>
InputCharParsing (Fixed p g s) where
satisfyCharInput :: (Char -> Bool) -> Fixed p g s (ParserInput (Fixed p g s))
satisfyCharInput Char -> Bool
predicate = forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
p g s a -> Fixed p g s a
liftPositive (forall (m :: * -> *).
InputCharParsing m =>
(Char -> Bool) -> m (ParserInput m)
satisfyCharInput Char -> Bool
predicate)
notSatisfyChar :: (Char -> Bool) -> Fixed p g s ()
notSatisfyChar Char -> Bool
predicate = forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
p g s a -> p g s a -> p g s a -> Fixed p g s a
primitive (forall (m :: * -> *). InputCharParsing m => (Char -> Bool) -> m ()
notSatisfyChar Char -> Bool
predicate) forall (f :: * -> *) a. Alternative f => f a
empty (forall (m :: * -> *). InputCharParsing m => (Char -> Bool) -> m ()
notSatisfyChar Char -> Bool
predicate)
scanChars :: forall state.
state
-> (state -> Char -> Maybe state)
-> Fixed p g s (ParserInput (Fixed p g s))
scanChars state
s0 state -> Char -> Maybe state
f = forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
p g s a -> p g s a -> p g s a -> Fixed p g s a
primitive (forall a. Monoid a => a
mempty forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ forall (m :: * -> *). InputCharParsing m => (Char -> Bool) -> m ()
notSatisfyChar Char -> Bool
test) (forall (m :: * -> *) a. LookAheadParsing m => m a -> m a
lookAhead (forall (m :: * -> *). CharParsing m => (Char -> Bool) -> m Char
Char.satisfy Char -> Bool
test) forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> p g s (ParserInput (p g s))
p) p g s (ParserInput (p g s))
p
where p :: p g s (ParserInput (p g s))
p = forall (m :: * -> *) state.
InputCharParsing m =>
state -> (state -> Char -> Maybe state) -> m (ParserInput m)
scanChars state
s0 state -> Char -> Maybe state
f
test :: Char -> Bool
test = forall a. Maybe a -> Bool
isJust forall b c a. (b -> c) -> (a -> b) -> a -> c
. state -> Char -> Maybe state
f state
s0
takeCharsWhile :: (Char -> Bool) -> Fixed p g s (ParserInput (Fixed p g s))
takeCharsWhile Char -> Bool
predicate = forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
p g s a -> p g s a -> p g s a -> Fixed p g s a
primitive (forall a. Monoid a => a
mempty forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ forall (m :: * -> *). InputCharParsing m => (Char -> Bool) -> m ()
notSatisfyChar Char -> Bool
predicate)
(forall (m :: * -> *).
InputCharParsing m =>
(Char -> Bool) -> m (ParserInput m)
takeCharsWhile1 Char -> Bool
predicate) (forall (m :: * -> *).
InputCharParsing m =>
(Char -> Bool) -> m (ParserInput m)
takeCharsWhile Char -> Bool
predicate)
takeCharsWhile1 :: (Char -> Bool) -> Fixed p g s (ParserInput (Fixed p g s))
takeCharsWhile1 Char -> Bool
predicate = forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
p g s a -> Fixed p g s a
liftPositive (forall (m :: * -> *).
InputCharParsing m =>
(Char -> Bool) -> m (ParserInput m)
takeCharsWhile1 Char -> Bool
predicate)
instance (Rank2.Apply g, CharParsing (p g s), InputCharParsing (Fixed p g s), TextualMonoid s,
s ~ ParserInput (Fixed p g s), Show s) => CharParsing (Fixed p g s) where
satisfy :: (Char -> Bool) -> Fixed p g s Char
satisfy Char -> Bool
predicate = forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
p g s a -> Fixed p g s a
liftPositive (forall (m :: * -> *). CharParsing m => (Char -> Bool) -> m Char
Char.satisfy Char -> Bool
predicate)
string :: String -> Fixed p g s String
string String
s = forall t. TextualMonoid t => (t -> String) -> t -> String
Textual.toString (forall a. HasCallStack => String -> a
error String
"unexpected non-character") forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *).
InputParsing m =>
ParserInput m -> m (ParserInput m)
string (forall a. IsString a => String -> a
fromString String
s)
text :: Text -> Fixed p g s Text
text Text
t = (forall a. IsString a => String -> a
fromString forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall t. TextualMonoid t => (t -> String) -> t -> String
Textual.toString (forall a. HasCallStack => String -> a
error String
"unexpected non-character")) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *).
InputParsing m =>
ParserInput m -> m (ParserInput m)
string (forall t. TextualMonoid t => Text -> t
Textual.fromText Text
t)
instance (AmbiguousParsing (p g s), Rank2.Apply g) => AmbiguousParsing (Fixed p g s) where
ambiguous :: forall a. Fixed p g s a -> Fixed p g s (Ambiguous a)
ambiguous (PositiveDirectParser p g s a
p) = forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
p g s a -> Fixed p g s a
PositiveDirectParser (forall (m :: * -> *) a.
AmbiguousParsing m =>
m a -> m (Ambiguous a)
ambiguous p g s a
p)
ambiguous p :: Fixed p g s a
p@DirectParser{} = DirectParser{complete :: p g s (Ambiguous a)
complete= forall (m :: * -> *) a.
AmbiguousParsing m =>
m a -> m (Ambiguous a)
ambiguous (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p),
direct0 :: p g s (Ambiguous a)
direct0= forall (m :: * -> *) a.
AmbiguousParsing m =>
m a -> m (Ambiguous a)
ambiguous (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
p),
direct1 :: p g s (Ambiguous a)
direct1= forall (m :: * -> *) a.
AmbiguousParsing m =>
m a -> m (Ambiguous a)
ambiguous (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
p)}
ambiguous p :: Fixed p g s a
p@Parser{} = forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> Fixed p g s a
asLeaf Parser{
complete :: p g s (Ambiguous a)
complete= forall (m :: * -> *) a.
AmbiguousParsing m =>
m a -> m (Ambiguous a)
ambiguous (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p),
direct :: p g s (Ambiguous a)
direct= forall (m :: * -> *) a.
AmbiguousParsing m =>
m a -> m (Ambiguous a)
ambiguous (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct Fixed p g s a
p),
direct0 :: p g s (Ambiguous a)
direct0= forall (m :: * -> *) a.
AmbiguousParsing m =>
m a -> m (Ambiguous a)
ambiguous (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
p),
direct1 :: p g s (Ambiguous a)
direct1= forall (m :: * -> *) a.
AmbiguousParsing m =>
m a -> m (Ambiguous a)
ambiguous (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
p),
indirect :: p g s (Ambiguous a)
indirect= forall (m :: * -> *) a.
AmbiguousParsing m =>
m a -> m (Ambiguous a)
ambiguous (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
indirect Fixed p g s a
p),
choices :: ChoiceTree (Fixed p g s (Ambiguous a))
choices= forall a. HasCallStack => a
undefined,
isAmbiguous :: Maybe (AmbiguityWitness (Ambiguous a))
isAmbiguous= forall a. a -> Maybe a
Just (forall a b. (a :~: Ambiguous b) -> AmbiguityWitness a
AmbiguityWitness forall {k} (a :: k). a :~: a
Refl),
cyclicDescendants :: g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants= forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants Fixed p g s a
p}
{-# INLINABLE ambiguous #-}
autochain :: forall p g s f rl (cb :: Type -> Type).
(cb ~ Const (g (Const Bool)), f ~ GrammarFunctor (p g s), f ~ rl s,
LeftRecParsing p g s rl, DeterministicParsing (p g s),
Rank2.Apply g, Rank2.Traversable g, Rank2.Distributive g, Rank2.Logistic g)
=> g (Fixed p g s) -> g (Fixed p g s)
autochain :: forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
(f :: * -> *) (rl :: * -> * -> *) (cb :: * -> *).
(cb ~ Const (g (Const Bool)), f ~ GrammarFunctor (p g s), f ~ rl s,
LeftRecParsing p g s rl, DeterministicParsing (p g s), Apply g,
Traversable g, Distributive g, Logistic g) =>
g (Fixed p g s) -> g (Fixed p g s)
autochain g (Fixed p g s)
g = forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *)
(r :: k -> *) (s :: k -> *) (t :: k -> *).
Apply g =>
(forall (a :: k). p a -> q a -> r a -> s a -> t a)
-> g p -> g q -> g r -> g s -> g t
Rank2.liftA4 forall a.
Compose ((->) (g cb)) cb a
-> Arrow (f ~> f) (Const (g f -> g f)) a
-> Const Bool a
-> Fixed p g s a
-> Fixed p g s a
optimize forall {k1} (g :: (k1 -> *) -> *) (f :: k1 -> *).
Distributive g =>
g (Compose ((->) (g f)) f)
Rank2.getters forall {k1} (g :: (k1 -> *) -> *) (f :: k1 -> *).
Logistic g =>
g ((f ~> f) ~> Const (g f -> g f))
Rank2.setters g (Const Bool)
candidates g (Fixed p g s)
g
where candidates :: g (Const Bool)
optimize :: forall a. (Compose ((->) (g cb)) cb a)
-> (Rank2.Arrow (f Rank2.~> f) (Const (g f -> g f)) a)
-> Const Bool a
-> Fixed p g s a
-> Fixed p g s a
optimize :: forall a.
Compose ((->) (g cb)) cb a
-> Arrow (f ~> f) (Const (g f -> g f)) a
-> Const Bool a
-> Fixed p g s a
-> Fixed p g s a
optimize Compose ((->) (g cb)) cb a
getter Arrow (f ~> f) (Const (g f -> g f)) a
setter (Const Bool
True) p :: Fixed p g s a
p@Parser{choices :: forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> ChoiceTree (Fixed p g s a)
choices= ChoiceTree (Fixed p g s a)
cs} =
forall a.
(g cb -> cb a)
-> (f a -> g f -> g f)
-> Fixed p g s a
-> ChoiceTree (Fixed p g s a)
-> Fixed p g s a
optimizeChoice (forall {k1} {k2} (f :: k1 -> *) (g :: k2 -> k1) (a :: k2).
Compose f g a -> f (g a)
getCompose Compose ((->) (g cb)) cb a
getter) (forall {k} a (b :: k). Const a b -> a
getConst forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall {k} (p :: k -> *) (q :: k -> *) (a :: k).
Arrow p q a -> p a -> q a
Rank2.apply Arrow (f ~> f) (Const (g f -> g f)) a
setter forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall {k} (p :: k -> *) (q :: k -> *) (a :: k).
(p a -> q a) -> Arrow p q a
Rank2.Arrow forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. a -> b -> a
const) Fixed p g s a
p ChoiceTree (Fixed p g s a)
cs
optimize Compose ((->) (g cb)) cb a
_ Arrow (f ~> f) (Const (g f -> g f)) a
_ Const Bool a
_ Fixed p g s a
p = Fixed p g s a
p
optimizeChoice :: (g cb -> cb a)
-> (f a -> g f -> g f)
-> Fixed p g s a
-> ChoiceTree (Fixed p g s a)
-> Fixed p g s a
splitSymmetric :: (g cb -> cb a) -> ChoiceTree (Fixed p g s a) -> ([Fixed p g s a], [Fixed p g s a])
isLeftRecursive :: (g cb -> cb a) -> ChoiceTree (Fixed p g s a) -> Bool
leftRecursiveParser :: (g cb -> cb a) -> Fixed p g s a -> Bool
optimizeChoice :: forall a.
(g cb -> cb a)
-> (f a -> g f -> g f)
-> Fixed p g s a
-> ChoiceTree (Fixed p g s a)
-> Fixed p g s a
optimizeChoice g cb -> cb a
_ f a -> g f -> g f
_ Fixed p g s a
fallback Leaf{} = Fixed p g s a
fallback
optimizeChoice g cb -> cb a
get f a -> g f -> g f
set Fixed p g s a
fallback (LeftBiasedChoice ChoiceTree (Fixed p g s a)
p ChoiceTree (Fixed p g s a)
q)
| forall a. (g cb -> cb a) -> ChoiceTree (Fixed p g s a) -> Bool
isLeftRecursive g cb -> cb a
get ChoiceTree (Fixed p g s a)
q = Fixed p g s a
fallback
| Bool -> Bool
not (forall a. (g cb -> cb a) -> ChoiceTree (Fixed p g s a) -> Bool
isLeftRecursive g cb -> cb a
get ChoiceTree (Fixed p g s a)
p) = Fixed p g s a
fallback
| LeftBiasedChoice ChoiceTree (Fixed p g s a)
p1 ChoiceTree (Fixed p g s a)
p2 <- ChoiceTree (Fixed p g s a)
p, Bool -> Bool
not (forall a. (g cb -> cb a) -> ChoiceTree (Fixed p g s a) -> Bool
isLeftRecursive g cb -> cb a
get ChoiceTree (Fixed p g s a)
p2)
= forall a.
(g cb -> cb a)
-> (f a -> g f -> g f)
-> Fixed p g s a
-> ChoiceTree (Fixed p g s a)
-> Fixed p g s a
optimizeChoice g cb -> cb a
get f a -> g f -> g f
set Fixed p g s a
fallback forall a b. (a -> b) -> a -> b
$ forall a. ChoiceTree a -> ChoiceTree a -> ChoiceTree a
LeftBiasedChoice ChoiceTree (Fixed p g s a)
p1 (forall a. ChoiceTree a -> ChoiceTree a -> ChoiceTree a
LeftBiasedChoice ChoiceTree (Fixed p g s a)
p2 ChoiceTree (Fixed p g s a)
q)
| Bool
otherwise = forall (m :: * -> *) (g :: (* -> *) -> *) (f :: * -> *) a.
(GrammarParsing m, g ~ ParserGrammar m, f ~ GrammarFunctor m,
GrammarConstraint m g) =>
(f a -> g f -> g f) -> m a -> m a -> m a
chainLongestRecursive f a -> g f -> g f
set (forall (p :: * -> *) a.
(Alternative p, DeterministicParsing p) =>
ChoiceTree (p a) -> p a
collapseChoices ChoiceTree (Fixed p g s a)
q) (forall (p :: * -> *) a.
(Alternative p, DeterministicParsing p) =>
ChoiceTree (p a) -> p a
collapseChoices ChoiceTree (Fixed p g s a)
p)
optimizeChoice g cb -> cb a
get f a -> g f -> g f
set Fixed p g s a
fallback c :: ChoiceTree (Fixed p g s a)
c@SymmetricChoice{}
| forall m. MonoidNull m => m -> Bool
null [Fixed p g s a]
base = Fixed p g s a
fallback
| forall m. MonoidNull m => m -> Bool
null [Fixed p g s a]
recursives = Fixed p g s a
fallback
| Bool
otherwise = forall (m :: * -> *) (g :: (* -> *) -> *) (f :: * -> *) a.
(GrammarParsing m, g ~ ParserGrammar m, f ~ GrammarFunctor m,
GrammarConstraint m g) =>
(f a -> g f -> g f) -> m a -> m a -> m a
chainRecursive f a -> g f -> g f
set (forall (t :: * -> *) a. Foldable t => (a -> a -> a) -> t a -> a
foldr1 forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
(<|>) [Fixed p g s a]
base) (forall (t :: * -> *) a. Foldable t => (a -> a -> a) -> t a -> a
foldr1 forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
(<|>) [Fixed p g s a]
recursives)
where ([Fixed p g s a]
base, [Fixed p g s a]
recursives) = forall a.
(g cb -> cb a)
-> ChoiceTree (Fixed p g s a) -> ([Fixed p g s a], [Fixed p g s a])
splitSymmetric g cb -> cb a
get ChoiceTree (Fixed p g s a)
c
splitSymmetric :: forall a.
(g cb -> cb a)
-> ChoiceTree (Fixed p g s a) -> ([Fixed p g s a], [Fixed p g s a])
splitSymmetric g cb -> cb a
get (SymmetricChoice ChoiceTree (Fixed p g s a)
p ChoiceTree (Fixed p g s a)
q) = forall a.
(g cb -> cb a)
-> ChoiceTree (Fixed p g s a) -> ([Fixed p g s a], [Fixed p g s a])
splitSymmetric g cb -> cb a
get ChoiceTree (Fixed p g s a)
p forall a. Semigroup a => a -> a -> a
<> forall a.
(g cb -> cb a)
-> ChoiceTree (Fixed p g s a) -> ([Fixed p g s a], [Fixed p g s a])
splitSymmetric g cb -> cb a
get ChoiceTree (Fixed p g s a)
q
splitSymmetric g cb -> cb a
get ChoiceTree (Fixed p g s a)
c
| forall a. (g cb -> cb a) -> ChoiceTree (Fixed p g s a) -> Bool
isLeftRecursive g cb -> cb a
get ChoiceTree (Fixed p g s a)
c = ([], [forall (p :: * -> *) a.
(Alternative p, DeterministicParsing p) =>
ChoiceTree (p a) -> p a
collapseChoices ChoiceTree (Fixed p g s a)
c])
| Bool
otherwise = ([forall (p :: * -> *) a.
(Alternative p, DeterministicParsing p) =>
ChoiceTree (p a) -> p a
collapseChoices ChoiceTree (Fixed p g s a)
c], [])
isLeftRecursive :: forall a. (g cb -> cb a) -> ChoiceTree (Fixed p g s a) -> Bool
isLeftRecursive g cb -> cb a
get = forall a. (g cb -> cb a) -> Fixed p g s a -> Bool
leftRecursiveParser g cb -> cb a
get forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (p :: * -> *) a.
(Alternative p, DeterministicParsing p) =>
ChoiceTree (p a) -> p a
collapseChoices
leftRecursiveParser :: forall a. (g cb -> cb a) -> Fixed p g s a -> Bool
leftRecursiveParser g cb -> cb a
get Parser{cyclicDescendants :: forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants= g (Const (ParserFlags g)) -> ParserFlags g
cds} =
Any -> Bool
getAny forall a b. (a -> b) -> a -> b
$ forall {k} (g :: (k -> *) -> *) m (p :: k -> *).
(Foldable g, Monoid m) =>
(forall (a :: k). p a -> m) -> g p -> m
Rank2.foldMap (Bool -> Any
Any forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall {k} a (b :: k). Const a b -> a
getConst) forall a b. (a -> b) -> a -> b
$ forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *)
(r :: k -> *).
Apply g =>
(forall (a :: k). p a -> q a -> r a) -> g p -> g q -> g r
Rank2.liftA2 forall x. Const Bool x -> Const Bool x -> Const Bool x
intersection (forall {k} a (b :: k). Const a b -> a
getConst forall a b. (a -> b) -> a -> b
$ g cb -> cb a
get forall (g :: (* -> *) -> *).
(Distributive g, Traversable g) =>
g (Const (g (Const Bool)))
bits) (g cb -> g (Const Bool)
deps forall (g :: (* -> *) -> *).
(Distributive g, Traversable g) =>
g (Const (g (Const Bool)))
bits)
where deps :: g cb -> g (Const Bool)
deps :: g cb -> g (Const Bool)
deps = forall (g :: (* -> *) -> *).
Distributive g =>
Dependencies g -> g (Const Bool)
getDependencies forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (g :: (* -> *) -> *). ParserFlags g -> Dependencies g
dependsOn forall b c a. (b -> c) -> (a -> b) -> a -> c
. g (Const (ParserFlags g)) -> ParserFlags g
cds
forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *).
Functor g =>
(forall (a :: k). p a -> q a) -> g p -> g q
Rank2.fmap (forall {k} a (b :: k). a -> Const a b
Const forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (g :: (* -> *) -> *).
Bool -> Dependencies g -> ParserFlags g
ParserFlags Bool
False forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (g :: (* -> *) -> *). g (Const Bool) -> Dependencies g
StaticDependencies forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall {k} a (b :: k). Const a b -> a
getConst)
leftRecursiveParser g cb -> cb a
_ Fixed p g s a
_ = Bool
False
candidates :: g (Const Bool)
candidates = forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *)
(r :: k -> *).
Apply g =>
(forall (a :: k). p a -> q a -> r a) -> g p -> g q -> g r
Rank2.liftA2 forall x. Const Bool x -> Const Bool x -> Const Bool x
intersection (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *)
s.
(Alternative (p g s), Apply g, Distributive g, Traversable g) =>
g (Fixed p g s) -> g (Const Bool)
cyclicDependencies g (Fixed p g s)
g) (forall x. Const Bool x -> Const Bool x
complement forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *).
Functor g =>
(forall (a :: k). p a -> q a) -> g p -> g q
Rank2.<$> forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *)
s.
(Alternative (p g s), Apply g, Distributive g, Traversable g) =>
g (Fixed p g s) -> g (Const Bool)
cyclicDependencies g (Fixed p g s)
g')
g' :: g (Fixed p g s)
g' = forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *)
(r :: k -> *).
Apply g =>
(forall (a :: k). p a -> q a -> r a) -> g p -> g q -> g r
Rank2.liftA2 forall {g :: (* -> *) -> *} {b}
{p :: ((* -> *) -> *) -> * -> * -> *} {s} {a}.
Apply g =>
Const (g (Const Bool)) b -> Fixed p g s a -> Fixed p g s a
noDirectLeftRecursion forall (g :: (* -> *) -> *).
(Distributive g, Traversable g) =>
g (Const (g (Const Bool)))
bits g (Fixed p g s)
g
noDirectLeftRecursion :: Const (g (Const Bool)) b -> Fixed p g s a -> Fixed p g s a
noDirectLeftRecursion (Const g (Const Bool)
bit) p :: Fixed p g s a
p@Parser{cyclicDescendants :: forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants= g (Const (ParserFlags g)) -> ParserFlags g
cd} = Fixed p g s a
p{cyclicDescendants :: g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants= ParserFlags g -> ParserFlags g
excludeSelf forall b c a. (b -> c) -> (a -> b) -> a -> c
. g (Const (ParserFlags g)) -> ParserFlags g
cd}
where excludeSelf :: ParserFlags g -> ParserFlags g
excludeSelf (ParserFlags Bool
n Dependencies g
DynamicDependencies) = forall (g :: (* -> *) -> *).
Bool -> Dependencies g -> ParserFlags g
ParserFlags Bool
n forall (g :: (* -> *) -> *). Dependencies g
DynamicDependencies
excludeSelf (ParserFlags Bool
n (StaticDependencies g (Const Bool)
deps)) =
forall (g :: (* -> *) -> *).
Bool -> Dependencies g -> ParserFlags g
ParserFlags Bool
n forall a b. (a -> b) -> a -> b
$ forall (g :: (* -> *) -> *). g (Const Bool) -> Dependencies g
StaticDependencies forall a b. (a -> b) -> a -> b
$ forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *)
(r :: k -> *).
Apply g =>
(forall (a :: k). p a -> q a -> r a) -> g p -> g q -> g r
Rank2.liftA2 forall x. Const Bool x -> Const Bool x -> Const Bool x
intersection (forall x. Const Bool x -> Const Bool x
complement forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *).
Functor g =>
(forall (a :: k). p a -> q a) -> g p -> g q
Rank2.<$> g (Const Bool)
bit) g (Const Bool)
deps
noDirectLeftRecursion Const (g (Const Bool)) b
_ Fixed p g s a
p = Fixed p g s a
p
separated :: forall p g s. (Alternative (p g s), Rank2.Apply g, Rank2.Distributive g, Rank2.Traversable g,
AmbiguousAlternative (GrammarFunctor (p g s))) =>
g (Fixed p g s) -> g (SeparatedParser 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)
separated g (Fixed p g s)
g = forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *)
(r :: k -> *) (s :: k -> *) (t :: k -> *).
Apply g =>
(forall (a :: k). p a -> q a -> r a -> s a -> t a)
-> g p -> g q -> g r -> g s -> g t
Rank2.liftA4 forall a.
Const Bool a
-> Const Bool a
-> Const (Dependencies g) a
-> Fixed p g s a
-> SeparatedParser p g s a
reseparate g (Const Bool)
circulars g (Const Bool)
cycleFollowers g (Const (Dependencies g))
descendants g (Fixed p g s)
g
where descendants :: g (Const (Dependencies g))
cycleFollowers, circulars :: g (Const Bool)
appendResults :: forall a. Maybe (AmbiguityWitness a)
-> GrammarFunctor (p g s) a -> GrammarFunctor (p g s) a -> GrammarFunctor (p g s) a
leftRecursiveDeps :: forall a. Const Bool a -> Const (Dependencies g) a -> Const (g (Const Bool)) a
reseparate :: forall a. Const Bool a -> Const Bool a -> Const (Dependencies g) a -> Fixed p g s a
-> SeparatedParser p g s a
reseparate :: forall a.
Const Bool a
-> Const Bool a
-> Const (Dependencies g) a
-> Fixed p g s a
-> SeparatedParser p g s a
reseparate (Const Bool
circular) (Const Bool
follower) (Const d :: Dependencies g
d@(StaticDependencies g (Const Bool)
deps)) Fixed p g s a
p
| Bool
circular Bool -> Bool -> Bool
|| Bool
leader Bool -> Bool -> Bool
&& Bool
follower =
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
p g s a
-> p g s a
-> ResultAppend p g s a
-> Dependencies g
-> SeparatedParser p g s a
CycleParser (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
indirect Fixed p g s a
p) (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct Fixed p g s a
p) (forall {k} (p :: k -> *) (q :: k -> *) (a :: k).
(p a -> q a) -> Arrow p q a
Rank2.Arrow (forall {k} (p :: k -> *) (q :: k -> *) (a :: k).
(p a -> q a) -> Arrow p q a
Rank2.Arrow forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a.
Maybe (AmbiguityWitness a)
-> GrammarFunctor (p g s) a
-> GrammarFunctor (p g s) a
-> GrammarFunctor (p g s) a
appendResults (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> Maybe (AmbiguityWitness a)
isAmbiguous Fixed p g s a
p))) Dependencies g
d
| Bool
follower = forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
p g s a -> SeparatedParser p g s a
BackParser (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p)
| Bool
otherwise = forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
p g s a -> SeparatedParser p g s a
FrontParser (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p)
where leader :: Bool
leader = Any -> Bool
getAny (forall {k} (g :: (k -> *) -> *) m (p :: k -> *).
(Foldable g, Monoid m) =>
(forall (a :: k). p a -> m) -> g p -> m
Rank2.foldMap (Bool -> Any
Any forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall {k} a (b :: k). Const a b -> a
getConst) forall a b. (a -> b) -> a -> b
$ forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *)
(r :: k -> *).
Apply g =>
(forall (a :: k). p a -> q a -> r a) -> g p -> g q -> g r
Rank2.liftA2 forall x. Const Bool x -> Const Bool x -> Const Bool x
intersection g (Const Bool)
circulars g (Const Bool)
deps)
reseparate Const Bool a
_ Const Bool a
_ (Const d :: Dependencies g
d@Dependencies g
DynamicDependencies) Fixed p g s a
p =
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
p g s a
-> p g s a
-> ResultAppend p g s a
-> Dependencies g
-> SeparatedParser p g s a
CycleParser (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
indirect Fixed p g s a
p) (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct Fixed p g s a
p) (forall {k} (p :: k -> *) (q :: k -> *) (a :: k).
(p a -> q a) -> Arrow p q a
Rank2.Arrow (forall {k} (p :: k -> *) (q :: k -> *) (a :: k).
(p a -> q a) -> Arrow p q a
Rank2.Arrow forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a.
Maybe (AmbiguityWitness a)
-> GrammarFunctor (p g s) a
-> GrammarFunctor (p g s) a
-> GrammarFunctor (p g s) a
appendResults (forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> Maybe (AmbiguityWitness a)
isAmbiguous Fixed p g s a
p))) Dependencies g
d
appendResults :: forall a.
Maybe (AmbiguityWitness a)
-> GrammarFunctor (p g s) a
-> GrammarFunctor (p g s) a
-> GrammarFunctor (p g s) a
appendResults (Just (AmbiguityWitness a :~: Ambiguous b
Refl)) = forall (f :: * -> *) a.
AmbiguousAlternative f =>
f (Ambiguous a) -> f (Ambiguous a) -> f (Ambiguous a)
ambiguousOr
appendResults Maybe (AmbiguityWitness a)
Nothing = forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
(<|>)
descendants :: g (Const (Dependencies g))
descendants = forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *)
s.
(Alternative (p g s), Apply g, Traversable g) =>
g (Fixed p g s) -> g (Const (Dependencies g))
transitiveDescendants g (Fixed p g s)
g
circulars :: g (Const Bool)
circulars = forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *)
(r :: k -> *).
Apply g =>
(forall (a :: k). p a -> q a -> r a) -> g p -> g q -> g r
Rank2.liftA2 forall (g :: (* -> *) -> *) a.
(Apply g, Foldable g) =>
Const (g (Const Bool)) a
-> Const (Dependencies g) a -> Const Bool a
leftRecursive forall (g :: (* -> *) -> *).
(Distributive g, Traversable g) =>
g (Const (g (Const Bool)))
bits g (Const (Dependencies g))
descendants
cycleFollowers :: g (Const Bool)
cycleFollowers = forall (g :: (* -> *) -> *). Union g -> g (Const Bool)
getUnion (forall {k} (g :: (k -> *) -> *) m (p :: k -> *).
(Foldable g, Monoid m) =>
(forall (a :: k). p a -> m) -> g p -> m
Rank2.foldMap (forall (g :: (* -> *) -> *). g (Const Bool) -> Union g
Union forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall {k} a (b :: k). Const a b -> a
getConst) forall a b. (a -> b) -> a -> b
$
forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *)
(r :: k -> *).
Apply g =>
(forall (a :: k). p a -> q a -> r a) -> g p -> g q -> g r
Rank2.liftA2 forall a.
Const Bool a
-> Const (Dependencies g) a -> Const (g (Const Bool)) a
leftRecursiveDeps g (Const Bool)
circulars g (Const (Dependencies g))
descendants)
leftRecursiveDeps :: forall a.
Const Bool a
-> Const (Dependencies g) a -> Const (g (Const Bool)) a
leftRecursiveDeps (Const Bool
True) (Const (StaticDependencies g (Const Bool)
deps)) = forall {k} a (b :: k). a -> Const a b
Const g (Const Bool)
deps
leftRecursiveDeps (Const Bool
False) (Const (StaticDependencies g (Const Bool)
deps)) =
forall {k} a (b :: k). a -> Const a b
Const (forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *).
Functor g =>
(forall (a :: k). p a -> q a) -> g p -> g q
Rank2.fmap (forall a b. a -> b -> a
const forall a b. (a -> b) -> a -> b
$ forall {k} a (b :: k). a -> Const a b
Const Bool
False) g (Const Bool)
deps)
leftRecursiveDeps Const Bool a
_ (Const Dependencies g
DynamicDependencies) = forall {k} a (b :: k). a -> Const a b
Const (forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *).
Functor g =>
(forall (a :: k). p a -> q a) -> g p -> g q
Rank2.fmap (forall a b. a -> b -> a
const forall a b. (a -> b) -> a -> b
$ forall {k} a (b :: k). a -> Const a b
Const Bool
True) g (Fixed p g s)
g)
{-# INLINABLE separated #-}
getDependencies :: Rank2.Distributive g => Dependencies g -> g (Const Bool)
getDependencies :: forall (g :: (* -> *) -> *).
Distributive g =>
Dependencies g -> g (Const Bool)
getDependencies (StaticDependencies g (Const Bool)
deps) = g (Const Bool)
deps
getDependencies Dependencies g
DynamicDependencies = forall {k1} (g :: (k1 -> *) -> *) (m :: * -> *) (p :: k1 -> *)
(q :: k1 -> *).
(Distributive g, Functor m) =>
(forall (a :: k1). m (p a) -> q a) -> m (g p) -> g q
Rank2.cotraverse (forall a b. a -> b -> a
const forall a b. (a -> b) -> a -> b
$ forall {k} a (b :: k). a -> Const a b
Const Bool
True) forall a. Maybe a
Nothing
cyclicDependencies :: (Alternative (p g s), Rank2.Apply g, Rank2.Distributive g, Rank2.Traversable g)
=> g (Fixed p g s) -> g (Const Bool)
cyclicDependencies :: forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *)
s.
(Alternative (p g s), Apply g, Distributive g, Traversable g) =>
g (Fixed p g s) -> g (Const Bool)
cyclicDependencies = forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *)
(r :: k -> *).
Apply g =>
(forall (a :: k). p a -> q a -> r a) -> g p -> g q -> g r
Rank2.liftA2 forall (g :: (* -> *) -> *) a.
(Apply g, Foldable g) =>
Const (g (Const Bool)) a
-> Const (Dependencies g) a -> Const Bool a
leftRecursive forall (g :: (* -> *) -> *).
(Distributive g, Traversable g) =>
g (Const (g (Const Bool)))
bits forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *)
s.
(Alternative (p g s), Apply g, Traversable g) =>
g (Fixed p g s) -> g (Const (Dependencies g))
transitiveDescendants
leftRecursive :: forall g a. (Rank2.Apply g, Rank2.Foldable g)
=> Const (g (Const Bool)) a -> Const (Dependencies g) a -> Const Bool a
leftRecursive :: forall (g :: (* -> *) -> *) a.
(Apply g, Foldable g) =>
Const (g (Const Bool)) a
-> Const (Dependencies g) a -> Const Bool a
leftRecursive (Const g (Const Bool)
bit) (Const (StaticDependencies g (Const Bool)
deps)) =
forall {k} a (b :: k). a -> Const a b
Const (Any -> Bool
getAny forall a b. (a -> b) -> a -> b
$ forall {k} (g :: (k -> *) -> *) m (p :: k -> *).
(Foldable g, Monoid m) =>
(forall (a :: k). p a -> m) -> g p -> m
Rank2.foldMap (Bool -> Any
Any forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall {k} a (b :: k). Const a b -> a
getConst) forall a b. (a -> b) -> a -> b
$ forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *)
(r :: k -> *).
Apply g =>
(forall (a :: k). p a -> q a -> r a) -> g p -> g q -> g r
Rank2.liftA2 forall x. Const Bool x -> Const Bool x -> Const Bool x
intersection g (Const Bool)
bit g (Const Bool)
deps)
leftRecursive Const (g (Const Bool)) a
_ (Const Dependencies g
DynamicDependencies) = forall {k} a (b :: k). a -> Const a b
Const Bool
True
transitiveDescendants :: (Alternative (p g s), Rank2.Apply g, Rank2.Traversable g)
=> g (Fixed p g s) -> g (Const (Dependencies g))
transitiveDescendants :: forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *)
s.
(Alternative (p g s), Apply g, Traversable g) =>
g (Fixed p g s) -> g (Const (Dependencies g))
transitiveDescendants =
forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *).
Functor g =>
(forall (a :: k). p a -> q a) -> g p -> g q
Rank2.fmap (forall {k} a (b :: k). a -> Const a b
Const forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (g :: (* -> *) -> *). ParserFlags g -> Dependencies g
dependsOn forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall {k} a (b :: k). Const a b -> a
getConst) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (g :: (* -> *) -> *).
(Apply g, Traversable g) =>
g (Const (g (Const (ParserFlags g)) -> ParserFlags g))
-> g (Const (ParserFlags g))
fixDescendants forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *).
Functor g =>
(forall (a :: k). p a -> q a) -> g p -> g q
Rank2.fmap (forall {k} a (b :: k). a -> Const a b
Const forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (g :: (* -> *) -> *) (p :: ((* -> *) -> *) -> * -> * -> *) s
a.
(Apply g, Alternative (p g s)) =>
Fixed p g s a -> Fixed p g s a
general)
fixDescendants :: forall g. (Rank2.Apply g, Rank2.Traversable g)
=> g (Const (g (Const (ParserFlags g)) -> (ParserFlags g))) -> g (Const (ParserFlags g))
fixDescendants :: forall (g :: (* -> *) -> *).
(Apply g, Traversable g) =>
g (Const (g (Const (ParserFlags g)) -> ParserFlags g))
-> g (Const (ParserFlags g))
fixDescendants g (Const (g (Const (ParserFlags g)) -> ParserFlags g))
gf = g (Const (ParserFlags g)) -> g (Const (ParserFlags g))
go g (Const (ParserFlags g))
initial
where go :: g (Const (ParserFlags g)) -> g (Const (ParserFlags g))
go :: g (Const (ParserFlags g)) -> g (Const (ParserFlags g))
go g (Const (ParserFlags g))
cd
| All -> Bool
getAll (forall {k} (g :: (k -> *) -> *) m (p :: k -> *).
(Foldable g, Monoid m) =>
(forall (a :: k). p a -> m) -> g p -> m
Rank2.foldMap (Bool -> All
All forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall {k} a (b :: k). Const a b -> a
getConst) forall a b. (a -> b) -> a -> b
$ forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *)
(r :: k -> *).
Apply g =>
(forall (a :: k). p a -> q a -> r a) -> g p -> g q -> g r
Rank2.liftA2 forall {g :: (* -> *) -> *} {b} {b} {b}.
(Foldable g, Apply g) =>
Const (ParserFlags g) b -> Const (ParserFlags g) b -> Const Bool b
agree g (Const (ParserFlags g))
cd g (Const (ParserFlags g))
cd') = g (Const (ParserFlags g))
cd
| Bool
otherwise = g (Const (ParserFlags g)) -> g (Const (ParserFlags g))
go g (Const (ParserFlags g))
cd'
where cd' :: g (Const (ParserFlags g))
cd' = forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *)
(r :: k -> *).
Apply g =>
(forall (a :: k). p a -> q a -> r a) -> g p -> g q -> g r
Rank2.liftA2 forall {g :: (* -> *) -> *} {b} {b} {b}.
Apply g =>
Const (ParserFlags g) b
-> Const (ParserFlags g) b -> Const (ParserFlags g) b
flagUnion g (Const (ParserFlags g))
cd (forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *).
Functor g =>
(forall (a :: k). p a -> q a) -> g p -> g q
Rank2.fmap (\(Const g (Const (ParserFlags g)) -> ParserFlags g
f)-> forall {k} a (b :: k). a -> Const a b
Const (g (Const (ParserFlags g)) -> ParserFlags g
f g (Const (ParserFlags g))
cd)) g (Const (g (Const (ParserFlags g)) -> ParserFlags g))
gf)
agree :: Const (ParserFlags g) b -> Const (ParserFlags g) b -> Const Bool b
agree (Const (ParserFlags Bool
_xn (StaticDependencies g (Const Bool)
xd))) (Const (ParserFlags Bool
_yn (StaticDependencies g (Const Bool)
yd))) =
forall {k} a (b :: k). a -> Const a b
Const (All -> Bool
getAll (forall {k} (g :: (k -> *) -> *) m (p :: k -> *).
(Foldable g, Monoid m) =>
(forall (a :: k). p a -> m) -> g p -> m
Rank2.foldMap (Bool -> All
All forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall {k} a (b :: k). Const a b -> a
getConst) (forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *)
(r :: k -> *).
Apply g =>
(forall (a :: k). p a -> q a -> r a) -> g p -> g q -> g r
Rank2.liftA2 forall {a} {b} {b} {b}.
Eq a =>
Const a b -> Const a b -> Const Bool b
agree' g (Const Bool)
xd g (Const Bool)
yd)))
agree (Const (ParserFlags Bool
_xn Dependencies g
DynamicDependencies)) (Const (ParserFlags Bool
_yn Dependencies g
DynamicDependencies)) = forall {k} a (b :: k). a -> Const a b
Const Bool
True
agree Const (ParserFlags g) b
_ Const (ParserFlags g) b
_ = forall {k} a (b :: k). a -> Const a b
Const Bool
False
agree' :: Const a b -> Const a b -> Const Bool b
agree' (Const a
x) (Const a
y) = forall {k} a (b :: k). a -> Const a b
Const (a
x forall a. Eq a => a -> a -> Bool
== a
y)
flagUnion :: Const (ParserFlags g) b
-> Const (ParserFlags g) b -> Const (ParserFlags g) b
flagUnion (Const ParserFlags{dependsOn :: forall (g :: (* -> *) -> *). ParserFlags g -> Dependencies g
dependsOn= Dependencies g
old}) (Const (ParserFlags Bool
n Dependencies g
new)) =
forall {k} a (b :: k). a -> Const a b
Const (forall (g :: (* -> *) -> *).
Bool -> Dependencies g -> ParserFlags g
ParserFlags Bool
n forall a b. (a -> b) -> a -> b
$ forall (g :: (* -> *) -> *).
Apply g =>
Dependencies g -> Dependencies g -> Dependencies g
depUnion Dependencies g
old Dependencies g
new)
initial :: g (Const (ParserFlags g))
initial = forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *)
(r :: k -> *).
Apply g =>
(forall (a :: k). p a -> q a -> r a) -> g p -> g q -> g r
Rank2.liftA2 (\Const (g (Const (ParserFlags g)) -> ParserFlags g) a
_ (Const Bool
n)-> forall {k} a (b :: k). a -> Const a b
Const (forall (g :: (* -> *) -> *).
Bool -> Dependencies g -> ParserFlags g
ParserFlags Bool
n Dependencies g
deps)) g (Const (g (Const (ParserFlags g)) -> ParserFlags g))
gf g (Const Bool)
nullabilities
deps :: Dependencies g
deps = forall (g :: (* -> *) -> *). g (Const Bool) -> Dependencies g
StaticDependencies (forall a b. a -> b -> a
const (forall {k} a (b :: k). a -> Const a b
Const Bool
False) forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *).
Functor g =>
(forall (a :: k). p a -> q a) -> g p -> g q
Rank2.<$> g (Const (g (Const (ParserFlags g)) -> ParserFlags g))
gf)
nullabilities :: g (Const Bool)
nullabilities = forall (g :: (* -> *) -> *).
(Apply g, Traversable g) =>
g (Const (g (Const (ParserFlags g)) -> ParserFlags g))
-> g (Const Bool)
fixNullabilities g (Const (g (Const (ParserFlags g)) -> ParserFlags g))
gf
{-# INLINABLE fixDescendants #-}
fixNullabilities :: forall g. (Rank2.Apply g, Rank2.Traversable g)
=> g (Const (g (Const (ParserFlags g)) -> (ParserFlags g))) -> g (Const Bool)
fixNullabilities :: forall (g :: (* -> *) -> *).
(Apply g, Traversable g) =>
g (Const (g (Const (ParserFlags g)) -> ParserFlags g))
-> g (Const Bool)
fixNullabilities g (Const (g (Const (ParserFlags g)) -> ParserFlags g))
gf = forall {k} a (b :: k). a -> Const a b
Const forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (g :: (* -> *) -> *). ParserFlags g -> Bool
nullable forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall {k} a (b :: k). Const a b -> a
getConst forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *).
Functor g =>
(forall (a :: k). p a -> q a) -> g p -> g q
Rank2.<$> g (Const (ParserFlags g)) -> g (Const (ParserFlags g))
go g (Const (ParserFlags g))
initial
where go :: g (Const (ParserFlags g)) -> g (Const (ParserFlags g))
go :: g (Const (ParserFlags g)) -> g (Const (ParserFlags g))
go g (Const (ParserFlags g))
cd
| All -> Bool
getAll (forall {k} (g :: (k -> *) -> *) m (p :: k -> *).
(Foldable g, Monoid m) =>
(forall (a :: k). p a -> m) -> g p -> m
Rank2.foldMap (Bool -> All
All forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall {k} a (b :: k). Const a b -> a
getConst) forall a b. (a -> b) -> a -> b
$ forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *)
(r :: k -> *).
Apply g =>
(forall (a :: k). p a -> q a -> r a) -> g p -> g q -> g r
Rank2.liftA2 forall {g :: (* -> *) -> *} {b} {g :: (* -> *) -> *} {b} {b}.
Const (ParserFlags g) b -> Const (ParserFlags g) b -> Const Bool b
agree g (Const (ParserFlags g))
cd g (Const (ParserFlags g))
cd') = g (Const (ParserFlags g))
cd
| Bool
otherwise = g (Const (ParserFlags g)) -> g (Const (ParserFlags g))
go g (Const (ParserFlags g))
cd'
where cd' :: g (Const (ParserFlags g))
cd' = forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *).
Functor g =>
(forall (a :: k). p a -> q a) -> g p -> g q
Rank2.fmap (\(Const g (Const (ParserFlags g)) -> ParserFlags g
f)-> forall {k} a (b :: k). a -> Const a b
Const (g (Const (ParserFlags g)) -> ParserFlags g
f g (Const (ParserFlags g))
cd)) g (Const (g (Const (ParserFlags g)) -> ParserFlags g))
gf
agree :: Const (ParserFlags g) b -> Const (ParserFlags g) b -> Const Bool b
agree (Const ParserFlags g
flags1) (Const ParserFlags g
flags2) = forall {k} a (b :: k). a -> Const a b
Const (forall (g :: (* -> *) -> *). ParserFlags g -> Bool
nullable ParserFlags g
flags1 forall a. Eq a => a -> a -> Bool
== forall (g :: (* -> *) -> *). ParserFlags g -> Bool
nullable ParserFlags g
flags2)
initial :: g (Const (ParserFlags g))
initial = forall a b. a -> b -> a
const (forall {k} a (b :: k). a -> Const a b
Const (forall (g :: (* -> *) -> *).
Bool -> Dependencies g -> ParserFlags g
ParserFlags Bool
True (forall (g :: (* -> *) -> *). g (Const Bool) -> Dependencies g
StaticDependencies forall a b. (a -> b) -> a -> b
$ forall a b. a -> b -> a
const (forall {k} a (b :: k). a -> Const a b
Const Bool
False) forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *).
Functor g =>
(forall (a :: k). p a -> q a) -> g p -> g q
Rank2.<$> g (Const (g (Const (ParserFlags g)) -> ParserFlags g))
gf))) forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *).
Functor g =>
(forall (a :: k). p a -> q a) -> g p -> g q
Rank2.<$> g (Const (g (Const (ParserFlags g)) -> ParserFlags g))
gf
{-# INLINABLE fixNullabilities #-}
parseSeparated :: forall p g rl s. (Rank2.Apply g, Rank2.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)))]
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)))]
parseSeparated g (SeparatedParser p g s)
parsers s
input = forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr s -> [(s, g (rl s))] -> [(s, g (rl s))]
parseTail [] (forall m. FactorialMonoid m => m -> [m]
Factorial.tails s
input)
where parseTail :: s -> [(s, g (rl s))] -> [(s, g (rl s))]
parseTail s
s [(s, g (rl s))]
parsedTail = [(s, g (rl s))]
parsed
where parsed :: [(s, g (rl s))]
parsed = (s
s,g (rl s)
d'')forall a. a -> [a] -> [a]
:[(s, g (rl s))]
parsedTail
d :: g (rl s)
d = forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *).
Functor g =>
(forall (a :: k). p a -> q a) -> g p -> g q
Rank2.fmap ((forall a b. (a -> b) -> a -> b
$ (s
s,g (rl s)
d)forall a. a -> [a] -> [a]
:[(s, g (rl s))]
parsedTail) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *) (g :: (* -> *) -> *) r.
(TailsParsing m, GrammarConstraint m g) =>
m r
-> [(ParserInput m, g (GrammarFunctor m))] -> GrammarFunctor m r
parseTails) g (p g s)
directs
d' :: g (GrammarFunctor (p g s))
d' = s
-> [(s, g (GrammarFunctor (p g s)))]
-> g (GrammarFunctor (p g s))
-> g (GrammarFunctor (p g s))
fixRecursive s
s [(s, g (rl s))]
parsedTail g (rl s)
d
d'' :: g (rl s)
d'' = forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *)
(r :: k -> *).
Apply g =>
(forall (a :: k). p a -> q a -> r a) -> g p -> g q -> g r
Rank2.liftA2 forall a.
SeparatedParser p g s a
-> GrammarFunctor (p g s) a -> GrammarFunctor (p g s) a
f g (SeparatedParser p g s)
parsers g (GrammarFunctor (p g s))
d'
f :: forall a. SeparatedParser p g s a -> GrammarFunctor (p g s) a -> GrammarFunctor (p g s) a
f :: forall a.
SeparatedParser p g s a
-> GrammarFunctor (p g s) a -> GrammarFunctor (p g s) a
f (FrontParser p g s a
p) GrammarFunctor (p g s) a
_ = forall (m :: * -> *) (g :: (* -> *) -> *) r.
(TailsParsing m, GrammarConstraint m g) =>
m r
-> [(ParserInput m, g (GrammarFunctor m))] -> GrammarFunctor m r
parseTails p g s a
p ((s
s,g (rl s)
d'')forall a. a -> [a] -> [a]
:[(s, g (rl s))]
parsedTail)
f SeparatedParser p g s a
_ GrammarFunctor (p g s) a
result = GrammarFunctor (p g s) a
result
fixRecursive :: s -> [(s, g (GrammarFunctor (p g s)))]
-> g (GrammarFunctor (p g s)) -> g (GrammarFunctor (p g s))
whileAnyContinues :: (g (GrammarFunctor (p g s)) -> g (GrammarFunctor (p g s)))
-> (g (GrammarFunctor (p g s)) -> g (GrammarFunctor (p g s)))
-> g (GrammarFunctor (p g s)) -> g (GrammarFunctor (p g s)) -> g (GrammarFunctor (p g s))
recurseTotal :: s -> g (GrammarFunctor (p g s) Rank2.~> GrammarFunctor (p g s))
-> [(s, g (GrammarFunctor (p g s)))]
-> g (GrammarFunctor (p g s))
-> g (GrammarFunctor (p g s))
recurseMarginal :: s -> [(s, g (GrammarFunctor (p g s)))]
-> g (GrammarFunctor (p g s))
-> g (GrammarFunctor (p g s))
maybeDependencies :: g (Const (Maybe (Dependencies g)))
maybeDependency :: SeparatedParser p g s r -> Const (Maybe (Dependencies g)) r
appends :: g (ResultAppend p g s)
parserAppend :: SeparatedParser p g s r -> ResultAppend p g s r
directs :: g (p g s)
directs = forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *).
Functor g =>
(forall (a :: k). p a -> q a) -> g p -> g q
Rank2.fmap forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
SeparatedParser p g s a -> p g s a
backParser g (SeparatedParser p g s)
parsers
indirects :: g (p g s)
indirects = forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *).
Functor g =>
(forall (a :: k). p a -> q a) -> g p -> g q
Rank2.fmap (\SeparatedParser p g s a
p-> case SeparatedParser p g s a
p of {CycleParser{}-> forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
SeparatedParser p g s a -> p g s a
cycleParser SeparatedParser p g s a
p; SeparatedParser p g s a
_ -> forall (f :: * -> *) a. Alternative f => f a
empty}) g (SeparatedParser p g s)
parsers
appends :: g (ResultAppend p g s)
appends = forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *).
Functor g =>
(forall (a :: k). p a -> q a) -> g p -> g q
Rank2.fmap forall r. SeparatedParser p g s r -> ResultAppend p g s r
parserAppend g (SeparatedParser p g s)
parsers
parserAppend :: forall r. SeparatedParser p g s r -> ResultAppend p g s r
parserAppend p :: SeparatedParser p g s r
p@CycleParser{} = forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
SeparatedParser p g s a -> ResultAppend p g s a
appendResultsArrow SeparatedParser p g s r
p
parserAppend SeparatedParser p g s r
_ = forall {k} (p :: k -> *) (q :: k -> *) (a :: k).
(p a -> q a) -> Arrow p q a
Rank2.Arrow (forall {k} (p :: k -> *) (q :: k -> *) (a :: k).
(p a -> q a) -> Arrow p q a
Rank2.Arrow forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. a -> b -> a
const)
maybeDependencies :: g (Const (Maybe (Dependencies g)))
maybeDependencies = forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *).
Functor g =>
(forall (a :: k). p a -> q a) -> g p -> g q
Rank2.fmap forall r.
SeparatedParser p g s r -> Const (Maybe (Dependencies g)) r
maybeDependency g (SeparatedParser p g s)
parsers
maybeDependency :: forall r.
SeparatedParser p g s r -> Const (Maybe (Dependencies g)) r
maybeDependency p :: SeparatedParser p g s r
p@CycleParser{} = forall {k} a (b :: k). a -> Const a b
Const (forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$ forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
SeparatedParser p g s a -> Dependencies g
dependencies SeparatedParser p g s r
p)
maybeDependency SeparatedParser p g s r
_ = forall {k} a (b :: k). a -> Const a b
Const forall a. Maybe a
Nothing
fixRecursive :: s
-> [(s, g (GrammarFunctor (p g s)))]
-> g (GrammarFunctor (p g s))
-> g (GrammarFunctor (p g s))
fixRecursive s
s [(s, g (GrammarFunctor (p g s)))]
parsedTail g (GrammarFunctor (p g s))
initial =
(g (GrammarFunctor (p g s)) -> g (GrammarFunctor (p g s)))
-> (g (GrammarFunctor (p g s)) -> g (GrammarFunctor (p g s)))
-> g (GrammarFunctor (p g s))
-> g (GrammarFunctor (p g s))
-> g (GrammarFunctor (p g s))
whileAnyContinues (s
-> g (GrammarFunctor (p g s) ~> GrammarFunctor (p g s))
-> [(s, g (GrammarFunctor (p g s)))]
-> g (GrammarFunctor (p g s))
-> g (GrammarFunctor (p g s))
recurseTotal s
s (g (ResultAppend p g s)
appends forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *).
Apply g =>
g (p ~> q) -> g p -> g q
Rank2.<*> g (GrammarFunctor (p g s))
initial) [(s, g (GrammarFunctor (p g s)))]
parsedTail)
(s
-> [(s, g (GrammarFunctor (p g s)))]
-> g (GrammarFunctor (p g s))
-> g (GrammarFunctor (p g s))
recurseMarginal s
s [(s, g (GrammarFunctor (p g s)))]
parsedTail)
g (GrammarFunctor (p g s))
initial g (GrammarFunctor (p g s))
initial
whileAnyContinues :: (g (GrammarFunctor (p g s)) -> g (GrammarFunctor (p g s)))
-> (g (GrammarFunctor (p g s)) -> g (GrammarFunctor (p g s)))
-> g (GrammarFunctor (p g s))
-> g (GrammarFunctor (p g s))
-> g (GrammarFunctor (p g s))
whileAnyContinues g (GrammarFunctor (p g s)) -> g (GrammarFunctor (p g s))
ft g (GrammarFunctor (p g s)) -> g (GrammarFunctor (p g s))
fm g (GrammarFunctor (p g s))
total g (GrammarFunctor (p g s))
marginal =
forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *)
(r :: k -> *) (s :: k -> *).
Apply g =>
(forall (a :: k). p a -> q a -> r a -> s a)
-> g p -> g q -> g r -> g s
Rank2.liftA3 forall x.
Const (Maybe (Dependencies g)) x
-> GrammarFunctor (p g s) x
-> GrammarFunctor (p g s) x
-> GrammarFunctor (p g s) x
choiceWhile g (Const (Maybe (Dependencies g)))
maybeDependencies g (GrammarFunctor (p g s))
total ((g (GrammarFunctor (p g s)) -> g (GrammarFunctor (p g s)))
-> (g (GrammarFunctor (p g s)) -> g (GrammarFunctor (p g s)))
-> g (GrammarFunctor (p g s))
-> g (GrammarFunctor (p g s))
-> g (GrammarFunctor (p g s))
whileAnyContinues g (GrammarFunctor (p g s)) -> g (GrammarFunctor (p g s))
ft g (GrammarFunctor (p g s)) -> g (GrammarFunctor (p g s))
fm (g (GrammarFunctor (p g s)) -> g (GrammarFunctor (p g s))
ft g (GrammarFunctor (p g s))
total) (g (GrammarFunctor (p g s)) -> g (GrammarFunctor (p g s))
fm g (GrammarFunctor (p g s))
marginal))
where choiceWhile :: Const (Maybe (Dependencies g)) x
-> GrammarFunctor (p g s) x -> GrammarFunctor (p g s) x
-> GrammarFunctor (p g s) x
choiceWhile :: forall x.
Const (Maybe (Dependencies g)) x
-> GrammarFunctor (p g s) x
-> GrammarFunctor (p g s) x
-> GrammarFunctor (p g s) x
choiceWhile (Const Maybe (Dependencies g)
Nothing) GrammarFunctor (p g s) x
t GrammarFunctor (p g s) x
_ = GrammarFunctor (p g s) x
t
choiceWhile (Const (Just (StaticDependencies g (Const Bool)
deps))) GrammarFunctor (p g s) x
t GrammarFunctor (p g s) x
t'
| Any -> Bool
getAny (forall {k} (g :: (k -> *) -> *) m (p :: k -> *).
(Foldable g, Monoid m) =>
(forall (a :: k). p a -> m) -> g p -> m
Rank2.foldMap (Bool -> Any
Any forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall {k} a (b :: k). Const a b -> a
getConst) (forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *)
(r :: k -> *).
Apply g =>
(forall (a :: k). p a -> q a -> r a) -> g p -> g q -> g r
Rank2.liftA2 forall x. Const Bool x -> GrammarFunctor (p g s) x -> Const Bool x
combine g (Const Bool)
deps g (GrammarFunctor (p g s))
marginal)) = GrammarFunctor (p g s) x
t'
| forall (f :: * -> * -> *) s a. FallibleResults f => f s a -> Bool
hasSuccess GrammarFunctor (p g s) x
t = GrammarFunctor (p g s) x
t
| Bool
otherwise =
forall (f :: * -> * -> *) s a.
FallibleResults f =>
ParseFailure (Down Int) s -> f s a
failWith (forall (f :: * -> * -> *) s a.
FallibleResults f =>
f s a -> ParseFailure (Down Int) s
failureOf forall a b. (a -> b) -> a -> b
$
if Any -> Bool
getAny (forall {k} (g :: (k -> *) -> *) m (p :: k -> *).
(Foldable g, Monoid m) =>
(forall (a :: k). p a -> m) -> g p -> m
Rank2.foldMap (Bool -> Any
Any forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall {k} a (b :: k). Const a b -> a
getConst) forall a b. (a -> b) -> a -> b
$
forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *)
(r :: k -> *).
Apply g =>
(forall (a :: k). p a -> q a -> r a) -> g p -> g q -> g r
Rank2.liftA2 (forall x.
ParseFailure (Down Int) s
-> Const Bool x -> GrammarFunctor (p g s) x -> Const Bool x
combineFailures forall a b. (a -> b) -> a -> b
$ forall (f :: * -> * -> *) s a.
FallibleResults f =>
f s a -> ParseFailure (Down Int) s
failureOf GrammarFunctor (p g s) x
t) g (Const Bool)
deps g (GrammarFunctor (p g s))
marginal)
then GrammarFunctor (p g s) x
t' else GrammarFunctor (p g s) x
t)
where combine :: Const Bool x -> GrammarFunctor (p g s) x -> Const Bool x
combineFailures :: ParseFailure Pos s -> Const Bool x -> GrammarFunctor (p g s) x
-> Const Bool x
combine :: forall x. Const Bool x -> GrammarFunctor (p g s) x -> Const Bool x
combine (Const Bool
False) GrammarFunctor (p g s) x
_ = forall {k} a (b :: k). a -> Const a b
Const Bool
False
combine (Const Bool
True) GrammarFunctor (p g s) x
results = forall {k} a (b :: k). a -> Const a b
Const (forall (f :: * -> * -> *) s a. FallibleResults f => f s a -> Bool
hasSuccess GrammarFunctor (p g s) x
results)
combineFailures :: forall x.
ParseFailure (Down Int) s
-> Const Bool x -> GrammarFunctor (p g s) x -> Const Bool x
combineFailures ParseFailure (Down Int) s
_ (Const Bool
False) GrammarFunctor (p g s) x
_ = forall {k} a (b :: k). a -> Const a b
Const Bool
False
combineFailures (ParseFailure Down Int
pos (FailureDescription [String]
expected [s]
inputs) [String]
errors) (Const Bool
True) GrammarFunctor (p g s) x
rl =
forall {k} a (b :: k). a -> Const a b
Const (Down Int
pos forall a. Ord a => a -> a -> Bool
< Down Int
pos'
Bool -> Bool -> Bool
|| Down Int
pos forall a. Eq a => a -> a -> Bool
== Down Int
pos' Bool -> Bool -> Bool
&& (forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any (forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`notElem` [String]
expected) [String]
expected'
Bool -> Bool -> Bool
|| forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any (forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`notElem` [String]
expected) [String]
expected')
Bool -> Bool -> Bool
|| forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any (forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`notElem` [String]
errors) [String]
errors')
where ParseFailure Down Int
pos' (FailureDescription [String]
expected' [s]
inputs') [String]
errors' = forall (f :: * -> * -> *) s a.
FallibleResults f =>
f s a -> ParseFailure (Down Int) s
failureOf GrammarFunctor (p g s) x
rl
choiceWhile (Const (Just Dependencies g
DynamicDependencies)) GrammarFunctor (p g s) x
t GrammarFunctor (p g s) x
t'
| Any -> Bool
getAny (forall {k} (g :: (k -> *) -> *) m (p :: k -> *).
(Foldable g, Monoid m) =>
(forall (a :: k). p a -> m) -> g p -> m
Rank2.foldMap (Bool -> Any
Any forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: * -> * -> *) s a. FallibleResults f => f s a -> Bool
hasSuccess) g (GrammarFunctor (p g s))
marginal) = GrammarFunctor (p g s) x
t'
| forall (f :: * -> * -> *) s a. FallibleResults f => f s a -> Bool
hasSuccess GrammarFunctor (p g s) x
t = GrammarFunctor (p g s) x
t
| ParseFailure Down Int
_ (FailureDescription [] []) [] <- forall (f :: * -> * -> *) s a.
FallibleResults f =>
f s a -> ParseFailure (Down Int) s
failureOf GrammarFunctor (p g s) x
t = GrammarFunctor (p g s) x
t'
| Bool
otherwise = GrammarFunctor (p g s) x
t
recurseTotal :: s
-> g (GrammarFunctor (p g s) ~> GrammarFunctor (p g s))
-> [(s, g (GrammarFunctor (p g s)))]
-> g (GrammarFunctor (p g s))
-> g (GrammarFunctor (p g s))
recurseTotal s
s g (GrammarFunctor (p g s) ~> GrammarFunctor (p g s))
initialAppends [(s, g (GrammarFunctor (p g s)))]
parsedTail g (GrammarFunctor (p g s))
total = forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *)
(r :: k -> *).
Apply g =>
(forall (a :: k). p a -> q a -> r a) -> g p -> g q -> g r
Rank2.liftA2 forall a.
(~>) (GrammarFunctor (p g s)) (GrammarFunctor (p g s)) a
-> p g s a -> GrammarFunctor (p g s) a
reparse g (GrammarFunctor (p g s) ~> GrammarFunctor (p g s))
initialAppends g (p g s)
indirects
where reparse :: (GrammarFunctor (p g s) Rank2.~> GrammarFunctor (p g s)) a -> p g s a
-> GrammarFunctor (p g s) a
reparse :: forall a.
(~>) (GrammarFunctor (p g s)) (GrammarFunctor (p g s)) a
-> p g s a -> GrammarFunctor (p g s) a
reparse (~>) (GrammarFunctor (p g s)) (GrammarFunctor (p g s)) a
append p g s a
p = forall {k} (p :: k -> *) (q :: k -> *) (a :: k).
Arrow p q a -> p a -> q a
Rank2.apply (~>) (GrammarFunctor (p g s)) (GrammarFunctor (p g s)) a
append (forall (m :: * -> *) (g :: (* -> *) -> *) r.
(TailsParsing m, GrammarConstraint m g) =>
m r
-> [(ParserInput m, g (GrammarFunctor m))] -> GrammarFunctor m r
parseTails p g s a
p forall a b. (a -> b) -> a -> b
$ (s
s, g (GrammarFunctor (p g s))
total) forall a. a -> [a] -> [a]
: [(s, g (GrammarFunctor (p g s)))]
parsedTail)
recurseMarginal :: s
-> [(s, g (GrammarFunctor (p g s)))]
-> g (GrammarFunctor (p g s))
-> g (GrammarFunctor (p g s))
recurseMarginal s
s [(s, g (GrammarFunctor (p g s)))]
parsedTail g (GrammarFunctor (p g s))
marginal =
forall a b c. (a -> b -> c) -> b -> a -> c
flip forall (m :: * -> *) (g :: (* -> *) -> *) r.
(TailsParsing m, GrammarConstraint m g) =>
m r
-> [(ParserInput m, g (GrammarFunctor m))] -> GrammarFunctor m r
parseTails ((s
s, g (GrammarFunctor (p g s))
marginal) forall a. a -> [a] -> [a]
: [(s, g (GrammarFunctor (p g s)))]
parsedTail) forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *).
Functor g =>
(forall (a :: k). p a -> q a) -> g p -> g q
Rank2.<$> g (p g s)
indirects
{-# NOINLINE parseSeparated #-}