ReadLibDefn.hs revision 2ca39b9545cad63df411619615736d9070ad7932
a78048ccbdb6256da15e6b0e7e95355e480c2301nd{-# LANGUAGE CPP #-}
a78048ccbdb6256da15e6b0e7e95355e480c2301ndModule : $Header$
a78048ccbdb6256da15e6b0e7e95355e480c2301ndDescription : reading Lib-Defns
a78048ccbdb6256da15e6b0e7e95355e480c2301ndCopyright : (c) C. Maeder, DFKI 2014
a78048ccbdb6256da15e6b0e7e95355e480c2301ndLicense : GPLv2 or higher, see LICENSE.txt
a78048ccbdb6256da15e6b0e7e95355e480c2301ndMaintainer : Christian.Maeder@dfki.de
a78048ccbdb6256da15e6b0e7e95355e480c2301ndStability : provisional
a78048ccbdb6256da15e6b0e7e95355e480c2301ndPortability : non-portable(DevGraph)
a78048ccbdb6256da15e6b0e7e95355e480c2301ndreading Lib-Defns for various logics, OWL and CL return several Lib-Defns
f3ec420152ca921e4c1ce77782f51b53f659018dnd#ifndef NOOWLLOGIC
90e0f7946d156746192720014bfcbe60de379b94nd#ifdef RDFLOGIC
a78048ccbdb6256da15e6b0e7e95355e480c2301ndimport Control.Monad.Trans (MonadIO (..))
a78048ccbdb6256da15e6b0e7e95355e480c2301ndreadLibDefn :: MonadIO m => LogicGraph -> HetcatsOpts -> FilePath
a78048ccbdb6256da15e6b0e7e95355e480c2301nd -> FilePath -> String -> m [LIB_DEFN]
a78048ccbdb6256da15e6b0e7e95355e480c2301ndreadLibDefn lgraph opts file fileForPos input =
a78048ccbdb6256da15e6b0e7e95355e480c2301nd if null input then fail ("empty input file: " ++ file) else
a78048ccbdb6256da15e6b0e7e95355e480c2301nd case intype opts of
a78048ccbdb6256da15e6b0e7e95355e480c2301nd ATermIn _ -> return [from_sml_ATermString input]
a78048ccbdb6256da15e6b0e7e95355e480c2301nd FreeCADIn ->
a78048ccbdb6256da15e6b0e7e95355e480c2301nd liftIO $ fmap (: []) . readFreeCADLib file $ fileToLibName opts file
a78048ccbdb6256da15e6b0e7e95355e480c2301nd ty <- guessInput opts file input
a78048ccbdb6256da15e6b0e7e95355e480c2301nd case ty of
a78048ccbdb6256da15e6b0e7e95355e480c2301nd CommonLogicIn _ -> liftIO $ parseCL_CLIF file opts
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#ifdef RDFLOGIC
a78048ccbdb6256da15e6b0e7e95355e480c2301nd -- - RDFIn -> liftIO $ parseRDF file
a78048ccbdb6256da15e6b0e7e95355e480c2301nd Xmi -> liftIO $ fmap (: []) $ parseXmi file
a78048ccbdb6256da15e6b0e7e95355e480c2301nd Qvt -> liftIO $ fmap (: []) $ parseQvt file
a78048ccbdb6256da15e6b0e7e95355e480c2301nd TPTPIn -> liftIO $ fmap (: []) $ parseTPTP file
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#ifndef NOOWLLOGIC
a78048ccbdb6256da15e6b0e7e95355e480c2301nd _ | elem ty [OWLIn, OwlXmlIn, OBOIn] -> liftIO $ parseOWL file
a78048ccbdb6256da15e6b0e7e95355e480c2301nd _ -> case runParser (library lgraph) (emptyAnnos ()) fileForPos input of
a78048ccbdb6256da15e6b0e7e95355e480c2301nd Left err -> fail (showErr err)
a78048ccbdb6256da15e6b0e7e95355e480c2301nd Right ast -> return [ast]