diff trunk/src/dil/Lexer.d @ 365:ed67acc82268

- Added option includes to config.d. - Added methods getName() and getPackageName() to class ModuleDeclaration. - Added method isNonReservedIdentifier() to class Lexer. - Added private member parser to class Module. - Initializing members moduleName and packageName in Module.parse().
author aziz
date Fri, 31 Aug 2007 11:07:05 +0000
parents b6a3755eba94
children dda55fae37de
line wrap: on
line diff
--- a/trunk/src/dil/Lexer.d	Fri Aug 31 00:53:00 2007 +0000
+++ b/trunk/src/dil/Lexer.d	Fri Aug 31 11:07:05 2007 +0000
@@ -1658,6 +1658,23 @@
     return head;
   }
 
+  static bool isNonReservedIdentifier(char[] ident)
+  {
+    static Identifier[string] reserved_ids_table;
+    if (reserved_ids_table is null)
+      foreach(k; keywords)
+        reserved_ids_table[k.str] = k;
+
+    try
+      foreach (dchar c; ident)
+        if (!isident(c) && !isUniAlpha(c))
+          return false;
+    catch (Exception e)
+      return false;
+
+    return !(ident in reserved_ids_table);
+  }
+
   private void encodeUTF8(inout char[] str, dchar d)
   {
     char[6] b;