on master help sign in
Merge pull request #314 from jsl/304_print_program_fix
b896941Evan Czaplicki
compiler/Compiler.hs+4−11
@@ -37,7 +37,6 @@ data Flags =
37 , runtime :: Maybe FilePath
37 , runtime :: Maybe FilePath
38 , only_js :: Bool
38 , only_js :: Bool
39 , print_types :: Bool
39 , print_types :: Bool
40− , print_program :: Bool
41 , scripts :: [FilePath]
40 , scripts :: [FilePath]
42 , no_prelude :: Bool
41 , no_prelude :: Bool
43 , cache_dir :: FilePath
42 , cache_dir :: FilePath
@@ -66,14 +65,12 @@ flags = Flags
66 &= help "Additional source directories besides project root. Searched when using --make"
65 &= help "Additional source directories besides project root. Searched when using --make"
67 , print_types = False
66 , print_types = False
68 &= help "Print out infered types of top-level definitions."
67 &= help "Print out infered types of top-level definitions."
69− , print_program = False
70− &= help "Print out an internal representation of a program."
71 } &= help "Compile Elm programs to HTML, CSS, and JavaScript."
68 } &= help "Compile Elm programs to HTML, CSS, and JavaScript."
72 &= helpArg [explicit, name "help", name "h"]
69 &= helpArg [explicit, name "help", name "h"]
73 &= versionArg [explicit, name "version", name "v", summary (showVersion version)]
70 &= versionArg [explicit, name "version", name "v", summary (showVersion version)]
74 &= summary ("The Elm Compiler " ++ showVersion version ++ ", (c) Evan Czaplicki 2011-2013")
71 &= summary ("The Elm Compiler " ++ showVersion version ++ ", (c) Evan Czaplicki 2011-2013")
75
72
76−main :: IO ()
73+main :: IO ()
77main = do setNumCapabilities =<< getNumProcessors
74main = do setNumCapabilities =<< getNumProcessors
78 compileArgs =<< cmdArgs flags
75 compileArgs =<< cmdArgs flags
79
76
@@ -82,7 +79,7 @@ compileArgs flags =
82 case files flags of
79 case files flags of
83 [] -> putStrLn "Usage: elm [OPTIONS] [FILES]\nFor more help: elm --help"
80 [] -> putStrLn "Usage: elm [OPTIONS] [FILES]\nFor more help: elm --help"
84 fs -> mapM_ (build flags) fs
81 fs -> mapM_ (build flags) fs
85−
82+
86
83
87buildPath :: Flags -> FilePath -> String -> FilePath
84buildPath :: Flags -> FilePath -> String -> FilePath
88buildPath flags filePath ext = build_dir flags </> replaceExtension filePath ext
85buildPath flags filePath ext = build_dir flags </> replaceExtension filePath ext
@@ -140,7 +137,7 @@ buildFile flags moduleNum numModules interfaces filePath =
140 putStrLn $ concat [ number, " Compiling ", name
137 putStrLn $ concat [ number, " Compiling ", name
141 , replicate (max 1 (20 - length name)) ' '
138 , replicate (max 1 (20 - length name)) ' '
142 , "( " ++ filePath ++ " )" ]
139 , "( " ++ filePath ++ " )" ]
143−
140+
144 createDirectoryIfMissing True (cache_dir flags)
141 createDirectoryIfMissing True (cache_dir flags)
145 createDirectoryIfMissing True (build_dir flags)
142 createDirectoryIfMissing True (build_dir flags)
146 metaModule <-
143 metaModule <-
@@ -148,11 +145,7 @@ buildFile flags moduleNum numModules interfaces filePath =
148 Left errors -> do
145 Left errors -> do
149 mapM print (List.intersperse (P.text " ") errors)
146 mapM print (List.intersperse (P.text " ") errors)
150 exitFailure
147 exitFailure
151− Right modul -> do
152− case print_program flags of
153− False -> return ()
154− True -> print . pretty $ program modul
155− return modul
148+ Right modul -> return modul
156
149
157 when (print_types flags)
150 when (print_types flags)
158 (printTypes interfaces
151 (printTypes interfaces