Mercurial > projects > dil
comparison trunk/src/dil/semantic/Pass1.d @ 787:47c5099562c7
Added two semantic error messages.
author | Aziz K?ksal <aziz.koeksal@gmail.com> |
---|---|
date | Sun, 24 Feb 2008 03:11:39 +0100 |
parents | 8380fb2c765f |
children | c24be8d4f6ab |
comparison
equal
deleted
inserted
replaced
786:3b34f6a95a27 | 787:47c5099562c7 |
---|---|
70 void exitScope() | 70 void exitScope() |
71 { | 71 { |
72 scop = scop.exit(); | 72 scop = scop.exit(); |
73 } | 73 } |
74 | 74 |
75 /// Returns true if this is the module scope. | |
76 bool isModuleScope() | |
77 { | |
78 return scop.symbol.isModule(); | |
79 } | |
80 | |
75 /// Insert a symbol into the current scope. | 81 /// Insert a symbol into the current scope. |
76 void insert(Symbol symbol, Identifier* name) | 82 void insert(Symbol symbol, Identifier* name) |
77 { | 83 { |
78 auto symX = scop.symbol.lookup(name); | 84 auto symX = scop.symbol.lookup(name); |
79 if (symX) | 85 if (symX) |
350 | 356 |
351 D visit(DebugDeclaration d) | 357 D visit(DebugDeclaration d) |
352 { | 358 { |
353 if (d.isSpecification) | 359 if (d.isSpecification) |
354 { | 360 { |
355 if (d.spec.kind == TOK.Identifier) | 361 if (!isModuleScope()) |
362 error(d.begin, MSG.DebugSpecModuleLevel, d.spec.srcText); | |
363 else if (d.spec.kind == TOK.Identifier) | |
356 context.addDebugId(d.spec.ident.str); | 364 context.addDebugId(d.spec.ident.str); |
357 else | 365 else |
358 context.debugLevel = d.spec.uint_; | 366 context.debugLevel = d.spec.uint_; |
359 } | 367 } |
360 else | 368 else |
370 | 378 |
371 D visit(VersionDeclaration d) | 379 D visit(VersionDeclaration d) |
372 { | 380 { |
373 if (d.isSpecification) | 381 if (d.isSpecification) |
374 { | 382 { |
375 if (d.spec.kind == TOK.Identifier) | 383 if (!isModuleScope()) |
384 error(d.begin, MSG.VersionSpecModuleLevel, d.spec.srcText); | |
385 else if (d.spec.kind == TOK.Identifier) | |
376 context.addVersionId(d.spec.ident.str); | 386 context.addVersionId(d.spec.ident.str); |
377 else | 387 else |
378 context.versionLevel = d.spec.uint_; | 388 context.versionLevel = d.spec.uint_; |
379 } | 389 } |
380 else | 390 else |