From: Ian Lynagh Date: Wed, 12 Aug 2009 18:59:12 +0000 (+0000) Subject: Add support for multi-line deprecated pragmas; trac #3303 X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=commitdiff_plain;h=2476249a77bde34ea2052910f111a3424c366db6 Add support for multi-line deprecated pragmas; trac #3303 --- diff --git a/compiler/basicTypes/BasicTypes.lhs b/compiler/basicTypes/BasicTypes.lhs index fad6533..0182139 100644 --- a/compiler/basicTypes/BasicTypes.lhs +++ b/compiler/basicTypes/BasicTypes.lhs @@ -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} %************************************************************************ diff --git a/compiler/parser/Parser.y.pp b/compiler/parser/Parser.y.pp index 6ba417f..c2b6aee 100644 --- a/compiler/parser/Parser.y.pp +++ b/compiler/parser/Parser.y.pp @@ -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 }