annotate trunk/src/dil/Information.d @ 744:7173ece1b696

Wrapped some macro functions inside struct MacroExpander. Warning messages from the macro expansion pass are collected now. Tidied up predefined.ddoc a bit, and added some macros. Added two messages to struct MSG. Added another opCatAssign to class InfoManager.
author Aziz K?ksal <aziz.koeksal@gmail.com>
date Sat, 09 Feb 2008 22:54:31 +0100
parents 50e64bab9c7a
children 9c47f377ca0b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
32d354584b28 - Upgraded license notices to GPL3.
aziz
parents: 94
diff changeset
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
4a7359b88c11 - Added package 'dil' to module declarations.
aziz
parents: 325
diff changeset
5 module dil.Information;
514
6ddff941862a Added new error classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 490
diff changeset
6
327
a48a987f7515 - Added package dil to import declarations.
aziz
parents: 326
diff changeset
7 import dil.Messages;
391
33b566df6af4 Migrated project to Tango.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 327
diff changeset
8 import common;
69
24db7c5522d5 - Added module Information for compiler messages like warnings, info and errors to the user.
aziz
parents:
diff changeset
9
490
47be6bfe39cd Refactored code and added new modules.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
10 public import dil.Location;
47be6bfe39cd Refactored code and added new modules.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
11
69
24db7c5522d5 - Added module Information for compiler messages like warnings, info and errors to the user.
aziz
parents:
diff changeset
12 class Information
24db7c5522d5 - Added module Information for compiler messages like warnings, info and errors to the user.
aziz
parents:
diff changeset
13 {
514
6ddff941862a Added new error classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 490
diff changeset
14
6ddff941862a Added new error classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 490
diff changeset
15 }
6ddff941862a Added new error classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 490
diff changeset
16
532
50e64bab9c7a Renamed InformationManager to InfoManager.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 518
diff changeset
17 class InfoManager
514
6ddff941862a Added new error classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 490
diff changeset
18 {
6ddff941862a Added new error classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 490
diff changeset
19 Information[] info;
518
8f86bb9ef715 Added module dil.Converter and dil.FileBOM.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 514
diff changeset
20
8f86bb9ef715 Added module dil.Converter and dil.FileBOM.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 514
diff changeset
21 void opCatAssign(Information info)
8f86bb9ef715 Added module dil.Converter and dil.FileBOM.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 514
diff changeset
22 {
8f86bb9ef715 Added module dil.Converter and dil.FileBOM.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 514
diff changeset
23 this.info ~= info;
8f86bb9ef715 Added module dil.Converter and dil.FileBOM.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 514
diff changeset
24 }
744
7173ece1b696 Wrapped some macro functions inside struct MacroExpander.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 532
diff changeset
25
7173ece1b696 Wrapped some macro functions inside struct MacroExpander.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 532
diff changeset
26 void opCatAssign(Information[] info)
7173ece1b696 Wrapped some macro functions inside struct MacroExpander.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 532
diff changeset
27 {
7173ece1b696 Wrapped some macro functions inside struct MacroExpander.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 532
diff changeset
28 this.info ~= info;
7173ece1b696 Wrapped some macro functions inside struct MacroExpander.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 532
diff changeset
29 }
514
6ddff941862a Added new error classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 490
diff changeset
30 }
6ddff941862a Added new error classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 490
diff changeset
31
6ddff941862a Added new error classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 490
diff changeset
32 class Problem : Information
6ddff941862a Added new error classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 490
diff changeset
33 {
422
ad7977fe315a Added support for column numbers in error messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 391
diff changeset
34 Location location;
514
6ddff941862a Added new error classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 490
diff changeset
35 uint column; /// Cache variable for column.
391
33b566df6af4 Migrated project to Tango.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 327
diff changeset
36 string message;
69
24db7c5522d5 - Added module Information for compiler messages like warnings, info and errors to the user.
aziz
parents:
diff changeset
37
514
6ddff941862a Added new error classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 490
diff changeset
38 this(Location location, string message)
69
24db7c5522d5 - Added module Information for compiler messages like warnings, info and errors to the user.
aziz
parents:
diff changeset
39 {
422
ad7977fe315a Added support for column numbers in error messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 391
diff changeset
40 assert(location !is null);
ad7977fe315a Added support for column numbers in error messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 391
diff changeset
41 this.location = location;
391
33b566df6af4 Migrated project to Tango.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 327
diff changeset
42 this.message = message;
69
24db7c5522d5 - Added module Information for compiler messages like warnings, info and errors to the user.
aziz
parents:
diff changeset
43 }
24db7c5522d5 - Added module Information for compiler messages like warnings, info and errors to the user.
aziz
parents:
diff changeset
44
24db7c5522d5 - Added module Information for compiler messages like warnings, info and errors to the user.
aziz
parents:
diff changeset
45 string getMsg()
24db7c5522d5 - Added module Information for compiler messages like warnings, info and errors to the user.
aziz
parents:
diff changeset
46 {
391
33b566df6af4 Migrated project to Tango.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 327
diff changeset
47 return this.message;
69
24db7c5522d5 - Added module Information for compiler messages like warnings, info and errors to the user.
aziz
parents:
diff changeset
48 }
422
ad7977fe315a Added support for column numbers in error messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 391
diff changeset
49
514
6ddff941862a Added new error classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 490
diff changeset
50 /// Returns the line of code.
422
ad7977fe315a Added support for column numbers in error messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 391
diff changeset
51 size_t loc()
ad7977fe315a Added support for column numbers in error messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 391
diff changeset
52 {
ad7977fe315a Added support for column numbers in error messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 391
diff changeset
53 return location.lineNum;
ad7977fe315a Added support for column numbers in error messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 391
diff changeset
54 }
ad7977fe315a Added support for column numbers in error messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 391
diff changeset
55
514
6ddff941862a Added new error classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 490
diff changeset
56 /// Returns the column.
422
ad7977fe315a Added support for column numbers in error messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 391
diff changeset
57 size_t col()
ad7977fe315a Added support for column numbers in error messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 391
diff changeset
58 {
ad7977fe315a Added support for column numbers in error messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 391
diff changeset
59 if (column == 0)
ad7977fe315a Added support for column numbers in error messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 391
diff changeset
60 column = location.calculateColumn();
ad7977fe315a Added support for column numbers in error messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 391
diff changeset
61 return column;
ad7977fe315a Added support for column numbers in error messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 391
diff changeset
62 }
ad7977fe315a Added support for column numbers in error messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 391
diff changeset
63
514
6ddff941862a Added new error classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 490
diff changeset
64 /// Returns the file path.
422
ad7977fe315a Added support for column numbers in error messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 391
diff changeset
65 string filePath()
ad7977fe315a Added support for column numbers in error messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 391
diff changeset
66 {
ad7977fe315a Added support for column numbers in error messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 391
diff changeset
67 return location.filePath;
ad7977fe315a Added support for column numbers in error messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 391
diff changeset
68 }
69
24db7c5522d5 - Added module Information for compiler messages like warnings, info and errors to the user.
aziz
parents:
diff changeset
69 }
422
ad7977fe315a Added support for column numbers in error messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 391
diff changeset
70
514
6ddff941862a Added new error classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 490
diff changeset
71 class Warning : Problem
6ddff941862a Added new error classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 490
diff changeset
72 {
6ddff941862a Added new error classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 490
diff changeset
73 this(Location location, string message)
6ddff941862a Added new error classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 490
diff changeset
74 {
6ddff941862a Added new error classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 490
diff changeset
75 super(location, message);
6ddff941862a Added new error classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 490
diff changeset
76 }
6ddff941862a Added new error classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 490
diff changeset
77 }
6ddff941862a Added new error classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 490
diff changeset
78
6ddff941862a Added new error classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 490
diff changeset
79 class Error : Problem
6ddff941862a Added new error classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 490
diff changeset
80 {
6ddff941862a Added new error classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 490
diff changeset
81 this(Location location, string message)
6ddff941862a Added new error classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 490
diff changeset
82 {
6ddff941862a Added new error classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 490
diff changeset
83 super(location, message);
6ddff941862a Added new error classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 490
diff changeset
84 }
6ddff941862a Added new error classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 490
diff changeset
85 }
6ddff941862a Added new error classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 490
diff changeset
86
6ddff941862a Added new error classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 490
diff changeset
87 class LexerError : Error
486
bd176bc73e43 Fixed a few things in the Parser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 434
diff changeset
88 {
514
6ddff941862a Added new error classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 490
diff changeset
89 this(Location location, string message)
6ddff941862a Added new error classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 490
diff changeset
90 {
6ddff941862a Added new error classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 490
diff changeset
91 super(location, message);
6ddff941862a Added new error classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 490
diff changeset
92 }
486
bd176bc73e43 Fixed a few things in the Parser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 434
diff changeset
93 }
514
6ddff941862a Added new error classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 490
diff changeset
94
6ddff941862a Added new error classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 490
diff changeset
95 class ParserError : Error
6ddff941862a Added new error classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 490
diff changeset
96 {
6ddff941862a Added new error classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 490
diff changeset
97 this(Location location, string message)
6ddff941862a Added new error classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 490
diff changeset
98 {
6ddff941862a Added new error classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 490
diff changeset
99 super(location, message);
6ddff941862a Added new error classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 490
diff changeset
100 }
6ddff941862a Added new error classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 490
diff changeset
101 }
6ddff941862a Added new error classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 490
diff changeset
102
6ddff941862a Added new error classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 490
diff changeset
103 class SemanticError : Error
6ddff941862a Added new error classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 490
diff changeset
104 {
6ddff941862a Added new error classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 490
diff changeset
105 this(Location location, string message)
6ddff941862a Added new error classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 490
diff changeset
106 {
6ddff941862a Added new error classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 490
diff changeset
107 super(location, message);
6ddff941862a Added new error classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 490
diff changeset
108 }
6ddff941862a Added new error classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 490
diff changeset
109 }