[project @ 2004-07-19 11:51:16 by simonmar]
[ghc-hetmet.git] / ghc / utils / hasktags / HaskTags.hs
index de2dd4e..9df6637 100644 (file)
@@ -24,10 +24,10 @@ main = do
        filenames <- getArgs
        filedata <- mapM findthings filenames
        ctagsfile <- openFile "tags" WriteMode
-       etagsfile <- openFile "TAGS" WriteMode
        writectagsfile ctagsfile filedata
-       writeetagsfile etagsfile filedata
        hClose ctagsfile
+       etagsfile <- openFile "TAGS" WriteMode
+       writeetagsfile etagsfile filedata
        hClose etagsfile
        
 type FileName = String
@@ -48,6 +48,7 @@ data FoundThing = FoundThing ThingName Pos
 
 -- Data we have obtained from a file
 data FileData = FileData FileName [FoundThing]
+       deriving Show
 
 data Token = Token String Pos
        deriving Show
@@ -121,13 +122,15 @@ withline filename words fullline i =
 -- comments stripping
 
 stripslcomments :: [String] -> [String]
-stripslcomments ("--":xs) = []
-stripslcomments (x:xs) = x : stripslcomments xs 
+stripslcomments (x:xs) | isPrefixOf "--" x = []
+                                          | otherwise = x : stripslcomments xs
 stripslcomments [] = []
 
 stripblockcomments :: [Token] -> [Token]
-stripblockcomments ((Token "\\end{code}" _):xs) = afterlitend xs
-stripblockcomments ((Token "{-" _):xs) = afterblockcomend xs
+stripblockcomments ((Token "\\end{code}" _):xs) = 
+       stripblockcomments $ afterlitend xs
+stripblockcomments ((Token "{-" _):xs) = 
+       stripblockcomments $ afterblockcomend xs
 stripblockcomments (x:xs) = x:stripblockcomments xs
 stripblockcomments [] = []