grammar-combinators-0.2.3: A parsing library of context-free grammar combinators.

Text.GrammarCombinators.Utils.LiftGrammar

Synopsis

Documentation

liftGrammar :: forall phi t r rr. (FoldFam phi, LiftFam phi, Token t) => GLAnyExtendedContextFreeGrammar phi t r rr -> Name -> Q Type -> Q [Dec]Source

Lift a given grammar to Template Haskell

unfoldAndLiftGrammar :: forall phi t r rr. (FoldFam phi, LiftFam phi, Token t) => GLAnyExtendedContextFreeGrammar phi t r rr -> Name -> Q Type -> Q [Dec]Source

Lift a given grammar to Template Haskell and replace recursion and loops with infinite-tree style recursive calls to the grammar itself. This allows GHC to do a much better optimization (x20 speed-ups in one realistic test, compared with result of liftGrammar).