[svn] r7258: vs-plugin/trunk/Nemerle.Compiler.Utils: Nemerle.Completion2/Engine/Engine.Completion.n Utils....

VladD2 svnadmin at nemerle.org
Fri Jan 12 12:52:12 CET 2007


Log:
1. Add GetLexer() into Engine.
2. Remove unused ParseQualIdent() from Utils.
3. Add ReadAllTokens() extension method to LexerBase.

Author: VladD2
Date: Fri Jan 12 12:52:10 2007
New Revision: 7258

Modified:
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine.Completion.n
   vs-plugin/trunk/Nemerle.Compiler.Utils/Utils.n

Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine.Completion.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine.Completion.n	(original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine.Completion.n	Fri Jan 12 12:52:10 2007
@@ -244,5 +244,17 @@
         _isCompletioInProgress = false;
       }
     }
+
+    /// Get lexer for some range in source file.
+    /// The range specified by loc parametr.
+    // Note: All locations strat at start point of loc.
+    public GetLexer(source : ISource, loc : Location) : LexerBase
+    {
+      def code = source.GetRegion(loc);
+      def lex = LexerString(this, code, loc);
+      lex.BeginParseFile();
+      lex.Keywords = lex.Manager.CoreEnv.Keywords;
+      lex
+    }
   } // end class Engine
 } // end namespace

Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Utils.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Utils.n	(original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Utils.n	Fri Jan 12 12:52:10 2007
@@ -316,48 +316,6 @@
       loop(members);
     }
 
-    /// It's poor performance and very pared-down implementation of 
-    /// qualified identifier fersing.
-    public ParseQualIdent(text : string) : list[string]
-    {
-      def str = System.Text.StringBuilder();
-
-      def parseComment(chars, name, csp)
-      {
-        match (chars)
-        {
-          | '\n' :: tail
-          | '\r' :: '\n' :: tail
-          | '\r' :: tail => csp(tail, name)
-          | _ => parseComment(chars, name, csp)
-        }
-      }
-
-      def parseMultilineComment(chars, name, csp)
-      {
-        match (chars)
-        {
-          | '*' :: '/' :: tail => csp(tail, name)
-          | _ => parseMultilineComment(chars, name, csp)
-        }
-      }
-
-      def parse(chars, name : list[string])
-      {
-        match (chars)
-        {
-          | '/' :: '/' :: tail => parseComment(tail, name, parse)
-          | '/' :: '*' :: tail => parseMultilineComment(tail, name, parse)
-          | '.' :: tail => def x = str.ToString(); str.Length = 0; parse(tail, x :: name);
-          | x :: tail when char.IsLetterOrDigit(x) || x == '_' => ignore(str.Append(x)); parse(tail, name);
-          | _ :: tail => parse(tail, name);
-          | [] => str.ToString() :: name
-        }
-      }
-
-      parse(text.Explode(), []).Rev()
-    }
-
     public GetLocalPath(this asm : Assembly) : string
     {
        Uri(asm.CodeBase).LocalPath;
@@ -410,5 +368,17 @@
       else
         (lst.Head.Location + lst.Last.Location).Contains(testLine, testCol)
     }
+    
+    public ReadAllTokens(this lex : LexerBase) : array[Token]
+    {
+      def lst = SCG.List();
+      def scan(tok : Token)
+      {
+        | EndOfFile | null => lst
+        | _                => lst.Add(tok); scan(lex.GetToken());
+      }
+      
+      scan(lex.GetToken()).ToArray();
+    }
   } // End of Utils module
 } // End of namespace
\ No newline at end of file



More information about the svn mailing list