Print_AS_Library.hs revision 4646d2a52641d50df02fc5c68c275607cf79c398
ecd98975b8a8ab5a7bc075562bdab51cf47d2a90Christian MaederModule : $Header$
ecd98975b8a8ab5a7bc075562bdab51cf47d2a90Christian MaederDescription : pretty printing of CASL specification libaries
54ea981a0503c396c2923a1c06421c6235baf27fChristian MaederCopyright : (c) Klaus Luettich, Uni Bremen 2002-2006
ecd98975b8a8ab5a7bc075562bdab51cf47d2a90Christian MaederLicense : GPLv2 or higher, see LICENSE.txt
98890889ffb2e8f6f722b00e265a211f13b5a861Corneliu-Claudiu ProdescuMaintainer : Christian.Maeder@dfki.de
ecd98975b8a8ab5a7bc075562bdab51cf47d2a90Christian MaederStability : provisional
ecd98975b8a8ab5a7bc075562bdab51cf47d2a90Christian MaederPortability : non-portable(Grothendieck)
ecd98975b8a8ab5a7bc075562bdab51cf47d2a90Christian MaederPretty printing of CASL specification libaries
ecd98975b8a8ab5a7bc075562bdab51cf47d2a90Christian Maederimport Data.Maybe (maybeToList)
54ea981a0503c396c2923a1c06421c6235baf27fChristian Maederinstance PrettyLG LIB_DEFN where
54ea981a0503c396c2923a1c06421c6235baf27fChristian Maeder prettyLG lg (Lib_defn aa ab _ ad) =
54ea981a0503c396c2923a1c06421c6235baf27fChristian Maeder let aa' = pretty aa -- lib name
1a38107941725211e7c3f051f7a8f5e12199f03acmaeder ab' = vsep $ printLibItems lg ab -- LIB_ITEMs
54ea981a0503c396c2923a1c06421c6235baf27fChristian Maeder ad' = vcat $ map pretty ad -- global ANNOTATIONs
54ea981a0503c396c2923a1c06421c6235baf27fChristian Maeder in (if getLibId aa == nullIRI then empty else
ecd98975b8a8ab5a7bc075562bdab51cf47d2a90Christian Maeder keyword libraryS <+> aa') $++$ ad' $++$ ab'
6f08518fe3561930fef290b8e01384a6f1c90598Till MossakowskiprintLibItems :: LogicGraph -> [Annoted LIB_ITEM] -> [Doc]
6f08518fe3561930fef290b8e01384a6f1c90598Till MossakowskiprintLibItems lg is = case is of
6f08518fe3561930fef290b8e01384a6f1c90598Till Mossakowski i : rs -> prettyLG lg i : printLibItems (case item i of
6f08518fe3561930fef290b8e01384a6f1c90598Till Mossakowski Logic_decl aa _ -> setLogicName aa lg
54ea981a0503c396c2923a1c06421c6235baf27fChristian Maederinstance PrettyLG VIEW_TYPE where
ecd98975b8a8ab5a7bc075562bdab51cf47d2a90Christian Maeder prettyLG = prettyViewType []
1e39a4ee4e97d16c48003d49e4af3d181f25ad71Christian MaederprettyViewType :: [a] -> LogicGraph -> VIEW_TYPE -> Doc
1e39a4ee4e97d16c48003d49e4af3d181f25ad71Christian MaederprettyViewType ad lg (View_type frm to _) =
1e39a4ee4e97d16c48003d49e4af3d181f25ad71Christian Maeder sep [ printGroupSpec lg frm <+> keyword toS
f456529a89bfb620d39e5fd5b0a53b24643db96dDominik Luecke , (if null ad then id else (<+> equals))
7ab2df3001654dd1b7a2cfc3da1ccef11c39a503Christian Maeder $ printGroupSpec lg to]
54ea981a0503c396c2923a1c06421c6235baf27fChristian Maederinstance PrettyLG LIB_ITEM where
54ea981a0503c396c2923a1c06421c6235baf27fChristian Maeder prettyLG lg li = case li of
54ea981a0503c396c2923a1c06421c6235baf27fChristian Maeder Spec_defn si (Genericity aa@(Params pl) ab@(Imported il) _) ac' _ ->
54ea981a0503c396c2923a1c06421c6235baf27fChristian Maeder let las = l_annos ac'
d0642e0d269791a923f2bf86ea249f971f14addbChristian Maeder (sa, ac) = if startsWithSemanticAnno las then