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

VladD2 svnadmin at nemerle.org
Sat Aug 5 17:10:17 CEST 2006


Log:
Add alias info into using directive notification.

Author: VladD2
Date: Sat Aug  5 17:10:12 2006
New Revision: 6484

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	Sat Aug  5 17:10:12 2006
@@ -383,7 +383,8 @@
             current_stream.Add (using_tok);
 
             lexer.Manager.OnAfterUsingDirectiveParse(loc 
-              + make_before_location (st.Location), id, idLocs, currentNsEnv, Env);
+              + make_before_location (st.Location), id, idLocs, 
+              "", Location.Default, currentNsEnv, Env);
             
           | Token.Operator ("=") =>
             def (id', idLocs') = get_qualified_identifier ();
@@ -397,16 +398,28 @@
             }
 
             match (id) {
-              | [name] => Env = Env.AddNamespaceAlias (name, id', tok.Location);
-              | _ => Message.Error (tok.Location, "using alias must be simple name without dots")
+              | [name] =>
+                Env = Env.AddNamespaceAlias (name, id', tok.Location);
+                lexer.Manager.OnAfterUsingDirectiveParse(tok.Location 
+                  + make_before_location (st.Location), id', idLocs', 
+                  name, idLocs.Head, currentNsEnv, Env);
+                assert (idLocs.Length == 1);
+              
+              | [] => // occur if syntax error
+                lexer.Manager.OnAfterUsingDirectiveParse(tok.Location 
+                  + make_before_location (st.Location), id', idLocs', 
+                  "", Location.Default, currentNsEnv, Env);
+              
+              | _ => 
+                Message.Error (tok.Location, "using alias must be simple name without dots");
+                lexer.Manager.OnAfterUsingDirectiveParse(tok.Location 
+                  + make_before_location (st.Location), id', idLocs', 
+                  id.ToString(), idLocs.Head + idLocs.Last, currentNsEnv, Env);
             }
          
             def using_tok = Token.Using (tok.Location + st.Location, Env);
             current_stream.Add (using_tok);
             
-            lexer.Manager.OnAfterUsingDirectiveParse(tok.Location 
-              + make_before_location (st.Location), id', idLocs', currentNsEnv, Env);
-
           | x => 
             push_back (x);
             // The error message must point to last using token
@@ -416,7 +429,7 @@
             // In notification location must point before first token of next directive
             lexer.Manager.OnAfterUsingDirectiveParse(tok.Location 
               + make_before_location (x.Location),
-              id, idLocs, currentNsEnv, Env);
+              id, idLocs, "", Location.Default, currentNsEnv, Env);
         }
 
         finish_current (current_begin);
@@ -530,3 +543,4 @@
     }
   }
 }
+

Modified: nemerle/trunk/ncc/passes.n
==============================================================================
--- nemerle/trunk/ncc/passes.n	(original)
+++ nemerle/trunk/ncc/passes.n	Sat Aug  5 17:10:12 2006
@@ -124,18 +124,22 @@
      * location : Location - location of qualified identifier.
     */
     protected mutable _afterUsingDirectiveParse 
-      : Location * list [string] * list [Location] * GlobalEnv * GlobalEnv -> void;
+      : Location * list [string] * list [Location] * string * Location
+        * GlobalEnv * GlobalEnv -> void;
 
     internal OnAfterUsingDirectiveParse(
       location : Location,
       name : list [string],
       nameLocations : list [Location],
+      alias         : string,
+      aliasLocation : Location,
       beforeEnv : GlobalEnv,
       afterEnv  : GlobalEnv
       ) : void
     {
       when (_afterUsingDirectiveParse != null)
-        _afterUsingDirectiveParse (location, name, nameLocations, beforeEnv, afterEnv);
+        _afterUsingDirectiveParse (location, name, nameLocations, alias, aliasLocation, 
+          beforeEnv, afterEnv);
     }
 
     protected mutable _beforeNamespaceParse : void -> void;



More information about the svn mailing list