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
164#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.
172MAILADDR ("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\-]+
198DECIMAL_INTEGER [1-9][0-9']*[0-9]?[uU]?[lL]?[lL]?
199HEXADECIMAL_INTEGER "0"[xX][0-9a-zA-Z']+[0-9a-zA-Z]?
200OCTAL_INTEGER "0"[0-7][0-7']+[0-7]?
201BINARY_INTEGER "0"[bB][01][01']*[01]?
202INTEGER_NUMBER {DECIMAL_INTEGER}|{HEXADECIMAL_INTEGER}|{OCTAL_INTEGER}|{BINARY_INTEGER}
206DIGIT_SEQ [0-9][0-9']*[0-9]?
207FRAC_CONST {DIGIT_SEQ}"."|{DIGIT_SEQ}?"."{DIGIT_SEQ}
208FP_EXP [eE][+-]?{DIGIT_SEQ}
209DEC_FP1 {FRAC_CONST}{FP_EXP}?{FP_SUF}?
210DEC_FP2 {DIGIT_SEQ}{FP_EXP}{FP_SUF}
212HEX_DIGIT_SEQ [0-9a-fA-F][0-9a-fA-F']*[0-9a-fA-F]?
213HEX_FRAC_CONST {HEX_DIGIT_SEQ}"."|{HEX_DIGIT_SEQ}?"."{HEX_DIGIT_SEQ}
214BIN_EXP [pP][+-]?{DIGIT_SEQ}
215HEX_FP1 "0"[xX]{HEX_FRAC_CONST}{BIN_EXP}{FP_SUF}?
216HEX_FP2 "0"[xX]{HEX_DIGIT_SEQ}{BIN_EXP}{FP_SUF}?
218FLOAT_DECIMAL {DEC_FP1}|{DEC_FP2}
219FLOAT_HEXADECIMAL {HEX_FP1}|{HEX_FP2}
220FLOAT_NUMBER {FLOAT_DECIMAL}|{FLOAT_HEXADECIMAL}
221NUMBER {INTEGER_NUMBER}|{FLOAT_NUMBER}
223FILEICHAR [a-z_A-Z0-9\x80-\xFF\\:\\\/\-\+=&#@]
224FILEECHAR [a-z_A-Z0-9\x80-\xFF\-\+=&#@]
225FILECHARS {FILEICHAR}*{FILEECHAR}+
226HFILEMASK {FILEICHAR}*("."{FILEICHAR}+)+{FILECHARS}*
227VFILEMASK {FILECHARS}("."{FILECHARS})*
228FILEMASK {VFILEMASK}|{HFILEMASK}
256 if (yyextra->lang!=SrcLangExt::Cpp) REJECT;
259<Scan>[^"'!\/\n\\#,\-=; \t@$]* {
267 if (yyextra->lang!=SrcLangExt::Python)
273 yyextra->pythonDocString =
TRUE;
274 yyextra->pythonDocStringChar = yytext[0];
275 yyextra->nestingCount=1;
279 yyextra->commentStack.push(yyextra->lineNr);
284 if (yyextra->lang!=SrcLangExt::Python)
294 yyextra->pythonDocString =
TRUE;
295 yyextra->pythonDocStringChar = yytext[0];
296 yyextra->nestingCount=1;
300 yyextra->commentStack.push(yyextra->lineNr);
#define Config_getBool(name)
303<Scan>{B}*![><!]/.*\n {
304 if (yyextra->lang!=SrcLangExt::Fortran)
310 yyextra->nestingCount=0;
312 yyextra->specialComment=
true;
314 yyextra->blockHeadCol=yyextra->col-2;
316 yyextra->commentStack.push(yyextra->lineNr);
319<Scan>[Cc\*][><!]/.*\n {
320 if (yyextra->lang!=SrcLangExt::Fortran)
327 if (yyextra->isFixedForm && (yyextra->col == 0))
329 yyextra->nestingCount=0;
331 yyextra->specialComment=
true;
333 yyextra->blockHeadCol=yyextra->col-1;
335 yyextra->commentStack.push(yyextra->lineNr);
344 if (yyextra->lang!=SrcLangExt::Fortran)
354 if (yyextra->lang!=SrcLangExt::Fortran)
360 if (yyextra->col == 0)
371 if (yyextra->lang!=SrcLangExt::CSharp) REJECT
373 yyextra->stringContext = YY_START;
374 BEGIN(SkipVerbString);
378 yyextra->stringContext = YY_START;
383 yyextra->charContext = YY_START;
384 if (yyextra->lang!=SrcLangExt::VHDL)
392<Scan>{CPPC}[!/]/.*\n[ \t]*{CPPC}[!/][ \t]*{CMD}"}" {
394 yyextra->inSpecialComment=
true;
395 yyextra->blockHeadCol=yyextra->col+1;
396 yyextra->insertCppCommentMarker=
true;
398 yyextra->readLineCtx=YY_START;
401<Scan>{CPPC}"!"/.*\n[ \t]*{CPPC}[\/!][^\/] |
402<Scan>({CPPC}"/"[/]*)/[^/].*\n[ \t]*{CPPC}[\/!][^\/] {
403 if (yyextra->mlBrief)
412 while (
i<(
int)yyleng && yytext[
i]==
'/')
i++;
414 yyextra->blockHeadCol=yyextra->col+1;
415 if (yytext[2] ==
'!')
424 yyextra->inSpecialComment=
TRUE;
426 yyextra->readLineCtx=SComment;
430<Scan>{CPPC}"##Documentation"{ANYopt}/\n {
431 if (yyextra->mlBrief) REJECT;
433 yyextra->blockHeadCol=yyextra->col+1;
436 yyextra->inRoseComment=
TRUE;
439<Scan>{CPPC}[!\/]/.*\n[ \t]*{CPPC}[|\/][ \t]*{CMD}"}" {
440 yyextra->inSpecialComment=yytext[2]==
'/' || yytext[2]==
'!';
441 if (yyextra->inSpecialComment)
443 yyextra->blockHeadCol=yyextra->col+1;
446 yyextra->readLineCtx=YY_START;
449<Scan>{CPPC}[!/]/.*\n {
450 yyextra->inSpecialComment=
true;
451 yyextra->blockHeadCol=yyextra->col+1;
452 yyextra->insertCppCommentMarker=
true;
454 yyextra->readLineCtx=YY_START;
458 yyextra->inSpecialComment=
false;
460 yyextra->readLineCtx=YY_START;
467 if (yyextra->lang==SrcLangExt::Python)
471 yyextra->specialComment=(int)yyleng==3;
472 yyextra->nestingCount=1;
475 if (yyextra->specialComment)
477 yyextra->blockHeadCol=0;
484 yyextra->commentStack.push(yyextra->lineNr);
487 if (yyextra->lang!=SrcLangExt::PHP)
494 if (yyextra->lang!=SrcLangExt::Python)
500 yyextra->nestingCount=0;
502 yyextra->specialComment=(int)yyleng==2;
503 if (yyextra->specialComment)
505 yyextra->blockHeadCol=yyextra->col;
507 yyextra->commentStack.push(yyextra->lineNr);
512<Scan>"--"[^!][^\n]* {
513 if (yyextra->lang!=SrcLangExt::VHDL)
523 if (yyextra->lang!=SrcLangExt::VHDL)
529 yyextra->specialComment=
true;
530 yyextra->blockHeadCol=yyextra->col;
531 yyextra->vhdl =
TRUE;
532 yyextra->nestingCount=0;
534 yyextra->commentStack.push(yyextra->lineNr);
540 if (yyextra->lang!=SrcLangExt::Fortran)
546 yyextra->nestingCount=0;
548 yyextra->specialComment=
true;
549 yyextra->blockHeadCol=yyextra->col;
550 yyextra->commentStack.push(yyextra->lineNr);
555<CComment,CNComment,ReadLine,IncludeFile>{MAILADDR} |
556<CComment,CNComment,ReadLine,IncludeFile>"<"{MAILADDR}">" {
559<CComment,IncludeFile>"{"[ \t]*"@code"/[ \t\n] {
561 yyextra->lastCommentContext = YY_START;
562 yyextra->javaBlock=1;
563 yyextra->blockName=
QCString(
"end")+&yytext[1];
564 yyextra->inVerbatim=
true;
565 yyextra->verbatimLine=yyextra->lineNr;
568<CComment,IncludeFile>"{"[ \t]*"@literal"/[ \t\n] {
570 yyextra->lastCommentContext = YY_START;
571 yyextra->javaBlock=1;
572 yyextra->blockName=
QCString(
"end")+&yytext[1];
573 yyextra->inVerbatim=
true;
574 yyextra->verbatimLine=yyextra->lineNr;
577<CComment,ReadLine,IncludeFile>{CMD}"ilinebr"[ \t]+("```"[`]*|"~~~"[~]*) {
583 yyextra->lastCommentContext = YY_START;
584 yyextra->javaBlock=0;
586 yyextra->inVerbatim=
true;
587 yyextra->verbatimLine=yyextra->lineNr;
QCString stripWhiteSpace() const
returns a copy of this string with leading and trailing whitespace removed
QCString right(size_t len) const
590<CComment,ReadLine,IncludeFile>^[ \t]*("```"[`]*|"~~~"[~]*) {
596 yyextra->lastCommentContext = YY_START;
597 yyextra->javaBlock=0;
599 yyextra->inVerbatim=
true;
600 yyextra->verbatimLine=yyextra->lineNr;
QCString left(size_t len) const
603<CComment,ReadLine,IncludeFile>{CMD}("dot"|"code"|"msc"|"startuml")/[^a-z_A-Z0-9] {
605 yyextra->lastCommentContext = YY_START;
606 yyextra->javaBlock=0;
607 if (
qstrcmp(&yytext[1],
"startuml")==0)
609 yyextra->blockName=
"enduml";
613 yyextra->blockName=
QCString(
"end")+&yytext[1];
615 yyextra->inVerbatim=
true;
616 yyextra->verbatimLine=yyextra->lineNr;
int qstrcmp(const char *str1, const char *str2)
619<CComment,ReadLine,IncludeFile>"\\`" {
622<CComment,ReadLine,IncludeFile>"```" {
625<CComment,ReadLine,IncludeFile>"`"{1,2} {
631 yyextra->lastCommentContext = YY_START;
632 yyextra->javaBlock=0;
633 yyextra->blockName=yytext;
634 yyextra->inVerbatim=
true;
635 yyextra->verbatimLine=yyextra->lineNr;
638<CComment,ReadLine,IncludeFile>{CMD}("f$"|"f["|"f{"|"f(") {
640 yyextra->blockName=&yytext[1];
641 if (yyextra->blockName.at(1)==
'[')
643 yyextra->blockName.at(1)=
']';
645 else if (yyextra->blockName.at(1)==
'{')
647 yyextra->blockName.at(1)=
'}';
649 else if (yyextra->blockName.at(1)==
'(')
651 yyextra->blockName.at(1)=
')';
653 yyextra->lastCommentContext = YY_START;
654 yyextra->inVerbatim=
true;
655 yyextra->verbatimLine=yyextra->lineNr;
658<CComment,ReadLine,IncludeFile>"<!--!" {
659 if (yyextra->inVerbatim) REJECT;
661 yyextra->inHtmlDoxygenCommand=
true;
663<CComment,ReadLine,IncludeFile>"-->" {
664 if (yyextra->inHtmlDoxygenCommand)
666 yyextra->inHtmlDoxygenCommand=
false;
673<CComment,ReadLine,IncludeFile>"<!--" {
675 yyextra->blockName=
"-->";
676 yyextra->lastCommentContext = YY_START;
677 yyextra->inVerbatim=
true;
678 yyextra->verbatimLine=yyextra->lineNr;
681<CComment,ReadLine,IncludeFile>{CMD}("verbatim"|"iliteral"|"latexonly"|"htmlonly"|"xmlonly"|"docbookonly"|"rtfonly"|"manonly")/[^a-z_A-Z0-9] {
683 yyextra->blockName=
QCString(
"end")+&yytext[1];
684 yyextra->lastCommentContext = YY_START;
685 yyextra->inVerbatim=
true;
686 yyextra->verbatimLine=yyextra->lineNr;
698<Verbatim>{CMD}("endverbatim"|"endiliteral"|"endlatexonly"|"endhtmlonly"|"endxmlonly"|"enddocbookonly"|"endrtfonly"|"endmanonly"|"f$"|"f]"|"f}"|"f)") {
700 if (&yytext[1]==yyextra->blockName)
702 yyextra->inVerbatim=
false;
703 BEGIN(yyextra->lastCommentContext);
708 if (yytext==yyextra->blockName)
710 yyextra->inVerbatim=
false;
711 BEGIN(yyextra->lastCommentContext);
715 if (yyextra->javaBlock==0)
721 yyextra->javaBlock++;
726 if (yyextra->javaBlock==0)
732 yyextra->javaBlock--;
733 if (yyextra->javaBlock==0)
736 yyextra->inVerbatim=
false;
737 BEGIN(yyextra->lastCommentContext);
745<VerbatimCode>("```"[`]*|"~~~"[~]*) {
746 if (yytext[0]==
'`' && (yyextra->blockName==
"`" || yyextra->blockName==
"``"))
750 yyextra->inVerbatim=
false;
751 BEGIN(yyextra->lastCommentContext);
756 if (yytext[0]==yyextra->blockName[0])
758 yyextra->inVerbatim=
false;
759 BEGIN(yyextra->lastCommentContext);
765 if (yyextra->blockName==
"`")
767 yyextra->inVerbatim=
false;
768 BEGIN(yyextra->lastCommentContext);
771<VerbatimCode>"`"{1,2} {
773 if (yytext==yyextra->blockName)
775 yyextra->inVerbatim=
false;
776 BEGIN(yyextra->lastCommentContext);
779<VerbatimCode>{CMD}("enddot"|"endcode"|"endmsc"|"enduml")/("{")? {
781 if (&yytext[1]==yyextra->blockName)
783 yyextra->inVerbatim=
false;
784 BEGIN(yyextra->lastCommentContext);
787<VerbatimCode>^[ \t]*{CPPC}[\!\/]? {
788 if (!yyextra->inSpecialComment || yyextra->mlBrief)
795 while (yytext[l]==
' ' || yytext[l]==
'\t')
810<Verbatim,VerbatimCode>[^`'~@\/\-\\\n{}]* {
813<Verbatim,VerbatimCode>[^`'~@\/\-\\\n{}]+/\n {
814 if (yyextra->lastCommentContext==ReadLine)
816 yyextra->inVerbatim=
false;
817 BEGIN(yyextra->lastCommentContext);
821<Verbatim,VerbatimCode>\n {
823 if (yyextra->lastCommentContext == IncludeFile)
828<Verbatim>^[ \t]*{CPPC}[/!] {
829 if (yyextra->blockName==
"enddot" || yyextra->blockName==
"endmsc" || yyextra->blockName==
"enduml" || yyextra->blockName.at(0)==
'f')
833 while (yytext[l]==
' ' || yytext[l]==
'\t')
845<Verbatim,VerbatimCode>. {
849 if (yyextra->lang==SrcLangExt::Fortran || yyextra->lang==SrcLangExt::VHDL)
861 BEGIN(yyextra->stringContext);
869<SkipVerbString>[^"\n]+ {
872<SkipVerbString>\"\" {
875<SkipVerbString>"\"" {
877 BEGIN(yyextra->stringContext);
886 if (yyextra->lang==SrcLangExt::Fortran || yyextra->lang==SrcLangExt::VHDL)
898 BEGIN(yyextra->charContext);
907<CComment,CNComment>[^ `~<\\!@*\n{\"'\/-`]* {
910<CComment,CNComment>^{B}*"*"+[^*\/<\\@\n{\"`]* {
911 if (yyextra->lang==SrcLangExt::Markdown) REJECT;
913 if (yyextra->col>yyextra->blockHeadCol)
916 yyextra->blockHeadCol=yyextra->col;
922 if (yyextra->lang!=SrcLangExt::Python)
926 else if (yyextra->pythonDocStringChar != yytext[0])
932 yyextra->nestingCount--;
933 yyextra->pythonDocString =
FALSE;
934 yyextra->pythonDocStringChar =
'\0';
939<CComment,CNComment>\n {
942 if (yyextra->lang==SrcLangExt::Fortran)
947<CComment,CNComment>"/""/"+/"*/" {
951<CComment,CNComment>"/"+"*" {
952 if (yyextra->lang==SrcLangExt::Python ||
953 yyextra->lang==SrcLangExt::Markdown)
957 yyextra->nestingCount++;
958 yyextra->commentStack.push(yyextra->lineNr);
961<CComment,CNComment>^{B}*"*"+"/" |
962<CComment,CNComment>"*"+"/" {
963 if (yyextra->lang==SrcLangExt::Python ||
964 yyextra->lang==SrcLangExt::Markdown)
971 yyextra->nestingCount--;
972 if (yyextra->nestingCount<=0)
979 yyextra->commentStack.pop();
984<CComment,CNComment>"\n"/[ \t]*"#" {
985 if (yyextra->lang!=SrcLangExt::VHDL)
993 yyextra->vhdl =
FALSE;
1003<CComment,CNComment>"\n"/[ \t]*"-" {
1004 if (yyextra->lang!=SrcLangExt::Python || yyextra->pythonDocString)
1014<CComment,CNComment>"\n"/[ \t]*[^ \t#\-] {
1015 if (yyextra->lang==SrcLangExt::Python)
1017 if (yyextra->pythonDocString)
1027 else if (yyextra->lang==SrcLangExt::VHDL)
1031 yyextra->vhdl =
FALSE;
1057<CComment,CNComment>{CMD}"~"[a-z_A-Z-]* {
1058 if (yyextra->lang!=SrcLangExt::Markdown) REJECT;
1065 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...
1071<CComment,CNComment>{CMD}{CMD} |
1072<CComment,CNComment>. {
1075<SkipLang>{CMD}"~"[a-zA-Z-]* {
1079 warn(yyextra->fileName,yyextra->lineNr,
1088<SkipLang>[^*@\\\n]* {
1095<SComment>^[ \t]*{CPPC}"/"{SLASHopt}/\n {
1098<SComment>\n[ \t]*{CPPC}"/"{SLASHopt}/\n {
1101<SComment>^[ \t]*{CPPC}"/"[^\/\n]/.*\n {
1103 yyextra->readLineCtx=YY_START;
1104 YY_CURRENT_BUFFER->yy_at_bol=1;
1107<SComment>\n[ \t]*{CPPC}[\/!]("<")?[ \t]*{CMD}"}".*\n {
1111 yyextra->inSpecialComment=
false;
1112 yyextra->inRoseComment=
false;
1115<SComment>\n[ \t]*{CPPC}"/"[^\\@\/\n]/.*\n {
1117 yyextra->readLineCtx=YY_START;
1118 YY_CURRENT_BUFFER->yy_at_bol=1;
1121<SComment>^[ \t]*{CPPC}"!" |
1122<SComment>^[ \t]*{CPPC}"!<"/.*\n |
1123<SComment>^[ \t]*{CPPC}"!"[^<]/.*\n {
1125 yyextra->readLineCtx=YY_START;
1126 YY_CURRENT_BUFFER->yy_at_bol=1;
1129<SComment>\n[ \t]*{CPPC}"!" |
1130<SComment>\n[ \t]*{CPPC}"!<"/.*\n |
1131<SComment>\n[ \t]*{CPPC}"!"[^<\n]/.*\n {
1133 yyextra->readLineCtx=YY_START;
1134 YY_CURRENT_BUFFER->yy_at_bol=1;
1137<SComment>^[ \t]*{CPPC}"##"/.*\n {
1138 if (!yyextra->inRoseComment)
1145 yyextra->readLineCtx=YY_START;
1146 YY_CURRENT_BUFFER->yy_at_bol=1;
1150<SComment>\n[ \t]*{CPPC}"##"/.*\n {
1151 if (!yyextra->inRoseComment)
1158 yyextra->readLineCtx=YY_START;
1159 YY_CURRENT_BUFFER->yy_at_bol=1;
1166 yyextra->inSpecialComment=
FALSE;
1167 yyextra->inRoseComment=
FALSE;
1168 yyextra->insertCppCommentMarker=
false;
1169 yyextra->readLineCtx = Scan;
1179<ReadLine,CopyLine>"*" {
1182<ReadLine,CopyLine>{RL} {
1185<ReadLine,CopyLine>{RL}/{B}{CMD}"ilinebr"{B} {
1188<ReadLine,CopyLine>{RLopt}/\n {
1190 yyextra->insertCppCommentMarker=
false;
1191 BEGIN(yyextra->readLineCtx);
1193<CComment,CNComment,ReadLine>"\<" {
1196<CComment,CNComment,ReadLine>{CMD}{CMD}[~a-z_A-Z][a-z_A-Z0-9]*[ \t]* {
1200<CComment,ReadLine,IncludeFile>{CMD}("include"{OPTS}|"includedoc"{OPTS}*) {
1201 if (!
parseIncludeOptions(yyscanner,std::string_view{yytext,
static_cast<size_t>(yyleng)})) REJECT;
1202 yyextra->includeCtx = YY_START;
1203 yyextra->firstIncludeLine =
true;
1204 yyextra->insertCommentCol = yyextra->col;
1205 if (!yyextra->insertCppCommentMarker && (yyextra->includeCtx==ReadLine || yyextra->includeCtx==IncludeFile))
1207 yyextra->insertCppCommentMarker = yyextra->mlBrief;
1212<CComment,ReadLine,IncludeFile>{CMD}("snippet"{OPTS}|"snippetdoc"{OPTS}*) {
1213 if (!
parseIncludeOptions(yyscanner,std::string_view{yytext,
static_cast<size_t>(yyleng)})) REJECT;
1214 yyextra->includeCtx = YY_START;
1215 yyextra->firstIncludeLine =
true;
1216 yyextra->insertCommentCol = yyextra->col;
1217 if (!yyextra->insertCppCommentMarker && (yyextra->includeCtx==ReadLine || yyextra->includeCtx==IncludeFile))
1219 yyextra->insertCppCommentMarker = yyextra->mlBrief;
1224<IncludeDoc,SnippetDoc>{B}*
1225<IncludeDoc>{FILEMASK}|"\""[^\n\"]+"\"" {
1229 fileName=fileName.
mid(1,fileName.
length()-2);
1237 BEGIN(yyextra->includeCtx);
size_t length() const
Returns the length of the string, not counting the 0-terminator.
1240<SnippetDoc>({FILEMASK}|"\""[^\n\"]+"\""){B}+ {
1241 yyextra->snippetFileName=yytext;
1242 yyextra->snippetFileName=yyextra->snippetFileName.stripWhiteSpace();
1243 if (yyextra->snippetFileName ==
"this") yyextra->snippetFileName=yyextra->fileName;
1244 yyextra->snippetName =
"";
1245 BEGIN(SnippetDocTag);
1247<SnippetDocTag>[^\\@\n]+ {
1248 yyextra->snippetName += yytext;
1250<SnippetDocTag>{CMD} {
1251 yyextra->snippetName += yytext;
1253<SnippetDocTag>(\n|{CMD}"ilinebr") {
1254 for (
int i=(
int)yyleng-1;
i>=0;
i--) unput(yytext[
i]);
1255 yyextra->snippetName = yyextra->snippetName.stripWhiteSpace();
1256 QCString blockId =
"["+yyextra->snippetName+
"]";
1263 BEGIN(yyextra->includeCtx);
1267<IncludeDoc,SnippetDoc>\n {
1272 BEGIN(yyextra->includeCtx);
1274<IncludeDoc,SnippetDoc>. {
1276 BEGIN(yyextra->includeCtx);
1278<CComment,ReadLine,IncludeFile>{CMD}"cond"/[^a-z_A-Z0-9] {
1279 yyextra->condCtx = YY_START;
1282<CComment,ReadLine,IncludeFile>{CMD}"endcond"/[^a-z_A-Z0-9] {
1283 bool oldSkip=yyextra->skip;
1285 if (YY_START==CComment && oldSkip && !yyextra->skip)
1288 if (yyextra->lang!=SrcLangExt::Python &&
1289 yyextra->lang!=SrcLangExt::VHDL &&
1290 yyextra->lang!=SrcLangExt::Markdown &&
1291 yyextra->lang!=SrcLangExt::Fortran)
1293 yyextra->outBuf+=
'/';
1294 yyextra->outBuf+=
'*';
1296 if (yyextra->specialComment)
1298 yyextra->outBuf+=
'*';
1304<CondLine>[!()&| \ta-z_A-Z0-9.\-]+ {
1307<CComment,ReadLine,IncludeFile>{CMD}"cond"{WSopt}/\n {
1308 yyextra->condCtx=YY_START;
1316<CComment,ReadLine,IncludeFile,Verbatim,VerbatimCode>{CMD}[a-z_A-Z][a-z_A-Z0-9-]* {
1317 replaceAliases(yyscanner,yytext,YY_START==ReadLine && yyextra->readLineCtx==SComment);
1319<CComment,ReadLine,IncludeFile,Verbatim,VerbatimCode>{B}?{CMD}"ilinebr"{B}{CMD}"ialias{" {
1320 yyextra->lastBlockContext=YY_START;
1321 yyextra->blockCount=1;
1322 int extraSpace = (yytext[0]==
' '? 1:0);
1323 yyextra->aliasString=yytext+9+extraSpace;
1324 yyextra->aliasCmd=yytext+9+extraSpace;
1325 yyextra->lastEscaped=0;
1326 BEGIN( ReadAliasArgs );
1328<CComment,ReadLine,IncludeFile,Verbatim,VerbatimCode>{CMD}[a-z_A-Z][a-z_A-Z0-9-]*"{" {
1329 yyextra->lastBlockContext=YY_START;
1330 yyextra->blockCount=1;
1331 yyextra->aliasString=yytext;
1332 yyextra->aliasCmd=yytext;
1333 yyextra->lastEscaped=0;
1334 BEGIN( ReadAliasArgs );
1336<ReadAliasArgs>^[ \t]*"*" {
1338<ReadAliasArgs>^[ \t]*{CPPC}[/!]/[^\n]* {
1340<ReadAliasArgs>[^{}\n\\\*]+ {
1341 yyextra->aliasString+=yytext;
1342 yyextra->lastEscaped=
FALSE;
1344<ReadAliasArgs>"\\" {
1345 if (yyextra->lastEscaped) yyextra->lastEscaped=
FALSE;
1346 else yyextra->lastEscaped=
TRUE;
1347 yyextra->aliasString+=yytext;
1349<ReadAliasArgs>{CMD}("endverbatim"|"endiliteral"|"endlatexonly"|"endhtmlonly"|"endxmlonly"|"enddocbookonly"|"endrtfonly"|"endmanonly"|"f$"|"f]"|"f}"|"f)") {
1350 yyextra->aliasString+=yytext;
1351 if (yyextra->inVerbatim && &yytext[1]==yyextra->blockName)
1360 yyextra->inVerbatim=
false;
1361 BEGIN(yyextra->lastCommentContext);
1365 yyextra->aliasString+=yytext;
1366 yyextra->lastEscaped=
FALSE;
1367 if (yyextra->inVerbatim)
1371 BEGIN( yyextra->lastBlockContext );
1375 yyextra->aliasString+=yytext;
1376 if (!yyextra->lastEscaped) yyextra->blockCount++;
1377 yyextra->lastEscaped=
FALSE;
1380 yyextra->aliasString+=yytext;
1381 if (!yyextra->lastEscaped) yyextra->blockCount--;
1382 if (yyextra->blockCount==0)
1385 yyextra->lastBlockContext==ReadLine && yyextra->readLineCtx==SComment);
1386 BEGIN( yyextra->lastBlockContext );
1388 yyextra->lastEscaped=
FALSE;
1391 yyextra->aliasString+=yytext;
1392 yyextra->lastEscaped=
FALSE;
1399 yyextra->insertCppCommentMarker=
false;
1400 BEGIN(yyextra->readLineCtx);
1402<ReadLine>{CMD}{CMD} |
1417 if (YY_START == ReadAliasArgs)
1419 warn(yyextra->fileName,yyextra->lineNr,
1420 "Reached end of file while still searching closing '}}' of an alias argument (probable start: '{}')",
1423 else if (YY_START==Verbatim || YY_START==VerbatimCode)
1425 warn(yyextra->fileName,yyextra->lineNr,
1426 "Reached end of file while still searching closing '{}' of a verbatim block starting at line {}",
1427 yyextra->blockName,yyextra->verbatimLine);
1429 if (yyextra->includeStack.empty())
1431 yyextra->insertCppCommentMarker=
false;
1436 std::unique_ptr<commentcnv_FileState> &fs = yyextra->includeStack.back();
1437 YY_BUFFER_STATE oldBuf = YY_CURRENT_BUFFER;
1438 yy_switch_to_buffer(fs->bufState, yyscanner);
1439 yy_delete_buffer(oldBuf, yyscanner);
1440 BEGIN(fs->oldState);
1441 yyextra->fileName = fs->oldFileName;
1442 yyextra->lineNr = fs->oldLineNr;
1443 yyextra->inBuf = fs->oldFileBuf;
1444 yyextra->inBufPos = fs->oldFileBufPos;
1445 yyextra->includeCtx = fs->oldIncludeCtx;
1447 if (fs->oldRaiseLvl!=yyextra->raiseLevel)
1449 lineStr+=
"\\iraise " + std::to_string(fs->oldRaiseLvl)+
" ";
1451 if (fs->oldRaiseLbl!=yyextra->raiseLabel)
1453 lineStr+=
"\\iprefix \"" + fs->oldRaiseLbl +
"\" ";
1455 lineStr+=
"\\ilinebr ";
1456 yyextra->raiseLevel = fs->oldRaiseLvl;
1457 yyextra->raiseLabel = fs->oldRaiseLbl;
1459 yyextra->includeStack.pop_back();
QCString & setNum(short n)
std::string_view view() const
1471 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
1474 size_t optIdxStart =
s.find(
'{');
1475 size_t optIdxEnd = optIdxStart!=std::string::npos ?
s.find(
"}",optIdxStart+1) : std::string::npos;
1476 std::string cmdName;
1478 if (optIdxStart == std::string::npos)
1485 optList =
split(std::string{
s.substr(optIdxStart+1,optIdxEnd-optIdxStart-1)},
",");
1487 bool isDoc = cmdName==
"includedoc" || cmdName==
"snippetdoc";
1488 for (
const auto &opt : optList)
1499 for (
const auto &opt : optList)
1502 size_t posEqual = locOpt.find(
'=');
1503 std::string_view option = posEqual!=std::string::npos ?
stripWhiteSpace(locOpt.substr(0,posEqual)) : locOpt;
1504 std::string_view value = posEqual!=std::string::npos ?
stripWhiteSpace(locOpt.substr(posEqual+1)) : std::string_view();
1506 if (option==std::string_view{
"doc"} && value.empty())
1509 else if (option==std::string_view{
"raise"} && !value.empty())
1511 yyextra->raiseIncrement = atoi(value.data());
1514 warn(yyextra->fileName,yyextra->lineNr,
"Raising section level from {} to {}, exceeds allowed range [0-{}], adjusting",
1519 else if (option==std::string_view{
"prefix"} && !value.empty())
1521 yyextra->raisePrefix = value;
1525 warn(yyextra->fileName,yyextra->lineNr,
"Unsupported option '{}' for {} command",option, cmdName);
1536 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
1537 if (
s.empty())
return;
1539 size_t len =
s.length();
1542 while (p<len && (c=
s[p]) && (c==
' ' || c==
'\t' || c==
'\n'))
1545 if (c==
'\n') { yyextra->lineNr++; yyextra->col=0; }
else { yyextra->col++; }
1550 while (p<len && (c=
s[p]) && (c==
'/' || c==
'!' || c==
'#'))
1554 if (p<len &&
s[p]==
'<')
1568 yyextra->outBuf+=
' ';
1572 if (blanks>1) { yyextra->outBuf+=
'*'; yyextra->col++; }
1573 yyextra->outBuf+=
' ';
1577 yyextra->outBuf+=
s.substr(p);
1578 yyextra->col+=
s.substr(p).length();
1590 else if (c==
'\t') col+=tabSize-(col%tabSize);
1599 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
1600 size_t len =
s.length();
1603 for (
size_t i=0;
i<len;
i++)
1608 yyextra->outBuf+=
'\n';
1613 yyextra->col+=tabSize-(yyextra->col%tabSize);
1624 for (
size_t i=0;
i<len;
i++)
1628 case '\n': yyextra->col=0;
1630 yyextra->lineNr++;
break;
1631 case '\t': yyextra->col+=tabSize-(yyextra->col%tabSize);
break;
1632 default: yyextra->col++;
break;
1645 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
1646 while (!yyextra->commentStack.empty()) yyextra->commentStack.pop();
1651 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
1654 bool expResult = prs.
parse(yyextra->fileName,yyextra->lineNr,sectId);
1655 yyextra->condStack.emplace(yyextra->lineNr,sectId,yyextra->skip);
1664 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
1665 if (yyextra->condStack.empty())
1667 warn(yyextra->fileName,yyextra->lineNr,
"Found \\endcond command without matching \\cond");
1668 yyextra->skip=
FALSE;
1674 yyextra->condStack.pop();
1681 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
1682 bool oldSkip=yyextra->skip;
1684 if ((yyextra->condCtx==CComment || yyextra->readLineCtx==SComment) &&
1685 !oldSkip && yyextra->skip)
1687 if (yyextra->lang!=SrcLangExt::Python &&
1688 yyextra->lang!=SrcLangExt::VHDL &&
1689 yyextra->lang!=SrcLangExt::Markdown &&
1690 yyextra->lang!=SrcLangExt::Fortran)
1692 yyextra->outBuf+=
'*';
1693 yyextra->outBuf+=
'/';
1697 if (yyextra->readLineCtx==SComment)
1703 BEGIN(yyextra->condCtx);
1718 int m1 = text.
find(marker);
1719 if (m1==-1)
return result;
1720 int m2 = text.
find(marker,m1+
static_cast<int>(marker.
length()));
1721 if (m2==-1)
return result;
1725 while (!found && (
i=text.
find(
'\n',p))!=-1)
1727 found = (p<=m1 && m1<
i);
1735 while ((
i=text.
find(
'\n',p))!=-1)
1755 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
1756 int startCol=yyextra->blockHeadCol;
1757 int contentCol=yyextra->insertCommentCol;
1758 int markerSpace=contentCol-startCol;
1762 if (yyextra->lang==SrcLangExt::Python)
1764 if (yyextra->pythonDocString)
1773 else if (yyextra->lang==SrcLangExt::Fortran)
1777 else if (yyextra->lang==SrcLangExt::Markdown)
1781 else if (yyextra->insertCppCommentMarker)
1796 for (;
i<startCol;
i++)
1800 if (
static_cast<int>(marker.length())<=markerSpace && !yyextra->firstIncludeLine)
1805 for (;
i<contentCol;
i++)
1809 yyextra->firstIncludeLine =
false;
1815 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
1823 warn_doc_error(yyextra->fileName,yyextra->lineNr,
"included file name '{}' is ambiguous"
1826 bool alreadyProcessed = std::any_of(
1827 yyextra->includeStack.begin(),
1828 yyextra->includeStack.end(),
1829 [&absFileName,&blockId](
const auto &lfs)
1830 { return lfs->fileName==absFileName && lfs->blockId==blockId; }
1833 if (alreadyProcessed)
1837 warn_doc_error(yyextra->fileName,yyextra->lineNr,
"recursive usage of '\\snippet{{doc}}' block with name '{}' and file name '{}', skipping",
1838 blockId,absFileName);
1842 warn_doc_error(yyextra->fileName,yyextra->lineNr,
"recursive usage of '\\include{{doc}}' with file name '{}', skipping", absFileName);
1847 auto fs = std::make_unique<commentcnv_FileState>();
1850 warn_doc_error(yyextra->fileName,yyextra->lineNr,
"\\{}{{doc}} file '{}' could not be read",blockId.
isEmpty()?
"include":
"snippet",absFileName);
1861 warn_doc_error(yyextra->fileName,yyextra->lineNr,
"block marked with {} for \\snippet{{doc}} should appear twice in file {}, found it {:d} times, skipping",
1862 blockId,absFileName,count);
1868 fs->fileBuf.clear();
1871 fs->fileBuf.append(incText.
str());
1874 int oldRaiseLevel = yyextra->raiseLevel;
1875 QCString oldRaiseLabel = yyextra->raiseLabel;
1876 yyextra->raiseLevel+=yyextra->raiseIncrement;
1877 yyextra->raiseLabel+=yyextra->raisePrefix;
1878 QCString lineStr=
" \\ifile \""+absFileName+
"\" \\iline " + std::to_string(lineNr)+
" ";
1879 if (yyextra->raiseLevel>0)
1881 lineStr+=
"\\iraise " + std::to_string(yyextra->raiseLevel)+
" ";
1883 if (!yyextra->raiseLabel.isEmpty())
1885 lineStr+=
"\\iprefix \"" + yyextra->raiseLabel +
"\" ";
1887 lineStr+=
"\\ilinebr ";
1890 fs->fileName = absFileName;
1891 fs->bufState = YY_CURRENT_BUFFER;
1892 fs->oldLineNr = yyextra->lineNr;
1893 fs->oldFileName = yyextra->fileName;
1894 fs->oldState = yyextra->includeCtx;
1895 fs->oldFileBuf = yyextra->inBuf;
1896 fs->oldFileBufPos = yyextra->inBufPos;
1897 fs->oldIncludeCtx = yyextra->includeCtx;
1898 fs->oldRaiseLvl = oldRaiseLevel;
1899 fs->oldRaiseLbl = oldRaiseLabel;
1900 fs->blockId = blockId;
1901 yy_switch_to_buffer(yy_create_buffer(
nullptr,
YY_BUF_SIZE, yyscanner),yyscanner);
1902 yyextra->fileName = absFileName;
1903 yyextra->lineNr = lineNr;
1904 yyextra->inBuf = &fs->fileBuf;
1905 yyextra->inBufPos = 0;
1906 yyextra->includeStack.push_back(std::move(fs));
1912 warn_doc_error(yyextra->fileName,yyextra->lineNr,
"\\{}{{doc}} file '{}' not found",blockId.
isEmpty()?
"include":
"snippet",inc);
1923 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
1924 if (
s.empty())
return;
1925 size_t pos =
s.find(
'{');
1926 std::string cmd {
s.substr(1, pos!=std::string::npos ? pos-1 :
s.length()-1) };
1927 auto &expAlias = yyextra->expandedAliases;
1928 if (std::find(expAlias.begin(),expAlias.end(),cmd)!=std::end(expAlias))
1933 else if (cmd==
"ialias")
1935 if (
s.length()>cmd.length()+3)
1937 std::string value {
s.substr(cmd.length()+2,
s.length()-cmd.length()-3) };
1939 expAlias.erase(std::remove(expAlias.begin(),expAlias.end(),value),expAlias.end());
1944 if (yyextra->inVerbatim)
1947 std::string blk = yyextra->blockName.str();
1948 assert(!blk.empty());
1949 bool isNamedCommand=
isId(blk[0]);
1952 while ((
i=result.find(blk,p))!=std::string::npos && !found)
1954 found = !isNamedCommand ||
1955 (
i>0 && (result[
i-1]==
'\\' || result[
i-1]==
'@') && !
isId(result[
i+blk.length()]));
1956 p =
i+yyextra->blockName.length();
1974 expAlias.push_back(cmd);
1976 result +=
" \\ilinebr \\ialias{";
1979 for (
int i=(
int)result.length()-1;
i>=0;
i--)
1993 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
1994 int bytesInBuf =
static_cast<int>(yyextra->inBuf->size())-yyextra->inBufPos;
1995 int bytesToCopy = std::min(max_size,bytesInBuf);
1996 memcpy(buf,yyextra->inBuf->data()+yyextra->inBufPos,bytesToCopy);
1997 yyextra->inBufPos+=bytesToCopy;
2003 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
2004 if (yyextra->mlBrief || yyextra->skip)
2012 if (
i==yyextra->blockHeadCol ||
i+1==yyextra->blockHeadCol)
2019 for (
i=(
int)yyleng-1;
i>=0;
i--) unput(yytext[
i]);
2020 yyextra->inSpecialComment=
FALSE;
2037 commentcnvYYlex_init_extra(&extra,&yyscanner);
2041 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
2043 yyextra->inBufPos = 0;
2046 yyextra->skip =
FALSE;
2047 yyextra->fileName = fileName;
2049 yyextra->pythonDocString =
FALSE;
2050 yyextra->lineNr = 1;
2051 yyextra->raiseLevel = 0;
2052 yyextra->raiseLabel =
"";
2053 yyextra->raiseIncrement = 0;
2054 yyextra->raisePrefix =
"";
2055 yyextra->insertCppCommentMarker=
false;
2056 yyextra->expandedAliases.clear();
2057 while (!yyextra->condStack.empty()) yyextra->condStack.pop();
2059 yyextra->vhdl =
FALSE;
2062 yyextra->isFixedForm =
FALSE;
2063 if (yyextra->lang==SrcLangExt::Fortran)
2069 if (yyextra->lang==SrcLangExt::Markdown)
2071 yyextra->nestingCount=0;
2073 yyextra->commentStack.push(yyextra->lineNr);
2080 while (!yyextra->condStack.empty())
2085 warn(yyextra->fileName,ctx.
lineNr,
"Conditional section{}does not have "
2086 "a corresponding \\endcond command within this file.",sectionInfo.
data());
2087 yyextra->condStack.pop();
2089 if (yyextra->nestingCount>0 && yyextra->lang!=SrcLangExt::Markdown && yyextra->lang!=SrcLangExt::Fortran)
2093 while (!yyextra->commentStack.empty())
2095 int lineNr = yyextra->commentStack.top();
2096 if (!first) lines +=
", ";
2099 yyextra->commentStack.pop();
2101 warn(yyextra->fileName,yyextra->lineNr,
"Reached end of file while still inside a (nested) comment. "
2102 "Nesting level {} (possible line reference(s): {})",yyextra->nestingCount,lines);
2104 yyextra->nestingCount = 0;
2108 "output=[\n{}]\n-----------\n",fileName,yyextra->outBuf
2111 commentcnvYYlex_destroy(yyscanner);
2117#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)