Mercurial > projects > dil
comparison trunk/src/dil/Information.d @ 514:6ddff941862a
Added new error classes.
author | Aziz K?ksal <aziz.koeksal@gmail.com> |
---|---|
date | Fri, 14 Dec 2007 19:32:07 +0100 |
parents | 47be6bfe39cd |
children | 8f86bb9ef715 |
comparison
equal
deleted
inserted
replaced
513:6160ab7b1816 | 514:6ddff941862a |
---|---|
1 /++ | 1 /++ |
2 Author: Aziz Köksal | 2 Author: Aziz Köksal |
3 License: GPL3 | 3 License: GPL3 |
4 +/ | 4 +/ |
5 module dil.Information; | 5 module dil.Information; |
6 | |
6 import dil.Messages; | 7 import dil.Messages; |
7 import common; | 8 import common; |
8 | 9 |
9 public import dil.Location; | 10 public import dil.Location; |
10 | 11 |
11 enum InfoType | 12 class Information |
12 { | 13 { |
13 Lexer, | 14 |
14 Parser, | |
15 Semantic | |
16 } | 15 } |
17 | 16 |
18 class Information | 17 class InformationManager |
19 { | 18 { |
20 MID id; | 19 Information[] info; |
21 InfoType type; | 20 } |
21 | |
22 class Problem : Information | |
23 { | |
22 Location location; | 24 Location location; |
23 uint column; | 25 uint column; /// Cache variable for column. |
24 string message; | 26 string message; |
25 | 27 |
26 this(InfoType type, MID id, Location location, string message) | 28 this(Location location, string message) |
27 { | 29 { |
28 assert(location !is null); | 30 assert(location !is null); |
29 this.id = id; | |
30 this.type = type; | |
31 this.location = location; | 31 this.location = location; |
32 this.message = message; | 32 this.message = message; |
33 } | 33 } |
34 | 34 |
35 string getMsg() | 35 string getMsg() |
36 { | 36 { |
37 return this.message; | 37 return this.message; |
38 } | 38 } |
39 | 39 |
40 /// Returns the line of code. | |
40 size_t loc() | 41 size_t loc() |
41 { | 42 { |
42 return location.lineNum; | 43 return location.lineNum; |
43 } | 44 } |
44 | 45 |
46 /// Returns the column. | |
45 size_t col() | 47 size_t col() |
46 { | 48 { |
47 if (column == 0) | 49 if (column == 0) |
48 column = location.calculateColumn(); | 50 column = location.calculateColumn(); |
49 return column; | 51 return column; |
50 } | 52 } |
51 | 53 |
54 /// Returns the file path. | |
52 string filePath() | 55 string filePath() |
53 { | 56 { |
54 return location.filePath; | 57 return location.filePath; |
55 } | 58 } |
56 } | 59 } |
57 | 60 |
58 class InformationManager | 61 class Warning : Problem |
59 { | 62 { |
60 Information[] info; | 63 this(Location location, string message) |
64 { | |
65 super(location, message); | |
66 } | |
61 } | 67 } |
68 | |
69 class Error : Problem | |
70 { | |
71 this(Location location, string message) | |
72 { | |
73 super(location, message); | |
74 } | |
75 } | |
76 | |
77 class LexerError : Error | |
78 { | |
79 this(Location location, string message) | |
80 { | |
81 super(location, message); | |
82 } | |
83 } | |
84 | |
85 class ParserError : Error | |
86 { | |
87 this(Location location, string message) | |
88 { | |
89 super(location, message); | |
90 } | |
91 } | |
92 | |
93 class SemanticError : Error | |
94 { | |
95 this(Location location, string message) | |
96 { | |
97 super(location, message); | |
98 } | |
99 } |