1 module ddc.lexer.exceptions; 2 3 import std.conv; 4 5 import ddc.lexer.textsource; 6 7 class ParserException : Exception { 8 protected string _msg; 9 protected SourceFile _file; 10 protected int _line; 11 protected int _pos; 12 13 @property SourceFile file() { return _file; } 14 @property string msg() { return _msg; } 15 @property int line() { return _line; } 16 @property int pos() { return _pos; } 17 18 this(string msg, SourceFile file, int line, int pos) { 19 super(msg ~ " at " ~ file.toString ~ " line " ~ to!string(line) ~ " column " ~ to!string(pos)); 20 _msg = msg; 21 _file = file; 22 _line = line; 23 _pos = pos; 24 } 25 } 26 27 class LexerException : ParserException { 28 this(string msg, SourceFile file, int line, int pos) { 29 super(msg, file, line, pos); 30 } 31 } 32 33 class SourceEncodingException : LexerException { 34 this(string msg, SourceFile file, int line, int pos) { 35 super(msg, file, line, pos); 36 } 37 }