{- Copyright 2010 Dominique Devriese
This file is part of the grammar-combinators library.
The grammar-combinators library is free software: you can
redistribute it and/or modify it under the terms of the GNU
Lesser General Public License as published by the Free
Software Foundation, either version 3 of the License, or (at
your option) any later version.
Foobar is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General
Public License along with Foobar. If not, see
<http://www.gnu.org/licenses/>.
-}{-# LANGUAGE FlexibleContexts #-}{-# LANGUAGE RankNTypes #-}{-# LANGUAGE TemplateHaskell #-}moduleText.GrammarCombinators.Base.Processor(GProcessor,Processor,identityProcessor,trivialProcessor,applyProcessor',applyProcessor,applyProcessorL,applyProcessorLE,applyProcessorE)whereimportText.GrammarCombinators.Base.GrammarimportText.GrammarCombinators.Base.DomainimportText.GrammarCombinators.Base.MultiRecimportText.GrammarCombinators.Base.ProductionRuleimportLanguage.Haskell.TH.Syntax(Q,Exp)typeGProcessorphirrr=forallix.phiix->rrix->rixtypeProcessorphir=GProcessorphir(PFphir)-- | A trivial identity processor that keeps current production-- rule results unmodified.identityProcessor::GProcessorphirridentityProcessor_v=vapplyProcessor'::(ProductionRulep,EpsProductionRulep)=>(forallix.phiix->p(rix))->GProcessorphir'r->(forallix.phiix->p(r'ix))applyProcessor'grammarprocidx=procidx$>>grammaridx-- | Apply a given processor to a given context-free grammar.applyProcessor::GContextFreeGrammarphitrrr->GProcessorphirr'rr->GContextFreeGrammarphitrrr'applyProcessorgramprocidx=applyProcessor'gramprocidxapplyProcessorL::(LiftFamphi)=>GLContextFreeGrammarphitrrr->GProcessorphirr'rr->QExp->GLContextFreeGrammarphitrrr'applyProcessorLgramprocqidx=(procidx,[|$(q)$(return$liftIdxEidx)|])$|>>gramidx-- | Apply a given processor to a given extended context-free-- grammar.applyProcessorE::GExtendedContextFreeGrammarphitrrr->GProcessorphirr'rr->GExtendedContextFreeGrammarphitrrr'applyProcessorEgramprocidx=applyProcessor'gramprocidx-- | Apply a given processor to a given extended liftable context-free-- grammar.applyProcessorLE::(LiftFamphi)=>GLExtendedContextFreeGrammarphitrrr->GProcessorphirr'rr->QExp->GLExtendedContextFreeGrammarphitrrr'applyProcessorLEgramprocqidx=(procidx,[|$(q)$(return$liftIdxEidx)|])$|>>gramidx-- | A trivial processor that throws everything away and returns -- a value of the type K0 ().trivialProcessor::Processorphi(K0())trivialProcessor__=K0()