[project @ 2000-09-08 09:26:05 by simonmar]
[ghc-hetmet.git] / ghc / compiler / hsSyn / HsBasic.lhs
index afe2516..11558f7 100644 (file)
@@ -1,19 +1,15 @@
 %
-% (c) The GRASP/AQUA Project, Glasgow University, 1992-1996
+% (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
 %
 \section[HsLit]{Abstract syntax: source-language literals}
 
 \begin{code}
-#include "HsVersions.h"
-
 module HsBasic where
 
-IMP_Ubiq(){-uitous-}
-
-IMPORT_1_3(Ratio(Rational))
+#include "HsVersions.h"
 
-import Pretty
 import Outputable
+import Ratio   ( Rational )
 \end{code}
 
 %************************************************************************
@@ -25,8 +21,8 @@ import Outputable
 
 \begin{code}
 data HsLit
-  = HsChar         Char        -- characters
-  | HsCharPrim     Char        -- unboxed char literals
+  = HsChar         Int         -- characters
+  | HsCharPrim     Int         -- unboxed char literals
   | HsString       FAST_STRING -- strings
   | HsStringPrim    FAST_STRING        -- packed string
 
@@ -60,16 +56,17 @@ negLiteral (HsFrac f) = HsFrac (-f)
 
 \begin{code}
 instance Outputable HsLit where
-    ppr sty (HsChar c)         = text (show c)
-    ppr sty (HsCharPrim c)     = (<>) (text (show c)) (char '#')
-    ppr sty (HsString s)       = text (show s)
-    ppr sty (HsStringPrim s)   = (<>) (text (show s)) (char '#')
-    ppr sty (HsInt i)          = integer i
-    ppr sty (HsFrac f)         = rational f
-    ppr sty (HsFloatPrim f)    = (<>) (rational f) (char '#')
-    ppr sty (HsDoublePrim d)   = (<>) (rational d) (text "##")
-    ppr sty (HsIntPrim i)      = (<>) (integer i) (char '#')
-    ppr sty (HsLitLit s)       = hcat [text "``", ptext s, text "''"]
+       -- Use "show" because it puts in appropriate escapes
+    ppr (HsChar c)      = pprHsChar c
+    ppr (HsCharPrim c)  = pprHsChar c <> char '#'
+    ppr (HsString s)    = pprHsString s
+    ppr (HsStringPrim s) = pprHsString s <> char '#'
+    ppr (HsInt i)       = integer i
+    ppr (HsFrac f)      = rational f
+    ppr (HsFloatPrim f)         = rational f <> char '#'
+    ppr (HsDoublePrim d) = rational d <> text "##"
+    ppr (HsIntPrim i)   = integer i  <> char '#'
+    ppr (HsLitLit s)    = hcat [text "``", ptext s, text "''"]
 \end{code}