[parse options pragmas early, so the results can be used to modify lexing behavior
John Meacham <john@repetae.net>**20061113100459] addfile ./FrontEnd/Syn/Options.hs
hunk ./FrontEnd/Syn/Options.hs 1
+module FrontEnd.Syn.Options(parseOptions) where
+
+
+import Text.ParserCombinators.ReadP
+import Char
+import List
+
+
+
+parseOptions :: String -> [(String,String)]
+parseOptions s = case readP_to_S parse s of
+    os -> head $ sortBy (\x y -> compare (negate $ length x) (negate $ length y)) [ x | (x,_) <- os ]
+
+token x = x >>= \r -> spaces >> return r
+
+parse = do
+    spaces
+    many (token pragma)
+
+
+spaces = do
+    skipSpaces
+    optional (comment >> spaces)
+
+pragma = do
+    string "{-#"
+    skipSpaces
+    nn <- munch1 (\c -> isAlpha c || c == '_')
+    skipSpaces
+    body <- manyTill get (string "#-}")
+    return $ (nn,body)
+
+
+comment = line +++ block where
+    line = do
+        string "--"
+        manyTill get (char '\n')
+        return ()
+    block = do
+        string "{-"
+        satisfy (/= '#')
+        manyTill get (string "-}")
+        return ()
+
+
+
hunk ./Ho/Build.hs 46
+import FrontEnd.Syn.Options
hunk ./Ho/Build.hs 368
-parseHsSource fn s = case runParserWithMode (parseModeOptions options) { parseFilename = fn } parse  s'  of
+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
hunk ./Ho/Build.hs 377
-    where
-    s' = if "shl." `isPrefixOf` reverse fn  then unlit fn s else s
hunk ./Options.hs 207
-    (os,[],[]) -> postProcessFD (foldl (flip ($)) options os)
+    (os,[],[]) -> postProcessFD (foldl (flip ($)) options os) >>= postProcessFO