CommentBriefParser.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===--- CommentBriefParser.h - Dumb comment parser -------------*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. //
  14. // This file defines a very simple Doxygen comment parser.
  15. //
  16. //===----------------------------------------------------------------------===//
  17. #ifndef LLVM_CLANG_AST_COMMENTBRIEFPARSER_H
  18. #define LLVM_CLANG_AST_COMMENTBRIEFPARSER_H
  19. #include "clang/AST/CommentLexer.h"
  20. namespace clang {
  21. namespace comments {
  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.
  29. class BriefParser {
  30. Lexer &L;
  31. const CommandTraits &Traits;
  32. /// Current lookahead token.
  33. Token Tok;
  34. SourceLocation ConsumeToken() {
  35. SourceLocation Loc = Tok.getLocation();
  36. L.lex(Tok);
  37. return Loc;
  38. }
  39. public:
  40. BriefParser(Lexer &L, const CommandTraits &Traits);
  41. /// Return the best "brief description" we can find.
  42. std::string Parse();
  43. };
  44. } // end namespace comments
  45. } // end namespace clang
  46. #endif
  47. #ifdef __GNUC__
  48. #pragma GCC diagnostic pop
  49. #endif