Add support for multi-line deprecated pragmas; trac #3303
authorIan Lynagh <igloo@earth.li>
Wed, 12 Aug 2009 18:59:12 +0000 (18:59 +0000)
committerIan Lynagh <igloo@earth.li>
Wed, 12 Aug 2009 18:59:12 +0000 (18:59 +0000)
compiler/basicTypes/BasicTypes.lhs
compiler/parser/Parser.y.pp

index fad6533..0182139 100644 (file)
@@ -119,13 +119,14 @@ initialVersion = 1
 
 \begin{code}
 -- reason/explanation from a WARNING or DEPRECATED pragma
-data WarningTxt = WarningTxt FastString
-                | DeprecatedTxt FastString
+data WarningTxt = WarningTxt [FastString]
+                | DeprecatedTxt [FastString]
     deriving Eq
 
 instance Outputable WarningTxt where
-    ppr (WarningTxt    w) =                        doubleQuotes (ftext w)
-    ppr (DeprecatedTxt d) = text "Deprecated:" <+> doubleQuotes (ftext d)
+    ppr (WarningTxt    ws) = doubleQuotes (vcat (map ftext ws))
+    ppr (DeprecatedTxt ds) = text "Deprecated:" <+>
+                             doubleQuotes (vcat (map ftext ds))
 \end{code}
 
 %************************************************************************
index 6ba417f..c2b6aee 100644 (file)
@@ -399,8 +399,8 @@ missing_module_keyword :: { () }
        : {- empty -}                           {% pushCurrentContext }
 
 maybemodwarning :: { Maybe WarningTxt }
-    : '{-# DEPRECATED' STRING '#-}' { Just (DeprecatedTxt (getSTRING $2)) }
-    | '{-# WARNING' STRING '#-}'    { Just (WarningTxt (getSTRING $2)) }
+    : '{-# DEPRECATED' strings '#-}' { Just (DeprecatedTxt $ unLoc $2) }
+    | '{-# WARNING' strings '#-}'    { Just (WarningTxt $ unLoc $2) }
     |  {- empty -}                  { Nothing }
 
 body   :: { ([LImportDecl RdrName], [LHsDecl RdrName]) }
@@ -839,8 +839,8 @@ warnings :: { OrdList (LHsDecl RdrName) }
 
 -- SUP: TEMPORARY HACK, not checking for `module Foo'
 warning :: { OrdList (LHsDecl RdrName) }
-       : namelist STRING
-               { toOL [ LL $ WarningD (Warning n (WarningTxt (getSTRING $2)))
+       : namelist strings
+               { toOL [ LL $ WarningD (Warning n (WarningTxt $ unLoc $2))
                       | n <- unLoc $1 ] }
 
 deprecations :: { OrdList (LHsDecl RdrName) }
@@ -851,10 +851,18 @@ deprecations :: { OrdList (LHsDecl RdrName) }
 
 -- SUP: TEMPORARY HACK, not checking for `module Foo'
 deprecation :: { OrdList (LHsDecl RdrName) }
-       : namelist STRING
-               { toOL [ LL $ WarningD (Warning n (DeprecatedTxt (getSTRING $2)))
+       : namelist strings
+               { toOL [ LL $ WarningD (Warning n (DeprecatedTxt $ unLoc $2))
                       | n <- unLoc $1 ] }
 
+strings :: { Located [FastString] }
+    : STRING { L1 [getSTRING $1] }
+    | '[' stringlist ']' { LL $ fromOL (unLoc $2) }
+
+stringlist :: { Located (OrdList FastString) }
+    : stringlist ',' STRING { LL (unLoc $1 `snocOL` getSTRING $3) }
+    | STRING                { LL (unitOL (getSTRING $1)) }
+
 -----------------------------------------------------------------------------
 -- Annotations
 annotation :: { LHsDecl RdrName }