ReadLibDefn.hs revision 2ca39b9545cad63df411619615736d9070ad7932
a78048ccbdb6256da15e6b0e7e95355e480c2301nd{-# LANGUAGE CPP #-}
a78048ccbdb6256da15e6b0e7e95355e480c2301nd{- |
a78048ccbdb6256da15e6b0e7e95355e480c2301ndModule : $Header$
a78048ccbdb6256da15e6b0e7e95355e480c2301ndDescription : reading Lib-Defns
a78048ccbdb6256da15e6b0e7e95355e480c2301ndCopyright : (c) C. Maeder, DFKI 2014
a78048ccbdb6256da15e6b0e7e95355e480c2301ndLicense : GPLv2 or higher, see LICENSE.txt
a78048ccbdb6256da15e6b0e7e95355e480c2301nd
a78048ccbdb6256da15e6b0e7e95355e480c2301ndMaintainer : Christian.Maeder@dfki.de
a78048ccbdb6256da15e6b0e7e95355e480c2301ndStability : provisional
a78048ccbdb6256da15e6b0e7e95355e480c2301ndPortability : non-portable(DevGraph)
a78048ccbdb6256da15e6b0e7e95355e480c2301nd
a78048ccbdb6256da15e6b0e7e95355e480c2301ndreading Lib-Defns for various logics, OWL and CL return several Lib-Defns
a78048ccbdb6256da15e6b0e7e95355e480c2301nd-}
a78048ccbdb6256da15e6b0e7e95355e480c2301nd
a78048ccbdb6256da15e6b0e7e95355e480c2301ndmodule Driver.ReadLibDefn where
27e52281f1522522b170cafc76b08b58aa70ccaand
a78048ccbdb6256da15e6b0e7e95355e480c2301ndimport Logic.Grothendieck
a78048ccbdb6256da15e6b0e7e95355e480c2301nd
a78048ccbdb6256da15e6b0e7e95355e480c2301ndimport Syntax.AS_Library
4b5981e276e93df97c34e4da05ca5cf8bbd937dandimport Syntax.Parse_AS_Library
a78048ccbdb6256da15e6b0e7e95355e480c2301nd
a78048ccbdb6256da15e6b0e7e95355e480c2301ndimport ATC.Sml_cats
a78048ccbdb6256da15e6b0e7e95355e480c2301ndimport ATC.LibName ()
a78048ccbdb6256da15e6b0e7e95355e480c2301nd
a78048ccbdb6256da15e6b0e7e95355e480c2301ndimport CommonLogic.ParseCLAsLibDefn
f3ec420152ca921e4c1ce77782f51b53f659018dnd#ifndef NOOWLLOGIC
f3ec420152ca921e4c1ce77782f51b53f659018dndimport OWL2.ParseOWLAsLibDefn
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#endif
90e0f7946d156746192720014bfcbe60de379b94nd#ifdef RDFLOGIC
90e0f7946d156746192720014bfcbe60de379b94nd-- import RDF.ParseRDFAsLibDefn
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#endif
a78048ccbdb6256da15e6b0e7e95355e480c2301ndimport CSMOF.ParseXmiAsLibDefn
a78048ccbdb6256da15e6b0e7e95355e480c2301ndimport QVTR.ParseQvtAsLibDefn
a78048ccbdb6256da15e6b0e7e95355e480c2301ndimport SoftFOL.ParseTPTPAsLibDefn
a78048ccbdb6256da15e6b0e7e95355e480c2301ndimport FreeCAD.Logic_FreeCAD
a78048ccbdb6256da15e6b0e7e95355e480c2301nd
a78048ccbdb6256da15e6b0e7e95355e480c2301ndimport Driver.Options
a78048ccbdb6256da15e6b0e7e95355e480c2301ndimport Driver.ReadFn
a78048ccbdb6256da15e6b0e7e95355e480c2301nd
a78048ccbdb6256da15e6b0e7e95355e480c2301ndimport Common.AnnoState
a78048ccbdb6256da15e6b0e7e95355e480c2301ndimport Common.Result
a78048ccbdb6256da15e6b0e7e95355e480c2301nd
a78048ccbdb6256da15e6b0e7e95355e480c2301ndimport Text.ParserCombinators.Parsec
a78048ccbdb6256da15e6b0e7e95355e480c2301nd
a78048ccbdb6256da15e6b0e7e95355e480c2301ndimport Control.Monad.Trans (MonadIO (..))
a78048ccbdb6256da15e6b0e7e95355e480c2301nd
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 _ -> do
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#endif
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#endif
a78048ccbdb6256da15e6b0e7e95355e480c2301nd _ -> case runParser (library lgraph) (emptyAnnos ()) fileForPos input of
a78048ccbdb6256da15e6b0e7e95355e480c2301nd Left err -> fail (showErr err)
a78048ccbdb6256da15e6b0e7e95355e480c2301nd Right ast -> return [ast]
a78048ccbdb6256da15e6b0e7e95355e480c2301nd