From: simonmar Date: Fri, 8 Feb 2002 14:59:19 +0000 (+0000) Subject: [project @ 2002-02-08 14:59:19 by simonmar] X-Git-Tag: Approximately_9120_patches~117 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=d5fce8fab0c607109c834005742a7ec6949c822b;p=ghc-hetmet.git [project @ 2002-02-08 14:59:19 by simonmar] Don't use RegexString to parse OPTIONS pragmas, instead do the matching by hand, thereby removing a dependency on RegexString (and hence Regex). --- diff --git a/ghc/compiler/main/DriverUtil.hs b/ghc/compiler/main/DriverUtil.hs index 0be0937..6dcc627 100644 --- a/ghc/compiler/main/DriverUtil.hs +++ b/ghc/compiler/main/DriverUtil.hs @@ -1,5 +1,5 @@ ----------------------------------------------------------------------------- --- $Id: DriverUtil.hs,v 1.29 2002/01/22 14:47:52 simonmar Exp $ +-- $Id: DriverUtil.hs,v 1.30 2002/02/08 14:59:19 simonmar Exp $ -- -- Utils for the driver -- @@ -19,7 +19,6 @@ import Config ( cLeadingUnderscore ) import IOExts import Exception import Dynamic -import RegexString import Directory ( getDirectoryContents ) import IO @@ -27,10 +26,6 @@ import List import Char import Monad - ------------------------------------------------------------------------------ --- Errors - ----------------------------------------------------------------------------- -- Reading OPTIONS pragmas @@ -49,12 +44,18 @@ getOptionsFromSource file () | null l -> look h | prefixMatch "#" l -> look h | prefixMatch "{-# LINE" l -> look h -- -} - | Just (opts:_) <- matchRegex optionRegex l + | Just opts <- matchOptions l -> do rest <- look h return (words opts ++ rest) | otherwise -> return [] -optionRegex = mkRegex "\\{-#[ \t]+OPTIONS[ \t]+(.*)#-\\}" -- -} +matchOptions s + | Just s1 <- my_prefix_match "{-#" s, + Just s2 <- my_prefix_match "OPTIONS" (remove_spaces s1), + Just s3 <- my_prefix_match "}-#" (reverse s2) + = Just (reverse s3) + | otherwise + = Nothing ----------------------------------------------------------------------------- -- A version of getDirectoryContents that is non-fatal if the