-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A parser generator -- -- Ptera is haskell libraries and toolchains for generating parser. @package ptera-th @version 0.2.0.0 module Language.Parser.Ptera.TH.Data.Bits.MaxBit maxBitSize :: FiniteBits a => Ord a => Num a => a -> Int module Language.Parser.Ptera.TH.ParserLib newtype ActionM ctx ActionM :: ([ReduceArgument] -> ActionTask ctx ReduceArgument) -> ActionM ctx [$sel:runActionM:ActionM] :: ActionM ctx -> [ReduceArgument] -> ActionTask ctx ReduceArgument data ReduceArgument [ReduceArgument] :: forall a. a -> ReduceArgument data RunnerParser ctx elem altHelp RunnerParser :: (StartNum -> Maybe StateNum) -> (elem -> TokenNum) -> (StateNum -> TokenNum -> Trans) -> (AltNum -> AltKind) -> (StateNum -> [(AltNum, Int)]) -> (AltNum -> (StringLit, Maybe altHelp)) -> (AltNum -> ActionM ctx) -> RunnerParser ctx elem altHelp [$sel:parserInitial:RunnerParser] :: RunnerParser ctx elem altHelp -> StartNum -> Maybe StateNum [$sel:parserGetTokenNum:RunnerParser] :: RunnerParser ctx elem altHelp -> elem -> TokenNum [$sel:parserTrans:RunnerParser] :: RunnerParser ctx elem altHelp -> StateNum -> TokenNum -> Trans [$sel:parserAltKind:RunnerParser] :: RunnerParser ctx elem altHelp -> AltNum -> AltKind [$sel:parserStateHelp:RunnerParser] :: RunnerParser ctx elem altHelp -> StateNum -> [(AltNum, Int)] [$sel:parserAltHelp:RunnerParser] :: RunnerParser ctx elem altHelp -> AltNum -> (StringLit, Maybe altHelp) [$sel:parserAction:RunnerParser] :: RunnerParser ctx elem altHelp -> AltNum -> ActionM ctx data Trans Trans :: StateNum -> [TransOp] -> Trans [$sel:transState:Trans] :: Trans -> StateNum [$sel:transOps:Trans] :: Trans -> [TransOp] data TransOp TransOpEnter :: VarNum -> Bool -> StateNum -> TransOp TransOpPushBackpoint :: StateNum -> TransOp TransOpHandleNot :: AltNum -> TransOp TransOpShift :: TransOp TransOpReduce :: AltNum -> TransOp failAction :: ActionTask ctx a modifyAction :: (ctx -> ctx) -> ActionTask ctx () getAction :: ActionTask ctx ctx data ActionTask ctx a class GrammarToken tokens elem tokenToTerminal :: GrammarToken tokens elem => Proxy tokens -> elem -> T (TokensTag tokens) data AltKind AltSeq :: AltKind AltNot :: AltKind AltAnd :: AltKind -- | Proxy is a type that holds no data, but has a phantom parameter -- of arbitrary type (or even kind). Its use is to provide type -- information, even though there is no value available of that type (or -- it may be too costly to create one). -- -- Historically, Proxy :: Proxy a is a safer -- alternative to the undefined :: a idiom. -- --
-- >>> Proxy :: Proxy (Void, Int -> Int) -- Proxy ---- -- Proxy can even hold types of higher kinds, -- --
-- >>> Proxy :: Proxy Either -- Proxy ---- --
-- >>> Proxy :: Proxy Functor -- Proxy ---- --
-- >>> Proxy :: Proxy complicatedStructure -- Proxy --data Proxy (t :: k) Proxy :: Proxy (t :: k) type Parser = T pteraTHTokenToTerminal :: GrammarToken tokens elem => Proxy tokens -> elem -> Int pteraTHArrayIndex :: Array Int e -> Int -> e pteraTHArrayFromList :: Int -> [e] -> Array Int e pteraTHLookupTable8 :: Int -> Addr# -> Int -> Int -> Int pteraTHLookupTable16 :: Int -> Addr# -> Int -> Int -> Int pteraTHLookupTable32 :: Int -> Addr# -> Int -> Int -> Int pteraTHUnsafeExtractReduceArgument :: ReduceArgument -> a pteraTHUnsafeRunner :: RunnerParser ctx elem () -> Parser ctx rules elem initials pteraTHAction :: ([ReduceArgument] -> ActionTask ctx b) -> ActionM ctx pteraTHActionTaskPure :: a -> ActionTask ctx a module Language.Parser.Ptera.TH.Syntax type T ctx = GrammarM ctx -- | Constraint representing the fact that the field x belongs to -- the record type r and has field type a. This will be -- solved automatically, but manual instances may be provided as well. class HasField (x :: k) r a | x r -> a -- | Selector function to extract the field from the record. getField :: HasField x r a => r -> a class (KnownSymbol v, HasField v rules RuleExprType rules RuleExprReturnType rules v) => HasRuleExprField rules (v :: Symbol) where { type family RuleExprReturnType rules (v :: Symbol); } nonTerminalName :: HasRuleExprField rules v => rules -> proxy v -> String type family TokensTag tokens :: [Symbol] type family RulesTag rules :: [Symbol] type family RuleExprType rules :: Type -> Type type GrammarM ctx = Grammar (SemActM ctx) class MemberInitials rules (initials :: [Symbol]) memberInitials :: MemberInitials rules initials => T (DictF (HasRuleExprField rules)) initials class Rules rules generateRules :: Rules rules => T (DictF (HasRuleExprField rules)) (RulesTag rules) class GrammarToken tokens elem tokenToTerminal :: GrammarToken tokens elem => Proxy tokens -> elem -> T (TokensTag tokens) type RuleExprM ctx = RuleExpr (SemActM ctx) type AltM ctx = Alt (SemActM ctx) data Expr rules tokens elem (us :: [Type]) newtype SemActM ctx us a UnsafeSemActM :: Q Exp -> SemActM ctx us a [$sel:unsafeSemanticAction:UnsafeSemActM] :: SemActM ctx us a -> Q Exp semActM :: (HTExpList us -> Q (TExp (ActionTask ctx a))) -> T f us -> SemActM ctx us a data HFList (a :: k -> Type) (b :: [k]) [HFNil] :: forall k (a :: k -> Type). HFList a ('[] :: [k]) [HFCons] :: forall k (a :: k -> Type) (x :: k) (xs :: [k]). a x -> HFList a xs -> HFList a (x : xs) data DictF (a :: k -> Constraint) (b :: k) [DictF] :: forall k (a :: k -> Constraint) (b :: k). a b => DictF a b type HTExpList = T TExpQ pattern HNil :: HTExpList '[] pattern (:*) :: Q (TExp u) -> HTExpList us -> HTExpList (u : us) infixr 6 :* newtype TExpQ a TExpQ :: Q (TExp a) -> TExpQ a [$sel:unTExpQ:TExpQ] :: TExpQ a -> Q (TExp a) newtype ActionTask ctx a ActionTask :: (ctx -> ActionTaskResult ctx a) -> ActionTask ctx a [$sel:runActionTask:ActionTask] :: ActionTask ctx a -> ctx -> ActionTaskResult ctx a data ActionTaskResult ctx a ActionTaskFail :: ActionTaskResult ctx a ActionTaskResult :: a -> ActionTaskResult ctx a ActionTaskModifyResult :: ctx -> a -> ActionTaskResult ctx a getAction :: ActionTask ctx ctx modifyAction :: (ctx -> ctx) -> ActionTask ctx () failAction :: ActionTask ctx a type Grammar = GrammarM () type RuleExpr = RuleExprM () type Alt = AltM () type SemAct = SemActM () semAct :: (HTExpList us -> Q (TExp a)) -> T f us -> SemActM ctx us a fixGrammar :: forall (initials :: [Symbol]) (action :: [Type] -> Type -> Type) rules tokens elem. (MemberInitials rules initials, Rules rules, RuleExprType rules ~ RuleExpr action rules tokens elem) => rules -> Grammar action rules tokens elem initials ruleExpr :: forall (action :: [Type] -> Type -> Type) rules tokens elem a. [Alt action rules tokens elem a] -> RuleExpr action rules tokens elem a (<^>) :: forall rules tokens elem (us1 :: [Type]) (us2 :: [Type]). Expr rules tokens elem us1 -> Expr rules tokens elem us2 -> Expr rules tokens elem (Concat us1 us2) infixr 5 <^> eps :: Expr rules tokens elem ('[] :: [Type]) (<:>) :: Expr rules tokens elem us -> (HTExpList us -> Q (TExp a)) -> AltM ctx rules tokens elem a infixl 4 <:> (<::>) :: Expr rules tokens elem us -> (HTExpList us -> Q (TExp (ActionTask ctx a))) -> AltM ctx rules tokens elem a infixl 4 <::> var :: forall (v :: Symbol) proxy rules tokens elem. KnownSymbol v => proxy v -> Expr rules tokens elem '[RuleExprReturnType rules v] varA :: forall (v :: Symbol) rules tokens elem. KnownSymbol v => Expr rules tokens elem '[RuleExprReturnType rules v] tok :: forall tokens (t :: Symbol) rules elem. Membership (TokensTag tokens) t -> Expr rules tokens elem '[elem] class TokensMember tokens (t :: Symbol) tokensMembership :: TokensMember tokens t => Proxy# '(tokens, t) -> Membership (TokensTag tokens) t tokA :: forall (t :: Symbol) rules tokens elem. TokensMember tokens t => Expr rules tokens elem '[elem] module Language.Parser.Ptera.TH.Pipeline.SRB2ParserDec type SemanticAction ctx = Action (SemActM ctx) data PipelineParam PipelineParam :: Q Type -> Q Type -> Q Type -> Q Type -> Q Type -> (Int, Int) -> PipelineParam [$sel:startsTy:PipelineParam] :: PipelineParam -> Q Type [$sel:rulesTy:PipelineParam] :: PipelineParam -> Q Type [$sel:tokensTy:PipelineParam] :: PipelineParam -> Q Type [$sel:tokenTy:PipelineParam] :: PipelineParam -> Q Type [$sel:customCtxTy:PipelineParam] :: PipelineParam -> Q Type [$sel:tokenBounds:PipelineParam] :: PipelineParam -> (Int, Int) srb2QParser :: PipelineParam -> T Int StringLit (Maybe altDoc) (SemanticAction ctx) -> Q [Dec] outputParserInitialFn :: Name -> EnumMap Int StateNum -> Q Dec outputParserTransFn :: Name -> (Int, Int) -> T StateNum MState -> Q Dec genOutTransRepr :: Int -> T StateNum MState -> OutTransRepr tableAddrExp :: Int -> [Int] -> Q Exp -- | Should correspond pteraTHLookupTable* addrCodeUnitsLE :: Int -> Int -> [Word8] toTransOpsExp :: OutTransOpsRepr -> Q Exp toTransOpExp :: TransOp -> Q Exp data OutTransRepr OutTransRepr :: [Int] -> [Int] -> [Q Exp] -> Int -> HashMap OutTransOpsRepr Int -> OutTransRepr [$sel:outTransReprStates:OutTransRepr] :: OutTransRepr -> [Int] [$sel:outTransReprOpsNums:OutTransRepr] :: OutTransRepr -> [Int] [$sel:outTransReprTransOps:OutTransRepr] :: OutTransRepr -> [Q Exp] [$sel:outTransReprNextOpsNum:OutTransRepr] :: OutTransRepr -> Int [$sel:outTransReprOpsMap:OutTransRepr] :: OutTransRepr -> HashMap OutTransOpsRepr Int data OutTransOpsRepr OutTransWithOpsRepr :: [TransOp] -> OutTransOpsRepr OutTransReduce :: AltNum -> OutTransOpsRepr outputParserAltKindFn :: Name -> T AltNum (Alt altDoc a) -> Q Dec outputParserStateHelpFn :: Name -> T StateNum MState -> Q Dec outputParserAltHelpFn :: Name -> T AltNum (Alt altDoc a) -> T VarNum (Var StringLit) -> Q Dec outputParserActionFn :: Name -> T AltNum (Alt altHelp (SemanticAction ctx)) -> Q Dec outputRunnerFn :: Name -> Name -> Name -> Name -> Name -> Name -> Name -> Name -> Q Dec instance GHC.Generics.Generic Language.Parser.Ptera.TH.Pipeline.SRB2ParserDec.OutTransOpsRepr instance GHC.Show.Show Language.Parser.Ptera.TH.Pipeline.SRB2ParserDec.OutTransOpsRepr instance GHC.Classes.Eq Language.Parser.Ptera.TH.Pipeline.SRB2ParserDec.OutTransOpsRepr instance Data.Hashable.Class.Hashable Language.Parser.Ptera.TH.Pipeline.SRB2ParserDec.OutTransOpsRepr module Language.Parser.Ptera.TH.Pipeline.Grammar2ParserDec grammar2ParserDec :: forall initials rules tokens ctx elem. GrammarToken tokens elem => Generate (TokensTag tokens) => PipelineParam -> GrammarM ctx rules tokens elem initials -> Q [Dec] data PipelineParam PipelineParam :: Q Type -> Q Type -> Q Type -> Q Type -> Q Type -> PipelineParam [$sel:startsTy:PipelineParam] :: PipelineParam -> Q Type [$sel:rulesTy:PipelineParam] :: PipelineParam -> Q Type [$sel:tokensTy:PipelineParam] :: PipelineParam -> Q Type [$sel:tokenTy:PipelineParam] :: PipelineParam -> Q Type [$sel:customCtxTy:PipelineParam] :: PipelineParam -> Q Type module Language.Parser.Ptera.TH.Util genGrammarToken :: Name -> Q Type -> [(String, Q Pat)] -> Q [Dec] data GenRulesTypes GenRulesTypes :: Q Type -> Q Type -> Q Type -> GenRulesTypes [$sel:genRulesCtxTy:GenRulesTypes] :: GenRulesTypes -> Q Type [$sel:genRulesTokensTy:GenRulesTypes] :: GenRulesTypes -> Q Type [$sel:genRulesTokenTy:GenRulesTypes] :: GenRulesTypes -> Q Type genRules :: Name -> GenRulesTypes -> [(Name, String, Q Type)] -> Q [Dec] genParsePoints :: Name -> Name -> [String] -> Q [Dec] newtype HEnum (as :: [k]) UnsafeHEnum :: Int -> HEnum (as :: [k]) [$sel:unsafeHEnum:UnsafeHEnum] :: HEnum (as :: [k]) -> Int unsafeMembership :: Int -> Membership xs x module Language.Parser.Ptera.TH -- | Constraint representing the fact that the field x belongs to -- the record type r and has field type a. This will be -- solved automatically, but manual instances may be provided as well. class HasField (x :: k) r a | x r -> a -- | Selector function to extract the field from the record. getField :: HasField x r a => r -> a failAction :: ActionTask ctx a modifyAction :: (ctx -> ctx) -> ActionTask ctx () getAction :: ActionTask ctx ctx newtype ActionTask ctx a ActionTask :: (ctx -> ActionTaskResult ctx a) -> ActionTask ctx a [$sel:runActionTask:ActionTask] :: ActionTask ctx a -> ctx -> ActionTaskResult ctx a data ActionTaskResult ctx a ActionTaskFail :: ActionTaskResult ctx a ActionTaskResult :: a -> ActionTaskResult ctx a ActionTaskModifyResult :: ctx -> a -> ActionTaskResult ctx a tokA :: forall (t :: Symbol) rules tokens elem. TokensMember tokens t => Expr rules tokens elem '[elem] tok :: forall tokens (t :: Symbol) rules elem. Membership (TokensTag tokens) t -> Expr rules tokens elem '[elem] varA :: forall (v :: Symbol) rules tokens elem. KnownSymbol v => Expr rules tokens elem '[RuleExprReturnType rules v] var :: forall (v :: Symbol) proxy rules tokens elem. KnownSymbol v => proxy v -> Expr rules tokens elem '[RuleExprReturnType rules v] (<^>) :: forall rules tokens elem (us1 :: [Type]) (us2 :: [Type]). Expr rules tokens elem us1 -> Expr rules tokens elem us2 -> Expr rules tokens elem (Concat us1 us2) infixr 5 <^> eps :: Expr rules tokens elem ('[] :: [Type]) ruleExpr :: forall (action :: [Type] -> Type -> Type) rules tokens elem a. [Alt action rules tokens elem a] -> RuleExpr action rules tokens elem a fixGrammar :: forall (initials :: [Symbol]) (action :: [Type] -> Type -> Type) rules tokens elem. (MemberInitials rules initials, Rules rules, RuleExprType rules ~ RuleExpr action rules tokens elem) => rules -> Grammar action rules tokens elem initials type family TokensTag tokens :: [Symbol] type family RulesTag rules :: [Symbol] type family RuleExprType rules :: Type -> Type class GrammarToken tokens elem tokenToTerminal :: GrammarToken tokens elem => Proxy tokens -> elem -> T (TokensTag tokens) type family RuleExprReturnType rules (v :: Symbol) class (KnownSymbol v, HasField v rules RuleExprType rules RuleExprReturnType rules v) => HasRuleExprField rules (v :: Symbol) where { type family RuleExprReturnType rules (v :: Symbol); } nonTerminalName :: HasRuleExprField rules v => rules -> proxy v -> String class MemberInitials rules (initials :: [Symbol]) memberInitials :: MemberInitials rules initials => T (DictF (HasRuleExprField rules)) initials class Rules rules generateRules :: Rules rules => T (DictF (HasRuleExprField rules)) (RulesTag rules) data Expr rules tokens elem (us :: [Type]) class TokensMember tokens (t :: Symbol) tokensMembership :: TokensMember tokens t => Proxy# '(tokens, t) -> Membership (TokensTag tokens) t data DictF (a :: k -> Constraint) (b :: k) [DictF] :: forall k (a :: k -> Constraint) (b :: k). a b => DictF a b data HFList (a :: k -> Type) (b :: [k]) [HFNil] :: forall k (a :: k -> Type). HFList a ('[] :: [k]) [HFCons] :: forall k (a :: k -> Type) (x :: k) (xs :: [k]). a x -> HFList a xs -> HFList a (x : xs) type SemAct = SemActM () data SemActM ctx us a newtype TExpQ a TExpQ :: Q (TExp a) -> TExpQ a [$sel:unTExpQ:TExpQ] :: TExpQ a -> Q (TExp a) type HTExpList = T TExpQ type Alt = AltM () type RuleExpr = RuleExprM () type Grammar = GrammarM () type AltM ctx = Alt (SemActM ctx) type RuleExprM ctx = RuleExpr (SemActM ctx) type GrammarM ctx = Grammar (SemActM ctx) pattern (:*) :: Q (TExp u) -> HTExpList us -> HTExpList (u : us) infixr 6 :* pattern HNil :: HTExpList '[] (<:>) :: Expr rules tokens elem us -> (HTExpList us -> Q (TExp a)) -> AltM ctx rules tokens elem a infixl 4 <:> (<::>) :: Expr rules tokens elem us -> (HTExpList us -> Q (TExp (ActionTask ctx a))) -> AltM ctx rules tokens elem a infixl 4 <::> runListScanner :: ListScanner e a -> [e] -> a class Monad m => Scanner posMark elem (m :: Type -> Type) | m -> posMark, m -> elem consumeInput :: Scanner posMark elem m => m (Maybe elem) getPosMark :: Scanner posMark elem m => m posMark seekToPosMark :: Scanner posMark elem m => posMark -> m () scanMode :: Scanner posMark elem m => ScanMode posMark -> m () data ScanMode posMark ScanModeNoBack :: ScanMode posMark ScanModeNeedBack :: posMark -> ScanMode posMark newtype ListScanner e a ListScanner :: State [e] a -> ListScanner e a [$sel:unListScanner:ListScanner] :: ListScanner e a -> State [e] a runParser :: forall (v :: Symbol) (initials :: [Symbol]) posMark m rules elem proxy. (Member initials v, T posMark elem m) => proxy v -> Runner rules elem initials -> m (Result posMark (RuleExprReturnType rules v)) runParserM :: forall (v :: Symbol) (initials :: [Symbol]) ctx posMark m rules elem proxy. (Member initials v, T posMark elem m) => proxy v -> RunnerM ctx rules elem initials -> ctx -> m (Result posMark (RuleExprReturnType rules v)) type Result posMark = ParseResult posMark () data ParseResult posMark altHelp a Parsed :: a -> ParseResult posMark altHelp a ParseFailed :: posMark -> FailedReason altHelp -> ParseResult posMark altHelp a data GenRulesTypes GenRulesTypes :: Q Type -> Q Type -> Q Type -> GenRulesTypes [$sel:genRulesCtxTy:GenRulesTypes] :: GenRulesTypes -> Q Type [$sel:genRulesTokensTy:GenRulesTypes] :: GenRulesTypes -> Q Type [$sel:genRulesTokenTy:GenRulesTypes] :: GenRulesTypes -> Q Type genGrammarToken :: Name -> Q Type -> [(String, Q Pat)] -> Q [Dec] genRules :: Name -> GenRulesTypes -> [(Name, String, Q Type)] -> Q [Dec] genParsePoints :: Name -> Name -> [String] -> Q [Dec] genRunner :: forall initials rules tokens ctx elem. GrammarToken tokens elem => Generate (TokensTag tokens) => GenParam -> GrammarM ctx rules tokens elem initials -> Q [Dec] data GenParam GenParam :: Q Type -> Q Type -> Q Type -> Q Type -> Q Type -> GenParam [$sel:startsTy:GenParam] :: GenParam -> Q Type [$sel:rulesTy:GenParam] :: GenParam -> Q Type [$sel:tokensTy:GenParam] :: GenParam -> Q Type [$sel:tokenTy:GenParam] :: GenParam -> Q Type [$sel:customCtxTy:GenParam] :: GenParam -> Q Type defaultCustomCtxTy :: Q Type