Mercurial > projects > dil
diff trunk/src/dil/Lexer.d @ 371:01887f05d4b0
- Added members loc_old and loc_hline to class Lexer.
- Added method errorLoc() for calculating error line number.
author | aziz |
---|---|
date | Thu, 06 Sep 2007 07:10:03 +0000 |
parents | ae4afb66768f |
children | 66477017cb95 |
line wrap: on
line diff
--- a/trunk/src/dil/Lexer.d Mon Sep 03 16:29:02 2007 +0000 +++ b/trunk/src/dil/Lexer.d Thu Sep 06 07:10:03 2007 +0000 @@ -35,7 +35,10 @@ char* p; /// Points to the current character in the source text. char* end; /// Points one character past the end of the source text. - uint loc = 1; /// line of code + uint loc = 1; /// Actual line of code. + + uint loc_old; /// Store actual line number when #line token is parsed. + uint loc_hline; /// Line number set by #line. char[] fileName; @@ -1532,7 +1535,8 @@ goto Lerr; } - this.loc = t.line_num.uint_ - 1; + this.loc_old = this.loc; + this.loc_hline = t.line_num.uint_ - 1; if (t.line_filespec) this.fileName = t.line_filespec.str; t.end = p; @@ -1543,6 +1547,12 @@ error(mid); } + uint errorLoc() + { + // ∆loc + line_num_of(#line) + return this.loc - this.loc_old + this.loc_hline; + } + dchar decodeUTF8() { assert(*p & 128, "check for ASCII char before calling decodeUTF8()."); @@ -1633,7 +1643,7 @@ void error(MID id, ...) { // if (reportErrors) - errors ~= new Information(InfoType.Lexer, id, loc, arguments(_arguments, _argptr)); + errors ~= new Information(InfoType.Lexer, id, this.errorLoc, arguments(_arguments, _argptr)); } unittest