CommentBriefParser.h revision 72021ff4038cbc48b09a3acb743e319809f086db
1//===--- CommentBriefParser.h - Dumb comment parser -------------*- C++ -*-===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10//  This file defines a very simple Doxygen comment parser.
11//
12//===----------------------------------------------------------------------===//
13
14
15#ifndef LLVM_CLANG_AST_BRIEF_COMMENT_PARSER_H
16#define LLVM_CLANG_AST_BRIEF_COMMENT_PARSER_H
17
18#include "clang/AST/CommentLexer.h"
19
20namespace clang {
21namespace comments {
22
23/// A very simple comment parser that extracts "a brief description".
24///
25/// Due to a variety of comment styles, it considers the following as "a brief
26/// description", in order of priority:
27/// \li a \\brief or \\short command,
28/// \li the first paragraph,
29/// \li a \\result or \\return or \\returns paragraph.
30class BriefParser {
31  Lexer &L;
32
33  /// Current lookahead token.
34  Token Tok;
35
36  SourceLocation ConsumeToken() {
37    SourceLocation Loc = Tok.getLocation();
38    L.lex(Tok);
39    return Loc;
40  }
41
42public:
43  BriefParser(Lexer &L);
44
45  /// Return \\brief paragraph, if it exists; otherwise return the first
46  /// paragraph.
47  std::string Parse();
48};
49
50} // end namespace comments
51} // end namespace clang
52
53#endif
54
55