grammar-combinators-0.1: Text/GrammarCombinators/TH/RealLL1.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 TemplateHaskell #-}
{-# LANGUAGE FlexibleContexts #-}
module Text.GrammarCombinators.TH.RealLL1 where
import Text.GrammarCombinators.Base
import Text.GrammarCombinators.Parser.RealLL1
import Text.GrammarCombinators.TH.Base ()
import Language.Haskell.TH.Syntax
instance (Token t) => Lift (FirstSet t) where
lift (FS fts e f) = [| FS $(lift fts) $(lift e) $(lift f) |]
instance (Token t) => Lift (BranchSelectorMemo t) where
lift DefaultBranchSelectorMemo = [| DefaultBranchSelectorMemo |]
lift (SplitBranchSelectorMemoL fs bsa bsb) = [| SplitBranchSelectorMemoL $(lift fs) $(lift bsa) $(lift bsb) |]
lift (FlipBS bsn) = [| FlipBS $(lift bsn) |]
liftRealLL1Table :: (Lift (Memo phi (K0 (BranchSelectorMemo t)))) => RealLL1Table phi t -> Q Exp
liftRealLL1Table (MkRealLL1Table memo) = [| MkRealLL1Table $(lift memo) |]