From 8af0f2d97ab5ca1a212c7f4901c43059ccb08e36 Mon Sep 17 00:00:00 2001 From: Rustan Leino Date: Fri, 2 Aug 2013 21:44:37 -0700 Subject: Introduced keywords "lemma" (like a "ghost method", but not allowed to have a "modifies" clause) and "colemma" (synonymous with "comethod"; perhaps "comethod" will go away at some point) --- Source/Dafny/Cloner.cs | 3 + Source/Dafny/Dafny.atg | 14 +- Source/Dafny/DafnyAst.cs | 15 + Source/Dafny/Parser.cs | 1117 +++++++++++++++--------------- Source/Dafny/Printer.cs | 4 +- Source/Dafny/RefinementTransformer.cs | 3 + Source/Dafny/Resolver.cs | 7 +- Source/Dafny/Scanner.cs | 174 ++--- Source/DafnyExtension/OutliningTagger.cs | 1 + Source/DafnyExtension/TokenTagger.cs | 2 + Test/dafny0/Answer | 13 +- Test/dafny0/Corecursion.dfy | 2 +- Test/dafny0/ResolutionErrors.dfy | 11 + Test/dafny0/Simple.dfy | 10 + Util/Emacs/dafny-mode.el | 2 +- Util/latex/dafny.sty | 2 +- Util/vim/dafny.vim | 2 +- 17 files changed, 736 insertions(+), 646 deletions(-) diff --git a/Source/Dafny/Cloner.cs b/Source/Dafny/Cloner.cs index f4b0cfaf..5a38fb2d 100644 --- a/Source/Dafny/Cloner.cs +++ b/Source/Dafny/Cloner.cs @@ -549,6 +549,9 @@ namespace Microsoft.Dafny } else if (m is CoMethod) { return new CoMethod(Tok(m.tok), m.Name, m.IsStatic, tps, ins, m.Outs.ConvertAll(CloneFormal), req, mod, ens, decreases, body, CloneAttributes(m.Attributes), false); + } else if (m is Lemma) { + return new Lemma(Tok(m.tok), m.Name, m.IsStatic, tps, ins, m.Outs.ConvertAll(CloneFormal), + req, mod, ens, decreases, body, CloneAttributes(m.Attributes), false); } else { return new Method(Tok(m.tok), m.Name, m.IsStatic, m.IsGhost, tps, ins, m.Outs.ConvertAll(CloneFormal), req, mod, ens, decreases, body, CloneAttributes(m.Attributes), false); diff --git a/Source/Dafny/Dafny.atg b/Source/Dafny/Dafny.atg index 778e2f72..a66286b5 100644 --- a/Source/Dafny/Dafny.atg +++ b/Source/Dafny/Dafny.atg @@ -527,6 +527,7 @@ MethodDecl Attributes decAttrs = null; Attributes modAttrs = null; BlockStmt body = null; + bool isLemma = false; bool isConstructor = false; bool isCoMethod = false; bool signatureOmitted = false; @@ -535,7 +536,9 @@ MethodDecl .) SYNC ( "method" + | "lemma" (. isLemma = true; .) | "comethod" (. isCoMethod = true; .) + | "colemma" (. isCoMethod = true; .) | "constructor" (. if (allowConstructor) { isConstructor = true; } else { @@ -543,7 +546,11 @@ MethodDecl } .) ) (. keywordToken = t; .) - (. if (isConstructor) { + (. if (isLemma) { + if (mmod.IsGhost) { + SemErr(t, "lemmas cannot be declared 'ghost' (they are automatically 'ghost')"); + } + } else if (isConstructor) { if (mmod.IsGhost) { SemErr(t, "constructors cannot be declared 'ghost'"); } @@ -552,7 +559,7 @@ MethodDecl } } else if (isCoMethod) { if (mmod.IsGhost) { - SemErr(t, "comethods cannot be declared 'ghost'"); + SemErr(t, "comethods cannot be declared 'ghost' (they are automatically 'ghost')"); } } .) @@ -583,6 +590,9 @@ MethodDecl } else if (isCoMethod) { m = new CoMethod(id, id.val, mmod.IsStatic, typeArgs, ins, outs, req, new Specification(mod, modAttrs), ens, new Specification(dec, decAttrs), body, attrs, signatureOmitted); + } else if (isLemma) { + m = new Lemma(id, id.val, mmod.IsStatic, typeArgs, ins, outs, + req, new Specification(mod, modAttrs), ens, new Specification(dec, decAttrs), body, attrs, signatureOmitted); } else { m = new Method(id, id.val, mmod.IsStatic, mmod.IsGhost, typeArgs, ins, outs, req, new Specification(mod, modAttrs), ens, new Specification(dec, decAttrs), body, attrs, signatureOmitted); diff --git a/Source/Dafny/DafnyAst.cs b/Source/Dafny/DafnyAst.cs index 488d1821..21435f76 100644 --- a/Source/Dafny/DafnyAst.cs +++ b/Source/Dafny/DafnyAst.cs @@ -2001,6 +2001,21 @@ namespace Microsoft.Dafny { bool ICodeContext.MustReverify { get { return this.MustReverify; } } } + public class Lemma : Method + { + public Lemma(IToken tok, string name, + bool isStatic, + [Captured] List/*!*/ typeArgs, + [Captured] List/*!*/ ins, [Captured] List/*!*/ outs, + [Captured] List/*!*/ req, [Captured] Specification/*!*/ mod, + [Captured] List/*!*/ ens, + [Captured] Specification/*!*/ decreases, + [Captured] BlockStmt body, + Attributes attributes, bool signatureOmitted) + : base(tok, name, isStatic, true, typeArgs, ins, outs, req, mod, ens, decreases, body, attributes, signatureOmitted) { + } + } + public class Constructor : Method { public Constructor(IToken tok, string name, diff --git a/Source/Dafny/Parser.cs b/Source/Dafny/Parser.cs index 05de87b6..547bc987 100644 --- a/Source/Dafny/Parser.cs +++ b/Source/Dafny/Parser.cs @@ -25,7 +25,7 @@ public class Parser { public const int _openparen = 9; public const int _star = 10; public const int _notIn = 11; - public const int maxT = 120; + public const int maxT = 122; const bool T = true; const bool x = false; @@ -248,7 +248,7 @@ bool IsParenStar() { defaultModule.TopLevelDecls.Add(iter); break; } - case 23: case 24: case 28: case 39: case 40: case 41: case 57: case 58: case 59: { + case 23: case 24: case 28: case 39: case 40: case 41: case 42: case 43: case 59: case 60: case 61: { ClassMemberDecl(membersDefaultClass, false); break; } @@ -324,7 +324,7 @@ bool IsParenStar() { module.TopLevelDecls.Add(iter); break; } - case 23: case 24: case 28: case 39: case 40: case 41: case 57: case 58: case 59: { + case 23: case 24: case 28: case 39: case 40: case 41: case 42: case 43: case 59: case 60: case 61: { ClassMemberDecl(namedModuleDefaultClassMembers, false); break; } @@ -357,7 +357,7 @@ bool IsParenStar() { } } if (la.kind == 20) { - while (!(la.kind == 0 || la.kind == 20)) {SynErr(121); Get();} + while (!(la.kind == 0 || la.kind == 20)) {SynErr(123); Get();} Get(); } if (submodule == null) { @@ -366,7 +366,7 @@ bool IsParenStar() { submodule = new AliasModuleDecl(idPath, id, parent, opened); } - } else SynErr(122); + } else SynErr(124); } void ClassDecl(ModuleDefinition/*!*/ module, out ClassDecl/*!*/ c) { @@ -378,7 +378,7 @@ bool IsParenStar() { List members = new List(); IToken bodyStart; - while (!(la.kind == 0 || la.kind == 22)) {SynErr(123); Get();} + while (!(la.kind == 0 || la.kind == 22)) {SynErr(125); Get();} Expect(22); while (la.kind == 7) { Attribute(ref attrs); @@ -409,13 +409,13 @@ bool IsParenStar() { IToken bodyStart = Token.NoToken; // dummy assignment bool co = false; - while (!(la.kind == 0 || la.kind == 25 || la.kind == 26)) {SynErr(124); Get();} + while (!(la.kind == 0 || la.kind == 25 || la.kind == 26)) {SynErr(126); Get();} if (la.kind == 25) { Get(); } else if (la.kind == 26) { Get(); co = true; - } else SynErr(125); + } else SynErr(127); while (la.kind == 7) { Attribute(ref attrs); } @@ -431,7 +431,7 @@ bool IsParenStar() { DatatypeMemberDecl(ctors); } if (la.kind == 20) { - while (!(la.kind == 0 || la.kind == 20)) {SynErr(126); Get();} + while (!(la.kind == 0 || la.kind == 20)) {SynErr(128); Get();} Get(); } if (co) { @@ -462,7 +462,7 @@ bool IsParenStar() { } at = new ArbitraryTypeDecl(id, id.val, module, eqSupport, attrs); if (la.kind == 20) { - while (!(la.kind == 0 || la.kind == 20)) {SynErr(127); Get();} + while (!(la.kind == 0 || la.kind == 20)) {SynErr(129); Get();} Get(); } } @@ -491,7 +491,7 @@ bool IsParenStar() { IToken bodyStart = Token.NoToken; IToken bodyEnd = Token.NoToken; - while (!(la.kind == 0 || la.kind == 33)) {SynErr(128); Get();} + while (!(la.kind == 0 || la.kind == 33)) {SynErr(130); Get();} Expect(33); while (la.kind == 7) { Attribute(ref attrs); @@ -514,7 +514,7 @@ bool IsParenStar() { } else if (la.kind == 36) { Get(); signatureOmitted = true; openParen = Token.NoToken; - } else SynErr(129); + } else SynErr(131); while (StartOf(3)) { IteratorSpec(reads, mod, decreases, req, ens, yieldReq, yieldEns, ref readsAttrs, ref modAttrs, ref decrAttrs); } @@ -549,13 +549,13 @@ bool IsParenStar() { } if (la.kind == 28) { FieldDecl(mmod, mm); - } else if (la.kind == 57 || la.kind == 58 || la.kind == 59) { + } else if (la.kind == 59 || la.kind == 60 || la.kind == 61) { FunctionDecl(mmod, out f); mm.Add(f); - } else if (la.kind == 39 || la.kind == 40 || la.kind == 41) { + } else if (StartOf(4)) { MethodDecl(mmod, allowConstructors, out m); mm.Add(m); - } else SynErr(130); + } else SynErr(132); } void Attribute(ref Attributes attrs) { @@ -599,7 +599,7 @@ bool IsParenStar() { } else if (la.kind == 2) { Get(); x = t; - } else SynErr(131); + } else SynErr(133); } void GenericParameters(List/*!*/ typeArgs) { @@ -637,7 +637,7 @@ bool IsParenStar() { Attributes attrs = null; IToken/*!*/ id; Type/*!*/ ty; - while (!(la.kind == 0 || la.kind == 28)) {SynErr(132); Get();} + while (!(la.kind == 0 || la.kind == 28)) {SynErr(134); Get();} Expect(28); if (mmod.IsStatic) { SemErr(t, "fields cannot be declared 'static'"); } @@ -651,7 +651,7 @@ bool IsParenStar() { FIdentType(out id, out ty); mm.Add(new Field(id, id.val, mmod.IsGhost, ty, attrs)); } - while (!(la.kind == 0 || la.kind == 20)) {SynErr(133); Get();} + while (!(la.kind == 0 || la.kind == 20)) {SynErr(135); Get();} Expect(20); } @@ -674,7 +674,7 @@ bool IsParenStar() { IToken bodyEnd = Token.NoToken; bool signatureOmitted = false; - if (la.kind == 57) { + if (la.kind == 59) { Get(); if (la.kind == 39) { Get(); @@ -697,8 +697,8 @@ bool IsParenStar() { Get(); signatureOmitted = true; openParen = Token.NoToken; - } else SynErr(134); - } else if (la.kind == 58) { + } else SynErr(136); + } else if (la.kind == 60) { Get(); isPredicate = true; if (la.kind == 39) { @@ -711,7 +711,7 @@ bool IsParenStar() { Attribute(ref attrs); } NoUSIdent(out id); - if (StartOf(4)) { + if (StartOf(5)) { if (la.kind == 37) { GenericParameters(typeArgs); } @@ -726,8 +726,8 @@ bool IsParenStar() { Get(); signatureOmitted = true; openParen = Token.NoToken; - } else SynErr(135); - } else if (la.kind == 59) { + } else SynErr(137); + } else if (la.kind == 61) { Get(); isCoPredicate = true; if (mmod.IsGhost) { SemErr(t, "copredicates cannot be declared 'ghost' (they are ghost by default)"); } @@ -736,7 +736,7 @@ bool IsParenStar() { Attribute(ref attrs); } NoUSIdent(out id); - if (StartOf(4)) { + if (StartOf(5)) { if (la.kind == 37) { GenericParameters(typeArgs); } @@ -751,10 +751,10 @@ bool IsParenStar() { Get(); signatureOmitted = true; openParen = Token.NoToken; - } else SynErr(136); - } else SynErr(137); + } else SynErr(138); + } else SynErr(139); decreases = isCoPredicate ? null : new List(); - while (StartOf(5)) { + while (StartOf(6)) { FunctionSpec(reqs, reads, ens, decreases); } if (la.kind == 7) { @@ -791,19 +791,26 @@ bool IsParenStar() { Attributes decAttrs = null; Attributes modAttrs = null; BlockStmt body = null; + bool isLemma = false; bool isConstructor = false; bool isCoMethod = false; bool signatureOmitted = false; IToken bodyStart = Token.NoToken; IToken bodyEnd = Token.NoToken; - while (!(StartOf(6))) {SynErr(138); Get();} + while (!(StartOf(7))) {SynErr(140); Get();} if (la.kind == 39) { Get(); } else if (la.kind == 40) { Get(); - isCoMethod = true; + isLemma = true; } else if (la.kind == 41) { + Get(); + isCoMethod = true; + } else if (la.kind == 42) { + Get(); + isCoMethod = true; + } else if (la.kind == 43) { Get(); if (allowConstructor) { isConstructor = true; @@ -811,9 +818,13 @@ bool IsParenStar() { SemErr(t, "constructors are only allowed in classes"); } - } else SynErr(139); + } else SynErr(141); keywordToken = t; - if (isConstructor) { + if (isLemma) { + if (mmod.IsGhost) { + SemErr(t, "lemmas cannot be declared 'ghost' (they are automatically 'ghost')"); + } + } else if (isConstructor) { if (mmod.IsGhost) { SemErr(t, "constructors cannot be declared 'ghost'"); } @@ -822,7 +833,7 @@ bool IsParenStar() { } } else if (isCoMethod) { if (mmod.IsGhost) { - SemErr(t, "comethods cannot be declared 'ghost'"); + SemErr(t, "comethods cannot be declared 'ghost' (they are automatically 'ghost')"); } } @@ -853,8 +864,8 @@ bool IsParenStar() { } else if (la.kind == 36) { Get(); signatureOmitted = true; openParen = Token.NoToken; - } else SynErr(140); - while (StartOf(7)) { + } else SynErr(142); + while (StartOf(8)) { MethodSpec(req, mod, ens, dec, ref decAttrs, ref modAttrs); } if (la.kind == 7) { @@ -866,6 +877,9 @@ bool IsParenStar() { } else if (isCoMethod) { m = new CoMethod(id, id.val, mmod.IsStatic, typeArgs, ins, outs, req, new Specification(mod, modAttrs), ens, new Specification(dec, decAttrs), body, attrs, signatureOmitted); + } else if (isLemma) { + m = new Lemma(id, id.val, mmod.IsStatic, typeArgs, ins, outs, + req, new Specification(mod, modAttrs), ens, new Specification(dec, decAttrs), body, attrs, signatureOmitted); } else { m = new Method(id, id.val, mmod.IsStatic, mmod.IsGhost, typeArgs, ins, outs, req, new Specification(mod, modAttrs), ens, new Specification(dec, decAttrs), body, attrs, signatureOmitted); @@ -894,7 +908,7 @@ bool IsParenStar() { void FormalsOptionalIds(List/*!*/ formals) { Contract.Requires(cce.NonNullElements(formals)); IToken/*!*/ id; Type/*!*/ ty; string/*!*/ name; bool isGhost; Expect(9); - if (StartOf(8)) { + if (StartOf(9)) { TypeIdentOptional(out id, out name, out ty, out isGhost); formals.Add(new Formal(id, name, ty, true, isGhost)); while (la.kind == 29) { @@ -915,7 +929,7 @@ bool IsParenStar() { } else if (la.kind == 2) { Get(); id = t; - } else SynErr(141); + } else SynErr(143); Expect(6); Type(out ty); } @@ -990,7 +1004,7 @@ bool IsParenStar() { Get(); isGhost = true; } - if (StartOf(9)) { + if (StartOf(10)) { TypeAndToken(out id, out ty); if (la.kind == 6) { Get(); @@ -1008,7 +1022,7 @@ bool IsParenStar() { id = t; name = id.val; Expect(6); Type(out ty); - } else SynErr(142); + } else SynErr(144); if (name != null) { identName = name; } else { @@ -1022,22 +1036,22 @@ bool IsParenStar() { List/*!*/ gt; switch (la.kind) { - case 49: { + case 51: { Get(); tok = t; break; } - case 50: { + case 52: { Get(); tok = t; ty = new NatType(); break; } - case 51: { + case 53: { Get(); tok = t; ty = new IntType(); break; } - case 52: { + case 54: { Get(); tok = t; gt = new List(); GenericInstantiation(gt); @@ -1048,7 +1062,7 @@ bool IsParenStar() { break; } - case 53: { + case 55: { Get(); tok = t; gt = new List(); GenericInstantiation(gt); @@ -1059,7 +1073,7 @@ bool IsParenStar() { break; } - case 54: { + case 56: { Get(); tok = t; gt = new List(); GenericInstantiation(gt); @@ -1070,7 +1084,7 @@ bool IsParenStar() { break; } - case 55: { + case 57: { Get(); tok = t; gt = new List(); GenericInstantiation(gt); @@ -1081,11 +1095,11 @@ bool IsParenStar() { break; } - case 1: case 4: case 56: { + case 1: case 4: case 58: { ReferenceType(out tok, out ty); break; } - default: SynErr(143); break; + default: SynErr(145); break; } } @@ -1111,13 +1125,13 @@ List/*!*/ yieldReq, List/*!* ref Attributes readsAttrs, ref Attributes modAttrs, ref Attributes decrAttrs) { Expression/*!*/ e; FrameExpression/*!*/ fe; bool isFree = false; bool isYield = false; Attributes ensAttrs = null; - while (!(StartOf(10))) {SynErr(144); Get();} - if (la.kind == 47) { + while (!(StartOf(11))) {SynErr(146); Get();} + if (la.kind == 49) { Get(); while (IsAttribute()) { Attribute(ref readsAttrs); } - if (StartOf(11)) { + if (StartOf(12)) { FrameExpression(out fe); reads.Add(fe); while (la.kind == 29) { @@ -1126,14 +1140,14 @@ ref Attributes readsAttrs, ref Attributes modAttrs, ref Attributes decrAttrs) { reads.Add(fe); } } - while (!(la.kind == 0 || la.kind == 20)) {SynErr(145); Get();} + while (!(la.kind == 0 || la.kind == 20)) {SynErr(147); Get();} Expect(20); - } else if (la.kind == 42) { + } else if (la.kind == 44) { Get(); while (IsAttribute()) { Attribute(ref modAttrs); } - if (StartOf(11)) { + if (StartOf(12)) { FrameExpression(out fe); mod.Add(fe); while (la.kind == 29) { @@ -1142,21 +1156,21 @@ ref Attributes readsAttrs, ref Attributes modAttrs, ref Attributes decrAttrs) { mod.Add(fe); } } - while (!(la.kind == 0 || la.kind == 20)) {SynErr(146); Get();} + while (!(la.kind == 0 || la.kind == 20)) {SynErr(148); Get();} Expect(20); - } else if (StartOf(12)) { - if (la.kind == 43) { + } else if (StartOf(13)) { + if (la.kind == 45) { Get(); isFree = true; } - if (la.kind == 48) { + if (la.kind == 50) { Get(); isYield = true; } - if (la.kind == 44) { + if (la.kind == 46) { Get(); Expression(out e); - while (!(la.kind == 0 || la.kind == 20)) {SynErr(147); Get();} + while (!(la.kind == 0 || la.kind == 20)) {SynErr(149); Get();} Expect(20); if (isYield) { yieldReq.Add(new MaybeFreeExpression(e, isFree)); @@ -1164,13 +1178,13 @@ ref Attributes readsAttrs, ref Attributes modAttrs, ref Attributes decrAttrs) { req.Add(new MaybeFreeExpression(e, isFree)); } - } else if (la.kind == 45) { + } else if (la.kind == 47) { Get(); while (IsAttribute()) { Attribute(ref ensAttrs); } Expression(out e); - while (!(la.kind == 0 || la.kind == 20)) {SynErr(148); Get();} + while (!(la.kind == 0 || la.kind == 20)) {SynErr(150); Get();} Expect(20); if (isYield) { yieldEns.Add(new MaybeFreeExpression(e, isFree, ensAttrs)); @@ -1178,16 +1192,16 @@ ref Attributes readsAttrs, ref Attributes modAttrs, ref Attributes decrAttrs) { ens.Add(new MaybeFreeExpression(e, isFree, ensAttrs)); } - } else SynErr(149); - } else if (la.kind == 46) { + } else SynErr(151); + } else if (la.kind == 48) { Get(); while (IsAttribute()) { Attribute(ref decrAttrs); } DecreasesList(decreases, false); - while (!(la.kind == 0 || la.kind == 20)) {SynErr(150); Get();} + while (!(la.kind == 0 || la.kind == 20)) {SynErr(152); Get();} Expect(20); - } else SynErr(151); + } else SynErr(153); } void BlockStmt(out BlockStmt/*!*/ block, out IToken bodyStart, out IToken bodyEnd) { @@ -1196,7 +1210,7 @@ ref Attributes readsAttrs, ref Attributes modAttrs, ref Attributes decrAttrs) { Expect(7); bodyStart = t; - while (StartOf(13)) { + while (StartOf(14)) { Stmt(body); } Expect(8); @@ -1209,13 +1223,13 @@ List/*!*/ 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(14))) {SynErr(152); Get();} - if (la.kind == 42) { + while (!(StartOf(15))) {SynErr(154); Get();} + if (la.kind == 44) { Get(); while (IsAttribute()) { Attribute(ref modAttrs); } - if (StartOf(11)) { + if (StartOf(12)) { FrameExpression(out fe); mod.Add(fe); while (la.kind == 29) { @@ -1224,38 +1238,38 @@ List/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo mod.Add(fe); } } - while (!(la.kind == 0 || la.kind == 20)) {SynErr(153); Get();} + while (!(la.kind == 0 || la.kind == 20)) {SynErr(155); Get();} Expect(20); - } else if (la.kind == 43 || la.kind == 44 || la.kind == 45) { - if (la.kind == 43) { + } else if (la.kind == 45 || la.kind == 46 || la.kind == 47) { + if (la.kind == 45) { Get(); isFree = true; } - if (la.kind == 44) { + if (la.kind == 46) { Get(); Expression(out e); - while (!(la.kind == 0 || la.kind == 20)) {SynErr(154); Get();} + while (!(la.kind == 0 || la.kind == 20)) {SynErr(156); Get();} Expect(20); req.Add(new MaybeFreeExpression(e, isFree)); - } else if (la.kind == 45) { + } else if (la.kind == 47) { Get(); while (IsAttribute()) { Attribute(ref ensAttrs); } Expression(out e); - while (!(la.kind == 0 || la.kind == 20)) {SynErr(155); Get();} + while (!(la.kind == 0 || la.kind == 20)) {SynErr(157); Get();} Expect(20); ens.Add(new MaybeFreeExpression(e, isFree, ensAttrs)); - } else SynErr(156); - } else if (la.kind == 46) { + } else SynErr(158); + } else if (la.kind == 48) { Get(); while (IsAttribute()) { Attribute(ref decAttrs); } DecreasesList(decreases, true); - while (!(la.kind == 0 || la.kind == 20)) {SynErr(157); Get();} + while (!(la.kind == 0 || la.kind == 20)) {SynErr(159); Get();} Expect(20); - } else SynErr(158); + } else SynErr(160); } void FrameExpression(out FrameExpression/*!*/ fe) { @@ -1265,21 +1279,21 @@ List/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo string fieldName = null; IToken feTok = null; fe = null; - if (StartOf(15)) { + if (StartOf(16)) { Expression(out e); feTok = e.tok; - if (la.kind == 60) { + if (la.kind == 62) { Get(); Ident(out id); fieldName = id.val; feTok = id; } fe = new FrameExpression(feTok, e, fieldName); - } else if (la.kind == 60) { + } else if (la.kind == 62) { Get(); Ident(out id); fieldName = id.val; fe = new FrameExpression(id, new ImplicitThisExpr(id), fieldName); - } else SynErr(159); + } else SynErr(161); } void Expression(out Expression/*!*/ e) { @@ -1326,7 +1340,7 @@ List/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo List/*!*/ gt; List path; - if (la.kind == 56) { + if (la.kind == 58) { Get(); tok = t; ty = new ObjectType(); } else if (la.kind == 4) { @@ -1355,7 +1369,7 @@ List/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo GenericInstantiation(gt); } ty = new UserDefinedType(tok, tok.val, gt, path); - } else SynErr(160); + } else SynErr(162); } void FunctionSpec(List/*!*/ reqs, List/*!*/ reads, List/*!*/ ens, List decreases) { @@ -1363,16 +1377,16 @@ List/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo Contract.Requires(cce.NonNullElements(reads)); Contract.Requires(decreases == null || cce.NonNullElements(decreases)); Expression/*!*/ e; FrameExpression/*!*/ fe; - if (la.kind == 44) { - while (!(la.kind == 0 || la.kind == 44)) {SynErr(161); Get();} + if (la.kind == 46) { + while (!(la.kind == 0 || la.kind == 46)) {SynErr(163); Get();} Get(); Expression(out e); - while (!(la.kind == 0 || la.kind == 20)) {SynErr(162); Get();} + while (!(la.kind == 0 || la.kind == 20)) {SynErr(164); Get();} Expect(20); reqs.Add(e); - } else if (la.kind == 47) { + } else if (la.kind == 49) { Get(); - if (StartOf(16)) { + if (StartOf(17)) { PossiblyWildFrameExpression(out fe); reads.Add(fe); while (la.kind == 29) { @@ -1381,15 +1395,15 @@ List/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo reads.Add(fe); } } - while (!(la.kind == 0 || la.kind == 20)) {SynErr(163); Get();} + while (!(la.kind == 0 || la.kind == 20)) {SynErr(165); Get();} Expect(20); - } else if (la.kind == 45) { + } else if (la.kind == 47) { Get(); Expression(out e); - while (!(la.kind == 0 || la.kind == 20)) {SynErr(164); Get();} + while (!(la.kind == 0 || la.kind == 20)) {SynErr(166); Get();} Expect(20); ens.Add(e); - } else if (la.kind == 46) { + } else if (la.kind == 48) { Get(); if (decreases == null) { SemErr(t, "'decreases' clauses are meaningless for copredicates, so they are not allowed"); @@ -1397,9 +1411,9 @@ List/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo } DecreasesList(decreases, false); - while (!(la.kind == 0 || la.kind == 20)) {SynErr(165); Get();} + while (!(la.kind == 0 || la.kind == 20)) {SynErr(167); Get();} Expect(20); - } else SynErr(166); + } else SynErr(168); } void FunctionBody(out Expression/*!*/ e, out IToken bodyStart, out IToken bodyEnd) { @@ -1416,9 +1430,9 @@ List/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo if (la.kind == 10) { Get(); fe = new FrameExpression(t, new WildcardExpr(t), null); - } else if (StartOf(11)) { + } else if (StartOf(12)) { FrameExpression(out fe); - } else SynErr(167); + } else SynErr(169); } void PossiblyWildExpression(out Expression/*!*/ e) { @@ -1427,9 +1441,9 @@ List/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo if (la.kind == 10) { Get(); e = new WildcardExpr(t); - } else if (StartOf(15)) { + } else if (StartOf(16)) { Expression(out e); - } else SynErr(168); + } else SynErr(170); } void Stmt(List/*!*/ ss) { @@ -1446,26 +1460,26 @@ List/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo IToken bodyStart, bodyEnd; int breakCount; - while (!(StartOf(17))) {SynErr(169); Get();} + while (!(StartOf(18))) {SynErr(171); Get();} switch (la.kind) { case 7: { BlockStmt(out bs, out bodyStart, out bodyEnd); s = bs; break; } - case 78: { + case 80: { AssertStmt(out s); break; } - case 67: { + case 69: { AssumeStmt(out s); break; } - case 79: { + case 81: { PrintStmt(out s); break; } - case 1: case 2: case 3: case 9: case 27: case 107: case 108: case 109: case 110: case 111: case 112: { + case 1: case 2: case 3: case 9: case 27: case 109: case 110: case 111: case 112: case 113: case 114: { UpdateStmt(out s); break; } @@ -1473,27 +1487,27 @@ List/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo VarDeclStatement(out s); break; } - case 71: { + case 73: { IfStmt(out s); break; } - case 75: { + case 77: { WhileStmt(out s); break; } - case 77: { + case 79: { MatchStmt(out s); break; } - case 80: case 81: { + case 82: case 83: { ForallStmt(out s); break; } - case 82: { + case 84: { CalcStmt(out s); break; } - case 61: { + case 63: { Get(); x = t; NoUSIdent(out id); @@ -1502,24 +1516,24 @@ List/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo s.Labels = new LList