+ let modes = getMode flags
+ let openFileMode = if elem FlagAppend flags
+ then AppendMode
+ else WriteMode
+ ctags_hdl <- if CTags `elem` modes
+ then Just `liftM` openFile "tags" openFileMode
+ else return Nothing
+ etags_hdl <- if ETags `elem` modes
+ then Just `liftM` openFile "TAGS" openFileMode
+ else return Nothing
+
+ GHC.defaultErrorHandler defaultDynFlags $ do
+ session <- newSession (Just ghc_topdir)
+ dflags <- getSessionDynFlags session
+ (pflags, _) <- parseDynamicFlags dflags{ verbosity=1 } ghcArgs
+ let dflags2 = pflags { hscTarget = HscNothing } -- don't generate anything
+ GHC.defaultCleanupHandler dflags2 $ do
+
+ setSessionDynFlags session dflags2
+ targetsAtOneGo session hsfiles (ctags_hdl,etags_hdl)
+ mapM_ (mapM hClose) [ctags_hdl, etags_hdl]