[project @ 2000-06-14 11:21:06 by simonmar]
authorsimonmar <unknown>
Wed, 14 Jun 2000 11:21:06 +0000 (11:21 +0000)
committersimonmar <unknown>
Wed, 14 Jun 2000 11:21:06 +0000 (11:21 +0000)
Produce a gcc-like "ghc: no input files" when called with nothing to
do.  Note at the top of the file that we don't support the old
driver's "Enter your Haskell program..." nonsense.

ghc/driver/Main.hs

index 07adca7..db6563b 100644 (file)
@@ -45,6 +45,7 @@ name = global (value) :: IORef (ty); \
 -----------------------------------------------------------------------------
 -- Differences vs. old driver:
 
+-- No more "Enter your Haskell program, end with ^D (on a line of its own):"
 -- consistency checking removed (may do this properly later)
 -- removed -noC
 -- no hi diffs (could be added later)
@@ -114,6 +115,7 @@ data BarfKind
   | WayCombinationNotSupported [WayName]
   | PhaseFailed String ExitCode
   | Interrupted
+  | NoInputFiles
   deriving Eq
 
 GLOBAL_VAR(prog_name, "ghc", String)
@@ -138,6 +140,8 @@ showBarf (WayCombinationNotSupported ws)
    = showString "combination not supported: " 
    . foldr1 (\a b -> a . showChar '/' . b) 
        (map (showString . wayName . lkupWay) ws)
+showBarf (NoInputFiles)
+   = showString "no input files"
 
 barfKindTc = mkTyCon "BarfKind"
 
@@ -1041,13 +1045,16 @@ main =
        then throwDyn MultipleSrcsOneOutput
        else do
 
+   if null unknown_srcs && null phase_srcs
+       then throwDyn NoInputFiles
+       else do
+
    -- if we have unknown files, and we're not doing linking, complain
    -- (otherwise pass them through to the linker).
    if not (null unknown_srcs) && not do_linking
        then throwDyn (UnknownFileType (head unknown_srcs))
        else do
 
-
    let  compileFile :: (Phase, String) -> IO String
        compileFile (phase, src) = do
          let (orig_base, _) = split_filename src