summaryrefslogtreecommitdiff
path: root/Source/Dafny/Parser.cs
diff options
context:
space:
mode:
authorGravatar qunyanm <unknown>2015-05-15 11:29:44 -0700
committerGravatar qunyanm <unknown>2015-05-15 11:29:44 -0700
commitbe103552b0a81d48afcc7883ca48d9b5194e63f8 (patch)
tree33a0fa7dc3b9a3c7ce6cf81b9e5edd23d1a9a341 /Source/Dafny/Parser.cs
parent454909184e73582e425cad56a526956d91b88dcc (diff)
Fix issue #79. Allow tuple pattern matching with parenthesis only.
Diffstat (limited to 'Source/Dafny/Parser.cs')
-rw-r--r--Source/Dafny/Parser.cs21
1 files changed, 20 insertions, 1 deletions
diff --git a/Source/Dafny/Parser.cs b/Source/Dafny/Parser.cs
index d0924169..162e23a3 100644
--- a/Source/Dafny/Parser.cs
+++ b/Source/Dafny/Parser.cs
@@ -2934,7 +2934,7 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
Ident(out id);
Expect(48);
arguments = new List<CasePattern>();
- if (la.kind == 1) {
+ if (la.kind == 1 || la.kind == 48) {
CasePattern(out pat);
arguments.Add(pat);
while (la.kind == 21) {
@@ -2945,6 +2945,25 @@ List<Expression/*!*/>/*!*/ decreases, ref Attributes decAttrs, ref Attributes mo
}
Expect(49);
pat = new CasePattern(id, id.val, arguments);
+ } else if (la.kind == 48) {
+ Get();
+ id = t;
+ arguments = new List<CasePattern>();
+
+ if (la.kind == 1 || la.kind == 48) {
+ CasePattern(out pat);
+ arguments.Add(pat);
+ while (la.kind == 21) {
+ Get();
+ CasePattern(out pat);
+ arguments.Add(pat);
+ }
+ }
+ Expect(49);
+ theBuiltIns.TupleType(id, arguments.Count, true); // make sure the tuple type exists
+ string ctor = BuiltIns.TupleTypeCtorName; //use the TupleTypeCtors
+ pat = new CasePattern(id, ctor, arguments);
+
} else if (la.kind == 1) {
IdentTypeOptional(out bv);
pat = new CasePattern(bv.tok, bv);