diff options
author | Rustan Leino <leino@microsoft.com> | 2011-05-25 22:14:28 -0700 |
---|---|---|
committer | Rustan Leino <leino@microsoft.com> | 2011-05-25 22:14:28 -0700 |
commit | daba6b774c3f945de58229f28078e8dccaaec782 (patch) | |
tree | 944cb474649574039164c4736bc3e705e6181fd4 /Source | |
parent | f7877ab8f223dcf3ea37ddc8a0b588316eb451a5 (diff) |
Dafny: cleaned up parser, moved foreach statement from AssignStmt<> parsing to UpdateStmt, automatically infer ghosts when local variables are introduced with a call RHS
Diffstat (limited to 'Source')
-rw-r--r-- | Source/Dafny/Compiler.cs | 4 | ||||
-rw-r--r-- | Source/Dafny/Dafny.atg | 255 | ||||
-rw-r--r-- | Source/Dafny/DafnyAst.cs | 43 | ||||
-rw-r--r-- | Source/Dafny/Parser.cs | 937 | ||||
-rw-r--r-- | Source/Dafny/Printer.cs | 2 | ||||
-rw-r--r-- | Source/Dafny/Resolver.cs | 45 | ||||
-rw-r--r-- | Source/Dafny/Scanner.cs | 109 | ||||
-rw-r--r-- | Source/Dafny/Translator.cs | 3 |
8 files changed, 433 insertions, 965 deletions
diff --git a/Source/Dafny/Compiler.cs b/Source/Dafny/Compiler.cs index c73b51a1..fdab9ab9 100644 --- a/Source/Dafny/Compiler.cs +++ b/Source/Dafny/Compiler.cs @@ -855,10 +855,6 @@ namespace Microsoft.Dafny { void TrCallStmt(CallStmt s, string receiverReplacement, int indent) {
Contract.Requires(s != null);
- foreach (VarDecl local in s.NewVars) {
- TrVarDecl(local, false, indent);
- }
-
Contract.Assert(s.Method != null); // follows from the fact that stmt has been successfully resolved
Indent(indent);
if (receiverReplacement != null) {
diff --git a/Source/Dafny/Dafny.atg b/Source/Dafny/Dafny.atg index fea29e11..5623f091 100644 --- a/Source/Dafny/Dafny.atg +++ b/Source/Dafny/Dafny.atg @@ -38,22 +38,6 @@ struct MemberModifiers { }
// helper routine for parsing call statements
-private static void RecordCallLhs(IdentifierExpr/*!*/ e,
- List<IdentifierExpr/*!*/>/*!*/ lhs,
- List<AutoVarDecl/*!*/>/*!*/ newVars) {
- Contract.Requires(e != null);
- Contract.Requires(cce.NonNullElements(lhs));
- Contract.Requires(cce.NonNullElements(newVars));
- int index = lhs.Count;
- lhs.Add(e);
- if (parseVarScope.Find(e.Name) == null) {
- AutoVarDecl d = new AutoVarDecl(e.tok, e.Name, new InferredTypeProxy(), index);
- newVars.Add(d);
- parseVarScope.Push(e.Name, e.Name);
- }
-}
-
-// helper routine for parsing call statements
private static Expression/*!*/ ConvertToLocal(Expression/*!*/ e)
{
Contract.Requires(e != null);
@@ -733,11 +717,9 @@ BlockStmt<out Statement/*!*/ block, out IToken bodyStart, out IToken bodyEnd> .
Stmt<.List<Statement/*!*/>/*!*/ ss.>
-= (. Contract.Requires(cce.NonNullElements(ss)); Statement/*!*/ s;
+= (. Statement/*!*/ s;
.)
- ( OneStmt<out s> (. ss.Add(s); .)
- | VarDeclStmts<ss>
- )
+ OneStmt<out s> (. ss.Add(s); .)
.
OneStmt<out Statement/*!*/ s>
@@ -751,9 +733,7 @@ OneStmt<out Statement/*!*/ s> | AssumeStmt<out s>
| UseStmt<out s>
| PrintStmt<out s>
-/* | AssignStmt<out s, true> */
| HavocStmt<out s>
- | CallStmt<out s>
| "call" UpdateStmt<out s>
| IfStmt<out s>
| WhileStmt<out s>
@@ -810,7 +790,7 @@ Rhs<out DeterminedAssignmentRhs r, Expression receiverForInitCall> | "." Ident<out x>
"(" (. args = new List<Expression/*!*/>(); .)
[ Expressions<args> ]
- ")" (. initCall = new CallStmt(x, new List<AutoVarDecl>(), new List<IdentifierExpr>(),
+ ")" (. initCall = new CallStmt(x, new List<IdentifierExpr>(),
receiverForInitCall, x.val, args); .)
]
(. if (ee != null) {
@@ -828,68 +808,6 @@ Rhs<out DeterminedAssignmentRhs r, Expression receiverForInitCall> )
.
-AssignStmt<out Statement/*!*/ s, bool allowChoose>
-= (. Contract.Ensures(Contract.ValueAtReturn(out s) != null);
- IToken/*!*/ x, rhsTok;
- Expression/*!*/ lhs;
- List<Expression> rhs;
- Type ty;
- s = dummyStmt;
- CallStmt initCall = null;
- .)
- LhsExpr<out lhs>
- ":=" (. x = t; .)
- AssignRhs<out rhsTok, out rhs, out ty, out initCall, lhs>
- (. if (ty == null) {
- Contract.Assert(rhs != null);
- Contract.Assert(rhs.Count == 1);
- s = new AssignStmt(x, lhs, new ExprRhs(rhs[0]));
- if (!allowChoose) {
- var r = rhs[0] as UnaryExpr;
- if (r != null && r.Op == UnaryExpr.Opcode.SetChoose) {
- SemErr("choose operator not allowed as RHS in foreach assignment");
- }
- }
- } else if (rhs == null) {
- s = new AssignStmt(x, lhs, new TypeRhs(rhsTok, ty, initCall));
- } else {
- s = new AssignStmt(x, lhs, new TypeRhs(rhsTok, ty, rhs));
- }
- .)
- ";"
- .
-
-AssignRhs<.out IToken tok, out List<Expression> ee, out Type ty, out CallStmt initCall, Expression receiverForInitCall.>
-/* ensures ee != null || ty != null; */
-/* ensures ee != null ==> 1 <= ee.Count; */
-/* ensures ty == null ==> 1 == ee.Count; */
-= (. IToken/*!*/ x; Expression/*!*/ e;
- ee = null; ty = null;
- initCall = null;
- List<Expression> args;
- tok = Token.NoToken; // to please compiler
- .)
- ( "new" (. tok = t; .)
- TypeAndToken<out x, out ty>
- [ "[" (. ee = new List<Expression>(); .)
- Expressions<ee>
- "]" (. // make sure an array class with this dimensionality exists
- UserDefinedType tmp = theBuiltIns.ArrayType(x, ee.Count, new IntType(), true);
- .)
- | "." Ident<out x>
- "(" (. args = new List<Expression/*!*/>(); .)
- [ Expressions<args> ]
- ")" (. initCall = new CallStmt(x, new List<AutoVarDecl>(), new List<IdentifierExpr>(),
- receiverForInitCall, x.val, args); .)
- ]
- | "choose" (. x = t; tok = t; .)
- Expression<out e> (. e = new UnaryExpr(x, UnaryExpr.Opcode.SetChoose, e);
- ee = new List<Expression>() { e };
- .)
- | Expression<out e> (. tok = e.tok; ee = new List<Expression>() { e }; .)
- ) (. if (ee == null && ty == null) { ee = new List<Expression>() { dummyExpr}; } .)
- .
-
VarDeclStatement<.out Statement/*!*/ s.>
= (. IToken x = null, assignTok = null; bool isGhost = false;
VarDecl/*!*/ d;
@@ -916,7 +834,7 @@ VarDeclStatement<.out Statement/*!*/ s.> } else {
var ies = new List<Expression>();
foreach (var lhs in lhss) {
- ies.Add(new IdentifierExpr(lhs.Tok, lhs.Name));
+ ies.Add(new AutoGhostIdentifierExpr(lhs.Tok, lhs.Name));
}
update = new UpdateStmt(assignTok, ies, rhss);
}
@@ -927,56 +845,9 @@ VarDeclStatement<.out Statement/*!*/ s.> HavocStmt<out Statement/*!*/ s>
= (. Contract.Ensures(Contract.ValueAtReturn(out s) != null); IToken/*!*/ x; Expression/*!*/ lhs; .)
"havoc" (. x = t; .)
-/* LhsExpr<out lhs> ";" (. s = new AssignStmt(x, lhs); .)
-*/
Lhs<out lhs> ";" (. s = new AssignStmt(x, lhs); .)
.
-LhsExpr<out Expression/*!*/ e>
-= (.Contract.Ensures(Contract.ValueAtReturn(out e)!=null);.)
- SelectExpression<out e>
- .
-
-VarDeclStmts<.List<Statement/*!*/>/*!*/ ss.>
-= (. Contract.Requires(cce.NonNullElements(ss)); VarDecl/*!*/ d; bool isGhost = false; .)
- [ "ghostXYZXYZ" (. isGhost = true; .)
- ]
- "varXYZXYZ"
- IdentTypeRhs<out d, isGhost> (. ss.Add(d); parseVarScope.Push(d.Name, d.Name); .)
- { "," IdentTypeRhs<out d, isGhost> (. ss.Add(d); parseVarScope.Push(d.Name, d.Name); .)
- }
- ";"
- .
-
-IdentTypeRhs<out VarDecl/*!*/ d, bool isGhost>
-= (. Contract.Ensures(Contract.ValueAtReturn(out d) != null);
- IToken/*!*/ id, rhsTok = null; Type/*!*/ ty;
- List<Expression> rhs = null; Type newType = null;
- Type optionalType = null; DeterminedAssignmentRhs optionalRhs = null;
- CallStmt initCall = null;
- .)
- Ident<out id>
- [ ":" Type<out ty> (. optionalType = ty; .)
- ]
- [ ":="
- AssignRhs<out rhsTok, out rhs, out newType, out initCall, new IdentifierExpr(id, id.val)>
- ]
- (. if (newType == null && rhs != null) {
- Contract.Assert(rhs.Count == 1);
- optionalRhs = new ExprRhs(rhs[0]);
- } else if (newType != null) {
- if (rhs == null) {
- optionalRhs = new TypeRhs(rhsTok, newType, initCall);
- } else {
- optionalRhs = new TypeRhs(rhsTok, newType, rhs);
- }
- } else if (optionalType == null) {
- optionalType = new InferredTypeProxy();
- }
- d = new VarDecl(id, id.val, optionalType, isGhost /*** OLD, optionalRhs ***/);
- .)
- .
-
IfStmt<out Statement/*!*/ ifStmt>
= (. Contract.Ensures(Contract.ValueAtReturn(out ifStmt) != null); IToken/*!*/ x;
Expression guard;
@@ -1109,66 +980,16 @@ CaseStatement<out MatchCaseStmt/*!*/ c> (. parseVarScope.PopMarker(); .)
.
-CallStmt<out Statement/*!*/ s>
-= (. Contract.Ensures(Contract.ValueAtReturn(out s) != null); IToken/*!*/ x, id;
- Expression/*!*/ e;
- List<IdentifierExpr/*!*/> lhs = new List<IdentifierExpr/*!*/>();
- List<AutoVarDecl/*!*/> newVars = new List<AutoVarDecl/*!*/>();
- .)
- "callXYZXYZ" (. x = t; .)
- CallStmtSubExpr<out e>
-
- [ "," /* call a,b,c,... := ... */
- (. e = ConvertToLocal(e);
- if (e is IdentifierExpr) {
- RecordCallLhs((IdentifierExpr)e, lhs, newVars);
- } else if (e is FieldSelectExpr) {
- SemErr(e.tok, "each LHS of call statement must be a variable, not a field");
- } else {
- SemErr(e.tok, "each LHS of call statement must be a variable");
- }
- .)
- Ident<out id> (. RecordCallLhs(new IdentifierExpr(id, id.val), lhs, newVars); .)
- { "," Ident<out id> (. RecordCallLhs(new IdentifierExpr(id, id.val), lhs, newVars); .)
- }
- ":="
- CallStmtSubExpr<out e>
-
- | ":=" /* call a := ... */
- (. e = ConvertToLocal(e);
- if (e is IdentifierExpr) {
- RecordCallLhs((IdentifierExpr)e, lhs, newVars);
- } else if (e is FieldSelectExpr) {
- SemErr(e.tok, "each LHS of call statement must be a variable, not a field");
- } else {
- SemErr(e.tok, "each LHS of call statement must be a variable");
- }
- .)
- CallStmtSubExpr<out e>
- ]
- ";"
-
- /* "e" has now been parsed as one of: IdentifierExpr, FunctionCallExpr, FieldSelectExpr.
- It denotes the RHS, so to be legal it must be a FunctionCallExpr. */
- (. if (e is FunctionCallExpr) {
- FunctionCallExpr fce = (FunctionCallExpr)e;
- s = new CallStmt(x, newVars, lhs, fce.Receiver, fce.Name, fce.Args); // this actually does an ownership transfer of fce.Args
- } else {
- SemErr("RHS of call statement must denote a method invocation");
- s = new CallStmt(x, newVars, lhs, dummyExpr, "dummyMethodName", new List<Expression/*!*/>());
- }
- .)
- .
-
/*------------------------------------------------------------------------*/
ForeachStmt<out Statement/*!*/ s>
-= (. Contract.Ensures(Contract.ValueAtReturn(out s) != null); IToken/*!*/ x, boundVar;
+= (. Contract.Ensures(Contract.ValueAtReturn(out s) != null);
+ IToken/*!*/ x, boundVar;
Type/*!*/ ty;
Expression/*!*/ collection;
Expression/*!*/ range;
List<PredicateStmt/*!*/> bodyPrefix = new List<PredicateStmt/*!*/>();
- AssignStmt bodyAssign = null;
+ Statement bodyAssign = null;
.)
(. parseVarScope.PushMarker(); .)
"foreach" (. x = t;
@@ -1186,8 +1007,8 @@ ForeachStmt<out Statement/*!*/ s> | AssumeStmt<out s> (. if (s is PredicateStmt) { bodyPrefix.Add((PredicateStmt)s); } .)
| UseStmt<out s> (. if (s is PredicateStmt) { bodyPrefix.Add((PredicateStmt)s); } .)
}
- ( AssignStmt<out s, false> (. if (s is AssignStmt) { bodyAssign = (AssignStmt)s; } .)
- | HavocStmt<out s> (. if (s is AssignStmt) { bodyAssign = (AssignStmt)s; } .)
+ ( UpdateStmt<out s> (. bodyAssign = s; .)
+ | HavocStmt<out s> (. bodyAssign = s; .)
)
"}" (. if (bodyAssign != null) {
s = new ForeachStmt(x, new BoundVar(boundVar, boundVar.val, ty), collection, range, bodyPrefix, bodyAssign);
@@ -1414,28 +1235,6 @@ EndlessExpression<out Expression e> /*------------------------------------------------------------------------*/
-/* returns one of:
- -- IdentifierExpr
- -- FunctionCallExpr
- -- FieldSelectExpr
-*/
-CallStmtSubExpr<out Expression/*!*/ e>
-= (. Contract.Ensures(Contract.ValueAtReturn(out e) != null); e = dummyExpr; .)
- ( IdentOrFuncExpression<out e>
- | ObjectExpression<out e>
- SelectOrCallSuffix<ref e>
- )
- { SelectOrCallSuffix<ref e> }
- .
-
-SelectExpression<out Expression/*!*/ e>
-= (. Contract.Ensures(Contract.ValueAtReturn(out e) != null); e = dummyExpr; .)
- ( IdentOrFuncExpression<out e>
- | ObjectExpression<out e>
- )
- { SelectOrCallSuffix<ref e> }
- .
-
DottedIdentifiersAndFunction<out Expression e>
= (. IToken id; IToken openParen = null;
List<Expression> args = null;
@@ -1452,27 +1251,7 @@ DottedIdentifiersAndFunction<out Expression e> (. e = new IdentifierSequence(idents, openParen, args); .)
.
-IdentOrFuncExpression<out Expression/*!*/ e>
-= (. Contract.Ensures(Contract.ValueAtReturn(out e) != null); IToken/*!*/ id; e = dummyExpr; List<Expression/*!*/>/*!*/ args; .)
- Ident<out id>
- [ "(" (. args = new List<Expression/*!*/>(); .)
- [ Expressions<args> ]
- ")" (. e = new FunctionCallExpr(id, id.val, new ImplicitThisExpr(id), args); .)
- ] (. if (e == dummyExpr) {
- if (parseVarScope.Find(id.val) != null) {
- e = new IdentifierExpr(id, id.val);
- } else {
- e = new FieldSelectExpr(id, new ImplicitThisExpr(id), id.val);
- }
- }
- .)
- .
-
Suffix<ref Expression/*!*/ e>
-= SelectOrCallSuffix<ref e>
- .
-
-SelectOrCallSuffix<ref Expression/*!*/ e>
= (. Contract.Requires(e != null); Contract.Ensures(e!=null); IToken/*!*/ id, x; List<Expression/*!*/>/*!*/ args;
Expression e0 = null; Expression e1 = null; Expression/*!*/ ee; bool anyDots = false;
List<Expression> multipleIndices = null;
@@ -1528,22 +1307,6 @@ SelectOrCallSuffix<ref Expression/*!*/ e> )
.
-/* ObjectExpression represents those expressions E that could possibly be used in E.f
- or E(...), except Ident. The expression returned is never an lvalue.
-*/
-ObjectExpression<out Expression/*!*/ e>
-= (. Contract.Ensures(Contract.ValueAtReturn(out e) != null); IToken/*!*/ x; e = dummyExpr; .)
- ( "this" (. e = new ThisExpr(t); .)
- | "old" (. x = t; .)
- "("
- Expression<out e>
- ")" (. e = new OldExpr(x, e); .)
- | "("
- Expression<out e>
- ")"
- )
- .
-
/*------------------------------------------------------------------------*/
QuantifierGuts<out Expression/*!*/ q>
diff --git a/Source/Dafny/DafnyAst.cs b/Source/Dafny/DafnyAst.cs index 47a3198c..8d1143af 100644 --- a/Source/Dafny/DafnyAst.cs +++ b/Source/Dafny/DafnyAst.cs @@ -1573,17 +1573,6 @@ namespace Microsoft.Dafny { return base.IsGhost;
}
}
- }
-
- public class AutoVarDecl : VarDecl {
- public readonly int Index;
- public AutoVarDecl(IToken tok, string name, Type type, int index)
- : base(tok, name, type, false) {
- Contract.Requires(tok != null);
- Contract.Requires(name != null);
- Index = index;
-
- }
/// <summary>
/// This method retrospectively makes the VarDecl a ghost. It is to be used only during resolution.
/// </summary>
@@ -1597,34 +1586,29 @@ namespace Microsoft.Dafny { void ObjectInvariant() {
Contract.Invariant(Receiver != null);
Contract.Invariant(MethodName != null);
- Contract.Invariant(cce.NonNullElements(NewVars));
Contract.Invariant(cce.NonNullElements(Lhs));
Contract.Invariant(cce.NonNullElements(Args));
}
- public readonly List<AutoVarDecl/*!*/>/*!*/ NewVars;
public readonly List<IdentifierExpr/*!*/>/*!*/ Lhs;
public readonly Expression/*!*/ Receiver;
public readonly string/*!*/ MethodName;
public readonly List<Expression/*!*/>/*!*/ Args;
public Method Method; // filled in by resolution
- public CallStmt(IToken tok, List<AutoVarDecl/*!*/>/*!*/ newVars, List<IdentifierExpr/*!*/>/*!*/ lhs, Expression/*!*/ receiver,
+ public CallStmt(IToken tok, List<IdentifierExpr/*!*/>/*!*/ lhs, Expression/*!*/ receiver,
string/*!*/ methodName, List<Expression/*!*/>/*!*/ args)
: base(tok) {
Contract.Requires(tok != null);
- Contract.Requires(cce.NonNullElements(newVars));
Contract.Requires(cce.NonNullElements(lhs));
Contract.Requires(receiver != null);
Contract.Requires(methodName != null);
Contract.Requires(cce.NonNullElements(args));
- this.NewVars = newVars;
this.Lhs = lhs;
this.Receiver = receiver;
this.MethodName = methodName;
this.Args = args;
-
}
}
@@ -1762,32 +1746,31 @@ namespace Microsoft.Dafny { public readonly Expression/*!*/ Collection;
public readonly Expression/*!*/ Range;
public readonly List<PredicateStmt/*!*/>/*!*/ BodyPrefix;
- public readonly AssignStmt/*!*/ BodyAssign;
+ public readonly Statement GivenBody; // used only until resolution; afterwards, use BodyAssign
+ public AssignStmt/*!*/ BodyAssign; // filled in during resolution
[ContractInvariantMethod]
void ObjectInvariant() {
Contract.Invariant(BoundVar != null);
Contract.Invariant(Collection != null);
Contract.Invariant(Range != null);
Contract.Invariant(cce.NonNullElements(BodyPrefix));
- Contract.Invariant(BodyAssign != null);
+ Contract.Invariant(GivenBody != null);
}
-
public ForeachStmt(IToken tok, BoundVar boundVar, Expression collection, Expression range,
- List<PredicateStmt/*!*/>/*!*/ bodyPrefix, AssignStmt bodyAssign)
+ List<PredicateStmt/*!*/>/*!*/ bodyPrefix, Statement givenBody)
: base(tok) {
Contract.Requires(tok != null);
Contract.Requires(boundVar != null);
Contract.Requires(collection != null);
Contract.Requires(range != null);
Contract.Requires(cce.NonNullElements(bodyPrefix));
- Contract.Requires(bodyAssign != null);
+ Contract.Requires(givenBody != null);
this.BoundVar = boundVar;
this.Collection = collection;
this.Range = range;
this.BodyPrefix = bodyPrefix;
- this.BodyAssign = bodyAssign;
-
+ this.GivenBody = givenBody;
}
}
@@ -2071,6 +2054,18 @@ namespace Microsoft.Dafny { }
}
+ /// <summary>
+ /// If an "AutoGhostIdentifierExpr" is used as the out-parameter of a ghost method or
+ /// a method with a ghost parameter, resolution will change the .Var's .IsGhost to true
+ /// automatically. This class is intended to be used only as a communicate between the
+ /// parser and parts of the resolver.
+ /// </summary>
+ public class AutoGhostIdentifierExpr : IdentifierExpr
+ {
+ public AutoGhostIdentifierExpr(IToken tok, string name)
+ : base(tok, name) { }
+ }
+
public abstract class DisplayExpression : Expression {
public readonly List<Expression/*!*/>/*!*/ Elements;
[ContractInvariantMethod]
diff --git a/Source/Dafny/Parser.cs b/Source/Dafny/Parser.cs index 190ac382..2586c67d 100644 --- a/Source/Dafny/Parser.cs +++ b/Source/Dafny/Parser.cs @@ -20,7 +20,7 @@ public class Parser { public const int _digits = 2;
public const int _arrayToken = 3;
public const int _string = 4;
- public const int maxT = 109;
+ public const int maxT = 106;
const bool T = true;
const bool x = false;
@@ -51,22 +51,6 @@ struct MemberModifiers { }
// helper routine for parsing call statements
-private static void RecordCallLhs(IdentifierExpr/*!*/ e,
- List<IdentifierExpr/*!*/>/*!*/ lhs,
- List<AutoVarDecl/*!*/>/*!*/ newVars) {
- Contract.Requires(e != null);
- Contract.Requires(cce.NonNullElements(lhs));
- Contract.Requires(cce.NonNullElements(newVars));
- int index = lhs.Count;
- lhs.Add(e);
- if (parseVarScope.Find(e.Name) == null) {
- AutoVarDecl d = new AutoVarDecl(e.tok, e.Name, new InferredTypeProxy(), index);
- newVars.Add(d);
- parseVarScope.Push(e.Name, e.Name);
- }
-}
-
-// helper routine for parsing call statements
private static Expression/*!*/ ConvertToLocal(Expression/*!*/ e)
{
Contract.Requires(e != null);
@@ -379,7 +363,7 @@ public static int Parse (string/*!*/ s, string/*!*/ filename, List<ModuleDecl/*! DatatypeMemberDecl(ctors);
}
Expect(15);
- } else SynErr(110);
+ } else SynErr(107);
dt = new DatatypeDecl(id, id.val, module, typeArgs, ctors, attrs);
dt.BodyStartTok = bodyStart;
dt.BodyEndTok = t;
@@ -414,7 +398,7 @@ public static int Parse (string/*!*/ s, string/*!*/ filename, List<ModuleDecl/*! mm.Add(m);
} else if (la.kind == 20) {
CouplingInvDecl(mmod, mm);
- } else SynErr(111);
+ } else SynErr(108);
}
void GenericParameters(List<TypeParameter/*!*/>/*!*/ typeArgs) {
@@ -498,7 +482,7 @@ public static int Parse (string/*!*/ s, string/*!*/ filename, List<ModuleDecl/*! }
FunctionBody(out bb, out bodyStart, out bodyEnd);
body = bb;
- } else SynErr(112);
+ } else SynErr(109);
parseVarScope.PopMarker();
f = new Function(id, id.val, mmod.IsStatic, !isFunctionMethod, mmod.IsUnlimited, typeArgs, formals, returnType, reqs, reads, ens, decreases, body, attrs);
f.BodyStartTok = bodyStart;
@@ -527,7 +511,7 @@ public static int Parse (string/*!*/ s, string/*!*/ filename, List<ModuleDecl/*! } else if (la.kind == 10) {
Get();
isRefinement = true;
- } else SynErr(113);
+ } else SynErr(110);
if (mmod.IsUnlimited) { SemErr(t, "methods cannot be declared 'unlimited'"); }
while (la.kind == 7) {
@@ -554,7 +538,7 @@ public static int Parse (string/*!*/ s, string/*!*/ filename, List<ModuleDecl/*! }
BlockStmt(out bb, out bodyStart, out bodyEnd);
body = (BlockStmt)bb;
- } else SynErr(114);
+ } else SynErr(111);
parseVarScope.PopMarker();
if (isRefinement)
m = new MethodRefinement(id, id.val, mmod.IsStatic, mmod.IsGhost, typeArgs, ins, outs, req, mod, ens, dec, body, attrs);
@@ -756,7 +740,7 @@ public static int Parse (string/*!*/ s, string/*!*/ filename, List<ModuleDecl/*! ReferenceType(out tok, out ty);
break;
}
- default: SynErr(115); break;
+ default: SynErr(112); break;
}
}
@@ -807,12 +791,12 @@ List<Expression/*!*/>/*!*/ decreases) { Expression(out e);
Expect(15);
ens.Add(new MaybeFreeExpression(e, isFree));
- } else SynErr(116);
+ } else SynErr(113);
} else if (la.kind == 31) {
Get();
Expressions(decreases);
Expect(15);
- } else SynErr(117);
+ } else SynErr(114);
}
void BlockStmt(out Statement/*!*/ block, out IToken bodyStart, out IToken bodyEnd) {
@@ -894,7 +878,7 @@ List<Expression/*!*/>/*!*/ decreases) { GenericInstantiation(gt);
}
ty = new UserDefinedType(tok, tok.val, gt);
- } else SynErr(118);
+ } else SynErr(115);
}
void FunctionSpec(List<Expression/*!*/>/*!*/ reqs, List<FrameExpression/*!*/>/*!*/ reads, List<Expression/*!*/>/*!*/ ens, List<Expression/*!*/>/*!*/ decreases) {
@@ -926,7 +910,7 @@ List<Expression/*!*/>/*!*/ decreases) { Get();
Expressions(decreases);
Expect(15);
- } else SynErr(119);
+ } else SynErr(116);
}
void FunctionBody(out Expression/*!*/ e, out IToken bodyStart, out IToken bodyEnd) {
@@ -937,7 +921,7 @@ List<Expression/*!*/>/*!*/ decreases) { MatchExpression(out e);
} else if (StartOf(8)) {
Expression(out e);
- } else SynErr(120);
+ } else SynErr(117);
Expect(8);
bodyEnd = t;
}
@@ -949,7 +933,7 @@ List<Expression/*!*/>/*!*/ decreases) { fe = new FrameExpression(new WildcardExpr(t), null);
} else if (StartOf(8)) {
FrameExpression(out fe);
- } else SynErr(121);
+ } else SynErr(118);
}
void PossiblyWildExpression(out Expression/*!*/ e) {
@@ -960,7 +944,7 @@ List<Expression/*!*/>/*!*/ decreases) { e = new WildcardExpr(t);
} else if (StartOf(8)) {
Expression(out e);
- } else SynErr(122);
+ } else SynErr(119);
}
void MatchExpression(out Expression/*!*/ e) {
@@ -1014,18 +998,14 @@ List<Expression/*!*/>/*!*/ decreases) { MatchExpression(out e);
} else if (StartOf(8)) {
Expression(out e);
- } else SynErr(123);
+ } else SynErr(120);
}
void Stmt(List<Statement/*!*/>/*!*/ ss) {
- Contract.Requires(cce.NonNullElements(ss)); Statement/*!*/ s;
+ Statement/*!*/ s;
- if (StartOf(11)) {
- OneStmt(out s);
- ss.Add(s);
- } else if (la.kind == 58 || la.kind == 59) {
- VarDeclStmts(ss);
- } else SynErr(124);
+ OneStmt(out s);
+ ss.Add(s);
}
void OneStmt(out Statement/*!*/ s) {
@@ -1035,28 +1015,26 @@ List<Expression/*!*/>/*!*/ decreases) { if (la.kind == 7) {
BlockStmt(out s, out bodyStart, out bodyEnd);
- } else if (la.kind == 67) {
+ } else if (la.kind == 64) {
AssertStmt(out s);
- } else if (la.kind == 68) {
+ } else if (la.kind == 65) {
AssumeStmt(out s);
- } else if (la.kind == 69) {
+ } else if (la.kind == 66) {
UseStmt(out s);
- } else if (la.kind == 70) {
+ } else if (la.kind == 67) {
PrintStmt(out s);
} else if (la.kind == 57) {
HavocStmt(out s);
- } else if (la.kind == 64) {
- CallStmt(out s);
} else if (la.kind == 47) {
Get();
UpdateStmt(out s);
- } else if (la.kind == 60) {
+ } else if (la.kind == 58) {
IfStmt(out s);
- } else if (la.kind == 62) {
+ } else if (la.kind == 60) {
WhileStmt(out s);
} else if (la.kind == 44) {
MatchStmt(out s);
- } else if (la.kind == 65) {
+ } else if (la.kind == 62) {
ForeachStmt(out s);
} else if (la.kind == 48) {
Get();
@@ -1080,31 +1058,14 @@ List<Expression/*!*/>/*!*/ decreases) { s = new ReturnStmt(x);
} else if (la.kind == 11 || la.kind == 18) {
VarDeclStatement(out s);
- } else if (StartOf(12)) {
+ } else if (StartOf(11)) {
UpdateStmt(out s);
- } else SynErr(125);
- }
-
- void VarDeclStmts(List<Statement/*!*/>/*!*/ ss) {
- Contract.Requires(cce.NonNullElements(ss)); VarDecl/*!*/ d; bool isGhost = false;
- if (la.kind == 58) {
- Get();
- isGhost = true;
- }
- Expect(59);
- IdentTypeRhs(out d, isGhost);
- ss.Add(d); parseVarScope.Push(d.Name, d.Name);
- while (la.kind == 19) {
- Get();
- IdentTypeRhs(out d, isGhost);
- ss.Add(d); parseVarScope.Push(d.Name, d.Name);
- }
- Expect(15);
+ } else SynErr(121);
}
void AssertStmt(out Statement/*!*/ s) {
Contract.Ensures(Contract.ValueAtReturn(out s) != null); IToken/*!*/ x; Expression/*!*/ e;
- Expect(67);
+ Expect(64);
x = t;
Expression(out e);
Expect(15);
@@ -1113,7 +1074,7 @@ List<Expression/*!*/>/*!*/ decreases) { void AssumeStmt(out Statement/*!*/ s) {
Contract.Ensures(Contract.ValueAtReturn(out s) != null); IToken/*!*/ x; Expression/*!*/ e;
- Expect(68);
+ Expect(65);
x = t;
Expression(out e);
Expect(15);
@@ -1122,7 +1083,7 @@ List<Expression/*!*/>/*!*/ decreases) { void UseStmt(out Statement/*!*/ s) {
Contract.Ensures(Contract.ValueAtReturn(out s) != null); IToken/*!*/ x; Expression/*!*/ e;
- Expect(69);
+ Expect(66);
x = t;
Expression(out e);
Expect(15);
@@ -1133,7 +1094,7 @@ List<Expression/*!*/>/*!*/ decreases) { Contract.Ensures(Contract.ValueAtReturn(out s) != null); IToken/*!*/ x; Attributes.Argument/*!*/ arg;
List<Attributes.Argument/*!*/> args = new List<Attributes.Argument/*!*/>();
- Expect(70);
+ Expect(67);
x = t;
AttributeArg(out arg);
args.Add(arg);
@@ -1155,61 +1116,6 @@ List<Expression/*!*/>/*!*/ decreases) { s = new AssignStmt(x, lhs);
}
- void CallStmt(out Statement/*!*/ s) {
- Contract.Ensures(Contract.ValueAtReturn(out s) != null); IToken/*!*/ x, id;
- Expression/*!*/ e;
- List<IdentifierExpr/*!*/> lhs = new List<IdentifierExpr/*!*/>();
- List<AutoVarDecl/*!*/> newVars = new List<AutoVarDecl/*!*/>();
-
- Expect(64);
- x = t;
- CallStmtSubExpr(out e);
- if (la.kind == 19 || la.kind == 51) {
- if (la.kind == 19) {
- Get();
- e = ConvertToLocal(e);
- if (e is IdentifierExpr) {
- RecordCallLhs((IdentifierExpr)e, lhs, newVars);
- } else if (e is FieldSelectExpr) {
- SemErr(e.tok, "each LHS of call statement must be a variable, not a field");
- } else {
- SemErr(e.tok, "each LHS of call statement must be a variable");
- }
-
- Ident(out id);
- RecordCallLhs(new IdentifierExpr(id, id.val), lhs, newVars);
- while (la.kind == 19) {
- Get();
- Ident(out id);
- RecordCallLhs(new IdentifierExpr(id, id.val), lhs, newVars);
- }
- Expect(51);
- CallStmtSubExpr(out e);
- } else {
- Get();
- e = ConvertToLocal(e);
- if (e is IdentifierExpr) {
- RecordCallLhs((IdentifierExpr)e, lhs, newVars);
- } else if (e is FieldSelectExpr) {
- SemErr(e.tok, "each LHS of call statement must be a variable, not a field");
- } else {
- SemErr(e.tok, "each LHS of call statement must be a variable");
- }
-
- CallStmtSubExpr(out e);
- }
- }
- Expect(15);
- if (e is FunctionCallExpr) {
- FunctionCallExpr fce = (FunctionCallExpr)e;
- s = new CallStmt(x, newVars, lhs, fce.Receiver, fce.Name, fce.Args); // this actually does an ownership transfer of fce.Args
- } else {
- SemErr("RHS of call statement must denote a method invocation");
- s = new CallStmt(x, newVars, lhs, dummyExpr, "dummyMethodName", new List<Expression/*!*/>());
- }
-
- }
-
void UpdateStmt(out Statement/*!*/ s) {
List<Expression> lhss = new List<Expression>();
List<DeterminedAssignmentRhs> rhss = new List<DeterminedAssignmentRhs>();
@@ -1239,7 +1145,7 @@ List<Expression/*!*/>/*!*/ decreases) { rhss.Add(r);
}
Expect(15);
- } else SynErr(126);
+ } else SynErr(122);
s = new UpdateStmt(x, lhss, rhss);
}
@@ -1253,26 +1159,26 @@ List<Expression/*!*/>/*!*/ decreases) { List<GuardedAlternative> alternatives;
ifStmt = dummyStmt; // to please the compiler
- Expect(60);
+ Expect(58);
x = t;
if (la.kind == 32) {
Guard(out guard);
BlockStmt(out thn, out bodyStart, out bodyEnd);
- if (la.kind == 61) {
+ if (la.kind == 59) {
Get();
- if (la.kind == 60) {
+ if (la.kind == 58) {
IfStmt(out s);
els = s;
} else if (la.kind == 7) {
BlockStmt(out s, out bodyStart, out bodyEnd);
els = s;
- } else SynErr(127);
+ } else SynErr(123);
}
ifStmt = new IfStmt(x, guard, thn, els);
} else if (la.kind == 7) {
AlternativeBlock(out alternatives);
ifStmt = new AlternativeStmt(x, alternatives);
- } else SynErr(128);
+ } else SynErr(124);
}
void WhileStmt(out Statement/*!*/ stmt) {
@@ -1285,7 +1191,7 @@ List<Expression/*!*/>/*!*/ decreases) { List<GuardedAlternative> alternatives;
stmt = dummyStmt; // to please the compiler
- Expect(62);
+ Expect(60);
x = t;
if (la.kind == 32) {
Guard(out guard);
@@ -1293,11 +1199,11 @@ List<Expression/*!*/>/*!*/ decreases) { LoopSpec(out invariants, out decreases);
BlockStmt(out body, out bodyStart, out bodyEnd);
stmt = new WhileStmt(x, guard, invariants, decreases, body);
- } else if (StartOf(13)) {
+ } else if (StartOf(12)) {
LoopSpec(out invariants, out decreases);
AlternativeBlock(out alternatives);
stmt = new AlternativeLoopStmt(x, invariants, decreases, alternatives);
- } else SynErr(129);
+ } else SynErr(125);
}
void MatchStmt(out Statement/*!*/ s) {
@@ -1317,15 +1223,16 @@ List<Expression/*!*/>/*!*/ decreases) { }
void ForeachStmt(out Statement/*!*/ s) {
- Contract.Ensures(Contract.ValueAtReturn(out s) != null); IToken/*!*/ x, boundVar;
+ Contract.Ensures(Contract.ValueAtReturn(out s) != null);
+ IToken/*!*/ x, boundVar;
Type/*!*/ ty;
Expression/*!*/ collection;
Expression/*!*/ range;
List<PredicateStmt/*!*/> bodyPrefix = new List<PredicateStmt/*!*/>();
- AssignStmt bodyAssign = null;
+ Statement bodyAssign = null;
parseVarScope.PushMarker();
- Expect(65);
+ Expect(62);
x = t;
range = new LiteralExpr(x, true);
ty = new InferredTypeProxy();
@@ -1336,7 +1243,7 @@ List<Expression/*!*/>/*!*/ decreases) { Get();
Type(out ty);
}
- Expect(66);
+ Expect(63);
Expression(out collection);
parseVarScope.Push(boundVar.val, boundVar.val);
if (la.kind == 17) {
@@ -1345,11 +1252,11 @@ List<Expression/*!*/>/*!*/ decreases) { }
Expect(33);
Expect(7);
- while (la.kind == 67 || la.kind == 68 || la.kind == 69) {
- if (la.kind == 67) {
+ while (la.kind == 64 || la.kind == 65 || la.kind == 66) {
+ if (la.kind == 64) {
AssertStmt(out s);
if (s is PredicateStmt) { bodyPrefix.Add((PredicateStmt)s); }
- } else if (la.kind == 68) {
+ } else if (la.kind == 65) {
AssumeStmt(out s);
if (s is PredicateStmt) { bodyPrefix.Add((PredicateStmt)s); }
} else {
@@ -1357,13 +1264,13 @@ List<Expression/*!*/>/*!*/ decreases) { if (s is PredicateStmt) { bodyPrefix.Add((PredicateStmt)s); }
}
}
- if (StartOf(14)) {
- AssignStmt(out s, false);
- if (s is AssignStmt) { bodyAssign = (AssignStmt)s; }
+ if (StartOf(11)) {
+ UpdateStmt(out s);
+ bodyAssign = s;
} else if (la.kind == 57) {
HavocStmt(out s);
- if (s is AssignStmt) { bodyAssign = (AssignStmt)s; }
- } else SynErr(130);
+ bodyAssign = s;
+ } else SynErr(126);
Expect(8);
if (bodyAssign != null) {
s = new ForeachStmt(x, new BoundVar(boundVar, boundVar.val, ty), collection, range, bodyPrefix, bodyAssign);
@@ -1412,7 +1319,7 @@ List<Expression/*!*/>/*!*/ decreases) { } else {
var ies = new List<Expression>();
foreach (var lhs in lhss) {
- ies.Add(new IdentifierExpr(lhs.Tok, lhs.Name));
+ ies.Add(new AutoGhostIdentifierExpr(lhs.Tok, lhs.Name));
}
update = new UpdateStmt(assignTok, ies, rhss);
}
@@ -1428,13 +1335,13 @@ List<Expression/*!*/>/*!*/ decreases) { while (la.kind == 53 || la.kind == 55) {
Suffix(ref e);
}
- } else if (StartOf(15)) {
+ } else if (StartOf(13)) {
ConstAtomExpression(out e);
Suffix(ref e);
while (la.kind == 53 || la.kind == 55) {
Suffix(ref e);
}
- } else SynErr(131);
+ } else SynErr(127);
}
void Rhs(out DeterminedAssignmentRhs r, Expression receiverForInitCall) {
@@ -1466,7 +1373,7 @@ List<Expression/*!*/>/*!*/ decreases) { Expressions(args);
}
Expect(33);
- initCall = new CallStmt(x, new List<AutoVarDecl>(), new List<IdentifierExpr>(),
+ initCall = new CallStmt(x, new List<IdentifierExpr>(),
receiverForInitCall, x.val, args);
}
}
@@ -1484,135 +1391,7 @@ List<Expression/*!*/>/*!*/ decreases) { } else if (StartOf(8)) {
Expression(out e);
r = new ExprRhs(e);
- } else SynErr(132);
- }
-
- void AssignStmt(out Statement/*!*/ s, bool allowChoose) {
- Contract.Ensures(Contract.ValueAtReturn(out s) != null);
- IToken/*!*/ x, rhsTok;
- Expression/*!*/ lhs;
- List<Expression> rhs;
- Type ty;
- s = dummyStmt;
- CallStmt initCall = null;
-
- LhsExpr(out lhs);
- Expect(51);
- x = t;
- AssignRhs(out rhsTok, out rhs, out ty, out initCall, lhs);
- if (ty == null) {
- Contract.Assert(rhs != null);
- Contract.Assert(rhs.Count == 1);
- s = new AssignStmt(x, lhs, new ExprRhs(rhs[0]));
- if (!allowChoose) {
- var r = rhs[0] as UnaryExpr;
- if (r != null && r.Op == UnaryExpr.Opcode.SetChoose) {
- SemErr("choose operator not allowed as RHS in foreach assignment");
- }
- }
- } else if (rhs == null) {
- s = new AssignStmt(x, lhs, new TypeRhs(rhsTok, ty, initCall));
- } else {
- s = new AssignStmt(x, lhs, new TypeRhs(rhsTok, ty, rhs));
- }
-
- Expect(15);
- }
-
- void LhsExpr(out Expression/*!*/ e) {
- Contract.Ensures(Contract.ValueAtReturn(out e)!=null);
- SelectExpression(out e);
- }
-
- void AssignRhs(out IToken tok, out List<Expression> ee, out Type ty, out CallStmt initCall, Expression receiverForInitCall) {
- IToken/*!*/ x; Expression/*!*/ e;
- ee = null; ty = null;
- initCall = null;
- List<Expression> args;
- tok = Token.NoToken; // to please compiler
-
- if (la.kind == 52) {
- Get();
- tok = t;
- TypeAndToken(out x, out ty);
- if (la.kind == 53 || la.kind == 55) {
- if (la.kind == 53) {
- Get();
- ee = new List<Expression>();
- Expressions(ee);
- Expect(54);
- UserDefinedType tmp = theBuiltIns.ArrayType(x, ee.Count, new IntType(), true);
-
- } else {
- Get();
- Ident(out x);
- Expect(32);
- args = new List<Expression/*!*/>();
- if (StartOf(8)) {
- Expressions(args);
- }
- Expect(33);
- initCall = new CallStmt(x, new List<AutoVarDecl>(), new List<IdentifierExpr>(),
- receiverForInitCall, x.val, args);
- }
- }
- } else if (la.kind == 56) {
- Get();
- x = t; tok = t;
- Expression(out e);
- e = new UnaryExpr(x, UnaryExpr.Opcode.SetChoose, e);
- ee = new List<Expression>() { e };
-
- } else if (StartOf(8)) {
- Expression(out e);
- tok = e.tok; ee = new List<Expression>() { e };
- } else SynErr(133);
- if (ee == null && ty == null) { ee = new List<Expression>() { dummyExpr}; }
- }
-
- void SelectExpression(out Expression/*!*/ e) {
- Contract.Ensures(Contract.ValueAtReturn(out e) != null); e = dummyExpr;
- if (la.kind == 1) {
- IdentOrFuncExpression(out e);
- } else if (la.kind == 32 || la.kind == 97 || la.kind == 100) {
- ObjectExpression(out e);
- } else SynErr(134);
- while (la.kind == 53 || la.kind == 55) {
- SelectOrCallSuffix(ref e);
- }
- }
-
- void IdentTypeRhs(out VarDecl/*!*/ d, bool isGhost) {
- Contract.Ensures(Contract.ValueAtReturn(out d) != null);
- IToken/*!*/ id, rhsTok = null; Type/*!*/ ty;
- List<Expression> rhs = null; Type newType = null;
- Type optionalType = null; DeterminedAssignmentRhs optionalRhs = null;
- CallStmt initCall = null;
-
- Ident(out id);
- if (la.kind == 22) {
- Get();
- Type(out ty);
- optionalType = ty;
- }
- if (la.kind == 51) {
- Get();
- AssignRhs(out rhsTok, out rhs, out newType, out initCall, new IdentifierExpr(id, id.val));
- }
- if (newType == null && rhs != null) {
- Contract.Assert(rhs.Count == 1);
- optionalRhs = new ExprRhs(rhs[0]);
- } else if (newType != null) {
- if (rhs == null) {
- optionalRhs = new TypeRhs(rhsTok, newType, initCall);
- } else {
- optionalRhs = new TypeRhs(rhsTok, newType, rhs);
- }
- } else if (optionalType == null) {
- optionalType = new InferredTypeProxy();
- }
- d = new VarDecl(id, id.val, optionalType, isGhost /*** OLD, optionalRhs ***/);
-
+ } else SynErr(128);
}
void Guard(out Expression e) {
@@ -1624,7 +1403,7 @@ List<Expression/*!*/>/*!*/ decreases) { } else if (StartOf(8)) {
Expression(out ee);
e = ee;
- } else SynErr(135);
+ } else SynErr(129);
Expect(33);
}
@@ -1656,14 +1435,14 @@ List<Expression/*!*/>/*!*/ decreases) { invariants = new List<MaybeFreeExpression/*!*/>();
decreases = new List<Expression/*!*/>();
- while (la.kind == 28 || la.kind == 31 || la.kind == 63) {
- if (la.kind == 28 || la.kind == 63) {
+ while (la.kind == 28 || la.kind == 31 || la.kind == 61) {
+ if (la.kind == 28 || la.kind == 61) {
isFree = false;
if (la.kind == 28) {
Get();
isFree = true;
}
- Expect(63);
+ Expect(61);
Expression(out e);
invariants.Add(new MaybeFreeExpression(e, isFree));
Expect(15);
@@ -1713,19 +1492,6 @@ List<Expression/*!*/>/*!*/ decreases) { parseVarScope.PopMarker();
}
- void CallStmtSubExpr(out Expression/*!*/ e) {
- Contract.Ensures(Contract.ValueAtReturn(out e) != null); e = dummyExpr;
- if (la.kind == 1) {
- IdentOrFuncExpression(out e);
- } else if (la.kind == 32 || la.kind == 97 || la.kind == 100) {
- ObjectExpression(out e);
- SelectOrCallSuffix(ref e);
- } else SynErr(136);
- while (la.kind == 53 || la.kind == 55) {
- SelectOrCallSuffix(ref e);
- }
- }
-
void AttributeArg(out Attributes.Argument/*!*/ arg) {
Contract.Ensures(Contract.ValueAtReturn(out arg) != null); Expression/*!*/ e; arg = dummyAttrArg;
if (la.kind == 4) {
@@ -1734,13 +1500,13 @@ List<Expression/*!*/>/*!*/ decreases) { } else if (StartOf(8)) {
Expression(out e);
arg = new Attributes.Argument(e);
- } else SynErr(137);
+ } else SynErr(130);
}
void EquivExpression(out Expression/*!*/ e0) {
Contract.Ensures(Contract.ValueAtReturn(out e0) != null); IToken/*!*/ x; Expression/*!*/ e1;
ImpliesExpression(out e0);
- while (la.kind == 71 || la.kind == 72) {
+ while (la.kind == 68 || la.kind == 69) {
EquivOp();
x = t;
ImpliesExpression(out e1);
@@ -1751,7 +1517,7 @@ List<Expression/*!*/>/*!*/ decreases) { void ImpliesExpression(out Expression/*!*/ e0) {
Contract.Ensures(Contract.ValueAtReturn(out e0) != null); IToken/*!*/ x; Expression/*!*/ e1;
LogicalExpression(out e0);
- if (la.kind == 73 || la.kind == 74) {
+ if (la.kind == 70 || la.kind == 71) {
ImpliesOp();
x = t;
ImpliesExpression(out e1);
@@ -1760,23 +1526,23 @@ List<Expression/*!*/>/*!*/ decreases) { }
void EquivOp() {
- if (la.kind == 71) {
+ if (la.kind == 68) {
Get();
- } else if (la.kind == 72) {
+ } else if (la.kind == 69) {
Get();
- } else SynErr(138);
+ } else SynErr(131);
}
void LogicalExpression(out Expression/*!*/ e0) {
Contract.Ensures(Contract.ValueAtReturn(out e0) != null); IToken/*!*/ x; Expression/*!*/ e1;
RelationalExpression(out e0);
- if (StartOf(16)) {
- if (la.kind == 75 || la.kind == 76) {
+ if (StartOf(14)) {
+ if (la.kind == 72 || la.kind == 73) {
AndOp();
x = t;
RelationalExpression(out e1);
e0 = new BinaryExpr(x, BinaryExpr.Opcode.And, e0, e1);
- while (la.kind == 75 || la.kind == 76) {
+ while (la.kind == 72 || la.kind == 73) {
AndOp();
x = t;
RelationalExpression(out e1);
@@ -1787,7 +1553,7 @@ List<Expression/*!*/>/*!*/ decreases) { x = t;
RelationalExpression(out e1);
e0 = new BinaryExpr(x, BinaryExpr.Opcode.Or, e0, e1);
- while (la.kind == 77 || la.kind == 78) {
+ while (la.kind == 74 || la.kind == 75) {
OrOp();
x = t;
RelationalExpression(out e1);
@@ -1798,17 +1564,17 @@ List<Expression/*!*/>/*!*/ decreases) { }
void ImpliesOp() {
- if (la.kind == 73) {
+ if (la.kind == 70) {
Get();
- } else if (la.kind == 74) {
+ } else if (la.kind == 71) {
Get();
- } else SynErr(139);
+ } else SynErr(132);
}
void RelationalExpression(out Expression/*!*/ e0) {
Contract.Ensures(Contract.ValueAtReturn(out e0) != null); IToken/*!*/ x; Expression/*!*/ e1; BinaryExpr.Opcode op;
Term(out e0);
- if (StartOf(17)) {
+ if (StartOf(15)) {
RelOp(out x, out op);
Term(out e1);
e0 = new BinaryExpr(x, op, e0, e1);
@@ -1816,25 +1582,25 @@ List<Expression/*!*/>/*!*/ decreases) { }
void AndOp() {
- if (la.kind == 75) {
+ if (la.kind == 72) {
Get();
- } else if (la.kind == 76) {
+ } else if (la.kind == 73) {
Get();
- } else SynErr(140);
+ } else SynErr(133);
}
void OrOp() {
- if (la.kind == 77) {
+ if (la.kind == 74) {
Get();
- } else if (la.kind == 78) {
+ } else if (la.kind == 75) {
Get();
- } else SynErr(141);
+ } else SynErr(134);
}
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 == 88 || la.kind == 89) {
+ while (la.kind == 85 || la.kind == 86) {
AddOp(out x, out op);
Factor(out e1);
e0 = new BinaryExpr(x, op, e0, e1);
@@ -1844,7 +1610,7 @@ List<Expression/*!*/>/*!*/ decreases) { void RelOp(out IToken/*!*/ x, out BinaryExpr.Opcode op) {
Contract.Ensures(Contract.ValueAtReturn(out x) != null); x = Token.NoToken; op = BinaryExpr.Opcode.Add/*(dummy)*/;
switch (la.kind) {
- case 79: {
+ case 76: {
Get();
x = t; op = BinaryExpr.Opcode.Eq;
break;
@@ -1859,59 +1625,59 @@ List<Expression/*!*/>/*!*/ decreases) { x = t; op = BinaryExpr.Opcode.Gt;
break;
}
- case 80: {
+ case 77: {
Get();
x = t; op = BinaryExpr.Opcode.Le;
break;
}
- case 81: {
+ case 78: {
Get();
x = t; op = BinaryExpr.Opcode.Ge;
break;
}
- case 82: {
+ case 79: {
Get();
x = t; op = BinaryExpr.Opcode.Neq;
break;
}
- case 83: {
+ case 80: {
Get();
x = t; op = BinaryExpr.Opcode.Disjoint;
break;
}
- case 66: {
+ case 63: {
Get();
x = t; op = BinaryExpr.Opcode.In;
break;
}
- case 84: {
+ case 81: {
Get();
x = t; op = BinaryExpr.Opcode.NotIn;
break;
}
- case 85: {
+ case 82: {
Get();
x = t; op = BinaryExpr.Opcode.Neq;
break;
}
- case 86: {
+ case 83: {
Get();
x = t; op = BinaryExpr.Opcode.Le;
break;
}
- case 87: {
+ case 84: {
Get();
x = t; op = BinaryExpr.Opcode.Ge;
break;
}
- default: SynErr(142); break;
+ default: SynErr(135); 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 == 42 || la.kind == 90 || la.kind == 91) {
+ while (la.kind == 42 || la.kind == 87 || la.kind == 88) {
MulOp(out x, out op);
UnaryExpression(out e1);
e0 = new BinaryExpr(x, op, e0, e1);
@@ -1920,40 +1686,40 @@ List<Expression/*!*/>/*!*/ decreases) { 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 == 88) {
+ if (la.kind == 85) {
Get();
x = t; op = BinaryExpr.Opcode.Add;
- } else if (la.kind == 89) {
+ } else if (la.kind == 86) {
Get();
x = t; op = BinaryExpr.Opcode.Sub;
- } else SynErr(143);
+ } else SynErr(136);
}
void UnaryExpression(out Expression/*!*/ e) {
Contract.Ensures(Contract.ValueAtReturn(out e) != null); IToken/*!*/ x; e = dummyExpr;
- if (la.kind == 89) {
+ if (la.kind == 86) {
Get();
x = t;
UnaryExpression(out e);
e = new BinaryExpr(x, BinaryExpr.Opcode.Sub, new LiteralExpr(x, 0), e);
- } else if (la.kind == 92 || la.kind == 93) {
+ } else if (la.kind == 89 || la.kind == 90) {
NegOp();
x = t;
UnaryExpression(out e);
e = new UnaryExpr(x, UnaryExpr.Opcode.Not, e);
- } else if (StartOf(18)) {
+ } else if (StartOf(16)) {
EndlessExpression(out e);
} else if (la.kind == 1) {
DottedIdentifiersAndFunction(out e);
while (la.kind == 53 || la.kind == 55) {
Suffix(ref e);
}
- } else if (StartOf(15)) {
+ } else if (StartOf(13)) {
ConstAtomExpression(out e);
while (la.kind == 53 || la.kind == 55) {
Suffix(ref e);
}
- } else SynErr(144);
+ } else SynErr(137);
}
void MulOp(out IToken/*!*/ x, out BinaryExpr.Opcode op) {
@@ -1961,21 +1727,21 @@ List<Expression/*!*/>/*!*/ decreases) { if (la.kind == 42) {
Get();
x = t; op = BinaryExpr.Opcode.Mul;
- } else if (la.kind == 90) {
+ } else if (la.kind == 87) {
Get();
x = t; op = BinaryExpr.Opcode.Div;
- } else if (la.kind == 91) {
+ } else if (la.kind == 88) {
Get();
x = t; op = BinaryExpr.Opcode.Mod;
- } else SynErr(145);
+ } else SynErr(138);
}
void NegOp() {
- if (la.kind == 92) {
+ if (la.kind == 89) {
Get();
- } else if (la.kind == 93) {
+ } else if (la.kind == 90) {
Get();
- } else SynErr(146);
+ } else SynErr(139);
}
void EndlessExpression(out Expression e) {
@@ -1983,20 +1749,20 @@ List<Expression/*!*/>/*!*/ decreases) { Expression e0, e1;
e = dummyExpr;
- if (la.kind == 60) {
+ if (la.kind == 58) {
Get();
x = t;
Expression(out e);
- Expect(101);
+ Expect(98);
Expression(out e0);
- Expect(61);
+ Expect(59);
Expression(out e1);
e = new ITEExpr(x, e, e0, e1);
- } else if (StartOf(19)) {
+ } else if (StartOf(17)) {
QuantifierGuts(out e);
} else if (la.kind == 37) {
ComprehensionExpr(out e);
- } else SynErr(147);
+ } else SynErr(140);
}
void DottedIdentifiersAndFunction(out Expression e) {
@@ -2023,7 +1789,82 @@ List<Expression/*!*/>/*!*/ decreases) { }
void Suffix(ref Expression/*!*/ e) {
- SelectOrCallSuffix(ref e);
+ Contract.Requires(e != null); Contract.Ensures(e!=null); IToken/*!*/ id, x; List<Expression/*!*/>/*!*/ args;
+ Expression e0 = null; Expression e1 = null; Expression/*!*/ ee; bool anyDots = false;
+ List<Expression> multipleIndices = null;
+ bool func = false;
+
+ if (la.kind == 55) {
+ Get();
+ Ident(out id);
+ if (la.kind == 32) {
+ Get();
+ args = new List<Expression/*!*/>(); func = true;
+ if (StartOf(8)) {
+ Expressions(args);
+ }
+ Expect(33);
+ e = new FunctionCallExpr(id, id.val, e, args);
+ }
+ if (!func) { e = new FieldSelectExpr(id, e, id.val); }
+ } else if (la.kind == 53) {
+ Get();
+ x = t;
+ if (StartOf(8)) {
+ Expression(out ee);
+ e0 = ee;
+ if (la.kind == 99) {
+ Get();
+ anyDots = true;
+ if (StartOf(8)) {
+ Expression(out ee);
+ e1 = ee;
+ }
+ } else if (la.kind == 51) {
+ Get();
+ Expression(out ee);
+ e1 = ee;
+ } else if (la.kind == 19 || la.kind == 54) {
+ while (la.kind == 19) {
+ Get();
+ Expression(out ee);
+ if (multipleIndices == null) {
+ multipleIndices = new List<Expression>();
+ multipleIndices.Add(e0);
+ }
+ multipleIndices.Add(ee);
+
+ }
+ } else SynErr(141);
+ } else if (la.kind == 99) {
+ Get();
+ Expression(out ee);
+ anyDots = true; e1 = ee;
+ } else SynErr(142);
+ if (multipleIndices != null) {
+ e = new MultiSelectExpr(x, e, multipleIndices);
+ // make sure an array class with this dimensionality exists
+ UserDefinedType tmp = theBuiltIns.ArrayType(x, multipleIndices.Count, new IntType(), true);
+ } else {
+ if (!anyDots && e0 == null) {
+ /* a parsing error occurred */
+ e0 = dummyExpr;
+ }
+ Contract.Assert(anyDots || e0 != null);
+ if (anyDots) {
+ Contract.Assert(e0 != null || e1 != null);
+ e = new SeqSelectExpr(x, false, e, e0, e1);
+ } else if (e1 == null) {
+ Contract.Assert(e0 != null);
+ e = new SeqSelectExpr(x, true, e, e0, null);
+ } else {
+ Contract.Assert(e0 != null);
+ e = new SeqUpdateExpr(x, e, e0, e1);
+ }
+ }
+
+ Expect(54);
+ } else SynErr(143);
}
void ConstAtomExpression(out Expression/*!*/ e) {
@@ -2032,17 +1873,17 @@ List<Expression/*!*/>/*!*/ decreases) { e = dummyExpr;
switch (la.kind) {
- case 94: {
+ case 91: {
Get();
e = new LiteralExpr(t, false);
break;
}
- case 95: {
+ case 92: {
Get();
e = new LiteralExpr(t, true);
break;
}
- case 96: {
+ case 93: {
Get();
e = new LiteralExpr(t);
break;
@@ -2052,12 +1893,12 @@ List<Expression/*!*/>/*!*/ decreases) { e = new LiteralExpr(t, n);
break;
}
- case 97: {
+ case 94: {
Get();
e = new ThisExpr(t);
break;
}
- case 98: {
+ case 95: {
Get();
x = t;
Expect(32);
@@ -2066,7 +1907,7 @@ List<Expression/*!*/>/*!*/ decreases) { e = new FreshExpr(x, e);
break;
}
- case 99: {
+ case 96: {
Get();
x = t;
Expect(32);
@@ -2075,7 +1916,7 @@ List<Expression/*!*/>/*!*/ decreases) { e = new AllocatedExpr(x, e);
break;
}
- case 100: {
+ case 97: {
Get();
x = t;
Expect(32);
@@ -2120,7 +1961,7 @@ List<Expression/*!*/>/*!*/ decreases) { Expect(33);
break;
}
- default: SynErr(148); break;
+ default: SynErr(144); break;
}
}
@@ -2145,13 +1986,13 @@ List<Expression/*!*/>/*!*/ decreases) { Expression range = null;
Expression/*!*/ body;
- if (la.kind == 103 || la.kind == 104) {
+ if (la.kind == 100 || la.kind == 101) {
Forall();
x = t; univ = true;
- } else if (la.kind == 105 || la.kind == 106) {
+ } else if (la.kind == 102 || la.kind == 103) {
Exists();
x = t;
- } else SynErr(149);
+ } else SynErr(145);
parseVarScope.PushMarker();
IdentTypeOptional(out bv);
bvars.Add(bv); parseVarScope.Push(bv.Name, bv.Name);
@@ -2198,7 +2039,7 @@ List<Expression/*!*/>/*!*/ decreases) { }
Expect(17);
Expression(out range);
- if (la.kind == 107 || la.kind == 108) {
+ if (la.kind == 104 || la.kind == 105) {
QSep();
Expression(out body);
}
@@ -2208,140 +2049,20 @@ List<Expression/*!*/>/*!*/ decreases) { }
- void IdentOrFuncExpression(out Expression/*!*/ e) {
- Contract.Ensures(Contract.ValueAtReturn(out e) != null); IToken/*!*/ id; e = dummyExpr; List<Expression/*!*/>/*!*/ args;
- Ident(out id);
- if (la.kind == 32) {
- Get();
- args = new List<Expression/*!*/>();
- if (StartOf(8)) {
- Expressions(args);
- }
- Expect(33);
- e = new FunctionCallExpr(id, id.val, new ImplicitThisExpr(id), args);
- }
- if (e == dummyExpr) {
- if (parseVarScope.Find(id.val) != null) {
- e = new IdentifierExpr(id, id.val);
- } else {
- e = new FieldSelectExpr(id, new ImplicitThisExpr(id), id.val);
- }
- }
-
- }
-
- void ObjectExpression(out Expression/*!*/ e) {
- Contract.Ensures(Contract.ValueAtReturn(out e) != null); IToken/*!*/ x; e = dummyExpr;
- if (la.kind == 97) {
- Get();
- e = new ThisExpr(t);
- } else if (la.kind == 100) {
- Get();
- x = t;
- Expect(32);
- Expression(out e);
- Expect(33);
- e = new OldExpr(x, e);
- } else if (la.kind == 32) {
- Get();
- Expression(out e);
- Expect(33);
- } else SynErr(150);
- }
-
- void SelectOrCallSuffix(ref Expression/*!*/ e) {
- Contract.Requires(e != null); Contract.Ensures(e!=null); IToken/*!*/ id, x; List<Expression/*!*/>/*!*/ args;
- Expression e0 = null; Expression e1 = null; Expression/*!*/ ee; bool anyDots = false;
- List<Expression> multipleIndices = null;
- bool func = false;
-
- if (la.kind == 55) {
- Get();
- Ident(out id);
- if (la.kind == 32) {
- Get();
- args = new List<Expression/*!*/>(); func = true;
- if (StartOf(8)) {
- Expressions(args);
- }
- Expect(33);
- e = new FunctionCallExpr(id, id.val, e, args);
- }
- if (!func) { e = new FieldSelectExpr(id, e, id.val); }
- } else if (la.kind == 53) {
- Get();
- x = t;
- if (StartOf(8)) {
- Expression(out ee);
- e0 = ee;
- if (la.kind == 102) {
- Get();
- anyDots = true;
- if (StartOf(8)) {
- Expression(out ee);
- e1 = ee;
- }
- } else if (la.kind == 51) {
- Get();
- Expression(out ee);
- e1 = ee;
- } else if (la.kind == 19 || la.kind == 54) {
- while (la.kind == 19) {
- Get();
- Expression(out ee);
- if (multipleIndices == null) {
- multipleIndices = new List<Expression>();
- multipleIndices.Add(e0);
- }
- multipleIndices.Add(ee);
-
- }
- } else SynErr(151);
- } else if (la.kind == 102) {
- Get();
- Expression(out ee);
- anyDots = true; e1 = ee;
- } else SynErr(152);
- if (multipleIndices != null) {
- e = new MultiSelectExpr(x, e, multipleIndices);
- // make sure an array class with this dimensionality exists
- UserDefinedType tmp = theBuiltIns.ArrayType(x, multipleIndices.Count, new IntType(), true);
- } else {
- if (!anyDots && e0 == null) {
- /* a parsing error occurred */
- e0 = dummyExpr;
- }
- Contract.Assert(anyDots || e0 != null);
- if (anyDots) {
- Contract.Assert(e0 != null || e1 != null);
- e = new SeqSelectExpr(x, false, e, e0, e1);
- } else if (e1 == null) {
- Contract.Assert(e0 != null);
- e = new SeqSelectExpr(x, true, e, e0, null);
- } else {
- Contract.Assert(e0 != null);
- e = new SeqUpdateExpr(x, e, e0, e1);
- }
- }
-
- Expect(54);
- } else SynErr(153);
- }
-
void Forall() {
- if (la.kind == 103) {
+ if (la.kind == 100) {
Get();
- } else if (la.kind == 104) {
+ } else if (la.kind == 101) {
Get();
- } else SynErr(154);
+ } else SynErr(146);
}
void Exists() {
- if (la.kind == 105) {
+ if (la.kind == 102) {
Get();
- } else if (la.kind == 106) {
+ } else if (la.kind == 103) {
Get();
- } else SynErr(155);
+ } else SynErr(147);
}
void AttributeOrTrigger(ref Attributes attrs, ref Triggers trigs) {
@@ -2354,16 +2075,16 @@ List<Expression/*!*/>/*!*/ decreases) { es = new List<Expression/*!*/>();
Expressions(es);
trigs = new Triggers(es, trigs);
- } else SynErr(156);
+ } else SynErr(148);
Expect(8);
}
void QSep() {
- if (la.kind == 107) {
+ if (la.kind == 104) {
Get();
- } else if (la.kind == 108) {
+ } else if (la.kind == 105) {
Get();
- } else SynErr(157);
+ } else SynErr(149);
}
void AttributeBody(ref Attributes attrs) {
@@ -2374,7 +2095,7 @@ List<Expression/*!*/>/*!*/ decreases) { Expect(22);
Expect(1);
aName = t.val;
- if (StartOf(20)) {
+ if (StartOf(18)) {
AttributeArg(out aArg);
aArgs.Add(aArg);
while (la.kind == 19) {
@@ -2398,27 +2119,25 @@ List<Expression/*!*/>/*!*/ decreases) { }
static readonly bool[,]/*!*/ set = {
- {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,T,x,x, x,T,T,T, T,T,T,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, 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,T,T, T,T,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, 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,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,T, 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,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,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,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,x, x,x,x},
- {x,T,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,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,x,x,x, 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,T, x,x,x,x, x,x,x,x, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,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, x,x,x,x, x,x,x,x, x,T,x,x, T,T,T,T, T,T,T,T, T,x,x,T, T,T,T,x, x,x,x},
- {x,T,T,x, x,x,x,T, x,x,x,T, x,x,x,x, x,T,T,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, T,x,x,T, T,T,T,x, x,T,x,x, x,T,T,T, T,x,T,x, T,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,x,T,T, T,T,T,T, T,x,x,x, x,x,x,x, x,x,x},
- {x,T,T,x, x,x,x,T, x,x,x,x, x,x,x,x, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,T,x,x, x,x,T,x, x,x,x,x, x,x,x,x, x,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, x,x,x,x, x,x,x,x, x,T,x,x, T,T,T,T, T,T,T,T, T,x,x,T, T,T,T,x, x,x,x},
- {x,T,T,x, x,x,x,T, x,x,x,T, x,x,x,x, x,T,T,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, T,x,x,T, T,T,T,x, x,T,x,x, x,T,x,x, T,x,T,x, T,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,x,T,T, T,T,T,T, T,x,x,x, x,x,x,x, x,x,x},
- {x,T,T,x, x,x,x,T, x,x,x,x, x,x,x,x, x,T,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,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,T,T, T,T,T,T, T,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, 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,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,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,T,x,x, T,x,x,x, x,x,x,x, x,x,x},
- {x,x,T,x, x,x,x,T, x,x,x,x, x,x,x,x, x,T,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,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,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, 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,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,T,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, x,x,x,x, x,x,x,x, x,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, 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,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,x, x,x,x,x, x,x,x,T, T,T,T,x, x,x,x},
- {x,T,T,x, T,x,x,T, x,x,x,x, x,x,x,x, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,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, x,x,x,x, x,x,x,x, x,T,x,x, T,T,T,T, T,T,T,T, T,x,x,T, T,T,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, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,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,T,T,T, T,T,T,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, 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,T,T, T,T,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, 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, 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,T, 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,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,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,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,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,x},
+ {x,T,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,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,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,T, x,x,x,x, x,x,x,x, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, 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,T,x, x,T,T,T, T,T,T,T, T,T,x,x, T,T,T,T, x,x,x,x},
+ {x,T,T,x, x,x,x,T, x,x,x,T, x,x,x,x, x,T,T,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, T,x,x,T, T,T,T,x, x,T,x,x, x,T,T,x, T,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,x,T, T,T,T,T, T,T,x,x, x,x,x,x, x,x,x,x},
+ {x,T,T,x, x,x,x,T, x,x,x,x, x,x,x,x, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,T,x,x, x,x,T,x, x,x,x,x, x,x,x,x, 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,T,x, x,T,T,T, T,T,T,T, T,T,x,x, T,T,T,T, x,x,x,x},
+ {x,T,T,x, x,x,x,T, x,x,x,x, x,x,x,x, x,T,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,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,T, T,T,T,T, T,T,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, 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,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,T,x, x,x,x,T, x,x,x,x, x,x,x,x, x,T,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,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,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, 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,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,T, 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, x,x,x,x, x,x,x,x, x,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,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, 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,x, x,x,x,x, T,T,T,T, x,x,x,x},
+ {x,T,T,x, T,x,x,T, x,x,x,x, x,x,x,x, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, 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,T,x, x,T,T,T, T,T,T,T, T,T,x,x, T,T,T,T, x,x,x,x}
};
} // end Parser
@@ -2501,106 +2220,98 @@ public class Errors { case 55: s = "\".\" expected"; break;
case 56: s = "\"choose\" expected"; break;
case 57: s = "\"havoc\" expected"; break;
- case 58: s = "\"ghostXYZXYZ\" expected"; break;
- case 59: s = "\"varXYZXYZ\" expected"; break;
- case 60: s = "\"if\" expected"; break;
- case 61: s = "\"else\" expected"; break;
- case 62: s = "\"while\" expected"; break;
- case 63: s = "\"invariant\" expected"; break;
- case 64: s = "\"callXYZXYZ\" expected"; break;
- case 65: s = "\"foreach\" expected"; break;
- case 66: s = "\"in\" expected"; break;
- case 67: s = "\"assert\" expected"; break;
- case 68: s = "\"assume\" expected"; break;
- case 69: s = "\"use\" expected"; break;
- case 70: s = "\"print\" expected"; break;
- case 71: s = "\"<==>\" expected"; break;
- case 72: s = "\"\\u21d4\" expected"; break;
- case 73: s = "\"==>\" expected"; break;
- case 74: s = "\"\\u21d2\" expected"; break;
- case 75: s = "\"&&\" expected"; break;
- case 76: s = "\"\\u2227\" expected"; break;
- case 77: s = "\"||\" expected"; break;
- case 78: s = "\"\\u2228\" expected"; break;
- case 79: s = "\"==\" expected"; break;
- case 80: s = "\"<=\" expected"; break;
- case 81: s = "\">=\" expected"; break;
- case 82: s = "\"!=\" expected"; break;
- case 83: s = "\"!!\" expected"; break;
- case 84: s = "\"!in\" expected"; break;
- case 85: s = "\"\\u2260\" expected"; break;
- case 86: s = "\"\\u2264\" expected"; break;
- case 87: s = "\"\\u2265\" expected"; break;
- case 88: s = "\"+\" expected"; break;
- case 89: s = "\"-\" expected"; break;
- case 90: s = "\"/\" expected"; break;
- case 91: s = "\"%\" expected"; break;
- case 92: s = "\"!\" expected"; break;
- case 93: s = "\"\\u00ac\" expected"; break;
- case 94: s = "\"false\" expected"; break;
- case 95: s = "\"true\" expected"; break;
- case 96: s = "\"null\" expected"; break;
- case 97: s = "\"this\" expected"; break;
- case 98: s = "\"fresh\" expected"; break;
- case 99: s = "\"allocated\" expected"; break;
- case 100: s = "\"old\" expected"; break;
- case 101: s = "\"then\" expected"; break;
- case 102: s = "\"..\" expected"; break;
- case 103: s = "\"forall\" expected"; break;
- case 104: s = "\"\\u2200\" expected"; break;
- case 105: s = "\"exists\" expected"; break;
- case 106: s = "\"\\u2203\" expected"; break;
- case 107: s = "\"::\" expected"; break;
- case 108: s = "\"\\u2022\" expected"; break;
- case 109: s = "??? expected"; break;
- case 110: s = "invalid DatatypeDecl"; break;
- case 111: s = "invalid ClassMemberDecl"; break;
- case 112: s = "invalid FunctionDecl"; break;
- case 113: s = "invalid MethodDecl"; break;
- case 114: s = "invalid MethodDecl"; break;
- case 115: s = "invalid TypeAndToken"; break;
- case 116: s = "invalid MethodSpec"; break;
- case 117: s = "invalid MethodSpec"; break;
- case 118: s = "invalid ReferenceType"; break;
- case 119: s = "invalid FunctionSpec"; break;
- case 120: s = "invalid FunctionBody"; break;
- case 121: s = "invalid PossiblyWildFrameExpression"; break;
- case 122: s = "invalid PossiblyWildExpression"; break;
- case 123: s = "invalid MatchOrExpr"; break;
- case 124: s = "invalid Stmt"; break;
- case 125: s = "invalid OneStmt"; break;
- case 126: s = "invalid UpdateStmt"; break;
- case 127: s = "invalid IfStmt"; break;
- case 128: s = "invalid IfStmt"; break;
- case 129: s = "invalid WhileStmt"; break;
- case 130: s = "invalid ForeachStmt"; break;
- case 131: s = "invalid Lhs"; break;
- case 132: s = "invalid Rhs"; break;
- case 133: s = "invalid AssignRhs"; break;
- case 134: s = "invalid SelectExpression"; break;
- case 135: s = "invalid Guard"; break;
- case 136: s = "invalid CallStmtSubExpr"; break;
- case 137: s = "invalid AttributeArg"; break;
- case 138: s = "invalid EquivOp"; break;
- case 139: s = "invalid ImpliesOp"; break;
- case 140: s = "invalid AndOp"; break;
- case 141: s = "invalid OrOp"; break;
- case 142: s = "invalid RelOp"; break;
- case 143: s = "invalid AddOp"; break;
- case 144: s = "invalid UnaryExpression"; break;
- case 145: s = "invalid MulOp"; break;
- case 146: s = "invalid NegOp"; break;
- case 147: s = "invalid EndlessExpression"; break;
- case 148: s = "invalid ConstAtomExpression"; break;
- case 149: s = "invalid QuantifierGuts"; break;
- case 150: s = "invalid ObjectExpression"; break;
- case 151: s = "invalid SelectOrCallSuffix"; break;
- case 152: s = "invalid SelectOrCallSuffix"; break;
- case 153: s = "invalid SelectOrCallSuffix"; break;
- case 154: s = "invalid Forall"; break;
- case 155: s = "invalid Exists"; break;
- case 156: s = "invalid AttributeOrTrigger"; break;
- case 157: s = "invalid QSep"; break;
+ case 58: s = "\"if\" expected"; break;
+ case 59: s = "\"else\" expected"; break;
+ case 60: s = "\"while\" expected"; break;
+ case 61: s = "\"invariant\" expected"; break;
+ case 62: s = "\"foreach\" expected"; break;
+ case 63: s = "\"in\" expected"; break;
+ case 64: s = "\"assert\" expected"; break;
+ case 65: s = "\"assume\" expected"; break;
+ case 66: s = "\"use\" expected"; break;
+ case 67: s = "\"print\" expected"; break;
+ case 68: s = "\"<==>\" expected"; break;
+ case 69: s = "\"\\u21d4\" expected"; break;
+ case 70: s = "\"==>\" expected"; break;
+ case 71: s = "\"\\u21d2\" expected"; break;
+ case 72: s = "\"&&\" expected"; break;
+ case 73: s = "\"\\u2227\" expected"; break;
+ case 74: s = "\"||\" expected"; break;
+ case 75: s = "\"\\u2228\" expected"; break;
+ case 76: s = "\"==\" expected"; break;
+ case 77: s = "\"<=\" expected"; break;
+ case 78: s = "\">=\" expected"; break;
+ case 79: s = "\"!=\" expected"; break;
+ case 80: s = "\"!!\" expected"; break;
+ case 81: s = "\"!in\" expected"; break;
+ case 82: s = "\"\\u2260\" expected"; break;
+ case 83: s = "\"\\u2264\" expected"; break;
+ case 84: s = "\"\\u2265\" expected"; break;
+ case 85: s = "\"+\" expected"; break;
+ case 86: s = "\"-\" expected"; break;
+ case 87: s = "\"/\" expected"; break;
+ case 88: s = "\"%\" expected"; break;
+ case 89: s = "\"!\" expected"; break;
+ case 90: s = "\"\\u00ac\" expected"; break;
+ case 91: s = "\"false\" expected"; break;
+ case 92: s = "\"true\" expected"; break;
+ case 93: s = "\"null\" expected"; break;
+ case 94: s = "\"this\" expected"; break;
+ case 95: s = "\"fresh\" expected"; break;
+ case 96: s = "\"allocated\" expected"; break;
+ case 97: s = "\"old\" expected"; break;
+ case 98: s = "\"then\" expected"; break;
+ case 99: s = "\"..\" expected"; break;
+ case 100: s = "\"forall\" expected"; break;
+ case 101: s = "\"\\u2200\" expected"; break;
+ case 102: s = "\"exists\" expected"; break;
+ case 103: s = "\"\\u2203\" expected"; break;
+ case 104: s = "\"::\" expected"; break;
+ case 105: s = "\"\\u2022\" expected"; break;
+ case 106: s = "??? expected"; break;
+ case 107: s = "invalid DatatypeDecl"; break;
+ case 108: s = "invalid ClassMemberDecl"; break;
+ case 109: s = "invalid FunctionDecl"; break;
+ case 110: s = "invalid MethodDecl"; break;
+ case 111: s = "invalid MethodDecl"; break;
+ case 112: s = "invalid TypeAndToken"; break;
+ case 113: s = "invalid MethodSpec"; break;
+ case 114: s = "invalid MethodSpec"; break;
+ case 115: s = "invalid ReferenceType"; break;
+ case 116: s = "invalid FunctionSpec"; break;
+ case 117: s = "invalid FunctionBody"; break;
+ case 118: s = "invalid PossiblyWildFrameExpression"; break;
+ case 119: s = "invalid PossiblyWildExpression"; break;
+ case 120: s = "invalid MatchOrExpr"; break;
+ case 121: s = "invalid OneStmt"; break;
+ case 122: s = "invalid UpdateStmt"; break;
+ case 123: s = "invalid IfStmt"; break;
+ case 124: s = "invalid IfStmt"; break;
+ case 125: s = "invalid WhileStmt"; break;
+ case 126: s = "invalid ForeachStmt"; break;
+ case 127: s = "invalid Lhs"; break;
+ case 128: s = "invalid Rhs"; break;
+ case 129: s = "invalid Guard"; break;
+ case 130: s = "invalid AttributeArg"; break;
+ case 131: s = "invalid EquivOp"; break;
+ case 132: s = "invalid ImpliesOp"; break;
+ case 133: s = "invalid AndOp"; break;
+ case 134: s = "invalid OrOp"; break;
+ case 135: s = "invalid RelOp"; break;
+ case 136: s = "invalid AddOp"; break;
+ case 137: s = "invalid UnaryExpression"; break;
+ case 138: s = "invalid MulOp"; break;
+ case 139: s = "invalid NegOp"; break;
+ case 140: s = "invalid EndlessExpression"; break;
+ case 141: s = "invalid Suffix"; break;
+ case 142: s = "invalid Suffix"; break;
+ case 143: s = "invalid Suffix"; break;
+ case 144: s = "invalid ConstAtomExpression"; break;
+ case 145: s = "invalid QuantifierGuts"; break;
+ case 146: s = "invalid Forall"; break;
+ case 147: s = "invalid Exists"; break;
+ case 148: s = "invalid AttributeOrTrigger"; break;
+ case 149: s = "invalid QSep"; break;
default: s = "error " + n; break;
}
diff --git a/Source/Dafny/Printer.cs b/Source/Dafny/Printer.cs index 894ffe94..f5fba723 100644 --- a/Source/Dafny/Printer.cs +++ b/Source/Dafny/Printer.cs @@ -548,7 +548,7 @@ namespace Microsoft.Dafny { wr.WriteLine();
}
Indent(ind);
- PrintStatement(s.BodyAssign, ind);
+ PrintStatement(s.GivenBody, ind);
wr.WriteLine();
Indent(indent);
wr.Write("}");
diff --git a/Source/Dafny/Resolver.cs b/Source/Dafny/Resolver.cs index 20bcd293..9b931f73 100644 --- a/Source/Dafny/Resolver.cs +++ b/Source/Dafny/Resolver.cs @@ -1253,14 +1253,13 @@ namespace Microsoft.Dafny { if (ErrorCount == prevErrorCount) {
#if !FULL_LHS_SUPPORT_FOR_CALLS
var idLhss = new List<IdentifierExpr>();
- var autos = new List<AutoVarDecl>();
foreach (var ll in s.Lhss) {
var ie = (IdentifierExpr)ll.Resolved; // TODO: the CallStmt should handle all LHS's, not just identifier expressions
Contract.Assert(ie != null);
idLhss.Add(ie);
}
#endif
- var a = new CallStmt(s.Tok, autos, idLhss, callRhs.Receiver, callRhs.MethodName, callRhs.Args);
+ var a = new CallStmt(callRhs.Tok, idLhss, callRhs.Receiver, callRhs.MethodName, callRhs.Args);
s.ResolvedStatements.Add(a);
}
}
@@ -1520,14 +1519,29 @@ namespace Microsoft.Dafny { bool specOnly = specContextOnly ||
(successfullyResolvedCollectionAndRange && (UsesSpecFeatures(s.Collection) || UsesSpecFeatures(s.Range)));
s.IsGhost = specOnly;
- ResolveStatement(s.BodyAssign, specOnly, method);
+ ResolveStatement(s.GivenBody, specOnly, method);
// check for correct usage of BoundVar in LHS and RHS of this assignment
- FieldSelectExpr lhs = s.BodyAssign.Lhs as FieldSelectExpr;
- IdentifierExpr obj = lhs == null ? null : lhs.Obj as IdentifierExpr;
- if (obj != null && obj.Var == s.BoundVar) {
- // exemplary!
+ if (s.GivenBody is AssignStmt) {
+ s.BodyAssign = (AssignStmt)s.GivenBody;
+ } else if (s.GivenBody is ConcreteSyntaxStatement) {
+ var css = (ConcreteSyntaxStatement)s.GivenBody;
+ if (css.ResolvedStatements.Count == 1 && css.ResolvedStatements[0] is AssignStmt) {
+ s.BodyAssign = (AssignStmt)css.ResolvedStatements[0];
+ }
+ }
+ if (s.BodyAssign == null) {
+ Error(s, "update statement inside foreach must be a single assignment statement");
} else {
- Error(s, "assignment inside foreach must assign to a field of the bound variable of the foreach statement");
+ FieldSelectExpr lhs = s.BodyAssign.Lhs as FieldSelectExpr;
+ IdentifierExpr obj = lhs == null ? null : lhs.Obj as IdentifierExpr;
+ if (obj == null || obj.Var != s.BoundVar) {
+ Error(s, "assignment inside foreach must assign to a field of the bound variable of the foreach statement");
+ } else {
+ var rhs = s.BodyAssign.Rhs as ExprRhs;
+ if (rhs != null && rhs.Expr is UnaryExpr && ((UnaryExpr)rhs.Expr).Op == UnaryExpr.Opcode.SetChoose) {
+ Error(s, "foreach statement does not support 'choose' statements");
+ }
+ }
}
scope.PopMarker();
@@ -1682,15 +1696,6 @@ namespace Microsoft.Dafny { }
}
- // resolve any local variables declared here
- foreach (AutoVarDecl local in s.NewVars) {
- // first, fix up the local variables to be ghost variable if the corresponding formal out-parameter is a ghost
- if (s.IsGhost || callee != null && local.Index < callee.Outs.Count && callee.Outs[local.Index].IsGhost) {
- local.MakeGhost();
- }
- ResolveStatement(local, specContextOnly, method);
- }
-
// resolve left-hand side
Dictionary<string, object> lhsNameSet = new Dictionary<string, object>();
foreach (IdentifierExpr lhs in s.Lhs) {
@@ -1758,7 +1763,11 @@ namespace Microsoft.Dafny { if (!UnifyTypes(cce.NonNull(lhs.Type), st)) {
Error(s, "incorrect type of method out-parameter {0} (expected {1}, got {2})", i, st, lhs.Type);
} else if (!specContextOnly && !cce.NonNull(lhs.Var).IsGhost && (s.IsGhost || callee.Outs[i].IsGhost)) {
- Error(s, "actual out-parameter {0} is required to be a ghost variable", i);
+ if (lhs is AutoGhostIdentifierExpr && lhs.Var is VarDecl) {
+ ((VarDecl)lhs.Var).MakeGhost();
+ } else {
+ Error(s, "actual out-parameter {0} is required to be a ghost variable", i);
+ }
}
}
diff --git a/Source/Dafny/Scanner.cs b/Source/Dafny/Scanner.cs index 3f9106f8..ba5a745d 100644 --- a/Source/Dafny/Scanner.cs +++ b/Source/Dafny/Scanner.cs @@ -211,8 +211,8 @@ public class UTF8Buffer: Buffer { public class Scanner {
const char EOL = '\n';
const int eofSym = 0; /* pdt */
- const int maxT = 109;
- const int noSym = 109;
+ const int maxT = 106;
+ const int noSym = 106;
[ContractInvariantMethod]
@@ -522,29 +522,26 @@ public class Scanner { case "new": t.kind = 52; break;
case "choose": t.kind = 56; break;
case "havoc": t.kind = 57; break;
- case "ghostXYZXYZ": t.kind = 58; break;
- case "varXYZXYZ": t.kind = 59; break;
- case "if": t.kind = 60; break;
- case "else": t.kind = 61; break;
- case "while": t.kind = 62; break;
- case "invariant": t.kind = 63; break;
- case "callXYZXYZ": t.kind = 64; break;
- case "foreach": t.kind = 65; break;
- case "in": t.kind = 66; break;
- case "assert": t.kind = 67; break;
- case "assume": t.kind = 68; break;
- case "use": t.kind = 69; break;
- case "print": t.kind = 70; break;
- case "false": t.kind = 94; break;
- case "true": t.kind = 95; break;
- case "null": t.kind = 96; break;
- case "this": t.kind = 97; break;
- case "fresh": t.kind = 98; break;
- case "allocated": t.kind = 99; break;
- case "old": t.kind = 100; break;
- case "then": t.kind = 101; break;
- case "forall": t.kind = 103; break;
- case "exists": t.kind = 105; break;
+ case "if": t.kind = 58; break;
+ case "else": t.kind = 59; break;
+ case "while": t.kind = 60; break;
+ case "invariant": t.kind = 61; break;
+ case "foreach": t.kind = 62; break;
+ case "in": t.kind = 63; break;
+ case "assert": t.kind = 64; break;
+ case "assume": t.kind = 65; break;
+ case "use": t.kind = 66; break;
+ case "print": t.kind = 67; break;
+ case "false": t.kind = 91; break;
+ case "true": t.kind = 92; break;
+ case "null": t.kind = 93; break;
+ case "this": t.kind = 94; break;
+ case "fresh": t.kind = 95; break;
+ case "allocated": t.kind = 96; break;
+ case "old": t.kind = 97; break;
+ case "then": t.kind = 98; break;
+ case "forall": t.kind = 100; break;
+ case "exists": t.kind = 102; break;
default: break;
}
}
@@ -673,61 +670,61 @@ public class Scanner { if (ch == '>') {AddCh(); goto case 30;}
else {goto case 0;}
case 30:
- {t.kind = 71; break;}
+ {t.kind = 68; break;}
case 31:
- {t.kind = 72; break;}
+ {t.kind = 69; break;}
case 32:
- {t.kind = 73; break;}
+ {t.kind = 70; break;}
case 33:
- {t.kind = 74; break;}
+ {t.kind = 71; break;}
case 34:
if (ch == '&') {AddCh(); goto case 35;}
else {goto case 0;}
case 35:
- {t.kind = 75; break;}
+ {t.kind = 72; break;}
case 36:
- {t.kind = 76; break;}
+ {t.kind = 73; break;}
case 37:
- {t.kind = 77; break;}
+ {t.kind = 74; break;}
case 38:
- {t.kind = 78; break;}
+ {t.kind = 75; break;}
case 39:
- {t.kind = 81; break;}
+ {t.kind = 78; break;}
case 40:
- {t.kind = 82; break;}
+ {t.kind = 79; break;}
case 41:
- {t.kind = 83; break;}
+ {t.kind = 80; break;}
case 42:
if (ch == 'n') {AddCh(); goto case 43;}
else {goto case 0;}
case 43:
- {t.kind = 84; break;}
+ {t.kind = 81; break;}
case 44:
- {t.kind = 85; break;}
+ {t.kind = 82; break;}
case 45:
- {t.kind = 86; break;}
+ {t.kind = 83; break;}
case 46:
- {t.kind = 87; break;}
+ {t.kind = 84; break;}
case 47:
- {t.kind = 88; break;}
+ {t.kind = 85; break;}
case 48:
- {t.kind = 89; break;}
+ {t.kind = 86; break;}
case 49:
- {t.kind = 90; break;}
+ {t.kind = 87; break;}
case 50:
- {t.kind = 91; break;}
+ {t.kind = 88; break;}
case 51:
- {t.kind = 93; break;}
+ {t.kind = 90; break;}
case 52:
- {t.kind = 102; break;}
+ {t.kind = 99; break;}
case 53:
- {t.kind = 104; break;}
+ {t.kind = 101; break;}
case 54:
- {t.kind = 106; break;}
+ {t.kind = 103; break;}
case 55:
- {t.kind = 107; break;}
+ {t.kind = 104; break;}
case 56:
- {t.kind = 108; break;}
+ {t.kind = 105; break;}
case 57:
recEnd = pos; recKind = 16;
if (ch == '>') {AddCh(); goto case 25;}
@@ -755,19 +752,19 @@ public class Scanner { if (ch == '.') {AddCh(); goto case 52;}
else {t.kind = 55; break;}
case 63:
- recEnd = pos; recKind = 92;
+ recEnd = pos; recKind = 89;
if (ch == '=') {AddCh(); goto case 40;}
else if (ch == '!') {AddCh(); goto case 41;}
else if (ch == 'i') {AddCh(); goto case 42;}
- else {t.kind = 92; break;}
+ else {t.kind = 89; break;}
case 64:
- recEnd = pos; recKind = 79;
+ recEnd = pos; recKind = 76;
if (ch == '>') {AddCh(); goto case 32;}
- else {t.kind = 79; break;}
+ else {t.kind = 76; break;}
case 65:
- recEnd = pos; recKind = 80;
+ recEnd = pos; recKind = 77;
if (ch == '=') {AddCh(); goto case 29;}
- else {t.kind = 80; break;}
+ else {t.kind = 77; break;}
}
t.val = new String(tval, 0, tlen);
diff --git a/Source/Dafny/Translator.cs b/Source/Dafny/Translator.cs index 04fd4eef..28281820 100644 --- a/Source/Dafny/Translator.cs +++ b/Source/Dafny/Translator.cs @@ -3433,9 +3433,6 @@ namespace Microsoft.Dafny { Contract.Requires(etran != null);
Expression receiver = actualReceiver == null ? s.Receiver : new BoogieWrapper(actualReceiver);
- foreach (VarDecl local in s.NewVars) {
- TrStmt(local, builder, locals, etran);
- }
AddComment(builder, s, actualReceiver == null ? "call statement" : "init call statement");
Bpl.ExprSeq ins = new Bpl.ExprSeq();
Contract.Assert(s.Method != null); // follows from the fact that stmt has been successfully resolved
|