Mercurial > projects > dil
diff trunk/src/dil/doc/Parser.d @ 741:35184354a502
Added method textBody() to IdentValueParser.
Applied some fixes.
author | Aziz K?ksal <aziz.koeksal@gmail.com> |
---|---|
date | Sat, 09 Feb 2008 16:18:53 +0100 |
parents | f88b5285b86b |
children | 7299159c3a19 |
line wrap: on
line diff
--- a/trunk/src/dil/doc/Parser.d Sat Feb 09 15:10:13 2008 +0100 +++ b/trunk/src/dil/doc/Parser.d Sat Feb 09 16:18:53 2008 +0100 @@ -46,15 +46,31 @@ // Continue. while (findNextIdent(nextIdent, nextBodyBegin)) { - idvalues ~= new IdentValue(ident, makeString(bodyBegin, nextIdent.ptr)); + idvalues ~= new IdentValue(ident, textBody(bodyBegin, nextIdent.ptr)); ident = nextIdent; bodyBegin = nextBodyBegin; } // Add last ident value. - idvalues ~= new IdentValue(ident, makeString(bodyBegin, textEnd)); + idvalues ~= new IdentValue(ident, textBody(bodyBegin, textEnd)); return idvalues; } + /// Removes trailing whitespace characters from the text body. + char[] textBody(char* begin, char* end) + { + // The body of A is empty, e.g.: + // A = + // B = some text + // ^- begin and end point to B (or to this.textEnd in the 2nd case.) + if (begin is end) + return null; + // Remove trailing whitespace. + while (isspace(*--end) || *end == '\n') + {} + end++; + return makeString(begin, end); + } + bool findNextIdent(ref string ident, ref char* bodyBegin) { while (p < textEnd)