[svn] r7374: nemerle/trunk/ncc: parsing/MainParser.n testsuite/positive/matching.n

nazgul svnadmin at nemerle.org
Sat Feb 3 23:15:29 CET 2007


Log:
Allow short match over several expressions

Author: nazgul
Date: Sat Feb  3 23:15:27 2007
New Revision: 7374

Modified:
   nemerle/trunk/ncc/parsing/MainParser.n
   nemerle/trunk/ncc/testsuite/positive/matching.n

Modified: nemerle/trunk/ncc/parsing/MainParser.n
==============================================================================
--- nemerle/trunk/ncc/parsing/MainParser.n	(original)
+++ nemerle/trunk/ncc/parsing/MainParser.n	Sat Feb  3 23:15:27 2007
@@ -2102,10 +2102,12 @@
           | Token.Keyword ("match") =>
             def expr = 
               match (get_token ()) {
-                | Token.RoundGroup (group) when group != null =>
+                | Token.RoundGroup (group) as whole when group != null =>
+                  loc = loc + whole.Location;
                   match (parse_expr_sequence (group, [])) {
                     | [x] => x
-                    | _ => fatal_error (group.Location, "expecting single expression in `match (..)'");
+                    | [] => fatal_error (group.Location, "expecting expression inside `match (..)'");
+                    | xs => PExpr.Tuple (loc, xs.Reverse ())
                   }
                 | x => fatal_error (x, "expecting non-empty `(..)' after `match'");
               }

Modified: nemerle/trunk/ncc/testsuite/positive/matching.n
==============================================================================
--- nemerle/trunk/ncc/testsuite/positive/matching.n	(original)
+++ nemerle/trunk/ncc/testsuite/positive/matching.n	Sat Feb  3 23:15:27 2007
@@ -1488,6 +1488,12 @@
     Bug534.M.Run ();
 
     Bug826.Program.Go ();
+    
+    match (1,2) {
+      | (1, x) => System.Console.WriteLine (x);
+      | (2, x) => System.Console.WriteLine (x);
+      | _ => ()   
+    }    
   }
 }
 
@@ -1715,5 +1721,6 @@
 ok42
 [3, 4]
 2
+2
 END-OUTPUT
 */



More information about the svn mailing list