From: simonmar Date: Mon, 26 Mar 2001 16:54:10 +0000 (+0000) Subject: [project @ 2001-03-26 16:54:10 by simonmar] X-Git-Tag: Approximately_9120_patches~2308 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=645e947026d2ae77a4da965c57d1e0b5ed551eab;p=ghc-hetmet.git [project @ 2001-03-26 16:54:10 by simonmar] Remove unused file. --- diff --git a/ghc/driver/GetImports.hs b/ghc/driver/GetImports.hs deleted file mode 100644 index 7234b76..0000000 --- a/ghc/driver/GetImports.hs +++ /dev/null @@ -1,80 +0,0 @@ ------------------------------------------------------------------------------ --- $Id: GetImports.hs,v 1.1 2000/08/02 15:27:25 simonmar Exp $ --- --- Collect up the imports from a Haskell module. This is approximate: we don't --- parse the module, but we do eliminate comments and strings. --- --- (c) The GHC Team 2000 --- - -module GetImports (Import(..), getImports) where - -import List ( nub ) -import Char ( isAlphaNum ) - -data Import - = Normal String | Source String - deriving (Eq, Show) - -getImports :: String -> [Import] -getImports = nub . gmiBase . clean - --- really get the imports from a de-litted, cpp'd, de-literal'd string -gmiBase :: String -> [Import] -gmiBase s - = f (words s) - where - f ("foreign" : "import" : ws) = f ws - f ("import" : "{-#" : "SOURCE" : "#-}" : "qualified" : m : ws) - = Source (takeWhile isModId m) : f ws - f ("import" : "{-#" : "SOURCE" : "#-}" : m : ws) - = Source (takeWhile isModId m) : f ws - f ("import" : "qualified" : m : ws) - = Normal (takeWhile isModId m) : f ws - f ("import" : m : ws) - = Normal (takeWhile isModId m) : f ws - f (w:ws) = f ws - f [] = [] - -isModId c = isAlphaNum c || c `elem` "'_" - --- remove literals and comments from a string -clean :: String -> String -clean s - = keep s - where - -- running through text we want to keep - keep [] = [] - keep ('"':cs) = dquote cs - -- try to eliminate single quotes when they're part of - -- an identifier... - keep (c:'\'':cs) | isAlphaNum c || c == '_' = keep (dropWhile (=='\'') cs) - keep ('\'':cs) = squote cs - keep ('-':'-':cs) = linecomment cs - keep ('{':'-':'#':' ':cs) = "{-# " ++ keep cs - keep ('{':'-':cs) = runcomment cs - keep (c:cs) = c : keep cs - - -- in a double-quoted string - dquote [] = [] - dquote ('\\':'\"':cs) = dquote cs - dquote ('\\':'\\':cs) = dquote cs - dquote ('\"':cs) = keep cs - dquote (c:cs) = dquote cs - - -- in a single-quoted string - squote [] = [] - squote ('\\':'\'':cs) = squote cs - squote ('\\':'\\':cs) = squote cs - squote ('\'':cs) = keep cs - squote (c:cs) = squote cs - - -- in a line comment - linecomment [] = [] - linecomment ('\n':cs) = '\n':keep cs - linecomment (c:cs) = linecomment cs - - -- in a running comment - runcomment [] = [] - runcomment ('-':'}':cs) = keep cs - runcomment (c:cs) = runcomment cs