[project @ 2001-07-24 09:53:27 by simonpj]
authorsimonpj <unknown>
Tue, 24 Jul 2001 09:53:27 +0000 (09:53 +0000)
committersimonpj <unknown>
Tue, 24 Jul 2001 09:53:27 +0000 (09:53 +0000)
Keep the printed stuff for Demand and DmdResult separate, else
we can get confused when parsing a strictness signature.  For
example, previously

LX

could have been parsed as L  -> X
or as LX -> T

Urk!  I've taken the simple path of making DmdResults print in
lower case.  Thus

Lx  means L  -> x
LX means LX -> t

ghc/compiler/basicTypes/NewDemand.lhs
ghc/compiler/parser/Lex.lhs

index 94d4aa2..0dcb69a 100644 (file)
@@ -71,9 +71,10 @@ instance Outputable DmdType where
       pp_elt (uniq, dmd) = ppr uniq <> text "->" <> ppr dmd
 
 instance Outputable DmdResult where
-  ppr TopRes = empty
-  ppr RetCPR = char 'M'
-  ppr BotRes = char 'X'
+  ppr TopRes = empty     -- Keep these distinct from Demand letters
+  ppr RetCPR = char 'm'          -- so that we can print strictness sigs as
+  ppr BotRes = char 'b'   --    dddr
+                         -- without ambiguity
 
 emptyDmdEnv = emptyVarEnv
 topDmdType = DmdType emptyDmdEnv [] TopRes
index fba97ed..5e82b53 100644 (file)
@@ -819,12 +819,11 @@ silly_escape_chars = [
 lex_demand cont buf = 
  case read_em [] buf of { (ls,buf') -> 
  case currentChar# buf' of
-   'X'# -> cont (ITstrict (StrictSig (mkTopDmdType ls BotRes))) (incLexeme buf')
-   'M'# -> cont (ITstrict (StrictSig (mkTopDmdType ls RetCPR))) (incLexeme buf')
+   'b'# -> cont (ITstrict (StrictSig (mkTopDmdType ls BotRes))) (incLexeme buf')
+   'm'# -> cont (ITstrict (StrictSig (mkTopDmdType ls RetCPR))) (incLexeme buf')
    _    -> cont (ITstrict (StrictSig (mkTopDmdType ls TopRes))) buf'
  }
  where
-   -- code snatched from Demand.lhs
   read_em acc buf = 
    case currentChar# buf of
     'L'# -> read_em (Lazy : acc) (stepOn buf)