{-#OPTIONS_GHC -fno-warn-missing-fields#-}
module Text.Alex.Quote (
parseAlex
, compileAlex
, Alex
, alex
) where
import Text.Alex(runAlex, Target(..), CLIFlags(..))
import Text.Alex.AlexTemplate
import Language.Haskell.TH.Quote
import Language.Haskell.TH
import Language.Haskell.Meta
type Alex = String
compileAlex :: Alex -> Q [Dec]
compileAlex = return . either error id . parseDecs
alex :: QuasiQuoter
alex = QuasiQuoter {quoteExp = litE . StringL . parseAlex}
parseAlex :: String -> Alex
parseAlex s = fst (runAlex [] Nothing s) ++ "\n" ++ alexTemplate HaskellTarget