[svn] r7470: nemerle/trunk/ncc/parsing/AST.n nemerle/trunk/ncc/parsing/MainParser.n nemerle/trunk/ncc/pars...

IT svnadmin at nemerle.org
Fri Feb 23 04:34:36 CET 2007


Log:
Working on ExprFinder (try/catch/finally)

Author: IT
Date: Fri Feb 23 04:34:30 2007
New Revision: 7470

Modified:
   nemerle/trunk/ncc/parsing/AST.n
   nemerle/trunk/ncc/parsing/MainParser.n
   nemerle/trunk/ncc/parsing/ParseTree.n
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Content/QuickTip2.n
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Tests.n

Modified: nemerle/trunk/ncc/parsing/AST.n
==============================================================================
--- nemerle/trunk/ncc/parsing/AST.n	(original)
+++ nemerle/trunk/ncc/parsing/AST.n	Fri Feb 23 04:34:30 2007
@@ -383,6 +383,11 @@
       }
     }
 
+    public Combine(l2 : Located) : Location
+    {
+      Combine(l2.Location)
+    }
+
     public Intersect(l2 : Location) : Location
       requires FileIndex == l2.FileIndex || FileIndex == 0 || l2.FileIndex == 0
     {

Modified: nemerle/trunk/ncc/parsing/MainParser.n
==============================================================================
--- nemerle/trunk/ncc/parsing/MainParser.n	(original)
+++ nemerle/trunk/ncc/parsing/MainParser.n	Fri Feb 23 04:34:30 2007
@@ -2232,7 +2232,9 @@
                                              [], mktry);
                   when (cases is [])
                     Error (x, "catch body must have at least one handler");
-                  body = PExpr.Try (loc, body, cases.Rev ());
+                  def l = loc.Combine(body.Location);
+                  def l = cases.FoldLeft(l, (e, l) => l.Combine(e.Location));
+                  body = PExpr.Try (l, body, cases.Rev ());
 
                 | x => Error (x, "expecting handlers of exceptions")
               }
@@ -2240,7 +2242,7 @@
             
             when (flag_sibling_keyword ("finally")) {
               def handler = parse_block ([]);
-              body = PExpr.TryFinally (loc, body, handler);
+              body = PExpr.TryFinally (loc.Combine(handler.Location), body, handler);
             }
             when (body == (try_body : object))
               Message.Error (loc, "expecting `catch' or `finally'");

Modified: nemerle/trunk/ncc/parsing/ParseTree.n
==============================================================================
--- nemerle/trunk/ncc/parsing/ParseTree.n	(original)
+++ nemerle/trunk/ncc/parsing/ParseTree.n	Fri Feb 23 04:34:30 2007
@@ -641,6 +641,16 @@
     | Catch    { exn : Splicable; exn_ty : PExpr; handler : PExpr; }
     | Filter   { exn : Splicable; exn_ty : PExpr; filter : PExpr; handler : PExpr; }
     | Ellipsis { body : PExpr; }
+
+    public Location : Location {
+      get {
+        match (this) {
+          | Catch   (exn, exn_ty, handler)         => exn.Location.Combine(exn_ty).Combine(handler)
+          | Filter  (exn, exn_ty, filter, handler) => exn.Location.Combine(exn_ty).Combine(filter).Combine(handler)
+          | Ellipsis(body)                         => body.Location
+        }
+      }
+    }
   }
 
   public variant SyntaxElement {

Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Content/QuickTip2.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Content/QuickTip2.n	(original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Content/QuickTip2.n	Fri Feb 23 04:34:30 2007
@@ -10,6 +10,22 @@
 
   public class Class1
   {
+    TryCatch() : void
+    {
+      try
+      {
+        def bbb /*035:-2*/ = "".ToString();
+      }
+      catch
+      {
+      | ex => ex /*034:-2*/.ToString();
+      }
+      finally
+      {
+        def aaa /*032:-2*/ = "". ToString /*033:-2*/();
+      }
+    }
+
     ParamTest( arr /*031:-2*/ : array[int]) : void
     {
       def bar(bbb /*030:-2*/: array[int] /*027:-2*/) {}

Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Tests.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Tests.n	(original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Tests.n	Fri Feb 23 04:34:30 2007
@@ -38,6 +38,10 @@
           Assert.AreEqual(len, result.ColEnd - result.ColStart);
       }
 
+      test("035",  3, "bbb");
+      test("034",  2, "ex");
+      test("033",  8, "ToString");
+      test("032",  3, "aaa");
       test("031",  3, "arr");
       test("030",  3, "bbb");
       test("029",  1, "y");



More information about the svn mailing list