module Language.Pads.Quote
(pads, padsDerivation, pparseDecl, make_pads_declarations)
where
import Prelude hiding (exp, init)
import System.IO.Unsafe (unsafePerformIO)
import Language.Haskell.TH
import Language.Haskell.TH.Quote (QuasiQuoter(..))
import Language.Pads.CodeGen
import qualified Language.Pads.Parser as P
pads :: QuasiQuoter
pads = padsDerivation (const $ return [])
padsDerivation :: Derivation -> QuasiQuoter
padsDerivation derivation = QuasiQuoter
pparseExp
(error "parse pattern")
(error "parse type")
(pparseDecl derivation)
pparseDecl :: Derivation -> String -> Q [Dec]
pparseDecl derivation input = do
loc <- location
let fileName = loc_filename loc
let (line,column) = loc_start loc
case P.parsePadsDecls fileName line column input of
Left err -> unsafePerformIO $ fail $ show err
Right x -> make_pads_declarations' derivation x
pparseExp :: String -> Q Exp
pparseExp input = do
loc <- location
let fileName = loc_filename loc
let (line,column) = loc_start loc
case P.parsePadsDecls fileName line column input of
Left err -> unsafePerformIO $ fail $ show err
Right x -> make_pads_asts x