Print_AS_Structured.hs revision b25c72845890740c2f8a21214752574990b943cf
ccb84c1cb43fb0ed70c5bf2d364e671820473ed5Francisc Nicolae BungiuModule : $Header$
734257b9ea9fcaa18d4e3627f54f5295a99aa1f7Felix Gabriel ManceDescription : pretty printing of CASL structured specifications
ccb84c1cb43fb0ed70c5bf2d364e671820473ed5Francisc Nicolae BungiuCopyright : (c) Klaus Luettich, Uni Bremen 2002-2006
ccb84c1cb43fb0ed70c5bf2d364e671820473ed5Francisc Nicolae BungiuLicense : GPLv2 or higher, see LICENSE.txt
ccb84c1cb43fb0ed70c5bf2d364e671820473ed5Francisc Nicolae BungiuMaintainer : Christian.Maeder@dfki.de
ccb84c1cb43fb0ed70c5bf2d364e671820473ed5Francisc Nicolae BungiuStability : provisional
ccb84c1cb43fb0ed70c5bf2d364e671820473ed5Francisc Nicolae BungiuPortability : non-portable(Grothendieck)
c038fcf2030a6cfac7a261dee48a9eb29edb78eaFelix Gabriel MancePretty printing of CASL structured specifications
c038fcf2030a6cfac7a261dee48a9eb29edb78eaFelix Gabriel Mance ( structSimpleId
c038fcf2030a6cfac7a261dee48a9eb29edb78eaFelix Gabriel Mance , printGroupSpec
ccb84c1cb43fb0ed70c5bf2d364e671820473ed5Francisc Nicolae Bungiu , skipVoidGroup
ccb84c1cb43fb0ed70c5bf2d364e671820473ed5Francisc Nicolae Bungiu , printExtension
e5dc5119231bdeb5c604f7709e0fa197fd2c4829Felix Gabriel MancestructSimpleId :: SIMPLE_ID -> Doc
0be7a9c012366ada63d587898a15c551b499b76dFelix Gabriel MancestructSimpleId = structId . tokStr
30e9cf458094e5970bc06be667558961c2eccff4Felix Gabriel Manceinstance Pretty SPEC where
30e9cf458094e5970bc06be667558961c2eccff4Felix Gabriel Mance pretty = printSPEC
30e9cf458094e5970bc06be667558961c2eccff4Felix Gabriel ManceprintUnion :: [Annoted SPEC] -> [Doc]
2c0c0264249b8d2a3f465e22cb3c6d9c4ac8924aFelix Gabriel ManceprintUnion = prepPunctuate (topKey andS <> space) . map condBracesAnd
2c0c0264249b8d2a3f465e22cb3c6d9c4ac8924aFelix Gabriel MancemoveAnnos :: Annoted SPEC -> [Annoted SPEC] -> [Annoted SPEC]
2c0c0264249b8d2a3f465e22cb3c6d9c4ac8924aFelix Gabriel MancemoveAnnos x l = appAnno $ case l of
2c0c0264249b8d2a3f465e22cb3c6d9c4ac8924aFelix Gabriel Mance [] -> error "moveAnnos"
2c0c0264249b8d2a3f465e22cb3c6d9c4ac8924aFelix Gabriel Mance h : r -> h { l_annos = l_annos x ++ l_annos h } : r
2c0c0264249b8d2a3f465e22cb3c6d9c4ac8924aFelix Gabriel Mance where appAnno a = case a of
2c0c0264249b8d2a3f465e22cb3c6d9c4ac8924aFelix Gabriel Mance [h] -> [appendAnno h (r_annos x)]
2c0c0264249b8d2a3f465e22cb3c6d9c4ac8924aFelix Gabriel Mance h : r -> h : appAnno r
120b4b5a0f61d93eeaa17ff2c7867f58c7325e3bFelix Gabriel ManceprintOptUnion :: Annoted SPEC -> [Doc]
120b4b5a0f61d93eeaa17ff2c7867f58c7325e3bFelix Gabriel ManceprintOptUnion x = case skipVoidGroup $ item x of
120b4b5a0f61d93eeaa17ff2c7867f58c7325e3bFelix Gabriel Mance Union e@(_ : _) _ -> printUnion $ moveAnnos x e
120b4b5a0f61d93eeaa17ff2c7867f58c7325e3bFelix Gabriel Mance Extension e@(_ : _) _ -> printExtension $ moveAnnos x e
120b4b5a0f61d93eeaa17ff2c7867f58c7325e3bFelix Gabriel Mance _ -> [pretty x]
120b4b5a0f61d93eeaa17ff2c7867f58c7325e3bFelix Gabriel ManceprintExtension :: [Annoted SPEC] -> [Doc]
120b4b5a0f61d93eeaa17ff2c7867f58c7325e3bFelix Gabriel ManceprintExtension l = case l of
120b4b5a0f61d93eeaa17ff2c7867f58c7325e3bFelix Gabriel Mance x : r -> printOptUnion x ++
120b4b5a0f61d93eeaa17ff2c7867f58c7325e3bFelix Gabriel Mance concatMap (( \ u -> case u of
12078a24d49ba36b83cda9d07c8e8a480c493fe8Felix Gabriel Mance d : s -> (topKey thenS <+> d) : s) .
12078a24d49ba36b83cda9d07c8e8a480c493fe8Felix Gabriel Mance printOptUnion) r
12078a24d49ba36b83cda9d07c8e8a480c493fe8Felix Gabriel ManceprintSPEC :: SPEC -> Doc
12078a24d49ba36b83cda9d07c8e8a480c493fe8Felix Gabriel ManceprintSPEC spec = case spec of
12078a24d49ba36b83cda9d07c8e8a480c493fe8Felix Gabriel Mance Basic_spec aa _ -> pretty aa
0be7a9c012366ada63d587898a15c551b499b76dFelix Gabriel Mance EmptySpec _ -> specBraces empty
30e9cf458094e5970bc06be667558961c2eccff4Felix Gabriel Mance Translation aa ab -> sep [condBracesTransReduct aa, printRENAMING ab]
30e9cf458094e5970bc06be667558961c2eccff4Felix Gabriel Mance Reduction aa ab -> sep [condBracesTransReduct aa, printRESTRICTION ab]
0be7a9c012366ada63d587898a15c551b499b76dFelix Gabriel Mance Union aa _ -> sep $ printUnion aa
30e9cf458094e5970bc06be667558961c2eccff4Felix Gabriel Mance Extension aa _ -> sep $ printExtension aa
3e0eb79b52a3078a12531efc3f66d0d94fd9938dFelix Gabriel Mance Free_spec aa _ -> sep [keyword freeS, printGroupSpec aa]
3e0eb79b52a3078a12531efc3f66d0d94fd9938dFelix Gabriel Mance Cofree_spec aa _ -> sep [keyword cofreeS, printGroupSpec aa]
9c3f6477a95da46a907326206673b4a5c2164164Felix Gabriel Mance Local_spec aa ab _ -> fsep
3e0eb79b52a3078a12531efc3f66d0d94fd9938dFelix Gabriel Mance [keyword localS, pretty aa, keyword withinS, condBracesWithin ab]
3e0eb79b52a3078a12531efc3f66d0d94fd9938dFelix Gabriel Mance Closed_spec aa _ -> sep [keyword closedS, printGroupSpec aa]
30e9cf458094e5970bc06be667558961c2eccff4Felix Gabriel Mance Group aa _ -> pretty aa
3e0eb79b52a3078a12531efc3f66d0d94fd9938dFelix Gabriel Mance Spec_inst aa ab _ -> cat [structSimpleId aa, print_fit_arg_list ab]
3e0eb79b52a3078a12531efc3f66d0d94fd9938dFelix Gabriel Mance Qualified_spec ln asp _ -> printLogicEncoding ln <> colon $+$ pretty asp
30e9cf458094e5970bc06be667558961c2eccff4Felix Gabriel Mance Data _ _ s1 s2 _ -> keyword dataS <+> printGroupSpec s1 $+$ pretty s2
316ef492799cd45fea0f5c26932f49adddfda3f7Felix Gabriel Manceinstance Pretty RENAMING where
3e0eb79b52a3078a12531efc3f66d0d94fd9938dFelix Gabriel Mance pretty = printRENAMING
30e9cf458094e5970bc06be667558961c2eccff4Felix Gabriel ManceprintRENAMING :: RENAMING -> Doc
3e0eb79b52a3078a12531efc3f66d0d94fd9938dFelix Gabriel ManceprintRENAMING (Renaming aa _) =
316ef492799cd45fea0f5c26932f49adddfda3f7Felix Gabriel Mance keyword withS <+> ppWithCommas aa
316ef492799cd45fea0f5c26932f49adddfda3f7Felix Gabriel Manceinstance Pretty RESTRICTION where
316ef492799cd45fea0f5c26932f49adddfda3f7Felix Gabriel Mance pretty = printRESTRICTION
0be7a9c012366ada63d587898a15c551b499b76dFelix Gabriel ManceprintRESTRICTION :: RESTRICTION -> Doc
30e9cf458094e5970bc06be667558961c2eccff4Felix Gabriel ManceprintRESTRICTION rest = case rest of
e5e3f128bbd44dd393e1038718038bd323f5e415Felix Gabriel Mance Hidden aa _ -> keyword hideS <+> ppWithCommas aa
e5e3f128bbd44dd393e1038718038bd323f5e415Felix Gabriel Mance Revealed aa _ -> keyword revealS <+> pretty aa
e5e3f128bbd44dd393e1038718038bd323f5e415Felix Gabriel ManceprintLogicEncoding :: (Pretty a) => a -> Doc
e5e3f128bbd44dd393e1038718038bd323f5e415Felix Gabriel ManceprintLogicEncoding enc = keyword logicS <+> pretty enc
e5e3f128bbd44dd393e1038718038bd323f5e415Felix Gabriel Manceinstance Pretty G_mapping where
734257b9ea9fcaa18d4e3627f54f5295a99aa1f7Felix Gabriel Mance pretty = printG_mapping
3e0eb79b52a3078a12531efc3f66d0d94fd9938dFelix Gabriel ManceprintG_mapping :: G_mapping -> Doc
e5ea4eeaeefd3521ae3475719e18c96cf91637d5Felix Gabriel ManceprintG_mapping gma = case gma of
15d62726781e67fe6458fbcf0a8c46832a7bb8daFelix Gabriel Mance G_symb_map gsmil -> pretty gsmil
15d62726781e67fe6458fbcf0a8c46832a7bb8daFelix Gabriel Mance G_logic_translation enc -> printLogicEncoding enc
dda7065c0c0f383558d7d4e8072969c8c41a8ed7Francisc Nicolae Bungiuinstance Pretty G_hiding where
15d62726781e67fe6458fbcf0a8c46832a7bb8daFelix Gabriel Mance pretty = printG_hiding
e5ea4eeaeefd3521ae3475719e18c96cf91637d5Felix Gabriel ManceprintG_hiding :: G_hiding -> Doc
dda7065c0c0f383558d7d4e8072969c8c41a8ed7Francisc Nicolae BungiuprintG_hiding ghid = case ghid of
734257b9ea9fcaa18d4e3627f54f5295a99aa1f7Felix Gabriel Mance G_symb_list gsil -> pretty gsil
c4076ff1721f8901a30e4b7aa004479ecb2631e0Felix Gabriel Mance G_logic_projection enc -> printLogicEncoding enc
12078a24d49ba36b83cda9d07c8e8a480c493fe8Felix Gabriel Manceinstance Pretty FIT_ARG where
12078a24d49ba36b83cda9d07c8e8a480c493fe8Felix Gabriel Mance pretty = printFIT_ARG