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}[!/][ \t]*{CMD}"}" {
393 yyextra->inSpecialComment=
true;
394 yyextra->blockHeadCol=yyextra->col+1;
395 yyextra->insertCppCommentMarker=
true;
397 yyextra->readLineCtx=YY_START;
400<Scan>{CPPC}"!"/.*\n[ \t]*{CPPC}[\/!][^\/] |
401<Scan>({CPPC}"/"[/]*)/[^/].*\n[ \t]*{CPPC}[\/!][^\/] {
402 if (yyextra->mlBrief)
411 while (i<(
int)yyleng && yytext[i]==
'/') i++;
413 yyextra->blockHeadCol=yyextra->col+1;
414 if (yytext[2] ==
'!')
423 yyextra->inSpecialComment=
TRUE;
425 yyextra->readLineCtx=SComment;
429<Scan>{CPPC}"##Documentation"{ANYopt}/\n {
430 if (yyextra->mlBrief) REJECT;
432 yyextra->blockHeadCol=yyextra->col+1;
435 yyextra->inRoseComment=
TRUE;
438<Scan>{CPPC}[!\/]/.*\n[ \t]*{CPPC}[|\/][ \t]*{CMD}"}" {
439 yyextra->inSpecialComment=yytext[2]==
'/' || yytext[2]==
'!';
440 if (yyextra->inSpecialComment)
442 yyextra->blockHeadCol=yyextra->col+1;
445 yyextra->readLineCtx=YY_START;
448<Scan>{CPPC}[!/]/.*\n {
449 yyextra->inSpecialComment=
true;
450 yyextra->blockHeadCol=yyextra->col+1;
451 yyextra->insertCppCommentMarker=
true;
453 yyextra->readLineCtx=YY_START;
457 yyextra->inSpecialComment=
false;
459 yyextra->readLineCtx=YY_START;
466 if (yyextra->lang==SrcLangExt::Python)
470 yyextra->specialComment=(int)yyleng==3;
471 yyextra->nestingCount=1;
474 if (yyextra->specialComment)
476 yyextra->blockHeadCol=0;
483 yyextra->commentStack.push(yyextra->lineNr);
486 if (yyextra->lang!=SrcLangExt::PHP)
493 if (yyextra->lang!=SrcLangExt::Python)
499 yyextra->nestingCount=0;
501 yyextra->specialComment=(int)yyleng==2;
502 if (yyextra->specialComment)
504 yyextra->blockHeadCol=yyextra->col;
506 yyextra->commentStack.push(yyextra->lineNr);
511<Scan>"--"[^!][^\n]* {
512 if (yyextra->lang!=SrcLangExt::VHDL)
522 if (yyextra->lang!=SrcLangExt::VHDL)
528 yyextra->specialComment=
true;
529 yyextra->blockHeadCol=yyextra->col;
530 yyextra->vhdl =
TRUE;
531 yyextra->nestingCount=0;
533 yyextra->commentStack.push(yyextra->lineNr);
539 if (yyextra->lang!=SrcLangExt::Fortran)
545 yyextra->nestingCount=0;
547 yyextra->specialComment=
true;
548 yyextra->blockHeadCol=yyextra->col;
549 yyextra->commentStack.push(yyextra->lineNr);
554<CComment,CNComment,ReadLine,IncludeFile>{MAILADDR} |
555<CComment,CNComment,ReadLine,IncludeFile>"<"{MAILADDR}">" {
558<CComment,IncludeFile>"{"[ \t]*"@code"/[ \t\n] {
560 yyextra->lastCommentContext = YY_START;
561 yyextra->javaBlock=1;
562 yyextra->blockName=
QCString(
"end")+&yytext[1];
563 yyextra->inVerbatim=
true;
566<CComment,IncludeFile>"{"[ \t]*"@literal"/[ \t\n] {
568 yyextra->lastCommentContext = YY_START;
569 yyextra->javaBlock=1;
570 yyextra->blockName=
QCString(
"end")+&yytext[1];
571 yyextra->inVerbatim=
true;
574<CComment,ReadLine,IncludeFile>{CMD}"ilinebr"[ \t]+("```"[`]*|"~~~"[~]*) {
580 yyextra->lastCommentContext = YY_START;
581 yyextra->javaBlock=0;
583 yyextra->inVerbatim=
true;
QCString stripWhiteSpace() const
returns a copy of this string with leading and trailing whitespace removed
QCString right(size_t len) const
586<CComment,ReadLine,IncludeFile>^[ \t]*("```"[`]*|"~~~"[~]*) {
592 yyextra->lastCommentContext = YY_START;
593 yyextra->javaBlock=0;
595 yyextra->inVerbatim=
true;
QCString left(size_t len) const
598<CComment,ReadLine,IncludeFile>{CMD}("dot"|"code"|"msc"|"startuml")/[^a-z_A-Z0-9] {
600 yyextra->lastCommentContext = YY_START;
601 yyextra->javaBlock=0;
602 if (
qstrcmp(&yytext[1],
"startuml")==0)
604 yyextra->blockName=
"enduml";
608 yyextra->blockName=
QCString(
"end")+&yytext[1];
610 yyextra->inVerbatim=
true;
int qstrcmp(const char *str1, const char *str2)
613<CComment,ReadLine,IncludeFile>{CMD}("f$"|"f["|"f{"|"f(") {
615 yyextra->blockName=&yytext[1];
616 if (yyextra->blockName.at(1)==
'[')
618 yyextra->blockName.at(1)=
']';
620 else if (yyextra->blockName.at(1)==
'{')
622 yyextra->blockName.at(1)=
'}';
624 else if (yyextra->blockName.at(1)==
'(')
626 yyextra->blockName.at(1)=
')';
628 yyextra->lastCommentContext = YY_START;
629 yyextra->inVerbatim=
true;
632<CComment,ReadLine,IncludeFile>"<!--!" {
633 if (yyextra->inVerbatim) REJECT;
635 yyextra->inHtmlDoxygenCommand=
true;
637<CComment,ReadLine,IncludeFile>"-->" {
638 if (yyextra->inHtmlDoxygenCommand)
640 yyextra->inHtmlDoxygenCommand=
false;
647<CComment,ReadLine,IncludeFile>"<!--" {
649 yyextra->blockName=
"-->";
650 yyextra->lastCommentContext = YY_START;
651 yyextra->inVerbatim=
true;
654<CComment,ReadLine,IncludeFile>{CMD}("verbatim"|"iliteral"|"latexonly"|"htmlonly"|"xmlonly"|"docbookonly"|"rtfonly"|"manonly")/[^a-z_A-Z0-9] {
656 yyextra->blockName=
QCString(
"end")+&yytext[1];
657 yyextra->lastCommentContext = YY_START;
658 yyextra->inVerbatim=
true;
670<Verbatim>{CMD}("endverbatim"|"endiliteral"|"endlatexonly"|"endhtmlonly"|"endxmlonly"|"enddocbookonly"|"endrtfonly"|"endmanonly"|"f$"|"f]"|"f}"|"f)") {
672 if (&yytext[1]==yyextra->blockName)
674 yyextra->inVerbatim=
false;
675 BEGIN(yyextra->lastCommentContext);
680 if (yytext==yyextra->blockName)
682 yyextra->inVerbatim=
false;
683 BEGIN(yyextra->lastCommentContext);
687 if (yyextra->javaBlock==0)
693 yyextra->javaBlock++;
698 if (yyextra->javaBlock==0)
704 yyextra->javaBlock--;
705 if (yyextra->javaBlock==0)
708 yyextra->inVerbatim=
false;
709 BEGIN(yyextra->lastCommentContext);
717<VerbatimCode>("```"[`]*|"~~~"[~]*) {
719 if (yytext[0]==yyextra->blockName[0])
721 yyextra->inVerbatim=
false;
722 BEGIN(yyextra->lastCommentContext);
725<VerbatimCode>{CMD}("enddot"|"endcode"|"endmsc"|"enduml")/("{")? {
727 if (&yytext[1]==yyextra->blockName)
729 yyextra->inVerbatim=
false;
730 BEGIN(yyextra->lastCommentContext);
733<VerbatimCode>^[ \t]*{CPPC}[\!\/]? {
734 if (!yyextra->inSpecialComment || yyextra->mlBrief)
741 while (yytext[l]==
' ' || yytext[l]==
'\t')
756<Verbatim,VerbatimCode>[^`~@\/\-\\\n{}]* {
759<Verbatim,VerbatimCode>\n {
761 if (yyextra->lastCommentContext == IncludeFile)
766<Verbatim>^[ \t]*{CPPC}[/!] {
767 if (yyextra->blockName==
"enddot" || yyextra->blockName==
"endmsc" || yyextra->blockName==
"enduml" || yyextra->blockName.at(0)==
'f')
771 while (yytext[l]==
' ' || yytext[l]==
'\t')
783<Verbatim,VerbatimCode>. {
787 if (yyextra->lang==SrcLangExt::Fortran || yyextra->lang==SrcLangExt::VHDL)
799 BEGIN(yyextra->stringContext);
807<SkipVerbString>[^"\n]+ {
810<SkipVerbString>\"\" {
813<SkipVerbString>"\"" {
815 BEGIN(yyextra->stringContext);
824 if (yyextra->lang==SrcLangExt::Fortran || yyextra->lang==SrcLangExt::VHDL)
836 BEGIN(yyextra->charContext);
845<CComment,CNComment>[^ `~<\\!@*\n{\"'\/-]* {
848<CComment,CNComment>^{B}*"*"+[^*\/<\\@\n{\"]* {
849 if (yyextra->lang==SrcLangExt::Markdown) REJECT;
851 if (yyextra->col>yyextra->blockHeadCol)
854 yyextra->blockHeadCol=yyextra->col;
860 if (yyextra->lang!=SrcLangExt::Python)
864 else if (yyextra->pythonDocStringChar != yytext[0])
870 yyextra->nestingCount--;
871 yyextra->pythonDocString =
FALSE;
872 yyextra->pythonDocStringChar =
'\0';
877<CComment,CNComment>\n {
880 if (yyextra->lang==SrcLangExt::Fortran)
885<CComment,CNComment>"/""/"+/"*/" {
889<CComment,CNComment>"/"+"*" {
890 if (yyextra->lang==SrcLangExt::Python ||
891 yyextra->lang==SrcLangExt::Markdown)
895 yyextra->nestingCount++;
896 yyextra->commentStack.push(yyextra->lineNr);
899<CComment,CNComment>^{B}*"*"+"/" |
900<CComment,CNComment>"*"+"/" {
901 if (yyextra->lang==SrcLangExt::Python ||
902 yyextra->lang==SrcLangExt::Markdown)
909 yyextra->nestingCount--;
910 if (yyextra->nestingCount<=0)
917 yyextra->commentStack.pop();
922<CComment,CNComment>"\n"/[ \t]*"#" {
923 if (yyextra->lang!=SrcLangExt::VHDL)
931 yyextra->vhdl =
FALSE;
941<CComment,CNComment>"\n"/[ \t]*"-" {
942 if (yyextra->lang!=SrcLangExt::Python || yyextra->pythonDocString)
952<CComment,CNComment>"\n"/[ \t]*[^ \t#\-] {
953 if (yyextra->lang==SrcLangExt::Python)
955 if (yyextra->pythonDocString)
965 else if (yyextra->lang==SrcLangExt::VHDL)
969 yyextra->vhdl =
FALSE;
995<CComment,CNComment>{CMD}"~"[a-z_A-Z-]* {
996 if (yyextra->lang!=SrcLangExt::Markdown) REJECT;
1003 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...
1009<CComment,CNComment>{CMD}{CMD} |
1010<CComment,CNComment>. {
1013<SkipLang>{CMD}"~"[a-zA-Z-]* {
1017 warn(yyextra->fileName,yyextra->lineNr,
1026<SkipLang>[^*@\\\n]* {
1033<SComment>^[ \t]*{CPPC}"/"{SLASHopt}/\n {
1036<SComment>\n[ \t]*{CPPC}"/"{SLASHopt}/\n {
1039<SComment>^[ \t]*{CPPC}"/"[^\/\n]/.*\n {
1041 yyextra->readLineCtx=YY_START;
1044<SComment>\n[ \t]*{CPPC}[\/!]("<")?[ \t]*{CMD}"}".*\n {
1048 yyextra->inSpecialComment=
false;
1049 yyextra->inRoseComment=
false;
1052<SComment>\n[ \t]*{CPPC}"/"[^\\@\/\n]/.*\n {
1054 yyextra->readLineCtx=YY_START;
1057<SComment>^[ \t]*{CPPC}"!" |
1058<SComment>^[ \t]*{CPPC}"!<"/.*\n |
1059<SComment>^[ \t]*{CPPC}"!"[^<]/.*\n {
1061 yyextra->readLineCtx=YY_START;
1064<SComment>\n[ \t]*{CPPC}"!" |
1065<SComment>\n[ \t]*{CPPC}"!<"/.*\n |
1066<SComment>\n[ \t]*{CPPC}"!"[^<\n]/.*\n {
1068 yyextra->readLineCtx=YY_START;
1071<SComment>^[ \t]*{CPPC}"##"/.*\n {
1072 if (!yyextra->inRoseComment)
1079 yyextra->readLineCtx=YY_START;
1083<SComment>\n[ \t]*{CPPC}"##"/.*\n {
1084 if (!yyextra->inRoseComment)
1091 yyextra->readLineCtx=YY_START;
1098 yyextra->inSpecialComment=
FALSE;
1099 yyextra->inRoseComment=
FALSE;
1100 yyextra->insertCppCommentMarker=
false;
1101 yyextra->readLineCtx = Scan;
1111<ReadLine,CopyLine>"*" {
1114<ReadLine,CopyLine>{RL} {
1117<ReadLine,CopyLine>{RL}/{B}{CMD}"ilinebr"{B} {
1120<ReadLine,CopyLine>{RLopt}/\n {
1122 yyextra->insertCppCommentMarker=
false;
1123 BEGIN(yyextra->readLineCtx);
1125<CComment,CNComment,ReadLine>"\<" {
1128<CComment,CNComment,ReadLine>{CMD}{CMD}[~a-z_A-Z][a-z_A-Z0-9]*[ \t]* {
1132<CComment,ReadLine,IncludeFile>{CMD}("include"{OPTS}|"includedoc"{OPTS}*) {
1133 if (!
parseIncludeOptions(yyscanner,std::string_view{yytext,
static_cast<size_t>(yyleng)})) REJECT;
1134 yyextra->includeCtx = YY_START;
1135 yyextra->firstIncludeLine =
true;
1136 yyextra->insertCommentCol = yyextra->col;
1137 if (!yyextra->insertCppCommentMarker && (yyextra->includeCtx==ReadLine || yyextra->includeCtx==IncludeFile))
1139 yyextra->insertCppCommentMarker = yyextra->mlBrief;
1144<CComment,ReadLine,IncludeFile>{CMD}("snippet"{OPTS}|"snippetdoc"{OPTS}*) {
1145 if (!
parseIncludeOptions(yyscanner,std::string_view{yytext,
static_cast<size_t>(yyleng)})) REJECT;
1146 yyextra->includeCtx = YY_START;
1147 yyextra->firstIncludeLine =
true;
1148 yyextra->insertCommentCol = yyextra->col;
1149 if (!yyextra->insertCppCommentMarker && (yyextra->includeCtx==ReadLine || yyextra->includeCtx==IncludeFile))
1151 yyextra->insertCppCommentMarker = yyextra->mlBrief;
1156<IncludeDoc,SnippetDoc>{B}*
1157<IncludeDoc>{FILEMASK}|"\""[^\n\"]+"\"" {
1161 fileName=fileName.
mid(1,fileName.
length()-2);
1169 BEGIN(yyextra->includeCtx);
size_t length() const
Returns the length of the string, not counting the 0-terminator.
1172<SnippetDoc>({FILEMASK}|"\""[^\n\"]+"\""){B}+ {
1173 yyextra->snippetFileName=yytext;
1174 yyextra->snippetFileName=yyextra->snippetFileName.stripWhiteSpace();
1175 if (yyextra->snippetFileName ==
"this") yyextra->snippetFileName=yyextra->fileName;
1176 yyextra->snippetName =
"";
1177 BEGIN(SnippetDocTag);
1179<SnippetDocTag>[^\\@\n]+ {
1180 yyextra->snippetName += yytext;
1182<SnippetDocTag>{CMD} {
1183 yyextra->snippetName += yytext;
1185<SnippetDocTag>(\n|{CMD}"ilinebr") {
1186 for (
int i=(
int)yyleng-1;i>=0;i--) unput(yytext[i]);
1187 yyextra->snippetName = yyextra->snippetName.stripWhiteSpace();
1188 QCString blockId =
"["+yyextra->snippetName+
"]";
1195 BEGIN(yyextra->includeCtx);
1199<IncludeDoc,SnippetDoc>\n {
1204 BEGIN(yyextra->includeCtx);
1206<IncludeDoc,SnippetDoc>. {
1208 BEGIN(yyextra->includeCtx);
1210<CComment,ReadLine,IncludeFile>{CMD}"cond"/[^a-z_A-Z0-9] {
1211 yyextra->condCtx = YY_START;
1214<CComment,ReadLine,IncludeFile>{CMD}"endcond"/[^a-z_A-Z0-9] {
1215 bool oldSkip=yyextra->skip;
1217 if (YY_START==CComment && oldSkip && !yyextra->skip)
1220 if (yyextra->lang!=SrcLangExt::Python &&
1221 yyextra->lang!=SrcLangExt::VHDL &&
1222 yyextra->lang!=SrcLangExt::Markdown &&
1223 yyextra->lang!=SrcLangExt::Fortran)
1225 yyextra->outBuf+=
'/';
1226 yyextra->outBuf+=
'*';
1228 if (yyextra->specialComment)
1230 yyextra->outBuf+=
'*';
1236<CondLine>[!()&| \ta-z_A-Z0-9.\-]+ {
1239<CComment,ReadLine,IncludeFile>{CMD}"cond"{WSopt}/\n {
1240 yyextra->condCtx=YY_START;
1248<CComment,ReadLine,IncludeFile,Verbatim,VerbatimCode>{CMD}[a-z_A-Z][a-z_A-Z0-9-]* {
1249 replaceAliases(yyscanner,yytext,YY_START==ReadLine && yyextra->readLineCtx==SComment);
1251<CComment,ReadLine,IncludeFile,Verbatim,VerbatimCode>{B}?{CMD}"ilinebr"{B}{CMD}"ialias{" {
1252 yyextra->lastBlockContext=YY_START;
1253 yyextra->blockCount=1;
1254 int extraSpace = (yytext[0]==
' '? 1:0);
1255 yyextra->aliasString=yytext+9+extraSpace;
1256 yyextra->aliasCmd=yytext+9+extraSpace;
1257 yyextra->lastEscaped=0;
1258 BEGIN( ReadAliasArgs );
1260<CComment,ReadLine,IncludeFile,Verbatim,VerbatimCode>{CMD}[a-z_A-Z][a-z_A-Z0-9-]*"{" {
1261 yyextra->lastBlockContext=YY_START;
1262 yyextra->blockCount=1;
1263 yyextra->aliasString=yytext;
1264 yyextra->aliasCmd=yytext;
1265 yyextra->lastEscaped=0;
1266 BEGIN( ReadAliasArgs );
1268<ReadAliasArgs>^[ \t]*"*" {
1270<ReadAliasArgs>^[ \t]*{CPPC}[/!]/[^\n]* {
1272<ReadAliasArgs>[^{}\n\\\*]+ {
1273 yyextra->aliasString+=yytext;
1274 yyextra->lastEscaped=
FALSE;
1276<ReadAliasArgs>"\\" {
1277 if (yyextra->lastEscaped) yyextra->lastEscaped=
FALSE;
1278 else yyextra->lastEscaped=
TRUE;
1279 yyextra->aliasString+=yytext;
1281<ReadAliasArgs>{CMD}("endverbatim"|"endiliteral"|"endlatexonly"|"endhtmlonly"|"endxmlonly"|"enddocbookonly"|"endrtfonly"|"endmanonly"|"f$"|"f]"|"f}"|"f)") {
1282 yyextra->aliasString+=yytext;
1283 if (yyextra->inVerbatim && &yytext[1]==yyextra->blockName)
1292 yyextra->inVerbatim=
false;
1293 BEGIN(yyextra->lastCommentContext);
1297 yyextra->aliasString+=yytext;
1298 yyextra->lastEscaped=
FALSE;
1299 if (yyextra->inVerbatim)
1303 BEGIN( yyextra->lastBlockContext );
1307 yyextra->aliasString+=yytext;
1308 if (!yyextra->lastEscaped) yyextra->blockCount++;
1309 yyextra->lastEscaped=
FALSE;
1312 yyextra->aliasString+=yytext;
1313 if (!yyextra->lastEscaped) yyextra->blockCount--;
1314 if (yyextra->blockCount==0)
1317 yyextra->lastBlockContext==ReadLine && yyextra->readLineCtx==SComment);
1318 BEGIN( yyextra->lastBlockContext );
1320 yyextra->lastEscaped=
FALSE;
1323 yyextra->aliasString+=yytext;
1324 yyextra->lastEscaped=
FALSE;
1331 yyextra->insertCppCommentMarker=
false;
1332 BEGIN(yyextra->readLineCtx);
1340<ReadLine>{CMD}{CMD} |
1355 if (YY_START == ReadAliasArgs)
1357 warn(yyextra->fileName,yyextra->lineNr,
1358 "Reached end of file while still searching closing '}}' of an alias argument (probable start: '{}')",
1361 if (yyextra->includeStack.empty())
1363 yyextra->insertCppCommentMarker=
false;
1368 std::unique_ptr<commentcnv_FileState> &fs = yyextra->includeStack.back();
1369 YY_BUFFER_STATE oldBuf = YY_CURRENT_BUFFER;
1370 yy_switch_to_buffer(fs->bufState, yyscanner);
1371 yy_delete_buffer(oldBuf, yyscanner);
1372 BEGIN(fs->oldState);
1373 yyextra->fileName = fs->oldFileName;
1374 yyextra->lineNr = fs->oldLineNr;
1375 yyextra->inBuf = fs->oldFileBuf;
1376 yyextra->inBufPos = fs->oldFileBufPos;
1377 yyextra->includeCtx = fs->oldIncludeCtx;
1379 if (fs->oldRaiseLvl!=yyextra->raiseLevel)
1381 lineStr+=
"\\iraise " + std::to_string(fs->oldRaiseLvl)+
" ";
1383 if (fs->oldRaiseLbl!=yyextra->raiseLabel)
1385 lineStr+=
"\\iprefix \"" + fs->oldRaiseLbl +
"\" ";
1387 lineStr+=
"\\ilinebr ";
1388 yyextra->raiseLevel = fs->oldRaiseLvl;
1389 yyextra->raiseLabel = fs->oldRaiseLbl;
1391 yyextra->includeStack.pop_back();
QCString & setNum(short n)
std::string_view view() const
1403 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
1406 size_t optIdxStart = s.find(
'{');
1407 size_t optIdxEnd = optIdxStart!=std::string::npos ? s.find(
"}",optIdxStart+1) : std::string::npos;
1408 std::string cmdName;
1410 if (optIdxStart == std::string::npos)
1417 optList =
split(std::string{s.substr(optIdxStart+1,optIdxEnd-optIdxStart-1)},
",");
1419 bool isDoc = cmdName==
"includedoc" || cmdName==
"snippetdoc";
1420 for (
const auto &opt : optList)
1431 for (
const auto &opt : optList)
1434 size_t posEqual = locOpt.find(
'=');
1435 std::string_view option = posEqual!=std::string::npos ?
stripWhiteSpace(locOpt.substr(0,posEqual)) : locOpt;
1436 std::string_view value = posEqual!=std::string::npos ?
stripWhiteSpace(locOpt.substr(posEqual+1)) : std::string_view();
1438 if (option==std::string_view{
"doc"} && value.empty())
1441 else if (option==std::string_view{
"raise"} && !value.empty())
1443 yyextra->raiseIncrement = atoi(value.data());
1446 warn(yyextra->fileName,yyextra->lineNr,
"Raising section level from {} to {}, exceeds allowed range [0-{}], adjusting",
1451 else if (option==std::string_view{
"prefix"} && !value.empty())
1453 yyextra->raisePrefix = value;
1457 warn(yyextra->fileName,yyextra->lineNr,
"Unsupported option '{}' for {} command",option, cmdName);
1468 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
1469 if (s.empty())
return;
1471 size_t len = s.length();
1474 while (p<len && (c=s[p]) && (c==
' ' || c==
'\t' || c==
'\n'))
1477 if (c==
'\n') { yyextra->lineNr++; yyextra->col=0; }
else { yyextra->col++; }
1482 while (p<len && (c=s[p]) && (c==
'/' || c==
'!' || c==
'#'))
1486 if (p<len && s[p]==
'<')
1500 yyextra->outBuf+=
' ';
1504 if (blanks>1) { yyextra->outBuf+=
'*'; yyextra->col++; }
1505 yyextra->outBuf+=
' ';
1509 yyextra->outBuf+=s.substr(p);
1510 yyextra->col+=s.substr(p).length();
1522 else if (c==
'\t') col+=tabSize-(col%tabSize);
1531 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
1532 size_t len = s.length();
1535 for (
size_t i=0;i<len;i++)
1540 yyextra->outBuf+=
'\n';
1545 yyextra->col+=tabSize-(yyextra->col%tabSize);
1556 for (
size_t i=0;i<len;i++)
1560 case '\n': yyextra->col=0;
1562 yyextra->lineNr++;
break;
1563 case '\t': yyextra->col+=tabSize-(yyextra->col%tabSize);
break;
1564 default: yyextra->col++;
break;
1572 copyToOutput(yyscanner,std::string_view{s,(size_t)len});
1577 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
1578 while (!yyextra->commentStack.empty()) yyextra->commentStack.pop();
1583 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
1586 bool expResult = prs.
parse(yyextra->fileName,yyextra->lineNr,sectId);
1587 yyextra->condStack.emplace(yyextra->lineNr,sectId,yyextra->skip);
1596 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
1597 if (yyextra->condStack.empty())
1599 warn(yyextra->fileName,yyextra->lineNr,
"Found \\endcond command without matching \\cond");
1600 yyextra->skip=
FALSE;
1606 yyextra->condStack.pop();
1613 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
1614 bool oldSkip=yyextra->skip;
1616 if ((yyextra->condCtx==CComment || yyextra->readLineCtx==SComment) &&
1617 !oldSkip && yyextra->skip)
1619 if (yyextra->lang!=SrcLangExt::Python &&
1620 yyextra->lang!=SrcLangExt::VHDL &&
1621 yyextra->lang!=SrcLangExt::Markdown &&
1622 yyextra->lang!=SrcLangExt::Fortran)
1624 yyextra->outBuf+=
'*';
1625 yyextra->outBuf+=
'/';
1629 if (yyextra->readLineCtx==SComment)
1635 BEGIN(yyextra->condCtx);
1650 int m1 = text.
find(marker);
1651 if (m1==-1)
return result;
1652 int m2 = text.
find(marker,m1+
static_cast<int>(marker.
length()));
1653 if (m2==-1)
return result;
1657 while (!found && (i=text.
find(
'\n',p))!=-1)
1659 found = (p<=m1 && m1<i);
1667 while ((i=text.
find(
'\n',p))!=-1)
1687 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
1688 int startCol=yyextra->blockHeadCol;
1689 int contentCol=yyextra->insertCommentCol;
1690 int markerSpace=contentCol-startCol;
1694 if (yyextra->lang==SrcLangExt::Python)
1696 if (yyextra->pythonDocString)
1705 else if (yyextra->lang==SrcLangExt::Fortran)
1709 else if (yyextra->lang==SrcLangExt::Markdown)
1713 else if (yyextra->insertCppCommentMarker)
1728 for (;i<startCol;i++)
1732 if (
static_cast<int>(marker.length())<=markerSpace && !yyextra->firstIncludeLine)
1737 for (;i<contentCol;i++)
1741 yyextra->firstIncludeLine =
false;
1747 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
1755 warn_doc_error(yyextra->fileName,yyextra->lineNr,
"included file name '{}' is ambiguous"
1758 bool alreadyProcessed = std::any_of(
1759 yyextra->includeStack.begin(),
1760 yyextra->includeStack.end(),
1761 [&absFileName,&blockId](
const auto &lfs)
1762 { return lfs->fileName==absFileName && lfs->blockId==blockId; }
1765 if (alreadyProcessed)
1769 warn_doc_error(yyextra->fileName,yyextra->lineNr,
"recursive usage of '\\snippet{{doc}}' block with name '{}' and file name '{}', skipping",
1770 blockId,absFileName);
1774 warn_doc_error(yyextra->fileName,yyextra->lineNr,
"recursive usage of '\\include{{doc}}' with file name '{}', skipping", absFileName);
1779 auto fs = std::make_unique<commentcnv_FileState>();
1782 warn_doc_error(yyextra->fileName,yyextra->lineNr,
"\\{}{{doc}} file '{}' could not be read",blockId.
isEmpty()?
"include":
"snippet",absFileName);
1793 warn_doc_error(yyextra->fileName,yyextra->lineNr,
"block marked with {} for \\snippet{{doc}} should appear twice in file {}, found it {:d} times, skipping",
1794 blockId,absFileName,count);
1800 fs->fileBuf.clear();
1803 fs->fileBuf.append(incText.
str());
1806 int oldRaiseLevel = yyextra->raiseLevel;
1807 QCString oldRaiseLabel = yyextra->raiseLabel;
1808 yyextra->raiseLevel+=yyextra->raiseIncrement;
1809 yyextra->raiseLabel+=yyextra->raisePrefix;
1810 QCString lineStr=
" \\ifile \""+absFileName+
"\" \\iline " + std::to_string(lineNr)+
" ";
1811 if (yyextra->raiseLevel>0)
1813 lineStr+=
"\\iraise " + std::to_string(yyextra->raiseLevel)+
" ";
1815 if (!yyextra->raiseLabel.isEmpty())
1817 lineStr+=
"\\iprefix \"" + yyextra->raiseLabel +
"\" ";
1819 lineStr+=
"\\ilinebr ";
1822 fs->fileName = absFileName;
1823 fs->bufState = YY_CURRENT_BUFFER;
1824 fs->oldLineNr = yyextra->lineNr;
1825 fs->oldFileName = yyextra->fileName;
1826 fs->oldState = yyextra->includeCtx;
1827 fs->oldFileBuf = yyextra->inBuf;
1828 fs->oldFileBufPos = yyextra->inBufPos;
1829 fs->oldIncludeCtx = yyextra->includeCtx;
1830 fs->oldRaiseLvl = oldRaiseLevel;
1831 fs->oldRaiseLbl = oldRaiseLabel;
1832 fs->blockId = blockId;
1833 yy_switch_to_buffer(yy_create_buffer(
nullptr,
YY_BUF_SIZE, yyscanner),yyscanner);
1834 yyextra->fileName = absFileName;
1835 yyextra->lineNr = lineNr;
1836 yyextra->inBuf = &fs->fileBuf;
1837 yyextra->inBufPos = 0;
1838 yyextra->includeStack.push_back(std::move(fs));
1844 warn_doc_error(yyextra->fileName,yyextra->lineNr,
"\\{}{{doc}} file '{}' not found",blockId.
isEmpty()?
"include":
"snippet",inc);
1855 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
1856 if (s.empty())
return;
1857 size_t pos = s.find(
'{');
1858 std::string cmd { s.substr(1, pos!=std::string::npos ? pos-1 : s.length()-1) };
1859 auto &expAlias = yyextra->expandedAliases;
1860 if (std::find(expAlias.begin(),expAlias.end(),cmd)!=std::end(expAlias))
1865 else if (cmd==
"ialias")
1867 if (s.length()>cmd.length()+3)
1869 std::string value { s.substr(cmd.length()+2,s.length()-cmd.length()-3) };
1871 expAlias.erase(std::remove(expAlias.begin(),expAlias.end(),value),expAlias.end());
1876 if (yyextra->inVerbatim)
1879 std::string blk = yyextra->blockName.str();
1880 assert(!blk.empty());
1881 bool isNamedCommand=
isId(blk[0]);
1884 while ((i=result.find(blk,p))!=std::string::npos && !found)
1886 found = !isNamedCommand ||
1887 (i>0 && (result[i-1]==
'\\' || result[i-1]==
'@') && !
isId(result[i+blk.length()]));
1888 p = i+yyextra->blockName.length();
1906 expAlias.push_back(cmd);
1908 result +=
" \\ilinebr \\ialias{";
1911 for (
int i=(
int)result.length()-1; i>=0; i--)
1925 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
1926 int bytesInBuf =
static_cast<int>(yyextra->inBuf->size())-yyextra->inBufPos;
1927 int bytesToCopy = std::min(max_size,bytesInBuf);
1928 memcpy(buf,yyextra->inBuf->data()+yyextra->inBufPos,bytesToCopy);
1929 yyextra->inBufPos+=bytesToCopy;
1935 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
1936 if (yyextra->mlBrief || yyextra->skip)
1944 if (i==yyextra->blockHeadCol || i+1==yyextra->blockHeadCol)
1951 for (i=(
int)yyleng-1;i>=0;i--) unput(yytext[i]);
1952 yyextra->inSpecialComment=
FALSE;
1969 commentcnvYYlex_init_extra(&extra,&yyscanner);
1973 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
1975 yyextra->inBufPos = 0;
1978 yyextra->skip =
FALSE;
1979 yyextra->fileName = fileName;
1981 yyextra->pythonDocString =
FALSE;
1982 yyextra->lineNr = 1;
1983 yyextra->raiseLevel = 0;
1984 yyextra->raiseLabel =
"";
1985 yyextra->raiseIncrement = 0;
1986 yyextra->raisePrefix =
"";
1987 yyextra->insertCppCommentMarker=
false;
1988 yyextra->expandedAliases.clear();
1989 while (!yyextra->condStack.empty()) yyextra->condStack.pop();
1991 yyextra->vhdl =
FALSE;
1994 yyextra->isFixedForm =
FALSE;
1995 if (yyextra->lang==SrcLangExt::Fortran)
2001 if (yyextra->lang==SrcLangExt::Markdown)
2003 yyextra->nestingCount=0;
2005 yyextra->commentStack.push(yyextra->lineNr);
2012 while (!yyextra->condStack.empty())
2017 warn(yyextra->fileName,ctx.
lineNr,
"Conditional section{}does not have "
2018 "a corresponding \\endcond command within this file.",sectionInfo.
data());
2019 yyextra->condStack.pop();
2021 if (yyextra->nestingCount>0 && yyextra->lang!=SrcLangExt::Markdown && yyextra->lang!=SrcLangExt::Fortran)
2025 while (!yyextra->commentStack.empty())
2027 int lineNr = yyextra->commentStack.top();
2028 if (!first) lines +=
", ";
2031 yyextra->commentStack.pop();
2033 warn(yyextra->fileName,yyextra->lineNr,
"Reached end of file while still inside a (nested) comment. "
2034 "Nesting level {} (possible line reference(s): {})",yyextra->nestingCount,lines);
2036 yyextra->nestingCount = 0;
2040 "output=[\n{}]\n-----------\n",fileName,yyextra->outBuf
2043 commentcnvYYlex_destroy(yyscanner);
2049#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)