summaryrefslogtreecommitdiff
path: root/Source/Dafny/Printer.cs
diff options
context:
space:
mode:
authorGravatar leino <unknown>2015-08-10 18:06:04 -0700
committerGravatar leino <unknown>2015-08-10 18:06:04 -0700
commit2a921fb2a765d91bba47901144845b0102edbcbb (patch)
tree9077a569c7332a623dce21af589b177676191429 /Source/Dafny/Printer.cs
parentc978cd18f8dfba5bfac92af792041c5b4756de5a (diff)
Added routine OneAttributeToString to pretty printer
Diffstat (limited to 'Source/Dafny/Printer.cs')
-rw-r--r--Source/Dafny/Printer.cs25
1 files changed, 18 insertions, 7 deletions
diff --git a/Source/Dafny/Printer.cs b/Source/Dafny/Printer.cs
index 1c7508eb..1fa90e41 100644
--- a/Source/Dafny/Printer.cs
+++ b/Source/Dafny/Printer.cs
@@ -109,6 +109,15 @@ namespace Microsoft.Dafny {
}
}
+ public static string OneAttributeToString(Attributes a) {
+ Contract.Requires(a != null);
+ using (var wr = new System.IO.StringWriter()) {
+ var pr = new Printer(wr);
+ pr.PrintOneAttribute(a);
+ return ToStringWithoutNewline(wr);
+ }
+ }
+
public static string ToStringWithoutNewline(System.IO.StringWriter wr) {
Contract.Requires(wr != null);
var sb = wr.GetStringBuilder();
@@ -429,14 +438,16 @@ namespace Microsoft.Dafny {
public void PrintAttributes(Attributes a) {
if (a != null) {
PrintAttributes(a.Prev);
-
- wr.Write(" {{:{0}", a.Name);
- if (a.Args != null)
- {
- PrintAttributeArgs(a.Args, false);
- }
- wr.Write("}");
+ PrintOneAttribute(a);
+ }
+ }
+ public void PrintOneAttribute(Attributes a) {
+ Contract.Requires(a != null);
+ wr.Write(" {{:{0}", a.Name);
+ if (a.Args != null) {
+ PrintAttributeArgs(a.Args, false);
}
+ wr.Write("}");
}
public void PrintAttributeArgs(List<Expression> args, bool isFollowedBySemicolon) {