267 {NUMBER} {
268 if (yyextra->lang!=SrcLangExt::Cpp) REJECT;
270 }
271<Scan>{RAWBEGIN} {
272 if (yyextra->lang!=SrcLangExt::Cpp) REJECT;
274 BEGIN(RawString);
275 }
276<Scan>[^"'!\/\n\\#,\-=; \t@$]* { /* eat anything that is not " / , or \n */
278 }
279<Scan>[,= ;\t] { /* eat , so we have a nice separator in long initialization lines */
281 }
282<Scan>"'''"! |
283<Scan>"\"\"\""! { /* start of python long comment */
284 if (yyextra->lang!=SrcLangExt::Python)
285 {
286 REJECT;
287 }
288 else
289 {
290 yyextra->pythonDocString = true;
291 yyextra->pythonDocStringChar = yytext[0];
292 yyextra->nestingCount=1;
295 BEGIN(CComment);
296 yyextra->commentStack.push(yyextra->lineNr);
297 }
298 }
299<Scan>"'''" |
300<Scan>"\"\"\"" { /* start of python long comment */
301 if (yyextra->lang!=SrcLangExt::Python)
302 {
303 REJECT;
304 }
306 {
307 REJECT;
308 }
309 else
310 {
311 yyextra->pythonDocString = true;
312 yyextra->pythonDocStringChar = yytext[0];
313 yyextra->nestingCount=1;
316 BEGIN(CComment);
317 yyextra->commentStack.push(yyextra->lineNr);
318 }
319 }
320<Scan>{B}*![><!]/.*\n {
321 if (yyextra->lang!=SrcLangExt::Fortran)
322 {
323 REJECT;
324 }
325 else
326 {
327 yyextra->nestingCount=0;
329 yyextra->specialComment=true;
331 yyextra->blockHeadCol=yyextra->col-2;
332 BEGIN(CComment);
333 yyextra->commentStack.push(yyextra->lineNr);
334 }
335 }
336<Scan>[Cc\*][><!]/.*\n {
337 if (yyextra->lang!=SrcLangExt::Fortran)
338 {
339 REJECT;
340 }
341 else
342 {
343
344 if (yyextra->isFixedForm && (yyextra->col == 0))
345 {
346 yyextra->nestingCount=0;
348 yyextra->specialComment=true;
350 yyextra->blockHeadCol=yyextra->col-1;
351 BEGIN(CComment);
352 yyextra->commentStack.push(yyextra->lineNr);
353 }
354 else
355 {
356 REJECT;
357 }
358 }
359 }
360<Scan>!.*\n {
361 if (yyextra->lang!=SrcLangExt::Fortran)
362 {
363 REJECT;
364 }
365 else
366 {
368 }
369 }
370<Scan>[Cc\*].*\n {
371 if (yyextra->lang!=SrcLangExt::Fortran)
372 {
373 REJECT;
374 }
375 else
376 {
377 if (yyextra->col == 0)
378 {
380 }
381 else
382 {
383 REJECT;
384 }
385 }
386 }
387<Scan>[$]?"@\"" { /* start of an interpolated verbatim C# string */
388 if (yyextra->lang!=SrcLangExt::CSharp) REJECT
390 yyextra->stringContext = YY_START;
391 BEGIN(SkipVerbString);
392 }
393<Scan>"\"" { /* start of a string */
395 yyextra->stringContext = YY_START;
396 BEGIN(SkipString);
397 }
398<Scan>' {
400 yyextra->charContext = YY_START;
401 if (yyextra->lang!=SrcLangExt::VHDL)
402 {
403 BEGIN(SkipChar);
404 }
405 }
406<Scan>\n { /* new line */
408 }
409<Scan>{CPPC}[!/]/.*\n[ \t]*{CPPC}[!/][ \t]*{CMD}"}" { // see bug #8731, don't treat multiline C++ comment as detailed description
410
411 yyextra->inSpecialComment=true;
412 yyextra->blockHeadCol=yyextra->col+1;
413 yyextra->insertCppCommentMarker=true;
415 yyextra->readLineCtx=YY_START;
416 BEGIN(ReadLine);
417 }
418<Scan>{CPPC}"!"/.*\n[ \t]*{CPPC}[\/!][^\/] | /* start C++ style special comment block */
419<Scan>({CPPC}"/"[/]*)/[^/].*\n[ \t]*{CPPC}[\/!][^\/] { /* start C++ style special comment block */
420 if (yyextra->mlBrief)
421 {
422 REJECT;
423 }
424 else
425 {
426 int i=3;
427 if (yytext[2]=='/')
428 {
429 while (i<(int)yyleng && yytext[i]=='/') i++;
430 }
431 yyextra->blockHeadCol=yyextra->col+1;
432 yyextra->blockHeadPos=yyextra->skip ? std::string::npos : yyextra->outBuf.size();
433 if (yytext[2] == '!')
434 {
436 }
437 else
438 {
440 }
442 yyextra->inSpecialComment=true;
443
444 yyextra->readLineCtx=SComment;
445 BEGIN(ReadLine);
446 }
447 }
448<Scan>{CPPC}"##Documentation"{ANYopt}/\n { /* Start of Rational Rose ANSI C++ comment block */
449 if (yyextra->mlBrief) REJECT;
450 int i=17;
451 yyextra->blockHeadCol=yyextra->col+1;
452 yyextra->blockHeadPos=yyextra->skip ? std::string::npos : yyextra->outBuf.size();
455 yyextra->inRoseComment=true;
456 BEGIN(SComment);
457 }
458<Scan>{CPPC}[!\/]/.*\n[ \t]*{CPPC}[|\/][ \t]*{CMD}"}" { // next line contains an end marker, see bug 752712
459 yyextra->inSpecialComment=yytext[2]=='/' || yytext[2]=='!';
460 if (yyextra->inSpecialComment)
461 {
462 yyextra->blockHeadCol=yyextra->col+1;
463 }
465 yyextra->readLineCtx=YY_START;
466 BEGIN(ReadLine);
467 }
468<Scan>{CPPC}[!/]/.*\n { /* one line special C++ comment */
469 yyextra->inSpecialComment=true;
470 yyextra->blockHeadCol=yyextra->col+1;
471 yyextra->insertCppCommentMarker=true;
473 yyextra->readLineCtx=YY_START;
474 BEGIN(ReadLine);
475 }
476<Scan>{CPPC}/.*\n { /* one line normal C++ comment */
477 yyextra->inSpecialComment=false;
479 yyextra->readLineCtx=YY_START;
480 BEGIN(CopyLine);
481 }
482<Scan>{CCS}{CCE} { /* avoid matching next rule for empty C comment, see bug 711723 */
484 }
485<Scan>{CCS}[*!]? { /* start of a C comment */
486 if (yyextra->lang==SrcLangExt::Python)
487 {
488 REJECT;
489 }
490 yyextra->specialComment=(int)yyleng==3;
491 yyextra->nestingCount=1;
494 if (yyextra->specialComment)
495 {
496 yyextra->blockHeadCol=0;
497 BEGIN(CComment);
498 }
499 else
500 {
501 BEGIN(CNComment);
502 }
503 yyextra->commentStack.push(yyextra->lineNr);
504 }
505<Scan>"#"[^\n]*\n {
506 if (yyextra->lang!=SrcLangExt::PHP)
507 {
508 REJECT;
509 }
511 }
512<Scan>"#"("#")? {
513 if (yyextra->lang!=SrcLangExt::Python)
514 {
515 REJECT;
516 }
517 else
518 {
519 yyextra->nestingCount=0;
521 yyextra->specialComment=(int)yyleng==2;
522 if (yyextra->specialComment)
523 {
524 yyextra->blockHeadCol=yyextra->col;
525 }
526 yyextra->commentStack.push(yyextra->lineNr);
528 BEGIN(CComment);
529 }
530 }
531<Scan>"--"[^!][^\n]* {
532 if (yyextra->lang!=SrcLangExt::VHDL)
533 {
534 REJECT;
535 }
536 else
537 {
539 }
540 }
541<Scan>"--!" {
542 if (yyextra->lang!=SrcLangExt::VHDL)
543 {
544 REJECT;
545 }
546 else
547 {
548 yyextra->specialComment=true;
549 yyextra->blockHeadCol=yyextra->col;
550 yyextra->vhdl = true;
551 yyextra->nestingCount=0;
553 yyextra->commentStack.push(yyextra->lineNr);
555 BEGIN(CComment);
556 }
557 }
558<Scan>{B}*![><!] {
559 if (yyextra->lang!=SrcLangExt::Fortran)
560 {
561 REJECT;
562 }
563 else
564 {
565 yyextra->nestingCount=0;
567 yyextra->specialComment=true;
568 yyextra->blockHeadCol=yyextra->col;
569 yyextra->commentStack.push(yyextra->lineNr);
571 BEGIN(CComment);
572 }
573 }
574<RawString>{RAWEND} {
577 {
578 BEGIN(Scan);
579 }
580 }
DString extractEndRawStringDelimiter(const char *rawEnd)
581<RawString>[^)\n]+ { copyToOutput(yyscanner,yytext,yyleng); }
582<RawString>\n { copyToOutput(yyscanner,yytext,yyleng); }
583<RawString>. { copyToOutput(yyscanner,yytext,yyleng); }
584
585<CComment,CNComment,ReadLine,IncludeFile>{MAILADDR} |
586<CComment,CNComment,ReadLine,IncludeFile>"<"{MAILADDR}">" { // Mail address, to prevent seeing e.g x@code-factory.org as start of a code block
588 }
589<CComment,IncludeFile>"{"[ \t]*"@code"/[ \t\n] {
591 yyextra->lastCommentContext = YY_START;
592 yyextra->javaBlock=1;
593 yyextra->blockName=
DString(
"end")+&yytext[1];
594 yyextra->inVerbatim=true;
595 yyextra->verbatimLine=yyextra->lineNr;
596 BEGIN(VerbatimCode);
597 }
598<CComment,IncludeFile>"{"[ \t]*"@literal"/[ \t\n] {
600 yyextra->lastCommentContext = YY_START;
601 yyextra->javaBlock=1;
602 yyextra->blockName=
DString(
"end")+&yytext[1];
603 yyextra->inVerbatim=true;
604 yyextra->verbatimLine=yyextra->lineNr;
605 BEGIN(VerbatimCode);
606 }
607<CComment,ReadLine,IncludeFile>{CMD}"ilinebr"[ \t]+("```"[`]*|"~~~"[~]*) { /* start of markdown code block */
609 {
610 REJECT;
611 }
613 yyextra->lastCommentContext = YY_START;
614 yyextra->javaBlock=0;
616 yyextra->inVerbatim=true;
617 yyextra->verbatimLine=yyextra->lineNr;
618 BEGIN(VerbatimCode);
619 }
DString right(size_t len) const
620<CComment,ReadLine,IncludeFile>^[ \t]*("```"[`]*|"~~~"[~]*) { /* start of markdown code block */
622 {
623 REJECT;
624 }
626 yyextra->lastCommentContext = YY_START;
627 yyextra->javaBlock=0;
629 yyextra->inVerbatim=true;
630 yyextra->verbatimLine=yyextra->lineNr;
631 BEGIN(VerbatimCode);
632 }
DString left(size_t len) const
633<CComment,ReadLine,IncludeFile>{CMD}("dot"|"code"|"msc"|"startuml"|"mermaid")/[^a-z_A-Z0-9] { /* start of a verbatim block */
635 if (yyextra->inSpecialComment || yyextra->specialComment || yyextra->lang==SrcLangExt::Markdown)
636 {
637 yyextra->lastCommentContext = YY_START;
638 yyextra->javaBlock=0;
639 if (
dstrcmp(&yytext[1],
"startuml")==0)
640 {
641 yyextra->blockName="enduml";
642 }
643 else
644 {
645 yyextra->blockName=
DString(
"end")+&yytext[1];
646 }
647 yyextra->inVerbatim=true;
648 yyextra->verbatimLine=yyextra->lineNr;
649 BEGIN(VerbatimCode);
650 }
651 }
int dstrcmp(const char *str1, const char *str2)
652<CComment,ReadLine,IncludeFile>"\\`" {
654 }
655<CComment,ReadLine,IncludeFile>"```" { // skip ``` if not at the start of the line
657 }
658<CComment,ReadLine,IncludeFile>"`"{1,2} {
660 {
661 REJECT;
662 }
664 if (yyextra->inSpecialComment || yyextra->specialComment || yyextra->lang==SrcLangExt::Markdown)
665 {
666 yyextra->lastCommentContext = YY_START;
667 yyextra->javaBlock=0;
668 yyextra->blockName=yytext;
669 yyextra->inVerbatim=true;
670 yyextra->verbatimLine=yyextra->lineNr;
671 BEGIN(VerbatimCode);
672 }
673 }
674<CComment,ReadLine,IncludeFile>{CMD}("f$"|"f["|"f{"|"f(") {
676 if (yyextra->inSpecialComment || yyextra->specialComment || yyextra->lang==SrcLangExt::Markdown)
677 {
678 yyextra->blockName=&yytext[1];
679 if (yyextra->blockName.at(1)=='[')
680 {
681 yyextra->blockName.at(1)=']';
682 }
683 else if (yyextra->blockName.at(1)=='{')
684 {
685 yyextra->blockName.at(1)='}';
686 }
687 else if (yyextra->blockName.at(1)=='(')
688 {
689 yyextra->blockName.at(1)=')';
690 }
691 yyextra->lastCommentContext = YY_START;
692 yyextra->inVerbatim=true;
693 yyextra->verbatimLine=yyextra->lineNr;
694 BEGIN(Verbatim);
695 }
696 }
697<CComment,ReadLine,IncludeFile>"<!--!" { /* HTML comment doxygen command*/
698 if (yyextra->inVerbatim) REJECT;
699
700 yyextra->inHtmlDoxygenCommand=true;
701 }
702<CComment,ReadLine,IncludeFile>"-->" { /* potential end HTML comment doxygen command*/
703 if (yyextra->inHtmlDoxygenCommand)
704 {
705 yyextra->inHtmlDoxygenCommand=false;
706 }
707 else
708 {
710 }
711 }
712<CComment,ReadLine,IncludeFile>"<!--" { /* HTML comment */
714 if (yyextra->inSpecialComment || yyextra->specialComment || yyextra->lang==SrcLangExt::Markdown)
715 {
716 yyextra->blockName="-->";
717 yyextra->lastCommentContext = YY_START;
718 yyextra->inVerbatim=true;
719 yyextra->verbatimLine=yyextra->lineNr;
720 BEGIN(Verbatim);
721 }
722 }
723<CComment,ReadLine,IncludeFile>{CMD}("verbatim"|"iliteral"|"latexonly"|"htmlonly"|"xmlonly"|"docbookonly"|"rtfonly"|"manonly")/[^a-z_A-Z0-9] { /* start of a verbatim block */
725 if (yyextra->inSpecialComment || yyextra->specialComment || yyextra->lang==SrcLangExt::Markdown)
726 {
727 yyextra->blockName=
DString(
"end")+&yytext[1];
728 yyextra->lastCommentContext = YY_START;
729 yyextra->inVerbatim=true;
730 yyextra->verbatimLine=yyextra->lineNr;
731 BEGIN(Verbatim);
732 }
733 }
734<Scan>"\\\"" { /* escaped double quote */
736 }
737<Scan>"\\\\" { /* escaped backslash */
739 }
740<Scan>. { /* any other character */
742 }
743<Verbatim>{CMD}("endverbatim"|"endiliteral"|"endlatexonly"|"endhtmlonly"|"endxmlonly"|"enddocbookonly"|"endrtfonly"|"endmanonly"|"f$"|"f]"|"f}"|"f)") { /* end of verbatim block */
745 if (&yytext[1]==yyextra->blockName)
746 {
747 yyextra->inVerbatim=false;
748 BEGIN(yyextra->lastCommentContext);
749 }
750 }
751<Verbatim>"-->" {
753 if (yytext==yyextra->blockName)
754 {
755 yyextra->inVerbatim=false;
756 BEGIN(yyextra->lastCommentContext);
757 }
758 }
759<VerbatimCode>"{" {
760 if (yyextra->javaBlock==0)
761 {
762 REJECT;
763 }
764 else
765 {
766 yyextra->javaBlock++;
768 }
769 }
770<VerbatimCode>"}" {
771 if (yyextra->javaBlock==0)
772 {
773 REJECT;
774 }
775 else
776 {
777 yyextra->javaBlock--;
778 if (yyextra->javaBlock==0)
779 {
781 yyextra->inVerbatim=false;
782 BEGIN(yyextra->lastCommentContext);
783 }
784 else
785 {
787 }
788 }
789 }
790<VerbatimCode>("```"[`]*|"~~~"[~]*) { /* end of markdown code block */
791 if (yytext[0]=='`' && (yyextra->blockName=="`" || yyextra->blockName=="``"))
792 {
793
795 }
796 else
797 {
799 if (yytext[0]==yyextra->blockName[0])
800 {
801 yyextra->inVerbatim=false;
802 BEGIN(yyextra->lastCommentContext);
803 }
804 }
805 }
806<VerbatimCode>"''" {
809 {
810 yyextra->inVerbatim=false;
811 BEGIN(yyextra->lastCommentContext);
812 }
813 }
814<VerbatimCode>"'" {
817 {
818 yyextra->inVerbatim=false;
819 BEGIN(yyextra->lastCommentContext);
820 }
821 }
822<VerbatimCode>"`"{1,2} {
824 if (yytext==yyextra->blockName)
825 {
826 yyextra->inVerbatim=false;
827 BEGIN(yyextra->lastCommentContext);
828 }
829 }
830<VerbatimCode>{CMD}("enddot"|"endcode"|"endmsc"|"enduml"|"endmermaid")/("{")? { // end of verbatim block
832 if (&yytext[1]==yyextra->blockName)
833 {
834 yyextra->inVerbatim=false;
835 BEGIN(yyextra->lastCommentContext);
836 }
837 }
838<VerbatimCode>^[ \t]*{CPPC}[\!\/]? { /* skip leading comments */
839 if (!yyextra->inSpecialComment || yyextra->mlBrief)
840 {
842 }
843 else
844 {
845 int l=0;
846 while (yytext[l]==' ' || yytext[l]=='\t')
847 {
848 l++;
849 }
851 if (yyleng-l==3)
852 {
854 }
855 else
856 {
858 }
859 }
860 }
861<Verbatim,VerbatimCode>[^`'~@\/\-\\\n{}]* { /* any character not a backslash or new line or } */
863 }
864<Verbatim,VerbatimCode>[^`'~@\/\-\\\n{}]+/\n{B}*"//" {
865 if (yyextra->lastCommentContext!=ReadLine)
866 {
867 REJECT;
868 }
869 else
870 {
872 }
873 }
874<Verbatim,VerbatimCode>[^`'~@\/\-\\\n{}]+/\n { /* premature end of comment block */
875 if (yyextra->lastCommentContext==ReadLine)
876 {
877 yyextra->inVerbatim=false;
878 BEGIN(yyextra->lastCommentContext);
879 }
881 }
882<Verbatim,VerbatimCode>\n { /* new line in verbatim block */
884 if (yyextra->lastCommentContext == IncludeFile)
885 {
887 }
888 }
889<Verbatim>^[ \t]*{CPPC}[/!] {
890 if (yyextra->blockName=="enddot" || yyextra->blockName=="endmsc" || yyextra->blockName=="enduml" || yyextra->blockName.at(0)=='f')
891 {
892
893 int l=0;
894 while (yytext[l]==' ' || yytext[l]=='\t')
895 {
896 l++;
897 }
900 }
901 else
902 {
903 REJECT;
904 }
905 }
906<Verbatim,VerbatimCode>. { /* any other character */
908 }
909<SkipString>\\. { /* escaped character in string */
910 if (yyextra->lang==SrcLangExt::Fortran || yyextra->lang==SrcLangExt::VHDL)
911 {
912 unput(yytext[1]);
914 }
915 else
916 {
918 }
919 }
920<SkipString>"\"" { /* end of string */
922 BEGIN(yyextra->stringContext);
923 }
924<SkipString>. { /* any other string character */
926 }
927<SkipString>\n { /* new line inside string (illegal for some compilers) */
929 }
930<SkipVerbString>[^"\n]+ {
932 }
933<SkipVerbString>\"\" { // escaped quote
935 }
936<SkipVerbString>"\"" { /* end of string */
938 BEGIN(yyextra->stringContext);
939 }
940<SkipVerbString>. {
942 }
943<SkipVerbString>\n {
945 }
946<SkipChar>\\. { /* escaped character */
947 if (yyextra->lang==SrcLangExt::Fortran || yyextra->lang==SrcLangExt::VHDL)
948 {
949 unput(yytext[1]);
951 }
952 else
953 {
955 }
956 }
957<SkipChar>' { /* end of character literal */
959 BEGIN(yyextra->charContext);
960 }
961<SkipChar>. { /* any other string character */
963 }
964<SkipChar>\n { /* new line character */
966 }
967
968<CComment,CNComment>[^ `~<\\!@*\n{\"'\/-`]* { /* anything that is not a '*' or command */
970 }
971<CComment,CNComment>^{B}*"*"+[^*\/<\\@\n{\"`]* { /* stars without slashes */
972 if (yyextra->lang==SrcLangExt::Markdown) REJECT;
974 if (yyextra->col>yyextra->blockHeadCol)
975 {
976
977 yyextra->blockHeadCol=yyextra->col;
978 }
980 }
981<CComment>"'''" |
982<CComment>"\"\"\"" { /* end of Python docstring */
983 if (yyextra->lang!=SrcLangExt::Python)
984 {
985 REJECT;
986 }
987 else if (yyextra->pythonDocStringChar != yytext[0])
988 {
990 }
991 else
992 {
993 yyextra->nestingCount--;
994 yyextra->pythonDocString = false;
995 yyextra->pythonDocStringChar = '\0';
997 BEGIN(Scan);
998 }
999 }
1000<CComment,CNComment>\n { /* new line in comment */
1002
1003 if (yyextra->lang==SrcLangExt::Fortran)
1004 {
1005 BEGIN(Scan);
1006 }
1007 }
1008<CComment,CNComment>"/""/"+/"*/" { /* we are already in C-comment so not a start of a nested comment but
1009 * just the
end of the comment (the
end part is handled later). */
1011 }
DirIterator end(const DirIterator &) noexcept
1012<CComment,CNComment>"/"+"*" { /* nested C comment */
1013 if (yyextra->lang==SrcLangExt::Python ||
1014 yyextra->lang==SrcLangExt::Markdown)
1015 {
1016 REJECT;
1017 }
1018 yyextra->nestingCount++;
1019 yyextra->commentStack.push(yyextra->lineNr);
1021 }
1022<CComment,CNComment>^{B}*"*"+"/" |
1023<CComment,CNComment>"*"+"/" { /* end of C comment */
1024 if (yyextra->lang==SrcLangExt::Python ||
1025 yyextra->lang==SrcLangExt::Markdown)
1026 {
1027 REJECT;
1028 }
1029 else
1030 {
1032 yyextra->nestingCount--;
1033 if (yyextra->nestingCount<=0)
1034 {
1035 BEGIN(Scan);
1036 }
1037 else
1038 {
1039
1040 yyextra->commentStack.pop();
1041 }
1042 }
1043 }
1044
1045<CComment,CNComment>"\n"/[ \t]*"#" {
1046 if (yyextra->lang!=SrcLangExt::VHDL)
1047 {
1048 REJECT;
1049 }
1050 else
1051 {
1052 if (yyextra->vhdl)
1053 {
1054 yyextra->vhdl = false;
1056 BEGIN(Scan);
1057 }
1058 else
1059 {
1060 REJECT;
1061 }
1062 }
1063 }
1064<CComment,CNComment>"\n"/[ \t]*"-" {
1065 if (yyextra->lang!=SrcLangExt::Python || yyextra->pythonDocString)
1066 {
1067 REJECT;
1068 }
1069 else
1070 {
1072 BEGIN(Scan);
1073 }
1074 }
1075<CComment,CNComment>"\n"/[ \t]*[^ \t#\-] {
1076 if (yyextra->lang==SrcLangExt::Python)
1077 {
1078 if (yyextra->pythonDocString)
1079 {
1080 REJECT;
1081 }
1082 else
1083 {
1085 BEGIN(Scan);
1086 }
1087 }
1088 else if (yyextra->lang==SrcLangExt::VHDL)
1089 {
1090 if (yyextra->vhdl)
1091 {
1092 yyextra->vhdl = false;
1094 BEGIN(Scan);
1095 }
1096 else
1097 {
1098 REJECT;
1099 }
1100 }
1101 else
1102 {
1103 REJECT;
1104 }
1105 }
1106
1107<CComment,CNComment>"'" {
1108 yyextra->charContext = YY_START;
1110 BEGIN(SkipChar);
1111 }
1112<CComment,CNComment>"\"" {
1113 yyextra->stringContext = YY_START;
1115 BEGIN(SkipString);
1116 }
1117 */
1118<CComment,CNComment>{CMD}"~"[a-z_A-Z-]* { // language switch command
1119 if (yyextra->lang!=SrcLangExt::Markdown) REJECT;
1121 if (!langId.
empty() &&
1123 {
1125 {
1126 warn(yyextra->fileName,yyextra->lineNr,
1128 }
1129 BEGIN(SkipLang);
1130 }
1131 }
#define Config_getEnumAsString(name)
#define Config_isAvailableEnum(name, value)
int dstricmp(const char *s1, const char *s2)
1132<CComment,CNComment>{CMD}{CMD} |
1133<CComment,CNComment>. {
1135 }
1136<SkipLang>{CMD}"~"[a-zA-Z-]* { /* language switch */
1139 {
1140 warn(yyextra->fileName,yyextra->lineNr,
1142 }
1143 else if (langId.
empty() ||
1145 {
1146 BEGIN(CComment);
1147 }
1148 }
1149<SkipLang>[^*@\\\n]* { /* any character not a *, @, backslash or new line */
1150 }
1151<SkipLang>\n { /* new line in language block, needed for keeping track of line numbers */
1153 }
1154<SkipLang>. { /* any other character */
1155 }
1156<SComment>^[ \t]*{CPPC}"/"{SLASHopt}/\n {
1158 }
1159<SComment>\n[ \t]*{CPPC}"/"{SLASHopt}/\n {
1161 }
1162<SComment>^[ \t]*{CPPC}"/"[^\/\n]/.*\n {
1164 yyextra->readLineCtx=YY_START;
1165 YY_CURRENT_BUFFER->yy_at_bol=1;
1166 BEGIN(ReadLine);
1167 }
1168<SComment>\n[ \t]*{CPPC}[\/!]("<")?[ \t]*{CMD}"}".*\n {
1169
1172 yyextra->inSpecialComment=false;
1173 yyextra->inRoseComment=false;
1174 BEGIN(Scan);
1175 }
1176<SComment>\n[ \t]*{CPPC}"/"[^\\@\/\n]/.*\n {
1178 yyextra->readLineCtx=YY_START;
1179 YY_CURRENT_BUFFER->yy_at_bol=1;
1180 BEGIN(ReadLine);
1181 }
1182<SComment>^[ \t]*{CPPC}"!" | // just //!
1183<SComment>^[ \t]*{CPPC}"!<"/.*\n | // or //!< something
1184<SComment>^[ \t]*{CPPC}"!"[^<]/.*\n { // or //!something
1186 yyextra->readLineCtx=YY_START;
1187 YY_CURRENT_BUFFER->yy_at_bol=1;
1188 BEGIN(ReadLine);
1189 }
1190<SComment>\n[ \t]*{CPPC}"!" |
1191<SComment>\n[ \t]*{CPPC}"!<"/.*\n |
1192<SComment>\n[ \t]*{CPPC}"!"[^<\n]/.*\n {
1194 yyextra->readLineCtx=YY_START;
1195 YY_CURRENT_BUFFER->yy_at_bol=1;
1196 BEGIN(ReadLine);
1197 }
1198<SComment>^[ \t]*{CPPC}"##"/.*\n {
1199 if (!yyextra->inRoseComment)
1200 {
1201 REJECT;
1202 }
1203 else
1204 {
1206 yyextra->readLineCtx=YY_START;
1207 YY_CURRENT_BUFFER->yy_at_bol=1;
1208 BEGIN(ReadLine);
1209 }
1210 }
1211<SComment>\n[ \t]*{CPPC}"##"/.*\n {
1212 if (!yyextra->inRoseComment)
1213 {
1214 REJECT;
1215 }
1216 else
1217 {
1219 yyextra->readLineCtx=YY_START;
1220 YY_CURRENT_BUFFER->yy_at_bol=1;
1221 BEGIN(ReadLine);
1222 }
1223 }
1224<SComment>\n { /* end of special comment */
1227 yyextra->inSpecialComment=false;
1228 yyextra->inRoseComment=false;
1229 yyextra->insertCppCommentMarker=false;
1230 yyextra->readLineCtx = Scan;
1231
1232 BEGIN(Scan);
1233 }
1234<ReadLine,CopyLine>{CCS}"*" {
1236 }
1237<ReadLine,CopyLine>{CCE} {
1239 }
1240<ReadLine,CopyLine>"*" {
1242 }
1243<ReadLine,CopyLine>{RL} {
1245 }
1246<ReadLine,CopyLine>{RL}/{B}{CMD}"ilinebr"{B} {
1248 }
1249<ReadLine,CopyLine>{RLopt}/\n {
1251 yyextra->insertCppCommentMarker=false;
1252 BEGIN(yyextra->readLineCtx);
1253 }
1254<CComment,CNComment,ReadLine>"\<" { /* escaped html comment */
1256 }
1257<CComment,CNComment,ReadLine>{CMD}{CMD}[~a-z_A-Z][a-z_A-Z0-9]*[ \t]* { // escaped command
1259 }
1260
1261<CComment,ReadLine,IncludeFile>{CMD}("include"{OPTS}|"includedoc"{OPTS}*) {
1262 if (!
parseIncludeOptions(yyscanner,std::string_view{yytext,
static_cast<size_t>(yyleng)})) REJECT;
1263 yyextra->includeCtx = YY_START;
1264 yyextra->firstIncludeLine = true;
1265 yyextra->insertCommentCol = yyextra->col;
1266 if (!yyextra->insertCppCommentMarker && (yyextra->includeCtx==ReadLine || yyextra->includeCtx==IncludeFile))
1267 {
1268 yyextra->insertCppCommentMarker = yyextra->mlBrief;
1269 }
1270
1271 BEGIN(IncludeDoc);
1272 }
1273<CComment,ReadLine,IncludeFile>{CMD}("snippet"{OPTS}|"snippetdoc"{OPTS}*) {
1274 if (!
parseIncludeOptions(yyscanner,std::string_view{yytext,
static_cast<size_t>(yyleng)})) REJECT;
1275 yyextra->includeCtx = YY_START;
1276 yyextra->firstIncludeLine = true;
1277 yyextra->insertCommentCol = yyextra->col;
1278 if (!yyextra->insertCppCommentMarker && (yyextra->includeCtx==ReadLine || yyextra->includeCtx==IncludeFile))
1279 {
1280 yyextra->insertCppCommentMarker = yyextra->mlBrief;
1281 }
1282
1283 BEGIN(SnippetDoc);
1284 }
1285<IncludeDoc,SnippetDoc>{B}*
1286<IncludeDoc>{FILEMASK}|"\""[^\n\"]+"\"" {
1288 if (yytext[0]=='"')
1289 {
1290 fileName=fileName.
mid(1,fileName.
length()-2);
1291 }
1293 {
1294 BEGIN(IncludeFile);
1295 }
1296 else
1297 {
1298 BEGIN(yyextra->includeCtx);
1299 }
1300 }
1301<SnippetDoc>({FILEMASK}|"\""[^\n\"]+"\""){B}+ {
1302 yyextra->snippetFileName=yytext;
1303 yyextra->snippetFileName=yyextra->snippetFileName.stripWhiteSpace();
1304 if (yyextra->snippetFileName == "this") yyextra->snippetFileName=yyextra->fileName;
1305 yyextra->snippetName = "";
1306 BEGIN(SnippetDocTag);
1307 }
1308<SnippetDocTag>[^\\@\n]+ {
1309 yyextra->snippetName += yytext;
1310 }
1311<SnippetDocTag>{CMD} {
1312 yyextra->snippetName += yytext;
1313 }
1314<SnippetDocTag>(\n|{CMD}"ilinebr") {
1315 for (int i=(int)yyleng-1;i>=0;i--) unput(yytext[i]);
1316 yyextra->snippetName = yyextra->snippetName.stripWhiteSpace();
1317 DString blockId =
"["+yyextra->snippetName+
"]";
1319 {
1320 BEGIN(IncludeFile);
1321 }
1322 else
1323 {
1324 BEGIN(yyextra->includeCtx);
1325 }
1326 }
1327
1328<IncludeDoc,SnippetDoc>\n {
1331
1332
1333 BEGIN(yyextra->includeCtx);
1334 }
1335<IncludeDoc,SnippetDoc>. { // invalid character
1337 BEGIN(yyextra->includeCtx);
1338 }
1339<CComment,ReadLine,IncludeFile>{CMD}"cond"/[^a-z_A-Z0-9] { // conditional section
1340 yyextra->condCtx = YY_START;
1341 BEGIN(CondLine);
1342 }
1343<CComment,ReadLine,IncludeFile>{CMD}"endcond"/[^a-z_A-Z0-9] { // end of conditional section
1344 bool oldSkip=yyextra->skip;
1346 if (YY_START==CComment && oldSkip && !yyextra->skip)
1347 {
1348
1349 if (yyextra->lang!=SrcLangExt::Python &&
1350 yyextra->lang!=SrcLangExt::VHDL &&
1351 yyextra->lang!=SrcLangExt::Markdown &&
1352 yyextra->lang!=SrcLangExt::Fortran)
1353 {
1354 yyextra->outBuf+='/';
1355 yyextra->outBuf+='*';
1356 yyextra->col+=2;
1357 if (yyextra->specialComment)
1358 {
1359 yyextra->outBuf+='*';
1360 yyextra->col++;
1361 }
1362 }
1363 }
1364 }
1365<CondLine>{B}*{CMD}doxyconfig{B}+{DOXYCFG} {
1367 }
1368<CondLine>([!()&| \ta-z_A-Z0-9.\-]|{CMD}"doxyconfig")+ {
1370 }
1371<CComment,ReadLine,IncludeFile>{CMD}"cond"{WSopt}/\n {
1372 yyextra->condCtx=YY_START;
1374 }
1375<CondLine>\n |
1376<CondLine>. { // forgot section id?
1379 }
1380<CComment,ReadLine,IncludeFile,Verbatim,VerbatimCode>{CMD}[a-z_A-Z][a-z_A-Z0-9-]* { // expand alias without arguments
1381 bool inCppComment = YY_START==ReadLine && yyextra->readLineCtx==SComment;
1382 bool inCComment = YY_START==CComment && yyextra->blockHeadCol>0;
1384 }
1385<CComment,ReadLine,IncludeFile,Verbatim,VerbatimCode>{B}?{CMD}"ilinebr"{B}{CMD}"ialias{" { // expand alias with arguments
1386 yyextra->lastBlockContext=YY_START;
1387 yyextra->blockCount=1;
1388 int extraSpace = (yytext[0]==' '? 1:0);
1389 yyextra->aliasString=yytext+9+extraSpace;
1390 yyextra->aliasCmd=yytext+9+extraSpace;
1391 yyextra->lastEscaped=0;
1392 BEGIN( ReadAliasArgs );
1393 }
1394<CComment,ReadLine,IncludeFile,Verbatim,VerbatimCode>{CMD}[a-z_A-Z][a-z_A-Z0-9-]*"{" { // expand alias with arguments
1395 yyextra->lastBlockContext=YY_START;
1396 yyextra->blockCount=1;
1397 yyextra->aliasString=yytext;
1398 yyextra->aliasCmd=yytext;
1399 yyextra->lastEscaped=0;
1400 BEGIN( ReadAliasArgs );
1401 }
1402<ReadAliasArgs>^[ \t]*"*" {
1404 if (indent>yyextra->blockHeadCol)
1405 {
1406 yyextra->aliasString+=yytext;
1407 }
1408 else
1409 {
1410
1411 }
1412 }
1413<ReadAliasArgs>^[ \t]*{CPPC}[/!]/[^\n]* { // skip leading special comments (see bug 618079)
1414 }
1415<ReadAliasArgs>[^{}\n\\\*]+ {
1416 yyextra->aliasString+=yytext;
1417 yyextra->lastEscaped=false;
1418 }
1419<ReadAliasArgs>"\\" {
1420 if (yyextra->lastEscaped) yyextra->lastEscaped=false;
1421 else yyextra->lastEscaped=true;
1422 yyextra->aliasString+=yytext;
1423 }
1424<ReadAliasArgs>{CMD}("endverbatim"|"endiliteral"|"endlatexonly"|"endhtmlonly"|"endxmlonly"|"enddocbookonly"|"endrtfonly"|"endmanonly"|"f$"|"f]"|"f}"|"f)") { /* end of verbatim block */
1425 yyextra->aliasString+=yytext;
1426 if (yyextra->inVerbatim && &yytext[1]==yyextra->blockName)
1427
1428
1429
1430
1431
1432
1433 {
1435 yyextra->inVerbatim=false;
1436 BEGIN(yyextra->lastCommentContext);
1437 }
1438 }
1439<ReadAliasArgs>\n {
1440 yyextra->aliasString+=yytext;
1441 yyextra->lastEscaped=false;
1442 if (yyextra->inVerbatim)
1443
1444 {
1446 BEGIN( yyextra->lastBlockContext );
1447 }
1448 }
1449<ReadAliasArgs>"{" {
1450 yyextra->aliasString+=yytext;
1451 if (!yyextra->lastEscaped) yyextra->blockCount++;
1452 yyextra->lastEscaped=false;
1453 }
1454<ReadAliasArgs>"}" {
1455 yyextra->aliasString+=yytext;
1456 if (!yyextra->lastEscaped) yyextra->blockCount--;
1457 if (yyextra->blockCount==0)
1458 {
1459 bool inCppComment = yyextra->lastBlockContext==ReadLine && yyextra->readLineCtx==SComment;
1460 bool inCComment = yyextra->lastBlockContext==CComment && yyextra->blockHeadCol>0;
1461 replaceAliases(yyscanner,yyextra->aliasString.view(),inCppComment,inCComment);
1462 BEGIN( yyextra->lastBlockContext );
1463 }
1464 yyextra->lastEscaped=false;
1465 }
1466<ReadAliasArgs>. {
1467 yyextra->aliasString+=yytext;
1468 yyextra->lastEscaped=false;
1469 }
1470<CopyLine>. {
1472 }
1473<CopyLine>\n {
1475 yyextra->insertCppCommentMarker=false;
1476 BEGIN(yyextra->readLineCtx);
1477 }
1478<ReadLine>{CMD}{CMD} |
1479<ReadLine>. {
1481 }
1482<IncludeFile>. {
1484 }
1485<IncludeFile>\n {
1488 }
1489<*>. {
1491 }
1492<<EOF>> {
1493 if (YY_START == ReadAliasArgs)
1494 {
1495 warn(yyextra->fileName,yyextra->lineNr,
1496 "Reached end of file while still searching closing '}}' of an alias argument (probable start: '{}')",
1497 yyextra->aliasCmd);
1498 }
1499 else if (YY_START==Verbatim || YY_START==VerbatimCode)
1500 {
1501 warn(yyextra->fileName,yyextra->lineNr,
1502 "Reached end of file while still searching closing '{}' of a verbatim block starting at line {}",
1503 yyextra->blockName,yyextra->verbatimLine);
1504 }
1505 if (yyextra->includeStack.empty())
1506 {
1507 yyextra->insertCppCommentMarker=false;
1509 }
1510 else
1511 {
1512 std::unique_ptr<commentcnv_FileState> &fs = yyextra->includeStack.back();
1513 YY_BUFFER_STATE oldBuf = YY_CURRENT_BUFFER;
1514 yy_switch_to_buffer(fs->bufState, yyscanner);
1515 yy_delete_buffer(oldBuf, yyscanner);
1516 BEGIN(fs->oldState);
1517 yyextra->fileName = fs->oldFileName;
1518 yyextra->lineNr = fs->oldLineNr;
1519 yyextra->inBuf = fs->oldFileBuf;
1520 yyextra->inBufPos = fs->oldFileBufPos;
1521 yyextra->includeCtx = fs->oldIncludeCtx;
1522 DString lineStr=
" \\ifile \""+yyextra->fileName+
"\" \\iline "+
DString().
setNum(yyextra->lineNr)+
" ";
1523 if (fs->oldRaiseLvl!=yyextra->raiseLevel)
1524 {
1525 lineStr+="\\iraise " + std::to_string(fs->oldRaiseLvl)+ " ";
1526 }
1527 if (fs->oldRaiseLbl!=yyextra->raiseLabel)
1528 {
1529 lineStr+="\\iprefix \"" + fs->oldRaiseLbl + "\" ";
1530 }
1531 lineStr+="\\ilinebr ";
1532 yyextra->raiseLevel = fs->oldRaiseLvl;
1533 yyextra->raiseLabel = fs->oldRaiseLbl;
1535 yyextra->includeStack.pop_back();
1536
1537
1538 }
1539 }
1540
1541<*>\n { fprintf(stderr,"Lex scanner %s (%s) default rule newline for state %s.\n", __FILE__, qPrint(yyextra->fileName),stateToString(YY_START));}
1542 */
1543%%