1 /// Author: Aziz Köksal 2 /// License: GPL3 3 /// $(Maturity average) 4 module dil.Information; 5 6 import dil.i18n.Messages; 7 import common; 8 9 public import dil.Location; 10 11 /// Information that can be displayed to the user. 12 class Information 13 { 14 15 } 16 17 /// For reporting a problem in the compilation process. 18 class Problem : Information 19 { 20 Location location; 21 uint column; /// Cache variable for column. 22 cstring message; 23 24 this(Location location, cstring message) 25 { 26 assert(location !is null); 27 this.location = location; 28 this.message = message; 29 } 30 31 /// Returns the message. 32 cstring getMsg() 33 { 34 return this.message; 35 } 36 37 /// Returns the line of code. 38 size_t loc() 39 { 40 return location.lineNum; 41 } 42 43 /// Returns the column. 44 size_t col() 45 { 46 if (column == 0) 47 column = location.calculateColumn(); 48 return column; 49 } 50 51 /// Returns the file path. 52 cstring filePath() 53 { 54 return location.filePath; 55 } 56 } 57 58 /// For DDoc reports. 59 class DDocProblem : Problem 60 { 61 /// Enumeration of problems. 62 enum Kind 63 { 64 UndocumentedSymbol, /// Undocumented symbol. 65 EmptyComment, /// Empty DDoc comment. 66 NoParamsSection, /// No params section for function parameters. 67 UndocumentedParam /// An undocumented function parameter. 68 } 69 Kind kind; /// The kind of problem. 70 /// Constructs a DDocProblem object. 71 this(Location location, Kind kind, cstring message) 72 { 73 super(location, message); 74 this.kind = kind; 75 } 76 } 77 78 /// For reporting warnings. 79 class Warning : Problem 80 { 81 /// Constructs a Warning object. 82 this(Location location, cstring message) 83 { 84 super(location, message); 85 } 86 } 87 88 /// For reporting a compiler error. 89 class GeneralError : Problem 90 { 91 this(Location location, cstring message) 92 { 93 super(location, message); 94 } 95 } 96 97 /// An error reported by the Lexer. 98 class LexerError : GeneralError 99 { 100 this(Location location, cstring message) 101 { 102 super(location, message); 103 } 104 } 105 106 /// An error reported by the Parser. 107 class ParserError : GeneralError 108 { 109 this(Location location, cstring message) 110 { 111 super(location, message); 112 } 113 } 114 115 /// An error reported by a semantic analyzer. 116 class SemanticError : GeneralError 117 { 118 this(Location location, cstring message) 119 { 120 super(location, message); 121 } 122 }