11573Srgrimes//===--- CommentBriefParser.h - Dumb comment parser -------------*- C++ -*-===//
21573Srgrimes//
31573Srgrimes// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
41573Srgrimes// See https://llvm.org/LICENSE.txt for license information.
51573Srgrimes// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
61573Srgrimes//
71573Srgrimes//===----------------------------------------------------------------------===//
81573Srgrimes//
91573Srgrimes//  This file defines a very simple Doxygen comment parser.
101573Srgrimes//
111573Srgrimes//===----------------------------------------------------------------------===//
121573Srgrimes
131573Srgrimes
141573Srgrimes#ifndef LLVM_CLANG_AST_COMMENTBRIEFPARSER_H
151573Srgrimes#define LLVM_CLANG_AST_COMMENTBRIEFPARSER_H
161573Srgrimes
171573Srgrimes#include "clang/AST/CommentLexer.h"
181573Srgrimes
191573Srgrimesnamespace clang {
201573Srgrimesnamespace comments {
211573Srgrimes
221573Srgrimes/// A very simple comment parser that extracts "a brief description".
231573Srgrimes///
241573Srgrimes/// Due to a variety of comment styles, it considers the following as "a brief
251573Srgrimes/// description", in order of priority:
261573Srgrimes/// \li a \or \\short command,
271573Srgrimes/// \li the first paragraph,
281573Srgrimes/// \li a \\result or \\return or \\returns paragraph.
291573Srgrimesclass BriefParser {
301573Srgrimes  Lexer &L;
311573Srgrimes
321573Srgrimes  const CommandTraits &Traits;
331573Srgrimes
341573Srgrimes  /// Current lookahead token.
351573Srgrimes  Token Tok;
361573Srgrimes
371573Srgrimes  SourceLocation ConsumeToken() {
381573Srgrimes    SourceLocation Loc = Tok.getLocation();
391573Srgrimes    L.lex(Tok);
401573Srgrimes    return Loc;
411573Srgrimes  }
421573Srgrimes
431573Srgrimespublic:
441573Srgrimes  BriefParser(Lexer &L, const CommandTraits &Traits);
451573Srgrimes
463050Sache  /// Return the best "brief description" we can find.
473050Sache  std::string Parse();
481573Srgrimes};
493050Sache
501573Srgrimes} // end namespace comments
511573Srgrimes} // end namespace clang
521573Srgrimes
531573Srgrimes#endif
541573Srgrimes
551573Srgrimes