Repository : ssh://darcs.haskell.org//srv/darcs/ghc

On branch  : master

http://hackage.haskell.org/trac/ghc/changeset/c56c355b0f5504f8afd062ca4c78a8bb40905299

>---------------------------------------------------------------

commit c56c355b0f5504f8afd062ca4c78a8bb40905299
Author: Andrew Farmer <afar...@ittc.ku.edu>
Date:   Thu Dec 6 15:47:33 2012 -0600

    Only allow special NeverActive syntax for RULES.

>---------------------------------------------------------------

 compiler/parser/Parser.y.pp       |   17 +++++++++++++----
 docs/users_guide/glasgow_exts.xml |    3 +++
 2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/compiler/parser/Parser.y.pp b/compiler/parser/Parser.y.pp
index 1907ab3..510d7c4 100644
--- a/compiler/parser/Parser.y.pp
+++ b/compiler/parser/Parser.y.pp
@@ -870,16 +870,17 @@ rules   :: { OrdList (LHsDecl RdrName) }
         |  {- empty -}                          { nilOL }
 
 rule    :: { LHsDecl RdrName }
-        : STRING activation rule_forall infixexp '=' exp
+        : STRING rule_activation rule_forall infixexp '=' exp
              { LL $ RuleD (HsRule (getSTRING $1) 
                                   ($2 `orElse` AlwaysActive) 
                                   $3 $4 placeHolderNames $6 placeHolderNames) }
 
-activation :: { Maybe Activation } 
+-- Rules can be specified to be NeverActive, unlike inline/specialize pragmas
+rule_activation :: { Maybe Activation } 
         : {- empty -}                           { Nothing }
-        | explicit_activation                   { Just $1 }
+        | rule_explicit_activation              { Just $1 }
 
-explicit_activation :: { Activation }  -- In brackets
+rule_explicit_activation :: { Activation }  -- In brackets
         : '[' INTEGER ']'               { ActiveAfter  (fromInteger 
(getINTEGER $2)) }
         | '[' '~' INTEGER ']'           { ActiveBefore (fromInteger 
(getINTEGER $3)) }
         | '[' '~' ']'                   { NeverActive }
@@ -1374,6 +1375,14 @@ sigdecl :: { Located (OrdList (LHsDecl RdrName)) }
         | '{-# SPECIALISE' 'instance' inst_type '#-}'
                 { LL $ unitOL (LL $ SigD (SpecInstSig $3)) }
 
+activation :: { Maybe Activation } 
+        : {- empty -}                           { Nothing }
+        | explicit_activation                   { Just $1 }
+
+explicit_activation :: { Activation }  -- In brackets
+        : '[' INTEGER ']'               { ActiveAfter  (fromInteger 
(getINTEGER $2)) }
+        | '[' '~' INTEGER ']'           { ActiveBefore (fromInteger 
(getINTEGER $3)) }
+
 -----------------------------------------------------------------------------
 -- Expressions
 
diff --git a/docs/users_guide/glasgow_exts.xml 
b/docs/users_guide/glasgow_exts.xml
index 7898677..49b6ea3 100644
--- a/docs/users_guide/glasgow_exts.xml
+++ b/docs/users_guide/glasgow_exts.xml
@@ -9469,6 +9469,9 @@ The "[2]" means that the rule is active in Phase 2 and 
subsequent phases.  The i
 notation "[~2]" is also accepted, meaning that the rule is active up to, but 
not including,
 Phase 2.
 </para>
+<para>
+Rules support the special phase-control notation "[~]", which means the rule 
is never active.
+</para>
 </listitem>
 
 



_______________________________________________
Cvs-ghc mailing list
Cvs-ghc@haskell.org
http://www.haskell.org/mailman/listinfo/cvs-ghc

Reply via email to