[svn] r6421: nemerle/trunk/ncc: parsing/PreParser.n passes.n

VladD2 svnadmin at nemerle.org
Mon Jul 3 04:50:11 CEST 2006


Log:
Has added the notification about parsing using directive. It is necessary for correct using directive completion.

Author: VladD2
Date: Mon Jul  3 04:50:09 2006
New Revision: 6421

Modified:
   nemerle/trunk/ncc/parsing/PreParser.n
   nemerle/trunk/ncc/passes.n

Modified: nemerle/trunk/ncc/parsing/PreParser.n
==============================================================================
--- nemerle/trunk/ncc/parsing/PreParser.n	(original)
+++ nemerle/trunk/ncc/parsing/PreParser.n	Mon Jul  3 04:50:09 2006
@@ -336,7 +336,7 @@
       def parent_begin = parent_stream.Count;
       def current_begin = current_stream.Count;
 
-      def get_qid ()
+      def get_qualified_identifier () : list [string] * Location
       {
         def tok1 = get_token ();
         match (tok1)
@@ -345,13 +345,19 @@
             def tok2 = get_token ();
             match (tok2)
             {
-              | Token.Operator (".") => x :: get_qid ()
-              | t => push_back (t); [x]
+              | Token.Operator (".") =>
+                def (ident, loc) = get_qualified_identifier ();
+                match (ident)
+                {
+                  | [] => ([x], tok1.Location + tok2.Location)
+                  | _  => (x :: ident, tok1.Location + loc)
+                }
+              | t => push_back (t); ([x], tok1.Location)
             }
           | t =>
             Message.Error (t.Location, "expected qualified identifier");
             push_back (t);
-            []
+            ([], Location.Default)
         }
       }
       
@@ -361,7 +367,9 @@
           | Token.Keyword ("using") =>
             finish_current (current_begin);
             
-            def id = get_qid ();
+            def prevEnv = Env;
+            def (id, idLoc) = get_qualified_identifier ();
+
             match (get_token ()) {
               | Token.Semicolon as st =>
                 def loc = tok.Location + st.Location;
@@ -371,8 +379,10 @@
                 def using_tok = Token.Using (loc, Env);
                 current_stream.Add (using_tok);
                 
+                lexer.Manager.NotifyUsingDirectiveParsed(id, prevEnv, idLoc);
+                
               | Token.Operator ("=") =>
-                def id' = get_qid ();
+                def (id', idLoc') = get_qualified_identifier ();
 
                 def st = get_token ();
                 match (st) {
@@ -388,6 +398,8 @@
                 def using_tok = Token.Using (tok.Location + st.Location, Env);
                 current_stream.Add (using_tok);
                 
+                lexer.Manager.NotifyUsingDirectiveParsed(id', prevEnv, idLoc');
+
               | x => Message.Error (x.Location, "expecting `;' or `='")
             }
             finish_current (current_begin);
@@ -396,7 +408,7 @@
           | Token.Keyword ("namespace") =>
             finish_current (current_begin);
             
-            def id = get_qid ();
+            def (id, _) = get_qualified_identifier ();
             match (get_token ()) {
               | Token.BeginBrace as br =>
                 def loc = tok.Location + br.Location;

Modified: nemerle/trunk/ncc/passes.n
==============================================================================
--- nemerle/trunk/ncc/passes.n	(original)
+++ nemerle/trunk/ncc/passes.n	Mon Jul  3 04:50:09 2006
@@ -113,6 +113,27 @@
     /** encountered file names with mapping to their indices */
     internal Location_file_indices : Hashtable [string, int] = Hashtable ();
 
+    public GetFileIndex(filePath : string) : int
+    {
+      Location_file_indices[filePath];
+    }
+
+    /** Called by parser when simple "using" directive parsed .
+     * qualifiedIdentifier : list [string] - qualified identifier/
+     * prevEnv : GlobalEnv - GlobalEnv before adding current using directive.
+     * location : Location - location of qualified identifier.
+    */
+    protected mutable _usingDirectiveParsed : list [string] * GlobalEnv * Location -> void;
+
+    internal NotifyUsingDirectiveParsed(
+      qualifiedIdentifier : list [string],
+      prevEnv : GlobalEnv,
+      location : Location) : void
+    {
+      when (_usingDirectiveParsed != null)
+        _usingDirectiveParsed (qualifiedIdentifier, prevEnv, location);
+    }
+
 
     // won't be needed when we use this object only once
     protected KillStatics () : void



More information about the svn mailing list