@@ -8,10 +8,8 @@ import polemy._common; import std.file : readText; import std.ctype : isspace, isalnum; -/// Exception from this module - /*mixin*/ template ExceptionWithPosition() { const LexPosition pos; @@ -18,13 +16,15 @@ this( const LexPosition pos, string msg, string file=null, size_t line=0, Throwable next=null ) { super(sprintf!"[%s] %s"(pos, msg), file, line, next); this.pos = pos; } } +/// class UnexpectedEOF : Exception { mixin ExceptionWithPosition; } +/// class LexException : Exception { mixin ExceptionWithPosition; }; @@ -96,14 +96,17 @@ } /// Named Construtors for Lexer -auto lexerFromFile(T...)( string filename, T rest ) +Lexer lexerFromFile(T...)( string filename, T rest ) { return lexerFromString( std.file.readText(filename), filename, rest ); } -auto lexerFromString(CharSeq)( CharSeq str, string filename="", int lineno=1, int column=1 ) +/// Named Construtors for Lexer + +LexerT!(PositionedReader!CharSeq) /* ddoc doesn't recognize auto return... bugzilla:2581 */ +lexerFromString(CharSeq)( CharSeq str, string filename="", int lineno=1, int column=1 ) { return new LexerT!(PositionedReader!CharSeq)( PositionedReader!CharSeq(str, filename, lineno, column) );