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

VladD2 svnadmin at nemerle.org
Thu Jan 4 21:17:03 CET 2007


Log:
Turnoff inline code in IntelliSense mode.

Author: VladD2
Date: Thu Jan  4 21:17:02 2007
New Revision: 7201

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	Thu Jan  4 21:17:02 2007
@@ -340,9 +340,9 @@
   {
   }
 
-  protected this (man : ManagerClass, fn : string)
+  protected this (manager : ManagerClass, fn : string)
   {
-    Manager = man;
+    Manager = manager;
     line = 1;
     col = 1;
     isPendingChar = false;
@@ -361,7 +361,7 @@
 
   public abstract Dispose () : void;
   
-  internal BeginParseFile() : void
+  public BeginParseFile() : void
   {
     is_check_wrong_chars = Manager.Options.Warnings.IsEnabled (10002);
   }
@@ -1494,19 +1494,19 @@
     (reader : IDisposable).Dispose ();
   }
   
-  public this (man : ManagerClass, fn : string)
+  public this (manager : ManagerClass, filePath : string)
   {
-    base (man, fn);
+    base (manager, filePath);
     comment_store = StringBuilder (300);
-    file_idx = Location.AddFile (fn);
+    file_idx = Location.AddFile (filePath);
     try {
-      def file = IO.FileStream (fn, IO.FileMode.Open, IO.FileAccess.Read);
+      def file = IO.FileStream (filePath, IO.FileMode.Open, IO.FileAccess.Read);
       reader = IO.StreamReader (file, Text.Encoding.UTF8);
-      when (man.Options.Warnings.IsEnabled (10002))
+      when (manager.Options.Warnings.IsEnabled (10002))
         check_last_line_for_lf (file);
     }
     catch {
-      | e => Message.FatalError ($"cannot open file `$fn': $(e.Message)")
+      | e => Message.FatalError ($"cannot open file `$filePath': $(e.Message)")
     }
       
   }
@@ -1634,20 +1634,16 @@
   protected mutable reader : string;
   protected mutable pos    : int;
 
-  public this (man : ManagerClass, fn : string, loc : Location)
+  public this (manager : ManagerClass, code : string, loc : Location)
   {
-    base (man, fn);
-    reader = fn;
+    base (manager, loc.File);
+    reader = code;
     pos = 0;
     file_idx = loc.FileIndex;
     line = loc.Line;
     col = loc.Column;
   }
 
-  public Position : int {
-    get { pos }
-  }
-
   public override Dispose () : void { }
   
   override protected peek () : char
@@ -1679,36 +1675,62 @@
 
   override protected comment_beginning () : char
   {
+    def startLocation = this.Location;
+    
     match (peek_or_white ()) {
       | '/' =>
         // we are for sure in one line comment
-        try
+        _ = read ();
+        try {
+          if (Manager.Options.LexerStoreComments && peek () == '/') {
+            //comment_loc = Location (file_idx, line, col - 2);
+            _ = read ();
+            mutable cc = ' ';
+            do
         {
-          while (read_or_eol () != '\n')
-            ();
+              cc = read_or_eol ();                
+              //_ = comment_store.Append (cc)
+            } while (cc != '\n');
+            //comment_loc = comment_loc + Location (file_idx, line, col);
+          }
+          else
+            while (read_or_eol () != '\n') {};
         } 
         catch { _ is LexerBase.Error => () };
 
         white_beginning = true;
-
-        ' ' // pass whitespace, so next read would be eof checked
+        // pass whitespace, so next read would be eof checked
+        ' '
 
       | '*' =>
         // multiline comment
-        ignore (read ());
-        def loop1 (seen_star) {
+        _ = read ();
+        def loop1 (seen_star, store) {
           def cc = read ();
+          //when (store)
+          //  ignore (comment_store.Append (cc));
 
           match (cc) {
-            | '*' => loop1 (true)
+            | '*' => loop1 (true, store)
             | '/' when seen_star => ()
             | '\0' =>
-              Message.Error (this.Location, 
-                "Unexpected end of file. Multiline comment not closed!")
-            | _ => loop1 (false)
+              Message.Error (startLocation, "End-of-file found, '*/' expected!") // like MS csc
+            | _ => loop1 (false, store)
           }
         };
-        loop1 (false);
+        if (Manager.Options.LexerStoreComments && peek_or_white () == '*') {
+          //comment_loc = Location (file_idx, line, col - 2);
+          _ = read ();
+          loop1 (true, true);
+          //if (comment_store.Length == 1)
+          //  ignore (comment_store.Remove (0, 1))
+          //else
+          //  ignore (comment_store.Remove (comment_store.Length - 2, 2));
+          //comment_loc = comment_loc + Location (file_idx, line, col);
+        }
+        else
+          loop1 (false, false);
+
         // pass whitespace, so next read would be eof checked            
         ' '
 

Modified: nemerle/trunk/ncc/parsing/MainParser.n
==============================================================================
--- nemerle/trunk/ncc/parsing/MainParser.n	(original)
+++ nemerle/trunk/ncc/parsing/MainParser.n	Thu Jan  4 21:17:02 2007
@@ -207,7 +207,7 @@
         when (topstream != null) {
           parser.eat_assembly_attributes (topstream);
           
-          if (IsTopLevel (topstream)) {
+          if (lex.Manager.IsIntelliSenseMode || IsTopLevel (topstream)) {
             result = parser.ParseTopLevel (topstream, result);
             topstream = topstream.Next :> Token.LooseGroup;
             iter ();



More information about the svn mailing list