[svn] r5857: nemerle/trunk/ncc/parsing/PreParserIndent.n

malekith svnadmin at nemerle.org
Thu Oct 27 10:19:47 CEST 2005


Log:
Kill current_indent.

Author: malekith
Date: Thu Oct 27 10:19:46 2005
New Revision: 5857

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

Modified: nemerle/trunk/ncc/parsing/PreParserIndent.n
==============================================================================
--- nemerle/trunk/ncc/parsing/PreParserIndent.n	(original)
+++ nemerle/trunk/ncc/parsing/PreParserIndent.n	Thu Oct 27 10:19:46 2005
@@ -33,9 +33,8 @@
 
 namespace Nemerle.Compiler
 {
-  public class PreParserIndent : PreParser {
     // For indentation syntax
-    mutable current_indent : string = "";
+  public class PreParserIndent : PreParser {
     // The number of unmatched { ( [ tokens found in the user code at this point
     mutable explicit_groups : int;
     mutable indentation_syntax_active : bool = true;
@@ -62,6 +61,11 @@
       tokens_pending.Push (Token.EndBrace (insertLocation, true));
     }
 
+    CurrentIndent : string
+    {
+      get { indent_strings.Top }
+    }
+
     handle_real_token (lexer_tok : Token) : void
     {
       unless (lexer_tok is Token.EndOfFile)
@@ -103,8 +107,8 @@
           tokens_pending.Push (lexer_tok)
           
         // If this is the 'set' keyword in the first column of a new line:
-        | Identifier ("set") when current_indent == ""
-        | Keyword ("set") when current_indent == "" =>
+        | Identifier ("set") when CurrentIndent == ""
+        | Keyword ("set") when CurrentIndent == "" =>
           def next = lexer.GetToken ();
           match (next) {
             | Token.Keyword ("namespace") =>
@@ -197,20 +201,17 @@
           get_token_after_indent (tok, new_indent)
 
         | _ =>
-          def previous_indent = current_indent;
-          current_indent = new_indent;
-
           // If we have not unindented
-          if (new_indent.Length >= previous_indent.Length) {
+          if (new_indent.Length >= CurrentIndent.Length) {
             // Make sure that the beginning of the new indent string
             //  starts with the contents of the current indent string.
-            when (!new_indent.StartsWith (previous_indent)) {
+            when (!new_indent.StartsWith (CurrentIndent)) {
               // TODO: make a better error message -- checkout python error message
               Message.Error (tok.Location, "inconsistent indentation");
             }
             
             // If we have remained at the same indentation level
-            if (new_indent == previous_indent) {
+            if (new_indent == CurrentIndent) {
               when (had_some_real_input)
                 //Message.Debug (tok.Location, $"Generate ';'");
                 tokens_pending.Push (Token.Semicolon (insertLocation, true));
@@ -221,7 +222,6 @@
             else {
               match (tok) {
                 | Token.Operator =>
-                  current_indent = previous_indent;
                   handle_real_token (tok)
                 
                 | _ =>



More information about the svn mailing list