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
30#define yyguts_t commentcnvYYguts_t
64#define YY_NO_UNISTD_H 1
172static void replaceAliases(
yyscan_t yyscanner,std::string_view s,
bool replaceCppComment=
false,
bool replaceCComment=
false);
181#define YY_INPUT(buf,result,max_size) result=yyread(yyscanner,buf,max_size);
A String class for use with Doxygen wrapping std::string and adding some additional functionality off...
Token literal values and constants.
Some helper functions for std::string.
A bunch of utility functions.
189MAILADDR ("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\-]+
216DECIMAL_INTEGER [1-9][0-9']*[0-9]?[uU]?[lL]?[lL]?
217HEXADECIMAL_INTEGER "0"[xX][0-9a-zA-Z']+[0-9a-zA-Z]?
218OCTAL_INTEGER "0"[0-7][0-7']+[0-7]?
219BINARY_INTEGER "0"[bB][01][01']*[01]?
220INTEGER_NUMBER {DECIMAL_INTEGER}|{HEXADECIMAL_INTEGER}|{OCTAL_INTEGER}|{BINARY_INTEGER}
224DIGIT_SEQ [0-9][0-9']*[0-9]?
225FRAC_CONST {DIGIT_SEQ}"."|{DIGIT_SEQ}?"."{DIGIT_SEQ}
226FP_EXP [eE][+-]?{DIGIT_SEQ}
227DEC_FP1 {FRAC_CONST}{FP_EXP}?{FP_SUF}?
228DEC_FP2 {DIGIT_SEQ}{FP_EXP}{FP_SUF}
230HEX_DIGIT_SEQ [0-9a-fA-F][0-9a-fA-F']*[0-9a-fA-F]?
231HEX_FRAC_CONST {HEX_DIGIT_SEQ}"."|{HEX_DIGIT_SEQ}?"."{HEX_DIGIT_SEQ}
232BIN_EXP [pP][+-]?{DIGIT_SEQ}
233HEX_FP1 "0"[xX]{HEX_FRAC_CONST}{BIN_EXP}{FP_SUF}?
234HEX_FP2 "0"[xX]{HEX_DIGIT_SEQ}{BIN_EXP}{FP_SUF}?
236FLOAT_DECIMAL {DEC_FP1}|{DEC_FP2}
237FLOAT_HEXADECIMAL {HEX_FP1}|{HEX_FP2}
238FLOAT_NUMBER {FLOAT_DECIMAL}|{FLOAT_HEXADECIMAL}
239NUMBER {INTEGER_NUMBER}|{FLOAT_NUMBER}
241RAWBEGIN (u|U|L|u8)?R\"[^ \t\(\)\\]{0,16}"("
242RAWEND ")"[^ \t\(\)\\]{0,16}\"
244FILEICHAR [a-z_A-Z0-9\x80-\xFF\\:\\\/\-\+=&#@]
245FILEECHAR [a-z_A-Z0-9\x80-\xFF\-\+=&#@]
246FILECHARS {FILEICHAR}*{FILEECHAR}+
247HFILEMASK {FILEICHAR}*("."{FILEICHAR}+)+{FILECHARS}*
248VFILEMASK {FILECHARS}("."{FILECHARS})*
249FILEMASK {VFILEMASK}|{HFILEMASK}
251DOXYCFG [A-Z][A-Z_0-9]*
279 if (yyextra->lang!=SrcLangExt::Cpp) REJECT;
283 if (yyextra->lang!=SrcLangExt::Cpp) REJECT;
287<Scan>[^"'!\/\n\\#,\-=; \t@$]* {
295 if (yyextra->lang!=SrcLangExt::Python)
301 yyextra->pythonDocString =
true;
302 yyextra->pythonDocStringChar = yytext[0];
303 yyextra->nestingCount=1;
307 yyextra->commentStack.push(yyextra->lineNr);
312 if (yyextra->lang!=SrcLangExt::Python)
322 yyextra->pythonDocString =
true;
323 yyextra->pythonDocStringChar = yytext[0];
324 yyextra->nestingCount=1;
328 yyextra->commentStack.push(yyextra->lineNr);
#define Config_getBool(name)
331<Scan>{B}*![><!]/.*\n {
332 if (yyextra->lang!=SrcLangExt::Fortran)
338 yyextra->nestingCount=0;
340 yyextra->specialComment=
true;
342 yyextra->blockHeadCol=yyextra->col-2;
344 yyextra->commentStack.push(yyextra->lineNr);
347<Scan>[Cc\*][><!]/.*\n {
348 if (yyextra->lang!=SrcLangExt::Fortran)
355 if (yyextra->isFixedForm && (yyextra->col == 0))
357 yyextra->nestingCount=0;
359 yyextra->specialComment=
true;
361 yyextra->blockHeadCol=yyextra->col-1;
363 yyextra->commentStack.push(yyextra->lineNr);
372 if (yyextra->lang!=SrcLangExt::Fortran)
382 if (yyextra->lang!=SrcLangExt::Fortran)
388 if (yyextra->col == 0)
399 if (yyextra->lang!=SrcLangExt::CSharp) REJECT
401 yyextra->stringContext = YY_START;
402 BEGIN(SkipVerbString);
406 yyextra->stringContext = YY_START;
411 yyextra->charContext = YY_START;
412 if (yyextra->lang!=SrcLangExt::VHDL)
420<Scan>{CPPC}[!/]/.*\n[ \t]*{CPPC}[!/][ \t]*{CMD}"}" {
422 yyextra->inSpecialComment=
true;
423 yyextra->blockHeadCol=yyextra->col+1;
424 yyextra->insertCppCommentMarker=
true;
426 yyextra->readLineCtx=YY_START;
429<Scan>{CPPC}"!"/.*\n[ \t]*{CPPC}[\/!][^\/] |
430<Scan>({CPPC}"/"[/]*)/[^/].*\n[ \t]*{CPPC}[\/!][^\/] {
431 if (yyextra->mlBrief)
440 while (i<(
int)yyleng && yytext[i]==
'/') i++;
442 yyextra->blockHeadCol=yyextra->col+1;
443 yyextra->blockHeadPos=yyextra->skip ? std::string::npos : yyextra->outBuf.size();
444 if (yytext[2] ==
'!')
453 yyextra->inSpecialComment=
true;
455 yyextra->readLineCtx=SComment;
459<Scan>{CPPC}"##Documentation"{ANYopt}/\n {
460 if (yyextra->mlBrief) REJECT;
462 yyextra->blockHeadCol=yyextra->col+1;
463 yyextra->blockHeadPos=yyextra->skip ? std::string::npos : yyextra->outBuf.size();
466 yyextra->inRoseComment=
true;
469<Scan>{CPPC}[!\/]/.*\n[ \t]*{CPPC}[|\/][ \t]*{CMD}"}" {
470 yyextra->inSpecialComment=yytext[2]==
'/' || yytext[2]==
'!';
471 if (yyextra->inSpecialComment)
473 yyextra->blockHeadCol=yyextra->col+1;
476 yyextra->readLineCtx=YY_START;
479<Scan>{CPPC}[!/]/.*\n {
480 yyextra->inSpecialComment=
true;
481 yyextra->blockHeadCol=yyextra->col+1;
482 yyextra->insertCppCommentMarker=
true;
484 yyextra->readLineCtx=YY_START;
488 yyextra->inSpecialComment=
false;
490 yyextra->readLineCtx=YY_START;
497 if (yyextra->lang==SrcLangExt::Python)
501 yyextra->specialComment=(int)yyleng==3;
502 yyextra->nestingCount=1;
505 if (yyextra->specialComment)
507 yyextra->blockHeadCol=0;
514 yyextra->commentStack.push(yyextra->lineNr);
517 if (yyextra->lang!=SrcLangExt::PHP)
524 if (yyextra->lang!=SrcLangExt::Python)
530 yyextra->nestingCount=0;
532 yyextra->specialComment=(int)yyleng==2;
533 if (yyextra->specialComment)
535 yyextra->blockHeadCol=yyextra->col;
537 yyextra->commentStack.push(yyextra->lineNr);
542<Scan>"--"[^!][^\n]* {
543 if (yyextra->lang!=SrcLangExt::VHDL)
553 if (yyextra->lang!=SrcLangExt::VHDL)
559 yyextra->specialComment=
true;
560 yyextra->blockHeadCol=yyextra->col;
561 yyextra->vhdl =
true;
562 yyextra->nestingCount=0;
564 yyextra->commentStack.push(yyextra->lineNr);
570 if (yyextra->lang!=SrcLangExt::Fortran)
576 yyextra->nestingCount=0;
578 yyextra->specialComment=
true;
579 yyextra->blockHeadCol=yyextra->col;
580 yyextra->commentStack.push(yyextra->lineNr);
DString extractEndRawStringDelimiter(const char *rawEnd)
592<RawString>[^)\n]+ {
copyToOutput(yyscanner,yytext,yyleng); }
596<CComment,CNComment,ReadLine,IncludeFile>{MAILADDR} |
597<CComment,CNComment,ReadLine,IncludeFile>"<"{MAILADDR}">" {
600<CComment,IncludeFile>"{"[ \t]*"@code"/[ \t\n] {
602 yyextra->lastCommentContext = YY_START;
603 yyextra->javaBlock=1;
604 yyextra->blockName=
DString(
"end")+&yytext[1];
605 yyextra->inVerbatim=
true;
606 yyextra->verbatimLine=yyextra->lineNr;
609<CComment,IncludeFile>"{"[ \t]*"@literal"/[ \t\n] {
611 yyextra->lastCommentContext = YY_START;
612 yyextra->javaBlock=1;
613 yyextra->blockName=
DString(
"end")+&yytext[1];
614 yyextra->inVerbatim=
true;
615 yyextra->verbatimLine=yyextra->lineNr;
618<CComment,ReadLine,IncludeFile>{CMD}"ilinebr"[ \t]+("```"[`]*|"~~~"[~]*) {
624 yyextra->lastCommentContext = YY_START;
625 yyextra->javaBlock=0;
627 yyextra->inVerbatim=
true;
628 yyextra->verbatimLine=yyextra->lineNr;
DString right(size_t len) const
DString stripWhiteSpace() const
returns a copy of this string with leading and trailing whitespace removed
631<CComment,ReadLine,IncludeFile>^[ \t]*("```"[`]*|"~~~"[~]*) {
637 yyextra->lastCommentContext = YY_START;
638 yyextra->javaBlock=0;
640 yyextra->inVerbatim=
true;
641 yyextra->verbatimLine=yyextra->lineNr;
DString left(size_t len) const
644<CComment,ReadLine,IncludeFile>{CMD}("dot"|"code"|"msc"|"startuml"|"mermaid")/[^a-z_A-Z0-9] {
646 if (yyextra->inSpecialComment || yyextra->specialComment || yyextra->lang==SrcLangExt::Markdown)
648 yyextra->lastCommentContext = YY_START;
649 yyextra->javaBlock=0;
650 if (
dstrcmp(&yytext[1],
"startuml")==0)
652 yyextra->blockName=
"enduml";
656 yyextra->blockName=
DString(
"end")+&yytext[1];
658 yyextra->inVerbatim=
true;
659 yyextra->verbatimLine=yyextra->lineNr;
int dstrcmp(const char *str1, const char *str2)
663<CComment,ReadLine,IncludeFile>"\\`" {
666<CComment,ReadLine,IncludeFile>"```" {
669<CComment,ReadLine,IncludeFile>"`"{1,2} {
675 if (yyextra->inSpecialComment || yyextra->specialComment || yyextra->lang==SrcLangExt::Markdown)
677 yyextra->lastCommentContext = YY_START;
678 yyextra->javaBlock=0;
679 yyextra->blockName=yytext;
680 yyextra->inVerbatim=
true;
681 yyextra->verbatimLine=yyextra->lineNr;
685<CComment,ReadLine,IncludeFile>{CMD}("f$"|"f["|"f{"|"f(") {
687 if (yyextra->inSpecialComment || yyextra->specialComment || yyextra->lang==SrcLangExt::Markdown)
689 yyextra->blockName=&yytext[1];
690 if (yyextra->blockName.at(1)==
'[')
692 yyextra->blockName.at(1)=
']';
694 else if (yyextra->blockName.at(1)==
'{')
696 yyextra->blockName.at(1)=
'}';
698 else if (yyextra->blockName.at(1)==
'(')
700 yyextra->blockName.at(1)=
')';
702 yyextra->lastCommentContext = YY_START;
703 yyextra->inVerbatim=
true;
704 yyextra->verbatimLine=yyextra->lineNr;
708<CComment,ReadLine,IncludeFile>"<!--!" {
709 if (yyextra->inVerbatim) REJECT;
711 yyextra->inHtmlDoxygenCommand=
true;
713<CComment,ReadLine,IncludeFile>"-->" {
714 if (yyextra->inHtmlDoxygenCommand)
716 yyextra->inHtmlDoxygenCommand=
false;
723<CComment,ReadLine,IncludeFile>"<!--" {
725 if (yyextra->inSpecialComment || yyextra->specialComment || yyextra->lang==SrcLangExt::Markdown)
727 yyextra->blockName=
"-->";
728 yyextra->lastCommentContext = YY_START;
729 yyextra->inVerbatim=
true;
730 yyextra->verbatimLine=yyextra->lineNr;
734<CComment,ReadLine,IncludeFile>{CMD}("verbatim"|"iliteral"|"latexonly"|"htmlonly"|"xmlonly"|"docbookonly"|"rtfonly"|"manonly")/[^a-z_A-Z0-9] {
736 if (yyextra->inSpecialComment || yyextra->specialComment || yyextra->lang==SrcLangExt::Markdown)
738 yyextra->blockName=
DString(
"end")+&yytext[1];
739 yyextra->lastCommentContext = YY_START;
740 yyextra->inVerbatim=
true;
741 yyextra->verbatimLine=yyextra->lineNr;
754<Verbatim>{CMD}("endverbatim"|"endiliteral"|"endlatexonly"|"endhtmlonly"|"endxmlonly"|"enddocbookonly"|"endrtfonly"|"endmanonly"|"f$"|"f]"|"f}"|"f)") {
756 if (&yytext[1]==yyextra->blockName)
758 yyextra->inVerbatim=
false;
759 BEGIN(yyextra->lastCommentContext);
764 if (yytext==yyextra->blockName)
766 yyextra->inVerbatim=
false;
767 BEGIN(yyextra->lastCommentContext);
771 if (yyextra->javaBlock==0)
777 yyextra->javaBlock++;
782 if (yyextra->javaBlock==0)
788 yyextra->javaBlock--;
789 if (yyextra->javaBlock==0)
792 yyextra->inVerbatim=
false;
793 BEGIN(yyextra->lastCommentContext);
801<VerbatimCode>("```"[`]*|"~~~"[~]*) {
802 if (yytext[0]==
'`' && (yyextra->blockName==
"`" || yyextra->blockName==
"``"))
810 if (yytext[0]==yyextra->blockName[0])
812 yyextra->inVerbatim=
false;
813 BEGIN(yyextra->lastCommentContext);
821 yyextra->inVerbatim=
false;
822 BEGIN(yyextra->lastCommentContext);
829 yyextra->inVerbatim=
false;
830 BEGIN(yyextra->lastCommentContext);
833<VerbatimCode>"`"{1,2} {
835 if (yytext==yyextra->blockName)
837 yyextra->inVerbatim=
false;
838 BEGIN(yyextra->lastCommentContext);
841<VerbatimCode>{CMD}("enddot"|"endcode"|"endmsc"|"enduml"|"endmermaid")/("{")? {
843 if (&yytext[1]==yyextra->blockName)
845 yyextra->inVerbatim=
false;
846 BEGIN(yyextra->lastCommentContext);
849<VerbatimCode>^[ \t]*{CPPC}[\!\/]? {
850 if (!yyextra->inSpecialComment || yyextra->mlBrief)
857 while (yytext[l]==
' ' || yytext[l]==
'\t')
872<Verbatim,VerbatimCode>[^`'~@\/\-\\\n{}]* {
875<Verbatim,VerbatimCode>[^`'~@\/\-\\\n{}]+/\n{B}*"//" {
876 if (yyextra->lastCommentContext!=ReadLine)
885<Verbatim,VerbatimCode>[^`'~@\/\-\\\n{}]+/\n {
886 if (yyextra->lastCommentContext==ReadLine)
888 yyextra->inVerbatim=
false;
889 BEGIN(yyextra->lastCommentContext);
893<Verbatim,VerbatimCode>\n {
895 if (yyextra->lastCommentContext == IncludeFile)
900<Verbatim>^[ \t]*{CPPC}[/!] {
901 if (yyextra->blockName==
"enddot" || yyextra->blockName==
"endmsc" || yyextra->blockName==
"enduml" || yyextra->blockName.at(0)==
'f')
905 while (yytext[l]==
' ' || yytext[l]==
'\t')
917<Verbatim,VerbatimCode>. {
921 if (yyextra->lang==SrcLangExt::Fortran || yyextra->lang==SrcLangExt::VHDL)
933 BEGIN(yyextra->stringContext);
941<SkipVerbString>[^"\n]+ {
944<SkipVerbString>\"\" {
947<SkipVerbString>"\"" {
949 BEGIN(yyextra->stringContext);
958 if (yyextra->lang==SrcLangExt::Fortran || yyextra->lang==SrcLangExt::VHDL)
970 BEGIN(yyextra->charContext);
979<CComment,CNComment>[^ `~<\\!@*\n{\"'\/-`]* {
982<CComment,CNComment>^{B}*"*"+[^*\/<\\@\n{\"`]* {
983 if (yyextra->lang==SrcLangExt::Markdown) REJECT;
985 if (yyextra->col>yyextra->blockHeadCol)
988 yyextra->blockHeadCol=yyextra->col;
994 if (yyextra->lang!=SrcLangExt::Python)
998 else if (yyextra->pythonDocStringChar != yytext[0])
1004 yyextra->nestingCount--;
1005 yyextra->pythonDocString =
false;
1006 yyextra->pythonDocStringChar =
'\0';
1011<CComment,CNComment>\n {
1014 if (yyextra->lang==SrcLangExt::Fortran)
1019<CComment,CNComment>"/""/"+/"*/" {
1023<CComment,CNComment>"/"+"*" {
1024 if (yyextra->lang==SrcLangExt::Python ||
1025 yyextra->lang==SrcLangExt::Markdown)
1029 yyextra->nestingCount++;
1030 yyextra->commentStack.push(yyextra->lineNr);
1033<CComment,CNComment>^{B}*"*"+"/" |
1034<CComment,CNComment>"*"+"/" {
1035 if (yyextra->lang==SrcLangExt::Python ||
1036 yyextra->lang==SrcLangExt::Markdown)
1043 yyextra->nestingCount--;
1044 if (yyextra->nestingCount<=0)
1051 yyextra->commentStack.pop();
1056<CComment,CNComment>"\n"/[ \t]*"#" {
1057 if (yyextra->lang!=SrcLangExt::VHDL)
1065 yyextra->vhdl =
false;
1075<CComment,CNComment>"\n"/[ \t]*"-" {
1076 if (yyextra->lang!=SrcLangExt::Python || yyextra->pythonDocString)
1086<CComment,CNComment>"\n"/[ \t]*[^ \t#\-] {
1087 if (yyextra->lang==SrcLangExt::Python)
1089 if (yyextra->pythonDocString)
1099 else if (yyextra->lang==SrcLangExt::VHDL)
1103 yyextra->vhdl =
false;
1129<CComment,CNComment>{CMD}"~"[a-z_A-Z-]* {
1130 if (yyextra->lang!=SrcLangExt::Markdown) REJECT;
1132 if (!langId.
empty() &&
1137 warn(yyextra->fileName,yyextra->lineNr,
DString mid(size_t index, size_t len=npos) const
bool empty() const
Returns true iff the string is empty (std::string compatible alias for isEmpty()).
#define Config_getEnumAsString(name)
#define Config_isAvailableEnum(name, value)
int dstricmp(const char *s1, const char *s2)
#define warn(file, line, fmt,...)
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...
1143<CComment,CNComment>{CMD}{CMD} |
1144<CComment,CNComment>. {
1147<SkipLang>{CMD}"~"[a-zA-Z-]* {
1151 warn(yyextra->fileName,yyextra->lineNr,
1154 else if (langId.
empty() ||
1160<SkipLang>[^*@\\\n]* {
1167<SComment>^[ \t]*{CPPC}"/"{SLASHopt}/\n {
1170<SComment>\n[ \t]*{CPPC}"/"{SLASHopt}/\n {
1173<SComment>^[ \t]*{CPPC}"/"[^\/\n]/.*\n {
1175 yyextra->readLineCtx=YY_START;
1176 YY_CURRENT_BUFFER->yy_at_bol=1;
1179<SComment>\n[ \t]*{CPPC}[\/!]("<")?[ \t]*{CMD}"}".*\n {
1183 yyextra->inSpecialComment=
false;
1184 yyextra->inRoseComment=
false;
1187<SComment>\n[ \t]*{CPPC}"/"[^\\@\/\n]/.*\n {
1189 yyextra->readLineCtx=YY_START;
1190 YY_CURRENT_BUFFER->yy_at_bol=1;
1193<SComment>^[ \t]*{CPPC}"!" |
1194<SComment>^[ \t]*{CPPC}"!<"/.*\n |
1195<SComment>^[ \t]*{CPPC}"!"[^<]/.*\n {
1197 yyextra->readLineCtx=YY_START;
1198 YY_CURRENT_BUFFER->yy_at_bol=1;
1201<SComment>\n[ \t]*{CPPC}"!" |
1202<SComment>\n[ \t]*{CPPC}"!<"/.*\n |
1203<SComment>\n[ \t]*{CPPC}"!"[^<\n]/.*\n {
1205 yyextra->readLineCtx=YY_START;
1206 YY_CURRENT_BUFFER->yy_at_bol=1;
1209<SComment>^[ \t]*{CPPC}"##"/.*\n {
1210 if (!yyextra->inRoseComment)
1217 yyextra->readLineCtx=YY_START;
1218 YY_CURRENT_BUFFER->yy_at_bol=1;
1222<SComment>\n[ \t]*{CPPC}"##"/.*\n {
1223 if (!yyextra->inRoseComment)
1230 yyextra->readLineCtx=YY_START;
1231 YY_CURRENT_BUFFER->yy_at_bol=1;
1238 yyextra->inSpecialComment=
false;
1239 yyextra->inRoseComment=
false;
1240 yyextra->insertCppCommentMarker=
false;
1241 yyextra->readLineCtx = Scan;
1245<ReadLine,CopyLine>{CCS}"*" {
1248<ReadLine,CopyLine>{CCE} {
1251<ReadLine,CopyLine>"*" {
1254<ReadLine,CopyLine>{RL} {
1257<ReadLine,CopyLine>{RL}/{B}{CMD}"ilinebr"{B} {
1260<ReadLine,CopyLine>{RLopt}/\n {
1262 yyextra->insertCppCommentMarker=
false;
1263 BEGIN(yyextra->readLineCtx);
1265<CComment,CNComment,ReadLine>"\<" {
1268<CComment,CNComment,ReadLine>{CMD}{CMD}[~a-z_A-Z][a-z_A-Z0-9]*[ \t]* {
1272<CComment,ReadLine,IncludeFile>{CMD}("include"{OPTS}|"includedoc"{OPTS}*) {
1273 if (!
parseIncludeOptions(yyscanner,std::string_view{yytext,
static_cast<size_t>(yyleng)})) REJECT;
1274 yyextra->includeCtx = YY_START;
1275 yyextra->firstIncludeLine =
true;
1276 yyextra->insertCommentCol = yyextra->col;
1277 if (!yyextra->insertCppCommentMarker && (yyextra->includeCtx==ReadLine || yyextra->includeCtx==IncludeFile))
1279 yyextra->insertCppCommentMarker = yyextra->mlBrief;
1282 yyextra->snippetRtn = 0;
1285<CComment,ReadLine,IncludeFile>{CMD}("snippet"{OPTS}|"snippetdoc"{OPTS}*) {
1286 if (!
parseIncludeOptions(yyscanner,std::string_view{yytext,
static_cast<size_t>(yyleng)})) REJECT;
1287 yyextra->includeCtx = YY_START;
1288 yyextra->firstIncludeLine =
true;
1289 yyextra->insertCommentCol = yyextra->col;
1290 if (!yyextra->insertCppCommentMarker && (yyextra->includeCtx==ReadLine || yyextra->includeCtx==IncludeFile))
1292 yyextra->insertCppCommentMarker = yyextra->mlBrief;
1295 yyextra->snippetRtn = 0;
1298<IncludeDoc,SnippetDoc>{B}*{CCE} {
1299 warn(yyextra->fileName,yyextra->lineNr,
"Found \\{}{{doc}} command without valid file name argument",
1300 YY_START==IncludeDoc?
"include" :
"snippet"
1302 for (
int i=(
int)yyleng-1;i>=0;i--) unput(yytext[i]);
1305 BEGIN(yyextra->includeCtx);
DString & setNum(short n)
std::string_view view() const
1307<IncludeDoc,SnippetDoc>^{B}*"*"+{B}* {
1308 if (!(yyextra->snippetRtn && (yyextra->includeCtx==CComment || yyextra->includeCtx==CNComment))) REJECT;
1310<IncludeDoc,SnippetDoc>{B}*
1311<IncludeDoc>{FILEMASK}|"\""[^\n\"]+"\"" {
1315 fileName=fileName.
mid(1,fileName.
length()-2);
1323 BEGIN(yyextra->includeCtx);
size_t length() const
Returns the length of the string, not counting the 0-terminator.
1326<SnippetDoc>({FILEMASK}|"\""[^\n\"]+"\"") {
1327 yyextra->snippetFileName=yytext;
1328 yyextra->snippetFileName=yyextra->snippetFileName.stripWhiteSpace();
1329 if (yyextra->snippetFileName ==
"this") yyextra->snippetFileName=yyextra->fileName;
1330 yyextra->snippetName =
"";
1331 yyextra->snippetRtn = 0;
1332 BEGIN(SnippetDocTag);
1334<SnippetDocTag>\n{B}*{CPPC}[\/!]{B}*/\n {
1335 if (!yyextra->snippetName.stripWhiteSpace().empty()) REJECT;
1337 warn_doc_error(yyextra->fileName,yyextra->lineNr,
"no block identification found in \\snippet{{doc}} command, skipping");
1341 BEGIN(yyextra->includeCtx);
#define warn_doc_error(file, line, fmt,...)
1343<SnippetDocTag>\n{B}*{CPPC}[\/!] {
1344 if (yyextra->snippetName.stripWhiteSpace().empty())
1346 if (yyextra->snippetRtn)
1348 warn_doc_error(yyextra->fileName,yyextra->lineNr,
"no block identification found in \\snippet{{doc}} command, skipping");
1352 BEGIN(yyextra->includeCtx);
1364<SnippetDocTag>{B}*{CCE} {
1365 if (!yyextra->snippetName.stripWhiteSpace().empty()) REJECT;
1367 warn_doc_error(yyextra->fileName,yyextra->lineNr,
"no block identification found in \\snippet{{doc}} command, skipping");
1368 for (
int i=(
int)yyleng-1;i>=0;i--) unput(yytext[i]);
1371 BEGIN(yyextra->includeCtx);
1373<SnippetDocTag>^{B}*"*"+{B}* {
1374 if (!(yyextra->snippetRtn && (yyextra->includeCtx==CComment || yyextra->includeCtx==CNComment))) REJECT;
1376<SnippetDocTag>[^\\@\n]+ {
1377 yyextra->snippetName += yytext;
1379<SnippetDocTag>{CMD} {
1380 yyextra->snippetName += yytext;
1383<SnippetDocTag>(\n|{CMD}"ilinebr")/{B}*("*/")? |
1384<SnippetDocTag>(\n|{CMD}"ilinebr"){B}*"*" {
1385 if (!yyextra->snippetName.stripWhiteSpace().empty() || yyextra->snippetRtn)
1387 for (
int i=(
int)yyleng-1;i>=0;i--) unput(yytext[i]);
1388 yyextra->snippetName = yyextra->snippetName.stripWhiteSpace();
1389 DString blockId =
"["+yyextra->snippetName+
"]";
1396 BEGIN(yyextra->includeCtx);
1399 else if (yyextra->snippetName.stripWhiteSpace().empty() && !yyextra->snippetRtn &&
1400 yyextra->includeCtx == ReadLine)
1402 warn_doc_error(yyextra->fileName,yyextra->lineNr,
"no block identification found in \\snippet{{doc}} command, skipping");
1403 for (
int i=(
int)yyleng-1;i>=0;i--) unput(yytext[i]);
1406 BEGIN(yyextra->includeCtx);
1410 if (yytext[0] ==
'\n')
1419 yyextra->snippetRtn++;
1423<IncludeDoc,SnippetDoc>\n{B}*{CPPC}[\/!]{B}*/\n {
1424 warn(yyextra->fileName,yyextra->lineNr,
"Found \\{}{{doc}} command without valid file name argument",
1425 YY_START==IncludeDoc?
"include" :
"snippet"
1430 BEGIN(yyextra->includeCtx);
1432<IncludeDoc,SnippetDoc>\n{B}*{CPPC}[\/!] {
1435<IncludeDoc,SnippetDoc>\n {
1436 if (yyextra->snippetRtn)
1441 warn(yyextra->fileName,yyextra->lineNr,
"Found \\{}{{doc}} command without valid file name argument",
1442 YY_START==IncludeDoc?
"include" :
"snippet"
1447 BEGIN(yyextra->includeCtx);
1449 else if (yyextra->includeCtx == ReadLine)
1452 warn(yyextra->fileName,yyextra->lineNr,
"Found \\{}{{doc}} command without valid file name argument",
1453 YY_START==IncludeDoc?
"include" :
"snippet"
1455 BEGIN(yyextra->includeCtx);
1461 yyextra->snippetRtn++;
1464<IncludeDoc,SnippetDoc>. {
1465 warn(yyextra->fileName,yyextra->lineNr,
"Found invalid character for file name of \\{}{{doc}} command",
1466 YY_START==IncludeDoc?
"include" :
"snippet"
1471 BEGIN(yyextra->includeCtx);
1473<CComment,ReadLine,IncludeFile>{CMD}"cond"/[^a-z_A-Z0-9] {
1474 yyextra->condCtx = YY_START;
1477<CComment,ReadLine,IncludeFile>{CMD}"endcond"/[^a-z_A-Z0-9] {
1478 bool oldSkip=yyextra->skip;
1480 if (YY_START==CComment && oldSkip && !yyextra->skip)
1483 if (yyextra->lang!=SrcLangExt::Python &&
1484 yyextra->lang!=SrcLangExt::VHDL &&
1485 yyextra->lang!=SrcLangExt::Markdown &&
1486 yyextra->lang!=SrcLangExt::Fortran)
1488 yyextra->outBuf+=
'/';
1489 yyextra->outBuf+=
'*';
1491 if (yyextra->specialComment)
1493 yyextra->outBuf+=
'*';
1499<CondLine>{B}*{CMD}doxyconfig{B}+{DOXYCFG} {
1502<CondLine>([!()&| \ta-z_A-Z0-9.\-]|{CMD}"doxyconfig")+ {
1505<CComment,ReadLine,IncludeFile>{CMD}"cond"{WSopt}/\n {
1506 yyextra->condCtx=YY_START;
1514<CComment,ReadLine,IncludeFile,Verbatim,VerbatimCode>{CMD}[a-z_A-Z][a-z_A-Z0-9-]* {
1515 bool inCppComment = YY_START==ReadLine && yyextra->readLineCtx==SComment;
1516 bool inCComment = YY_START==CComment && yyextra->blockHeadCol>0;
1519<CComment,ReadLine,IncludeFile,Verbatim,VerbatimCode>{B}?{CMD}"ilinebr"{B}{CMD}"ialias{" {
1520 yyextra->lastBlockContext=YY_START;
1521 yyextra->blockCount=1;
1522 int extraSpace = (yytext[0]==
' '? 1:0);
1523 yyextra->aliasString=yytext+9+extraSpace;
1524 yyextra->aliasCmd=yytext+9+extraSpace;
1525 yyextra->lastEscaped=0;
1526 BEGIN( ReadAliasArgs );
1528<CComment,ReadLine,IncludeFile,Verbatim,VerbatimCode>{CMD}[a-z_A-Z][a-z_A-Z0-9-]*"{" {
1529 yyextra->lastBlockContext=YY_START;
1530 yyextra->blockCount=1;
1531 yyextra->aliasString=yytext;
1532 yyextra->aliasCmd=yytext;
1533 yyextra->lastEscaped=0;
1534 BEGIN( ReadAliasArgs );
1536<ReadAliasArgs>^[ \t]*"*" {
1538 if (indent>yyextra->blockHeadCol)
1540 yyextra->aliasString+=yytext;
1547<ReadAliasArgs>^[ \t]*{CPPC}[/!]/[^\n]* {
1549<ReadAliasArgs>[^{}\n\\\*]+ {
1550 yyextra->aliasString+=yytext;
1551 yyextra->lastEscaped=
false;
1553<ReadAliasArgs>"\\" {
1554 if (yyextra->lastEscaped) yyextra->lastEscaped=
false;
1555 else yyextra->lastEscaped=
true;
1556 yyextra->aliasString+=yytext;
1558<ReadAliasArgs>{CMD}("endverbatim"|"endiliteral"|"endlatexonly"|"endhtmlonly"|"endxmlonly"|"enddocbookonly"|"endrtfonly"|"endmanonly"|"f$"|"f]"|"f}"|"f)") {
1559 yyextra->aliasString+=yytext;
1560 if (yyextra->inVerbatim && &yytext[1]==yyextra->blockName)
1569 yyextra->inVerbatim=
false;
1570 BEGIN(yyextra->lastCommentContext);
1574 yyextra->aliasString+=yytext;
1575 yyextra->lastEscaped=
false;
1576 if (yyextra->inVerbatim)
1580 BEGIN( yyextra->lastBlockContext );
1584 yyextra->aliasString+=yytext;
1585 if (!yyextra->lastEscaped) yyextra->blockCount++;
1586 yyextra->lastEscaped=
false;
1589 yyextra->aliasString+=yytext;
1590 if (!yyextra->lastEscaped) yyextra->blockCount--;
1591 if (yyextra->blockCount==0)
1593 bool inCppComment = yyextra->lastBlockContext==ReadLine && yyextra->readLineCtx==SComment;
1594 bool inCComment = yyextra->lastBlockContext==CComment && yyextra->blockHeadCol>0;
1595 replaceAliases(yyscanner,yyextra->aliasString.view(),inCppComment,inCComment);
1596 BEGIN( yyextra->lastBlockContext );
1598 yyextra->lastEscaped=
false;
1601 yyextra->aliasString+=yytext;
1602 yyextra->lastEscaped=
false;
1609 yyextra->insertCppCommentMarker=
false;
1610 BEGIN(yyextra->readLineCtx);
1612<ReadLine>{CMD}{CMD} |
1627 if (YY_START == ReadAliasArgs)
1629 warn(yyextra->fileName,yyextra->lineNr,
1630 "Reached end of file while still searching closing '}}' of an alias argument (probable start: '{}')",
1633 else if (YY_START==Verbatim || YY_START==VerbatimCode)
1635 warn(yyextra->fileName,yyextra->lineNr,
1636 "Reached end of file while still searching closing '{}' of a verbatim block starting at line {}",
1637 yyextra->blockName,yyextra->verbatimLine);
1639 if (yyextra->includeStack.empty())
1641 yyextra->insertCppCommentMarker=
false;
1646 std::unique_ptr<commentcnv_FileState> &fs = yyextra->includeStack.back();
1647 YY_BUFFER_STATE oldBuf = YY_CURRENT_BUFFER;
1648 yy_switch_to_buffer(fs->bufState, yyscanner);
1649 yy_delete_buffer(oldBuf, yyscanner);
1650 BEGIN(fs->oldState);
1651 yyextra->fileName = fs->oldFileName;
1652 yyextra->lineNr = fs->oldLineNr;
1653 yyextra->inBuf = fs->oldFileBuf;
1654 yyextra->inBufPos = fs->oldFileBufPos;
1655 yyextra->includeCtx = fs->oldIncludeCtx;
1656 DString lineStr=
" \\ifile \""+yyextra->fileName+
"\" \\iline "+
DString().
setNum(yyextra->lineNr)+
" ";
1657 if (fs->oldRaiseLvl!=yyextra->raiseLevel)
1659 lineStr+=
"\\iraise " + std::to_string(fs->oldRaiseLvl)+
" ";
1661 if (fs->oldRaiseLbl!=yyextra->raiseLabel)
1663 lineStr+=
"\\iprefix \"" + fs->oldRaiseLbl +
"\" ";
1665 lineStr+=
"\\ilinebr ";
1666 yyextra->raiseLevel = fs->oldRaiseLvl;
1667 yyextra->raiseLabel = fs->oldRaiseLbl;
1669 yyextra->includeStack.pop_back();
1684 size_t optIdxStart = s.find(
'{');
1685 size_t optIdxEnd = optIdxStart!=std::string::npos ? s.find(
"}",optIdxStart+1) : std::string::npos;
1686 std::string cmdName;
1688 if (optIdxStart == std::string::npos)
1695 optList =
split(std::string{s.substr(optIdxStart+1,optIdxEnd-optIdxStart-1)},
",");
1698 bool isDoc = cmdName==
"includedoc" || cmdName==
"snippetdoc";
1699 for (
const auto &opt : optList)
1704 docOption =
"{doc}";
1711 yyextra->replacements.clear();
1712 for (
const auto &opt : optList)
1715 size_t posEqual = locOpt.find(
'=');
1716 auto option = std::string{posEqual!=std::string::npos ?
stripWhiteSpace(locOpt.substr(0,posEqual)) : locOpt};
1717 auto value = std::string{posEqual!=std::string::npos ?
stripWhiteSpace(locOpt.substr(posEqual+1)) : std::string()};
1719 if (option==
"doc" && value.empty())
1723 else if (option==
"raise" && !value.empty())
1725 yyextra->raiseIncrement = atoi(value.data());
1728 warn(yyextra->fileName,yyextra->lineNr,
"Raising section level from {} to {}, exceeds allowed range [0-{}], adjusting",
1733 else if (option==
"prefix" && !value.empty())
1735 yyextra->raisePrefix = value;
1737 else if (option==
"replace" && !value.empty())
1739 bool global =
false;
1741 size_t replSize = replVec.size();
1742 if ((replSize!=2 && replSize!=3) || (replSize==3 && replVec[2]!=
"g"))
1744 warn(yyextra->fileName,yyextra->lineNr,
"Incorrect replace option '{}' for {} command with value '{}'",option, cmdName, value);
1748 if (replSize==3 && !replVec[0].empty())
1750 global = !(replVec[0][0]==
'^' || replVec[0][replVec[0].length()-1]==
'$');
1752 yyextra->replacements.emplace_back(std::move(replVec[0]), std::move(replVec[1]), global);
1757 warn(yyextra->fileName,yyextra->lineNr,
"Unsupported option '{}' for {}{} command",option, cmdName, docOption);
1769 if (s.empty())
return;
1771 size_t len = s.length();
1774 while (p<len && (c=s[p]) && (c==
' ' || c==
'\t' || c==
'\n'))
1777 if (c==
'\n') { yyextra->lineNr++; yyextra->col=0; }
else { yyextra->col++; }
1782 while (p<len && (c=s[p]) && (c==
'/' || c==
'!' || c==
'#'))
1786 if (p<len && s[p]==
'<')
1800 yyextra->outBuf+=
' ';
1804 if (blanks>1) { yyextra->outBuf+=
'*'; yyextra->col++; }
1805 yyextra->outBuf+=
' ';
1809 yyextra->outBuf+=s.substr(p);
1810 yyextra->col+=
static_cast<int>(s.substr(p).length());
1822 else if (c==
'\t') col+=tabSize-(col%tabSize);
1832 size_t len = s.length();
1835 for (
size_t i=0;i<len;i++)
1840 yyextra->outBuf+=
'\n';
1845 yyextra->col+=tabSize-(yyextra->col%tabSize);
1856 for (
size_t i=0;i<len;i++)
1860 case '\n': yyextra->col=0;
1862 yyextra->lineNr++;
break;
1863 case '\t': yyextra->col+=tabSize-(yyextra->col%tabSize);
break;
1864 default: yyextra->col++;
break;
1872 copyToOutput(yyscanner,std::string_view{s,(size_t)len});
1878 while (!yyextra->commentStack.empty()) yyextra->commentStack.pop();
1886 bool expResult = prs.
parse(yyextra->fileName,yyextra->lineNr,sectId);
1887 yyextra->condStack.emplace(yyextra->lineNr,sectId,yyextra->skip);
1897 if (yyextra->condStack.empty())
1899 warn(yyextra->fileName,yyextra->lineNr,
"Found \\endcond command without matching \\cond");
1900 yyextra->skip=
false;
1906 yyextra->condStack.pop();
1914 bool oldSkip=yyextra->skip;
1916 if ((yyextra->condCtx==CComment || yyextra->readLineCtx==SComment) &&
1917 !oldSkip && yyextra->skip)
1919 if (yyextra->lang!=SrcLangExt::Python &&
1920 yyextra->lang!=SrcLangExt::VHDL &&
1921 yyextra->lang!=SrcLangExt::Markdown &&
1922 yyextra->lang!=SrcLangExt::Fortran)
1924 yyextra->outBuf+=
'*';
1925 yyextra->outBuf+=
'/';
1929 if (yyextra->readLineCtx==SComment)
1935 BEGIN(yyextra->condCtx);
1947 size_t m1 = text.
find(marker);
1955 found = (p<=m1 && m1<i);
1974 size_t m1 = text.
find(marker);
1976 size_t m2 = text.
find(marker,m1+marker.
length());
1983 found = (p<=m1 && m1<i);
2012 size_t startCol=yyextra->blockHeadCol;
2013 size_t contentCol=yyextra->insertCommentCol;
2014 size_t markerSpace=contentCol-startCol;
2018 if (yyextra->lang==SrcLangExt::Python)
2020 if (yyextra->pythonDocString)
2029 else if (yyextra->lang==SrcLangExt::Fortran)
2033 else if (yyextra->lang==SrcLangExt::Markdown)
2037 else if (yyextra->insertCppCommentMarker)
2052 for (;i<startCol;i++)
2056 if (marker.length()<=markerSpace && !yyextra->firstIncludeLine)
2059 i+=
static_cast<int>(marker.length());
2061 for (;i<contentCol;i++)
2065 yyextra->firstIncludeLine =
false;
2079 warn_doc_error(yyextra->fileName,yyextra->lineNr,
"included file name '{}' is ambiguous"
2084 bool alreadyProcessed = std::any_of(
2085 yyextra->includeStack.begin(),
2086 yyextra->includeStack.end(),
2087 [&absFileName,&blockId](
const auto &lfs)
2088 { return lfs->fileName==absFileName && lfs->blockId==blockId; }
2091 if (alreadyProcessed)
2093 if (!blockId.
empty())
2095 warn_doc_error(yyextra->fileName,yyextra->lineNr,
"recursive usage of '\\snippet{{doc}}' block with name '{}' and file name '{}', skipping",
2096 blockId,absFileName);
2100 warn_doc_error(yyextra->fileName,yyextra->lineNr,
"recursive usage of '\\include{{doc}}' with file name '{}', skipping", absFileName);
2107 auto fs = std::make_unique<commentcnv_FileState>();
2110 warn_doc_error(yyextra->fileName,yyextra->lineNr,
"\\{}{{doc}} file '{}' could not be read",blockId.
empty()?
"include":
"snippet",absFileName);
2117 DString incText { fs->fileBuf };
2118 if (!blockId.
empty())
2120 if (blockId ==
"[]")
2124 warn_doc_error(yyextra->fileName,yyextra->lineNr,
"no block identification found in \\snippet{{doc}} command, skipping");
2133 warn_doc_error(yyextra->fileName,yyextra->lineNr,
"block marked with {} for \\snippet{{doc}} should appear twice in file {}, found it {:d} times, skipping",
2134 blockId,absFileName,count);
2138 size_t blockPos = 0;
2142 if (!yyextra->replacements.empty())
2145 for (
const auto &replElem : yyextra->replacements)
2151 for (
const auto &line : txtVec)
2153 std::string newLine;
2154 if (replElem.re ==
"^")
2156 newLine += replElem.replacement;
2159 else if (replElem.re ==
"$")
2162 newLine += replElem.replacement;
2164 else if ((replElem.re ==
"^$") && (line.length() == 0))
2166 newLine += replElem.replacement;
2173 if (match.length() == 0)
break;
2174 newLine += line.substr(pos,match.position() - pos);
2175 newLine += replElem.replacement;
2176 pos=match.position()+match.length();
2177 if (!replElem.global)
break;
2179 newLine += line.substr(pos);
2181 txtVec[i++] = newLine;
2184 fs->fileBuf.clear();
2185 if (!incText.
empty())
2187 fs->fileBuf.append(
join(txtVec,
"\n"));
2188 fs->fileBuf.append(
"\n");
2193 fs->fileBuf.clear();
2194 if (!incText.
empty())
2196 fs->fileBuf.append(incText.
str());
2200 int oldRaiseLevel = yyextra->raiseLevel;
2201 DString oldRaiseLabel = yyextra->raiseLabel;
2202 yyextra->raiseLevel+=yyextra->raiseIncrement;
2203 yyextra->raiseLabel+=yyextra->raisePrefix;
2204 DString lineStr=
" \\ifile \""+absFileName+
"\" \\iline " + std::to_string(lineNr)+
" ";
2205 if (yyextra->raiseLevel>0)
2207 lineStr+=
"\\iraise " + std::to_string(yyextra->raiseLevel)+
" ";
2209 if (!yyextra->raiseLabel.empty())
2211 lineStr+=
"\\iprefix \"" + yyextra->raiseLabel +
"\" ";
2213 lineStr+=
"\\ilinebr ";
2216 fs->fileName = absFileName;
2217 fs->bufState = YY_CURRENT_BUFFER;
2218 fs->oldLineNr = yyextra->lineNr;
2219 fs->oldFileName = yyextra->fileName;
2220 fs->oldState = yyextra->includeCtx;
2221 fs->oldFileBuf = yyextra->inBuf;
2222 fs->oldFileBufPos = yyextra->inBufPos;
2223 fs->oldIncludeCtx = yyextra->includeCtx;
2224 fs->oldRaiseLvl = oldRaiseLevel;
2225 fs->oldRaiseLbl = oldRaiseLabel;
2226 fs->blockId = blockId;
2227 yy_switch_to_buffer(yy_create_buffer(
nullptr,
YY_BUF_SIZE, yyscanner),yyscanner);
2228 yyextra->fileName = absFileName;
2229 yyextra->lineNr = lineNr;
2230 yyextra->inBuf = &fs->fileBuf;
2231 yyextra->inBufPos = 0;
2232 yyextra->includeStack.
push_back(std::move(fs));
2238 warn_doc_error(yyextra->fileName,yyextra->lineNr,
"\\{}{{doc}} file '{}' not found",blockId.
empty()?
"include":
"snippet",inc);
2252 if (s.empty())
return;
2253 size_t pos = s.find(
'{');
2254 std::string cmd { s.substr(1, pos!=std::string::npos ? pos-1 : s.length()-1) };
2255 auto &expAlias = yyextra->expandedAliases;
2256 if (std::find(expAlias.begin(),expAlias.end(),cmd)!=std::end(expAlias))
2261 else if (cmd==
"ialias")
2263 if (s.length()>cmd.length()+3)
2265 std::string value { s.substr(cmd.length()+2,s.length()-cmd.length()-3) };
2267 expAlias.erase(std::remove(expAlias.begin(),expAlias.end(),value),expAlias.end());
2272 if (yyextra->inVerbatim)
2275 std::string blk = yyextra->blockName.str();
2277 bool isNamedCommand=
isId(blk[0]);
2280 while ((i=result.find(blk,p))!=std::string::npos && !found)
2282 found = !isNamedCommand ||
2283 (i>0 && (result[i-1]==
'\\' || result[i-1]==
'@') && !
isId(result[i+blk.length()]));
2284 p = i+yyextra->blockName.length();
2296 size_t numSpaces = yyextra->blockHeadCol>1 ? yyextra->blockHeadCol-1 : 0;
2297 std::string spaces(numSpaces,
' ');
2298 if (replaceCppComment)
2302 std::string replacement =
"\n"+spaces+
"///";
2305 else if (replaceCComment)
2307 std::string replacement =
"\n"+spaces+
" * ";
2310 expAlias.push_back(cmd);
2312 result +=
" \\ilinebr \\ialias{";
2315 for (
int i=(
int)result.length()-1; i>=0; i--)
2330 int bytesInBuf =
static_cast<int>(yyextra->inBuf->size())-yyextra->inBufPos;
2331 int bytesToCopy = std::min(max_size,bytesInBuf);
2332 memcpy(buf,yyextra->inBuf->data()+yyextra->inBufPos,bytesToCopy);
2333 yyextra->inBufPos+=bytesToCopy;
2340 if (yyextra->mlBrief || yyextra->skip)
2353 bool afterMember = yyleng>0 && yytext[yyleng-1]==
'<';
2356 bool headAfterMember = yyextra->blockHeadPos!=std::string::npos &&
2357 yyextra->blockHeadPos+3<yyextra->outBuf.size() &&
2358 yyextra->outBuf[yyextra->blockHeadPos+3]==
'<';
2359 bool sameEntity = afterMember && headAfterMember;
2361 if (i==yyextra->blockHeadCol || i+1==yyextra->blockHeadCol)
2365 else if (sameEntity)
2369 while (p<(
size_t)yyleng && (yytext[p]==
' ' || yytext[p]==
'\t')) p++;
2370 bool javadoc = yytext[p+2]==
'/';
2373 yyextra->blockHeadCol=i+1;
2374 yyextra->blockHeadPos=yyextra->outBuf.size();
2379 if (javadoc && jdAuto && !qtAuto) javadoc=
false;
2380 else if (!javadoc && qtAuto && !jdAuto) javadoc=
true;
2386 for (i = yyleng; i>0; )
2391 yyextra->inSpecialComment=
false;
2408 commentcnvYYlex_init_extra(&extra,&yyscanner);
2414 yyextra->inBufPos = 0;
2417 yyextra->skip =
false;
2418 yyextra->fileName = fileName;
2420 yyextra->pythonDocString =
false;
2421 yyextra->lineNr = 1;
2422 yyextra->raiseLevel = 0;
2423 yyextra->raiseLabel =
"";
2424 yyextra->raiseIncrement = 0;
2425 yyextra->raisePrefix =
"";
2426 yyextra->insertCppCommentMarker=
false;
2427 yyextra->expandedAliases.clear();
2428 yyextra->replacements.clear();
2429 while (!yyextra->condStack.empty()) yyextra->condStack.pop();
2431 yyextra->vhdl =
false;
2434 yyextra->isFixedForm =
false;
2435 if (yyextra->lang==SrcLangExt::Fortran)
2441 if (yyextra->lang==SrcLangExt::Markdown)
2443 yyextra->nestingCount=0;
2445 yyextra->commentStack.push(yyextra->lineNr);
2452 while (!yyextra->condStack.empty())
2457 warn(yyextra->fileName,ctx.
lineNr,
"Conditional section{}does not have "
2458 "a corresponding \\endcond command within this file.",sectionInfo.
data());
2459 yyextra->condStack.pop();
2461 if (yyextra->nestingCount>0 && yyextra->lang!=SrcLangExt::Markdown && yyextra->lang!=SrcLangExt::Fortran)
2465 while (!yyextra->commentStack.empty())
2467 int lineNr = yyextra->commentStack.top();
2468 if (!first) lines +=
", ";
2471 yyextra->commentStack.pop();
2473 warn(yyextra->fileName,yyextra->lineNr,
"Reached end of file while still inside a (nested) comment. "
2474 "Nesting level {} (possible line reference(s): {})",yyextra->nestingCount,lines);
2476 yyextra->nestingCount = 0;
2480 "output=[\n{}]\n-----------\n",fileName,yyextra->outBuf
2483 commentcnvYYlex_destroy(yyscanner);
2489#include "commentcnv.l.h"
std::string resolveAliasCmd(std::string_view aliasCmd)
Copyright (C) 1997-2026 by Dimitri van Heesch.
bool parse(const DString &fileName, int lineNr, const DString &expr)
parses and evaluates the given expression.
static constexpr size_t npos
value used to indicate 'not found' or 'to the end of the string', matching std::string::npos
int contains(char c, bool cs=true) const
size_t find(char c, size_t pos=0) const
DString & sprintf(const char *format,...)
const std::string & str() const
const char * data() const
Returns a pointer to the contents of the string in the form of a 0-terminated C string.
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.
DString showFileDefMatches(const DString &n) const
Returns a list of file definitions in fnMap that match the file name n.
static constexpr int MaxLevel
Class representing a regular expression.
Object representing the matching results.
#define Config_getInt(name)
std::vector< std::string > StringVector
bool isId(char c)
Returns true if c is a valid character for an identifier.
const char * qPrint(const char *s)
bool recognizeFixedForm(const DString &contents, FortranFormat format)
FortranFormat convertFileNameFortranParserCode(const DString &fn)
bool search(std::string_view str, Match &match, const Ex &re, size_t pos)
Search in a given string str starting at position pos for a match against regular expression re.
std::string join(const StringVector &sv, const std::string &delimiter)
create a string where the string in the vector are joined by the given delimiter
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...
StringVector split(const std::string &s, const std::string &delimiter, bool retainEmpty=false)
split input string s by string delimiter delimiter.
bool readInputFile(const DString &fileName, std::string &contents, const ReadInputFileOptions &options)
read a file name fileName and optionally filter and transcode it
SrcLangExt getLanguageFromFileName(const DString &fileName, SrcLangExt defLang)
DString findExampleFilePath(const DString &file, bool &ambig)