LaTeX_Modal.hs revision bfa3df9a76eebd7d6934623e99194ad954be54ea
{- |
Module : $Header$
Copyright : (c) Christian Maeder and Uni Bremen 2004
Licence : similar to LGPL, see HetCATS/LICENCE.txt or LIZENZ.txt
Maintainer : hets@tzi.de
Stability : experimental
Portability : portable
latex output of the abstract syntax
-}
module Modal.LaTeX_Modal where
import Modal.AS_Modal
import Modal.ModalSign
import Modal.Print_AS
import Common.Id
import Common.PrettyPrint (printText0)
import Common.PrintLaTeX
import Common.Lib.Pretty
import Common.Keywords
import Common.PPUtils
import Common.LaTeX_utils
import CASL.LaTeX_AS_Basic
instance PrintLaTeX M_BASIC_ITEM where
printLatex0 ga (Simple_mod_decl is fs _) =
-- Warning: very bad hacking!!!
-- sp_text 0 "\\\\\n\\SPEC~\\=\\PREDS~\\=\\kill\n\\>"<>
hc_sty_plain_keyword (pl_modalityS is) <\+>
tabbed_nest_latex (semiAnno_latex ga is) <\+>
tabbed_nest_latex (braces_latex (semiAnno_latex ga fs))
printLatex0 ga (Term_mod_decl ss fs _) =
-- sp_text 0 "\\\\\n\\SPEC~\\=\\PREDS~\\=\\kill\n\\>"<>
hc_sty_plain_keyword termS <\+>
hc_sty_plain_keyword (pl_modalityS ss) <\+>
tabbed_nest_latex (semiAnno_latex ga ss) <\+>
tabbed_nest_latex (braces_latex (semiAnno_latex ga fs))
instance PrintLaTeX RIGOR where
printLatex0 _ Rigid = hc_sty_plain_keyword rigidS
printLatex0 _ Flexible = hc_sty_plain_keyword flexibleS
{-
hc_sty_sig_item_keyword ga (opS++pluralS l) <\+>
set_tabbed_nest_latex (semiAnno_latex ga l)
-}
instance PrintLaTeX M_SIG_ITEM where
printLatex0 ga (Rigid_op_items r ls _) =
printLatex0 ga r <\+> hc_sty_sig_item_keyword ga (opS++pluralS ls)
<\+> set_tabbed_nest_latex (semiAnno_latex ga ls)
printLatex0 ga (Rigid_pred_items r ls _) =
printLatex0 ga r <\+> hc_sty_sig_item_keyword ga (predS++pluralS ls)
<\+> set_tabbed_nest_latex (semiAnno_latex ga ls)
instance PrintLaTeX M_FORMULA where
printLatex0 ga (Box t f _) =
(if isEmpty t'
then hc_sty_axiom "\\Box"
else brackets_latex t') <>
condParensInnerF (printLatex0 ga) parens_tab_latex f
where t' = (printLatex0 ga t)
printLatex0 ga (Diamond t f _) =
(if isEmpty t'
then hc_sty_axiom "\\Diamond"
else hc_sty_axiom lessS `sp` t' `sp` hc_sty_axiom greaterS) <\+>
condParensInnerF (printLatex0 ga) parens_tab_latex f
where t' = (printLatex0 ga t)
sp = if isEmpty t' then (<>) else (<\+>)
instance PrintLaTeX MODALITY where
printLatex0 ga (Simple_mod ident) =
if tokStr ident == emptyS then empty
else printLatex0 ga ident
printLatex0 ga (Term_mod t) = printLatex0 ga t
instance PrintLaTeX ModalSign where
printLatex0 = printText0
pl_modalityS :: [a] -> String
pl_modalityS l = if length l > 1 then modalitiesS else modalityS