ehaskell 0.2 → 0.3
raw patch · 2 files changed
+23/−19 lines, 2 filesdep +filepathdep ~yjtools
Dependencies added: filepath
Dependency ranges changed: yjtools
Files
- Main.hs +20/−16
- ehaskell.cabal +3/−3
Main.hs view
@@ -4,6 +4,7 @@ import System.Directory (doesDirectoryExist, createDirectory, copyFile, doesFileExist) import System.Directory.Tools (doesNotExistOrOldThan) import System.Process (runProcess, waitForProcess)+import System.FilePath (takeDirectory, takeFileName) import Control.Monad.Tools (whenM, unlessM, skipRet) import Control.Applicative ((<$>)) import Text.RegexPR (gsubRegexPR)@@ -11,6 +12,7 @@ import YJTools.Tribial (ghcMake) import Data.Char (isSpace) import Data.Maybe (maybeToList)+import Data.Function.Tools (applyUnless) ehaskellDir, haskellSffx, ehsHandleStr, putStrStr :: String ehaskellDir = "_ehs/"@@ -23,25 +25,27 @@ args <- getArgs let [infile] = dropOptionO args outfile = takeOptionO args- exeName = gsubRegexPR "\\." "_" infile- exeFile = ehaskellDir ++ exeName- srcFile = ehaskellDir ++ exeName ++ haskellSffx+ edir = let d = takeDirectory infile+ in applyUnless (null d) ((d ++ "/") ++) ehaskellDir+ exeName = gsubRegexPR "\\." "_" $ takeFileName infile+ exeFile = edir ++ exeName+ srcFile = edir ++ exeName ++ haskellSffx cont <- readFile infile- unlessM (doesDirectoryExist ehaskellDir) $ createDirectory ehaskellDir- copyRequiredFile cont+ unlessM (doesDirectoryExist edir) $ createDirectory edir+ copyRequiredFile edir cont whenM (doesNotExistOrOldThan srcFile infile) $ writeFile srcFile $ fst $ head $ runParse parseAll ("", cont) whenM (doesNotExistOrOldThan exeFile srcFile) $- ghcMake exeName ehaskellDir >> return ()+ ghcMake exeName edir >> return () runProcess exeFile (maybeToList outfile) Nothing Nothing Nothing Nothing Nothing >>= waitForProcess return () -copyRequiredFile :: String -> IO ()-copyRequiredFile src = evalParseT copyRequiredFileParse ("",src) >> return ()+copyRequiredFile :: FilePath -> String -> IO ()+copyRequiredFile dir src = evalParseT (copyRequiredFileParse dir) ("",src) >> return () -copyRequiredFileParse :: ParseT Char IO ()-copyRequiredFileParse = list crfp >> return ()+copyRequiredFileParse :: FilePath -> ParseT Char IO ()+copyRequiredFileParse dir = list crfp >> return () where crfp = do list $ do@@ -53,7 +57,7 @@ list $ spot isSpace mn <- neList (spot $ not . isSpace) >>= skipRet (still $ spot $ isSpace) let sfn = mn ++ ".hs"- dfn = ehaskellDir ++ sfn+ dfn = dir ++ sfn lift $ whenM (doesFileExist sfn) $ whenM (doesNotExistOrOldThan dfn sfn) $ copyFile sfn dfn list $ spot isSpace@@ -193,8 +197,8 @@ spot (const True) mkOutputText txt = " " ++ putStrStr ++ " $ " ++ show txt ++ ";\n"-mkOutputHere code = " " ++ code ++ ";\n"-mkOutputCode code = " " ++ code ++ " >>= " ++ putStrStr ++ ";\n"-mkOutputShowCode code = " " ++ code ++ " >>= " ++ putStrStr ++ ". show ;\n"-mkOutputReturnCode code = " " ++ putStrStr ++ " $ " ++ code ++ " ;\n"-mkOutputReturnShowCode code = " " ++ putStrStr ++ " $ show" ++ code ++ " ;\n"+mkOutputHere code = " (" ++ code ++ ")" ++ ";\n"+mkOutputCode code = " (" ++ code ++ ") >>= " ++ putStrStr ++ ";\n"+mkOutputShowCode code = " (" ++ code ++ ") >>= " ++ putStrStr ++ ". show ;\n"+mkOutputReturnCode code = " " ++ putStrStr ++ " $ (" ++ code ++ ") ;\n"+mkOutputReturnShowCode code = " " ++ putStrStr ++ " $ show (" ++ code ++ ") ;\n"
ehaskell.cabal view
@@ -1,5 +1,5 @@ Name: ehaskell-Version: 0.2+Version: 0.3 Cabal-Version: >= 1.2 Build-Type: Simple License: GPL@@ -7,7 +7,7 @@ Stability: experimental Author: Yoshikuni Jujo <PAF01143@nifty.ne.jp> Maintainer: PAF01143@nifty.ne.jp-Category: Code Generation+Category: Text Homepage: http://homepage3.nifty.com/salamander/second/projects/ehaskell/index.xhtml Synopsis: like eruby, ehaskell is embedded haskell. Description: You can embed haskell in Text file.@@ -44,5 +44,5 @@ Executable ehs Main-Is: Main.hs- Build-Depends: base, mtlparse >= 0.0.1, yjtools >= 0.7, directory, regexpr >= 0.3.3, process+ Build-Depends: base, mtlparse >= 0.0.1, yjtools >= 0.8, directory, regexpr >= 0.3.3, process, filepath GHC-Options: -Wall