19 #define YY_BUF_SIZE 10*1024*1024
22%option never-interactive
23%option prefix="commentcnvYY"
25%option extra-type="struct commentcnvYY_state *"
29#define YY_TYPEDEF_YY_SCANNER_T
59#define YY_NO_UNISTD_H 1
163#define YY_INPUT(buf,result,max_size) result=yyread(yyscanner,buf,max_size);
This is an alternative implementation of QCString.
Token literal values and constants.
Some helper functions for std::string.
A bunch of utility functions.
171MAILADDR ("mailto:")?[a-z_A-Z0-9\x80-\xff.+-]+"@"[a-z_A-Z0-9\x80-\xff-]+("."[a-z_A-Z0-9\x80-\xff\-]+)+[a-z_A-Z0-9\x80-\xff\-]+
197DECIMAL_INTEGER [1-9][0-9']*[0-9]?[uU]?[lL]?[lL]?
198HEXADECIMAL_INTEGER "0"[xX][0-9a-zA-Z']+[0-9a-zA-Z]?
199OCTAL_INTEGER "0"[0-7][0-7']+[0-7]?
200BINARY_INTEGER "0"[bB][01][01']*[01]?
201INTEGER_NUMBER {DECIMAL_INTEGER}|{HEXADECIMAL_INTEGER}|{OCTAL_INTEGER}|{BINARY_INTEGER}
205DIGIT_SEQ [0-9][0-9']*[0-9]?
206FRAC_CONST {DIGIT_SEQ}"."|{DIGIT_SEQ}?"."{DIGIT_SEQ}
207FP_EXP [eE][+-]?{DIGIT_SEQ}
208DEC_FP1 {FRAC_CONST}{FP_EXP}?{FP_SUF}?
209DEC_FP2 {DIGIT_SEQ}{FP_EXP}{FP_SUF}
211HEX_DIGIT_SEQ [0-9a-fA-F][0-9a-fA-F']*[0-9a-fA-F]?
212HEX_FRAC_CONST {HEX_DIGIT_SEQ}"."|{HEX_DIGIT_SEQ}?"."{HEX_DIGIT_SEQ}
213BIN_EXP [pP][+-]?{DIGIT_SEQ}
214HEX_FP1 "0"[xX]{HEX_FRAC_CONST}{BIN_EXP}{FP_SUF}?
215HEX_FP2 "0"[xX]{HEX_DIGIT_SEQ}{BIN_EXP}{FP_SUF}?
217FLOAT_DECIMAL {DEC_FP1}|{DEC_FP2}
218FLOAT_HEXADECIMAL {HEX_FP1}|{HEX_FP2}
219FLOAT_NUMBER {FLOAT_DECIMAL}|{FLOAT_HEXADECIMAL}
220NUMBER {INTEGER_NUMBER}|{FLOAT_NUMBER}
222FILEICHAR [a-z_A-Z0-9\x80-\xFF\\:\\\/\-\+=&#@]
223FILEECHAR [a-z_A-Z0-9\x80-\xFF\-\+=&#@]
224FILECHARS {FILEICHAR}*{FILEECHAR}+
225HFILEMASK {FILEICHAR}*("."{FILEICHAR}+)+{FILECHARS}*
226VFILEMASK {FILECHARS}("."{FILECHARS})*
227FILEMASK {VFILEMASK}|{HFILEMASK}
255 if (yyextra->lang!=SrcLangExt::Cpp) REJECT;
258<Scan>[^"'!\/\n\\#,\-=; \t@$]* {
266 if (yyextra->lang!=SrcLangExt::Python)
272 yyextra->pythonDocString =
TRUE;
273 yyextra->pythonDocStringChar = yytext[0];
274 yyextra->nestingCount=1;
278 yyextra->commentStack.push(yyextra->lineNr);
283 if (yyextra->lang!=SrcLangExt::Python)
293 yyextra->pythonDocString =
TRUE;
294 yyextra->pythonDocStringChar = yytext[0];
295 yyextra->nestingCount=1;
299 yyextra->commentStack.push(yyextra->lineNr);
#define Config_getBool(name)
302<Scan>{B}*![><!]/.*\n {
303 if (yyextra->lang!=SrcLangExt::Fortran)
309 yyextra->nestingCount=0;
311 yyextra->specialComment=
true;
313 yyextra->blockHeadCol=yyextra->col-2;
315 yyextra->commentStack.push(yyextra->lineNr);
318<Scan>[Cc\*][><!]/.*\n {
319 if (yyextra->lang!=SrcLangExt::Fortran)
326 if (yyextra->isFixedForm && (yyextra->col == 0))
328 yyextra->nestingCount=0;
330 yyextra->specialComment=
true;
332 yyextra->blockHeadCol=yyextra->col-1;
334 yyextra->commentStack.push(yyextra->lineNr);
343 if (yyextra->lang!=SrcLangExt::Fortran)
353 if (yyextra->lang!=SrcLangExt::Fortran)
359 if (yyextra->col == 0)
370 if (yyextra->lang!=SrcLangExt::CSharp) REJECT
372 yyextra->stringContext = YY_START;
373 BEGIN(SkipVerbString);
377 yyextra->stringContext = YY_START;
382 yyextra->charContext = YY_START;
383 if (yyextra->lang!=SrcLangExt::VHDL)
391<Scan>{CPPC}"!"/.*\n[ \t]*{CPPC}[\/!][^\/] |
392<Scan>({CPPC}"/"[/]*)/[^/].*\n[ \t]*{CPPC}[\/!][^\/] {
393 if (yyextra->mlBrief)
402 while (i<(
int)yyleng && yytext[i]==
'/') i++;
404 yyextra->blockHeadCol=yyextra->col+1;
405 if (yytext[2] ==
'!')
414 yyextra->inSpecialComment=
TRUE;
416 yyextra->readLineCtx=SComment;
420<Scan>{CPPC}"##Documentation"{ANYopt}/\n {
421 if (yyextra->mlBrief) REJECT;
423 yyextra->blockHeadCol=yyextra->col+1;
426 yyextra->inRoseComment=
TRUE;
429<Scan>{CPPC}[!\/]/.*\n[ \t]*{CPPC}[|\/][ \t]*[@\\]"}" {
430 yyextra->inSpecialComment=yytext[2]==
'/' || yytext[2]==
'!';
431 if (yyextra->inSpecialComment)
433 yyextra->blockHeadCol=yyextra->col+1;
436 yyextra->readLineCtx=YY_START;
439<Scan>{CPPC}[!/]/.*\n {
440 yyextra->inSpecialComment=
true;
441 yyextra->blockHeadCol=yyextra->col+1;
442 yyextra->insertCppCommentMarker=
true;
444 yyextra->readLineCtx=YY_START;
448 yyextra->inSpecialComment=
false;
450 yyextra->readLineCtx=YY_START;
457 if (yyextra->lang==SrcLangExt::Python)
461 yyextra->specialComment=(int)yyleng==3;
462 yyextra->nestingCount=1;
465 if (yyextra->specialComment)
467 yyextra->blockHeadCol=0;
474 yyextra->commentStack.push(yyextra->lineNr);
477 if (yyextra->lang!=SrcLangExt::PHP)
484 if (yyextra->lang!=SrcLangExt::Python)
490 yyextra->nestingCount=0;
492 yyextra->specialComment=(int)yyleng==2;
493 if (yyextra->specialComment)
495 yyextra->blockHeadCol=yyextra->col;
497 yyextra->commentStack.push(yyextra->lineNr);
502<Scan>"--"[^!][^\n]* {
503 if (yyextra->lang!=SrcLangExt::VHDL)
513 if (yyextra->lang!=SrcLangExt::VHDL)
519 yyextra->specialComment=
true;
520 yyextra->blockHeadCol=yyextra->col;
521 yyextra->vhdl =
TRUE;
522 yyextra->nestingCount=0;
524 yyextra->commentStack.push(yyextra->lineNr);
530 if (yyextra->lang!=SrcLangExt::Fortran)
536 yyextra->nestingCount=0;
538 yyextra->specialComment=
true;
539 yyextra->blockHeadCol=yyextra->col;
540 yyextra->commentStack.push(yyextra->lineNr);
545<CComment,CNComment,ReadLine,IncludeFile>{MAILADDR} |
546<CComment,CNComment,ReadLine,IncludeFile>"<"{MAILADDR}">" {
549<CComment,IncludeFile>"{"[ \t]*"@code"/[ \t\n] {
551 yyextra->lastCommentContext = YY_START;
552 yyextra->javaBlock=1;
553 yyextra->blockName=
QCString(
"end")+&yytext[1];
554 yyextra->inVerbatim=
true;
557<CComment,IncludeFile>"{"[ \t]*"@literal"/[ \t\n] {
559 yyextra->lastCommentContext = YY_START;
560 yyextra->javaBlock=1;
561 yyextra->blockName=
QCString(
"end")+&yytext[1];
562 yyextra->inVerbatim=
true;
565<CComment,ReadLine,IncludeFile>{CMD}"ilinebr"[ \t]+("```"[`]*|"~~~"[~]*) {
571 yyextra->lastCommentContext = YY_START;
572 yyextra->javaBlock=0;
574 yyextra->inVerbatim=
true;
QCString stripWhiteSpace() const
returns a copy of this string with leading and trailing whitespace removed
QCString right(size_t len) const
577<CComment,ReadLine,IncludeFile>^[ \t]*("```"[`]*|"~~~"[~]*) {
583 yyextra->lastCommentContext = YY_START;
584 yyextra->javaBlock=0;
586 yyextra->inVerbatim=
true;
QCString left(size_t len) const
589<CComment,ReadLine,IncludeFile>[\\@]("dot"|"code"|"msc"|"startuml")/[^a-z_A-Z0-9] {
591 yyextra->lastCommentContext = YY_START;
592 yyextra->javaBlock=0;
593 if (
qstrcmp(&yytext[1],
"startuml")==0)
595 yyextra->blockName=
"enduml";
599 yyextra->blockName=
QCString(
"end")+&yytext[1];
601 yyextra->inVerbatim=
true;
int qstrcmp(const char *str1, const char *str2)
604<CComment,ReadLine,IncludeFile>[\\@]("f$"|"f["|"f{"|"f(") {
606 yyextra->blockName=&yytext[1];
607 if (yyextra->blockName.at(1)==
'[')
609 yyextra->blockName.at(1)=
']';
611 else if (yyextra->blockName.at(1)==
'{')
613 yyextra->blockName.at(1)=
'}';
615 else if (yyextra->blockName.at(1)==
'(')
617 yyextra->blockName.at(1)=
')';
619 yyextra->lastCommentContext = YY_START;
620 yyextra->inVerbatim=
true;
623<CComment,ReadLine,IncludeFile>"<!--!" {
624 if (yyextra->inVerbatim) REJECT;
626 yyextra->inHtmlDoxygenCommand=
true;
628<CComment,ReadLine,IncludeFile>"-->" {
629 if (yyextra->inHtmlDoxygenCommand)
631 yyextra->inHtmlDoxygenCommand=
false;
638<CComment,ReadLine,IncludeFile>"<!--" {
640 yyextra->blockName=
"-->";
641 yyextra->lastCommentContext = YY_START;
642 yyextra->inVerbatim=
true;
645<CComment,ReadLine,IncludeFile>[\\@]("verbatim"|"iliteral"|"latexonly"|"htmlonly"|"xmlonly"|"docbookonly"|"rtfonly"|"manonly")/[^a-z_A-Z0-9] {
647 yyextra->blockName=
QCString(
"end")+&yytext[1];
648 yyextra->lastCommentContext = YY_START;
649 yyextra->inVerbatim=
true;
661<Verbatim>[\\@]("endverbatim"|"endiliteral"|"endlatexonly"|"endhtmlonly"|"endxmlonly"|"enddocbookonly"|"endrtfonly"|"endmanonly"|"f$"|"f]"|"f}"|"f)") {
663 if (&yytext[1]==yyextra->blockName)
665 yyextra->inVerbatim=
false;
666 BEGIN(yyextra->lastCommentContext);
671 if (yytext==yyextra->blockName)
673 yyextra->inVerbatim=
false;
674 BEGIN(yyextra->lastCommentContext);
678 if (yyextra->javaBlock==0)
684 yyextra->javaBlock++;
689 if (yyextra->javaBlock==0)
695 yyextra->javaBlock--;
696 if (yyextra->javaBlock==0)
699 yyextra->inVerbatim=
false;
700 BEGIN(yyextra->lastCommentContext);
708<VerbatimCode>("```"[`]*|"~~~"[~]*) {
710 if (yytext[0]==yyextra->blockName[0])
712 yyextra->inVerbatim=
false;
713 BEGIN(yyextra->lastCommentContext);
716<VerbatimCode>[\\@]("enddot"|"endcode"|"endmsc"|"enduml")/("{")? {
718 if (&yytext[1]==yyextra->blockName)
720 yyextra->inVerbatim=
false;
721 BEGIN(yyextra->lastCommentContext);
724<VerbatimCode>^[ \t]*{CPPC}[\!\/]? {
725 if (!yyextra->inSpecialComment || yyextra->mlBrief)
732 while (yytext[l]==
' ' || yytext[l]==
'\t')
747<Verbatim,VerbatimCode>[^`~@\/\-\\\n{}]* {
750<Verbatim,VerbatimCode>\n {
752 if (yyextra->lastCommentContext == IncludeFile)
757<Verbatim>^[ \t]*{CPPC}[/!] {
758 if (yyextra->blockName==
"enddot" || yyextra->blockName==
"endmsc" || yyextra->blockName==
"enduml" || yyextra->blockName.at(0)==
'f')
762 while (yytext[l]==
' ' || yytext[l]==
'\t')
774<Verbatim,VerbatimCode>. {
778 if (yyextra->lang==SrcLangExt::Fortran || yyextra->lang==SrcLangExt::VHDL)
790 BEGIN(yyextra->stringContext);
798<SkipVerbString>[^"\n]+ {
801<SkipVerbString>\"\" {
804<SkipVerbString>"\"" {
806 BEGIN(yyextra->stringContext);
815 if (yyextra->lang==SrcLangExt::Fortran || yyextra->lang==SrcLangExt::VHDL)
827 BEGIN(yyextra->charContext);
836<CComment,CNComment>[^ `~<\\!@*\n{\"'\/-]* {
839<CComment,CNComment>^{B}*"*"+[^*\/<\\@\n{\"]* {
840 if (yyextra->lang==SrcLangExt::Markdown) REJECT;
842 if (yyextra->col>yyextra->blockHeadCol)
845 yyextra->blockHeadCol=yyextra->col;
851 if (yyextra->lang!=SrcLangExt::Python)
855 else if (yyextra->pythonDocStringChar != yytext[0])
861 yyextra->nestingCount--;
862 yyextra->pythonDocString =
FALSE;
863 yyextra->pythonDocStringChar =
'\0';
868<CComment,CNComment>\n {
871 if (yyextra->lang==SrcLangExt::Fortran)
876<CComment,CNComment>"/""/"+/"*/" {
880<CComment,CNComment>"/"+"*" {
881 if (yyextra->lang==SrcLangExt::Python ||
882 yyextra->lang==SrcLangExt::Markdown)
886 yyextra->nestingCount++;
887 yyextra->commentStack.push(yyextra->lineNr);
890<CComment,CNComment>^{B}*"*"+"/" |
891<CComment,CNComment>"*"+"/" {
892 if (yyextra->lang==SrcLangExt::Python ||
893 yyextra->lang==SrcLangExt::Markdown)
900 yyextra->nestingCount--;
901 if (yyextra->nestingCount<=0)
908 yyextra->commentStack.pop();
913<CComment,CNComment>"\n"/[ \t]*"#" {
914 if (yyextra->lang!=SrcLangExt::VHDL)
922 yyextra->vhdl =
FALSE;
932<CComment,CNComment>"\n"/[ \t]*"-" {
933 if (yyextra->lang!=SrcLangExt::Python || yyextra->pythonDocString)
943<CComment,CNComment>"\n"/[ \t]*[^ \t#\-] {
944 if (yyextra->lang==SrcLangExt::Python)
946 if (yyextra->pythonDocString)
956 else if (yyextra->lang==SrcLangExt::VHDL)
960 yyextra->vhdl =
FALSE;
986<CComment,CNComment>{CMD}"~"[a-z_A-Z-]* {
987 if (yyextra->lang!=SrcLangExt::Markdown) REJECT;
994 warn(yyextra->fileName,yyextra->lineNr,
QCString mid(size_t index, size_t len=static_cast< size_t >(-1)) const
bool isEmpty() const
Returns TRUE iff the string is empty.
#define Config_getEnumAsString(name)
#define Config_isAvailableEnum(name, value)
#define warn(file, line, fmt,...)
int qstricmp(const char *s1, const char *s2)
std::string_view stripWhiteSpace(std::string_view s)
Given a string view s, returns a new, narrower view on that string, skipping over any leading or trai...
1000<CComment,CNComment>{CMD}{CMD} |
1001<CComment,CNComment>. {
1004<SkipLang>{CMD}"~"[a-zA-Z-]* {
1008 warn(yyextra->fileName,yyextra->lineNr,
1017<SkipLang>[^*@\\\n]* {
1024<SComment>^[ \t]*{CPPC}"/"{SLASHopt}/\n {
1027<SComment>\n[ \t]*{CPPC}"/"{SLASHopt}/\n {
1030<SComment>^[ \t]*{CPPC}"/"[^\/\n]/.*\n {
1032 yyextra->readLineCtx=YY_START;
1035<SComment>\n[ \t]*{CPPC}[\/!]("<")?[ \t]*[\\@]"}".*\n {
1039 yyextra->inSpecialComment=
false;
1040 yyextra->inRoseComment=
false;
1043<SComment>\n[ \t]*{CPPC}"/"[^\\@\/\n]/.*\n {
1045 yyextra->readLineCtx=YY_START;
1048<SComment>^[ \t]*{CPPC}"!" |
1049<SComment>^[ \t]*{CPPC}"!<"/.*\n |
1050<SComment>^[ \t]*{CPPC}"!"[^<]/.*\n {
1052 yyextra->readLineCtx=YY_START;
1055<SComment>\n[ \t]*{CPPC}"!" |
1056<SComment>\n[ \t]*{CPPC}"!<"/.*\n |
1057<SComment>\n[ \t]*{CPPC}"!"[^<\n]/.*\n {
1059 yyextra->readLineCtx=YY_START;
1062<SComment>^[ \t]*{CPPC}"##"/.*\n {
1063 if (!yyextra->inRoseComment)
1070 yyextra->readLineCtx=YY_START;
1074<SComment>\n[ \t]*{CPPC}"##"/.*\n {
1075 if (!yyextra->inRoseComment)
1082 yyextra->readLineCtx=YY_START;
1089 yyextra->inSpecialComment=
FALSE;
1090 yyextra->inRoseComment=
FALSE;
1091 yyextra->insertCppCommentMarker=
false;
1092 yyextra->readLineCtx = Scan;
1102<ReadLine,CopyLine>"*" {
1105<ReadLine,CopyLine>{RL} {
1108<ReadLine,CopyLine>{RL}/{B}{CMD}"ilinebr"{B} {
1111<ReadLine,CopyLine>{RLopt}/\n {
1113 yyextra->insertCppCommentMarker=
false;
1114 BEGIN(yyextra->readLineCtx);
1116<CComment,CNComment,ReadLine>"\<" {
1119<CComment,CNComment,ReadLine>[\\@][\\@][~a-z_A-Z][a-z_A-Z0-9]*[ \t]* {
1123<CComment,ReadLine,IncludeFile>[\\@]("include"{OPTS}|"includedoc"{OPTS}*) {
1124 if (!
parseIncludeOptions(yyscanner,std::string_view{yytext,
static_cast<size_t>(yyleng)})) REJECT;
1125 yyextra->includeCtx = YY_START;
1126 yyextra->firstIncludeLine =
true;
1127 yyextra->insertCommentCol = yyextra->col;
1128 if (!yyextra->insertCppCommentMarker && (yyextra->includeCtx==ReadLine || yyextra->includeCtx==IncludeFile))
1130 yyextra->insertCppCommentMarker = yyextra->mlBrief;
1135<CComment,ReadLine,IncludeFile>[\\@]("snippet"{OPTS}|"snippetdoc"{OPTS}*) {
1136 if (!
parseIncludeOptions(yyscanner,std::string_view{yytext,
static_cast<size_t>(yyleng)})) REJECT;
1137 yyextra->includeCtx = YY_START;
1138 yyextra->firstIncludeLine =
true;
1139 yyextra->insertCommentCol = yyextra->col;
1140 if (!yyextra->insertCppCommentMarker && (yyextra->includeCtx==ReadLine || yyextra->includeCtx==IncludeFile))
1142 yyextra->insertCppCommentMarker = yyextra->mlBrief;
1147<IncludeDoc,SnippetDoc>{B}*
1148<IncludeDoc>{FILEMASK}|"\""[^\n\"]+"\"" {
1152 fileName=fileName.
mid(1,fileName.
length()-2);
1160 BEGIN(yyextra->includeCtx);
size_t length() const
Returns the length of the string, not counting the 0-terminator.
1163<SnippetDoc>({FILEMASK}|"\""[^\n\"]+"\""){B}+ {
1164 yyextra->snippetFileName=yytext;
1165 yyextra->snippetFileName=yyextra->snippetFileName.stripWhiteSpace();
1166 if (yyextra->snippetFileName ==
"this") yyextra->snippetFileName=yyextra->fileName;
1167 yyextra->snippetName =
"";
1168 BEGIN(SnippetDocTag);
1170<SnippetDocTag>[^\\@\n]+ {
1171 yyextra->snippetName += yytext;
1173<SnippetDocTag>{CMD} {
1174 yyextra->snippetName += yytext;
1176<SnippetDocTag>(\n|{CMD}"ilinebr") {
1177 for (
int i=(
int)yyleng-1;i>=0;i--) unput(yytext[i]);
1178 yyextra->snippetName = yyextra->snippetName.stripWhiteSpace();
1179 QCString blockId =
"["+yyextra->snippetName+
"]";
1186 BEGIN(yyextra->includeCtx);
1190<IncludeDoc,SnippetDoc>\n {
1195 BEGIN(yyextra->includeCtx);
1197<IncludeDoc,SnippetDoc>. {
1199 BEGIN(yyextra->includeCtx);
1201<CComment,ReadLine,IncludeFile>[\\@]"cond"/[^a-z_A-Z0-9] {
1202 yyextra->condCtx = YY_START;
1205<CComment,ReadLine,IncludeFile>[\\@]"endcond"/[^a-z_A-Z0-9] {
1206 bool oldSkip=yyextra->skip;
1208 if (YY_START==CComment && oldSkip && !yyextra->skip)
1211 if (yyextra->lang!=SrcLangExt::Python &&
1212 yyextra->lang!=SrcLangExt::VHDL &&
1213 yyextra->lang!=SrcLangExt::Markdown &&
1214 yyextra->lang!=SrcLangExt::Fortran)
1216 yyextra->outBuf+=
'/';
1217 yyextra->outBuf+=
'*';
1219 if (yyextra->specialComment)
1221 yyextra->outBuf+=
'*';
1227<CondLine>[!()&| \ta-z_A-Z0-9.\-]+ {
1230<CComment,ReadLine,IncludeFile>[\\@]"cond"{WSopt}/\n {
1231 yyextra->condCtx=YY_START;
1239<CComment,ReadLine,IncludeFile,Verbatim,VerbatimCode>[\\@][a-z_A-Z][a-z_A-Z0-9-]* {
1240 replaceAliases(yyscanner,yytext,YY_START==ReadLine && yyextra->readLineCtx==SComment);
1242<CComment,ReadLine,IncludeFile,Verbatim,VerbatimCode>{B}?{CMD}"ilinebr"{B}[\\@]"ialias{" {
1243 yyextra->lastBlockContext=YY_START;
1244 yyextra->blockCount=1;
1245 int extraSpace = (yytext[0]==
' '? 1:0);
1246 yyextra->aliasString=yytext+9+extraSpace;
1247 yyextra->aliasCmd=yytext+9+extraSpace;
1248 yyextra->lastEscaped=0;
1249 BEGIN( ReadAliasArgs );
1251<CComment,ReadLine,IncludeFile,Verbatim,VerbatimCode>[\\@][a-z_A-Z][a-z_A-Z0-9-]*"{" {
1252 yyextra->lastBlockContext=YY_START;
1253 yyextra->blockCount=1;
1254 yyextra->aliasString=yytext;
1255 yyextra->aliasCmd=yytext;
1256 yyextra->lastEscaped=0;
1257 BEGIN( ReadAliasArgs );
1259<ReadAliasArgs>^[ \t]*"*" {
1261<ReadAliasArgs>^[ \t]*{CPPC}[/!]/[^\n]* {
1263<ReadAliasArgs>[^{}\n\\\*]+ {
1264 yyextra->aliasString+=yytext;
1265 yyextra->lastEscaped=
FALSE;
1267<ReadAliasArgs>"\\" {
1268 if (yyextra->lastEscaped) yyextra->lastEscaped=
FALSE;
1269 else yyextra->lastEscaped=
TRUE;
1270 yyextra->aliasString+=yytext;
1272<ReadAliasArgs>[\\@]("endverbatim"|"endiliteral"|"endlatexonly"|"endhtmlonly"|"endxmlonly"|"enddocbookonly"|"endrtfonly"|"endmanonly"|"f$"|"f]"|"f}"|"f)") {
1273 yyextra->aliasString+=yytext;
1274 if (yyextra->inVerbatim && &yytext[1]==yyextra->blockName)
1283 yyextra->inVerbatim=
false;
1284 BEGIN(yyextra->lastCommentContext);
1288 yyextra->aliasString+=yytext;
1289 yyextra->lastEscaped=
FALSE;
1290 if (yyextra->inVerbatim)
1294 BEGIN( yyextra->lastBlockContext );
1298 yyextra->aliasString+=yytext;
1299 if (!yyextra->lastEscaped) yyextra->blockCount++;
1300 yyextra->lastEscaped=
FALSE;
1303 yyextra->aliasString+=yytext;
1304 if (!yyextra->lastEscaped) yyextra->blockCount--;
1305 if (yyextra->blockCount==0)
1308 yyextra->lastBlockContext==ReadLine && yyextra->readLineCtx==SComment);
1309 BEGIN( yyextra->lastBlockContext );
1311 yyextra->lastEscaped=
FALSE;
1314 yyextra->aliasString+=yytext;
1315 yyextra->lastEscaped=
FALSE;
1322 yyextra->insertCppCommentMarker=
false;
1323 BEGIN(yyextra->readLineCtx);
1331<ReadLine>{CMD}{CMD} |
1346 if (YY_START == ReadAliasArgs)
1348 warn(yyextra->fileName,yyextra->lineNr,
1349 "Reached end of file while still searching closing '}}' of an alias argument (probable start: '{}')",
1352 if (yyextra->includeStack.empty())
1354 yyextra->insertCppCommentMarker=
false;
1359 std::unique_ptr<commentcnv_FileState> &fs = yyextra->includeStack.back();
1360 YY_BUFFER_STATE oldBuf = YY_CURRENT_BUFFER;
1361 yy_switch_to_buffer(fs->bufState, yyscanner);
1362 yy_delete_buffer(oldBuf, yyscanner);
1363 BEGIN(fs->oldState);
1364 yyextra->fileName = fs->oldFileName;
1365 yyextra->lineNr = fs->oldLineNr;
1366 yyextra->inBuf = fs->oldFileBuf;
1367 yyextra->inBufPos = fs->oldFileBufPos;
1368 yyextra->includeCtx = fs->oldIncludeCtx;
1370 if (fs->oldRaiseLvl!=yyextra->raiseLevel)
1372 lineStr+=
"\\iraise " + std::to_string(fs->oldRaiseLvl)+
" ";
1374 if (fs->oldRaiseLbl!=yyextra->raiseLabel)
1376 lineStr+=
"\\iprefix \"" + fs->oldRaiseLbl +
"\" ";
1378 lineStr+=
"\\ilinebr ";
1379 yyextra->raiseLevel = fs->oldRaiseLvl;
1380 yyextra->raiseLabel = fs->oldRaiseLbl;
1382 yyextra->includeStack.pop_back();
QCString & setNum(short n)
std::string_view view() const
1394 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
1397 size_t optIdxStart = s.find(
'{');
1398 size_t optIdxEnd = optIdxStart!=std::string::npos ? s.find(
"}",optIdxStart+1) : std::string::npos;
1399 std::string cmdName;
1401 if (optIdxStart == std::string::npos)
1408 optList =
split(std::string{s.substr(optIdxStart+1,optIdxEnd-optIdxStart-1)},
",");
1410 bool isDoc = cmdName==
"includedoc" || cmdName==
"snippetdoc";
1411 for (
const auto &opt : optList)
1422 for (
const auto &opt : optList)
1425 size_t posEqual = locOpt.find(
'=');
1426 std::string_view option = posEqual!=std::string::npos ?
stripWhiteSpace(locOpt.substr(0,posEqual)) : locOpt;
1427 std::string_view value = posEqual!=std::string::npos ?
stripWhiteSpace(locOpt.substr(posEqual+1)) : std::string_view();
1429 if (option==std::string_view{
"doc"} && value.empty())
1432 else if (option==std::string_view{
"raise"} && !value.empty())
1434 yyextra->raiseIncrement = atoi(value.data());
1437 warn(yyextra->fileName,yyextra->lineNr,
"Raising section level from {} to {}, exceeds allowed range [0-{}], adjusting",
1442 else if (option==std::string_view{
"prefix"} && !value.empty())
1444 yyextra->raisePrefix = value;
1448 warn(yyextra->fileName,yyextra->lineNr,
"Unsupported option '{}' for {} command",option, cmdName);
1459 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
1460 if (s.empty())
return;
1462 size_t len = s.length();
1465 while (p<len && (c=s[p]) && (c==
' ' || c==
'\t' || c==
'\n'))
1468 if (c==
'\n') { yyextra->lineNr++; yyextra->col=0; }
else { yyextra->col++; }
1473 while (p<len && (c=s[p]) && (c==
'/' || c==
'!' || c==
'#'))
1477 if (p<len && s[p]==
'<')
1491 yyextra->outBuf+=
' ';
1495 if (blanks>1) { yyextra->outBuf+=
'*'; yyextra->col++; }
1496 yyextra->outBuf+=
' ';
1500 yyextra->outBuf+=s.substr(p);
1501 yyextra->col+=s.substr(p).length();
1513 else if (c==
'\t') col+=tabSize-(col%tabSize);
1522 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
1523 size_t len = s.length();
1526 for (
size_t i=0;i<len;i++)
1531 yyextra->outBuf+=
'\n';
1536 yyextra->col+=tabSize-(yyextra->col%tabSize);
1547 for (
size_t i=0;i<len;i++)
1551 case '\n': yyextra->col=0;
1553 yyextra->lineNr++;
break;
1554 case '\t': yyextra->col+=tabSize-(yyextra->col%tabSize);
break;
1555 default: yyextra->col++;
break;
1563 copyToOutput(yyscanner,std::string_view{s,(size_t)len});
1568 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
1569 while (!yyextra->commentStack.empty()) yyextra->commentStack.pop();
1574 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
1577 bool expResult = prs.
parse(yyextra->fileName,yyextra->lineNr,sectId);
1578 yyextra->condStack.emplace(yyextra->lineNr,sectId,yyextra->skip);
1587 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
1588 if (yyextra->condStack.empty())
1590 warn(yyextra->fileName,yyextra->lineNr,
"Found \\endcond command without matching \\cond");
1591 yyextra->skip=
FALSE;
1597 yyextra->condStack.pop();
1604 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
1605 bool oldSkip=yyextra->skip;
1607 if ((yyextra->condCtx==CComment || yyextra->readLineCtx==SComment) &&
1608 !oldSkip && yyextra->skip)
1610 if (yyextra->lang!=SrcLangExt::Python &&
1611 yyextra->lang!=SrcLangExt::VHDL &&
1612 yyextra->lang!=SrcLangExt::Markdown &&
1613 yyextra->lang!=SrcLangExt::Fortran)
1615 yyextra->outBuf+=
'*';
1616 yyextra->outBuf+=
'/';
1620 if (yyextra->readLineCtx==SComment)
1626 BEGIN(yyextra->condCtx);
1641 int m1 = text.
find(marker);
1642 if (m1==-1)
return result;
1643 int m2 = text.
find(marker,m1+
static_cast<int>(marker.
length()));
1644 if (m2==-1)
return result;
1648 while (!
found && (i=text.
find(
'\n',p))!=-1)
1650 found = (p<=m1 && m1<i);
1658 while ((i=text.
find(
'\n',p))!=-1)
1678 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
1679 int startCol=yyextra->blockHeadCol;
1680 int contentCol=yyextra->insertCommentCol;
1681 int markerSpace=contentCol-startCol;
1685 if (yyextra->lang==SrcLangExt::Python)
1687 if (yyextra->pythonDocString)
1696 else if (yyextra->lang==SrcLangExt::Fortran)
1700 else if (yyextra->lang==SrcLangExt::Markdown)
1704 else if (yyextra->insertCppCommentMarker)
1719 for (;i<startCol;i++)
1723 if (
static_cast<int>(marker.length())<=markerSpace && !yyextra->firstIncludeLine)
1728 for (;i<contentCol;i++)
1732 yyextra->firstIncludeLine =
false;
1738 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
1746 warn_doc_error(yyextra->fileName,yyextra->lineNr,
"included file name '{}' is ambiguous"
1749 bool alreadyProcessed = std::any_of(
1750 yyextra->includeStack.begin(),
1751 yyextra->includeStack.end(),
1752 [&absFileName,&blockId](
const auto &lfs)
1753 { return lfs->fileName==absFileName && lfs->blockId==blockId; }
1756 if (alreadyProcessed)
1760 warn_doc_error(yyextra->fileName,yyextra->lineNr,
"recursive usage of '\\snippet{{doc}}' block with name '{}' and file name '{}', skipping",
1761 blockId,absFileName);
1765 warn_doc_error(yyextra->fileName,yyextra->lineNr,
"recursive usage of '\\include{{doc}}' with file name '{}', skipping", absFileName);
1770 auto fs = std::make_unique<commentcnv_FileState>();
1773 warn_doc_error(yyextra->fileName,yyextra->lineNr,
"\\{}{{doc}} file '{}' could not be read",blockId.
isEmpty()?
"include":
"snippet",absFileName);
1784 warn_doc_error(yyextra->fileName,yyextra->lineNr,
"block marked with {} for \\snippet{{doc}} should appear twice in file {}, found it {:d} times, skipping",
1785 blockId,absFileName,count);
1791 fs->fileBuf.clear();
1792 if (!incText.isEmpty())
1794 fs->fileBuf.append(incText.str());
1797 int oldRaiseLevel = yyextra->raiseLevel;
1798 QCString oldRaiseLabel = yyextra->raiseLabel;
1799 yyextra->raiseLevel+=yyextra->raiseIncrement;
1800 yyextra->raiseLabel+=yyextra->raisePrefix;
1801 QCString lineStr=
" \\ifile \""+absFileName+
"\" \\iline " + std::to_string(lineNr)+
" ";
1802 if (yyextra->raiseLevel>0)
1804 lineStr+=
"\\iraise " + std::to_string(yyextra->raiseLevel)+
" ";
1806 if (!yyextra->raiseLabel.isEmpty())
1808 lineStr+=
"\\iprefix \"" + yyextra->raiseLabel +
"\" ";
1810 lineStr+=
"\\ilinebr ";
1813 fs->fileName = absFileName;
1814 fs->bufState = YY_CURRENT_BUFFER;
1815 fs->oldLineNr = yyextra->lineNr;
1816 fs->oldFileName = yyextra->fileName;
1817 fs->oldState = yyextra->includeCtx;
1818 fs->oldFileBuf = yyextra->inBuf;
1819 fs->oldFileBufPos = yyextra->inBufPos;
1820 fs->oldIncludeCtx = yyextra->includeCtx;
1821 fs->oldRaiseLvl = oldRaiseLevel;
1822 fs->oldRaiseLbl = oldRaiseLabel;
1823 fs->blockId = blockId;
1824 yy_switch_to_buffer(yy_create_buffer(
nullptr,
YY_BUF_SIZE, yyscanner),yyscanner);
1825 yyextra->fileName = absFileName;
1826 yyextra->lineNr = lineNr;
1827 yyextra->inBuf = &fs->fileBuf;
1828 yyextra->inBufPos = 0;
1829 yyextra->includeStack.push_back(std::move(fs));
1835 warn_doc_error(yyextra->fileName,yyextra->lineNr,
"\\{}{{doc}} file '{}' not found",blockId.
isEmpty()?
"include":
"snippet",inc);
1846 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
1847 if (s.empty())
return;
1848 size_t pos = s.find(
'{');
1849 std::string cmd { s.substr(1, pos!=std::string::npos ? pos-1 : s.length()-1) };
1850 auto &expAlias = yyextra->expandedAliases;
1851 if (std::find(expAlias.begin(),expAlias.end(),cmd)!=std::end(expAlias))
1856 else if (cmd==
"ialias")
1858 if (s.length()>cmd.length()+3)
1860 std::string value { s.substr(cmd.length()+2,s.length()-cmd.length()-3) };
1862 expAlias.erase(std::remove(expAlias.begin(),expAlias.end(),value),expAlias.end());
1867 if (yyextra->inVerbatim)
1870 std::string blk = yyextra->blockName.str();
1871 assert(!blk.empty());
1872 bool isNamedCommand=
isId(blk[0]);
1875 while ((i=result.find(blk,p))!=std::string::npos && !
found)
1877 found = !isNamedCommand ||
1878 (i>0 && (result[i-1]==
'\\' || result[i-1]==
'@') && !
isId(result[i+blk.length()]));
1879 p = i+yyextra->blockName.length();
1897 expAlias.push_back(cmd);
1899 result +=
" \\ilinebr \\ialias{";
1902 for (
int i=(
int)result.length()-1; i>=0; i--)
1916 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
1917 int bytesInBuf =
static_cast<int>(yyextra->inBuf->size())-yyextra->inBufPos;
1918 int bytesToCopy = std::min(max_size,bytesInBuf);
1919 memcpy(buf,yyextra->inBuf->data()+yyextra->inBufPos,bytesToCopy);
1920 yyextra->inBufPos+=bytesToCopy;
1926 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
1927 if (yyextra->mlBrief || yyextra->skip)
1935 if (i==yyextra->blockHeadCol || i+1==yyextra->blockHeadCol)
1942 for (i=(
int)yyleng-1;i>=0;i--) unput(yytext[i]);
1943 yyextra->inSpecialComment=
FALSE;
1960 commentcnvYYlex_init_extra(&extra,&yyscanner);
1964 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
1966 yyextra->inBufPos = 0;
1969 yyextra->skip =
FALSE;
1970 yyextra->fileName = fileName;
1972 yyextra->pythonDocString =
FALSE;
1973 yyextra->lineNr = 1;
1974 yyextra->raiseLevel = 0;
1975 yyextra->raiseLabel =
"";
1976 yyextra->raiseIncrement = 0;
1977 yyextra->raisePrefix =
"";
1978 yyextra->insertCppCommentMarker=
false;
1979 yyextra->expandedAliases.clear();
1980 while (!yyextra->condStack.empty()) yyextra->condStack.pop();
1982 yyextra->vhdl =
FALSE;
1985 yyextra->isFixedForm =
FALSE;
1986 if (yyextra->lang==SrcLangExt::Fortran)
1992 if (yyextra->lang==SrcLangExt::Markdown)
1994 yyextra->nestingCount=0;
1996 yyextra->commentStack.push(yyextra->lineNr);
2003 while (!yyextra->condStack.empty())
2008 warn(yyextra->fileName,ctx.
lineNr,
"Conditional section{}does not have "
2009 "a corresponding \\endcond command within this file.",sectionInfo.
data());
2010 yyextra->condStack.pop();
2012 if (yyextra->nestingCount>0 && yyextra->lang!=SrcLangExt::Markdown && yyextra->lang!=SrcLangExt::Fortran)
2016 while (!yyextra->commentStack.empty())
2018 int lineNr = yyextra->commentStack.top();
2019 if (!first) lines +=
", ";
2022 yyextra->commentStack.pop();
2024 warn(yyextra->fileName,yyextra->lineNr,
"Reached end of file while still inside a (nested) comment. "
2025 "Nesting level {} (possible line reference(s): {})",yyextra->nestingCount,lines);
2027 yyextra->nestingCount = 0;
2031 "output=[\n{}]\n-----------\n",fileName,yyextra->outBuf
2034 commentcnvYYlex_destroy(yyscanner);
2040#include "commentcnv.l.h"
std::string resolveAliasCmd(std::string_view aliasCmd)
Copyright (C) 1997-2015 by Dimitri van Heesch.
bool parse(const QCString &fileName, int lineNr, const QCString &expr)
Copyright (C) 1997-2015 by Dimitri van Heesch.
static bool isFlagSet(const DebugMask mask)
static void print(DebugMask mask, int prio, fmt::format_string< Args... > fmt, Args &&... args)
static FileNameLinkedMap * exampleNameLinkedMap
Minimal replacement for QFileInfo.
int find(char c, int index=0, bool cs=TRUE) const
const std::string & str() const
QCString & sprintf(const char *format,...)
const char * data() const
Returns a pointer to the contents of the string in the form of a 0-terminated C string.
int contains(char c, bool cs=TRUE) const
static constexpr int MaxLevel
static int yyread(yyscan_t yyscanner, char *buf, int max_size)
#define Config_getInt(name)
std::vector< std::string > StringVector
#define warn_doc_error(file, line, fmt,...)
const char * qPrint(const char *s)
std::string substituteStringView(std::string_view s, std::string_view toReplace, std::string_view replaceWith)
Returns a new string where occurrences of substring toReplace in string s are replaced by string repl...
QCString findFilePath(const QCString &file, bool &ambig)
SrcLangExt getLanguageFromFileName(const QCString &fileName, SrcLangExt defLang)
int lineBlock(const QCString &text, const QCString &marker)
Returns the line number of the line following the line with the marker.
bool readInputFile(const QCString &fileName, std::string &contents, bool filter, bool isSourceCode)
read a file name fileName and optionally filter and transcode it
bool recognizeFixedForm(const QCString &contents, FortranFormat format)
QCString showFileDefMatches(const FileNameLinkedMap *fnMap, const QCString &n)
StringVector split(const std::string &s, const std::string &delimiter)
split input string s by string delimiter delimiter.
FortranFormat convertFileNameFortranParserCode(QCString fn)