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

VladD2 svnadmin at nemerle.org
Sat Jul 8 14:04:11 CEST 2006


Log:
Fix \t accounting in lexer.

Author: VladD2
Date: Sat Jul  8 14:04:09 2006
New Revision: 6434

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

Modified: nemerle/trunk/ncc/parsing/Lexer.n
==============================================================================
--- nemerle/trunk/ncc/parsing/Lexer.n	(original)
+++ nemerle/trunk/ncc/parsing/Lexer.n	Sat Jul  8 14:04:09 2006
@@ -319,6 +319,8 @@
   
   protected mutable defines : Map [string, bool];
 
+  mutable is_check_wrong_chars : bool;
+
   #endregion PREPROCESSOR VARIABLES
   
   public class Error : System.Exception
@@ -350,27 +352,27 @@
 
   public abstract Dispose () : void;
   
-  protected virtual read () : char
+  internal BeginParseFile() : void
   {
-    def ch = 
-      if (!putback)
-        do_read ()
-      else {
-        putback = false;
-        putbackVal
+    is_check_wrong_chars = Manager.Options.Warnings.IsEnabled (10002);
       }
   
-    match (ch) {
-      | '\n' => ++line; col = 1
+  protected virtual read () : char
+  {
+    def ch = if (!putback) do_read () else { putback = false; putbackVal };
       
+    match (ch) {
+      | '\n' => ++line; col = 1;
       | '\r' =>
+        when (is_check_wrong_chars)
         Message.Warning (10002, this.Location, "CR character found in input stream")
-          
       | '\t' =>
+        ++col;
+        when (is_check_wrong_chars)
         Message.Warning (10002, this.Location, "tab character found in input stream")
-          
       | _ => ++col;
     };
+
     ch
   }
 

Modified: nemerle/trunk/ncc/parsing/MainParser.n
==============================================================================
--- nemerle/trunk/ncc/parsing/MainParser.n	(original)
+++ nemerle/trunk/ncc/parsing/MainParser.n	Sat Jul  8 14:04:09 2006
@@ -153,6 +153,7 @@
      */
     public static Parse (lex : LexerBase) : list [TopDeclaration]
     {
+      lex.BeginParseFile();
       def preparser =
         if (lex.Manager.Options.IndentationSyntax)
           PreParserIndent (lex)



More information about the svn mailing list