[project @ 1997-05-26 04:57:23 by sof]
[ghc-hetmet.git] / ghc / compiler / utils / PprStyle.lhs
1 %
2 % (c) The AQUA Project, Glasgow University, 1996
3 %
4 \section[PprStyle]{Pretty-printing `styles'}
5
6 \begin{code}
7 #include "HsVersions.h"
8
9 module PprStyle (
10         PprStyle(..),
11         codeStyle, ifaceStyle, userStyle
12     ) where
13
14 CHK_Ubiq() -- debugging consistency check
15
16 import FastString
17
18 data PprStyle
19   = PprForUser                  -- Pretty-print in a way that will
20                                 -- make sense to the ordinary user;
21                                 -- must be very close to Haskell
22                                 -- syntax, etc.
23   | PprQuote                    -- Like PprForUser, but also quote the whole thing
24
25   | PprDebug                    -- Standard debugging output
26   | PprShowAll                  -- Debugging output which leaves
27                                 -- nothing to the imagination
28
29   | PprInterface                -- Interface generation
30
31   | PprForC                     -- must print out C-acceptable names
32
33   | PprForAsm                   -- must print out assembler-acceptable names
34         Bool                    -- prefix CLabel with underscore?
35         (String -> String)      -- format AsmTempLabel
36
37 \end{code}
38
39 Orthogonal to the above printing styles are (possibly) some
40 command-line flags that affect printing (often carried with the
41 style).  The most likely ones are variations on how much type info is
42 shown.
43
44 The following test decides whether or not we are actually generating
45 code (either C or assembly), or generating interface files.
46 \begin{code}
47 codeStyle :: PprStyle -> Bool
48 codeStyle PprForC         = True
49 codeStyle (PprForAsm _ _) = True
50 codeStyle _               = False
51
52 ifaceStyle :: PprStyle -> Bool
53 ifaceStyle PprInterface   = True
54 ifaceStyle other          = False
55
56 userStyle ::  PprStyle -> Bool
57 userStyle PprQuote   = True
58 userStyle PprForUser = True
59 userStyle other      = False
60 \end{code}