-----------------------------------------------------------------------------
--- $Id: GetImports.hs,v 1.6 2001/05/01 16:01:06 simonmar Exp $
+-- $Id: GetImports.hs,v 1.8 2001/06/27 11:11:03 simonmar Exp $
--
-- GHC Driver program
--
f si ni me [] = (nub si, nub ni, me)
mkMN str = mkModuleName (takeWhile isModId (reverse str))
- isModId c = isAlphaNum c || c `elem` "'_"
+ isModId c = isAlphaNum c || c `elem` "'._"
-- remove literals and comments from a string, producing a
keep acc ('\'':cs) = cons acc (squote cs)
keep acc ('-':'-':cs) = cons acc (linecomment cs)
keep acc ('{':'-':'#':' ':cs) = cons acc (cons "#-{" (keep "" cs))
- keep acc ('{':'-':cs) = cons acc (runcomment cs) -- -}
+ keep acc ('{':'-':cs) = cons acc (runcomment (0::Int) cs) -- -}
keep acc (c:cs) = keep (c:acc) cs
cons [] xs = xs
linecomment (c:cs) = linecomment cs
-- in a running comment
- runcomment [] = []
- runcomment ('-':'}':cs) = keep "" cs
- runcomment (c:cs) = runcomment cs
+ runcomment _ [] = []
+ runcomment n ('{':'-':cs) = runcomment (n+1) cs -- catches both nested comments and pragmas.
+ runcomment n ('-':'}':cs)
+ | n == 0 = keep "" cs
+ | otherwise = runcomment (n-1) cs
+ runcomment n (c:cs) = runcomment n cs