[svn] r6904: nemerle/trunk/ncc/parsing/Lexer.n

IT svnadmin at nemerle.org
Thu Nov 16 01:27:05 CET 2006


Log:
Fixed string location.

Author: IT
Date: Thu Nov 16 01:27:03 2006
New Revision: 6904

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

Modified: nemerle/trunk/ncc/parsing/Lexer.n
==============================================================================
--- nemerle/trunk/ncc/parsing/Lexer.n	(original)
+++ nemerle/trunk/ncc/parsing/Lexer.n	Thu Nov 16 01:27:03 2006
@@ -801,6 +801,7 @@
   
   protected get_string (end_ch : char, is_dollarized : bool) : Token.StringLiteral
   {
+    mutable tok;
     def buf = StringBuilder ();
     def loop () {
       match (read ()) {
@@ -826,7 +827,11 @@
           loop ();
           
         | _ =>
+          tok = Token.StringLiteral (buf.ToString ());
+          tok.Location = Location (file_idx, 0, 0, line, col);
+
           when (eat_whitespace () && peek_or_white () == end_ch) {
+            tok = null;
             ignore_comments ();
             _ = read ();
             loop ();
@@ -835,7 +840,10 @@
     }
     loop ();
      
+    if (tok == null)
     Token.StringLiteral (buf.ToString ())
+    else
+      tok;
   }
 
   protected get_monkey_string () : Token
@@ -1090,7 +1098,12 @@
         def last_line = line;
         def last_col = col;
         def tok = do_get_token ();
+
+        // IT: to make last_line & last_col as class fields could be a better solution.
+        if (tok.Location.FileIndex == 0)
         tok.Location = Location (file_idx, last_line, last_col, line, col);
+        else
+          tok.Location = Location (file_idx, last_line, last_col, tok.Location.EndLine, tok.Location.EndColumn);
         tok
       }
     }



More information about the svn mailing list