Commit c56c355b authored by afarmer's avatar afarmer Committed by Simon Peyton Jones

Only allow special NeverActive syntax for RULES.

parent 6290c7bd
......@@ -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
......
......@@ -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>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment