[svn] r6140: nemerle/trunk/ncc: parsing/PreParser.n testsuite/positive/parser.n

nazgul svnadmin at nemerle.org
Mon Feb 27 18:29:53 CET 2006


Log:
Do not cut current group when encounter } inside () or []

Author: nazgul
Date: Mon Feb 27 18:29:50 2006
New Revision: 6140

Added:
   nemerle/trunk/ncc/testsuite/positive/parser.n
Modified:
   nemerle/trunk/ncc/parsing/PreParser.n

Modified: nemerle/trunk/ncc/parsing/PreParser.n
==============================================================================
--- nemerle/trunk/ncc/parsing/PreParser.n	(original)
+++ nemerle/trunk/ncc/parsing/PreParser.n	Mon Feb 27 18:29:50 2006
@@ -177,11 +177,12 @@
 
         Throws PreParserException when there is unmatched end bracket.
      */
-    handle_default_token (current_begin : int, tok : Token) : void {
+    handle_default_token (current_begin : int, tok : Token, braces_cut_current = true) : void {
       match (tok) {
         | Token.BeginBrace =>
           def brace_group = parse_brace_group (tok.Location);
           current_stream.Add (brace_group);
+          when (braces_cut_current)
           finish_current (current_begin);
 
         | Token.BeginRound =>
@@ -268,7 +269,7 @@
             finish_current (current_begin);
             loop ()
 
-          | _ => handle_default_token (current_begin, tok); loop ()
+          | _ => handle_default_token (current_begin, tok, false); loop ()
         }
       }
       try { loop () }
@@ -296,7 +297,7 @@
           // finish current loose group
           | Token.Comma => finish_current (current_begin); loop ()
 
-          | _ => handle_default_token (current_begin, tok); loop ()
+          | _ => handle_default_token (current_begin, tok, false); loop ()
         }
       }
       try { loop () }

Added: nemerle/trunk/ncc/testsuite/positive/parser.n
==============================================================================
--- (empty file)
+++ nemerle/trunk/ncc/testsuite/positive/parser.n	Mon Feb 27 18:29:50 2006
@@ -0,0 +1,60 @@
+
+class Increment
+{
+  Item [x : uint] : uint {
+    get { x }
+  }
+
+  public static Run() : void
+  {
+    mutable x : uint = 1;
+
+    x = 1;
+    System.Console.Write("Val: {0}", {x++; x});
+    System.Console.WriteLine(", End: {0}", x);
+
+    x = 1;
+    System.Console.Write("Val: {0}", {++x; x});
+    System.Console.WriteLine(", End: {0}", x);
+
+    x = 1;
+    System.Console.Write("Add: {0}", {x++; x} + {x++; x});
+    System.Console.WriteLine(", End: {0}", x);
+
+    x = 1;
+    System.Console.Write("Add: {0}", {++x; x} + {++x; x});
+    System.Console.WriteLine(", End: {0}", x);
+
+    x = 1;
+    System.Console.Write("Add: {0}", Add({x++; x}, {x++; x}));
+    System.Console.WriteLine(", End: {0}", x);
+
+    x = 1;
+    System.Console.Write("Add: {0}", Add({++x; x}, {++x; x}));
+    System.Console.WriteLine(", End: {0}", x);
+
+    x = 1;
+    System.Console.Write("Add: {0}", Increment() [{++x; x} + {++x; x}]);
+    System.Console.WriteLine(", End: {0}", x);
+  }
+
+  static Add(a : uint, b : uint) : uint
+  {
+    a + b;
+  }
+}
+
+Increment.Run();
+
+
+/*
+BEGIN-OUTPUT
+Val: 2, End: 2
+Val: 2, End: 2
+Add: 5, End: 3
+Add: 5, End: 3
+Add: 5, End: 3
+Add: 5, End: 3
+Add: 5, End: 3
+END-OUTPUT
+*/



More information about the svn mailing list