diff options
author | Clément Pit--Claudel <clement.pitclaudel@live.com> | 2015-08-18 08:47:40 -0700 |
---|---|---|
committer | Clément Pit--Claudel <clement.pitclaudel@live.com> | 2015-08-18 08:47:40 -0700 |
commit | 108e634af783601c60555c2e8e75775c3b4041ed (patch) | |
tree | b6759e1aa35f6eb8cdef1613d083c25359d9fd9e /Source/Dafny/Triggers/QuantifiersCollector.cs | |
parent | 4b3fc0e7413424e27131dd8dd919423711f097ad (diff) |
Small cleanups, fixes, and refactorings
In particular, start detecting loops between terms that don't look like each
other at the Dafny level, such as {a[x]} and {x in a} (when a is a multiset)
Diffstat (limited to 'Source/Dafny/Triggers/QuantifiersCollector.cs')
-rw-r--r-- | Source/Dafny/Triggers/QuantifiersCollector.cs | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/Source/Dafny/Triggers/QuantifiersCollector.cs b/Source/Dafny/Triggers/QuantifiersCollector.cs new file mode 100644 index 00000000..a43aae7a --- /dev/null +++ b/Source/Dafny/Triggers/QuantifiersCollector.cs @@ -0,0 +1,33 @@ +using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Microsoft.Boogie;
+using System.Collections.ObjectModel;
+using System.Diagnostics.Contracts;
+
+namespace Microsoft.Dafny.Triggers { //FIXME rename this file
+ internal class QuantifierCollector : TopDownVisitor<object> {
+ readonly ErrorReporter reporter;
+ internal List<QuantifiersCollection> quantifierCollections = new List<QuantifiersCollection>();
+
+ public QuantifierCollector(ErrorReporter reporter) {
+ Contract.Requires(reporter != null);
+ this.reporter = reporter;
+ }
+
+ protected override bool VisitOneExpr(Expression expr, ref object st) {
+ var quantifier = expr as QuantifierExpr;
+ if (quantifier != null) {
+ if (quantifier.SplitQuantifier != null) {
+ var collection = quantifier.SplitQuantifier.Select(q => q as QuantifierExpr).Where(q => q != null);
+ quantifierCollections.Add(new QuantifiersCollection(collection, reporter));
+ return false;
+ } else {
+ quantifierCollections.Add(new QuantifiersCollection(Enumerable.Repeat(quantifier, 1), reporter));
+ }
+ }
+ return true;
+ }
+ }
+}
|