Mercurial > projects > dil
comparison 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 |
comparison
equal
deleted
inserted
replaced
813:1abffc396594 | 814:49e32b5bc161 |
---|---|
8 import dil.ast.Declarations; | 8 import dil.ast.Declarations; |
9 import dil.parser.Parser; | 9 import dil.parser.Parser; |
10 import dil.lexer.Lexer; | 10 import dil.lexer.Lexer; |
11 import dil.semantic.Symbol; | 11 import dil.semantic.Symbol; |
12 import dil.semantic.Symbols; | 12 import dil.semantic.Symbols; |
13 import dil.Location; | |
14 import dil.Messages; | |
13 import dil.Information; | 15 import dil.Information; |
14 import dil.SourceText; | 16 import dil.SourceText; |
15 import common; | 17 import common; |
16 | 18 |
17 import tango.io.FilePath; | 19 import tango.io.FilePath; |
100 } | 102 } |
101 | 103 |
102 if (!this.moduleFQN.length) | 104 if (!this.moduleFQN.length) |
103 { // Take base name of file path as module name. | 105 { // Take base name of file path as module name. |
104 auto str = (new FilePath(filePath)).name(); | 106 auto str = (new FilePath(filePath)).name(); |
105 if (Lexer.isReservedIdentifier(str)) | 107 if (!Lexer.isValidUnreservedIdentifier(str)) |
106 throw new Exception("'"~str~"' is not a valid module name; it's a reserved or invalid D identifier."); | 108 { |
109 auto location = parser.lexer.firstToken().getErrorLocation(); | |
110 auto msg = Format(MSG.InvalidModuleName, str); | |
111 infoMan ~= new LexerError(location, msg); | |
112 str = "_"; | |
113 } | |
107 this.moduleFQN = this.moduleName = str; | 114 this.moduleFQN = this.moduleName = str; |
108 } | 115 } |
109 } | 116 } |
110 | 117 |
111 /// Returns the first token of the module's source text. | 118 /// Returns the first token of the module's source text. |