module HeaderInfo ( getImports
, getOptionsFromFile, getOptions
- , optionsErrorMsgs ) where
+ , optionsErrorMsgs,
+ checkProcessArgsResult ) where
#include "HsVersions.h"
import System.IO
import Data.List
-#if !defined(__GLASGOW_HASKELL__) || __GLASGOW_HASKELL__ >= 601
- -- already imported above
---import System.IO ( openBinaryFile )
-#else
-import IOExts ( openFileEx, IOModeEx(..) )
-#endif
-
-#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ < 601
-openBinaryFile fp mode = openFileEx fp (BinaryMode mode)
-#endif
-
getImports :: DynFlags -> StringBuffer -> FilePath -> FilePath
-> IO ([Located ModuleName], [Located ModuleName], Located ModuleName)
getImports dflags buf filename source_filename = do
POk state' t -> (buffer state,t):lexAll state'
_ -> [(buffer state,L (last_loc state) ITeof)]
+-----------------------------------------------------------------------------
+-- Complain about non-dynamic flags in OPTIONS pragmas
+
+checkProcessArgsResult :: [String] -> FilePath -> IO ()
+checkProcessArgsResult flags filename
+ = do when (notNull flags) (throwDyn (ProgramError (
+ showSDoc (hang (text filename <> char ':')
+ 4 (text "unknown flags in {-# OPTIONS #-} pragma:" <+>
+ hsep (map text flags)))
+ )))
+
+-----------------------------------------------------------------------------
+
checkExtension :: Located FastString -> Located String
checkExtension (L l ext)
-- Checks if a given extension is valid, and if so returns