module Language.Parser.Ptera.Machine.PEG where import Language.Parser.Ptera.Prelude import qualified Data.EnumMap.Strict as EnumMap import qualified Language.Parser.Ptera.Data.Alignable as Alignable import qualified Language.Parser.Ptera.Data.Alignable.Array as AlignableArray type T = PEG data PEG start varDoc altDoc a = PEG { PEG start varDoc altDoc a -> T VarNum (Var varDoc) vars :: AlignableArray.T VarNum (Var varDoc) , PEG start varDoc altDoc a -> T VarNum Rule rules :: AlignableArray.T VarNum Rule , PEG start varDoc altDoc a -> T AltNum (Alt altDoc a) alts :: AlignableArray.T AltNum (Alt altDoc a) , PEG start varDoc altDoc a -> EnumMap start VarNum initials :: EnumMap.EnumMap start VarNum } deriving (PEG start varDoc altDoc a -> PEG start varDoc altDoc a -> Bool (PEG start varDoc altDoc a -> PEG start varDoc altDoc a -> Bool) -> (PEG start varDoc altDoc a -> PEG start varDoc altDoc a -> Bool) -> Eq (PEG start varDoc altDoc a) forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a forall start varDoc altDoc a. (Eq varDoc, Eq a, Eq altDoc) => PEG start varDoc altDoc a -> PEG start varDoc altDoc a -> Bool /= :: PEG start varDoc altDoc a -> PEG start varDoc altDoc a -> Bool $c/= :: forall start varDoc altDoc a. (Eq varDoc, Eq a, Eq altDoc) => PEG start varDoc altDoc a -> PEG start varDoc altDoc a -> Bool == :: PEG start varDoc altDoc a -> PEG start varDoc altDoc a -> Bool $c== :: forall start varDoc altDoc a. (Eq varDoc, Eq a, Eq altDoc) => PEG start varDoc altDoc a -> PEG start varDoc altDoc a -> Bool Eq, Int -> PEG start varDoc altDoc a -> ShowS [PEG start varDoc altDoc a] -> ShowS PEG start varDoc altDoc a -> String (Int -> PEG start varDoc altDoc a -> ShowS) -> (PEG start varDoc altDoc a -> String) -> ([PEG start varDoc altDoc a] -> ShowS) -> Show (PEG start varDoc altDoc a) forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a forall start varDoc altDoc a. (Enum start, Show varDoc, Show a, Show altDoc, Show start) => Int -> PEG start varDoc altDoc a -> ShowS forall start varDoc altDoc a. (Enum start, Show varDoc, Show a, Show altDoc, Show start) => [PEG start varDoc altDoc a] -> ShowS forall start varDoc altDoc a. (Enum start, Show varDoc, Show a, Show altDoc, Show start) => PEG start varDoc altDoc a -> String showList :: [PEG start varDoc altDoc a] -> ShowS $cshowList :: forall start varDoc altDoc a. (Enum start, Show varDoc, Show a, Show altDoc, Show start) => [PEG start varDoc altDoc a] -> ShowS show :: PEG start varDoc altDoc a -> String $cshow :: forall start varDoc altDoc a. (Enum start, Show varDoc, Show a, Show altDoc, Show start) => PEG start varDoc altDoc a -> String showsPrec :: Int -> PEG start varDoc altDoc a -> ShowS $cshowsPrec :: forall start varDoc altDoc a. (Enum start, Show varDoc, Show a, Show altDoc, Show start) => Int -> PEG start varDoc altDoc a -> ShowS Show, a -> PEG start varDoc altDoc b -> PEG start varDoc altDoc a (a -> b) -> PEG start varDoc altDoc a -> PEG start varDoc altDoc b (forall a b. (a -> b) -> PEG start varDoc altDoc a -> PEG start varDoc altDoc b) -> (forall a b. a -> PEG start varDoc altDoc b -> PEG start varDoc altDoc a) -> Functor (PEG start varDoc altDoc) forall a b. a -> PEG start varDoc altDoc b -> PEG start varDoc altDoc a forall a b. (a -> b) -> PEG start varDoc altDoc a -> PEG start varDoc altDoc b forall start varDoc altDoc a b. a -> PEG start varDoc altDoc b -> PEG start varDoc altDoc a forall start varDoc altDoc a b. (a -> b) -> PEG start varDoc altDoc a -> PEG start varDoc altDoc b forall (f :: * -> *). (forall a b. (a -> b) -> f a -> f b) -> (forall a b. a -> f b -> f a) -> Functor f <$ :: a -> PEG start varDoc altDoc b -> PEG start varDoc altDoc a $c<$ :: forall start varDoc altDoc a b. a -> PEG start varDoc altDoc b -> PEG start varDoc altDoc a fmap :: (a -> b) -> PEG start varDoc altDoc a -> PEG start varDoc altDoc b $cfmap :: forall start varDoc altDoc a b. (a -> b) -> PEG start varDoc altDoc a -> PEG start varDoc altDoc b Functor) newtype VarNum = VarNum Int deriving (VarNum -> VarNum -> Bool (VarNum -> VarNum -> Bool) -> (VarNum -> VarNum -> Bool) -> Eq VarNum forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a /= :: VarNum -> VarNum -> Bool $c/= :: VarNum -> VarNum -> Bool == :: VarNum -> VarNum -> Bool $c== :: VarNum -> VarNum -> Bool Eq, Int -> VarNum -> ShowS [VarNum] -> ShowS VarNum -> String (Int -> VarNum -> ShowS) -> (VarNum -> String) -> ([VarNum] -> ShowS) -> Show VarNum forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a showList :: [VarNum] -> ShowS $cshowList :: [VarNum] -> ShowS show :: VarNum -> String $cshow :: VarNum -> String showsPrec :: Int -> VarNum -> ShowS $cshowsPrec :: Int -> VarNum -> ShowS Show) deriving Int -> VarNum -> Int VarNum -> Int (Int -> VarNum -> Int) -> (VarNum -> Int) -> Hashable VarNum forall a. (Int -> a -> Int) -> (a -> Int) -> Hashable a hash :: VarNum -> Int $chash :: VarNum -> Int hashWithSalt :: Int -> VarNum -> Int $chashWithSalt :: Int -> VarNum -> Int Hashable via Int deriving Coercible Int VarNum Coercible Int VarNum -> Alignable VarNum forall i. Coercible Int i -> Alignable i Alignable.T via Alignable.Inst newtype AltNum = AltNum Int deriving (AltNum -> AltNum -> Bool (AltNum -> AltNum -> Bool) -> (AltNum -> AltNum -> Bool) -> Eq AltNum forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a /= :: AltNum -> AltNum -> Bool $c/= :: AltNum -> AltNum -> Bool == :: AltNum -> AltNum -> Bool $c== :: AltNum -> AltNum -> Bool Eq, Int -> AltNum -> ShowS [AltNum] -> ShowS AltNum -> String (Int -> AltNum -> ShowS) -> (AltNum -> String) -> ([AltNum] -> ShowS) -> Show AltNum forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a showList :: [AltNum] -> ShowS $cshowList :: [AltNum] -> ShowS show :: AltNum -> String $cshow :: AltNum -> String showsPrec :: Int -> AltNum -> ShowS $cshowsPrec :: Int -> AltNum -> ShowS Show) deriving Int -> AltNum -> Int AltNum -> Int (Int -> AltNum -> Int) -> (AltNum -> Int) -> Hashable AltNum forall a. (Int -> a -> Int) -> (a -> Int) -> Hashable a hash :: AltNum -> Int $chash :: AltNum -> Int hashWithSalt :: Int -> AltNum -> Int $chashWithSalt :: Int -> AltNum -> Int Hashable via Int deriving Coercible Int AltNum Coercible Int AltNum -> Alignable AltNum forall i. Coercible Int i -> Alignable i Alignable.T via Alignable.Inst newtype Rule = Rule { Rule -> [AltNum] ruleAlts :: [AltNum] } deriving (Rule -> Rule -> Bool (Rule -> Rule -> Bool) -> (Rule -> Rule -> Bool) -> Eq Rule forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a /= :: Rule -> Rule -> Bool $c/= :: Rule -> Rule -> Bool == :: Rule -> Rule -> Bool $c== :: Rule -> Rule -> Bool Eq, Int -> Rule -> ShowS [Rule] -> ShowS Rule -> String (Int -> Rule -> ShowS) -> (Rule -> String) -> ([Rule] -> ShowS) -> Show Rule forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a showList :: [Rule] -> ShowS $cshowList :: [Rule] -> ShowS show :: Rule -> String $cshow :: Rule -> String showsPrec :: Int -> Rule -> ShowS $cshowsPrec :: Int -> Rule -> ShowS Show) newtype Var varDoc = Var { Var varDoc -> varDoc varHelp :: varDoc } deriving (Var varDoc -> Var varDoc -> Bool (Var varDoc -> Var varDoc -> Bool) -> (Var varDoc -> Var varDoc -> Bool) -> Eq (Var varDoc) forall varDoc. Eq varDoc => Var varDoc -> Var varDoc -> Bool forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a /= :: Var varDoc -> Var varDoc -> Bool $c/= :: forall varDoc. Eq varDoc => Var varDoc -> Var varDoc -> Bool == :: Var varDoc -> Var varDoc -> Bool $c== :: forall varDoc. Eq varDoc => Var varDoc -> Var varDoc -> Bool Eq, Int -> Var varDoc -> ShowS [Var varDoc] -> ShowS Var varDoc -> String (Int -> Var varDoc -> ShowS) -> (Var varDoc -> String) -> ([Var varDoc] -> ShowS) -> Show (Var varDoc) forall varDoc. Show varDoc => Int -> Var varDoc -> ShowS forall varDoc. Show varDoc => [Var varDoc] -> ShowS forall varDoc. Show varDoc => Var varDoc -> String forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a showList :: [Var varDoc] -> ShowS $cshowList :: forall varDoc. Show varDoc => [Var varDoc] -> ShowS show :: Var varDoc -> String $cshow :: forall varDoc. Show varDoc => Var varDoc -> String showsPrec :: Int -> Var varDoc -> ShowS $cshowsPrec :: forall varDoc. Show varDoc => Int -> Var varDoc -> ShowS Show, a -> Var b -> Var a (a -> b) -> Var a -> Var b (forall a b. (a -> b) -> Var a -> Var b) -> (forall a b. a -> Var b -> Var a) -> Functor Var forall a b. a -> Var b -> Var a forall a b. (a -> b) -> Var a -> Var b forall (f :: * -> *). (forall a b. (a -> b) -> f a -> f b) -> (forall a b. a -> f b -> f a) -> Functor f <$ :: a -> Var b -> Var a $c<$ :: forall a b. a -> Var b -> Var a fmap :: (a -> b) -> Var a -> Var b $cfmap :: forall a b. (a -> b) -> Var a -> Var b Functor) data Alt altDoc a = Alt { Alt altDoc a -> AltKind altKind :: AltKind , Alt altDoc a -> [Unit] altUnitSeq :: [Unit] , Alt altDoc a -> a altAction :: a , Alt altDoc a -> altDoc altHelp :: altDoc } deriving (Alt altDoc a -> Alt altDoc a -> Bool (Alt altDoc a -> Alt altDoc a -> Bool) -> (Alt altDoc a -> Alt altDoc a -> Bool) -> Eq (Alt altDoc a) forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a forall altDoc a. (Eq a, Eq altDoc) => Alt altDoc a -> Alt altDoc a -> Bool /= :: Alt altDoc a -> Alt altDoc a -> Bool $c/= :: forall altDoc a. (Eq a, Eq altDoc) => Alt altDoc a -> Alt altDoc a -> Bool == :: Alt altDoc a -> Alt altDoc a -> Bool $c== :: forall altDoc a. (Eq a, Eq altDoc) => Alt altDoc a -> Alt altDoc a -> Bool Eq, Int -> Alt altDoc a -> ShowS [Alt altDoc a] -> ShowS Alt altDoc a -> String (Int -> Alt altDoc a -> ShowS) -> (Alt altDoc a -> String) -> ([Alt altDoc a] -> ShowS) -> Show (Alt altDoc a) forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a forall altDoc a. (Show a, Show altDoc) => Int -> Alt altDoc a -> ShowS forall altDoc a. (Show a, Show altDoc) => [Alt altDoc a] -> ShowS forall altDoc a. (Show a, Show altDoc) => Alt altDoc a -> String showList :: [Alt altDoc a] -> ShowS $cshowList :: forall altDoc a. (Show a, Show altDoc) => [Alt altDoc a] -> ShowS show :: Alt altDoc a -> String $cshow :: forall altDoc a. (Show a, Show altDoc) => Alt altDoc a -> String showsPrec :: Int -> Alt altDoc a -> ShowS $cshowsPrec :: forall altDoc a. (Show a, Show altDoc) => Int -> Alt altDoc a -> ShowS Show, a -> Alt altDoc b -> Alt altDoc a (a -> b) -> Alt altDoc a -> Alt altDoc b (forall a b. (a -> b) -> Alt altDoc a -> Alt altDoc b) -> (forall a b. a -> Alt altDoc b -> Alt altDoc a) -> Functor (Alt altDoc) forall a b. a -> Alt altDoc b -> Alt altDoc a forall a b. (a -> b) -> Alt altDoc a -> Alt altDoc b forall altDoc a b. a -> Alt altDoc b -> Alt altDoc a forall altDoc a b. (a -> b) -> Alt altDoc a -> Alt altDoc b forall (f :: * -> *). (forall a b. (a -> b) -> f a -> f b) -> (forall a b. a -> f b -> f a) -> Functor f <$ :: a -> Alt altDoc b -> Alt altDoc a $c<$ :: forall altDoc a b. a -> Alt altDoc b -> Alt altDoc a fmap :: (a -> b) -> Alt altDoc a -> Alt altDoc b $cfmap :: forall altDoc a b. (a -> b) -> Alt altDoc a -> Alt altDoc b Functor) data AltKind = AltSeq | AltNot | AltAnd deriving (AltKind -> AltKind -> Bool (AltKind -> AltKind -> Bool) -> (AltKind -> AltKind -> Bool) -> Eq AltKind forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a /= :: AltKind -> AltKind -> Bool $c/= :: AltKind -> AltKind -> Bool == :: AltKind -> AltKind -> Bool $c== :: AltKind -> AltKind -> Bool Eq, Int -> AltKind -> ShowS [AltKind] -> ShowS AltKind -> String (Int -> AltKind -> ShowS) -> (AltKind -> String) -> ([AltKind] -> ShowS) -> Show AltKind forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a showList :: [AltKind] -> ShowS $cshowList :: [AltKind] -> ShowS show :: AltKind -> String $cshow :: AltKind -> String showsPrec :: Int -> AltKind -> ShowS $cshowsPrec :: Int -> AltKind -> ShowS Show) data Unit = UnitTerminal Terminal | UnitNonTerminal VarNum deriving (Unit -> Unit -> Bool (Unit -> Unit -> Bool) -> (Unit -> Unit -> Bool) -> Eq Unit forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a /= :: Unit -> Unit -> Bool $c/= :: Unit -> Unit -> Bool == :: Unit -> Unit -> Bool $c== :: Unit -> Unit -> Bool Eq, Int -> Unit -> ShowS [Unit] -> ShowS Unit -> String (Int -> Unit -> ShowS) -> (Unit -> String) -> ([Unit] -> ShowS) -> Show Unit forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a showList :: [Unit] -> ShowS $cshowList :: [Unit] -> ShowS show :: Unit -> String $cshow :: Unit -> String showsPrec :: Int -> Unit -> ShowS $cshowsPrec :: Int -> Unit -> ShowS Show) type Terminal = Int