Doxygen
Loading...
Searching...
No Matches
commentcnv.h File Reference

First pass comment processing. More...

#include <string>
+ Include dependency graph for commentcnv.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void convertCppComments (const std::string &inBuf, std::string &outBuf, const std::string &fn)
 Converts the comments in a file.
 

Detailed Description

First pass comment processing.

Definition in file commentcnv.h.

Function Documentation

◆ convertCppComments()

void convertCppComments ( const std::string & inBuf,
std::string & outBuf,
const std::string & fn )

Converts the comments in a file.

Parameters
inBufinput buffer holding the file content.
outBufoutput buffer to which the results after conversion are written to.
fnthe name of the file from which the comments originate.

The following is converted:

  • C++ style multiline doxygen comments are converted to C style doxygen comments.
  • conditional sections are processed.
  • aliases are expanded.

This function does three things:

  1. It converts multi-line C++ style comment blocks (that are aligned) to C style comment blocks (if MULTILINE_CPP_IS_BRIEF is set to NO).
  2. It replaces aliases with their definition (see ALIASES)
  3. It handles conditional sections (cond...endcond blocks)

Definition at line 1870 of file commentcnv.l.

1871{
1872 QCString fileName { fn };
1873 yyscan_t yyscanner;
1874 commentcnvYY_state extra(&inBuf,outBuf);
1875 commentcnvYYlex_init_extra(&extra,&yyscanner);
1876#ifdef FLEX_DEBUG
1877 commentcnvYYset_debug(Debug::isFlagSet(Debug::Lex_commentcnv)?1:0,yyscanner);
1878#endif
1879 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1880 //printf("convertCppComments(%s)\n",qPrint(fileName));
1881 yyextra->inBufPos = 0;
1882 yyextra->col = 0;
1883 yyextra->mlBrief = Config_getBool(MULTILINE_CPP_IS_BRIEF);
1884 yyextra->skip = FALSE;
1885 yyextra->fileName = fileName;
1886 yyextra->lang = getLanguageFromFileName(fileName);
1887 yyextra->pythonDocString = FALSE;
1888 yyextra->lineNr = 1;
1889 yyextra->raiseLevel = 0;
1890 yyextra->raiseLabel = "";
1891 yyextra->raiseIncrement = 0;
1892 yyextra->raisePrefix = "";
1893 yyextra->insertCppCommentMarker=false;
1894 yyextra->expandedAliases.clear();
1895 while (!yyextra->condStack.empty()) yyextra->condStack.pop();
1896 clearCommentStack(yyscanner);
1897 yyextra->vhdl = FALSE;
1898
1899 DebugLex debugLex(Debug::Lex_commentcnv,__FILE__, qPrint(fileName));
1900 yyextra->isFixedForm = FALSE;
1901 if (yyextra->lang==SrcLangExt::Fortran)
1902 {
1904 yyextra->isFixedForm = recognizeFixedForm(QCString(inBuf),fmt);
1905 }
1906
1907 if (yyextra->lang==SrcLangExt::Markdown)
1908 {
1909 yyextra->nestingCount=0;
1910 BEGIN(CComment);
1911 yyextra->commentStack.push(yyextra->lineNr);
1912 }
1913 else
1914 {
1915 BEGIN(Scan);
1916 }
1917 yylex(yyscanner);
1918 while (!yyextra->condStack.empty())
1919 {
1920 const commentcnvYY_CondCtx &ctx = yyextra->condStack.top();
1921 QCString sectionInfo(" ");
1922 if (ctx.sectionId!=" ") sectionInfo.sprintf(" with label '%s' ",ctx.sectionId.stripWhiteSpace().data());
1923 warn(yyextra->fileName,ctx.lineNr,"Conditional section%sdoes not have "
1924 "a corresponding \\endcond command within this file.",sectionInfo.data());
1925 yyextra->condStack.pop();
1926 }
1927 if (yyextra->nestingCount>0 && yyextra->lang!=SrcLangExt::Markdown && yyextra->lang!=SrcLangExt::Fortran)
1928 {
1929 QCString tmp("(probable line reference: ");
1930 bool first = TRUE;
1931 while (!yyextra->commentStack.empty())
1932 {
1933 int lineNr = yyextra->commentStack.top();
1934 if (!first) tmp += ", ";
1935 tmp += QCString().setNum(lineNr);
1936 first = FALSE;
1937 yyextra->commentStack.pop();
1938 }
1939 tmp += ")";
1940 warn(yyextra->fileName,yyextra->lineNr,"Reached end of file while still inside a (nested) comment. "
1941 "Nesting level %d %s",yyextra->nestingCount,tmp.data());
1942 }
1943 yyextra->nestingCount = 0;
1945 {
1946 Debug::print(Debug::CommentCnv,0,"-----------\nCommentCnv: %s\n"
1947 "output=[\n%s]\n-----------\n",qPrint(fileName),qPrint(yyextra->outBuf)
1948 );
1949 }
1950 commentcnvYYlex_destroy(yyscanner);
1951}
@ Lex_commentcnv
Definition debug.h:51
@ CommentCnv
Definition debug.h:30
static void print(DebugMask mask, int prio, const char *fmt,...)
Definition debug.cpp:80
static bool isFlagSet(const DebugMask mask)
Definition debug.cpp:134
This is an alternative implementation of QCString.
Definition qcstring.h:94
QCString stripWhiteSpace() const
returns a copy of this string with leading and trailing whitespace removed
Definition qcstring.h:238
QCString & setNum(short n)
Definition qcstring.h:435
const char * data() const
Returns a pointer to the contents of the string in the form of a 0-terminated C string.
Definition qcstring.h:152
yyguts_t * yyscan_t
Definition code.l:24
static void clearCommentStack(yyscan_t yyscanner)
#define Config_getBool(name)
Definition config.h:33
int yylex(void)
#define warn(file, line, fmt,...)
Definition message.h:59
Definition trace.h:153
const char * qPrint(const char *s)
Definition qcstring.h:652
#define TRUE
Definition qcstring.h:37
#define FALSE
Definition qcstring.h:34
FortranFormat
Definition types.h:301
SrcLangExt getLanguageFromFileName(const QCString &fileName, SrcLangExt defLang)
Definition util.cpp:5472
bool recognizeFixedForm(const QCString &contents, FortranFormat format)
Definition util.cpp:6693
FortranFormat convertFileNameFortranParserCode(QCString fn)
Definition util.cpp:6746

References clearCommentStack(), Debug::CommentCnv, Config_getBool, convertFileNameFortranParserCode(), QCString::data(), FALSE, Fortran, getLanguageFromFileName(), Debug::isFlagSet(), Debug::Lex_commentcnv, commentcnvYY_CondCtx::lineNr, Markdown, Debug::print(), qPrint(), recognizeFixedForm(), commentcnvYY_CondCtx::sectionId, QCString::setNum(), QCString::sprintf(), QCString::stripWhiteSpace(), TRUE, warn, and yylex().

Referenced by parseFile().