Mercurial > projects > dil
changeset 388:ae154eceba65
Applied some fixes to scanning and printing #line tokens.
Fix: Token.line_num can be null which could cause a segfault in printToken().
Renamed MID.ExpectedNumberAfterSTLine to ExpectedIntegerAfterSTLine.
Fix: Added a check for TOK.Int32 and TOK.Uint32 after a number was scanned
in scanSpecialTokenSequence().
author | Aziz K?ksal <aziz.koeksal@gmail.com> |
---|---|
date | Wed, 12 Sep 2007 13:43:45 +0200 |
parents | ad0cbd1c8881 |
children | c4bfceab7246 |
files | trunk/src/cmd/Generate.d trunk/src/dil/Lexer.d trunk/src/dil/Messages.d |
diffstat | 3 files changed, 24 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/trunk/src/cmd/Generate.d Wed Sep 12 12:04:21 2007 +0200 +++ b/trunk/src/cmd/Generate.d Wed Sep 12 13:43:45 2007 +0200 @@ -169,7 +169,7 @@ // Keyword `<span class="k">%s</span>`, // HLineBegin - `<span class="hl">#line`, + `<span class="hl">`, // HLineEnd "</span>", // Filespec @@ -232,7 +232,7 @@ // Keyword "<k>%s</k>", // HLineBegin - "<hl>#line", + "<hl>", // HLineEnd "</hl>", // Filespec @@ -475,9 +475,15 @@ } writef(tags[DP.HLineBegin]); auto num = token.line_num; + if (num is null) + { + writef(token.start[0 .. token.end - token.start]); + writef(tags[DP.HLineEnd]); + break; + } // Print whitespace between #line and number - auto ptr = token.start + "#line".length; - printWS(ptr, num.start); + auto ptr = token.start; + printWS(ptr, num.start); // prints "#line" as well printToken(num, tags); if (token.line_filespec) {
--- a/trunk/src/dil/Lexer.d Wed Sep 12 12:04:21 2007 +0200 +++ b/trunk/src/dil/Lexer.d Wed Sep 12 13:43:45 2007 +0200 @@ -1711,10 +1711,12 @@ } p += 3; + // TODO: #line58"path/file" is legal. Require spaces? + // State.Space could be used for that purpose. enum State - { Number, Filespec, End } + { /+Space,+/ Integer, Filespec, End } - State state; + State state = State.Integer; Loop: while (1) @@ -1736,16 +1738,21 @@ default: if (isspace(*p)) continue; - if (state == State.Number) + if (state == State.Integer) { if (!isdigit(*p)) { - mid = MID.ExpectedNumberAfterSTLine; + mid = MID.ExpectedIntegerAfterSTLine; goto Lerr; } t.line_num = new Token; scan(*t.line_num); --p; + if (t.line_num.type != TOK.Int32 && t.line_num.type != TOK.Uint32) + { + mid = MID.ExpectedIntegerAfterSTLine; + goto Lerr; + } state = State.Filespec; } else if (state == State.Filespec) @@ -1791,9 +1798,9 @@ } } - if (state == State.Number) + if (state == State.Integer) { - mid = MID.ExpectedNumberAfterSTLine; + mid = MID.ExpectedIntegerAfterSTLine; goto Lerr; }
--- a/trunk/src/dil/Messages.d Wed Sep 12 12:04:21 2007 +0200 +++ b/trunk/src/dil/Messages.d Wed Sep 12 13:43:45 2007 +0200 @@ -17,7 +17,7 @@ EmptyCharacterLiteral, // #line ExpectedIdentifierSTLine, - ExpectedNumberAfterSTLine, + ExpectedIntegerAfterSTLine, ExpectedFilespec, UnterminatedFilespec, UnterminatedSpecialToken,