diff src/dil/semantic/Module.d @ 814:49e32b5bc161

Added isValidUnreservedIdentifier() to Lexer. Added the msg InvalidModuleName.
author Aziz K?ksal <aziz.koeksal@gmail.com>
date Wed, 12 Mar 2008 17:01:27 +0100
parents 525ee3f848d9
children 615c1386b18d
line wrap: on
line diff
--- a/src/dil/semantic/Module.d	Wed Mar 12 00:49:17 2008 +0100
+++ b/src/dil/semantic/Module.d	Wed Mar 12 17:01:27 2008 +0100
@@ -10,6 +10,8 @@
 import dil.lexer.Lexer;
 import dil.semantic.Symbol;
 import dil.semantic.Symbols;
+import dil.Location;
+import dil.Messages;
 import dil.Information;
 import dil.SourceText;
 import common;
@@ -102,8 +104,13 @@
     if (!this.moduleFQN.length)
     { // Take base name of file path as module name.
       auto str = (new FilePath(filePath)).name();
-      if (Lexer.isReservedIdentifier(str))
-        throw new Exception("'"~str~"' is not a valid module name; it's a reserved or invalid D identifier.");
+      if (!Lexer.isValidUnreservedIdentifier(str))
+      {
+        auto location = parser.lexer.firstToken().getErrorLocation();
+        auto msg = Format(MSG.InvalidModuleName, str);
+        infoMan ~= new LexerError(location, msg);
+        str = "_";
+      }
       this.moduleFQN = this.moduleName = str;
     }
   }