1//===--- CommentBriefParser.h - Dumb comment parser -------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9//  This file defines a very simple Doxygen comment parser.
10//
11//===----------------------------------------------------------------------===//
12
13
14#ifndef LLVM_CLANG_AST_COMMENTBRIEFPARSER_H
15#define LLVM_CLANG_AST_COMMENTBRIEFPARSER_H
16
17#include "clang/AST/CommentLexer.h"
18
19namespace clang {
20namespace comments {
21
22/// A very simple comment parser that extracts "a brief description".
23///
24/// Due to a variety of comment styles, it considers the following as "a brief
25/// description", in order of priority:
26/// \li a \or \\short command,
27/// \li the first paragraph,
28/// \li a \\result or \\return or \\returns paragraph.
29class BriefParser {
30  Lexer &L;
31
32  const CommandTraits &Traits;
33
34  /// Current lookahead token.
35  Token Tok;
36
37  SourceLocation ConsumeToken() {
38    SourceLocation Loc = Tok.getLocation();
39    L.lex(Tok);
40    return Loc;
41  }
42
43public:
44  BriefParser(Lexer &L, const CommandTraits &Traits);
45
46  /// Return the best "brief description" we can find.
47  std::string Parse();
48};
49
50} // end namespace comments
51} // end namespace clang
52
53#endif
54
55