summaryrefslogtreecommitdiff
path: root/Source/Dafny/Util.cs
diff options
context:
space:
mode:
authorGravatar leino <unknown>2014-10-23 21:52:12 -0700
committerGravatar leino <unknown>2014-10-23 21:52:12 -0700
commit40f36d68b8cb9489d052ababada29539c7d8de92 (patch)
tree46b3b65776325e0bb78b5a5bfae1d483fec0485a /Source/Dafny/Util.cs
parent07ac1e4cfe6cdaf73a5bfa8b863728beae2a4c86 (diff)
Allow underscores in numeric literals (and in field/destructor names that are written as numeric strings). The
underscores have no semantic meaning, but can help a human parse the numbers.
Diffstat (limited to 'Source/Dafny/Util.cs')
-rw-r--r--Source/Dafny/Util.cs14
1 files changed, 14 insertions, 0 deletions
diff --git a/Source/Dafny/Util.cs b/Source/Dafny/Util.cs
index bc4017c0..f9421659 100644
--- a/Source/Dafny/Util.cs
+++ b/Source/Dafny/Util.cs
@@ -68,6 +68,20 @@ namespace Microsoft.Dafny {
}
/// <summary>
+ /// Returns s but with all occurrences of '_' removed.
+ /// </summary>
+ public static string RemoveUnderscores(string s) {
+ Contract.Requires(s != null);
+ while (true) {
+ var j = s.IndexOf('_');
+ if (j == -1) {
+ return s;
+ }
+ s = s.Substring(0, j) + s.Substring(j + 1);
+ }
+ }
+
+ /// <summary>
/// For "S" returns S and false.
/// For @"S" return S and true.
/// Assumes that s has one of these forms.