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

VladD2 svnadmin at nemerle.org
Mon Jul 24 00:22:59 CEST 2006


Log:
Fix the method location.

Author: VladD2
Date: Mon Jul 24 00:22:57 2006
New Revision: 6467

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	Mon Jul 24 00:22:57 2006
@@ -659,7 +659,8 @@
     
     ParseClassMember () : ClassMember
     {
-      match (get_token ()) {
+      def start_tok = get_token ();
+      match (start_tok) {
         | Token.LooseGroup (toks) =>
           push_stream (toks);
           mutable customs = get_customs ();
@@ -700,7 +701,7 @@
                 if (is_property)
                   parse_property (mods, customs, id, ret_type, parms, typarms)
                 else {
-                  def header = Fun_header (tok.Location + ret_type.Location,
+                  def header = Fun_header (start_tok.Location + ret_type.Location,
                                            name = id,
                                            ret_type = ret_type, 
                                            parms = parms, 
@@ -713,7 +714,7 @@
               | Token.Keyword ("this") =>
                 shift ();
                 def parms = parse_parameters ();                
-                def header = Fun_header (tok.Location,
+                def header = Fun_header (start_tok.Location + tok.Location,
                                          name = Splicable.Name (mkname (".ctor")),
                                          ret_type = PExpr.Void (),
                                          parms = parms,
@@ -758,10 +759,13 @@
 
       parse_top_extensions (modifiers, MacroTargets.Method);
         
+      mutable loc = h.loc;
+      
       def body =
         match (peek_token ()) {
           | Token.BracesGroup as brac => 
             shift ();
+            loc += brac.Location;
             // we skip body parsing in completion mode,
             // to save time and ignore errors
             if (Manager.IsInCompletionMode)
@@ -769,9 +773,13 @@
             else
               FunBody.Parsed (parse_block (brac, h.parms))
 
-          | Token.EndOfGroup => FunBody.Abstract ()
+          | Token.EndOfGroup as tok =>
+            loc += tok.Location;
+            FunBody.Abstract ()
           | Token.Operator ("$") =>
-            def result = FunBody.Parsed (parse_spliced_expr ());
+            def expr = parse_spliced_expr ();
+            loc += expr.Location;
+            def result = FunBody.Parsed (expr);
             new_group_beginning ();
             result
 
@@ -779,7 +787,7 @@
         };
 
       ClassMember.Function (header = h, name = h.name, modifiers = modifiers, 
-                            loc = h.loc, body = body, kind = FunKind.Method (impl))
+                            loc = loc, body = body, kind = FunKind.Method (impl))
     }
 
     parse_option (modifiers : Modifiers) : ClassMember



More information about the svn mailing list