grammar-combinators-0.1: Text/GrammarCombinators/Transform/OptimizeGrammar.hs
{- 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 #-}
module Text.GrammarCombinators.Transform.OptimizeGrammar where
-- just a combination of some transforms (in a correct order)
-- TODO: check order
import Text.GrammarCombinators.Base
import Text.GrammarCombinators.Transform.CombineEpsilons
import Text.GrammarCombinators.Transform.FilterDies
import Text.GrammarCombinators.Transform.UnfoldDead
import Text.GrammarCombinators.Transform.UniformPaull
import Text.GrammarCombinators.Transform.UnfoldChainNTs
optimizeGrammarE :: (Token t, Domain phi) =>
ProcessingExtendedContextFreeGrammar phi t r ->
ProcessingExtendedContextFreeGrammar (UPDomain phi) t (UPValue r)
optimizeGrammarE g = combineEpsilonsE (unfoldChainNTsE (filterDiesE (unfoldDeadE (transformUniformPaullE g))))