@@ -14,10 +14,10 @@ class LexException : Exception { const LexPosition pos; - this( const LexPosition pos, string msg, string file="", int line=0 ) - { super(sprintf!"[%s] %s"(pos, msg), file, line); this.pos = pos; } + this( const LexPosition pos, string msg, string file="", int line=0, Throwable next=null ) + { super(sprintf!"[%s] %s"(pos, msg), file, line, next); this.pos = pos; } }; /// Represents a position in a source code @@ -37,21 +37,22 @@ unittest { auto p = new LexPosition("hello.cpp", 123, 45); - auto q = new LexPosition("hello.cpp", 123, 46); assert_eq( p.filename, "hello.cpp" ); assert_eq( p.lineno, 123 ); assert_eq( p.column, 45 ); assert_eq( to!string(p), "hello.cpp:123:45" ); - assert_lt( p, q ); - assert_ne( p, q ); assert( !__traits(compiles, new LexPosition) ); assert( !__traits(compiles, p.filename="foo") ); assert( !__traits(compiles, p.lineno =789) ); assert( !__traits(compiles, p.column =222) ); + + auto q = new LexPosition("hello.cpp", 123, 46); + assert_lt( p, q ); + assert_ne( p, q ); } /// Represents a lexer token @@ -160,9 +161,9 @@ string readQuoted(const LexPosition pos){char[] buf; return readQuoted(pos,buf);} string readQuoted(const LexPosition pos, ref char[] buf) { if( reader.empty ) - throw new LexException(pos, "EOF found while lexing a quoted-string"); + throw genex!LexException(pos, "EOF found while lexing a quoted-string"); dchar c = reader.front; reader.popFront; if( c == '"' ) return assumeUnique(buf); @@ -226,8 +227,9 @@ unittest { assert( std.range.isForwardRange!(Lexer) ); + assert( is(ElementType!(Lexer) == Token) ); } unittest {