diff options
-rw-r--r-- | Dafny/Cloner.cs | 2 | ||||
-rw-r--r-- | Dafny/DafnyAst.cs | 85 | ||||
-rw-r--r-- | Dafny/Parser.cs | 537 | ||||
-rw-r--r-- | Dafny/Printer.cs | 4 | ||||
-rw-r--r-- | Dafny/Resolver.cs | 45 | ||||
-rw-r--r-- | Dafny/Translator.cs | 47 |
6 files changed, 404 insertions, 316 deletions
diff --git a/Dafny/Cloner.cs b/Dafny/Cloner.cs index 58f16235..8a7b314c 100644 --- a/Dafny/Cloner.cs +++ b/Dafny/Cloner.cs @@ -424,7 +424,7 @@ namespace Microsoft.Dafny } else if (stmt is CalcStmt) {
var s = (CalcStmt)stmt;
- r = new CalcStmt(Tok(s.Tok), s.Steps.ConvertAll(CloneExpr), s.Hints.ConvertAll(CloneStmt));
+ r = new CalcStmt(Tok(s.Tok), s.Terms.ConvertAll(CloneExpr), s.Hints.ConvertAll(CloneStmt));
} else if (stmt is MatchStmt) {
var s = (MatchStmt)stmt;
diff --git a/Dafny/DafnyAst.cs b/Dafny/DafnyAst.cs index 3eda6088..f138a4d9 100644 --- a/Dafny/DafnyAst.cs +++ b/Dafny/DafnyAst.cs @@ -2664,52 +2664,53 @@ namespace Microsoft.Dafny { public class CalcStmt : Statement
{
- public readonly List<Expression/*!*/> Steps; // come up with a better name
- public readonly List<Statement> Hints; // an empty hint is represented with null
+ public readonly List<Expression/*!*/> Terms;
+ public readonly List<Statement> Hints; // an empty hint is represented with null
+ public readonly List<BinaryExpr/*!*/> Steps; // expressions ti op t<i + 1>, filled in during resolution in order to get the correct op
+ public BinaryExpr Result; // expressions t0 op tn, filled in during resolution in order to get the correct op
- [ContractInvariantMethod]
- void ObjectInvariant()
- {
- Contract.Invariant(Steps != null);
- Contract.Invariant(Hints != null);
- Contract.Invariant(Steps.Count > 0);
- Contract.Invariant(Hints.Count == Steps.Count - 1);
- }
-
- public CalcStmt(IToken tok, List<Expression/*!*/> steps, List<Statement> hints)
- // Attributes attrs?
- : base(tok)
- {
- Contract.Requires(tok != null);
- Contract.Requires(steps != null);
- Contract.Requires(cce.NonNullElements(steps));
- Contract.Requires(hints != null);
- Contract.Requires(steps.Count > 0);
- Contract.Requires(hints.Count == steps.Count - 1);
- this.Steps = steps;
- this.Hints = hints;
- }
+ [ContractInvariantMethod]
+ void ObjectInvariant()
+ {
+ Contract.Invariant(Terms != null);
+ Contract.Invariant(Hints != null);
+ Contract.Invariant(Terms.Count > 0);
+ Contract.Invariant(Hints.Count == Terms.Count - 1);
+ Contract.Invariant(Steps.Count == 0 /*before resolution*/ || Steps.Count == Hints.Count /*after resolution*/);
+ }
- public override IEnumerable<Statement> SubStatements
- {
- get
- {
- foreach (var h in Hints)
- {
- if (h != null) yield return h;
- }
- }
+ public CalcStmt(IToken tok, List<Expression/*!*/> terms, List<Statement> hints)
+ // Attributes attrs?
+ : base(tok)
+ {
+ Contract.Requires(tok != null);
+ Contract.Requires(terms != null);
+ Contract.Requires(cce.NonNullElements(terms));
+ Contract.Requires(hints != null);
+ Contract.Requires(terms.Count > 0);
+ Contract.Requires(hints.Count == terms.Count - 1);
+ this.Terms = terms;
+ this.Hints = hints;
+ this.Steps = new List<BinaryExpr>();
+ this.Result = null;
+ }
+
+ public override IEnumerable<Statement> SubStatements
+ {
+ get {
+ foreach (var h in Hints) {
+ if (h != null) yield return h;
+ }
}
- public override IEnumerable<Expression> SubExpressions
- {
- get
- {
- foreach (var s in Steps)
- {
- yield return s;
- }
- }
+ }
+ public override IEnumerable<Expression> SubExpressions
+ {
+ get {
+ foreach (var t in Terms) {
+ yield return t;
+ }
}
+ }
}
public class MatchStmt : Statement
diff --git a/Dafny/Parser.cs b/Dafny/Parser.cs index 69d13347..ebde5f12 100644 --- a/Dafny/Parser.cs +++ b/Dafny/Parser.cs @@ -21,7 +21,7 @@ public class Parser { public const int _colon = 5;
public const int _lbrace = 6;
public const int _rbrace = 7;
- public const int maxT = 111;
+ public const int maxT = 112;
const bool T = true;
const bool x = false;
@@ -221,7 +221,7 @@ bool IsAttribute() { defaultModule.TopLevelDecls.Add(at);
} else if (StartOf(2)) {
ClassMemberDecl(membersDefaultClass, isGhost, false);
- } else SynErr(112);
+ } else SynErr(113);
}
DefaultClassDecl defaultClass = null;
foreach (TopLevelDecl topleveldecl in defaultModule.TopLevelDecls) {
@@ -285,7 +285,7 @@ bool IsAttribute() { module.TopLevelDecls.Add(at);
} else if (StartOf(2)) {
ClassMemberDecl(namedModuleDefaultClassMembers, isGhost, false);
- } else SynErr(113);
+ } else SynErr(114);
}
Expect(7);
module.BodyEndTok = t;
@@ -315,8 +315,8 @@ bool IsAttribute() { }
Expect(14);
submodule = new AbstractModuleDecl(idPath, id, parent, idAssignment, opened);
- } else SynErr(114);
- } else SynErr(115);
+ } else SynErr(115);
+ } else SynErr(116);
}
void ClassDecl(ModuleDefinition/*!*/ module, out ClassDecl/*!*/ c) {
@@ -328,7 +328,7 @@ bool IsAttribute() { List<MemberDecl/*!*/> members = new List<MemberDecl/*!*/>();
IToken bodyStart;
- while (!(la.kind == 0 || la.kind == 18)) {SynErr(116); Get();}
+ while (!(la.kind == 0 || la.kind == 18)) {SynErr(117); Get();}
Expect(18);
while (la.kind == 6) {
Attribute(ref attrs);
@@ -359,13 +359,13 @@ bool IsAttribute() { IToken bodyStart = Token.NoToken; // dummy assignment
bool co = false;
- while (!(la.kind == 0 || la.kind == 20 || la.kind == 21)) {SynErr(117); Get();}
+ while (!(la.kind == 0 || la.kind == 20 || la.kind == 21)) {SynErr(118); Get();}
if (la.kind == 20) {
Get();
} else if (la.kind == 21) {
Get();
co = true;
- } else SynErr(118);
+ } else SynErr(119);
while (la.kind == 6) {
Attribute(ref attrs);
}
@@ -380,7 +380,7 @@ bool IsAttribute() { Get();
DatatypeMemberDecl(ctors);
}
- while (!(la.kind == 0 || la.kind == 14)) {SynErr(119); Get();}
+ while (!(la.kind == 0 || la.kind == 14)) {SynErr(120); Get();}
Expect(14);
if (co) {
dt = new CoDatatypeDecl(id, id.val, module, typeArgs, ctors, attrs);
@@ -409,7 +409,7 @@ bool IsAttribute() { eqSupport = TypeParameter.EqualitySupportValue.Required;
}
at = new ArbitraryTypeDecl(id, id.val, module, eqSupport, attrs);
- while (!(la.kind == 0 || la.kind == 14)) {SynErr(120); Get();}
+ while (!(la.kind == 0 || la.kind == 14)) {SynErr(121); Get();}
Expect(14);
}
@@ -437,7 +437,7 @@ bool IsAttribute() { } else if (la.kind == 31 || la.kind == 32) {
MethodDecl(mmod, allowConstructors, out m);
mm.Add(m);
- } else SynErr(121);
+ } else SynErr(122);
}
void Attribute(ref Attributes attrs) {
@@ -508,7 +508,7 @@ bool IsAttribute() { Attributes attrs = null;
IToken/*!*/ id; Type/*!*/ ty;
- while (!(la.kind == 0 || la.kind == 23)) {SynErr(122); Get();}
+ while (!(la.kind == 0 || la.kind == 23)) {SynErr(123); Get();}
Expect(23);
if (mmod.IsStatic) { SemErr(t, "fields cannot be declared 'static'"); }
@@ -522,7 +522,7 @@ bool IsAttribute() { IdentType(out id, out ty, false);
mm.Add(new Field(id, id.val, mmod.IsGhost, ty, attrs));
}
- while (!(la.kind == 0 || la.kind == 14)) {SynErr(123); Get();}
+ while (!(la.kind == 0 || la.kind == 14)) {SynErr(124); Get();}
Expect(14);
}
@@ -568,7 +568,7 @@ bool IsAttribute() { Get();
signatureOmitted = true;
openParen = Token.NoToken;
- } else SynErr(124);
+ } else SynErr(125);
} else if (la.kind == 49) {
Get();
isPredicate = true;
@@ -597,7 +597,7 @@ bool IsAttribute() { Get();
signatureOmitted = true;
openParen = Token.NoToken;
- } else SynErr(125);
+ } else SynErr(126);
} else if (la.kind == 50) {
Get();
isCoPredicate = true;
@@ -622,8 +622,8 @@ bool IsAttribute() { Get();
signatureOmitted = true;
openParen = Token.NoToken;
- } else SynErr(126);
- } else SynErr(127);
+ } else SynErr(127);
+ } else SynErr(128);
decreases = isCoPredicate ? null : new List<Expression/*!*/>();
while (StartOf(4)) {
FunctionSpec(reqs, reads, ens, decreases);
@@ -666,7 +666,7 @@ bool IsAttribute() { IToken bodyStart = Token.NoToken;
IToken bodyEnd = Token.NoToken;
- while (!(la.kind == 0 || la.kind == 31 || la.kind == 32)) {SynErr(128); Get();}
+ while (!(la.kind == 0 || la.kind == 31 || la.kind == 32)) {SynErr(129); Get();}
if (la.kind == 31) {
Get();
} else if (la.kind == 32) {
@@ -677,7 +677,7 @@ bool IsAttribute() { SemErr(t, "constructors are only allowed in classes");
}
- } else SynErr(129);
+ } else SynErr(130);
if (isConstructor) {
if (mmod.IsGhost) {
SemErr(t, "constructors cannot be declared 'ghost'");
@@ -704,7 +704,7 @@ bool IsAttribute() { } else if (la.kind == 34) {
Get();
signatureOmitted = true; openParen = Token.NoToken;
- } else SynErr(130);
+ } else SynErr(131);
while (StartOf(5)) {
MethodSpec(req, mod, ens, dec, ref decAttrs, ref modAttrs);
}
@@ -912,7 +912,7 @@ bool IsAttribute() { ReferenceType(out tok, out ty);
break;
}
- default: SynErr(131); break;
+ default: SynErr(132); break;
}
}
@@ -937,7 +937,7 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo Contract.Requires(cce.NonNullElements(req)); Contract.Requires(cce.NonNullElements(mod)); Contract.Requires(cce.NonNullElements(ens)); Contract.Requires(cce.NonNullElements(decreases));
Expression/*!*/ e; FrameExpression/*!*/ fe; bool isFree = false; Attributes ensAttrs = null;
- while (!(StartOf(7))) {SynErr(132); Get();}
+ while (!(StartOf(7))) {SynErr(133); Get();}
if (la.kind == 35) {
Get();
while (IsAttribute()) {
@@ -952,7 +952,7 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo mod.Add(fe);
}
}
- while (!(la.kind == 0 || la.kind == 14)) {SynErr(133); Get();}
+ while (!(la.kind == 0 || la.kind == 14)) {SynErr(134); Get();}
Expect(14);
} else if (la.kind == 36 || la.kind == 37 || la.kind == 38) {
if (la.kind == 36) {
@@ -962,7 +962,7 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo if (la.kind == 37) {
Get();
Expression(out e);
- while (!(la.kind == 0 || la.kind == 14)) {SynErr(134); Get();}
+ while (!(la.kind == 0 || la.kind == 14)) {SynErr(135); Get();}
Expect(14);
req.Add(new MaybeFreeExpression(e, isFree));
} else if (la.kind == 38) {
@@ -971,19 +971,19 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo Attribute(ref ensAttrs);
}
Expression(out e);
- while (!(la.kind == 0 || la.kind == 14)) {SynErr(135); Get();}
+ while (!(la.kind == 0 || la.kind == 14)) {SynErr(136); Get();}
Expect(14);
ens.Add(new MaybeFreeExpression(e, isFree, ensAttrs));
- } else SynErr(136);
+ } else SynErr(137);
} else if (la.kind == 39) {
Get();
while (IsAttribute()) {
Attribute(ref decAttrs);
}
DecreasesList(decreases, true);
- while (!(la.kind == 0 || la.kind == 14)) {SynErr(137); Get();}
+ while (!(la.kind == 0 || la.kind == 14)) {SynErr(138); Get();}
Expect(14);
- } else SynErr(138);
+ } else SynErr(139);
}
void BlockStmt(out BlockStmt/*!*/ block, out IToken bodyStart, out IToken bodyEnd) {
@@ -1021,7 +1021,7 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo Ident(out id);
fieldName = id.val;
fe = new FrameExpression(id, new ImplicitThisExpr(id), fieldName);
- } else SynErr(139);
+ } else SynErr(140);
}
void Expression(out Expression/*!*/ e) {
@@ -1097,7 +1097,7 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo GenericInstantiation(gt);
}
ty = new UserDefinedType(tok, tok.val, gt, path);
- } else SynErr(140);
+ } else SynErr(141);
}
void FunctionSpec(List<Expression/*!*/>/*!*/ reqs, List<FrameExpression/*!*/>/*!*/ reads, List<Expression/*!*/>/*!*/ ens, List<Expression/*!*/> decreases) {
@@ -1106,10 +1106,10 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo Contract.Requires(decreases == null || cce.NonNullElements(decreases));
Expression/*!*/ e; FrameExpression/*!*/ fe;
if (la.kind == 37) {
- while (!(la.kind == 0 || la.kind == 37)) {SynErr(141); Get();}
+ while (!(la.kind == 0 || la.kind == 37)) {SynErr(142); Get();}
Get();
Expression(out e);
- while (!(la.kind == 0 || la.kind == 14)) {SynErr(142); Get();}
+ while (!(la.kind == 0 || la.kind == 14)) {SynErr(143); Get();}
Expect(14);
reqs.Add(e);
} else if (la.kind == 51) {
@@ -1123,12 +1123,12 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo reads.Add(fe);
}
}
- while (!(la.kind == 0 || la.kind == 14)) {SynErr(143); Get();}
+ while (!(la.kind == 0 || la.kind == 14)) {SynErr(144); Get();}
Expect(14);
} else if (la.kind == 38) {
Get();
Expression(out e);
- while (!(la.kind == 0 || la.kind == 14)) {SynErr(144); Get();}
+ while (!(la.kind == 0 || la.kind == 14)) {SynErr(145); Get();}
Expect(14);
ens.Add(e);
} else if (la.kind == 39) {
@@ -1139,9 +1139,9 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo }
DecreasesList(decreases, false);
- while (!(la.kind == 0 || la.kind == 14)) {SynErr(145); Get();}
+ while (!(la.kind == 0 || la.kind == 14)) {SynErr(146); Get();}
Expect(14);
- } else SynErr(146);
+ } else SynErr(147);
}
void FunctionBody(out Expression/*!*/ e, out IToken bodyStart, out IToken bodyEnd) {
@@ -1160,7 +1160,7 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo fe = new FrameExpression(t, new WildcardExpr(t), null);
} else if (StartOf(8)) {
FrameExpression(out fe);
- } else SynErr(147);
+ } else SynErr(148);
}
void PossiblyWildExpression(out Expression/*!*/ e) {
@@ -1171,7 +1171,7 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo e = new WildcardExpr(t);
} else if (StartOf(10)) {
Expression(out e);
- } else SynErr(148);
+ } else SynErr(149);
}
void Stmt(List<Statement/*!*/>/*!*/ ss) {
@@ -1188,7 +1188,7 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo IToken bodyStart, bodyEnd;
int breakCount;
- while (!(StartOf(12))) {SynErr(149); Get();}
+ while (!(StartOf(12))) {SynErr(150); Get();}
switch (la.kind) {
case 6: {
BlockStmt(out bs, out bodyStart, out bodyEnd);
@@ -1207,7 +1207,7 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo PrintStmt(out s);
break;
}
- case 1: case 2: case 22: case 26: case 97: case 98: case 99: case 100: case 101: case 102: {
+ case 1: case 2: case 22: case 26: case 98: case 99: case 100: case 101: case 102: case 103: {
UpdateStmt(out s);
break;
}
@@ -1231,6 +1231,10 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo ParallelStmt(out s);
break;
}
+ case 75: {
+ CalcStmt(out s);
+ break;
+ }
case 54: {
Get();
x = t;
@@ -1251,8 +1255,8 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo Get();
breakCount++;
}
- } else SynErr(150);
- while (!(la.kind == 0 || la.kind == 14)) {SynErr(151); Get();}
+ } else SynErr(151);
+ while (!(la.kind == 0 || la.kind == 14)) {SynErr(152); Get();}
Expect(14);
s = label != null ? new BreakStmt(x, label) : new BreakStmt(x, breakCount);
break;
@@ -1266,7 +1270,7 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo Expect(14);
break;
}
- default: SynErr(152); break;
+ default: SynErr(153); break;
}
}
@@ -1283,7 +1287,7 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo Expression(out e);
} else if (la.kind == 34) {
Get();
- } else SynErr(153);
+ } else SynErr(154);
Expect(14);
if (e == null) {
s = new SkeletonStatement(new AssertStmt(x, new LiteralExpr(x, true), attrs), true, false);
@@ -1306,7 +1310,7 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo Expression(out e);
} else if (la.kind == 34) {
Get();
- } else SynErr(154);
+ } else SynErr(155);
if (e == null) {
s = new SkeletonStatement(new AssumeStmt(x, new LiteralExpr(x, true), attrs), true, false);
} else {
@@ -1376,12 +1380,12 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo suchThatAssume = t;
}
Expression(out suchThat);
- } else SynErr(155);
+ } else SynErr(156);
Expect(14);
} else if (la.kind == 5) {
Get();
SemErr(t, "invalid statement (did you forget the 'label' keyword?)");
- } else SynErr(156);
+ } else SynErr(157);
if (suchThat != null) {
s = new AssignSuchThatStmt(x, lhss, suchThat, suchThatAssume);
} else {
@@ -1490,7 +1494,7 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo } else if (la.kind == 6) {
BlockStmt(out bs, out bodyStart, out bodyEnd);
els = bs;
- } else SynErr(157);
+ } else SynErr(158);
}
if (guardOmitted) {
ifStmt = new SkeletonStatement(new IfStmt(x, guard, thn, els), true, false);
@@ -1501,7 +1505,7 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo } else if (la.kind == 6) {
AlternativeBlock(out alternatives);
ifStmt = new AlternativeStmt(x, alternatives);
- } else SynErr(158);
+ } else SynErr(159);
}
void WhileStmt(out Statement/*!*/ stmt) {
@@ -1533,7 +1537,7 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo } else if (la.kind == 34) {
Get();
bodyOmitted = true;
- } else SynErr(159);
+ } else SynErr(160);
if (guardOmitted || bodyOmitted) {
if (mod != null) {
SemErr(mod[0].E.tok, "'modifies' clauses are not allowed on refining loops");
@@ -1553,7 +1557,7 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo LoopSpec(out invariants, out decreases, out mod, ref decAttrs, ref modAttrs);
AlternativeBlock(out alternatives);
stmt = new AlternativeLoopStmt(x, invariants, new Specification<Expression>(decreases, decAttrs), new Specification<FrameExpression>(mod, modAttrs), alternatives);
- } else SynErr(160);
+ } else SynErr(161);
}
void MatchStmt(out Statement/*!*/ s) {
@@ -1612,6 +1616,36 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo s = new ParallelStmt(x, bvars, attrs, range, ens, block);
}
+ void CalcStmt(out Statement/*!*/ s) {
+ Contract.Ensures(Contract.ValueAtReturn(out s) != null);
+ Token x;
+ List<Expression/*!*/> steps = new List<Expression/*!*/>();
+ List<Statement> hints = new List<Statement>();
+ Expression/*!*/ e;
+ BlockStmt/*!*/ block;
+ IToken bodyStart, bodyEnd;
+
+ Expect(75);
+ x = t;
+ Expect(6);
+ Expression(out e);
+ steps.Add(e);
+ Expect(14);
+ while (StartOf(10)) {
+ if (la.kind == 6) {
+ BlockStmt(out block, out bodyStart, out bodyEnd);
+ hints.Add(block);
+ } else {
+ hints.Add(null);
+ }
+ Expression(out e);
+ steps.Add(e);
+ Expect(14);
+ }
+ Expect(7);
+ s = new CalcStmt(x, steps, hints);
+ }
+
void ReturnStmt(out Statement/*!*/ s) {
IToken returnTok = null;
List<AssignmentRhs> rhss = null;
@@ -1738,7 +1772,7 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo } else if (StartOf(10)) {
Expression(out e);
r = new ExprRhs(e);
- } else SynErr(161);
+ } else SynErr(162);
while (la.kind == 6) {
Attribute(ref attrs);
}
@@ -1759,7 +1793,7 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo while (la.kind == 17 || la.kind == 62) {
Suffix(ref e);
}
- } else SynErr(162);
+ } else SynErr(163);
}
void Expressions(List<Expression/*!*/>/*!*/ args) {
@@ -1782,7 +1816,7 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo } else if (StartOf(10)) {
Expression(out ee);
e = ee;
- } else SynErr(163);
+ } else SynErr(164);
Expect(28);
}
@@ -1817,20 +1851,20 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo while (StartOf(16)) {
if (la.kind == 36 || la.kind == 70) {
Invariant(out invariant);
- while (!(la.kind == 0 || la.kind == 14)) {SynErr(164); Get();}
+ while (!(la.kind == 0 || la.kind == 14)) {SynErr(165); Get();}
Expect(14);
invariants.Add(invariant);
} else if (la.kind == 39) {
- while (!(la.kind == 0 || la.kind == 39)) {SynErr(165); Get();}
+ while (!(la.kind == 0 || la.kind == 39)) {SynErr(166); Get();}
Get();
while (IsAttribute()) {
Attribute(ref decAttrs);
}
DecreasesList(decreases, true);
- while (!(la.kind == 0 || la.kind == 14)) {SynErr(166); Get();}
+ while (!(la.kind == 0 || la.kind == 14)) {SynErr(167); Get();}
Expect(14);
} else {
- while (!(la.kind == 0 || la.kind == 35)) {SynErr(167); Get();}
+ while (!(la.kind == 0 || la.kind == 35)) {SynErr(168); Get();}
Get();
while (IsAttribute()) {
Attribute(ref modAttrs);
@@ -1845,7 +1879,7 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo mod.Add(fe);
}
}
- while (!(la.kind == 0 || la.kind == 14)) {SynErr(168); Get();}
+ while (!(la.kind == 0 || la.kind == 14)) {SynErr(169); Get();}
Expect(14);
}
}
@@ -1853,7 +1887,7 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo void Invariant(out MaybeFreeExpression/*!*/ invariant) {
bool isFree = false; Expression/*!*/ e; List<string> ids = new List<string>(); invariant = null; Attributes attrs = null;
- while (!(la.kind == 0 || la.kind == 36 || la.kind == 70)) {SynErr(169); Get();}
+ while (!(la.kind == 0 || la.kind == 36 || la.kind == 70)) {SynErr(170); Get();}
if (la.kind == 36) {
Get();
isFree = true;
@@ -1902,7 +1936,7 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo } else if (StartOf(10)) {
Expression(out e);
arg = new Attributes.Argument(t, e);
- } else SynErr(170);
+ } else SynErr(171);
}
void QuantifierDomain(out List<BoundVar/*!*/> bvars, out Attributes attrs, out Expression range) {
@@ -1930,7 +1964,7 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo void EquivExpression(out Expression/*!*/ e0) {
Contract.Ensures(Contract.ValueAtReturn(out e0) != null); IToken/*!*/ x; Expression/*!*/ e1;
ImpliesExpression(out e0);
- while (la.kind == 75 || la.kind == 76) {
+ while (la.kind == 76 || la.kind == 77) {
EquivOp();
x = t;
ImpliesExpression(out e1);
@@ -1941,7 +1975,7 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo void ImpliesExpression(out Expression/*!*/ e0) {
Contract.Ensures(Contract.ValueAtReturn(out e0) != null); IToken/*!*/ x; Expression/*!*/ e1;
LogicalExpression(out e0);
- if (la.kind == 77 || la.kind == 78) {
+ if (la.kind == 78 || la.kind == 79) {
ImpliesOp();
x = t;
ImpliesExpression(out e1);
@@ -1950,23 +1984,23 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo }
void EquivOp() {
- if (la.kind == 75) {
+ if (la.kind == 76) {
Get();
- } else if (la.kind == 76) {
+ } else if (la.kind == 77) {
Get();
- } else SynErr(171);
+ } else SynErr(172);
}
void LogicalExpression(out Expression/*!*/ e0) {
Contract.Ensures(Contract.ValueAtReturn(out e0) != null); IToken/*!*/ x; Expression/*!*/ e1;
RelationalExpression(out e0);
if (StartOf(17)) {
- if (la.kind == 79 || la.kind == 80) {
+ if (la.kind == 80 || la.kind == 81) {
AndOp();
x = t;
RelationalExpression(out e1);
e0 = new BinaryExpr(x, BinaryExpr.Opcode.And, e0, e1);
- while (la.kind == 79 || la.kind == 80) {
+ while (la.kind == 80 || la.kind == 81) {
AndOp();
x = t;
RelationalExpression(out e1);
@@ -1977,7 +2011,7 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo x = t;
RelationalExpression(out e1);
e0 = new BinaryExpr(x, BinaryExpr.Opcode.Or, e0, e1);
- while (la.kind == 81 || la.kind == 82) {
+ while (la.kind == 82 || la.kind == 83) {
OrOp();
x = t;
RelationalExpression(out e1);
@@ -1988,11 +2022,11 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo }
void ImpliesOp() {
- if (la.kind == 77) {
+ if (la.kind == 78) {
Get();
- } else if (la.kind == 78) {
+ } else if (la.kind == 79) {
Get();
- } else SynErr(172);
+ } else SynErr(173);
}
void RelationalExpression(out Expression/*!*/ e) {
@@ -2086,25 +2120,25 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo }
void AndOp() {
- if (la.kind == 79) {
+ if (la.kind == 80) {
Get();
- } else if (la.kind == 80) {
+ } else if (la.kind == 81) {
Get();
- } else SynErr(173);
+ } else SynErr(174);
}
void OrOp() {
- if (la.kind == 81) {
+ if (la.kind == 82) {
Get();
- } else if (la.kind == 82) {
+ } else if (la.kind == 83) {
Get();
- } else SynErr(174);
+ } else SynErr(175);
}
void Term(out Expression/*!*/ e0) {
Contract.Ensures(Contract.ValueAtReturn(out e0) != null); IToken/*!*/ x; Expression/*!*/ e1; BinaryExpr.Opcode op;
Factor(out e0);
- while (la.kind == 92 || la.kind == 93) {
+ while (la.kind == 93 || la.kind == 94) {
AddOp(out x, out op);
Factor(out e1);
e0 = new BinaryExpr(x, op, e0, e1);
@@ -2132,35 +2166,35 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo x = t; op = BinaryExpr.Opcode.Gt;
break;
}
- case 83: {
+ case 84: {
Get();
x = t; op = BinaryExpr.Opcode.Le;
break;
}
- case 84: {
+ case 85: {
Get();
x = t; op = BinaryExpr.Opcode.Ge;
break;
}
- case 85: {
+ case 86: {
Get();
x = t; op = BinaryExpr.Opcode.Neq;
break;
}
- case 86: {
+ case 87: {
Get();
x = t; op = BinaryExpr.Opcode.Disjoint;
break;
}
- case 87: {
+ case 88: {
Get();
x = t; op = BinaryExpr.Opcode.In;
break;
}
- case 88: {
+ case 89: {
Get();
x = t; y = Token.NoToken;
- if (la.kind == 87) {
+ if (la.kind == 88) {
Get();
y = t;
}
@@ -2175,29 +2209,29 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo break;
}
- case 89: {
+ case 90: {
Get();
x = t; op = BinaryExpr.Opcode.Neq;
break;
}
- case 90: {
+ case 91: {
Get();
x = t; op = BinaryExpr.Opcode.Le;
break;
}
- case 91: {
+ case 92: {
Get();
x = t; op = BinaryExpr.Opcode.Ge;
break;
}
- default: SynErr(175); break;
+ default: SynErr(176); break;
}
}
void Factor(out Expression/*!*/ e0) {
Contract.Ensures(Contract.ValueAtReturn(out e0) != null); IToken/*!*/ x; Expression/*!*/ e1; BinaryExpr.Opcode op;
UnaryExpression(out e0);
- while (la.kind == 52 || la.kind == 94 || la.kind == 95) {
+ while (la.kind == 52 || la.kind == 95 || la.kind == 96) {
MulOp(out x, out op);
UnaryExpression(out e1);
e0 = new BinaryExpr(x, op, e0, e1);
@@ -2206,33 +2240,33 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo void AddOp(out IToken/*!*/ x, out BinaryExpr.Opcode op) {
Contract.Ensures(Contract.ValueAtReturn(out x) != null); x = Token.NoToken; op=BinaryExpr.Opcode.Add/*(dummy)*/;
- if (la.kind == 92) {
+ if (la.kind == 93) {
Get();
x = t; op = BinaryExpr.Opcode.Add;
- } else if (la.kind == 93) {
+ } else if (la.kind == 94) {
Get();
x = t; op = BinaryExpr.Opcode.Sub;
- } else SynErr(176);
+ } else SynErr(177);
}
void UnaryExpression(out Expression/*!*/ e) {
Contract.Ensures(Contract.ValueAtReturn(out e) != null); IToken/*!*/ x; e = dummyExpr;
switch (la.kind) {
- case 93: {
+ case 94: {
Get();
x = t;
UnaryExpression(out e);
e = new BinaryExpr(x, BinaryExpr.Opcode.Sub, new LiteralExpr(x, 0), e);
break;
}
- case 88: case 96: {
+ case 89: case 97: {
NegOp();
x = t;
UnaryExpression(out e);
e = new UnaryExpr(x, UnaryExpr.Opcode.Not, e);
break;
}
- case 23: case 43: case 54: case 60: case 65: case 71: case 72: case 105: case 106: case 107: case 108: {
+ case 23: case 43: case 54: case 60: case 65: case 71: case 72: case 106: case 107: case 108: case 109: {
EndlessExpression(out e);
break;
}
@@ -2269,17 +2303,17 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo MapComprehensionExpr(x, out e);
} else if (StartOf(19)) {
SemErr("map must be followed by literal in brackets or comprehension.");
- } else SynErr(177);
+ } else SynErr(178);
break;
}
- case 2: case 22: case 26: case 97: case 98: case 99: case 100: case 101: case 102: {
+ case 2: case 22: case 26: case 98: case 99: case 100: case 101: case 102: case 103: {
ConstAtomExpression(out e);
while (la.kind == 17 || la.kind == 62) {
Suffix(ref e);
}
break;
}
- default: SynErr(178); break;
+ default: SynErr(179); break;
}
}
@@ -2288,21 +2322,21 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo if (la.kind == 52) {
Get();
x = t; op = BinaryExpr.Opcode.Mul;
- } else if (la.kind == 94) {
+ } else if (la.kind == 95) {
Get();
x = t; op = BinaryExpr.Opcode.Div;
- } else if (la.kind == 95) {
+ } else if (la.kind == 96) {
Get();
x = t; op = BinaryExpr.Opcode.Mod;
- } else SynErr(179);
+ } else SynErr(180);
}
void NegOp() {
- if (la.kind == 88) {
+ if (la.kind == 89) {
Get();
- } else if (la.kind == 96) {
+ } else if (la.kind == 97) {
Get();
- } else SynErr(180);
+ } else SynErr(181);
}
void EndlessExpression(out Expression e) {
@@ -2315,7 +2349,7 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo Get();
x = t;
Expression(out e);
- Expect(103);
+ Expect(104);
Expression(out e0);
Expect(66);
Expression(out e1);
@@ -2326,7 +2360,7 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo MatchExpression(out e);
break;
}
- case 105: case 106: case 107: case 108: {
+ case 106: case 107: case 108: case 109: {
QuantifierGuts(out e);
break;
}
@@ -2360,7 +2394,7 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo NamedExpr(out e);
break;
}
- default: SynErr(181); break;
+ default: SynErr(182); break;
}
}
@@ -2412,7 +2446,7 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo if (StartOf(10)) {
Expression(out ee);
e0 = ee;
- if (la.kind == 104) {
+ if (la.kind == 105) {
Get();
anyDots = true;
if (StartOf(10)) {
@@ -2434,15 +2468,15 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo multipleIndices.Add(ee);
}
- } else SynErr(182);
- } else if (la.kind == 104) {
+ } else SynErr(183);
+ } else if (la.kind == 105) {
Get();
anyDots = true;
if (StartOf(10)) {
Expression(out ee);
e1 = ee;
}
- } else SynErr(183);
+ } else SynErr(184);
if (multipleIndices != null) {
e = new MultiSelectExpr(x, e, multipleIndices);
// make sure an array class with this dimensionality exists
@@ -2466,7 +2500,7 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo }
Expect(63);
- } else SynErr(184);
+ } else SynErr(185);
}
void DisplayExpr(out Expression e) {
@@ -2490,7 +2524,7 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo }
e = new SeqDisplayExpr(x, elements);
Expect(63);
- } else SynErr(185);
+ } else SynErr(186);
}
void MultiSetExpr(out Expression e) {
@@ -2516,7 +2550,7 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo Expect(28);
} else if (StartOf(20)) {
SemErr("multiset must be followed by multiset literal or expression to coerce in parentheses.");
- } else SynErr(186);
+ } else SynErr(187);
}
void MapDisplayExpr(IToken/*!*/ mapToken, out Expression e) {
@@ -2557,17 +2591,17 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo e = dummyExpr;
switch (la.kind) {
- case 97: {
+ case 98: {
Get();
e = new LiteralExpr(t, false);
break;
}
- case 98: {
+ case 99: {
Get();
e = new LiteralExpr(t, true);
break;
}
- case 99: {
+ case 100: {
Get();
e = new LiteralExpr(t);
break;
@@ -2577,12 +2611,12 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo e = new LiteralExpr(t, n);
break;
}
- case 100: {
+ case 101: {
Get();
e = new ThisExpr(t);
break;
}
- case 101: {
+ case 102: {
Get();
x = t;
Expect(26);
@@ -2591,7 +2625,7 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo e = new FreshExpr(x, e);
break;
}
- case 102: {
+ case 103: {
Get();
x = t;
Expect(26);
@@ -2616,7 +2650,7 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo Expect(28);
break;
}
- default: SynErr(187); break;
+ default: SynErr(188); break;
}
}
@@ -2648,11 +2682,11 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo }
void QSep() {
- if (la.kind == 109) {
+ if (la.kind == 110) {
Get();
- } else if (la.kind == 110) {
+ } else if (la.kind == 111) {
Get();
- } else SynErr(188);
+ } else SynErr(189);
}
void MatchExpression(out Expression/*!*/ e) {
@@ -2677,13 +2711,13 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo Expression range;
Expression/*!*/ body;
- if (la.kind == 105 || la.kind == 106) {
+ if (la.kind == 106 || la.kind == 107) {
Forall();
x = t; univ = true;
- } else if (la.kind == 107 || la.kind == 108) {
+ } else if (la.kind == 108 || la.kind == 109) {
Exists();
x = t;
- } else SynErr(189);
+ } else SynErr(190);
QuantifierDomain(out bvars, out attrs, out range);
QSep();
Expression(out body);
@@ -2714,7 +2748,7 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo }
Expect(22);
Expression(out range);
- if (la.kind == 109 || la.kind == 110) {
+ if (la.kind == 110 || la.kind == 111) {
QSep();
Expression(out body);
}
@@ -2793,19 +2827,19 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo }
void Forall() {
- if (la.kind == 105) {
+ if (la.kind == 106) {
Get();
- } else if (la.kind == 106) {
+ } else if (la.kind == 107) {
Get();
- } else SynErr(190);
+ } else SynErr(191);
}
void Exists() {
- if (la.kind == 107) {
+ if (la.kind == 108) {
Get();
- } else if (la.kind == 108) {
+ } else if (la.kind == 109) {
Get();
- } else SynErr(191);
+ } else SynErr(192);
}
void AttributeBody(ref Attributes attrs) {
@@ -2841,28 +2875,28 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo }
static readonly bool[,]/*!*/ set = {
- {T,T,T,x, x,x,T,x, T,x,x,x, x,x,T,x, x,x,T,x, T,T,T,T, x,x,T,x, x,x,x,T, T,x,T,T, T,T,T,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,T, x,x,T,x, T,x,x,x, x,T,x,x, x,T,T,T, T,T,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,T,T, T,T,T,x, x,x,x,x, x,x,x,x, x},
- {x,x,x,x, x,x,x,x, T,T,x,T, x,x,x,x, x,x,T,T, T,T,x,T, x,T,x,x, x,x,x,T, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,T,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x},
- {x,x,x,x, x,x,x,x, T,x,x,x, x,x,x,x, x,x,x,T, x,x,x,T, x,x,x,x, x,x,x,T, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,T,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x},
- {T,x,x,x, x,x,T,T, T,T,x,T, x,x,x,x, x,x,T,T, T,T,x,T, x,T,T,x, x,T,x,T, T,x,x,x, x,T,T,T, x,x,x,x, x,x,x,x, T,T,T,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x},
- {x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,T,T, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x},
- {x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, T,T,T,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x},
- {x,T,x,T, x,x,x,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,T,T,T, T,T,T,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x},
- {T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, T,T,T,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x},
- {x,T,T,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,T, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, T,x,T,x, x,x,x,x, x,T,T,x, x,x,x,x, T,x,T,x, x,T,x,x, x,x,x,T, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,T,x,x, T,T,T,T, T,T,T,x, x,T,T,T, T,x,x,x, x},
- {x,T,T,x, x,x,T,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,T,T, x,x,T,x, x,x,x,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,T, x,x,T,x, T,x,x,x, x,T,x,x, x,T,x,T, T,T,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,T,T, T,T,T,x, x,x,x,x, x,x,x,x, x},
- {x,T,T,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,T, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, T,x,T,x, x,x,x,x, x,x,T,x, x,x,x,x, T,x,T,x, x,T,x,x, x,x,x,T, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,T,x,x, T,T,T,T, T,T,T,x, x,T,T,T, T,x,x,x, x},
- {x,T,T,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,T, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, T,x,T,x, x,x,x,x, T,T,T,x, x,x,x,x, T,x,T,x, x,T,x,x, x,x,x,T, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,T,x,x, T,T,T,T, T,T,T,x, x,T,T,T, T,x,x,x, x},
- {T,T,T,x, x,x,T,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,T,T, x,x,T,x, x,x,x,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,T, x,x,T,x, T,x,x,x, x,T,x,x, x,T,x,T, T,T,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,T,T, T,T,T,x, x,x,x,x, x,x,x,x, x},
- {x,x,x,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, T,x,x,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x},
- {x,T,T,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,T, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, T,x,T,x, x,x,x,x, T,x,T,x, x,x,x,x, T,T,T,x, T,T,x,x, x,x,x,T, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,T,x,x, T,T,T,T, T,T,T,x, x,T,T,T, T,x,x,x, x},
- {x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,T,T, T,T,T,x, x,x,x,x, x,x,x,x, x},
- {x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, T,x,x,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x},
- {x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, T,T,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x},
- {x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,T,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, T,T,T,T, T,T,T,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x},
- {x,x,x,x, x,x,T,T, x,x,x,x, x,x,T,x, x,x,x,x, x,x,T,x, T,x,x,T, T,T,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,T,x,x, x,T,x,x, x,x,x,T, x,x,T,T, T,x,x,x, x,x,x,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, x,x,x,x, x,x,x,T, T,x,x,x, x,T,T,x, x},
- {x,x,x,x, x,x,T,T, x,x,x,x, x,x,T,x, x,T,x,x, x,x,T,x, T,x,x,T, T,T,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,T,x,x, x,T,x,x, x,x,T,T, x,x,T,T, T,x,x,x, x,x,x,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, x,x,x,x, x,x,x,T, T,x,x,x, x,T,T,x, x},
- {x,T,T,x, T,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,T, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, T,x,T,x, x,x,x,x, x,x,T,x, x,x,x,x, T,x,T,x, x,T,x,x, x,x,x,T, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,T,x,x, T,T,T,T, T,T,T,x, x,T,T,T, T,x,x,x, x}
+ {T,T,T,x, x,x,T,x, T,x,x,x, x,x,T,x, x,x,T,x, T,T,T,T, x,x,T,x, x,x,x,T, T,x,T,T, T,T,T,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,T, x,x,T,x, T,x,x,x, x,T,x,x, x,T,T,T, T,T,T,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,T, T,T,T,T, x,x,x,x, x,x,x,x, x,x},
+ {x,x,x,x, x,x,x,x, T,T,x,T, x,x,x,x, x,x,T,T, T,T,x,T, x,T,x,x, x,x,x,T, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,T,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x},
+ {x,x,x,x, x,x,x,x, T,x,x,x, x,x,x,x, x,x,x,T, x,x,x,T, x,x,x,x, x,x,x,T, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,T,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x},
+ {T,x,x,x, x,x,T,T, T,T,x,T, x,x,x,x, x,x,T,T, T,T,x,T, x,T,T,x, x,T,x,T, T,x,x,x, x,T,T,T, x,x,x,x, x,x,x,x, T,T,T,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x},
+ {x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,T,T, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x},
+ {x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, T,T,T,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x},
+ {x,T,x,T, x,x,x,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,T,T,T, T,T,T,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x},
+ {T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, T,T,T,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x},
+ {x,T,T,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,T, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, T,x,T,x, x,x,x,x, x,T,T,x, x,x,x,x, T,x,T,x, x,T,x,x, x,x,x,T, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,x, x,x,T,x, x,T,T,T, T,T,T,T, x,x,T,T, T,T,x,x, x,x},
+ {x,T,T,x, x,x,T,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,T,T, x,x,T,x, x,x,x,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,T, x,x,T,x, T,x,x,x, x,T,x,x, x,T,x,T, T,T,T,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,T, T,T,T,T, x,x,x,x, x,x,x,x, x,x},
+ {x,T,T,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,T, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, T,x,T,x, x,x,x,x, x,x,T,x, x,x,x,x, T,x,T,x, x,T,x,x, x,x,x,T, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,x, x,x,T,x, x,T,T,T, T,T,T,T, x,x,T,T, T,T,x,x, x,x},
+ {x,T,T,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,T, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, T,x,T,x, x,x,x,x, T,T,T,x, x,x,x,x, T,x,T,x, x,T,x,x, x,x,x,T, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,x, x,x,T,x, x,T,T,T, T,T,T,T, x,x,T,T, T,T,x,x, x,x},
+ {T,T,T,x, x,x,T,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,T,T, x,x,T,x, x,x,x,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,T, x,x,T,x, T,x,x,x, x,T,x,x, x,T,x,T, T,T,T,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,T, T,T,T,T, x,x,x,x, x,x,x,x, x,x},
+ {x,x,x,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, T,x,x,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x},
+ {x,T,T,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,T, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, T,x,T,x, x,x,x,x, T,x,T,x, x,x,x,x, T,T,T,x, T,T,x,x, x,x,x,T, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,x, x,x,T,x, x,T,T,T, T,T,T,T, x,x,T,T, T,T,x,x, x,x},
+ {x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,T, T,T,T,T, x,x,x,x, x,x,x,x, x,x},
+ {x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, T,x,x,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x},
+ {x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,T,T,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x},
+ {x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,T,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,T,T,T, T,T,T,T, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x},
+ {x,x,x,x, x,x,T,T, x,x,x,x, x,x,T,x, x,x,x,x, x,x,T,x, T,x,x,T, T,T,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,T,x,x, x,T,x,x, x,x,x,T, x,x,T,T, T,x,x,x, x,x,x,x, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,x,x,x, x,x,x,x, T,T,x,x, x,x,T,T, x,x},
+ {x,x,x,x, x,x,T,T, x,x,x,x, x,x,T,x, x,T,x,x, x,x,T,x, T,x,x,T, T,T,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,T,x,x, x,T,x,x, x,x,T,T, x,x,T,T, T,x,x,x, x,x,x,x, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,x,x,x, x,x,x,x, T,T,x,x, x,x,T,T, x,x},
+ {x,T,T,x, T,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,T, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, T,x,T,x, x,x,x,x, x,x,T,x, x,x,x,x, T,x,T,x, x,T,x,x, x,x,x,T, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,x, x,x,T,x, x,T,T,T, T,T,T,T, x,x,T,T, T,T,x,x, x,x}
};
} // end Parser
@@ -2962,123 +2996,124 @@ public class Errors { case 72: s = "\"assert\" expected"; break;
case 73: s = "\"print\" expected"; break;
case 74: s = "\"parallel\" expected"; break;
- case 75: s = "\"<==>\" expected"; break;
- case 76: s = "\"\\u21d4\" expected"; break;
- case 77: s = "\"==>\" expected"; break;
- case 78: s = "\"\\u21d2\" expected"; break;
- case 79: s = "\"&&\" expected"; break;
- case 80: s = "\"\\u2227\" expected"; break;
- case 81: s = "\"||\" expected"; break;
- case 82: s = "\"\\u2228\" expected"; break;
- case 83: s = "\"<=\" expected"; break;
- case 84: s = "\">=\" expected"; break;
- case 85: s = "\"!=\" expected"; break;
- case 86: s = "\"!!\" expected"; break;
- case 87: s = "\"in\" expected"; break;
- case 88: s = "\"!\" expected"; break;
- case 89: s = "\"\\u2260\" expected"; break;
- case 90: s = "\"\\u2264\" expected"; break;
- case 91: s = "\"\\u2265\" expected"; break;
- case 92: s = "\"+\" expected"; break;
- case 93: s = "\"-\" expected"; break;
- case 94: s = "\"/\" expected"; break;
- case 95: s = "\"%\" expected"; break;
- case 96: s = "\"\\u00ac\" expected"; break;
- case 97: s = "\"false\" expected"; break;
- case 98: s = "\"true\" expected"; break;
- case 99: s = "\"null\" expected"; break;
- case 100: s = "\"this\" expected"; break;
- case 101: s = "\"fresh\" expected"; break;
- case 102: s = "\"old\" expected"; break;
- case 103: s = "\"then\" expected"; break;
- case 104: s = "\"..\" expected"; break;
- case 105: s = "\"forall\" expected"; break;
- case 106: s = "\"\\u2200\" expected"; break;
- case 107: s = "\"exists\" expected"; break;
- case 108: s = "\"\\u2203\" expected"; break;
- case 109: s = "\"::\" expected"; break;
- case 110: s = "\"\\u2022\" expected"; break;
- case 111: s = "??? expected"; break;
- case 112: s = "invalid Dafny"; break;
- case 113: s = "invalid SubModuleDecl"; break;
+ case 75: s = "\"calc\" expected"; break;
+ case 76: s = "\"<==>\" expected"; break;
+ case 77: s = "\"\\u21d4\" expected"; break;
+ case 78: s = "\"==>\" expected"; break;
+ case 79: s = "\"\\u21d2\" expected"; break;
+ case 80: s = "\"&&\" expected"; break;
+ case 81: s = "\"\\u2227\" expected"; break;
+ case 82: s = "\"||\" expected"; break;
+ case 83: s = "\"\\u2228\" expected"; break;
+ case 84: s = "\"<=\" expected"; break;
+ case 85: s = "\">=\" expected"; break;
+ case 86: s = "\"!=\" expected"; break;
+ case 87: s = "\"!!\" expected"; break;
+ case 88: s = "\"in\" expected"; break;
+ case 89: s = "\"!\" expected"; break;
+ case 90: s = "\"\\u2260\" expected"; break;
+ case 91: s = "\"\\u2264\" expected"; break;
+ case 92: s = "\"\\u2265\" expected"; break;
+ case 93: s = "\"+\" expected"; break;
+ case 94: s = "\"-\" expected"; break;
+ case 95: s = "\"/\" expected"; break;
+ case 96: s = "\"%\" expected"; break;
+ case 97: s = "\"\\u00ac\" expected"; break;
+ case 98: s = "\"false\" expected"; break;
+ case 99: s = "\"true\" expected"; break;
+ case 100: s = "\"null\" expected"; break;
+ case 101: s = "\"this\" expected"; break;
+ case 102: s = "\"fresh\" expected"; break;
+ case 103: s = "\"old\" expected"; break;
+ case 104: s = "\"then\" expected"; break;
+ case 105: s = "\"..\" expected"; break;
+ case 106: s = "\"forall\" expected"; break;
+ case 107: s = "\"\\u2200\" expected"; break;
+ case 108: s = "\"exists\" expected"; break;
+ case 109: s = "\"\\u2203\" expected"; break;
+ case 110: s = "\"::\" expected"; break;
+ case 111: s = "\"\\u2022\" expected"; break;
+ case 112: s = "??? expected"; break;
+ case 113: s = "invalid Dafny"; break;
case 114: s = "invalid SubModuleDecl"; break;
case 115: s = "invalid SubModuleDecl"; break;
- case 116: s = "this symbol not expected in ClassDecl"; break;
- case 117: s = "this symbol not expected in DatatypeDecl"; break;
- case 118: s = "invalid DatatypeDecl"; break;
- case 119: s = "this symbol not expected in DatatypeDecl"; break;
- case 120: s = "this symbol not expected in ArbitraryTypeDecl"; break;
- case 121: s = "invalid ClassMemberDecl"; break;
- case 122: s = "this symbol not expected in FieldDecl"; break;
+ case 116: s = "invalid SubModuleDecl"; break;
+ case 117: s = "this symbol not expected in ClassDecl"; break;
+ case 118: s = "this symbol not expected in DatatypeDecl"; break;
+ case 119: s = "invalid DatatypeDecl"; break;
+ case 120: s = "this symbol not expected in DatatypeDecl"; break;
+ case 121: s = "this symbol not expected in ArbitraryTypeDecl"; break;
+ case 122: s = "invalid ClassMemberDecl"; break;
case 123: s = "this symbol not expected in FieldDecl"; break;
- case 124: s = "invalid FunctionDecl"; break;
+ case 124: s = "this symbol not expected in FieldDecl"; break;
case 125: s = "invalid FunctionDecl"; break;
case 126: s = "invalid FunctionDecl"; break;
case 127: s = "invalid FunctionDecl"; break;
- case 128: s = "this symbol not expected in MethodDecl"; break;
- case 129: s = "invalid MethodDecl"; break;
+ case 128: s = "invalid FunctionDecl"; break;
+ case 129: s = "this symbol not expected in MethodDecl"; break;
case 130: s = "invalid MethodDecl"; break;
- case 131: s = "invalid TypeAndToken"; break;
- case 132: s = "this symbol not expected in MethodSpec"; break;
+ case 131: s = "invalid MethodDecl"; break;
+ case 132: s = "invalid TypeAndToken"; break;
case 133: s = "this symbol not expected in MethodSpec"; break;
case 134: s = "this symbol not expected in MethodSpec"; break;
case 135: s = "this symbol not expected in MethodSpec"; break;
- case 136: s = "invalid MethodSpec"; break;
- case 137: s = "this symbol not expected in MethodSpec"; break;
- case 138: s = "invalid MethodSpec"; break;
- case 139: s = "invalid FrameExpression"; break;
- case 140: s = "invalid ReferenceType"; break;
- case 141: s = "this symbol not expected in FunctionSpec"; break;
+ case 136: s = "this symbol not expected in MethodSpec"; break;
+ case 137: s = "invalid MethodSpec"; break;
+ case 138: s = "this symbol not expected in MethodSpec"; break;
+ case 139: s = "invalid MethodSpec"; break;
+ case 140: s = "invalid FrameExpression"; break;
+ case 141: s = "invalid ReferenceType"; break;
case 142: s = "this symbol not expected in FunctionSpec"; break;
case 143: s = "this symbol not expected in FunctionSpec"; break;
case 144: s = "this symbol not expected in FunctionSpec"; break;
case 145: s = "this symbol not expected in FunctionSpec"; break;
- case 146: s = "invalid FunctionSpec"; break;
- case 147: s = "invalid PossiblyWildFrameExpression"; break;
- case 148: s = "invalid PossiblyWildExpression"; break;
- case 149: s = "this symbol not expected in OneStmt"; break;
- case 150: s = "invalid OneStmt"; break;
- case 151: s = "this symbol not expected in OneStmt"; break;
- case 152: s = "invalid OneStmt"; break;
- case 153: s = "invalid AssertStmt"; break;
- case 154: s = "invalid AssumeStmt"; break;
- case 155: s = "invalid UpdateStmt"; break;
+ case 146: s = "this symbol not expected in FunctionSpec"; break;
+ case 147: s = "invalid FunctionSpec"; break;
+ case 148: s = "invalid PossiblyWildFrameExpression"; break;
+ case 149: s = "invalid PossiblyWildExpression"; break;
+ case 150: s = "this symbol not expected in OneStmt"; break;
+ case 151: s = "invalid OneStmt"; break;
+ case 152: s = "this symbol not expected in OneStmt"; break;
+ case 153: s = "invalid OneStmt"; break;
+ case 154: s = "invalid AssertStmt"; break;
+ case 155: s = "invalid AssumeStmt"; break;
case 156: s = "invalid UpdateStmt"; break;
- case 157: s = "invalid IfStmt"; break;
+ case 157: s = "invalid UpdateStmt"; break;
case 158: s = "invalid IfStmt"; break;
- case 159: s = "invalid WhileStmt"; break;
+ case 159: s = "invalid IfStmt"; break;
case 160: s = "invalid WhileStmt"; break;
- case 161: s = "invalid Rhs"; break;
- case 162: s = "invalid Lhs"; break;
- case 163: s = "invalid Guard"; break;
- case 164: s = "this symbol not expected in LoopSpec"; break;
+ case 161: s = "invalid WhileStmt"; break;
+ case 162: s = "invalid Rhs"; break;
+ case 163: s = "invalid Lhs"; break;
+ case 164: s = "invalid Guard"; break;
case 165: s = "this symbol not expected in LoopSpec"; break;
case 166: s = "this symbol not expected in LoopSpec"; break;
case 167: s = "this symbol not expected in LoopSpec"; break;
case 168: s = "this symbol not expected in LoopSpec"; break;
- case 169: s = "this symbol not expected in Invariant"; break;
- case 170: s = "invalid AttributeArg"; break;
- case 171: s = "invalid EquivOp"; break;
- case 172: s = "invalid ImpliesOp"; break;
- case 173: s = "invalid AndOp"; break;
- case 174: s = "invalid OrOp"; break;
- case 175: s = "invalid RelOp"; break;
- case 176: s = "invalid AddOp"; break;
- case 177: s = "invalid UnaryExpression"; break;
+ case 169: s = "this symbol not expected in LoopSpec"; break;
+ case 170: s = "this symbol not expected in Invariant"; break;
+ case 171: s = "invalid AttributeArg"; break;
+ case 172: s = "invalid EquivOp"; break;
+ case 173: s = "invalid ImpliesOp"; break;
+ case 174: s = "invalid AndOp"; break;
+ case 175: s = "invalid OrOp"; break;
+ case 176: s = "invalid RelOp"; break;
+ case 177: s = "invalid AddOp"; break;
case 178: s = "invalid UnaryExpression"; break;
- case 179: s = "invalid MulOp"; break;
- case 180: s = "invalid NegOp"; break;
- case 181: s = "invalid EndlessExpression"; break;
- case 182: s = "invalid Suffix"; break;
+ case 179: s = "invalid UnaryExpression"; break;
+ case 180: s = "invalid MulOp"; break;
+ case 181: s = "invalid NegOp"; break;
+ case 182: s = "invalid EndlessExpression"; break;
case 183: s = "invalid Suffix"; break;
case 184: s = "invalid Suffix"; break;
- case 185: s = "invalid DisplayExpr"; break;
- case 186: s = "invalid MultiSetExpr"; break;
- case 187: s = "invalid ConstAtomExpression"; break;
- case 188: s = "invalid QSep"; break;
- case 189: s = "invalid QuantifierGuts"; break;
- case 190: s = "invalid Forall"; break;
- case 191: s = "invalid Exists"; break;
+ case 185: s = "invalid Suffix"; break;
+ case 186: s = "invalid DisplayExpr"; break;
+ case 187: s = "invalid MultiSetExpr"; break;
+ case 188: s = "invalid ConstAtomExpression"; break;
+ case 189: s = "invalid QSep"; break;
+ case 190: s = "invalid QuantifierGuts"; break;
+ case 191: s = "invalid Forall"; break;
+ case 192: s = "invalid Exists"; break;
default: s = "error " + n; break;
}
diff --git a/Dafny/Printer.cs b/Dafny/Printer.cs index 627ec1b5..8d7eb26e 100644 --- a/Dafny/Printer.cs +++ b/Dafny/Printer.cs @@ -566,9 +566,9 @@ namespace Microsoft.Dafny { wr.WriteLine(" {");
int stepInd = indent + IndentAmount;
Indent(stepInd);
- PrintExpression(s.Steps[0], stepInd);
+ PrintExpression(s.Terms[0], stepInd);
wr.WriteLine(";");
- var pairs = s.Hints.Zip(s.Steps.Skip(1), (h, e) => Tuple.Create(h, e));
+ var pairs = s.Hints.Zip(s.Terms.Skip(1), (h, e) => Tuple.Create(h, e));
foreach (var pair in pairs) {
if (pair.Item1 != null) {
Indent(stepInd);
diff --git a/Dafny/Resolver.cs b/Dafny/Resolver.cs index 59b8c13e..1c72ad31 100644 --- a/Dafny/Resolver.cs +++ b/Dafny/Resolver.cs @@ -3133,28 +3133,33 @@ namespace Microsoft.Dafny }
} else if (stmt is CalcStmt) {
- CalcStmt s = (CalcStmt)stmt;
- s.IsGhost = true;
- Contract.Assert(s.Steps.Count > 0); // follows from the invariant of CalcStatement
- var source = s.Steps[0];
- ResolveExpression(source, true);
- Contract.Assert(source.Type != null); // follows from postcondition of ResolveExpression
- foreach (var e in s.Steps.Skip(1))
- {
- ResolveExpression(e, true);
- Contract.Assert(e.Type != null); // follows from postcondition of ResolveExpression
- if (!UnifyTypes(source.Type, e.Type))
- {
- Error(e, "all calculation steps must have the same type (got {0} after {1})", e.Type, source.Type);
- }
+ CalcStmt s = (CalcStmt)stmt;
+ s.IsGhost = true;
+ Contract.Assert(s.Terms.Count > 0); // follows from the invariant of CalcStatement
+ var e0 = s.Terms.First();
+ ResolveExpression(e0, true);
+ Contract.Assert(e0.Type != null); // follows from postcondition of ResolveExpression
+ foreach (var e1 in s.Terms.Skip(1))
+ {
+ ResolveExpression(e1, true);
+ Contract.Assert(e1.Type != null); // follows from postcondition of ResolveExpression
+ if (!UnifyTypes(e0.Type, e1.Type)) {
+ Error(e1, "all calculation steps must have the same type (got {0} after {1})", e1.Type, e0.Type);
+ } else {
+ var step = new BinaryExpr(s.Tok, BinaryExpr.Opcode.Eq, e0, e1);
+ ResolveExpression(step, true);
+ s.Steps.Add(step);
}
- foreach (var h in s.Hints)
- {
- if (h != null)
- {
- ResolveStatement(h, true, method);
- }
+ e0 = e1;
+ }
+ foreach (var h in s.Hints)
+ {
+ if (h != null) {
+ ResolveStatement(h, true, method);
}
+ }
+ s.Result = new BinaryExpr(s.Tok, BinaryExpr.Opcode.Eq, s.Terms.First(), s.Terms.Last());
+ ResolveExpression(s.Result, true);
} else if (stmt is MatchStmt) {
MatchStmt s = (MatchStmt)stmt;
diff --git a/Dafny/Translator.cs b/Dafny/Translator.cs index a090515e..31e39af2 100644 --- a/Dafny/Translator.cs +++ b/Dafny/Translator.cs @@ -7,6 +7,7 @@ using System; using System.Collections.Generic;
using System.Numerics;
using System.Diagnostics.Contracts;
+using System.Linq;
using Bpl = Microsoft.Boogie;
using System.Text;
using Microsoft.Boogie;
@@ -3983,6 +3984,52 @@ namespace Microsoft.Dafny { Contract.Assert(false); // unexpected kind
}
+ } else if (stmt is CalcStmt) {
+ /* Translate into:
+ if (*) {
+ hint0;
+ assert t0 op t1;
+ assume false;
+ } else if ...
+ } else {
+ hint<n-1>;
+ assert t<n-1> op tn;
+ assume false;
+ }
+ assume t0 op tn;
+ */
+ var s = (CalcStmt)stmt;
+ AddComment(builder, stmt, "calc statement");
+ // NadiaTodo: check well-formedness of steps
+ if (s.Steps.Count > 0) {
+ Bpl.IfCmd ifCmd = null;
+ Bpl.StmtList els = null;
+
+ for (int i = s.Steps.Count; 0 <= --i; ) {
+ var b = new Bpl.StmtListBuilder();
+ var h = s.Hints[i];
+ if (h != null) {
+ TrStmt(h, b, locals, etran);
+ }
+ // NadiaTodo: add error messages
+ b.Add(new Bpl.AssertCmd(s.Tok, etran.TrExpr(s.Steps[i])));
+ b.Add(new Bpl.AssumeCmd(s.Tok, Bpl.Expr.False));
+ if (i == s.Steps.Count - 1) {
+ // first iteration (last step)
+ els = b.Collect(s.Tok);
+ } else {
+ ifCmd = new Bpl.IfCmd(s.Tok, null, b.Collect(s.Tok), ifCmd, els);
+ els = null;
+ }
+ }
+ if (ifCmd == null) {
+ // single step: generate an if without else parts
+ ifCmd = new Bpl.IfCmd(s.Tok, null, els, null, null);
+ }
+ builder.Add(ifCmd);
+ builder.Add(new Bpl.AssumeCmd(s.Tok, etran.TrExpr(s.Result)));
+ }
+
} else if (stmt is MatchStmt) {
var s = (MatchStmt)stmt;
TrStmt_CheckWellformed(s.Source, builder, locals, etran, true);
|