Print_AS.hs revision d7b3ce2c285453331cca8ac7bec7a3b49b3e1ee9
beff4152e9f0fe90885458d1a1733b183a2a8816Christian MaederModule : $Header$
b53688bfed888214b485cf76439d57262d80e0a7Christian MaederCopyright : (c) T. Mossakowski, Uni Bremen 2004-2006
e6d40133bc9f858308654afb1262b8b483ec5922Till MossakowskiLicense : similar to LGPL, see HetCATS/LICENSE.txt or LIZENZ.txt
98890889ffb2e8f6f722b00e265a211f13b5a861Corneliu-Claudiu ProdescuMaintainer : hausmann@tzi.de
b53688bfed888214b485cf76439d57262d80e0a7Christian MaederStability : provisional
3f69b6948966979163bdfe8331c38833d5d90ecdChristian MaederPortability : portable
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederprinting AS_CoCASL and CoCASLSign data types
109a53dbf4c9233f869f63ba7a7f3fece49973c3Christian Maederinstance PrettyPrint C_BASIC_ITEM where
109a53dbf4c9233f869f63ba7a7f3fece49973c3Christian Maederinstance Pretty C_BASIC_ITEM where
109a53dbf4c9233f869f63ba7a7f3fece49973c3Christian Maeder pretty = printC_BASIC_ITEM
85e1d54a475bfc30b3eac5ae6c5e42a2d7e93f10Christian MaederprintC_BASIC_ITEM :: C_BASIC_ITEM -> Doc
109a53dbf4c9233f869f63ba7a7f3fece49973c3Christian MaederprintC_BASIC_ITEM cb = case cb of
91e24fc45834b35f2a3830d72565640251149bf3Christian Maeder CoFree_datatype l _ -> text cofreeS <+> text (cotypeS ++ pluralS l)
109a53dbf4c9233f869f63ba7a7f3fece49973c3Christian Maeder <+> (fsep $ punctuate semi $ map (printAnnoted printCODATATYPE_DECL) l)
109a53dbf4c9233f869f63ba7a7f3fece49973c3Christian Maeder CoSort_gen l _ -> case l of
109a53dbf4c9233f869f63ba7a7f3fece49973c3Christian Maeder [Annoted (Ext_SIG_ITEMS (CoDatatype_items l' _)) _ _ _] ->
109a53dbf4c9233f869f63ba7a7f3fece49973c3Christian Maeder keyword cogeneratedS <+> keyword (cotypeS ++ pluralS l') <+>
109a53dbf4c9233f869f63ba7a7f3fece49973c3Christian Maeder semiAnnos printCODATATYPE_DECL l'
109a53dbf4c9233f869f63ba7a7f3fece49973c3Christian Maeder _ -> keyword cogeneratedS <+>
109a53dbf4c9233f869f63ba7a7f3fece49973c3Christian Maeder (specBraces $ vcat $ map pretty l)
109a53dbf4c9233f869f63ba7a7f3fece49973c3Christian Maederinstance PrettyPrint C_SIG_ITEM where
109a53dbf4c9233f869f63ba7a7f3fece49973c3Christian Maederinstance Pretty C_SIG_ITEM where
109a53dbf4c9233f869f63ba7a7f3fece49973c3Christian Maeder pretty = printC_SIG_ITEM
109a53dbf4c9233f869f63ba7a7f3fece49973c3Christian MaederprintC_SIG_ITEM :: C_SIG_ITEM -> Doc
109a53dbf4c9233f869f63ba7a7f3fece49973c3Christian MaederprintC_SIG_ITEM (CoDatatype_items l _) =
109a53dbf4c9233f869f63ba7a7f3fece49973c3Christian Maeder text (cotypeS ++ pluralS l) <+>
bbba6dd86153aacb0f662b182b128df0eb09fd54Christian Maeder (fsep $ punctuate semi $ map (printAnnoted printCODATATYPE_DECL) l)
a461314c811f4187dff85c8be079a41b2f13f176Christian Maederinstance PrettyPrint CODATATYPE_DECL where
109a53dbf4c9233f869f63ba7a7f3fece49973c3Christian Maederinstance Pretty CODATATYPE_DECL where
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder pretty = printCODATATYPE_DECL
be43c3fa0292555bd126784ae27ff5c1d23438cbChristian MaederprintCODATATYPE_DECL :: CODATATYPE_DECL -> Doc
b53688bfed888214b485cf76439d57262d80e0a7Christian MaederprintCODATATYPE_DECL (CoDatatype_decl s a _) = case a of
16b71dad8d398af412d66a4f4763f1ada5b03d23Christian Maeder [] -> idDoc s
f39b8dd9651dfcc38b06191cda23cacbfc298323Christian Maeder _ -> fsep [idDoc s, defn, sep $ punctuate (space <> bar) $
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder map (printAnnoted printCOALTERNATIVE) a]
3a9d784341454573b50b32fa1b494e7418df3086Christian Maederinstance PrettyPrint COALTERNATIVE where
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederinstance Pretty COALTERNATIVE where
9d6562465b41f17c7967d4e5678f34811d958cb2Christian Maeder pretty = printCOALTERNATIVE
502483734c83d0bf1eadcc94113d0362f8713784Christian MaederprintCOALTERNATIVE :: COALTERNATIVE -> Doc
b53688bfed888214b485cf76439d57262d80e0a7Christian MaederprintCOALTERNATIVE coal = case coal of
be43c3fa0292555bd126784ae27ff5c1d23438cbChristian Maeder Co_construct k n l _ -> case n of
7f7460e7095628f3437b116ee78d3043d11f8febChristian Maeder Nothing -> empty
16b71dad8d398af412d66a4f4763f1ada5b03d23Christian Maeder Just i -> idDoc i
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder <> (case l of
96ae1a1d2197d0e0d5b80da2474b64c456feb1b0Christian Maeder [] -> case k of
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder Total -> empty
38c817b94e0a5b1ae94178b1075c187e07bcc5e1Christian Maeder _ -> parens empty
38c817b94e0a5b1ae94178b1075c187e07bcc5e1Christian Maeder _ -> parens (fsep $ punctuate semi $ map printCOCOMPONENTS l))
38c817b94e0a5b1ae94178b1075c187e07bcc5e1Christian Maeder Total -> empty
4eb859461f8fd904f40f57261cf23e5c73cf8ecaChristian Maeder _ -> text quMark
4eb859461f8fd904f40f57261cf23e5c73cf8ecaChristian Maeder CoSubsorts l _ -> fsep $ text (sortS ++ if isSingle l then "" else "s")
4eb859461f8fd904f40f57261cf23e5c73cf8ecaChristian Maeder : punctuate comma (map idDoc l)
4eb859461f8fd904f40f57261cf23e5c73cf8ecaChristian Maederinstance PrettyPrint COCOMPONENTS where
2353f65833a3da763392f771223250cd50b8d873Christian Maederinstance Pretty COCOMPONENTS where
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder pretty = printCOCOMPONENTS
dff1de7ad15d1582e25d636c3724dd202874897fChristian MaederprintCOCOMPONENTS :: COCOMPONENTS -> Doc
96ae1a1d2197d0e0d5b80da2474b64c456feb1b0Christian MaederprintCOCOMPONENTS (CoSelect l s _) =
8c8545dd3bf34fbcbc16904b65d249658f8f9efcChristian Maeder (fsep $ punctuate comma $ map idDoc l)
d81905a5b924415c524d702df26204683c82c12eChristian Maeder <> printOpType s
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederinstance PrettyPrint C_FORMULA where
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederinstance Pretty C_FORMULA where
dff1de7ad15d1582e25d636c3724dd202874897fChristian Maeder pretty = printC_FORMULA
cb2044812811d66efe038d914966e04290be93faChristian MaederprintC_FORMULA :: C_FORMULA -> Doc
b53688bfed888214b485cf76439d57262d80e0a7Christian MaederprintC_FORMULA cf = case cf of
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder BoxOrDiamond b t f _ -> let sp = case t of
dff1de7ad15d1582e25d636c3724dd202874897fChristian Maeder Simple_mod _ -> (<>)
083bc1972a66d73749760eab3a90bf4eb9ca7951Christian Maeder td = printMODALITY t
6352f3c31da3043783a13be6594aacb2147378baRazvan Pascanu fd = printFormula printC_FORMULA f
fefee7e1dee1ee5f0768a03a4abae88d1ca2c3fdRazvan Pascanu in if b then brackets td <> fd
b324cda6178c49ddeead3ce62b832ccf644cbcabRazvan Pascanu else text lessS `sp` td `sp` text greaterS <+> fd
fefee7e1dee1ee5f0768a03a4abae88d1ca2c3fdRazvan Pascanu CoSort_gen_ax sorts ops _ -> text cogeneratedS <>
bc263f610d20a9cd3014ddfca903026127fa0d48Christian Maeder specBraces (text sortS <+>
966519955f5f7111abac20118563132b9dd41165Christian Maeder (fsep $ punctuate comma $ map idDoc sorts) <> semi <+>
8c8545dd3bf34fbcbc16904b65d249658f8f9efcChristian Maeder (fsep $ punctuate semi $ map printOpSymb ops))
0b13f102310e03a20b38c870b5acb88712f316a4Christian Maederinstance PrettyPrint MODALITY where
33fcc19ef2b59493b4e91eebf701df95fd230765Christian Maederinstance Pretty MODALITY where
33fcc19ef2b59493b4e91eebf701df95fd230765Christian Maeder pretty = printMODALITY
d4ebd9e5adc974cfa2bdf4bdd155e07be0e26f75Christian MaederprintMODALITY :: MODALITY -> Doc
d4ebd9e5adc974cfa2bdf4bdd155e07be0e26f75Christian MaederprintMODALITY mod = case mod of
0d79ea4ed8512a802ecb6645edac141e0fbcee3fChristian Maeder Simple_mod ident -> sidDoc ident
0d79ea4ed8512a802ecb6645edac141e0fbcee3fChristian Maeder Term_mod t -> printTerm printC_FORMULA t
a31430de8b0632d29f42634d6395e982bf31b14dChristian Maederinstance PrettyPrint CoCASLSign where
ce8a93047aaf0dc36fa221642292d47852a9862aChristian Maederinstance Pretty CoCASLSign where
ce8a93047aaf0dc36fa221642292d47852a9862aChristian Maeder pretty = printCoCASLSign
9f4902edfa3d477e42343e0ec357a2f93b1119d1Christian MaederprintCoCASLSign :: CoCASLSign -> Doc
9f4902edfa3d477e42343e0ec357a2f93b1119d1Christian MaederprintCoCASLSign _ = empty
9f4902edfa3d477e42343e0ec357a2f93b1119d1Christian Maederinstance ListCheck CODATATYPE_DECL where
9f4902edfa3d477e42343e0ec357a2f93b1119d1Christian Maeder innerList (CoDatatype_decl _ _ _) = [()]