summaryrefslogtreecommitdiff
path: root/Source/Dafny
diff options
context:
space:
mode:
authorGravatar Nadia Polikarpova <nadia.polikarpova@gmail.com>2012-09-14 14:58:21 +0200
committerGravatar Nadia Polikarpova <nadia.polikarpova@gmail.com>2012-09-14 14:58:21 +0200
commit6bb857d27340108c2b89b916d326a2bab4cdfd52 (patch)
treec0e54880f9291ac7ce71c12cd2234d0ce017552b /Source/Dafny
parent745dca0d21549daa267b0f7d8a7cbb87697d9c99 (diff)
Pretty-print calc statements
Diffstat (limited to 'Source/Dafny')
-rw-r--r--Source/Dafny/Printer.cs23
1 files changed, 23 insertions, 0 deletions
diff --git a/Source/Dafny/Printer.cs b/Source/Dafny/Printer.cs
index 24941ce1..627ec1b5 100644
--- a/Source/Dafny/Printer.cs
+++ b/Source/Dafny/Printer.cs
@@ -8,6 +8,7 @@ using System.IO;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Numerics;
+using System.Linq;
using Bpl = Microsoft.Boogie;
namespace Microsoft.Dafny {
@@ -559,6 +560,28 @@ namespace Microsoft.Dafny {
}
PrintStatement(s.Body, indent);
+ } else if (stmt is CalcStmt) {
+ CalcStmt s = (CalcStmt)stmt;
+ wr.Write("calc");
+ wr.WriteLine(" {");
+ int stepInd = indent + IndentAmount;
+ Indent(stepInd);
+ PrintExpression(s.Steps[0], stepInd);
+ wr.WriteLine(";");
+ var pairs = s.Hints.Zip(s.Steps.Skip(1), (h, e) => Tuple.Create(h, e));
+ foreach (var pair in pairs) {
+ if (pair.Item1 != null) {
+ Indent(stepInd);
+ PrintStatement(pair.Item1, stepInd);
+ wr.WriteLine();
+ }
+ Indent(stepInd);
+ PrintExpression(pair.Item2, stepInd);
+ wr.WriteLine(";");
+ }
+ Indent(indent);
+ wr.Write("}");
+
} else if (stmt is MatchStmt) {
MatchStmt s = (MatchStmt)stmt;
wr.Write("match ");