[allow passing of haskell source through m4, let -fcpp and -fm4 be processed in OPTIONS pragmas
John Meacham <john@repetae.net>**20070606235709] hunk ./FlagOpts.flags 13
+m4 pass haskell source through m4
hunk ./Ho/Build.hs 31
-import FrontEnd.Class
hunk ./Ho/Build.hs 42
+import FrontEnd.Class
hunk ./Ho/Build.hs 46
-import FrontEnd.Unlit
hunk ./Ho/Build.hs 47
-import GenUtil hiding(putErrLn,putErr,putErrDie)
-import Ho.Type
+import FrontEnd.Unlit
+import FrontEnd.Warning
hunk ./Ho/Build.hs 51
+import Ho.Type
hunk ./Ho/Build.hs 56
+import Util.Gen hiding(putErrLn,putErr,putErrDie)
hunk ./Ho/Build.hs 58
-import FrontEnd.Warning
hunk ./Ho/Build.hs 320
-        cs <- if fopts FO.Cpp then filterInput "cpp" ["-D__JHC__","-traditional","-P"] fh
-                              else CharIO.hGetContents fh
-        hs <- parseHsSource (fromAtom $ fileName fd) cs
+        hs <- parseHsSource (fromAtom $ fileName fd) fh
hunk ./Ho/Build.hs 345
-parseHsSource :: String -> String -> IO HsModule
-parseHsSource fn s = do
-    let opts = concat [ words as | (x,as) <- parseOptions s', x `elem` ["OPTIONS","JHC_OPTIONS","OPTIONS_JHC"]]
-        s' = if "shl." `isPrefixOf` reverse fn  then unlit fn s else s
-    opt <- case fileOptions opts of
-        Just o -> return o
-        Nothing -> return options
-    case runParserWithMode (parseModeOptions opt) { parseFilename = fn } parse  s'  of
+parseHsSource :: String -> Handle -> IO HsModule
+parseHsSource fn fh = do
+    pos <- hGetPosn fh
+    ls <- replicateM 10 (ioM $ hGetLine fh)
+    let f s = opt where
+            Just opt = fileOptions opts `mplus` Just options where
+            s' = if "shl." `isPrefixOf` reverse fn  then unlit fn s else s
+            opts = concat [ words as | (x,as) <- parseOptions s', x `elem` ["OPTIONS","JHC_OPTIONS","OPTIONS_JHC"]]
+    let fopts s = s `member` optFOptsSet opt where opt = f (concatMap concat ls)
+    hSetPosn pos
+    s <- case () of
+        _ | fopts FO.Cpp -> filterInput "cpp" ["-D__JHC__","-P","-CC","-traditional"] fh
+          | fopts FO.M4 ->  filterInput "m4" ["-D__JHC__"] fh
+          | otherwise -> CharIO.hGetContents fh
+    let s' = if "shl." `isPrefixOf` reverse fn  then unlit fn s else s
+    case runParserWithMode (parseModeOptions $ f s) { parseFilename = fn } parse  s'  of
hunk ./utils/opt_sets.prl 27
-    if (/^([a-z-]+)\s+(\S.*\S)\s*$/) {
+    if (/^([a-z0-9-]+)\s+(\S.*\S)\s*$/) {