Changeset 8315 for src/Pugs.hs
- Timestamp:
- 12/20/05 07:11:45 (3 years ago)
- Files:
-
- 1 modified
-
src/Pugs.hs (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Pugs.hs
r8153 r8315 79 79 80 80 -- -CPIL1.Perl5 outputs PIL formatted as Perl 5. 81 run ("-C":backend:args) | map to Upper backend == "JS" = do81 run ("-C":backend:args) | map toLower backend == "js" = do 82 82 exec <- getArg0 83 83 doHelperRun "JS" ("--compile-only":("--pugs="++exec):args) 84 run ("-C":backend:"-e":prog:_) = doCompileDump backend "-e" prog85 run ("-C":backend:file:_) = slurpFile file>>= doCompileDump backend file84 run ("-C":backend:"-e":prog:_) = withInlinedIncludes prog >>= doCompileDump backend "-e" 85 run ("-C":backend:file:_) = readFile file >>= withInlinedIncludes >>= doCompileDump backend file 86 86 87 87 run ("-B":backend:_) | (== map toLower backend) `any` ["js","perl5"] = do … … 89 89 args <- getArgs 90 90 doHelperRun backend (("--pugs="++exec):args) 91 run ("-B":backend:"-e":prog:_) = doCompileRun backend "-e" prog92 run ("-B":backend:file:_) = slurpFile file>>= doCompileRun backend file91 run ("-B":backend:"-e":prog:_) = withInlinedIncludes prog >>= doCompileRun backend "-e" 92 run ("-B":backend:file:_) = readFile file >>= withInlinedIncludes >>= doCompileRun backend file 93 93 94 94 run ("--external":mod:"-e":prog:_) = doExternal mod "-e" prog … … 417 417 evalParrotFile "a.pir" 418 418 419 slurpFile :: FilePath -> IO String 420 slurpFile file = do 421 prog <- readFile file 419 withInlinedIncludes :: String -> IO String 420 withInlinedIncludes prog = do 422 421 libs <- getLibs 423 422 expandInc libs prog 424 423 where 425 424 expandInc :: [FilePath] -> String -> IO String 426 expandInc incs str = case breakOnGlue "\nuse " strof427 Nothing -> case breakOnGlue "\nrequire " strof425 expandInc incs str = case breakOnGlue "\nuse " ('\n':str) of 426 Nothing -> case breakOnGlue "\nrequire " ('\n':str) of 428 427 Nothing -> return str 429 428 Just (pre, post) -> do … … 436 435 mod' <- includeInc incs mod 437 436 rest' <- expandInc incs rest 438 return $ pre ++ mod'++ rest'437 return $ pre ++ "\n{" ++ mod' ++ "\n}\n" ++ rest' 439 438 includeInc :: [FilePath] -> String -> IO String 440 439 includeInc _ ('v':_) = return []
