From 552d0bbb074445979675ab9784baf8119c6e1f3e Mon Sep 17 00:00:00 2001 From: Hackerpilot Date: Thu, 30 Jan 2014 20:00:20 -0800 Subject: [PATCH] Solved the mystery of the disappearing doc comments --- main.d | 5 ++--- stdx/d/lexer.d | 10 ++++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/main.d b/main.d index 3b3103a..6a5897f 100644 --- a/main.d +++ b/main.d @@ -109,12 +109,11 @@ int main(string[] args) } else if (tokenDump) { - writeln("text blank\tindex\tline\tcolumn\tcomment"); + writeln("text blank\tindex\tline\tcolumn"); foreach (token; tokens) { writefln("<<%20s>>%b\t%d\t%d\t%d", token.text is null ? str(token.type) : token.text, - token.text !is null, token.index, token.line, token.column, - token.comment); + token.text !is null, token.index, token.line, token.column); } return 0; } diff --git a/stdx/d/lexer.d b/stdx/d/lexer.d index 670afcb..cbff766 100644 --- a/stdx/d/lexer.d +++ b/stdx/d/lexer.d @@ -412,13 +412,14 @@ public struct DLexer private static bool isDocComment(string comment) pure nothrow @safe { - return comment.length >= 3 && (comment[0 .. 3] == "///" - || comment[0 .. 3] == "/**" || comment[0 .. 3] == "/++"); + return comment.length >= 3 && (comment[2] == '/' + || comment[2] == '*' || comment[2] == '+'); } public void popFront() pure { _popFront(); + string comment = null; switch (front.type) { case tok!"comment": @@ -427,9 +428,9 @@ public struct DLexer import std.string; if (isDocComment(front.text)) { - _front.comment = _front.comment == null + comment = comment is null ? front.text - : format("%s\n%s", _front.comment, front.text); + : format("%s\n%s", comment, front.text); } do _popFront(); while (front == tok!"comment"); if (front == tok!"whitespace") goto case tok!"whitespace"; @@ -445,6 +446,7 @@ public struct DLexer default: break; } + _front.comment = comment; }