[svn] r5864: nemerle/trunk/ncc: parsing/Lexer.n parsing/PreParserIndent.n testsuite/positive/indentation-s...

malekith svnadmin at nemerle.org
Sun Oct 30 10:22:10 CET 2005


Log:
Fix problems with string literals in indentation syntax.

Author: malekith
Date: Sun Oct 30 10:22:09 2005
New Revision: 5864

Modified:
   nemerle/trunk/ncc/parsing/Lexer.n
   nemerle/trunk/ncc/parsing/PreParserIndent.n
   nemerle/trunk/ncc/testsuite/positive/indentation-syntax.n

Modified: nemerle/trunk/ncc/parsing/Lexer.n
==============================================================================
--- nemerle/trunk/ncc/parsing/Lexer.n	(original)
+++ nemerle/trunk/ncc/parsing/Lexer.n	Sun Oct 30 10:22:09 2005
@@ -1549,13 +1549,14 @@
     indentString = "";
   }
   
-  override protected read () : char
+  override protected do_read () : char
   {
-    def ch = base.read ();
-    //Message.Debug (Location (file_idx, line, col), $"ch = $ch");
+    def ch = base.do_read ();
+    // Message.Debug (Location, $"ch = '$ch'");
     
     // Start counting indentation anew after a newline
     if (ch == '\n' || ch == '\r') {
+      // Message.Debug (Location, $"start");
       indentString = "";
       countingIndentation = true;
       //Message.Debug (Location (file_idx, line, col), "countingIndentation ON");
@@ -1566,7 +1567,7 @@
       // We have a non-space character, so stop counting indentation
       //  and indicate that we have a new line to process
       else {
-        //Message.Debug (Location (file_idx, line, col), $"countingIndentation OFF: indentColNew = $indentColNew");
+        // Message.Debug (Location, $"stop");
         countingIndentation = false;
         insert_indent = true;
       }
@@ -1589,18 +1590,15 @@
       def tok = tokPending;
       tokPending = null;
       tok;
-    }
-    else {
-      def tok = base.GetToken ();
+    } else {
+      unless (isPendingChar)
+        _ = eat_whitespace ();
+      
       if (insert_indent) {
-        tokPending = tok;
         insert_indent = false;
-        mutable tokIndent = Token.Indent (indentString);
-        tokIndent.Location = insertLocation;
-        tokIndent;
-      }
-      else
-        tok;
+        Token.Indent (insertLocation, indentString)
+      } else 
+        base.GetToken ()
     }
   }
 } // LexerFileIndent

Modified: nemerle/trunk/ncc/parsing/PreParserIndent.n
==============================================================================
--- nemerle/trunk/ncc/parsing/PreParserIndent.n	(original)
+++ nemerle/trunk/ncc/parsing/PreParserIndent.n	Sun Oct 30 10:22:09 2005
@@ -153,7 +153,9 @@
         last_token = null;
         result;
       } else if (! tokens_pending.IsEmpty) {
-        tokens_pending.Take ()
+        def t = tokens_pending.Take ();
+        //Message.Debug ($ "tok: $t");
+        t
       }
       else {
         try {
@@ -179,17 +181,18 @@
       }
     }
 
-    #if false
-    display_space (s : string) : string
+    #pragma warning disable 10003
+    static display_space (s : string) : string
     {
       s.Replace (" ", "S").Replace("\t", "T")
     }
-    #endif
+    #pragma warning restore 10003
 
     get_token_after_indent (tok : Token, new_indent : string = "") : Token
     {
       match (tok) {
         | Token.Indent (value) =>
+          //Message.Debug ($"tok indent: $(display_space(value))");
           insertLocation = tok.Location;
           get_token_after_indent (lexer.GetToken (), value)
           
@@ -207,6 +210,7 @@
 
           // If we have not unindented
           if (new_indent.Length >= CurrentIndent.Length) {
+            //Message.Debug ($ "ni=$(display_space(new_indent)) ci=$(display_space(CurrentIndent))");
             // Make sure that the beginning of the new indent string
             //  starts with the contents of the current indent string.
             when (!new_indent.StartsWith (CurrentIndent)) {

Modified: nemerle/trunk/ncc/testsuite/positive/indentation-syntax.n
==============================================================================
--- nemerle/trunk/ncc/testsuite/positive/indentation-syntax.n	(original)
+++ nemerle/trunk/ncc/testsuite/positive/indentation-syntax.n	Sun Oct 30 10:22:09 2005
@@ -44,6 +44,13 @@
           | "bar" => {}
           | "foo" => {}
           | _ => {}
+        _ = 
+          match ("foo")
+            | "bar" => "bar"
+            | "foo" => 
+              "qux"
+            | _ =>
+              "fix"
         WriteLine($"c = $c, d = $d")
         WriteLine(SomeField)
 



More information about the svn mailing list