278 {NUMBER} {
279 if (yyextra->lang!=SrcLangExt::Cpp) REJECT;
281 }
282<Scan>{RAWBEGIN} {
283 if (yyextra->lang!=SrcLangExt::Cpp) REJECT;
285 BEGIN(RawString);
286 }
287<Scan>[^"'!\/\n\\#,\-=; \t@$]* { /* eat anything that is not " / , or \n */
289 }
290<Scan>[,= ;\t] { /* eat , so we have a nice separator in long initialization lines */
292 }
293<Scan>"'''"! |
294<Scan>"\"\"\""! { /* start of python long comment */
295 if (yyextra->lang!=SrcLangExt::Python)
296 {
297 REJECT;
298 }
299 else
300 {
301 yyextra->pythonDocString = true;
302 yyextra->pythonDocStringChar = yytext[0];
303 yyextra->nestingCount=1;
306 BEGIN(CComment);
307 yyextra->commentStack.push(yyextra->lineNr);
308 }
309 }
310<Scan>"'''" |
311<Scan>"\"\"\"" { /* start of python long comment */
312 if (yyextra->lang!=SrcLangExt::Python)
313 {
314 REJECT;
315 }
317 {
318 REJECT;
319 }
320 else
321 {
322 yyextra->pythonDocString = true;
323 yyextra->pythonDocStringChar = yytext[0];
324 yyextra->nestingCount=1;
327 BEGIN(CComment);
328 yyextra->commentStack.push(yyextra->lineNr);
329 }
330 }
331<Scan>{B}*![><!]/.*\n {
332 if (yyextra->lang!=SrcLangExt::Fortran)
333 {
334 REJECT;
335 }
336 else
337 {
338 yyextra->nestingCount=0;
340 yyextra->specialComment=true;
342 yyextra->blockHeadCol=yyextra->col-2;
343 BEGIN(CComment);
344 yyextra->commentStack.push(yyextra->lineNr);
345 }
346 }
347<Scan>[Cc\*][><!]/.*\n {
348 if (yyextra->lang!=SrcLangExt::Fortran)
349 {
350 REJECT;
351 }
352 else
353 {
354
355 if (yyextra->isFixedForm && (yyextra->col == 0))
356 {
357 yyextra->nestingCount=0;
359 yyextra->specialComment=true;
361 yyextra->blockHeadCol=yyextra->col-1;
362 BEGIN(CComment);
363 yyextra->commentStack.push(yyextra->lineNr);
364 }
365 else
366 {
367 REJECT;
368 }
369 }
370 }
371<Scan>!.*\n {
372 if (yyextra->lang!=SrcLangExt::Fortran)
373 {
374 REJECT;
375 }
376 else
377 {
379 }
380 }
381<Scan>[Cc\*].*\n {
382 if (yyextra->lang!=SrcLangExt::Fortran)
383 {
384 REJECT;
385 }
386 else
387 {
388 if (yyextra->col == 0)
389 {
391 }
392 else
393 {
394 REJECT;
395 }
396 }
397 }
398<Scan>[$]?"@\"" { /* start of an interpolated verbatim C# string */
399 if (yyextra->lang!=SrcLangExt::CSharp) REJECT
401 yyextra->stringContext = YY_START;
402 BEGIN(SkipVerbString);
403 }
404<Scan>"\"" { /* start of a string */
406 yyextra->stringContext = YY_START;
407 BEGIN(SkipString);
408 }
409<Scan>' {
411 yyextra->charContext = YY_START;
412 if (yyextra->lang!=SrcLangExt::VHDL)
413 {
414 BEGIN(SkipChar);
415 }
416 }
417<Scan>\n { /* new line */
419 }
420<Scan>{CPPC}[!/]/.*\n[ \t]*{CPPC}[!/][ \t]*{CMD}"}" { // see bug #8731, don't treat multiline C++ comment as detailed description
421
422 yyextra->inSpecialComment=true;
423 yyextra->blockHeadCol=yyextra->col+1;
424 yyextra->insertCppCommentMarker=true;
426 yyextra->readLineCtx=YY_START;
427 BEGIN(ReadLine);
428 }
429<Scan>{CPPC}"!"/.*\n[ \t]*{CPPC}[\/!][^\/] | /* start C++ style special comment block */
430<Scan>({CPPC}"/"[/]*)/[^/].*\n[ \t]*{CPPC}[\/!][^\/] { /* start C++ style special comment block */
431 if (yyextra->mlBrief)
432 {
433 REJECT;
434 }
435 else
436 {
437 int i=3;
438 if (yytext[2]=='/')
439 {
440 while (i<(int)yyleng && yytext[i]=='/') i++;
441 }
442 yyextra->blockHeadCol=yyextra->col+1;
443 yyextra->blockHeadPos=yyextra->skip ? std::string::npos : yyextra->outBuf.size();
444 if (yytext[2] == '!')
445 {
447 }
448 else
449 {
451 }
453 yyextra->inSpecialComment=true;
454
455 yyextra->readLineCtx=SComment;
456 BEGIN(ReadLine);
457 }
458 }
459<Scan>{CPPC}"##Documentation"{ANYopt}/\n { /* Start of Rational Rose ANSI C++ comment block */
460 if (yyextra->mlBrief) REJECT;
461 int i=17;
462 yyextra->blockHeadCol=yyextra->col+1;
463 yyextra->blockHeadPos=yyextra->skip ? std::string::npos : yyextra->outBuf.size();
466 yyextra->inRoseComment=true;
467 BEGIN(SComment);
468 }
469<Scan>{CPPC}[!\/]/.*\n[ \t]*{CPPC}[|\/][ \t]*{CMD}"}" { // next line contains an end marker, see bug 752712
470 yyextra->inSpecialComment=yytext[2]=='/' || yytext[2]=='!';
471 if (yyextra->inSpecialComment)
472 {
473 yyextra->blockHeadCol=yyextra->col+1;
474 }
476 yyextra->readLineCtx=YY_START;
477 BEGIN(ReadLine);
478 }
479<Scan>{CPPC}[!/]/.*\n { /* one line special C++ comment */
480 yyextra->inSpecialComment=true;
481 yyextra->blockHeadCol=yyextra->col+1;
482 yyextra->insertCppCommentMarker=true;
484 yyextra->readLineCtx=YY_START;
485 BEGIN(ReadLine);
486 }
487<Scan>{CPPC}/.*\n { /* one line normal C++ comment */
488 yyextra->inSpecialComment=false;
490 yyextra->readLineCtx=YY_START;
491 BEGIN(CopyLine);
492 }
493<Scan>{CCS}{CCE} { /* avoid matching next rule for empty C comment, see bug 711723 */
495 }
496<Scan>{CCS}[*!]? { /* start of a C comment */
497 if (yyextra->lang==SrcLangExt::Python)
498 {
499 REJECT;
500 }
501 yyextra->specialComment=(int)yyleng==3;
502 yyextra->nestingCount=1;
505 if (yyextra->specialComment)
506 {
507 yyextra->blockHeadCol=0;
508 BEGIN(CComment);
509 }
510 else
511 {
512 BEGIN(CNComment);
513 }
514 yyextra->commentStack.push(yyextra->lineNr);
515 }
516<Scan>"#"[^\n]*\n {
517 if (yyextra->lang!=SrcLangExt::PHP)
518 {
519 REJECT;
520 }
522 }
523<Scan>"#"("#")? {
524 if (yyextra->lang!=SrcLangExt::Python)
525 {
526 REJECT;
527 }
528 else
529 {
530 yyextra->nestingCount=0;
532 yyextra->specialComment=(int)yyleng==2;
533 if (yyextra->specialComment)
534 {
535 yyextra->blockHeadCol=yyextra->col;
536 }
537 yyextra->commentStack.push(yyextra->lineNr);
539 BEGIN(CComment);
540 }
541 }
542<Scan>"--"[^!][^\n]* {
543 if (yyextra->lang!=SrcLangExt::VHDL)
544 {
545 REJECT;
546 }
547 else
548 {
550 }
551 }
552<Scan>"--!" {
553 if (yyextra->lang!=SrcLangExt::VHDL)
554 {
555 REJECT;
556 }
557 else
558 {
559 yyextra->specialComment=true;
560 yyextra->blockHeadCol=yyextra->col;
561 yyextra->vhdl = true;
562 yyextra->nestingCount=0;
564 yyextra->commentStack.push(yyextra->lineNr);
566 BEGIN(CComment);
567 }
568 }
569<Scan>{B}*![><!] {
570 if (yyextra->lang!=SrcLangExt::Fortran)
571 {
572 REJECT;
573 }
574 else
575 {
576 yyextra->nestingCount=0;
578 yyextra->specialComment=true;
579 yyextra->blockHeadCol=yyextra->col;
580 yyextra->commentStack.push(yyextra->lineNr);
582 BEGIN(CComment);
583 }
584 }
585<RawString>{RAWEND} {
588 {
589 BEGIN(Scan);
590 }
591 }
DString extractEndRawStringDelimiter(const char *rawEnd)
592<RawString>[^)\n]+ { copyToOutput(yyscanner,yytext,yyleng); }
593<RawString>\n { copyToOutput(yyscanner,yytext,yyleng); }
594<RawString>. { copyToOutput(yyscanner,yytext,yyleng); }
595
596<CComment,CNComment,ReadLine,IncludeFile>{MAILADDR} |
597<CComment,CNComment,ReadLine,IncludeFile>"<"{MAILADDR}">" { // Mail address, to prevent seeing e.g x@code-factory.org as start of a code block
599 }
600<CComment,IncludeFile>"{"[ \t]*"@code"/[ \t\n] {
602 yyextra->lastCommentContext = YY_START;
603 yyextra->javaBlock=1;
604 yyextra->blockName=
DString(
"end")+&yytext[1];
605 yyextra->inVerbatim=true;
606 yyextra->verbatimLine=yyextra->lineNr;
607 BEGIN(VerbatimCode);
608 }
609<CComment,IncludeFile>"{"[ \t]*"@literal"/[ \t\n] {
611 yyextra->lastCommentContext = YY_START;
612 yyextra->javaBlock=1;
613 yyextra->blockName=
DString(
"end")+&yytext[1];
614 yyextra->inVerbatim=true;
615 yyextra->verbatimLine=yyextra->lineNr;
616 BEGIN(VerbatimCode);
617 }
618<CComment,ReadLine,IncludeFile>{CMD}"ilinebr"[ \t]+("```"[`]*|"~~~"[~]*) { /* start of markdown code block */
620 {
621 REJECT;
622 }
624 yyextra->lastCommentContext = YY_START;
625 yyextra->javaBlock=0;
627 yyextra->inVerbatim=true;
628 yyextra->verbatimLine=yyextra->lineNr;
629 BEGIN(VerbatimCode);
630 }
DString right(size_t len) const
631<CComment,ReadLine,IncludeFile>^[ \t]*("```"[`]*|"~~~"[~]*) { /* start of markdown code block */
633 {
634 REJECT;
635 }
637 yyextra->lastCommentContext = YY_START;
638 yyextra->javaBlock=0;
640 yyextra->inVerbatim=true;
641 yyextra->verbatimLine=yyextra->lineNr;
642 BEGIN(VerbatimCode);
643 }
DString left(size_t len) const
644<CComment,ReadLine,IncludeFile>{CMD}("dot"|"code"|"msc"|"startuml"|"mermaid")/[^a-z_A-Z0-9] { /* start of a verbatim block */
646 if (yyextra->inSpecialComment || yyextra->specialComment || yyextra->lang==SrcLangExt::Markdown)
647 {
648 yyextra->lastCommentContext = YY_START;
649 yyextra->javaBlock=0;
650 if (
dstrcmp(&yytext[1],
"startuml")==0)
651 {
652 yyextra->blockName="enduml";
653 }
654 else
655 {
656 yyextra->blockName=
DString(
"end")+&yytext[1];
657 }
658 yyextra->inVerbatim=true;
659 yyextra->verbatimLine=yyextra->lineNr;
660 BEGIN(VerbatimCode);
661 }
662 }
int dstrcmp(const char *str1, const char *str2)
663<CComment,ReadLine,IncludeFile>"\\`" {
665 }
666<CComment,ReadLine,IncludeFile>"```" { // skip ``` if not at the start of the line
668 }
669<CComment,ReadLine,IncludeFile>"`"{1,2} {
671 {
672 REJECT;
673 }
675 if (yyextra->inSpecialComment || yyextra->specialComment || yyextra->lang==SrcLangExt::Markdown)
676 {
677 yyextra->lastCommentContext = YY_START;
678 yyextra->javaBlock=0;
679 yyextra->blockName=yytext;
680 yyextra->inVerbatim=true;
681 yyextra->verbatimLine=yyextra->lineNr;
682 BEGIN(VerbatimCode);
683 }
684 }
685<CComment,ReadLine,IncludeFile>{CMD}("f$"|"f["|"f{"|"f(") {
687 if (yyextra->inSpecialComment || yyextra->specialComment || yyextra->lang==SrcLangExt::Markdown)
688 {
689 yyextra->blockName=&yytext[1];
690 if (yyextra->blockName.at(1)=='[')
691 {
692 yyextra->blockName.at(1)=']';
693 }
694 else if (yyextra->blockName.at(1)=='{')
695 {
696 yyextra->blockName.at(1)='}';
697 }
698 else if (yyextra->blockName.at(1)=='(')
699 {
700 yyextra->blockName.at(1)=')';
701 }
702 yyextra->lastCommentContext = YY_START;
703 yyextra->inVerbatim=true;
704 yyextra->verbatimLine=yyextra->lineNr;
705 BEGIN(Verbatim);
706 }
707 }
708<CComment,ReadLine,IncludeFile>"<!--!" { /* HTML comment doxygen command*/
709 if (yyextra->inVerbatim) REJECT;
710
711 yyextra->inHtmlDoxygenCommand=true;
712 }
713<CComment,ReadLine,IncludeFile>"-->" { /* potential end HTML comment doxygen command*/
714 if (yyextra->inHtmlDoxygenCommand)
715 {
716 yyextra->inHtmlDoxygenCommand=false;
717 }
718 else
719 {
721 }
722 }
723<CComment,ReadLine,IncludeFile>"<!--" { /* HTML comment */
725 if (yyextra->inSpecialComment || yyextra->specialComment || yyextra->lang==SrcLangExt::Markdown)
726 {
727 yyextra->blockName="-->";
728 yyextra->lastCommentContext = YY_START;
729 yyextra->inVerbatim=true;
730 yyextra->verbatimLine=yyextra->lineNr;
731 BEGIN(Verbatim);
732 }
733 }
734<CComment,ReadLine,IncludeFile>{CMD}("verbatim"|"iliteral"|"latexonly"|"htmlonly"|"xmlonly"|"docbookonly"|"rtfonly"|"manonly")/[^a-z_A-Z0-9] { /* start of a verbatim block */
736 if (yyextra->inSpecialComment || yyextra->specialComment || yyextra->lang==SrcLangExt::Markdown)
737 {
738 yyextra->blockName=
DString(
"end")+&yytext[1];
739 yyextra->lastCommentContext = YY_START;
740 yyextra->inVerbatim=true;
741 yyextra->verbatimLine=yyextra->lineNr;
742 BEGIN(Verbatim);
743 }
744 }
745<Scan>"\\\"" { /* escaped double quote */
747 }
748<Scan>"\\\\" { /* escaped backslash */
750 }
751<Scan>. { /* any other character */
753 }
754<Verbatim>{CMD}("endverbatim"|"endiliteral"|"endlatexonly"|"endhtmlonly"|"endxmlonly"|"enddocbookonly"|"endrtfonly"|"endmanonly"|"f$"|"f]"|"f}"|"f)") { /* end of verbatim block */
756 if (&yytext[1]==yyextra->blockName)
757 {
758 yyextra->inVerbatim=false;
759 BEGIN(yyextra->lastCommentContext);
760 }
761 }
762<Verbatim>"-->" {
764 if (yytext==yyextra->blockName)
765 {
766 yyextra->inVerbatim=false;
767 BEGIN(yyextra->lastCommentContext);
768 }
769 }
770<VerbatimCode>"{" {
771 if (yyextra->javaBlock==0)
772 {
773 REJECT;
774 }
775 else
776 {
777 yyextra->javaBlock++;
779 }
780 }
781<VerbatimCode>"}" {
782 if (yyextra->javaBlock==0)
783 {
784 REJECT;
785 }
786 else
787 {
788 yyextra->javaBlock--;
789 if (yyextra->javaBlock==0)
790 {
792 yyextra->inVerbatim=false;
793 BEGIN(yyextra->lastCommentContext);
794 }
795 else
796 {
798 }
799 }
800 }
801<VerbatimCode>("```"[`]*|"~~~"[~]*) { /* end of markdown code block */
802 if (yytext[0]=='`' && (yyextra->blockName=="`" || yyextra->blockName=="``"))
803 {
804
806 }
807 else
808 {
810 if (yytext[0]==yyextra->blockName[0])
811 {
812 yyextra->inVerbatim=false;
813 BEGIN(yyextra->lastCommentContext);
814 }
815 }
816 }
817<VerbatimCode>"''" {
820 {
821 yyextra->inVerbatim=false;
822 BEGIN(yyextra->lastCommentContext);
823 }
824 }
825<VerbatimCode>"'" {
828 {
829 yyextra->inVerbatim=false;
830 BEGIN(yyextra->lastCommentContext);
831 }
832 }
833<VerbatimCode>"`"{1,2} {
835 if (yytext==yyextra->blockName)
836 {
837 yyextra->inVerbatim=false;
838 BEGIN(yyextra->lastCommentContext);
839 }
840 }
841<VerbatimCode>{CMD}("enddot"|"endcode"|"endmsc"|"enduml"|"endmermaid")/("{")? { // end of verbatim block
843 if (&yytext[1]==yyextra->blockName)
844 {
845 yyextra->inVerbatim=false;
846 BEGIN(yyextra->lastCommentContext);
847 }
848 }
849<VerbatimCode>^[ \t]*{CPPC}[\!\/]? { /* skip leading comments */
850 if (!yyextra->inSpecialComment || yyextra->mlBrief)
851 {
853 }
854 else
855 {
856 int l=0;
857 while (yytext[l]==' ' || yytext[l]=='\t')
858 {
859 l++;
860 }
862 if (yyleng-l==3)
863 {
865 }
866 else
867 {
869 }
870 }
871 }
872<Verbatim,VerbatimCode>[^`'~@\/\-\\\n{}]* { /* any character not a backslash or new line or } */
874 }
875<Verbatim,VerbatimCode>[^`'~@\/\-\\\n{}]+/\n{B}*"//" {
876 if (yyextra->lastCommentContext!=ReadLine)
877 {
878 REJECT;
879 }
880 else
881 {
883 }
884 }
885<Verbatim,VerbatimCode>[^`'~@\/\-\\\n{}]+/\n { /* premature end of comment block */
886 if (yyextra->lastCommentContext==ReadLine)
887 {
888 yyextra->inVerbatim=false;
889 BEGIN(yyextra->lastCommentContext);
890 }
892 }
893<Verbatim,VerbatimCode>\n { /* new line in verbatim block */
895 if (yyextra->lastCommentContext == IncludeFile)
896 {
898 }
899 }
900<Verbatim>^[ \t]*{CPPC}[/!] {
901 if (yyextra->blockName=="enddot" || yyextra->blockName=="endmsc" || yyextra->blockName=="enduml" || yyextra->blockName.at(0)=='f')
902 {
903
904 int l=0;
905 while (yytext[l]==' ' || yytext[l]=='\t')
906 {
907 l++;
908 }
911 }
912 else
913 {
914 REJECT;
915 }
916 }
917<Verbatim,VerbatimCode>. { /* any other character */
919 }
920<SkipString>\\. { /* escaped character in string */
921 if (yyextra->lang==SrcLangExt::Fortran || yyextra->lang==SrcLangExt::VHDL)
922 {
923 unput(yytext[1]);
925 }
926 else
927 {
929 }
930 }
931<SkipString>"\"" { /* end of string */
933 BEGIN(yyextra->stringContext);
934 }
935<SkipString>. { /* any other string character */
937 }
938<SkipString>\n { /* new line inside string (illegal for some compilers) */
940 }
941<SkipVerbString>[^"\n]+ {
943 }
944<SkipVerbString>\"\" { // escaped quote
946 }
947<SkipVerbString>"\"" { /* end of string */
949 BEGIN(yyextra->stringContext);
950 }
951<SkipVerbString>. {
953 }
954<SkipVerbString>\n {
956 }
957<SkipChar>\\. { /* escaped character */
958 if (yyextra->lang==SrcLangExt::Fortran || yyextra->lang==SrcLangExt::VHDL)
959 {
960 unput(yytext[1]);
962 }
963 else
964 {
966 }
967 }
968<SkipChar>' { /* end of character literal */
970 BEGIN(yyextra->charContext);
971 }
972<SkipChar>. { /* any other string character */
974 }
975<SkipChar>\n { /* new line character */
977 }
978
979<CComment,CNComment>[^ `~<\\!@*\n{\"'\/-`]* { /* anything that is not a '*' or command */
981 }
982<CComment,CNComment>^{B}*"*"+[^*\/<\\@\n{\"`]* { /* stars without slashes */
983 if (yyextra->lang==SrcLangExt::Markdown) REJECT;
985 if (yyextra->col>yyextra->blockHeadCol)
986 {
987
988 yyextra->blockHeadCol=yyextra->col;
989 }
991 }
992<CComment>"'''" |
993<CComment>"\"\"\"" { /* end of Python docstring */
994 if (yyextra->lang!=SrcLangExt::Python)
995 {
996 REJECT;
997 }
998 else if (yyextra->pythonDocStringChar != yytext[0])
999 {
1001 }
1002 else
1003 {
1004 yyextra->nestingCount--;
1005 yyextra->pythonDocString = false;
1006 yyextra->pythonDocStringChar = '\0';
1008 BEGIN(Scan);
1009 }
1010 }
1011<CComment,CNComment>\n { /* new line in comment */
1013
1014 if (yyextra->lang==SrcLangExt::Fortran)
1015 {
1016 BEGIN(Scan);
1017 }
1018 }
1019<CComment,CNComment>"/""/"+/"*/" { /* we are already in C-comment so not a start of a nested comment but
1020 * just the
end of the comment (the
end part is handled later). */
1022 }
DirIterator end(const DirIterator &) noexcept
1023<CComment,CNComment>"/"+"*" { /* nested C comment */
1024 if (yyextra->lang==SrcLangExt::Python ||
1025 yyextra->lang==SrcLangExt::Markdown)
1026 {
1027 REJECT;
1028 }
1029 yyextra->nestingCount++;
1030 yyextra->commentStack.push(yyextra->lineNr);
1032 }
1033<CComment,CNComment>^{B}*"*"+"/" |
1034<CComment,CNComment>"*"+"/" { /* end of C comment */
1035 if (yyextra->lang==SrcLangExt::Python ||
1036 yyextra->lang==SrcLangExt::Markdown)
1037 {
1038 REJECT;
1039 }
1040 else
1041 {
1043 yyextra->nestingCount--;
1044 if (yyextra->nestingCount<=0)
1045 {
1046 BEGIN(Scan);
1047 }
1048 else
1049 {
1050
1051 yyextra->commentStack.pop();
1052 }
1053 }
1054 }
1055
1056<CComment,CNComment>"\n"/[ \t]*"#" {
1057 if (yyextra->lang!=SrcLangExt::VHDL)
1058 {
1059 REJECT;
1060 }
1061 else
1062 {
1063 if (yyextra->vhdl)
1064 {
1065 yyextra->vhdl = false;
1067 BEGIN(Scan);
1068 }
1069 else
1070 {
1071 REJECT;
1072 }
1073 }
1074 }
1075<CComment,CNComment>"\n"/[ \t]*"-" {
1076 if (yyextra->lang!=SrcLangExt::Python || yyextra->pythonDocString)
1077 {
1078 REJECT;
1079 }
1080 else
1081 {
1083 BEGIN(Scan);
1084 }
1085 }
1086<CComment,CNComment>"\n"/[ \t]*[^ \t#\-] {
1087 if (yyextra->lang==SrcLangExt::Python)
1088 {
1089 if (yyextra->pythonDocString)
1090 {
1091 REJECT;
1092 }
1093 else
1094 {
1096 BEGIN(Scan);
1097 }
1098 }
1099 else if (yyextra->lang==SrcLangExt::VHDL)
1100 {
1101 if (yyextra->vhdl)
1102 {
1103 yyextra->vhdl = false;
1105 BEGIN(Scan);
1106 }
1107 else
1108 {
1109 REJECT;
1110 }
1111 }
1112 else
1113 {
1114 REJECT;
1115 }
1116 }
1117
1118<CComment,CNComment>"'" {
1119 yyextra->charContext = YY_START;
1121 BEGIN(SkipChar);
1122 }
1123<CComment,CNComment>"\"" {
1124 yyextra->stringContext = YY_START;
1126 BEGIN(SkipString);
1127 }
1128 */
1129<CComment,CNComment>{CMD}"~"[a-z_A-Z-]* { // language switch command
1130 if (yyextra->lang!=SrcLangExt::Markdown) REJECT;
1132 if (!langId.
empty() &&
1134 {
1136 {
1137 warn(yyextra->fileName,yyextra->lineNr,
1139 }
1140 BEGIN(SkipLang);
1141 }
1142 }
#define Config_getEnumAsString(name)
#define Config_isAvailableEnum(name, value)
int dstricmp(const char *s1, const char *s2)
1143<CComment,CNComment>{CMD}{CMD} |
1144<CComment,CNComment>. {
1146 }
1147<SkipLang>{CMD}"~"[a-zA-Z-]* { /* language switch */
1150 {
1151 warn(yyextra->fileName,yyextra->lineNr,
1153 }
1154 else if (langId.
empty() ||
1156 {
1157 BEGIN(CComment);
1158 }
1159 }
1160<SkipLang>[^*@\\\n]* { /* any character not a *, @, backslash or new line */
1161 }
1162<SkipLang>\n { /* new line in language block, needed for keeping track of line numbers */
1164 }
1165<SkipLang>. { /* any other character */
1166 }
1167<SComment>^[ \t]*{CPPC}"/"{SLASHopt}/\n {
1169 }
1170<SComment>\n[ \t]*{CPPC}"/"{SLASHopt}/\n {
1172 }
1173<SComment>^[ \t]*{CPPC}"/"[^\/\n]/.*\n {
1175 yyextra->readLineCtx=YY_START;
1176 YY_CURRENT_BUFFER->yy_at_bol=1;
1177 BEGIN(ReadLine);
1178 }
1179<SComment>\n[ \t]*{CPPC}[\/!]("<")?[ \t]*{CMD}"}".*\n {
1180
1183 yyextra->inSpecialComment=false;
1184 yyextra->inRoseComment=false;
1185 BEGIN(Scan);
1186 }
1187<SComment>\n[ \t]*{CPPC}"/"[^\\@\/\n]/.*\n {
1189 yyextra->readLineCtx=YY_START;
1190 YY_CURRENT_BUFFER->yy_at_bol=1;
1191 BEGIN(ReadLine);
1192 }
1193<SComment>^[ \t]*{CPPC}"!" | // just //!
1194<SComment>^[ \t]*{CPPC}"!<"/.*\n | // or //!< something
1195<SComment>^[ \t]*{CPPC}"!"[^<]/.*\n { // or //!something
1197 yyextra->readLineCtx=YY_START;
1198 YY_CURRENT_BUFFER->yy_at_bol=1;
1199 BEGIN(ReadLine);
1200 }
1201<SComment>\n[ \t]*{CPPC}"!" |
1202<SComment>\n[ \t]*{CPPC}"!<"/.*\n |
1203<SComment>\n[ \t]*{CPPC}"!"[^<\n]/.*\n {
1205 yyextra->readLineCtx=YY_START;
1206 YY_CURRENT_BUFFER->yy_at_bol=1;
1207 BEGIN(ReadLine);
1208 }
1209<SComment>^[ \t]*{CPPC}"##"/.*\n {
1210 if (!yyextra->inRoseComment)
1211 {
1212 REJECT;
1213 }
1214 else
1215 {
1217 yyextra->readLineCtx=YY_START;
1218 YY_CURRENT_BUFFER->yy_at_bol=1;
1219 BEGIN(ReadLine);
1220 }
1221 }
1222<SComment>\n[ \t]*{CPPC}"##"/.*\n {
1223 if (!yyextra->inRoseComment)
1224 {
1225 REJECT;
1226 }
1227 else
1228 {
1230 yyextra->readLineCtx=YY_START;
1231 YY_CURRENT_BUFFER->yy_at_bol=1;
1232 BEGIN(ReadLine);
1233 }
1234 }
1235<SComment>\n { /* end of special comment */
1238 yyextra->inSpecialComment=false;
1239 yyextra->inRoseComment=false;
1240 yyextra->insertCppCommentMarker=false;
1241 yyextra->readLineCtx = Scan;
1242
1243 BEGIN(Scan);
1244 }
1245<ReadLine,CopyLine>{CCS}"*" {
1247 }
1248<ReadLine,CopyLine>{CCE} {
1250 }
1251<ReadLine,CopyLine>"*" {
1253 }
1254<ReadLine,CopyLine>{RL} {
1256 }
1257<ReadLine,CopyLine>{RL}/{B}{CMD}"ilinebr"{B} {
1259 }
1260<ReadLine,CopyLine>{RLopt}/\n {
1262 yyextra->insertCppCommentMarker=false;
1263 BEGIN(yyextra->readLineCtx);
1264 }
1265<CComment,CNComment,ReadLine>"\<" { /* escaped html comment */
1267 }
1268<CComment,CNComment,ReadLine>{CMD}{CMD}[~a-z_A-Z][a-z_A-Z0-9]*[ \t]* { // escaped command
1270 }
1271
1272<CComment,ReadLine,IncludeFile>{CMD}("include"{OPTS}|"includedoc"{OPTS}*) {
1273 if (!
parseIncludeOptions(yyscanner,std::string_view{yytext,
static_cast<size_t>(yyleng)})) REJECT;
1274 yyextra->includeCtx = YY_START;
1275 yyextra->firstIncludeLine = true;
1276 yyextra->insertCommentCol = yyextra->col;
1277 if (!yyextra->insertCppCommentMarker && (yyextra->includeCtx==ReadLine || yyextra->includeCtx==IncludeFile))
1278 {
1279 yyextra->insertCppCommentMarker = yyextra->mlBrief;
1280 }
1281
1282 yyextra->snippetRtn = 0;
1283 BEGIN(IncludeDoc);
1284 }
1285<CComment,ReadLine,IncludeFile>{CMD}("snippet"{OPTS}|"snippetdoc"{OPTS}*) {
1286 if (!
parseIncludeOptions(yyscanner,std::string_view{yytext,
static_cast<size_t>(yyleng)})) REJECT;
1287 yyextra->includeCtx = YY_START;
1288 yyextra->firstIncludeLine = true;
1289 yyextra->insertCommentCol = yyextra->col;
1290 if (!yyextra->insertCppCommentMarker && (yyextra->includeCtx==ReadLine || yyextra->includeCtx==IncludeFile))
1291 {
1292 yyextra->insertCppCommentMarker = yyextra->mlBrief;
1293 }
1294
1295 yyextra->snippetRtn = 0;
1296 BEGIN(SnippetDoc);
1297 }
1298<IncludeDoc,SnippetDoc>{B}*{CCE} {
1299 warn(yyextra->fileName,yyextra->lineNr,
"Found \\{}{{doc}} command without valid file name argument",
1300 YY_START==IncludeDoc? "include" : "snippet"
1301 );
1302 for (int i=(int)yyleng-1;i>=0;i--) unput(yytext[i]);
1305 BEGIN(yyextra->includeCtx);
1306 }
1307<IncludeDoc,SnippetDoc>^{B}*"*"+{B}* {
1308 if (!(yyextra->snippetRtn && (yyextra->includeCtx==CComment || yyextra->includeCtx==CNComment))) REJECT;
1309 }
1310<IncludeDoc,SnippetDoc>{B}*
1311<IncludeDoc>{FILEMASK}|"\""[^\n\"]+"\"" {
1313 if (yytext[0]=='"')
1314 {
1315 fileName=fileName.
mid(1,fileName.
length()-2);
1316 }
1318 {
1319 BEGIN(IncludeFile);
1320 }
1321 else
1322 {
1323 BEGIN(yyextra->includeCtx);
1324 }
1325 }
1326<SnippetDoc>({FILEMASK}|"\""[^\n\"]+"\"") {
1327 yyextra->snippetFileName=yytext;
1328 yyextra->snippetFileName=yyextra->snippetFileName.stripWhiteSpace();
1329 if (yyextra->snippetFileName == "this") yyextra->snippetFileName=yyextra->fileName;
1330 yyextra->snippetName = "";
1331 yyextra->snippetRtn = 0;
1332 BEGIN(SnippetDocTag);
1333 }
1334<SnippetDocTag>\n{B}*{CPPC}[\/!]{B}*/\n {
1335 if (!yyextra->snippetName.stripWhiteSpace().empty()) REJECT;
1336
1337 warn_doc_error(yyextra->fileName,yyextra->lineNr,
"no block identification found in \\snippet{{doc}} command, skipping");
1338 yyextra->lineNr++;
1341 BEGIN(yyextra->includeCtx);
1342 }
1343<SnippetDocTag>\n{B}*{CPPC}[\/!] {
1344 if (yyextra->snippetName.stripWhiteSpace().empty())
1345 {
1346 if (yyextra->snippetRtn)
1347 {
1348 warn_doc_error(yyextra->fileName,yyextra->lineNr,
"no block identification found in \\snippet{{doc}} command, skipping");
1349 yyextra->lineNr++;
1352 BEGIN(yyextra->includeCtx);
1353 }
1354 else
1355 {
1356 yyextra->lineNr++;
1357 }
1358 }
1359 else
1360 {
1361 REJECT;
1362 }
1363 }
1364<SnippetDocTag>{B}*{CCE} {
1365 if (!yyextra->snippetName.stripWhiteSpace().empty()) REJECT;
1366
1367 warn_doc_error(yyextra->fileName,yyextra->lineNr,
"no block identification found in \\snippet{{doc}} command, skipping");
1368 for (int i=(int)yyleng-1;i>=0;i--) unput(yytext[i]);
1371 BEGIN(yyextra->includeCtx);
1372 }
1373<SnippetDocTag>^{B}*"*"+{B}* {
1374 if (!(yyextra->snippetRtn && (yyextra->includeCtx==CComment || yyextra->includeCtx==CNComment))) REJECT;
1375 }
1376<SnippetDocTag>[^\\@\n]+ {
1377 yyextra->snippetName += yytext;
1378 }
1379<SnippetDocTag>{CMD} {
1380 yyextra->snippetName += yytext;
1381 }
1382
1383<SnippetDocTag>(\n|{CMD}"ilinebr")/{B}*("*/")? |
1384<SnippetDocTag>(\n|{CMD}"ilinebr"){B}*"*" {
1385 if (!yyextra->snippetName.stripWhiteSpace().empty() || yyextra->snippetRtn)
1386 {
1387 for (int i=(int)yyleng-1;i>=0;i--) unput(yytext[i]);
1388 yyextra->snippetName = yyextra->snippetName.stripWhiteSpace();
1389 DString blockId =
"["+yyextra->snippetName+
"]";
1391 {
1392 BEGIN(IncludeFile);
1393 }
1394 else
1395 {
1396 BEGIN(yyextra->includeCtx);
1397 }
1398 }
1399 else if (yyextra->snippetName.stripWhiteSpace().empty() && !yyextra->snippetRtn &&
1400 yyextra->includeCtx == ReadLine)
1401 {
1402 warn_doc_error(yyextra->fileName,yyextra->lineNr,
"no block identification found in \\snippet{{doc}} command, skipping");
1403 for (int i=(int)yyleng-1;i>=0;i--) unput(yytext[i]);
1406 BEGIN(yyextra->includeCtx);
1407 }
1408 else
1409 {
1410 if (yytext[0] == '\n')
1411 {
1412 yyextra->lineNr++;
1413 yyextra->col=0;
1414 }
1415 else
1416 {
1417 yyextra->col+=8;
1418 }
1419 yyextra->snippetRtn++;
1420 }
1421 }
1422
1423<IncludeDoc,SnippetDoc>\n{B}*{CPPC}[\/!]{B}*/\n {
1424 warn(yyextra->fileName,yyextra->lineNr,
"Found \\{}{{doc}} command without valid file name argument",
1425 YY_START==IncludeDoc? "include" : "snippet"
1426 );
1427 yyextra->lineNr++;
1430 BEGIN(yyextra->includeCtx);
1431 }
1432<IncludeDoc,SnippetDoc>\n{B}*{CPPC}[\/!] {
1433 yyextra->lineNr++;
1434 }
1435<IncludeDoc,SnippetDoc>\n {
1436 if (yyextra->snippetRtn)
1437 {
1439
1440
1441 warn(yyextra->fileName,yyextra->lineNr,
"Found \\{}{{doc}} command without valid file name argument",
1442 YY_START==IncludeDoc? "include" : "snippet"
1443 );
1447 BEGIN(yyextra->includeCtx);
1448 }
1449 else if (yyextra->includeCtx == ReadLine)
1450 {
1451 unput('\n');
1452 warn(yyextra->fileName,yyextra->lineNr,
"Found \\{}{{doc}} command without valid file name argument",
1453 YY_START==IncludeDoc? "include" : "snippet"
1454 );
1455 BEGIN(yyextra->includeCtx);
1456 }
1457 else
1458 {
1459 yyextra->lineNr++;
1460 yyextra->col=0;
1461 yyextra->snippetRtn++;
1462 }
1463 }
1464<IncludeDoc,SnippetDoc>. { // invalid character
1465 warn(yyextra->fileName,yyextra->lineNr,
"Found invalid character for file name of \\{}{{doc}} command",
1466 YY_START==IncludeDoc? "include" : "snippet"
1467 );
1471 BEGIN(yyextra->includeCtx);
1472 }
1473<CComment,ReadLine,IncludeFile>{CMD}"cond"/[^a-z_A-Z0-9] { // conditional section
1474 yyextra->condCtx = YY_START;
1475 BEGIN(CondLine);
1476 }
1477<CComment,ReadLine,IncludeFile>{CMD}"endcond"/[^a-z_A-Z0-9] { // end of conditional section
1478 bool oldSkip=yyextra->skip;
1480 if (YY_START==CComment && oldSkip && !yyextra->skip)
1481 {
1482
1483 if (yyextra->lang!=SrcLangExt::Python &&
1484 yyextra->lang!=SrcLangExt::VHDL &&
1485 yyextra->lang!=SrcLangExt::Markdown &&
1486 yyextra->lang!=SrcLangExt::Fortran)
1487 {
1488 yyextra->outBuf+='/';
1489 yyextra->outBuf+='*';
1490 yyextra->col+=2;
1491 if (yyextra->specialComment)
1492 {
1493 yyextra->outBuf+='*';
1494 yyextra->col++;
1495 }
1496 }
1497 }
1498 }
1499<CondLine>{B}*{CMD}doxyconfig{B}+{DOXYCFG} {
1501 }
1502<CondLine>([!()&| \ta-z_A-Z0-9.\-]|{CMD}"doxyconfig")+ {
1504 }
1505<CComment,ReadLine,IncludeFile>{CMD}"cond"{WSopt}/\n {
1506 yyextra->condCtx=YY_START;
1508 }
1509<CondLine>\n |
1510<CondLine>. { // forgot section id?
1513 }
1514<CComment,ReadLine,IncludeFile,Verbatim,VerbatimCode>{CMD}[a-z_A-Z][a-z_A-Z0-9-]* { // expand alias without arguments
1515 bool inCppComment = YY_START==ReadLine && yyextra->readLineCtx==SComment;
1516 bool inCComment = YY_START==CComment && yyextra->blockHeadCol>0;
1518 }
1519<CComment,ReadLine,IncludeFile,Verbatim,VerbatimCode>{B}?{CMD}"ilinebr"{B}{CMD}"ialias{" { // expand alias with arguments
1520 yyextra->lastBlockContext=YY_START;
1521 yyextra->blockCount=1;
1522 int extraSpace = (yytext[0]==' '? 1:0);
1523 yyextra->aliasString=yytext+9+extraSpace;
1524 yyextra->aliasCmd=yytext+9+extraSpace;
1525 yyextra->lastEscaped=0;
1526 BEGIN( ReadAliasArgs );
1527 }
1528<CComment,ReadLine,IncludeFile,Verbatim,VerbatimCode>{CMD}[a-z_A-Z][a-z_A-Z0-9-]*"{" { // expand alias with arguments
1529 yyextra->lastBlockContext=YY_START;
1530 yyextra->blockCount=1;
1531 yyextra->aliasString=yytext;
1532 yyextra->aliasCmd=yytext;
1533 yyextra->lastEscaped=0;
1534 BEGIN( ReadAliasArgs );
1535 }
1536<ReadAliasArgs>^[ \t]*"*" {
1538 if (indent>yyextra->blockHeadCol)
1539 {
1540 yyextra->aliasString+=yytext;
1541 }
1542 else
1543 {
1544
1545 }
1546 }
1547<ReadAliasArgs>^[ \t]*{CPPC}[/!]/[^\n]* { // skip leading special comments (see bug 618079)
1548 }
1549<ReadAliasArgs>[^{}\n\\\*]+ {
1550 yyextra->aliasString+=yytext;
1551 yyextra->lastEscaped=false;
1552 }
1553<ReadAliasArgs>"\\" {
1554 if (yyextra->lastEscaped) yyextra->lastEscaped=false;
1555 else yyextra->lastEscaped=true;
1556 yyextra->aliasString+=yytext;
1557 }
1558<ReadAliasArgs>{CMD}("endverbatim"|"endiliteral"|"endlatexonly"|"endhtmlonly"|"endxmlonly"|"enddocbookonly"|"endrtfonly"|"endmanonly"|"f$"|"f]"|"f}"|"f)") { /* end of verbatim block */
1559 yyextra->aliasString+=yytext;
1560 if (yyextra->inVerbatim && &yytext[1]==yyextra->blockName)
1561
1562
1563
1564
1565
1566
1567 {
1569 yyextra->inVerbatim=false;
1570 BEGIN(yyextra->lastCommentContext);
1571 }
1572 }
1573<ReadAliasArgs>\n {
1574 yyextra->aliasString+=yytext;
1575 yyextra->lastEscaped=false;
1576 if (yyextra->inVerbatim)
1577
1578 {
1580 BEGIN( yyextra->lastBlockContext );
1581 }
1582 }
1583<ReadAliasArgs>"{" {
1584 yyextra->aliasString+=yytext;
1585 if (!yyextra->lastEscaped) yyextra->blockCount++;
1586 yyextra->lastEscaped=false;
1587 }
1588<ReadAliasArgs>"}" {
1589 yyextra->aliasString+=yytext;
1590 if (!yyextra->lastEscaped) yyextra->blockCount--;
1591 if (yyextra->blockCount==0)
1592 {
1593 bool inCppComment = yyextra->lastBlockContext==ReadLine && yyextra->readLineCtx==SComment;
1594 bool inCComment = yyextra->lastBlockContext==CComment && yyextra->blockHeadCol>0;
1595 replaceAliases(yyscanner,yyextra->aliasString.view(),inCppComment,inCComment);
1596 BEGIN( yyextra->lastBlockContext );
1597 }
1598 yyextra->lastEscaped=false;
1599 }
1600<ReadAliasArgs>. {
1601 yyextra->aliasString+=yytext;
1602 yyextra->lastEscaped=false;
1603 }
1604<CopyLine>. {
1606 }
1607<CopyLine>\n {
1609 yyextra->insertCppCommentMarker=false;
1610 BEGIN(yyextra->readLineCtx);
1611 }
1612<ReadLine>{CMD}{CMD} |
1613<ReadLine>. {
1615 }
1616<IncludeFile>. {
1618 }
1619<IncludeFile>\n {
1622 }
1623<*>. {
1625 }
1626<<EOF>> {
1627 if (YY_START == ReadAliasArgs)
1628 {
1629 warn(yyextra->fileName,yyextra->lineNr,
1630 "Reached end of file while still searching closing '}}' of an alias argument (probable start: '{}')",
1631 yyextra->aliasCmd);
1632 }
1633 else if (YY_START==Verbatim || YY_START==VerbatimCode)
1634 {
1635 warn(yyextra->fileName,yyextra->lineNr,
1636 "Reached end of file while still searching closing '{}' of a verbatim block starting at line {}",
1637 yyextra->blockName,yyextra->verbatimLine);
1638 }
1639 if (yyextra->includeStack.empty())
1640 {
1641 yyextra->insertCppCommentMarker=false;
1643 }
1644 else
1645 {
1646 std::unique_ptr<commentcnv_FileState> &fs = yyextra->includeStack.back();
1647 YY_BUFFER_STATE oldBuf = YY_CURRENT_BUFFER;
1648 yy_switch_to_buffer(fs->bufState, yyscanner);
1649 yy_delete_buffer(oldBuf, yyscanner);
1650 BEGIN(fs->oldState);
1651 yyextra->fileName = fs->oldFileName;
1652 yyextra->lineNr = fs->oldLineNr;
1653 yyextra->inBuf = fs->oldFileBuf;
1654 yyextra->inBufPos = fs->oldFileBufPos;
1655 yyextra->includeCtx = fs->oldIncludeCtx;
1656 DString lineStr=
" \\ifile \""+yyextra->fileName+
"\" \\iline "+
DString().
setNum(yyextra->lineNr)+
" ";
1657 if (fs->oldRaiseLvl!=yyextra->raiseLevel)
1658 {
1659 lineStr+="\\iraise " + std::to_string(fs->oldRaiseLvl)+ " ";
1660 }
1661 if (fs->oldRaiseLbl!=yyextra->raiseLabel)
1662 {
1663 lineStr+="\\iprefix \"" + fs->oldRaiseLbl + "\" ";
1664 }
1665 lineStr+="\\ilinebr ";
1666 yyextra->raiseLevel = fs->oldRaiseLvl;
1667 yyextra->raiseLabel = fs->oldRaiseLbl;
1669 yyextra->includeStack.pop_back();
1670
1671
1672 }
1673 }
1674
1675<*>\n { fprintf(stderr,"Lex scanner %s (%s) default rule newline for state %s.\n", __FILE__, qPrint(yyextra->fileName),stateToString(YY_START));}
1676 */
1677%%