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

NoiseEHC svnadmin at nemerle.org
Thu Apr 27 14:36:14 CEST 2006


Log:
fixed -1 comment beginning error (hack, Nazgul may write it correctly)

Author: NoiseEHC
Date: Thu Apr 27 14:36:12 2006
New Revision: 6202

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 Apr 27 14:36:12 2006
@@ -1991,6 +1991,7 @@
     mutable begin_pos = pos;
     def loop (c) {
       | ' ' | '\t' | '\r' | '\n' =>
+        //System.Diagnostics.Debug.WriteLine("loop(whitespace) " + c.ToString());
         if (pos < reader.Length) {
           ++begin_pos;
           loop (read ())
@@ -1998,26 +1999,38 @@
           SyntaxType.EndOfFile
             
       | '/' =>
+        //System.Diagnostics.Debug.WriteLine("loop(/) " + c.ToString());
         match (comment_beginning (ref state)) {
           | '/' => loop (' ')
-          | _ => SyntaxType.Comment 
+          | _ => 
+            //++begin_pos; // loop (' ') increments in the FUCK case so we have too (but not here, dunno why...)
+            SyntaxType.Comment 
         }
         
       | '#' =>
+        //System.Diagnostics.Debug.WriteLine("loop(#) " + c.ToString());
         throw LexerBase.Error ("preprocessor directives may not occur in"
                                " string programs")
         
-      | _ => --pos; get_token ()
+      | _ =>
+        //System.Diagnostics.Debug.WriteLine("loop(else) " + c.ToString());
+        --pos; get_token ()
     };
     def tok =
-      if (pos >= reader.Length)
+      if (pos >= reader.Length) {
+        //System.Diagnostics.Debug.WriteLine("if (pos >= reader.Length)");
         SyntaxType.EndOfFile
-      else if (state == 1) {
+      } else if (state == 1) {
+        //System.Diagnostics.Debug.WriteLine("} else if (state == 1)");
+        ++begin_pos; // loop (' ') increments in the FUCK case so we have too...
         when (eat_comment ()) state = 0;
         SyntaxType.Comment
       }
       else {
+        //System.Diagnostics.Debug.WriteLine("else {");
         try {
+          //FUCK: because it works as putting an extra char before then everything else has 
+          // to increment begin_pos, and later we have to substract 1
           loop (' ');
         }
         catch {



More information about the svn mailing list