Mercurial > projects > dil
annotate trunk/src/dil/Information.d @ 490:47be6bfe39cd
Refactored code and added new modules.
Added ProtectionDeclaration and changed Parser to make use of it.
Moved class Location to its own module.
Moved some Lexer functions to new module LexerFuncs.
Moved Lexer.getLocation() to struct Token.
Added methods semantic() and error() to class Expression.
Added method error() to class Scope.
author | Aziz K?ksal <aziz.koeksal@gmail.com> |
---|---|
date | Tue, 04 Dec 2007 23:31:20 +0100 |
parents | bd176bc73e43 |
children | 6ddff941862a |
rev | line source |
---|---|
69
24db7c5522d5
- Added module Information for compiler messages like warnings, info and errors to the user.
aziz
parents:
diff
changeset
|
1 /++ |
24db7c5522d5
- Added module Information for compiler messages like warnings, info and errors to the user.
aziz
parents:
diff
changeset
|
2 Author: Aziz Köksal |
249 | 3 License: GPL3 |
69
24db7c5522d5
- Added module Information for compiler messages like warnings, info and errors to the user.
aziz
parents:
diff
changeset
|
4 +/ |
326 | 5 module dil.Information; |
327 | 6 import dil.Messages; |
391
33b566df6af4
Migrated project to Tango.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
327
diff
changeset
|
7 import common; |
69
24db7c5522d5
- Added module Information for compiler messages like warnings, info and errors to the user.
aziz
parents:
diff
changeset
|
8 |
490
47be6bfe39cd
Refactored code and added new modules.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
9 public import dil.Location; |
47be6bfe39cd
Refactored code and added new modules.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
10 |
94 | 11 enum InfoType |
69
24db7c5522d5
- Added module Information for compiler messages like warnings, info and errors to the user.
aziz
parents:
diff
changeset
|
12 { |
24db7c5522d5
- Added module Information for compiler messages like warnings, info and errors to the user.
aziz
parents:
diff
changeset
|
13 Lexer, |
24db7c5522d5
- Added module Information for compiler messages like warnings, info and errors to the user.
aziz
parents:
diff
changeset
|
14 Parser, |
24db7c5522d5
- Added module Information for compiler messages like warnings, info and errors to the user.
aziz
parents:
diff
changeset
|
15 Semantic |
24db7c5522d5
- Added module Information for compiler messages like warnings, info and errors to the user.
aziz
parents:
diff
changeset
|
16 } |
24db7c5522d5
- Added module Information for compiler messages like warnings, info and errors to the user.
aziz
parents:
diff
changeset
|
17 |
24db7c5522d5
- Added module Information for compiler messages like warnings, info and errors to the user.
aziz
parents:
diff
changeset
|
18 class Information |
24db7c5522d5
- Added module Information for compiler messages like warnings, info and errors to the user.
aziz
parents:
diff
changeset
|
19 { |
24db7c5522d5
- Added module Information for compiler messages like warnings, info and errors to the user.
aziz
parents:
diff
changeset
|
20 MID id; |
94 | 21 InfoType type; |
422
ad7977fe315a
Added support for column numbers in error messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
22 Location location; |
ad7977fe315a
Added support for column numbers in error messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
23 uint column; |
391
33b566df6af4
Migrated project to Tango.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
327
diff
changeset
|
24 string message; |
69
24db7c5522d5
- Added module Information for compiler messages like warnings, info and errors to the user.
aziz
parents:
diff
changeset
|
25 |
422
ad7977fe315a
Added support for column numbers in error messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
26 this(InfoType type, MID id, Location location, string message) |
69
24db7c5522d5
- Added module Information for compiler messages like warnings, info and errors to the user.
aziz
parents:
diff
changeset
|
27 { |
422
ad7977fe315a
Added support for column numbers in error messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
28 assert(location !is null); |
69
24db7c5522d5
- Added module Information for compiler messages like warnings, info and errors to the user.
aziz
parents:
diff
changeset
|
29 this.id = id; |
24db7c5522d5
- Added module Information for compiler messages like warnings, info and errors to the user.
aziz
parents:
diff
changeset
|
30 this.type = type; |
422
ad7977fe315a
Added support for column numbers in error messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
31 this.location = location; |
391
33b566df6af4
Migrated project to Tango.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
327
diff
changeset
|
32 this.message = message; |
69
24db7c5522d5
- Added module Information for compiler messages like warnings, info and errors to the user.
aziz
parents:
diff
changeset
|
33 } |
24db7c5522d5
- Added module Information for compiler messages like warnings, info and errors to the user.
aziz
parents:
diff
changeset
|
34 |
24db7c5522d5
- Added module Information for compiler messages like warnings, info and errors to the user.
aziz
parents:
diff
changeset
|
35 string getMsg() |
24db7c5522d5
- Added module Information for compiler messages like warnings, info and errors to the user.
aziz
parents:
diff
changeset
|
36 { |
391
33b566df6af4
Migrated project to Tango.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
327
diff
changeset
|
37 return this.message; |
69
24db7c5522d5
- Added module Information for compiler messages like warnings, info and errors to the user.
aziz
parents:
diff
changeset
|
38 } |
422
ad7977fe315a
Added support for column numbers in error messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
39 |
ad7977fe315a
Added support for column numbers in error messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
40 size_t loc() |
ad7977fe315a
Added support for column numbers in error messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
41 { |
ad7977fe315a
Added support for column numbers in error messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
42 return location.lineNum; |
ad7977fe315a
Added support for column numbers in error messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
43 } |
ad7977fe315a
Added support for column numbers in error messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
44 |
ad7977fe315a
Added support for column numbers in error messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
45 size_t col() |
ad7977fe315a
Added support for column numbers in error messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
46 { |
ad7977fe315a
Added support for column numbers in error messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
47 if (column == 0) |
ad7977fe315a
Added support for column numbers in error messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
48 column = location.calculateColumn(); |
ad7977fe315a
Added support for column numbers in error messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
49 return column; |
ad7977fe315a
Added support for column numbers in error messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
50 } |
ad7977fe315a
Added support for column numbers in error messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
51 |
ad7977fe315a
Added support for column numbers in error messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
52 string filePath() |
ad7977fe315a
Added support for column numbers in error messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
53 { |
ad7977fe315a
Added support for column numbers in error messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
54 return location.filePath; |
ad7977fe315a
Added support for column numbers in error messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
55 } |
69
24db7c5522d5
- Added module Information for compiler messages like warnings, info and errors to the user.
aziz
parents:
diff
changeset
|
56 } |
422
ad7977fe315a
Added support for column numbers in error messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
57 |
486
bd176bc73e43
Fixed a few things in the Parser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
434
diff
changeset
|
58 class InformationManager |
bd176bc73e43
Fixed a few things in the Parser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
434
diff
changeset
|
59 { |
bd176bc73e43
Fixed a few things in the Parser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
434
diff
changeset
|
60 Information[] info; |
bd176bc73e43
Fixed a few things in the Parser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
434
diff
changeset
|
61 } |