{-# LANGUAGE TemplateHaskell #-} module Language.Parser.Ptera.TH ( module Language.Parser.Ptera.TH.Syntax, module Language.Parser.Ptera.Scanner, module Language.Parser.Ptera.Runner, module Language.Parser.Ptera.TH.ParserLib, module Language.Parser.Ptera.TH.Util, module Language.Parser.Ptera.TH.Class.LiftType, genRunner, GenParam (..), defaultCustomCtxTy, ) where import Language.Parser.Ptera.Prelude import qualified Language.Haskell.TH as TH import Language.Parser.Ptera.Runner (ParseResult (..), Result, runParser, runParserM) import Language.Parser.Ptera.Scanner hiding (T) import Language.Parser.Ptera.TH.ParserLib import qualified Language.Parser.Ptera.TH.Pipeline.Grammar2ParserDec as Grammar2ParserDec import Language.Parser.Ptera.TH.Syntax hiding (T, UnsafeSemActM, semAct, semActM, unsafeSemanticAction) import Language.Parser.Ptera.TH.Util (GenRulesTypes (..), genGrammarToken, genParsePoints, genRules) import Language.Parser.Ptera.TH.Class.LiftType (LiftType (..)) import qualified Type.Membership as Membership genRunner :: forall initials rules tokens ctx elem . GrammarToken tokens elem => Membership.Generate (TokensTag tokens) => GenParam -> GrammarM ctx rules tokens elem initials -> TH.Q [TH.Dec] genRunner :: GenParam -> GrammarM ctx rules tokens elem initials -> Q [Dec] genRunner GenParam param GrammarM ctx rules tokens elem initials g = PipelineParam -> GrammarM ctx rules tokens elem initials -> Q [Dec] forall (initials :: [Symbol]) rules tokens ctx elem. (GrammarToken tokens elem, Generate (TokensTag tokens)) => PipelineParam -> GrammarM ctx rules tokens elem initials -> Q [Dec] Grammar2ParserDec.grammar2ParserDec do PipelineParam :: Q Type -> Q Type -> Q Type -> Q Type -> Q Type -> PipelineParam Grammar2ParserDec.PipelineParam { $sel:startsTy:PipelineParam :: Q Type startsTy = GenParam -> Q Type startsTy GenParam param, $sel:rulesTy:PipelineParam :: Q Type rulesTy = GenParam -> Q Type rulesTy GenParam param, $sel:tokensTy:PipelineParam :: Q Type tokensTy = GenParam -> Q Type tokensTy GenParam param, $sel:tokenTy:PipelineParam :: Q Type tokenTy = GenParam -> Q Type tokenTy GenParam param, $sel:customCtxTy:PipelineParam :: Q Type customCtxTy = GenParam -> Q Type customCtxTy GenParam param } do GrammarM ctx rules tokens elem initials g data GenParam = GenParam { GenParam -> Q Type startsTy :: TH.Q TH.Type, GenParam -> Q Type rulesTy :: TH.Q TH.Type, GenParam -> Q Type tokensTy :: TH.Q TH.Type, GenParam -> Q Type tokenTy :: TH.Q TH.Type, GenParam -> Q Type customCtxTy :: TH.Q TH.Type } defaultCustomCtxTy :: TH.Q TH.Type defaultCustomCtxTy :: Q Type defaultCustomCtxTy = [t|()|]