Changeset 4914 for src/Main.hs
- Timestamp:
- 06/22/05 20:57:31 (4 years ago)
- svk:copy_cache_prev:
- 6641
- Files:
-
- 1 modified
-
src/Main.hs (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Main.hs
r4913 r4914 29 29 import Pugs.Trans 30 30 import Pugs.Embed 31 import Pugs.Prim.Eval (requireInc) 31 32 import qualified Data.Map as Map 32 33 import Data.IORef … … 74 75 75 76 run ("-C":backend:"-e":prog:_) = doCompileDump backend "-e" prog 76 run ("-C":backend:file:_) = readFile file >>= doCompileDump backend file77 run ("-C":backend:file:_) = slurpFile file >>= doCompileDump backend file 77 78 78 79 run ("-B":backend:"-e":prog:_) = doCompileRun backend "-e" prog 79 run ("-B":backend:file:_) = readFile file >>= doCompileRun backend file80 run ("-B":backend:file:_) = slurpFile file >>= doCompileRun backend file 80 81 81 82 run ("--external":mod:"-e":prog:_) = doExternal mod "-e" prog … … 312 313 writeFile "a.pir" pir 313 314 evalParrotFile "a.pir" 315 316 slurpFile :: FilePath -> IO String 317 slurpFile file = do 318 prog <- readFile file 319 libs <- getLibs 320 file <- expandInc libs prog 321 -- writeFile "ZZZ" file 322 return file 323 where 324 expandInc :: [FilePath] -> String -> IO String 325 expandInc incs str = case breakOnGlue "\nuse " str of 326 Nothing -> return str 327 Just (pre, post) -> do 328 let (mod, (_:rest)) = span isAlphaNum (dropWhile isSpace post) 329 mod' <- includeInc incs mod 330 rest' <- expandInc incs rest 331 return $ pre ++ mod' ++ rest' 332 includeInc :: [FilePath] -> String -> IO String 333 includeInc _ ('v':_) = return [] 334 includeInc incs name = do 335 let name' = concat (intersperse "/" names) ++ ".pm" 336 names = split "::" name 337 pathName <- requireInc incs name' (errMsg name incs) 338 readFile pathName 339 errMsg file incs = "Can't locate " ++ file ++ " in @*INC (@*INC contains: " ++ unwords incs ++ ")." 340
