LGToXml.hs revision cd390eed6d6162e259b97424ef4a867124c08717
9ebbce450fb242e1a346f9f89367d8c46fcb2ec8Andy Gimblett{- |
9ebbce450fb242e1a346f9f89367d8c46fcb2ec8Andy GimblettModule : $Header$
9ebbce450fb242e1a346f9f89367d8c46fcb2ec8Andy GimblettDescription : export logic graph information as XML
9ebbce450fb242e1a346f9f89367d8c46fcb2ec8Andy GimblettCopyright : (c) Christian Maeder DFKI GmbH 2013
9ebbce450fb242e1a346f9f89367d8c46fcb2ec8Andy GimblettLicense : GPLv2 or higher, see LICENSE.txt
9ebbce450fb242e1a346f9f89367d8c46fcb2ec8Andy Gimblett
9ebbce450fb242e1a346f9f89367d8c46fcb2ec8Andy GimblettMaintainer : Christian.Maeder@dfki.de
9ebbce450fb242e1a346f9f89367d8c46fcb2ec8Andy GimblettStability : provisional
9ebbce450fb242e1a346f9f89367d8c46fcb2ec8Andy GimblettPortability : non-portable (via imports)
9ebbce450fb242e1a346f9f89367d8c46fcb2ec8Andy Gimblett
9ebbce450fb242e1a346f9f89367d8c46fcb2ec8Andy Gimblettexport logic graph information as XML
9ebbce450fb242e1a346f9f89367d8c46fcb2ec8Andy Gimblett-}
9ebbce450fb242e1a346f9f89367d8c46fcb2ec8Andy Gimblett
9ebbce450fb242e1a346f9f89367d8c46fcb2ec8Andy Gimblettmodule Logic.LGToXml where
2cf5a456da8bb3a2bbb695414d8304426e3bd277Andy Gimblett
2cf5a456da8bb3a2bbb695414d8304426e3bd277Andy Gimblettimport Logic.Comorphism
2cf5a456da8bb3a2bbb695414d8304426e3bd277Andy Gimblettimport Logic.Grothendieck
2cf5a456da8bb3a2bbb695414d8304426e3bd277Andy Gimblettimport Logic.Logic
2cf5a456da8bb3a2bbb695414d8304426e3bd277Andy Gimblettimport Logic.Prover
2cf5a456da8bb3a2bbb695414d8304426e3bd277Andy Gimblett
2cf5a456da8bb3a2bbb695414d8304426e3bd277Andy Gimblettimport qualified Data.Map as Map
2cf5a456da8bb3a2bbb695414d8304426e3bd277Andy Gimblettimport qualified Data.Set as Set
2cf5a456da8bb3a2bbb695414d8304426e3bd277Andy Gimblettimport Data.Maybe
2cf5a456da8bb3a2bbb695414d8304426e3bd277Andy Gimblett
2cf5a456da8bb3a2bbb695414d8304426e3bd277Andy Gimblettimport Common.Consistency
2cf5a456da8bb3a2bbb695414d8304426e3bd277Andy Gimblettimport Common.ToXml
2cf5a456da8bb3a2bbb695414d8304426e3bd277Andy Gimblett
2cf5a456da8bb3a2bbb695414d8304426e3bd277Andy Gimblettimport Text.XML.Light
2cf5a456da8bb3a2bbb695414d8304426e3bd277Andy Gimblett
2cf5a456da8bb3a2bbb695414d8304426e3bd277Andy GimblettlGToXml :: LogicGraph -> Element
2cf5a456da8bb3a2bbb695414d8304426e3bd277Andy GimblettlGToXml lg = let
2cf5a456da8bb3a2bbb695414d8304426e3bd277Andy Gimblett cs = Map.elems $ comorphisms lg
2cf5a456da8bb3a2bbb695414d8304426e3bd277Andy Gimblett ssubs = Set.toList . Set.fromList
2cf5a456da8bb3a2bbb695414d8304426e3bd277Andy Gimblett $ map (\ (Comorphism cid) -> G_sublogics (sourceLogic cid)
2cf5a456da8bb3a2bbb695414d8304426e3bd277Andy Gimblett $ sourceSublogic cid) cs
9ebbce450fb242e1a346f9f89367d8c46fcb2ec8Andy Gimblett tsubs = Set.toList . Set.fromList
9ebbce450fb242e1a346f9f89367d8c46fcb2ec8Andy Gimblett $ map (\ (Comorphism cid) -> G_sublogics (targetLogic cid)
9ebbce450fb242e1a346f9f89367d8c46fcb2ec8Andy Gimblett $ targetSublogic cid) cs
9ebbce450fb242e1a346f9f89367d8c46fcb2ec8Andy Gimblett in unode "LogicGraph"
2cf5a456da8bb3a2bbb695414d8304426e3bd277Andy Gimblett $ map logicToXml (Map.elems $ logics lg)
2cf5a456da8bb3a2bbb695414d8304426e3bd277Andy Gimblett ++ map (\ a -> add_attr (mkNameAttr $ show a) $ unode "sourceSublogic" ())
9ebbce450fb242e1a346f9f89367d8c46fcb2ec8Andy Gimblett ssubs
9ebbce450fb242e1a346f9f89367d8c46fcb2ec8Andy Gimblett ++ map (\ a -> add_attr (mkNameAttr $ show a) $ unode "targetSublogic" ())
9ebbce450fb242e1a346f9f89367d8c46fcb2ec8Andy Gimblett tsubs
9ebbce450fb242e1a346f9f89367d8c46fcb2ec8Andy Gimblett ++ map comorphismToXml cs
9ebbce450fb242e1a346f9f89367d8c46fcb2ec8Andy Gimblett
9ebbce450fb242e1a346f9f89367d8c46fcb2ec8Andy GimblettlogicToXml :: AnyLogic -> Element
9ebbce450fb242e1a346f9f89367d8c46fcb2ec8Andy GimblettlogicToXml (Logic lid) = add_attrs
9ebbce450fb242e1a346f9f89367d8c46fcb2ec8Andy Gimblett [ mkNameAttr $ language_name lid
2cf5a456da8bb3a2bbb695414d8304426e3bd277Andy Gimblett , mkAttr "Stability" . show $ stability lid
aa0d5f8be9950e788884f7431cf4cb7bee74788cAndy Gimblett , mkAttr "has_basic_parser" . show . not . Map.null $ parsersAndPrinters lid
9ebbce450fb242e1a346f9f89367d8c46fcb2ec8Andy Gimblett , mkAttr "has_basic_analysis" . show . isJust $ basic_analysis lid
2cf5a456da8bb3a2bbb695414d8304426e3bd277Andy Gimblett , mkAttr "has_symbol_list_parser" . show . isJust $ parse_symb_items lid
9ebbce450fb242e1a346f9f89367d8c46fcb2ec8Andy Gimblett , mkAttr "has_symbol_map_parser" . show . isJust $ parse_symb_map_items lid
9ebbce450fb242e1a346f9f89367d8c46fcb2ec8Andy Gimblett , mkAttr "is_a_process_logic" . show . isJust $ data_logic lid
9ebbce450fb242e1a346f9f89367d8c46fcb2ec8Andy Gimblett ] . unode "logic"
aa0d5f8be9950e788884f7431cf4cb7bee74788cAndy Gimblett $ unode "Description" (mkText $ description lid)
9ebbce450fb242e1a346f9f89367d8c46fcb2ec8Andy Gimblett : map (\ a -> add_attr (mkNameAttr a) $ unode "Serialization" ())
9ebbce450fb242e1a346f9f89367d8c46fcb2ec8Andy Gimblett (filter (not . null) . Map.keys $ parsersAndPrinters lid)
9ebbce450fb242e1a346f9f89367d8c46fcb2ec8Andy Gimblett ++ map (\ a -> add_attr (mkNameAttr $ proverName a) $ unode "Prover" ())
aa0d5f8be9950e788884f7431cf4cb7bee74788cAndy Gimblett (provers lid)
aa0d5f8be9950e788884f7431cf4cb7bee74788cAndy Gimblett ++ map (\ a -> add_attr (mkNameAttr $ ccName a)
9ebbce450fb242e1a346f9f89367d8c46fcb2ec8Andy Gimblett $ unode "ConsistencyChecker" ()) (cons_checkers lid)
9ebbce450fb242e1a346f9f89367d8c46fcb2ec8Andy Gimblett ++ map (\ a -> add_attr (mkNameAttr $ checkerId a)
9ebbce450fb242e1a346f9f89367d8c46fcb2ec8Andy Gimblett $ unode "ConservativityChecker" ()) (conservativityCheck lid)
9ebbce450fb242e1a346f9f89367d8c46fcb2ec8Andy Gimblett
9ebbce450fb242e1a346f9f89367d8c46fcb2ec8Andy GimblettcomorphismToXml :: AnyComorphism -> Element
9ebbce450fb242e1a346f9f89367d8c46fcb2ec8Andy GimblettcomorphismToXml (Comorphism cid) = add_attrs
9ebbce450fb242e1a346f9f89367d8c46fcb2ec8Andy Gimblett [ mkNameAttr $ language_name cid
9ebbce450fb242e1a346f9f89367d8c46fcb2ec8Andy Gimblett , mkAttr "source" $ language_name (sourceLogic cid)
9ebbce450fb242e1a346f9f89367d8c46fcb2ec8Andy Gimblett , mkAttr "target" $ language_name (targetLogic cid)
2cf5a456da8bb3a2bbb695414d8304426e3bd277Andy Gimblett , mkAttr "sourceSublogic" . sublogicName $ sourceSublogic cid
2cf5a456da8bb3a2bbb695414d8304426e3bd277Andy Gimblett , mkAttr "targetSublogic" . sublogicName $ targetSublogic cid
2cf5a456da8bb3a2bbb695414d8304426e3bd277Andy Gimblett , mkAttr "is_inclusion" . show $ isInclusionComorphism cid
2cf5a456da8bb3a2bbb695414d8304426e3bd277Andy Gimblett , mkAttr "has_model_expansion" . show $ has_model_expansion cid
2cf5a456da8bb3a2bbb695414d8304426e3bd277Andy Gimblett , mkAttr "is_weakly_amalgamable" . show $ is_weakly_amalgamable cid
2cf5a456da8bb3a2bbb695414d8304426e3bd277Andy Gimblett ] $ unode "comorphism" ()
2cf5a456da8bb3a2bbb695414d8304426e3bd277Andy Gimblett