summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorGravatar chrishaw <unknown>2015-03-11 20:06:02 -0700
committerGravatar chrishaw <unknown>2015-03-11 20:06:02 -0700
commitfeee322b21fa0d83fd6e86142685f27bc6b73f8b (patch)
tree11f9f5e1ad581de22d2c6405e41639a8f020c74b /Source
parent0af950664b011d95dc8d1bf84c193a151bbffac4 (diff)
Allow trigger annotations in more statements and expressions
Diffstat (limited to 'Source')
-rw-r--r--Source/Dafny/Cloner.cs8
-rw-r--r--Source/Dafny/Dafny.atg21
-rw-r--r--Source/Dafny/DafnyAst.cs23
-rw-r--r--Source/Dafny/Parser.cs33
-rw-r--r--Source/Dafny/Resolver.cs6
-rw-r--r--Source/Dafny/Scanner.cs19
-rw-r--r--Source/Dafny/Translator.cs29
7 files changed, 94 insertions, 45 deletions
diff --git a/Source/Dafny/Cloner.cs b/Source/Dafny/Cloner.cs
index 0e599ad2..8552e480 100644
--- a/Source/Dafny/Cloner.cs
+++ b/Source/Dafny/Cloner.cs
@@ -363,7 +363,7 @@ namespace Microsoft.Dafny
} else if (expr is LetExpr) {
var e = (LetExpr)expr;
- return new LetExpr(Tok(e.tok), e.LHSs.ConvertAll(CloneCasePattern), e.RHSs.ConvertAll(CloneExpr), CloneExpr(e.Body), e.Exact);
+ return new LetExpr(Tok(e.tok), e.LHSs.ConvertAll(CloneCasePattern), e.RHSs.ConvertAll(CloneExpr), CloneExpr(e.Body), e.Exact, e.Attributes);
} else if (expr is NamedExpr) {
var e = (NamedExpr)expr;
@@ -385,13 +385,13 @@ namespace Microsoft.Dafny
Contract.Assert(false); throw new cce.UnreachableException(); // unexpected quantifier expression
}
} else if (e is MapComprehension) {
- return new MapComprehension(tk, ((MapComprehension)e).Finite, bvs, range, term);
+ return new MapComprehension(tk, ((MapComprehension)e).Finite, bvs, range, term, CloneAttributes(e.Attributes));
} else if (e is LambdaExpr) {
var l = (LambdaExpr)e;
return new LambdaExpr(tk, l.OneShot, bvs, range, l.Reads.ConvertAll(CloneFrameExpr), term);
} else {
Contract.Assert(e is SetComprehension);
- return new SetComprehension(tk, bvs, range, term);
+ return new SetComprehension(tk, bvs, range, term, CloneAttributes(e.Attributes));
}
} else if (expr is WildcardExpr) {
@@ -540,7 +540,7 @@ namespace Microsoft.Dafny
} else if (stmt is AssignSuchThatStmt) {
var s = (AssignSuchThatStmt)stmt;
- r = new AssignSuchThatStmt(Tok(s.Tok), Tok(s.EndTok), s.Lhss.ConvertAll(CloneExpr), CloneExpr(s.Expr), s.AssumeToken == null ? null : Tok(s.AssumeToken));
+ r = new AssignSuchThatStmt(Tok(s.Tok), Tok(s.EndTok), s.Lhss.ConvertAll(CloneExpr), CloneExpr(s.Expr), s.AssumeToken == null ? null : Tok(s.AssumeToken), null);
} else if (stmt is UpdateStmt) {
var s = (UpdateStmt)stmt;
diff --git a/Source/Dafny/Dafny.atg b/Source/Dafny/Dafny.atg
index dc26392b..a9653439 100644
--- a/Source/Dafny/Dafny.atg
+++ b/Source/Dafny/Dafny.atg
@@ -1484,7 +1484,7 @@ UpdateStmt<out Statement/*!*/ s>
| ":" (. SemErr(t, "invalid statement (did you forget the 'label' keyword?)"); .)
)
(. if (suchThat != null) {
- s = new AssignSuchThatStmt(x, endTok, lhss, suchThat, suchThatAssume);
+ s = new AssignSuchThatStmt(x, endTok, lhss, suchThat, suchThatAssume, null);
} else {
if (lhss.Count == 0 && rhss.Count == 0) {
s = new BlockStmt(x, endTok, new List<Statement>()); // error, give empty statement
@@ -1552,7 +1552,8 @@ VarDeclStatement<.out Statement/*!*/ s.>
Rhs<out r> (. rhss.Add(r); .)
{ "," Rhs<out r> (. rhss.Add(r); .)
}
- | ":|" (. assignTok = t; .)
+ | { Attribute<ref attrs> }
+ ":|" (. assignTok = t; .)
[ IF(la.kind == _assume) /* an Expression can also begin with an "assume", so this says to resolve it to pick up any "assume" here */
"assume" (. suchThatAssume = t; .)
]
@@ -1565,7 +1566,7 @@ VarDeclStatement<.out Statement/*!*/ s.>
foreach (var lhs in lhss) {
ies.Add(new IdentifierExpr(lhs.Tok, lhs.Name));
}
- update = new AssignSuchThatStmt(assignTok, endTok, ies, suchThat, suchThatAssume);
+ update = new AssignSuchThatStmt(assignTok, endTok, ies, suchThat, suchThatAssume, attrs);
} else if (rhss.Count == 0) {
update = null;
} else {
@@ -2429,12 +2430,14 @@ MapComprehensionExpr<IToken mapToken, bool finite, out Expression e, bool allowS
List<BoundVar> bvars = new List<BoundVar>();
Expression range = null;
Expression body;
+ Attributes attrs = null;
.)
IdentTypeOptional<out bv> (. bvars.Add(bv); .)
+ { Attribute<ref attrs> }
[ "|" Expression<out range, true, true> ]
QSep
Expression<out body, allowSemi, allowLambda>
- (. e = new MapComprehension(mapToken, finite, bvars, range ?? new LiteralExpr(mapToken, true), body);
+ (. e = new MapComprehension(mapToken, finite, bvars, range ?? new LiteralExpr(mapToken, true), body, attrs);
.)
.
EndlessExpression<out Expression e, bool allowSemi, bool allowLambda>
@@ -2476,6 +2479,7 @@ LetExpr<out Expression e, bool allowSemi, bool allowLambda>
var letRHSs = new List<Expression>();
CasePattern pat;
bool exact = true;
+ Attributes attrs = null;
e = dummyExpr;
.)
[ "ghost" (. isGhost = true; x = t; .)
@@ -2489,7 +2493,8 @@ LetExpr<out Expression e, bool allowSemi, bool allowLambda>
.)
}
( ":="
- | ":|" (. exact = false;
+ | { Attribute<ref attrs> }
+ ":|" (. exact = false;
foreach (var lhs in letLHSs) {
if (lhs.Arguments != null) {
SemErr(lhs.tok, "LHS of let-such-that expression must be variables, not general patterns");
@@ -2501,7 +2506,7 @@ LetExpr<out Expression e, bool allowSemi, bool allowLambda>
{ "," Expression<out e, false, true> (. letRHSs.Add(e); .)
}
";"
- Expression<out e, allowSemi, allowLambda> (. e = new LetExpr(x, letLHSs, letRHSs, e, exact); .)
+ Expression<out e, allowSemi, allowLambda> (. e = new LetExpr(x, letLHSs, letRHSs, e, exact, attrs); .)
.
NamedExpr<out Expression e, bool allowSemi, bool allowLambda>
@@ -2775,19 +2780,21 @@ SetComprehensionExpr<out Expression q, bool allowSemi, bool allowLambda>
List<BoundVar/*!*/> bvars = new List<BoundVar>();
Expression range;
Expression body = null;
+ Attributes attrs = null;
.)
"set" (. x = t; .)
IdentTypeOptional<out bv> (. bvars.Add(bv); .)
{ ","
IdentTypeOptional<out bv> (. bvars.Add(bv); .)
}
+ { Attribute<ref attrs> }
"|" Expression<out range, allowSemi, allowLambda>
[ IF(IsQSep()) /* let any given body bind to the closest enclosing set comprehension */
QSep
Expression<out body, allowSemi, allowLambda>
]
(. if (body == null && bvars.Count != 1) { SemErr(t, "a set comprehension with more than one bound variable must have a term expression"); }
- q = new SetComprehension(x, bvars, range, body);
+ q = new SetComprehension(x, bvars, range, body, attrs);
.)
.
Expressions<.List<Expression> args.>
diff --git a/Source/Dafny/DafnyAst.cs b/Source/Dafny/DafnyAst.cs
index 8943fc5f..5aaef662 100644
--- a/Source/Dafny/DafnyAst.cs
+++ b/Source/Dafny/DafnyAst.cs
@@ -3709,8 +3709,8 @@ namespace Microsoft.Dafny {
public abstract class ConcreteUpdateStatement : Statement
{
public readonly List<Expression> Lhss;
- public ConcreteUpdateStatement(IToken tok, IToken endTok, List<Expression> lhss)
- : base(tok, endTok) {
+ public ConcreteUpdateStatement(IToken tok, IToken endTok, List<Expression> lhss, Attributes attrs = null)
+ : base(tok, endTok, attrs) {
Contract.Requires(tok != null);
Contract.Requires(endTok != null);
Contract.Requires(cce.NonNullElements(lhss));
@@ -3738,8 +3738,8 @@ namespace Microsoft.Dafny {
/// "assumeToken" is allowed to be "null", in which case the verifier will check that a RHS value exists.
/// If "assumeToken" is non-null, then it should denote the "assume" keyword used in the statement.
/// </summary>
- public AssignSuchThatStmt(IToken tok, IToken endTok, List<Expression> lhss, Expression expr, IToken assumeToken)
- : base(tok, endTok, lhss) {
+ public AssignSuchThatStmt(IToken tok, IToken endTok, List<Expression> lhss, Expression expr, IToken assumeToken, Attributes attrs)
+ : base(tok, endTok, lhss, attrs) {
Contract.Requires(tok != null);
Contract.Requires(endTok != null);
Contract.Requires(cce.NonNullElements(lhss));
@@ -6282,16 +6282,21 @@ namespace Microsoft.Dafny {
public readonly List<Expression> RHSs;
public readonly Expression Body;
public readonly bool Exact; // Exact==true means a regular let expression; Exact==false means an assign-such-that expression
+ public readonly Attributes Attributes;
public Expression translationDesugaring; // filled in during translation, lazily; to be accessed only via Translation.LetDesugaring; always null when Exact==true
- public LetExpr(IToken tok, List<CasePattern> lhss, List<Expression> rhss, Expression body, bool exact)
+ public LetExpr(IToken tok, List<CasePattern> lhss, List<Expression> rhss, Expression body, bool exact, Attributes attrs = null)
: base(tok) {
LHSs = lhss;
RHSs = rhss;
Body = body;
Exact = exact;
+ Attributes = attrs;
}
public override IEnumerable<Expression> SubExpressions {
get {
+ foreach (var e in Attributes.SubExpressions(Attributes)) {
+ yield return e;
+ }
foreach (var rhs in RHSs) {
yield return rhs;
}
@@ -6533,8 +6538,8 @@ namespace Microsoft.Dafny {
{
public readonly bool TermIsImplicit;
- public SetComprehension(IToken tok, List<BoundVar> bvars, Expression range, Expression term)
- : base(tok, bvars, range, term ?? new IdentifierExpr(tok, bvars[0].Name), null) {
+ public SetComprehension(IToken tok, List<BoundVar> bvars, Expression range, Expression term, Attributes attrs)
+ : base(tok, bvars, range, term ?? new IdentifierExpr(tok, bvars[0].Name), attrs) {
Contract.Requires(tok != null);
Contract.Requires(cce.NonNullElements(bvars));
Contract.Requires(1 <= bvars.Count);
@@ -6547,8 +6552,8 @@ namespace Microsoft.Dafny {
{
public readonly bool Finite;
- public MapComprehension(IToken tok, bool finite, List<BoundVar> bvars, Expression range, Expression term)
- : base(tok, bvars, range, term, null) {
+ public MapComprehension(IToken tok, bool finite, List<BoundVar> bvars, Expression range, Expression term, Attributes attrs)
+ : base(tok, bvars, range, term, attrs) {
Contract.Requires(tok != null);
Contract.Requires(cce.NonNullElements(bvars));
Contract.Requires(1 <= bvars.Count);
diff --git a/Source/Dafny/Parser.cs b/Source/Dafny/Parser.cs
index 3426da4c..6342e9c7 100644
--- a/Source/Dafny/Parser.cs
+++ b/Source/Dafny/Parser.cs
@@ -2194,7 +2194,7 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
SemErr(t, "invalid statement (did you forget the 'label' keyword?)");
} else SynErr(179);
if (suchThat != null) {
- s = new AssignSuchThatStmt(x, endTok, lhss, suchThat, suchThatAssume);
+ s = new AssignSuchThatStmt(x, endTok, lhss, suchThat, suchThatAssume, null);
} else {
if (lhss.Count == 0 && rhss.Count == 0) {
s = new BlockStmt(x, endTok, new List<Statement>()); // error, give empty statement
@@ -2235,7 +2235,7 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
LocalIdentTypeOptional(out d, isGhost);
lhss.Add(d); d.Attributes = attrs; attrs = null;
}
- if (la.kind == 91 || la.kind == 93) {
+ if (la.kind == 39 || la.kind == 91 || la.kind == 93) {
if (la.kind == 91) {
Get();
assignTok = t;
@@ -2247,7 +2247,10 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
rhss.Add(r);
}
} else {
- Get();
+ while (la.kind == 39) {
+ Attribute(ref attrs);
+ }
+ Expect(93);
assignTok = t;
if (la.kind == _assume) {
Expect(29);
@@ -2265,7 +2268,7 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
foreach (var lhs in lhss) {
ies.Add(new IdentifierExpr(lhs.Tok, lhs.Name));
}
- update = new AssignSuchThatStmt(assignTok, endTok, ies, suchThat, suchThatAssume);
+ update = new AssignSuchThatStmt(assignTok, endTok, ies, suchThat, suchThatAssume, attrs);
} else if (rhss.Count == 0) {
update = null;
} else {
@@ -3896,16 +3899,20 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
List<BoundVar> bvars = new List<BoundVar>();
Expression range = null;
Expression body;
+ Attributes attrs = null;
IdentTypeOptional(out bv);
bvars.Add(bv);
+ while (la.kind == 39) {
+ Attribute(ref attrs);
+ }
if (la.kind == 22) {
Get();
Expression(out range, true, true);
}
QSep();
Expression(out body, allowSemi, allowLambda);
- e = new MapComprehension(mapToken, finite, bvars, range ?? new LiteralExpr(mapToken, true), body);
+ e = new MapComprehension(mapToken, finite, bvars, range ?? new LiteralExpr(mapToken, true), body, attrs);
}
@@ -3967,6 +3974,7 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
List<BoundVar/*!*/> bvars = new List<BoundVar>();
Expression range;
Expression body = null;
+ Attributes attrs = null;
Expect(13);
x = t;
@@ -3977,6 +3985,9 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
IdentTypeOptional(out bv);
bvars.Add(bv);
}
+ while (la.kind == 39) {
+ Attribute(ref attrs);
+ }
Expect(22);
Expression(out range, allowSemi, allowLambda);
if (IsQSep()) {
@@ -3984,7 +3995,7 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
Expression(out body, allowSemi, allowLambda);
}
if (body == null && bvars.Count != 1) { SemErr(t, "a set comprehension with more than one bound variable must have a term expression"); }
- q = new SetComprehension(x, bvars, range, body);
+ q = new SetComprehension(x, bvars, range, body, attrs);
}
@@ -4006,6 +4017,7 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
var letRHSs = new List<Expression>();
CasePattern pat;
bool exact = true;
+ Attributes attrs = null;
e = dummyExpr;
if (la.kind == 65) {
@@ -4027,8 +4039,11 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
}
if (la.kind == 91) {
Get();
- } else if (la.kind == 93) {
- Get();
+ } else if (la.kind == 39 || la.kind == 93) {
+ while (la.kind == 39) {
+ Attribute(ref attrs);
+ }
+ Expect(93);
exact = false;
foreach (var lhs in letLHSs) {
if (lhs.Arguments != null) {
@@ -4046,7 +4061,7 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
}
Expect(26);
Expression(out e, allowSemi, allowLambda);
- e = new LetExpr(x, letLHSs, letRHSs, e, exact);
+ e = new LetExpr(x, letLHSs, letRHSs, e, exact, attrs);
}
void NamedExpr(out Expression e, bool allowSemi, bool allowLambda) {
diff --git a/Source/Dafny/Resolver.cs b/Source/Dafny/Resolver.cs
index 98fcb0ee..b6f142e6 100644
--- a/Source/Dafny/Resolver.cs
+++ b/Source/Dafny/Resolver.cs
@@ -570,7 +570,7 @@ namespace Microsoft.Dafny
{
ResolvedOp = BinaryExpr.ResolvedOpcode.InSet,
Type = Type.Bool
- }, obj)
+ }, obj, null)
{
Type = new SetType(new ObjectType())
};
@@ -610,7 +610,7 @@ namespace Microsoft.Dafny
var sInE = new BinaryExpr(e.tok, BinaryExpr.Opcode.In, bvIE, e);
sInE.ResolvedOp = BinaryExpr.ResolvedOpcode.InSeq; // resolve here
sInE.Type = Type.Bool; // resolve here
- var s = new SetComprehension(e.tok, new List<BoundVar>() { bv }, sInE, bvIE);
+ var s = new SetComprehension(e.tok, new List<BoundVar>() { bv }, sInE, bvIE, null);
s.Type = new SetType(new ObjectType()); // resolve here
sets.Add(s);
} else {
@@ -5339,6 +5339,7 @@ namespace Microsoft.Dafny
} else {
ResolveUpdateStmt(update, specContextOnly, codeContext, errorCountBeforeCheckingLhs);
}
+ ResolveAttributes(s.Attributes, new ResolveOpts(codeContext, true));
}
/// <summary>
/// Resolve the RHSs and entire UpdateStmt (LHSs should already have been checked by the caller).
@@ -7024,6 +7025,7 @@ namespace Microsoft.Dafny
}
}
ResolveExpression(e.Body, opts);
+ ResolveAttributes(e.Attributes, opts);
scope.PopMarker();
expr.Type = e.Body.Type;
diff --git a/Source/Dafny/Scanner.cs b/Source/Dafny/Scanner.cs
index d981a7a1..cbe8e6e5 100644
--- a/Source/Dafny/Scanner.cs
+++ b/Source/Dafny/Scanner.cs
@@ -217,7 +217,7 @@ public class Scanner {
[ContractInvariantMethod]
void objectInvariant(){
- Contract.Invariant(buffer!=null);
+ Contract.Invariant(this._buffer != null);
Contract.Invariant(t != null);
Contract.Invariant(start != null);
Contract.Invariant(tokens != null);
@@ -227,7 +227,18 @@ public class Scanner {
Contract.Invariant(errorHandler != null);
}
- public Buffer/*!*/ buffer; // scanner buffer
+ private Buffer/*!*/ _buffer; // scanner buffer
+
+ public Buffer/*!*/ buffer {
+ get {
+ Contract.Ensures(Contract.Result<Buffer>() != null);
+ return this._buffer;
+ }
+ set {
+ Contract.Requires(value != null);
+ this._buffer = value;
+ }
+ }
Token/*!*/ t; // current token
int ch; // current input character
@@ -307,7 +318,7 @@ public class Scanner {
t = new Token(); // dummy because t is a non-null field
try {
Stream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);
- buffer = new Buffer(stream, false);
+ this._buffer = new Buffer(stream, false);
Filename = useBaseName? GetBaseName(fileName): fileName;
Init();
} catch (IOException) {
@@ -322,7 +333,7 @@ public class Scanner {
Contract.Requires(fileName != null);
pt = tokens = new Token(); // first token is a dummy
t = new Token(); // dummy because t is a non-null field
- buffer = new Buffer(s, true);
+ this._buffer = new Buffer(s, true);
this.errorHandler = errorHandler;
this.Filename = useBaseName? GetBaseName(fileName) : fileName;
Init();
diff --git a/Source/Dafny/Translator.cs b/Source/Dafny/Translator.cs
index 6f5ccc1b..81eb36e4 100644
--- a/Source/Dafny/Translator.cs
+++ b/Source/Dafny/Translator.cs
@@ -4453,7 +4453,12 @@ namespace Microsoft.Dafny {
if (canCall != Bpl.Expr.True) {
List<Variable> bvars = new List<Variable>();
Bpl.Expr typeAntecedent = etran.TrBoundVariables(e.BoundVars, bvars);
- canCall = new Bpl.ForallExpr(expr.tok, Concat(tyvars, bvars), Bpl.Expr.Imp(typeAntecedent, canCall));
+ if (Attributes.Contains(e.Attributes, "trigger")) {
+ Bpl.Trigger tr = TrTrigger(etran, e.Attributes, expr.tok);
+ canCall = new Bpl.ForallExpr(expr.tok, Concat(tyvars, bvars), tr, Bpl.Expr.Imp(typeAntecedent, canCall));
+ } else {
+ canCall = new Bpl.ForallExpr(expr.tok, Concat(tyvars, bvars), Bpl.Expr.Imp(typeAntecedent, canCall));
+ }
}
return canCall;
} else if (expr is StmtExpr) {
@@ -5095,7 +5100,8 @@ namespace Microsoft.Dafny {
if (tup.Item1.Count != 0) {
var bvs = new List<Variable>();
var typeAntecedent = etran.TrBoundVariables(tup.Item1, bvs);
- body = new Bpl.ExistsExpr(e.tok, bvs, BplAnd(typeAntecedent, body));
+ var triggers = TrTrigger(etran, e.Attributes, e.tok);
+ body = new Bpl.ExistsExpr(e.tok, bvs, triggers, BplAnd(typeAntecedent, body));
}
w = BplOr(body, w);
}
@@ -7038,7 +7044,8 @@ namespace Microsoft.Dafny {
if (tup.Item1.Count != 0) {
var bvs = new List<Variable>();
var typeAntecedent = etran.TrBoundVariables(tup.Item1, bvs);
- body = new Bpl.ExistsExpr(s.Tok, bvs, BplAnd(typeAntecedent, body));
+ var triggers = TrTrigger(etran, s.Attributes, s.Tok, substMap);
+ body = new Bpl.ExistsExpr(s.Tok, bvs, triggers, BplAnd(typeAntecedent, body));
}
w = BplOr(body, w);
}
@@ -8229,7 +8236,8 @@ namespace Microsoft.Dafny {
Bpl.Expr qq = Bpl.Expr.Imp(ante, post);
if (bvars.Count != 0) {
- qq = new Bpl.ForallExpr(s.Tok, bvars, qq);
+ var triggers = TrTrigger(etran, s.Attributes, s.Tok, substMap);
+ qq = new Bpl.ForallExpr(s.Tok, bvars, triggers, qq);
}
exporter.Add(new Bpl.AssumeCmd(s.Tok, qq));
}
@@ -11175,14 +11183,15 @@ namespace Microsoft.Dafny {
// Translate "set xs | R :: T" into "lambda y: BoxType :: (exists xs :: CorrectType(xs) && R && y==Box(T))".
List<Variable> bvars = new List<Variable>();
Bpl.Expr typeAntecedent = TrBoundVariables(e.BoundVars, bvars);
- Bpl.QKeyValue kv = TrAttributes(e.Attributes, null);
+ Bpl.QKeyValue kv = TrAttributes(e.Attributes, "trigger");
var yVar = new Bpl.BoundVariable(expr.tok, new Bpl.TypedIdent(expr.tok, translator.CurrentIdGenerator.FreshId("$y#"), predef.BoxType));
Bpl.Expr y = new Bpl.IdentifierExpr(expr.tok, yVar);
var eq = Bpl.Expr.Eq(y, BoxIfNecessary(expr.tok, TrExpr(e.Term), e.Term.Type));
var ebody = Bpl.Expr.And(BplAnd(typeAntecedent, TrExpr(e.Range)), eq);
- var exst = new Bpl.ExistsExpr(expr.tok, bvars, ebody);
+ var triggers = translator.TrTrigger(this, e.Attributes, e.tok);
+ var exst = new Bpl.ExistsExpr(expr.tok, bvars, triggers, ebody);
return new Bpl.LambdaExpr(expr.tok, new List<TypeVariable>(), new List<Variable> { yVar }, kv, exst);
@@ -11196,7 +11205,7 @@ namespace Microsoft.Dafny {
var bv = e.BoundVars[0];
TrBoundVariables(e.BoundVars, bvars);
- Bpl.QKeyValue kv = TrAttributes(e.Attributes, null);
+ Bpl.QKeyValue kv = TrAttributes(e.Attributes, "trigger");
var yVar = new Bpl.BoundVariable(expr.tok, new Bpl.TypedIdent(expr.tok, translator.CurrentIdGenerator.FreshId("$y#"), predef.BoxType));
@@ -13405,9 +13414,9 @@ namespace Microsoft.Dafny {
Attributes newAttrs = SubstAttributes(e.Attributes);
if (newBoundVars != e.BoundVars || newRange != e.Range || newTerm != e.Term || newAttrs != e.Attributes) {
if (e is SetComprehension) {
- newExpr = new SetComprehension(expr.tok, newBoundVars, newRange, newTerm);
+ newExpr = new SetComprehension(expr.tok, newBoundVars, newRange, newTerm, newAttrs);
} else if (e is MapComprehension) {
- newExpr = new MapComprehension(expr.tok, ((MapComprehension)e).Finite, newBoundVars, newRange, newTerm);
+ newExpr = new MapComprehension(expr.tok, ((MapComprehension)e).Finite, newBoundVars, newRange, newTerm, newAttrs);
} else if (expr is ForallExpr) {
newExpr = new ForallExpr(expr.tok, ((QuantifierExpr)expr).TypeArgs, newBoundVars, newRange, newTerm, newAttrs);
} else if (expr is ExistsExpr) {
@@ -13685,7 +13694,7 @@ namespace Microsoft.Dafny {
r = rr;
} else if (stmt is AssignSuchThatStmt) {
var s = (AssignSuchThatStmt)stmt;
- r = new AssignSuchThatStmt(s.Tok, s.EndTok, s.Lhss.ConvertAll(Substitute), Substitute(s.Expr), s.AssumeToken == null ? null : s.AssumeToken);
+ r = new AssignSuchThatStmt(s.Tok, s.EndTok, s.Lhss.ConvertAll(Substitute), Substitute(s.Expr), s.AssumeToken == null ? null : s.AssumeToken, null);
} else if (stmt is UpdateStmt) {
var s = (UpdateStmt)stmt;
var resolved = s.ResolvedStatements;