[project @ 2003-11-27 13:26:38 by simonmar]
authorsimonmar <unknown>
Thu, 27 Nov 2003 13:26:39 +0000 (13:26 +0000)
committersimonmar <unknown>
Thu, 27 Nov 2003 13:26:39 +0000 (13:26 +0000)
On reflection, using the '!!' prefix for unboxing a constructor field
was a mistake:  firstly it has to be written '! !', and secondly it
isn't backwards-compatible.  So instead, we now use the syntax:

   data T = T {-# UNPACK #-} !Int

to unbox a field.  We thought this would be a cute reuse of the UNPACK
pragma.

The effect of -funbox-strict-fields is to add {-# UNPACK #-} to every
strict field.

ghc/compiler/parser/Lexer.x
ghc/compiler/parser/Parser.y

index ccfc3e8..bb32d63 100644 (file)
@@ -174,6 +174,7 @@ $white_no_nl+                               ;
                                        { token ITdeprecated_prag }
   "{-#" $whitechar* (SCC|scc)          { token ITscc_prag }
   "{-#" $whitechar* (CORE|core)                { token ITcore_prag }
+  "{-#" $whitechar* (UNPACK|unpack)    { token ITunpack_prag }
   
   "{-#"                                { nested_comment }
 
@@ -349,6 +350,7 @@ data Token__
   | ITline_prag
   | ITscc_prag
   | ITcore_prag                 -- hdaume: core annotations
+  | ITunpack_prag
   | ITclose_prag
 
   | ITdotdot                   -- reserved symbols
index 9333122..965863a 100644 (file)
@@ -1,6 +1,6 @@
 {-                                                             -*-haskell-*-
 -----------------------------------------------------------------------------
-$Id: Parser.y,v 1.130 2003/11/26 10:07:19 simonmar Exp $
+$Id: Parser.y,v 1.131 2003/11/27 13:26:39 simonmar Exp $
 
 Haskell grammar.
 
@@ -137,6 +137,7 @@ Conflicts: 29 shift/reduce, [SDM 19/9/2002]
  '{-# CORE'        { T _ _ ITcore_prag }              -- hdaume: annotated core
  '{-# SCC'        { T _ _ ITscc_prag }
  '{-# DEPRECATED'  { T _ _ ITdeprecated_prag }
+ '{-# UNPACK'      { T _ _ ITunpack_prag }
  '#-}'            { T _ _ ITclose_prag }
 
  '..'          { T _ _ ITdotdot }                      -- reserved symbols
@@ -827,7 +828,7 @@ stype :: { RdrNameBangType }
 
 strict_mark :: { HsBang }
        : '!'                           { HsStrict }
-       | '!' '!'                       { HsUnbox }
+       | '{-# UNPACK' '#-}' '!'        { HsUnbox }
 
 deriving :: { Maybe RdrNameContext }
        : {- empty -}                   { Nothing }