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.
SrcLangExt
Language as given by extension.
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\-]+
196DECIMAL_INTEGER [1-9][0-9']*[0-9]?[uU]?[lL]?[lL]?
197HEXADECIMAL_INTEGER "0"[xX][0-9a-zA-Z']+[0-9a-zA-Z]?
198OCTAL_INTEGER "0"[0-7][0-7']+[0-7]?
199BINARY_INTEGER "0"[bB][01][01']*[01]?
200INTEGER_NUMBER {DECIMAL_INTEGER}|{HEXADECIMAL_INTEGER}|{OCTAL_INTEGER}|{BINARY_INTEGER}
204DIGIT_SEQ [0-9][0-9']*[0-9]?
205FRAC_CONST {DIGIT_SEQ}"."|{DIGIT_SEQ}?"."{DIGIT_SEQ}
206FP_EXP [eE][+-]?{DIGIT_SEQ}
207DEC_FP1 {FRAC_CONST}{FP_EXP}?{FP_SUF}?
208DEC_FP2 {DIGIT_SEQ}{FP_EXP}{FP_SUF}
210HEX_DIGIT_SEQ [0-9a-fA-F][0-9a-fA-F']*[0-9a-fA-F]?
211HEX_FRAC_CONST {HEX_DIGIT_SEQ}"."|{HEX_DIGIT_SEQ}?"."{HEX_DIGIT_SEQ}
212BIN_EXP [pP][+-]?{DIGIT_SEQ}
213HEX_FP1 "0"[xX]{HEX_FRAC_CONST}{BIN_EXP}{FP_SUF}?
214HEX_FP2 "0"[xX]{HEX_DIGIT_SEQ}{BIN_EXP}{FP_SUF}?
216FLOAT_DECIMAL {DEC_FP1}|{DEC_FP2}
217FLOAT_HEXADECIMAL {HEX_FP1}|{HEX_FP2}
218FLOAT_NUMBER {FLOAT_DECIMAL}|{FLOAT_HEXADECIMAL}
219NUMBER {INTEGER_NUMBER}|{FLOAT_NUMBER}
221FILEICHAR [a-z_A-Z0-9\x80-\xFF\\:\\\/\-\+=&#@]
222FILEECHAR [a-z_A-Z0-9\x80-\xFF\-\+=&#@]
223FILECHARS {FILEICHAR}*{FILEECHAR}+
224HFILEMASK {FILEICHAR}*("."{FILEICHAR}+)+{FILECHARS}*
225VFILEMASK {FILECHARS}("."{FILECHARS})*
226FILEMASK {VFILEMASK}|{HFILEMASK}
257<Scan>[^"'!\/\n\\#,\-=; \t@$]* {
271 yyextra->pythonDocString =
TRUE;
272 yyextra->pythonDocStringChar = yytext[0];
273 yyextra->nestingCount=1;
277 yyextra->commentStack.push(yyextra->lineNr);
292 yyextra->pythonDocString =
TRUE;
293 yyextra->pythonDocStringChar = yytext[0];
294 yyextra->nestingCount=1;
298 yyextra->commentStack.push(yyextra->lineNr);
#define Config_getBool(name)
301<Scan>{B}*![><!]/.*\n {
308 yyextra->nestingCount=0;
310 yyextra->specialComment=
true;
312 yyextra->blockHeadCol=yyextra->col-2;
314 yyextra->commentStack.push(yyextra->lineNr);
317<Scan>[Cc\*][><!]/.*\n {
325 if (yyextra->isFixedForm && (yyextra->col == 0))
327 yyextra->nestingCount=0;
329 yyextra->specialComment=
true;
331 yyextra->blockHeadCol=yyextra->col-1;
333 yyextra->commentStack.push(yyextra->lineNr);
358 if (yyextra->col == 0)
371 yyextra->stringContext = YY_START;
372 BEGIN(SkipVerbString);
376 yyextra->stringContext = YY_START;
381 yyextra->charContext = YY_START;
390<Scan>{CPPC}"!"/.*\n[ \t]*{CPPC}[\/!][^\/] |
391<Scan>({CPPC}"/"[/]*)/[^/].*\n[ \t]*{CPPC}[\/!][^\/] {
392 if (yyextra->mlBrief)
401 while (i<(
int)yyleng && yytext[i]==
'/') i++;
403 yyextra->blockHeadCol=yyextra->col+1;
404 if (yytext[2] ==
'!')
413 yyextra->inSpecialComment=
TRUE;
415 yyextra->readLineCtx=SComment;
419<Scan>{CPPC}"##Documentation"{ANYopt}/\n {
420 if (yyextra->mlBrief) REJECT;
422 yyextra->blockHeadCol=yyextra->col+1;
425 yyextra->inRoseComment=
TRUE;
428<Scan>{CPPC}[!\/]/.*\n[ \t]*{CPPC}[|\/][ \t]*[@\\]"}" {
429 yyextra->inSpecialComment=yytext[2]==
'/' || yytext[2]==
'!';
430 if (yyextra->inSpecialComment)
432 yyextra->blockHeadCol=yyextra->col+1;
435 yyextra->readLineCtx=YY_START;
438<Scan>{CPPC}[!/]/.*\n {
439 yyextra->inSpecialComment=
true;
440 yyextra->blockHeadCol=yyextra->col+1;
441 yyextra->insertCppCommentMarker=
true;
443 yyextra->readLineCtx=YY_START;
447 yyextra->inSpecialComment=
false;
449 yyextra->readLineCtx=YY_START;
460 yyextra->specialComment=(int)yyleng==3;
461 yyextra->nestingCount=1;
464 if (yyextra->specialComment)
466 yyextra->blockHeadCol=0;
473 yyextra->commentStack.push(yyextra->lineNr);
489 yyextra->nestingCount=0;
491 yyextra->specialComment=(int)yyleng==2;
492 if (yyextra->specialComment)
494 yyextra->blockHeadCol=yyextra->col;
496 yyextra->commentStack.push(yyextra->lineNr);
501<Scan>"--"[^!][^\n]* {
518 yyextra->specialComment=
true;
519 yyextra->blockHeadCol=yyextra->col;
520 yyextra->vhdl =
TRUE;
521 yyextra->nestingCount=0;
523 yyextra->commentStack.push(yyextra->lineNr);
535 yyextra->nestingCount=0;
537 yyextra->specialComment=
true;
538 yyextra->blockHeadCol=yyextra->col;
539 yyextra->commentStack.push(yyextra->lineNr);
544<CComment,CNComment,ReadLine,IncludeFile>{MAILADDR} |
545<CComment,CNComment,ReadLine,IncludeFile>"<"{MAILADDR}">" {
548<CComment,IncludeFile>"{"[ \t]*"@code"/[ \t\n] {
550 yyextra->lastCommentContext = YY_START;
551 yyextra->javaBlock=1;
552 yyextra->blockName=
QCString(
"end")+&yytext[1];
553 yyextra->inVerbatim=
true;
556<CComment,IncludeFile>"{"[ \t]*"@literal"/[ \t\n] {
558 yyextra->lastCommentContext = YY_START;
559 yyextra->javaBlock=1;
560 yyextra->blockName=
QCString(
"end")+&yytext[1];
561 yyextra->inVerbatim=
true;
564<CComment,ReadLine,IncludeFile>"\\ilinebr"[ \t]+("```"[`]*|"~~~"[~]*) {
570 yyextra->lastCommentContext = YY_START;
571 yyextra->javaBlock=0;
573 yyextra->inVerbatim=
true;
QCString stripWhiteSpace() const
returns a copy of this string with leading and trailing whitespace removed
QCString right(size_t len) const
576<CComment,ReadLine,IncludeFile>^[ \t]*("```"[`]*|"~~~"[~]*) {
582 yyextra->lastCommentContext = YY_START;
583 yyextra->javaBlock=0;
585 yyextra->inVerbatim=
true;
QCString left(size_t len) const
588<CComment,ReadLine,IncludeFile>[\\@]("dot"|"code"|"msc"|"startuml")/[^a-z_A-Z0-9] {
590 yyextra->lastCommentContext = YY_START;
591 yyextra->javaBlock=0;
592 if (
qstrcmp(&yytext[1],
"startuml")==0)
594 yyextra->blockName=
"enduml";
598 yyextra->blockName=
QCString(
"end")+&yytext[1];
600 yyextra->inVerbatim=
true;
int qstrcmp(const char *str1, const char *str2)
603<CComment,ReadLine,IncludeFile>[\\@]("f$"|"f["|"f{"|"f(") {
605 yyextra->blockName=&yytext[1];
606 if (yyextra->blockName.at(1)==
'[')
608 yyextra->blockName.at(1)=
']';
610 else if (yyextra->blockName.at(1)==
'{')
612 yyextra->blockName.at(1)=
'}';
614 else if (yyextra->blockName.at(1)==
'(')
616 yyextra->blockName.at(1)=
')';
618 yyextra->lastCommentContext = YY_START;
619 yyextra->inVerbatim=
true;
622<CComment,ReadLine,IncludeFile>"<!--!" {
623 if (yyextra->inVerbatim) REJECT;
625 yyextra->inHtmlDoxygenCommand=
true;
627<CComment,ReadLine,IncludeFile>"-->" {
628 if (yyextra->inHtmlDoxygenCommand)
630 yyextra->inHtmlDoxygenCommand=
false;
637<CComment,ReadLine,IncludeFile>"<!--" {
639 yyextra->blockName=
"-->";
640 yyextra->lastCommentContext = YY_START;
641 yyextra->inVerbatim=
true;
644<CComment,ReadLine,IncludeFile>[\\@]("verbatim"|"iliteral"|"latexonly"|"htmlonly"|"xmlonly"|"docbookonly"|"rtfonly"|"manonly")/[^a-z_A-Z0-9] {
646 yyextra->blockName=
QCString(
"end")+&yytext[1];
647 yyextra->lastCommentContext = YY_START;
648 yyextra->inVerbatim=
true;
660<Verbatim>[\\@]("endverbatim"|"endiliteral"|"endlatexonly"|"endhtmlonly"|"endxmlonly"|"enddocbookonly"|"endrtfonly"|"endmanonly"|"f$"|"f]"|"f}"|"f)") {
662 if (&yytext[1]==yyextra->blockName)
664 yyextra->inVerbatim=
false;
665 BEGIN(yyextra->lastCommentContext);
670 if (yytext==yyextra->blockName)
672 yyextra->inVerbatim=
false;
673 BEGIN(yyextra->lastCommentContext);
677 if (yyextra->javaBlock==0)
683 yyextra->javaBlock++;
688 if (yyextra->javaBlock==0)
694 yyextra->javaBlock--;
695 if (yyextra->javaBlock==0)
698 yyextra->inVerbatim=
false;
699 BEGIN(yyextra->lastCommentContext);
707<VerbatimCode>("```"[`]*|"~~~"[~]*) {
709 if (yytext[0]==yyextra->blockName[0])
711 yyextra->inVerbatim=
false;
712 BEGIN(yyextra->lastCommentContext);
715<VerbatimCode>[\\@]("enddot"|"endcode"|"endmsc"|"enduml")/("{")? {
717 if (&yytext[1]==yyextra->blockName)
719 yyextra->inVerbatim=
false;
720 BEGIN(yyextra->lastCommentContext);
723<VerbatimCode>^[ \t]*{CPPC}[\!\/]? {
724 if (!yyextra->inSpecialComment || yyextra->mlBrief)
731 while (yytext[l]==
' ' || yytext[l]==
'\t')
746<Verbatim,VerbatimCode>[^`~@\/\-\\\n{}]* {
749<Verbatim,VerbatimCode>\n {
751 if (yyextra->lastCommentContext == IncludeFile)
756<Verbatim>^[ \t]*{CPPC}[/!] {
757 if (yyextra->blockName==
"enddot" || yyextra->blockName==
"endmsc" || yyextra->blockName==
"enduml" || yyextra->blockName.at(0)==
'f')
761 while (yytext[l]==
' ' || yytext[l]==
'\t')
773<Verbatim,VerbatimCode>. {
789 BEGIN(yyextra->stringContext);
797<SkipVerbString>[^"\n]+ {
800<SkipVerbString>\"\" {
803<SkipVerbString>"\"" {
805 BEGIN(yyextra->stringContext);
826 BEGIN(yyextra->charContext);
835<CComment,CNComment>[^ `~<\\!@*\n{\"'\/-]* {
838<CComment,CNComment>^{B}*"*"+[^*\/<\\@\n{\"]* {
841 if (yyextra->col>yyextra->blockHeadCol)
844 yyextra->blockHeadCol=yyextra->col;
854 else if (yyextra->pythonDocStringChar != yytext[0])
860 yyextra->nestingCount--;
861 yyextra->pythonDocString =
FALSE;
862 yyextra->pythonDocStringChar =
'\0';
867<CComment,CNComment>\n {
875<CComment,CNComment>"/""/"+/"*/" {
879<CComment,CNComment>"/"+"*" {
885 yyextra->nestingCount++;
886 yyextra->commentStack.push(yyextra->lineNr);
889<CComment,CNComment>^{B}*"*"+"/" |
890<CComment,CNComment>"*"+"/" {
899 yyextra->nestingCount--;
900 if (yyextra->nestingCount<=0)
907 yyextra->commentStack.pop();
912<CComment,CNComment>"\n"/[ \t]*"#" {
921 yyextra->vhdl =
FALSE;
931<CComment,CNComment>"\n"/[ \t]*"-" {
942<CComment,CNComment>"\n"/[ \t]*[^ \t#\-] {
945 if (yyextra->pythonDocString)
959 yyextra->vhdl =
FALSE;
985<CComment,CNComment>{CMD}{CMD} |
986<CComment,CNComment>. {
989<SComment>^[ \t]*{CPPC}"/"{SLASHopt}/\n {
992<SComment>\n[ \t]*{CPPC}"/"{SLASHopt}/\n {
995<SComment>^[ \t]*{CPPC}"/"[^\/\n]/.*\n {
997 yyextra->readLineCtx=YY_START;
1000<SComment>\n[ \t]*{CPPC}[\/!]("<")?[ \t]*[\\@]"}".*\n {
1004 yyextra->inSpecialComment=
false;
1005 yyextra->inRoseComment=
false;
1008<SComment>\n[ \t]*{CPPC}"/"[^\\@\/\n]/.*\n {
1010 yyextra->readLineCtx=YY_START;
1013<SComment>^[ \t]*{CPPC}"!" |
1014<SComment>^[ \t]*{CPPC}"!<"/.*\n |
1015<SComment>^[ \t]*{CPPC}"!"[^<]/.*\n {
1017 yyextra->readLineCtx=YY_START;
1020<SComment>\n[ \t]*{CPPC}"!" |
1021<SComment>\n[ \t]*{CPPC}"!<"/.*\n |
1022<SComment>\n[ \t]*{CPPC}"!"[^<\n]/.*\n {
1024 yyextra->readLineCtx=YY_START;
1027<SComment>^[ \t]*{CPPC}"##"/.*\n {
1028 if (!yyextra->inRoseComment)
1035 yyextra->readLineCtx=YY_START;
1039<SComment>\n[ \t]*{CPPC}"##"/.*\n {
1040 if (!yyextra->inRoseComment)
1047 yyextra->readLineCtx=YY_START;
1054 yyextra->inSpecialComment=
FALSE;
1055 yyextra->inRoseComment=
FALSE;
1056 yyextra->insertCppCommentMarker=
false;
1057 yyextra->readLineCtx = Scan;
1067<ReadLine,CopyLine>"*" {
1070<ReadLine,CopyLine>{RL} {
1073<ReadLine,CopyLine>{RL}/{B}"\\ilinebr"{B} {
1076<ReadLine,CopyLine>{RLopt}/\n {
1078 yyextra->insertCppCommentMarker=
false;
1079 BEGIN(yyextra->readLineCtx);
1081<CComment,CNComment,ReadLine>"\<" {
1084<CComment,CNComment,ReadLine>[\\@][\\@][~a-z_A-Z][a-z_A-Z0-9]*[ \t]* {
1088<CComment,ReadLine,IncludeFile>[\\@]("include"{OPTS}|"includedoc"{OPTS}*) {
1089 if (!
parseIncludeOptions(yyscanner,std::string_view{yytext,
static_cast<size_t>(yyleng)})) REJECT;
1090 yyextra->includeCtx = YY_START;
1091 yyextra->firstIncludeLine =
true;
1092 yyextra->insertCommentCol = yyextra->col;
1093 if (!yyextra->insertCppCommentMarker && (yyextra->includeCtx==ReadLine || yyextra->includeCtx==IncludeFile))
1095 yyextra->insertCppCommentMarker = yyextra->mlBrief;
1100<CComment,ReadLine,IncludeFile>[\\@]("snippet"{OPTS}|"snippetdoc"{OPTS}*) {
1101 if (!
parseIncludeOptions(yyscanner,std::string_view{yytext,
static_cast<size_t>(yyleng)})) REJECT;
1102 yyextra->includeCtx = YY_START;
1103 yyextra->firstIncludeLine =
true;
1104 yyextra->insertCommentCol = yyextra->col;
1105 if (!yyextra->insertCppCommentMarker && (yyextra->includeCtx==ReadLine || yyextra->includeCtx==IncludeFile))
1107 yyextra->insertCppCommentMarker = yyextra->mlBrief;
1112<IncludeDoc,SnippetDoc>{B}*
1113<IncludeDoc>{FILEMASK}|"\""[^\n\"]+"\"" {
1117 fileName=fileName.
mid(1,fileName.
length()-2);
1125 BEGIN(yyextra->includeCtx);
size_t length() const
Returns the length of the string, not counting the 0-terminator.
QCString mid(size_t index, size_t len=static_cast< size_t >(-1)) const
1128<SnippetDoc>({FILEMASK}|"\""[^\n\"]+"\""){B}+ {
1129 yyextra->snippetFileName=yytext;
1130 yyextra->snippetFileName=yyextra->snippetFileName.stripWhiteSpace();
1131 if (yyextra->snippetFileName ==
"this") yyextra->snippetFileName=yyextra->fileName;
1132 yyextra->snippetName =
"";
1133 BEGIN(SnippetDocTag);
1135<SnippetDocTag>[^\\\n]+ {
1136 yyextra->snippetName += yytext;
1138<SnippetDocTag>"\\" {
1139 yyextra->snippetName += yytext;
1141<SnippetDocTag>(\n|"\\ilinebr") {
1142 for (
int i=(
int)yyleng-1;i>=0;i--) unput(yytext[i]);
1143 yyextra->snippetName = yyextra->snippetName.stripWhiteSpace();
1144 QCString blockId =
"["+yyextra->snippetName+
"]";
1151 BEGIN(yyextra->includeCtx);
1155<IncludeDoc,SnippetDoc>\n {
1160 BEGIN(yyextra->includeCtx);
1162<IncludeDoc,SnippetDoc>. {
1164 BEGIN(yyextra->includeCtx);
1166<CComment,ReadLine,IncludeFile>[\\@]"cond"/[^a-z_A-Z0-9] {
1167 yyextra->condCtx = YY_START;
1170<CComment,ReadLine,IncludeFile>[\\@]"endcond"/[^a-z_A-Z0-9] {
1171 bool oldSkip=yyextra->skip;
1173 if (YY_START==CComment && oldSkip && !yyextra->skip)
1181 yyextra->outBuf+=
'/';
1182 yyextra->outBuf+=
'*';
1184 if (yyextra->specialComment)
1186 yyextra->outBuf+=
'*';
1192<CondLine>[!()&| \ta-z_A-Z0-9.\-]+ {
1195<CComment,ReadLine,IncludeFile>[\\@]"cond"{WSopt}/\n {
1196 yyextra->condCtx=YY_START;
1204<CComment,ReadLine,IncludeFile,Verbatim,VerbatimCode>[\\@][a-z_A-Z][a-z_A-Z0-9-]* {
1205 replaceAliases(yyscanner,yytext,YY_START==ReadLine && yyextra->readLineCtx==SComment);
1207<CComment,ReadLine,IncludeFile,Verbatim,VerbatimCode>{B}?"\\ilinebr"{B}[\\@]"ialias{" {
1208 yyextra->lastBlockContext=YY_START;
1209 yyextra->blockCount=1;
1210 int extraSpace = (yytext[0]==
' '? 1:0);
1211 yyextra->aliasString=yytext+9+extraSpace;
1212 yyextra->aliasCmd=yytext+9+extraSpace;
1213 yyextra->lastEscaped=0;
1214 BEGIN( ReadAliasArgs );
1216<CComment,ReadLine,IncludeFile,Verbatim,VerbatimCode>[\\@][a-z_A-Z][a-z_A-Z0-9-]*"{" {
1217 yyextra->lastBlockContext=YY_START;
1218 yyextra->blockCount=1;
1219 yyextra->aliasString=yytext;
1220 yyextra->aliasCmd=yytext;
1221 yyextra->lastEscaped=0;
1222 BEGIN( ReadAliasArgs );
1224<ReadAliasArgs>^[ \t]*"*" {
1226<ReadAliasArgs>^[ \t]*{CPPC}[/!]/[^\n]* {
1228<ReadAliasArgs>[^{}\n\\\*]+ {
1229 yyextra->aliasString+=yytext;
1230 yyextra->lastEscaped=
FALSE;
1232<ReadAliasArgs>"\\" {
1233 if (yyextra->lastEscaped) yyextra->lastEscaped=
FALSE;
1234 else yyextra->lastEscaped=
TRUE;
1235 yyextra->aliasString+=yytext;
1237<ReadAliasArgs>[\\@]("endverbatim"|"endiliteral"|"endlatexonly"|"endhtmlonly"|"endxmlonly"|"enddocbookonly"|"endrtfonly"|"endmanonly"|"f$"|"f]"|"f}"|"f)") {
1238 yyextra->aliasString+=yytext;
1239 if (yyextra->inVerbatim && &yytext[1]==yyextra->blockName)
1248 yyextra->inVerbatim=
false;
1249 BEGIN(yyextra->lastCommentContext);
1253 yyextra->aliasString+=yytext;
1254 yyextra->lastEscaped=
FALSE;
1255 if (yyextra->inVerbatim)
1259 BEGIN( yyextra->lastBlockContext );
1263 yyextra->aliasString+=yytext;
1264 if (!yyextra->lastEscaped) yyextra->blockCount++;
1265 yyextra->lastEscaped=
FALSE;
1268 yyextra->aliasString+=yytext;
1269 if (!yyextra->lastEscaped) yyextra->blockCount--;
1270 if (yyextra->blockCount==0)
1273 yyextra->lastBlockContext==ReadLine && yyextra->readLineCtx==SComment);
1274 BEGIN( yyextra->lastBlockContext );
1276 yyextra->lastEscaped=
FALSE;
1279 yyextra->aliasString+=yytext;
1280 yyextra->lastEscaped=
FALSE;
1287 yyextra->insertCppCommentMarker=
false;
1288 BEGIN(yyextra->readLineCtx);
1296<ReadLine>{CMD}{CMD} |
1311 if (YY_START == ReadAliasArgs)
1313 warn(yyextra->fileName,yyextra->lineNr,
1314 "Reached end of file while still searching closing '}}' of an alias argument (probable start: '{}')",
1317 if (yyextra->includeStack.empty())
1319 yyextra->insertCppCommentMarker=
false;
1324 std::unique_ptr<commentcnv_FileState> &fs = yyextra->includeStack.back();
1325 YY_BUFFER_STATE oldBuf = YY_CURRENT_BUFFER;
1326 yy_switch_to_buffer(fs->bufState, yyscanner);
1327 yy_delete_buffer(oldBuf, yyscanner);
1328 BEGIN(fs->oldState);
1329 yyextra->fileName = fs->oldFileName;
1330 yyextra->lineNr = fs->oldLineNr;
1331 yyextra->inBuf = fs->oldFileBuf;
1332 yyextra->inBufPos = fs->oldFileBufPos;
1333 yyextra->includeCtx = fs->oldIncludeCtx;
1335 if (fs->oldRaiseLvl!=yyextra->raiseLevel)
1337 lineStr+=
"\\iraise " + std::to_string(fs->oldRaiseLvl)+
" ";
1339 if (fs->oldRaiseLbl!=yyextra->raiseLabel)
1341 lineStr+=
"\\iprefix \"" + fs->oldRaiseLbl +
"\" ";
1343 lineStr+=
"\\ilinebr ";
1344 yyextra->raiseLevel = fs->oldRaiseLvl;
1345 yyextra->raiseLabel = fs->oldRaiseLbl;
1347 yyextra->includeStack.pop_back();
QCString & setNum(short n)
std::string_view view() const
#define warn(file, line, fmt,...)
1359 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
1362 size_t optIdxStart = s.find(
'{');
1363 size_t optIdxEnd = optIdxStart!=std::string::npos ? s.find(
"}",optIdxStart+1) : std::string::npos;
1364 std::string cmdName;
1366 if (optIdxStart == std::string::npos)
1373 optList =
split(std::string{s.substr(optIdxStart+1,optIdxEnd-optIdxStart-1)},
",");
1375 bool isDoc = cmdName==
"includedoc" || cmdName==
"snippetdoc";
1376 for (
const auto &opt : optList)
1387 for (
const auto &opt : optList)
1390 size_t posEqual = locOpt.find(
'=');
1391 std::string_view option = posEqual!=std::string::npos ?
stripWhiteSpace(locOpt.substr(0,posEqual)) : locOpt;
1392 std::string_view value = posEqual!=std::string::npos ?
stripWhiteSpace(locOpt.substr(posEqual+1)) : std::string_view();
1394 if (option==std::string_view{
"doc"} && value.empty())
1397 else if (option==std::string_view{
"raise"} && !value.empty())
1399 yyextra->raiseIncrement = atoi(value.data());
1402 warn(yyextra->fileName,yyextra->lineNr,
"Raising section level from {} to {}, exceeds allowed range [0-{}], adjusting",
1407 else if (option==std::string_view{
"prefix"} && !value.empty())
1409 yyextra->raisePrefix = value;
1413 warn(yyextra->fileName,yyextra->lineNr,
"Unsupported option '{}' for {} command",option, cmdName);
1424 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
1425 if (s.empty())
return;
1427 size_t len = s.length();
1430 while (p<len && (c=s[p]) && (c==
' ' || c==
'\t' || c==
'\n'))
1433 if (c==
'\n') { yyextra->lineNr++; yyextra->col=0; }
else { yyextra->col++; }
1438 while (p<len && (c=s[p]) && (c==
'/' || c==
'!' || c==
'#'))
1442 if (p<len && s[p]==
'<')
1456 yyextra->outBuf+=
' ';
1460 if (blanks>1) { yyextra->outBuf+=
'*'; yyextra->col++; }
1461 yyextra->outBuf+=
' ';
1465 yyextra->outBuf+=s.substr(p);
1466 yyextra->col+=s.substr(p).length();
1478 else if (c==
'\t') col+=tabSize-(col%tabSize);
1487 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
1488 size_t len = s.length();
1491 for (
size_t i=0;i<len;i++)
1496 yyextra->outBuf+=
'\n';
1501 yyextra->col+=tabSize-(yyextra->col%tabSize);
1512 for (
size_t i=0;i<len;i++)
1516 case '\n': yyextra->col=0;
1518 yyextra->lineNr++;
break;
1519 case '\t': yyextra->col+=tabSize-(yyextra->col%tabSize);
break;
1520 default: yyextra->col++;
break;
1528 copyToOutput(yyscanner,std::string_view{s,(size_t)len});
1533 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
1534 while (!yyextra->commentStack.empty()) yyextra->commentStack.pop();
1539 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
1542 bool expResult = prs.
parse(yyextra->fileName,yyextra->lineNr,sectId);
1543 yyextra->condStack.emplace(yyextra->lineNr,sectId,yyextra->skip);
1552 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
1553 if (yyextra->condStack.empty())
1555 warn(yyextra->fileName,yyextra->lineNr,
"Found \\endcond command without matching \\cond");
1556 yyextra->skip=
FALSE;
1562 yyextra->condStack.pop();
1569 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
1570 bool oldSkip=yyextra->skip;
1572 if ((yyextra->condCtx==CComment || yyextra->readLineCtx==SComment) &&
1573 !oldSkip && yyextra->skip)
1580 yyextra->outBuf+=
'*';
1581 yyextra->outBuf+=
'/';
1585 if (yyextra->readLineCtx==SComment)
1591 BEGIN(yyextra->condCtx);
1606 int m1 = text.
find(marker);
1607 if (m1==-1)
return result;
1608 int m2 = text.
find(marker,m1+
static_cast<int>(marker.
length()));
1609 if (m2==-1)
return result;
1613 while (!
found && (i=text.
find(
'\n',p))!=-1)
1615 found = (p<=m1 && m1<i);
1623 while ((i=text.
find(
'\n',p))!=-1)
1643 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
1644 int startCol=yyextra->blockHeadCol;
1645 int contentCol=yyextra->insertCommentCol;
1646 int markerSpace=contentCol-startCol;
1652 if (yyextra->pythonDocString)
1669 else if (yyextra->insertCppCommentMarker)
1684 for (;i<startCol;i++)
1688 if (
static_cast<int>(marker.length())<=markerSpace && !yyextra->firstIncludeLine)
1693 for (;i<contentCol;i++)
1697 yyextra->firstIncludeLine =
false;
1703 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
1711 warn_doc_error(yyextra->fileName,yyextra->lineNr,
"included file name '{}' is ambiguous"
1714 bool alreadyProcessed = std::any_of(
1715 yyextra->includeStack.begin(),
1716 yyextra->includeStack.end(),
1717 [&absFileName,&blockId](
const auto &lfs)
1718 { return lfs->fileName==absFileName && lfs->blockId==blockId; }
1721 if (alreadyProcessed)
1725 warn_doc_error(yyextra->fileName,yyextra->lineNr,
"recursive usage of '\\snippet{{doc}}' block with name '{}' and file name '{}', skipping",
1726 blockId,absFileName);
1730 warn_doc_error(yyextra->fileName,yyextra->lineNr,
"recursive usage of '\\include{{doc}}' with file name '{}', skipping", absFileName);
1735 auto fs = std::make_unique<commentcnv_FileState>();
1738 warn_doc_error(yyextra->fileName,yyextra->lineNr,
"\\{}{{doc}} file '{}' could not be read",blockId.
isEmpty()?
"include":
"snippet",absFileName);
1749 warn_doc_error(yyextra->fileName,yyextra->lineNr,
"block marked with [{}] for \\snippet{{doc}} should appear twice in file {}, found it {:d} times, skipping",
1750 blockId,absFileName,count);
1756 fs->fileBuf.clear();
1757 if (!incText.isEmpty())
1759 fs->fileBuf.append(incText.str());
1762 int oldRaiseLevel = yyextra->raiseLevel;
1763 QCString oldRaiseLabel = yyextra->raiseLabel;
1764 yyextra->raiseLevel+=yyextra->raiseIncrement;
1765 yyextra->raiseLabel+=yyextra->raisePrefix;
1766 QCString lineStr=
" \\ifile \""+absFileName+
"\" \\iline " + std::to_string(lineNr)+
" ";
1767 if (yyextra->raiseLevel>0)
1769 lineStr+=
"\\iraise " + std::to_string(yyextra->raiseLevel)+
" ";
1771 if (!yyextra->raiseLabel.isEmpty())
1773 lineStr+=
"\\iprefix \"" + yyextra->raiseLabel +
"\" ";
1775 lineStr+=
"\\ilinebr ";
1778 fs->fileName = absFileName;
1779 fs->bufState = YY_CURRENT_BUFFER;
1780 fs->oldLineNr = yyextra->lineNr;
1781 fs->oldFileName = yyextra->fileName;
1782 fs->oldState = yyextra->includeCtx;
1783 fs->oldFileBuf = yyextra->inBuf;
1784 fs->oldFileBufPos = yyextra->inBufPos;
1785 fs->oldIncludeCtx = yyextra->includeCtx;
1786 fs->oldRaiseLvl = oldRaiseLevel;
1787 fs->oldRaiseLbl = oldRaiseLabel;
1788 fs->blockId = blockId;
1789 yy_switch_to_buffer(yy_create_buffer(
nullptr,
YY_BUF_SIZE, yyscanner),yyscanner);
1790 yyextra->fileName = absFileName;
1791 yyextra->lineNr = lineNr;
1792 yyextra->inBuf = &fs->fileBuf;
1793 yyextra->inBufPos = 0;
1794 yyextra->includeStack.push_back(std::move(fs));
1800 warn_doc_error(yyextra->fileName,yyextra->lineNr,
"\\{}{{doc}} file '{}' not found",blockId.
isEmpty()?
"include":
"snippet",inc);
1811 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
1812 if (s.empty())
return;
1813 size_t pos = s.find(
'{');
1814 std::string cmd { s.substr(1, pos!=std::string::npos ? pos-1 : s.length()-1) };
1815 auto &expAlias = yyextra->expandedAliases;
1816 if (std::find(expAlias.begin(),expAlias.end(),cmd)!=std::end(expAlias))
1821 else if (cmd==
"ialias")
1823 if (s.length()>cmd.length()+3)
1825 std::string value { s.substr(cmd.length()+2,s.length()-cmd.length()-3) };
1827 expAlias.erase(std::remove(expAlias.begin(),expAlias.end(),value),expAlias.end());
1832 if (yyextra->inVerbatim)
1835 std::string blk = yyextra->blockName.str();
1836 assert(!blk.empty());
1837 bool isNamedCommand=
isId(blk[0]);
1840 while ((i=result.find(blk,p))!=std::string::npos && !
found)
1842 found = !isNamedCommand ||
1843 (i>0 && (result[i-1]==
'\\' || result[i-1]==
'@') && !
isId(result[i+blk.length()]));
1844 p = i+yyextra->blockName.length();
1862 expAlias.push_back(cmd);
1864 result +=
" \\ilinebr \\ialias{";
1867 for (
int i=(
int)result.length()-1; i>=0; i--)
1881 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
1882 int bytesInBuf =
static_cast<int>(yyextra->inBuf->size())-yyextra->inBufPos;
1883 int bytesToCopy = std::min(max_size,bytesInBuf);
1884 memcpy(buf,yyextra->inBuf->data()+yyextra->inBufPos,bytesToCopy);
1885 yyextra->inBufPos+=bytesToCopy;
1891 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
1892 if (yyextra->mlBrief || yyextra->skip)
1900 if (i==yyextra->blockHeadCol || i+1==yyextra->blockHeadCol)
1907 for (i=(
int)yyleng-1;i>=0;i--) unput(yytext[i]);
1908 yyextra->inSpecialComment=
FALSE;
1925 commentcnvYYlex_init_extra(&extra,&yyscanner);
1929 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
1931 yyextra->inBufPos = 0;
1934 yyextra->skip =
FALSE;
1935 yyextra->fileName = fileName;
1937 yyextra->pythonDocString =
FALSE;
1938 yyextra->lineNr = 1;
1939 yyextra->raiseLevel = 0;
1940 yyextra->raiseLabel =
"";
1941 yyextra->raiseIncrement = 0;
1942 yyextra->raisePrefix =
"";
1943 yyextra->insertCppCommentMarker=
false;
1944 yyextra->expandedAliases.clear();
1945 while (!yyextra->condStack.empty()) yyextra->condStack.pop();
1947 yyextra->vhdl =
FALSE;
1950 yyextra->isFixedForm =
FALSE;
1959 yyextra->nestingCount=0;
1961 yyextra->commentStack.push(yyextra->lineNr);
1968 while (!yyextra->condStack.empty())
1973 warn(yyextra->fileName,ctx.
lineNr,
"Conditional section{}does not have "
1974 "a corresponding \\endcond command within this file.",sectionInfo.
data());
1975 yyextra->condStack.pop();
1981 while (!yyextra->commentStack.empty())
1983 int lineNr = yyextra->commentStack.top();
1984 if (!first) lines +=
", ";
1987 yyextra->commentStack.pop();
1989 warn(yyextra->fileName,yyextra->lineNr,
"Reached end of file while still inside a (nested) comment. "
1990 "Nesting level {} (possible line reference(s): {})",yyextra->nestingCount,lines);
1992 yyextra->nestingCount = 0;
1996 "output=[\n{}]\n-----------\n",fileName,yyextra->outBuf
1999 commentcnvYYlex_destroy(yyscanner);
2005#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
bool isEmpty() const
Returns TRUE iff the string is empty.
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...
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...
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)