Diff
Not logged in

Differences From Artifact [cc80329bc2ab2034]:

To Artifact [df057f5d35e6bc8a]:


11 11 12 12 /// Exception from this module 13 13 14 14 class LexException : Exception 15 15 { 16 16 const LexPosition pos; 17 17 18 - private this( const LexPosition pos, string msg ) 19 - { super(sprintf!"%s [%s]"(msg, pos)); this.pos = pos; } 18 + this( const LexPosition pos, string msg, string file="", int line=0 ) 19 + { super(sprintf!"[%s] %s"(pos, msg), file, line); this.pos = pos; } 20 20 }; 21 21 22 22 /// Represents a position in a source code 23 23 24 24 class LexPosition 25 25 { 26 26 immutable string filename; /// name of the source file 27 27 immutable int lineno; /// 1-origin 28 28 immutable int column; /// 1-origin 29 29 30 + mixin SimpleClass; 30 31 override string toString() const 31 32 { return sprintf!"%s:%d:%d"(filename, lineno, column); } 32 33 33 - mixin SimpleConstructor; 34 - mixin SimpleCompare; 35 - 36 34 static immutable LexPosition dummy; 37 35 static this(){ dummy = new immutable(LexPosition)("<unnamed>",0,0); } 38 36 } 39 37 40 38 unittest 41 39 { 42 40 auto p = new LexPosition("hello.cpp", 123, 45); ................................................................................ 59 57 60 58 class Token 61 59 { 62 60 immutable LexPosition pos; /// Position where the token occurred in the source 63 61 immutable string str; /// The token string itself 64 62 immutable bool quoted; /// Was it a "quoted" token or unquoted? 65 63 66 - mixin SimpleConstructor; 67 - mixin SimpleCompare; 68 - mixin SimpleToString; 64 + mixin SimpleClass; 69 65 } 70 66 71 67 unittest 72 68 { 73 69 auto p = new immutable(LexPosition)("hello.cpp", 123, 45); 74 70 auto t = new Token(p, "class", false); 75 71 auto u = new Token(p, "class", true);