2012-06-26 20:39:18 +00:00
|
|
|
//===--- CommentBriefParser.cpp - Dumb comment parser ---------------------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "clang/AST/CommentBriefParser.h"
|
|
|
|
|
|
|
|
namespace clang {
|
|
|
|
namespace comments {
|
|
|
|
|
|
|
|
std::string BriefParser::Parse() {
|
2012-06-27 01:17:34 +00:00
|
|
|
std::string Paragraph;
|
2012-06-26 20:39:18 +00:00
|
|
|
bool InFirstParagraph = true;
|
|
|
|
bool InBrief = false;
|
|
|
|
bool BriefDone = false;
|
|
|
|
|
|
|
|
while (Tok.isNot(tok::eof)) {
|
|
|
|
if (Tok.is(tok::text)) {
|
2012-06-27 01:17:34 +00:00
|
|
|
if (InFirstParagraph || InBrief)
|
|
|
|
Paragraph += Tok.getText();
|
2012-06-26 20:39:18 +00:00
|
|
|
ConsumeToken();
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!BriefDone && Tok.is(tok::command) && Tok.getCommandName() == "brief") {
|
2012-06-27 01:17:34 +00:00
|
|
|
Paragraph.clear();
|
2012-06-26 20:39:18 +00:00
|
|
|
InBrief = true;
|
|
|
|
ConsumeToken();
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Tok.is(tok::newline)) {
|
2012-06-27 01:17:34 +00:00
|
|
|
if (InFirstParagraph || InBrief)
|
|
|
|
Paragraph += '\n';
|
2012-06-26 20:39:18 +00:00
|
|
|
ConsumeToken();
|
|
|
|
|
|
|
|
if (Tok.is(tok::newline)) {
|
|
|
|
ConsumeToken();
|
|
|
|
// We found a paragraph end.
|
|
|
|
InFirstParagraph = false;
|
|
|
|
if (InBrief) {
|
|
|
|
InBrief = false;
|
|
|
|
BriefDone = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// We didn't handle this token, so just drop it.
|
|
|
|
ConsumeToken();
|
|
|
|
}
|
|
|
|
|
2012-06-27 01:17:34 +00:00
|
|
|
return Paragraph;
|
2012-06-26 20:39:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
BriefParser::BriefParser(Lexer &L) : L(L)
|
|
|
|
{
|
|
|
|
// Get lookahead token.
|
|
|
|
ConsumeToken();
|
|
|
|
}
|
|
|
|
|
|
|
|
} // end namespace comments
|
|
|
|
} // end namespace clang
|
|
|
|
|
|
|
|
|