[svn] r7628: nemerle/trunk/ncc/parsing/MainParser.n

kliss svnadmin at nemerle.org
Sun Apr 29 20:28:36 CEST 2007


Log:
Finish work on exception handlers' locations. Now they are accurate.

Author: kliss
Date: Sun Apr 29 20:28:26 2007
New Revision: 7628

Modified:
   nemerle/trunk/ncc/parsing/MainParser.n

Modified: nemerle/trunk/ncc/parsing/MainParser.n
==============================================================================
--- nemerle/trunk/ncc/parsing/MainParser.n	(original)
+++ nemerle/trunk/ncc/parsing/MainParser.n	Sun Apr 29 20:28:26 2007
@@ -2179,56 +2179,54 @@
             when (flag_sibling_keyword ("catch")) {
               def mktry (h : MatchCase, cases) 
               {
-                // Getting combined location of patterns.
-                def pattersLocation = h.patterns.Map(_.Location).Fold(Location.Default, (loc, acc) => acc.Combine(loc));
                 match (h.patterns) 
                 {
-                  | [PExpr.TypeEnforcement (PExpr.Wildcard, t)] =>
-                    Message.Warning (602, pattersLocation, "using ``:'' as a type tests is "
+                  | [PExpr.TypeEnforcement (PExpr.Wildcard as wc, t)] =>
+                    Message.Warning (602, wc.Location, "using ``:'' as a type tests is "
                                      "deprecated, please use ``is'' instead");
-                    TryCase.Catch (Splicable.Name (pattersLocation, mkname (Util.tmpname ("u"))), t, h.body) :: cases
+                    TryCase.Catch (Splicable.Name (wc.Location, mkname (Util.tmpname ("u"))), t, h.body) :: cases
                   
-                  | [PExpr.Is (PExpr.Wildcard, t)] =>
-                    TryCase.Catch (Splicable.Name (pattersLocation, mkname (Util.tmpname ("u"))), t, h.body) :: cases
+                  | [PExpr.Is (PExpr.Wildcard as wc, t)] =>
+                    TryCase.Catch (Splicable.Name (wc.Location, mkname (Util.tmpname ("u"))), t, h.body) :: cases
 
-                  | [<[ _ is $t when $cond ]>] =>
-                    TryCase.Filter (Splicable.Name (pattersLocation, mkname (Util.tmpname ("u"))), t, cond, h.body) :: cases
+                  | [<[ $var is $t when $cond ]>] when var is PExpr.Wildcard =>
+                    TryCase.Filter (Splicable.Name (var.Location, mkname (Util.tmpname ("u"))), t, cond, h.body) :: cases
 
-                  | [PExpr.TypeEnforcement (PExpr.Ref (id), t)] =>
-                    Message.Warning (602, pattersLocation, "using ``:'' as a type tests is "
+                  | [PExpr.TypeEnforcement (PExpr.Ref (Location = loc,  name = id), t)] =>
+                    Message.Warning (602, loc, "using ``:'' as a type tests is "
                                      "deprecated, please use ``is'' instead");
-                    TryCase.Catch (Splicable.Name (id), t, h.body) :: cases
+                    TryCase.Catch (Splicable.Name (loc, id), t, h.body) :: cases
 
-                  | [PExpr.Is (PExpr.Ref (id), t)] =>
-                    TryCase.Catch (Splicable.Name (pattersLocation, id), t, h.body) :: cases
+                  | [PExpr.Is (PExpr.Ref (Location = loc, name = id), t)] =>
+                    TryCase.Catch (Splicable.Name (loc, id), t, h.body) :: cases
 
-                  | [<[ $(PExpr.Ref(id)) is $t when $cond ]>] =>
-                    TryCase.Filter (Splicable.Name (pattersLocation, id), t, cond, h.body) :: cases
+                  | [<[ $(PExpr.Ref(Location = loc, name = id)) is $t when $cond ]>] =>
+                    TryCase.Filter (Splicable.Name (loc, id), t, cond, h.body) :: cases
 
-                  | [PExpr.Ref (id)] =>
-                    TryCase.Catch (Splicable.Name (pattersLocation, id), <[ System.Exception ]>, h.body) :: cases
+                  | [PExpr.Ref (Location = loc, name = id)] =>
+                    TryCase.Catch (Splicable.Name (loc, id), <[ System.Exception ]>, h.body) :: cases
 
-                  | [<[ $(PExpr.Ref(id)) when $cond ]>] =>
-                    TryCase.Filter (Splicable.Name (pattersLocation, id), <[ System.Exception ]>, cond, h.body) :: cases
+                  | [<[ $(PExpr.Ref(Location = loc, name = id)) when $cond ]>] =>
+                    TryCase.Filter (Splicable.Name (loc, id), <[ System.Exception ]>, cond, h.body) :: cases
 
-                  | [PExpr.Wildcard] =>
-                    TryCase.Catch (Splicable.Name (pattersLocation, mkname (Util.tmpname ("u"))), 
+                  | [PExpr.Wildcard as wc]=>
+                    TryCase.Catch (Splicable.Name (wc.Location, mkname (Util.tmpname ("u"))), 
                                    <[ System.Exception ]>, h.body) :: cases
 
-                  | [<[ _ when $cond ]>] =>
-                    TryCase.Filter (Splicable.Name (pattersLocation, mkname (Util.tmpname ("u"))),
+                  | [<[ $var when $cond ]>] when var is PExpr.Wildcard =>
+                    TryCase.Filter (Splicable.Name (var.Location, mkname (Util.tmpname ("u"))),
                                     <[ System.Exception ]>, cond, h.body) :: cases
 
-                  | [PExpr.TypeEnforcement (PExpr.Spliced (id), t)] =>
-                    Message.Warning (602, pattersLocation, "using ``:'' as a type tests is "
+                  | [PExpr.TypeEnforcement (PExpr.Spliced (Location = loc, body = id), t)] =>
+                    Message.Warning (602, loc, "using ``:'' as a type tests is "
                                      "deprecated, please use ``is'' instead");
                     TryCase.Catch (Splicable.Expression (id), t, h.body) :: cases
 
-                  | [PExpr.Is (PExpr.Spliced (id), t)] =>
-                    TryCase.Catch (Splicable.Expression (pattersLocation, id), t, h.body) :: cases
+                  | [PExpr.Is (PExpr.Spliced (Location = loc, body = id), t)] =>
+                    TryCase.Catch (Splicable.Expression (loc, id), t, h.body) :: cases
 
-                  | [<[ $(PExpr.Spliced(id)) is $t when $cond ]>] =>
-                    TryCase.Filter (Splicable.Expression (pattersLocation, id), t, cond, h.body) :: cases
+                  | [<[ $(PExpr.Spliced(Location = loc, body = id)) is $t when $cond ]>] =>
+                    TryCase.Filter (Splicable.Expression (loc, id), t, cond, h.body) :: cases
 
                   | _ =>
                     Message.Error (h.body.Location, "exception catch pattern must"



More information about the svn mailing list