[svn] r7071: nemerle/trunk/ncc/parsing: Lexer.n PreParser.n PreParserIndent.n

malekith svnadmin at nemerle.org
Thu Dec 7 12:02:07 CET 2006


Log:
Reinterpret things being or not keywords again, so 'using MacroNamespace \n macro-keyword' works. Resolves #798.

Author: malekith
Date: Thu Dec  7 12:02:06 2006
New Revision: 7071

Modified:
   nemerle/trunk/ncc/parsing/Lexer.n
   nemerle/trunk/ncc/parsing/PreParser.n
   nemerle/trunk/ncc/parsing/PreParserIndent.n

Modified: nemerle/trunk/ncc/parsing/Lexer.n
==============================================================================
--- nemerle/trunk/ncc/parsing/Lexer.n	(original)
+++ nemerle/trunk/ncc/parsing/Lexer.n	Thu Dec  7 12:02:06 2006
@@ -39,6 +39,7 @@
 public variant Token : System.Collections.IEnumerable
 {
   | Identifier { name : string; }
+  | QuotedIdentifier { name : string; }
   | IdentifierToComplete { prefix : string; }
   | Keyword { name : string; }
   | Operator { name : string; }
@@ -89,6 +90,7 @@
 
   public override ToString () : string {
     match (this) {
+      | QuotedIdentifier (name) => "@" + name
       | Identifier (name) => name
       | IdentifierToComplete (name) => name + "<COMPL>";
       | Keyword (name) => name
@@ -143,6 +145,7 @@
     if (describe)
       match (this) {
         | Keyword (x) => "keyword `" + x + "'"
+        | QuotedIdentifier (x) => "quoted identifier `" + x + "'"
         | Identifier (x) => "identifier `" + x + "'"
         | IdentifierToComplete (x) => "identifier to complete `" + x + "'"
         | Operator (x) => "operator `" + x + "'"
@@ -1003,7 +1006,7 @@
         else if (IsIdBeginning (next))
           match (get_id (next)) {
             | Token.Identifier (x)
-            | Token.Keyword (x) => Token.Identifier (x)
+            | Token.Keyword (x) => Token.QuotedIdentifier (x)
             | _ => Util.ice ()
           }
         else if (next == '"')

Modified: nemerle/trunk/ncc/parsing/PreParser.n
==============================================================================
--- nemerle/trunk/ncc/parsing/PreParser.n	(original)
+++ nemerle/trunk/ncc/parsing/PreParser.n	Thu Dec  7 12:02:06 2006
@@ -103,7 +103,10 @@
       }
       else {
         try {
-          lexer.GetToken ()
+          match (lexer.GetToken ()) {
+            | QuotedIdentifier (x) as q => Token.Identifier (q.Location, x)
+            | t => t
+          }
         }
         catch {
           | e is LexerBase.Error =>

Modified: nemerle/trunk/ncc/parsing/PreParserIndent.n
==============================================================================
--- nemerle/trunk/ncc/parsing/PreParserIndent.n	(original)
+++ nemerle/trunk/ncc/parsing/PreParserIndent.n	Thu Dec  7 12:02:06 2006
@@ -157,8 +157,13 @@
         result;
       } else if (! tokens_pending.IsEmpty) {
         def t = tokens_pending.Take ();
-        //Message.Debug ($ "tok: $t");
-        t
+        //Message.Debug (t.ToString(true));
+        match (t) {
+          | QuotedIdentifier (x) as q => Token.Identifier (q.Location, x)
+          | Identifier (x) as i when lexer.Keywords.Contains (x) =>
+            Token.Keyword (i.Location, x)
+          | t => t
+        }
       }
       else {
         try {



More information about the svn mailing list