268 {NUMBER} {
269 if (yyextra->lang!=SrcLangExt::Cpp) REJECT;
271 }
272<Scan>{RAWBEGIN} {
273 if (yyextra->lang!=SrcLangExt::Cpp) REJECT;
275 BEGIN(RawString);
276 }
277<Scan>[^"'!\/\n\\#,\-=; \t@$]* { /* eat anything that is not " / , or \n */
279 }
280<Scan>[,= ;\t] { /* eat , so we have a nice separator in long initialization lines */
282 }
283<Scan>"'''"! |
284<Scan>"\"\"\""! { /* start of python long comment */
285 if (yyextra->lang!=SrcLangExt::Python)
286 {
287 REJECT;
288 }
289 else
290 {
291 yyextra->pythonDocString = true;
292 yyextra->pythonDocStringChar = yytext[0];
293 yyextra->nestingCount=1;
296 BEGIN(CComment);
297 yyextra->commentStack.push(yyextra->lineNr);
298 }
299 }
300<Scan>"'''" |
301<Scan>"\"\"\"" { /* start of python long comment */
302 if (yyextra->lang!=SrcLangExt::Python)
303 {
304 REJECT;
305 }
307 {
308 REJECT;
309 }
310 else
311 {
312 yyextra->pythonDocString = true;
313 yyextra->pythonDocStringChar = yytext[0];
314 yyextra->nestingCount=1;
317 BEGIN(CComment);
318 yyextra->commentStack.push(yyextra->lineNr);
319 }
320 }
321<Scan>{B}*![><!]/.*\n {
322 if (yyextra->lang!=SrcLangExt::Fortran)
323 {
324 REJECT;
325 }
326 else
327 {
328 yyextra->nestingCount=0;
330 yyextra->specialComment=true;
332 yyextra->blockHeadCol=yyextra->col-2;
333 BEGIN(CComment);
334 yyextra->commentStack.push(yyextra->lineNr);
335 }
336 }
337<Scan>[Cc\*][><!]/.*\n {
338 if (yyextra->lang!=SrcLangExt::Fortran)
339 {
340 REJECT;
341 }
342 else
343 {
344
345 if (yyextra->isFixedForm && (yyextra->col == 0))
346 {
347 yyextra->nestingCount=0;
349 yyextra->specialComment=true;
351 yyextra->blockHeadCol=yyextra->col-1;
352 BEGIN(CComment);
353 yyextra->commentStack.push(yyextra->lineNr);
354 }
355 else
356 {
357 REJECT;
358 }
359 }
360 }
361<Scan>!.*\n {
362 if (yyextra->lang!=SrcLangExt::Fortran)
363 {
364 REJECT;
365 }
366 else
367 {
369 }
370 }
371<Scan>[Cc\*].*\n {
372 if (yyextra->lang!=SrcLangExt::Fortran)
373 {
374 REJECT;
375 }
376 else
377 {
378 if (yyextra->col == 0)
379 {
381 }
382 else
383 {
384 REJECT;
385 }
386 }
387 }
388<Scan>[$]?"@\"" { /* start of an interpolated verbatim C# string */
389 if (yyextra->lang!=SrcLangExt::CSharp) REJECT
391 yyextra->stringContext = YY_START;
392 BEGIN(SkipVerbString);
393 }
394<Scan>"\"" { /* start of a string */
396 yyextra->stringContext = YY_START;
397 BEGIN(SkipString);
398 }
399<Scan>' {
401 yyextra->charContext = YY_START;
402 if (yyextra->lang!=SrcLangExt::VHDL)
403 {
404 BEGIN(SkipChar);
405 }
406 }
407<Scan>\n { /* new line */
409 }
410<Scan>{CPPC}[!/]/.*\n[ \t]*{CPPC}[!/][ \t]*{CMD}"}" { // see bug #8731, don't treat multiline C++ comment as detailed description
411
412 yyextra->inSpecialComment=true;
413 yyextra->blockHeadCol=yyextra->col+1;
414 yyextra->insertCppCommentMarker=true;
416 yyextra->readLineCtx=YY_START;
417 BEGIN(ReadLine);
418 }
419<Scan>{CPPC}"!"/.*\n[ \t]*{CPPC}[\/!][^\/] | /* start C++ style special comment block */
420<Scan>({CPPC}"/"[/]*)/[^/].*\n[ \t]*{CPPC}[\/!][^\/] { /* start C++ style special comment block */
421 if (yyextra->mlBrief)
422 {
423 REJECT;
424 }
425 else
426 {
427 int i=3;
428 if (yytext[2]=='/')
429 {
430 while (i<(int)yyleng && yytext[i]=='/') i++;
431 }
432 yyextra->blockHeadCol=yyextra->col+1;
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;
454 yyextra->inRoseComment=true;
455 BEGIN(SComment);
456 }
457<Scan>{CPPC}[!\/]/.*\n[ \t]*{CPPC}[|\/][ \t]*{CMD}"}" { // next line contains an end marker, see bug 752712
458 yyextra->inSpecialComment=yytext[2]=='/' || yytext[2]=='!';
459 if (yyextra->inSpecialComment)
460 {
461 yyextra->blockHeadCol=yyextra->col+1;
462 }
464 yyextra->readLineCtx=YY_START;
465 BEGIN(ReadLine);
466 }
467<Scan>{CPPC}[!/]/.*\n { /* one line special C++ comment */
468 yyextra->inSpecialComment=true;
469 yyextra->blockHeadCol=yyextra->col+1;
470 yyextra->insertCppCommentMarker=true;
472 yyextra->readLineCtx=YY_START;
473 BEGIN(ReadLine);
474 }
475<Scan>{CPPC}/.*\n { /* one line normal C++ comment */
476 yyextra->inSpecialComment=false;
478 yyextra->readLineCtx=YY_START;
479 BEGIN(CopyLine);
480 }
481<Scan>{CCS}{CCE} { /* avoid matching next rule for empty C comment, see bug 711723 */
483 }
484<Scan>{CCS}[*!]? { /* start of a C comment */
485 if (yyextra->lang==SrcLangExt::Python)
486 {
487 REJECT;
488 }
489 yyextra->specialComment=(int)yyleng==3;
490 yyextra->nestingCount=1;
493 if (yyextra->specialComment)
494 {
495 yyextra->blockHeadCol=0;
496 BEGIN(CComment);
497 }
498 else
499 {
500 BEGIN(CNComment);
501 }
502 yyextra->commentStack.push(yyextra->lineNr);
503 }
504<Scan>"#"[^\n]*\n {
505 if (yyextra->lang!=SrcLangExt::PHP)
506 {
507 REJECT;
508 }
510 }
511<Scan>"#"("#")? {
512 if (yyextra->lang!=SrcLangExt::Python)
513 {
514 REJECT;
515 }
516 else
517 {
518 yyextra->nestingCount=0;
520 yyextra->specialComment=(int)yyleng==2;
521 if (yyextra->specialComment)
522 {
523 yyextra->blockHeadCol=yyextra->col;
524 }
525 yyextra->commentStack.push(yyextra->lineNr);
527 BEGIN(CComment);
528 }
529 }
530<Scan>"--"[^!][^\n]* {
531 if (yyextra->lang!=SrcLangExt::VHDL)
532 {
533 REJECT;
534 }
535 else
536 {
538 }
539 }
540<Scan>"--!" {
541 if (yyextra->lang!=SrcLangExt::VHDL)
542 {
543 REJECT;
544 }
545 else
546 {
547 yyextra->specialComment=true;
548 yyextra->blockHeadCol=yyextra->col;
549 yyextra->vhdl = true;
550 yyextra->nestingCount=0;
552 yyextra->commentStack.push(yyextra->lineNr);
554 BEGIN(CComment);
555 }
556 }
557<Scan>{B}*![><!] {
558 if (yyextra->lang!=SrcLangExt::Fortran)
559 {
560 REJECT;
561 }
562 else
563 {
564 yyextra->nestingCount=0;
566 yyextra->specialComment=true;
567 yyextra->blockHeadCol=yyextra->col;
568 yyextra->commentStack.push(yyextra->lineNr);
570 BEGIN(CComment);
571 }
572 }
573<RawString>{RAWEND} {
576 {
577 BEGIN(Scan);
578 }
579 }
DString extractEndRawStringDelimiter(const char *rawEnd)
580<RawString>[^)\n]+ { copyToOutput(yyscanner,yytext,yyleng); }
581<RawString>\n { copyToOutput(yyscanner,yytext,yyleng); }
582<RawString>. { copyToOutput(yyscanner,yytext,yyleng); }
583
584<CComment,CNComment,ReadLine,IncludeFile>{MAILADDR} |
585<CComment,CNComment,ReadLine,IncludeFile>"<"{MAILADDR}">" { // Mail address, to prevent seeing e.g x@code-factory.org as start of a code block
587 }
588<CComment,IncludeFile>"{"[ \t]*"@code"/[ \t\n] {
590 yyextra->lastCommentContext = YY_START;
591 yyextra->javaBlock=1;
592 yyextra->blockName=
DString(
"end")+&yytext[1];
593 yyextra->inVerbatim=true;
594 yyextra->verbatimLine=yyextra->lineNr;
595 BEGIN(VerbatimCode);
596 }
597<CComment,IncludeFile>"{"[ \t]*"@literal"/[ \t\n] {
599 yyextra->lastCommentContext = YY_START;
600 yyextra->javaBlock=1;
601 yyextra->blockName=
DString(
"end")+&yytext[1];
602 yyextra->inVerbatim=true;
603 yyextra->verbatimLine=yyextra->lineNr;
604 BEGIN(VerbatimCode);
605 }
606<CComment,ReadLine,IncludeFile>{CMD}"ilinebr"[ \t]+("```"[`]*|"~~~"[~]*) { /* start of markdown code block */
608 {
609 REJECT;
610 }
612 yyextra->lastCommentContext = YY_START;
613 yyextra->javaBlock=0;
615 yyextra->inVerbatim=true;
616 yyextra->verbatimLine=yyextra->lineNr;
617 BEGIN(VerbatimCode);
618 }
DString right(size_t len) const
619<CComment,ReadLine,IncludeFile>^[ \t]*("```"[`]*|"~~~"[~]*) { /* start of markdown code block */
621 {
622 REJECT;
623 }
625 yyextra->lastCommentContext = YY_START;
626 yyextra->javaBlock=0;
628 yyextra->inVerbatim=true;
629 yyextra->verbatimLine=yyextra->lineNr;
630 BEGIN(VerbatimCode);
631 }
DString left(size_t len) const
632<CComment,ReadLine,IncludeFile>{CMD}("dot"|"code"|"msc"|"startuml"|"mermaid")/[^a-z_A-Z0-9] { /* start of a verbatim block */
634 if (yyextra->inSpecialComment || yyextra->specialComment || yyextra->lang==SrcLangExt::Markdown)
635 {
636 yyextra->lastCommentContext = YY_START;
637 yyextra->javaBlock=0;
638 if (
dstrcmp(&yytext[1],
"startuml")==0)
639 {
640 yyextra->blockName="enduml";
641 }
642 else
643 {
644 yyextra->blockName=
DString(
"end")+&yytext[1];
645 }
646 yyextra->inVerbatim=true;
647 yyextra->verbatimLine=yyextra->lineNr;
648 BEGIN(VerbatimCode);
649 }
650 }
int dstrcmp(const char *str1, const char *str2)
651<CComment,ReadLine,IncludeFile>"\\`" {
653 }
654<CComment,ReadLine,IncludeFile>"```" { // skip ``` if not at the start of the line
656 }
657<CComment,ReadLine,IncludeFile>"`"{1,2} {
659 {
660 REJECT;
661 }
663 if (yyextra->inSpecialComment || yyextra->specialComment || yyextra->lang==SrcLangExt::Markdown)
664 {
665 yyextra->lastCommentContext = YY_START;
666 yyextra->javaBlock=0;
667 yyextra->blockName=yytext;
668 yyextra->inVerbatim=true;
669 yyextra->verbatimLine=yyextra->lineNr;
670 BEGIN(VerbatimCode);
671 }
672 }
673<CComment,ReadLine,IncludeFile>{CMD}("f$"|"f["|"f{"|"f(") {
675 if (yyextra->inSpecialComment || yyextra->specialComment || yyextra->lang==SrcLangExt::Markdown)
676 {
677 yyextra->blockName=&yytext[1];
678 if (yyextra->blockName.at(1)=='[')
679 {
680 yyextra->blockName.at(1)=']';
681 }
682 else if (yyextra->blockName.at(1)=='{')
683 {
684 yyextra->blockName.at(1)='}';
685 }
686 else if (yyextra->blockName.at(1)=='(')
687 {
688 yyextra->blockName.at(1)=')';
689 }
690 yyextra->lastCommentContext = YY_START;
691 yyextra->inVerbatim=true;
692 yyextra->verbatimLine=yyextra->lineNr;
693 BEGIN(Verbatim);
694 }
695 }
696<CComment,ReadLine,IncludeFile>"<!--!" { /* HTML comment doxygen command*/
697 if (yyextra->inVerbatim) REJECT;
698
699 yyextra->inHtmlDoxygenCommand=true;
700 }
701<CComment,ReadLine,IncludeFile>"-->" { /* potential end HTML comment doxygen command*/
702 if (yyextra->inHtmlDoxygenCommand)
703 {
704 yyextra->inHtmlDoxygenCommand=false;
705 }
706 else
707 {
709 }
710 }
711<CComment,ReadLine,IncludeFile>"<!--" { /* HTML comment */
713 if (yyextra->inSpecialComment || yyextra->specialComment || yyextra->lang==SrcLangExt::Markdown)
714 {
715 yyextra->blockName="-->";
716 yyextra->lastCommentContext = YY_START;
717 yyextra->inVerbatim=true;
718 yyextra->verbatimLine=yyextra->lineNr;
719 BEGIN(Verbatim);
720 }
721 }
722<CComment,ReadLine,IncludeFile>{CMD}("verbatim"|"iliteral"|"latexonly"|"htmlonly"|"xmlonly"|"docbookonly"|"rtfonly"|"manonly")/[^a-z_A-Z0-9] { /* start of a verbatim block */
724 if (yyextra->inSpecialComment || yyextra->specialComment || yyextra->lang==SrcLangExt::Markdown)
725 {
726 yyextra->blockName=
DString(
"end")+&yytext[1];
727 yyextra->lastCommentContext = YY_START;
728 yyextra->inVerbatim=true;
729 yyextra->verbatimLine=yyextra->lineNr;
730 BEGIN(Verbatim);
731 }
732 }
733<Scan>"\\\"" { /* escaped double quote */
735 }
736<Scan>"\\\\" { /* escaped backslash */
738 }
739<Scan>. { /* any other character */
741 }
742<Verbatim>{CMD}("endverbatim"|"endiliteral"|"endlatexonly"|"endhtmlonly"|"endxmlonly"|"enddocbookonly"|"endrtfonly"|"endmanonly"|"f$"|"f]"|"f}"|"f)") { /* end of verbatim block */
744 if (&yytext[1]==yyextra->blockName)
745 {
746 yyextra->inVerbatim=false;
747 BEGIN(yyextra->lastCommentContext);
748 }
749 }
750<Verbatim>"-->" {
752 if (yytext==yyextra->blockName)
753 {
754 yyextra->inVerbatim=false;
755 BEGIN(yyextra->lastCommentContext);
756 }
757 }
758<VerbatimCode>"{" {
759 if (yyextra->javaBlock==0)
760 {
761 REJECT;
762 }
763 else
764 {
765 yyextra->javaBlock++;
767 }
768 }
769<VerbatimCode>"}" {
770 if (yyextra->javaBlock==0)
771 {
772 REJECT;
773 }
774 else
775 {
776 yyextra->javaBlock--;
777 if (yyextra->javaBlock==0)
778 {
780 yyextra->inVerbatim=false;
781 BEGIN(yyextra->lastCommentContext);
782 }
783 else
784 {
786 }
787 }
788 }
789<VerbatimCode>("```"[`]*|"~~~"[~]*) { /* end of markdown code block */
790 if (yytext[0]=='`' && (yyextra->blockName=="`" || yyextra->blockName=="``"))
791 {
792
794 }
795 else
796 {
798 if (yytext[0]==yyextra->blockName[0])
799 {
800 yyextra->inVerbatim=false;
801 BEGIN(yyextra->lastCommentContext);
802 }
803 }
804 }
805<VerbatimCode>"''" {
808 {
809 yyextra->inVerbatim=false;
810 BEGIN(yyextra->lastCommentContext);
811 }
812 }
813<VerbatimCode>"'" {
816 {
817 yyextra->inVerbatim=false;
818 BEGIN(yyextra->lastCommentContext);
819 }
820 }
821<VerbatimCode>"`"{1,2} {
823 if (yytext==yyextra->blockName)
824 {
825 yyextra->inVerbatim=false;
826 BEGIN(yyextra->lastCommentContext);
827 }
828 }
829<VerbatimCode>{CMD}("enddot"|"endcode"|"endmsc"|"enduml"|"endmermaid")/("{")? { // end of verbatim block
831 if (&yytext[1]==yyextra->blockName)
832 {
833 yyextra->inVerbatim=false;
834 BEGIN(yyextra->lastCommentContext);
835 }
836 }
837<VerbatimCode>^[ \t]*{CPPC}[\!\/]? { /* skip leading comments */
838 if (!yyextra->inSpecialComment || yyextra->mlBrief)
839 {
841 }
842 else
843 {
844 int l=0;
845 while (yytext[l]==' ' || yytext[l]=='\t')
846 {
847 l++;
848 }
850 if (yyleng-l==3)
851 {
853 }
854 else
855 {
857 }
858 }
859 }
860<Verbatim,VerbatimCode>[^`'~@\/\-\\\n{}]* { /* any character not a backslash or new line or } */
862 }
863<Verbatim,VerbatimCode>[^`'~@\/\-\\\n{}]+/\n{B}*"//" {
864 if (yyextra->lastCommentContext!=ReadLine)
865 {
866 REJECT;
867 }
868 else
869 {
871 }
872 }
873<Verbatim,VerbatimCode>[^`'~@\/\-\\\n{}]+/\n { /* premature end of comment block */
874 if (yyextra->lastCommentContext==ReadLine)
875 {
876 yyextra->inVerbatim=false;
877 BEGIN(yyextra->lastCommentContext);
878 }
880 }
881<Verbatim,VerbatimCode>\n { /* new line in verbatim block */
883 if (yyextra->lastCommentContext == IncludeFile)
884 {
886 }
887 }
888<Verbatim>^[ \t]*{CPPC}[/!] {
889 if (yyextra->blockName=="enddot" || yyextra->blockName=="endmsc" || yyextra->blockName=="enduml" || yyextra->blockName.at(0)=='f')
890 {
891
892 int l=0;
893 while (yytext[l]==' ' || yytext[l]=='\t')
894 {
895 l++;
896 }
899 }
900 else
901 {
902 REJECT;
903 }
904 }
905<Verbatim,VerbatimCode>. { /* any other character */
907 }
908<SkipString>\\. { /* escaped character in string */
909 if (yyextra->lang==SrcLangExt::Fortran || yyextra->lang==SrcLangExt::VHDL)
910 {
911 unput(yytext[1]);
913 }
914 else
915 {
917 }
918 }
919<SkipString>"\"" { /* end of string */
921 BEGIN(yyextra->stringContext);
922 }
923<SkipString>. { /* any other string character */
925 }
926<SkipString>\n { /* new line inside string (illegal for some compilers) */
928 }
929<SkipVerbString>[^"\n]+ {
931 }
932<SkipVerbString>\"\" { // escaped quote
934 }
935<SkipVerbString>"\"" { /* end of string */
937 BEGIN(yyextra->stringContext);
938 }
939<SkipVerbString>. {
941 }
942<SkipVerbString>\n {
944 }
945<SkipChar>\\. { /* escaped character */
946 if (yyextra->lang==SrcLangExt::Fortran || yyextra->lang==SrcLangExt::VHDL)
947 {
948 unput(yytext[1]);
950 }
951 else
952 {
954 }
955 }
956<SkipChar>' { /* end of character literal */
958 BEGIN(yyextra->charContext);
959 }
960<SkipChar>. { /* any other string character */
962 }
963<SkipChar>\n { /* new line character */
965 }
966
967<CComment,CNComment>[^ `~<\\!@*\n{\"'\/-`]* { /* anything that is not a '*' or command */
969 }
970<CComment,CNComment>^{B}*"*"+[^*\/<\\@\n{\"`]* { /* stars without slashes */
971 if (yyextra->lang==SrcLangExt::Markdown) REJECT;
973 if (yyextra->col>yyextra->blockHeadCol)
974 {
975
976 yyextra->blockHeadCol=yyextra->col;
977 }
979 }
980<CComment>"'''" |
981<CComment>"\"\"\"" { /* end of Python docstring */
982 if (yyextra->lang!=SrcLangExt::Python)
983 {
984 REJECT;
985 }
986 else if (yyextra->pythonDocStringChar != yytext[0])
987 {
989 }
990 else
991 {
992 yyextra->nestingCount--;
993 yyextra->pythonDocString = false;
994 yyextra->pythonDocStringChar = '\0';
996 BEGIN(Scan);
997 }
998 }
999<CComment,CNComment>\n { /* new line in comment */
1001
1002 if (yyextra->lang==SrcLangExt::Fortran)
1003 {
1004 BEGIN(Scan);
1005 }
1006 }
1007<CComment,CNComment>"/""/"+/"*/" { /* we are already in C-comment so not a start of a nested comment but
1008 * just the
end of the comment (the
end part is handled later). */
1010 }
DirIterator end(const DirIterator &) noexcept
1011<CComment,CNComment>"/"+"*" { /* nested C comment */
1012 if (yyextra->lang==SrcLangExt::Python ||
1013 yyextra->lang==SrcLangExt::Markdown)
1014 {
1015 REJECT;
1016 }
1017 yyextra->nestingCount++;
1018 yyextra->commentStack.push(yyextra->lineNr);
1020 }
1021<CComment,CNComment>^{B}*"*"+"/" |
1022<CComment,CNComment>"*"+"/" { /* end of C comment */
1023 if (yyextra->lang==SrcLangExt::Python ||
1024 yyextra->lang==SrcLangExt::Markdown)
1025 {
1026 REJECT;
1027 }
1028 else
1029 {
1031 yyextra->nestingCount--;
1032 if (yyextra->nestingCount<=0)
1033 {
1034 BEGIN(Scan);
1035 }
1036 else
1037 {
1038
1039 yyextra->commentStack.pop();
1040 }
1041 }
1042 }
1043
1044<CComment,CNComment>"\n"/[ \t]*"#" {
1045 if (yyextra->lang!=SrcLangExt::VHDL)
1046 {
1047 REJECT;
1048 }
1049 else
1050 {
1051 if (yyextra->vhdl)
1052 {
1053 yyextra->vhdl = false;
1055 BEGIN(Scan);
1056 }
1057 else
1058 {
1059 REJECT;
1060 }
1061 }
1062 }
1063<CComment,CNComment>"\n"/[ \t]*"-" {
1064 if (yyextra->lang!=SrcLangExt::Python || yyextra->pythonDocString)
1065 {
1066 REJECT;
1067 }
1068 else
1069 {
1071 BEGIN(Scan);
1072 }
1073 }
1074<CComment,CNComment>"\n"/[ \t]*[^ \t#\-] {
1075 if (yyextra->lang==SrcLangExt::Python)
1076 {
1077 if (yyextra->pythonDocString)
1078 {
1079 REJECT;
1080 }
1081 else
1082 {
1084 BEGIN(Scan);
1085 }
1086 }
1087 else if (yyextra->lang==SrcLangExt::VHDL)
1088 {
1089 if (yyextra->vhdl)
1090 {
1091 yyextra->vhdl = false;
1093 BEGIN(Scan);
1094 }
1095 else
1096 {
1097 REJECT;
1098 }
1099 }
1100 else
1101 {
1102 REJECT;
1103 }
1104 }
1105
1106<CComment,CNComment>"'" {
1107 yyextra->charContext = YY_START;
1109 BEGIN(SkipChar);
1110 }
1111<CComment,CNComment>"\"" {
1112 yyextra->stringContext = YY_START;
1114 BEGIN(SkipString);
1115 }
1116 */
1117<CComment,CNComment>{CMD}"~"[a-z_A-Z-]* { // language switch command
1118 if (yyextra->lang!=SrcLangExt::Markdown) REJECT;
1120 if (!langId.
empty() &&
1122 {
1124 {
1125 warn(yyextra->fileName,yyextra->lineNr,
1127 }
1128 BEGIN(SkipLang);
1129 }
1130 }
#define Config_getEnumAsString(name)
#define Config_isAvailableEnum(name, value)
int dstricmp(const char *s1, const char *s2)
1131<CComment,CNComment>{CMD}{CMD} |
1132<CComment,CNComment>. {
1134 }
1135<SkipLang>{CMD}"~"[a-zA-Z-]* { /* language switch */
1138 {
1139 warn(yyextra->fileName,yyextra->lineNr,
1141 }
1142 else if (langId.
empty() ||
1144 {
1145 BEGIN(CComment);
1146 }
1147 }
1148<SkipLang>[^*@\\\n]* { /* any character not a *, @, backslash or new line */
1149 }
1150<SkipLang>\n { /* new line in language block, needed for keeping track of line numbers */
1152 }
1153<SkipLang>. { /* any other character */
1154 }
1155<SComment>^[ \t]*{CPPC}"/"{SLASHopt}/\n {
1157 }
1158<SComment>\n[ \t]*{CPPC}"/"{SLASHopt}/\n {
1160 }
1161<SComment>^[ \t]*{CPPC}"/"[^\/\n]/.*\n {
1163 yyextra->readLineCtx=YY_START;
1164 YY_CURRENT_BUFFER->yy_at_bol=1;
1165 BEGIN(ReadLine);
1166 }
1167<SComment>\n[ \t]*{CPPC}[\/!]("<")?[ \t]*{CMD}"}".*\n {
1168
1171 yyextra->inSpecialComment=false;
1172 yyextra->inRoseComment=false;
1173 BEGIN(Scan);
1174 }
1175<SComment>\n[ \t]*{CPPC}"/"[^\\@\/\n]/.*\n {
1177 yyextra->readLineCtx=YY_START;
1178 YY_CURRENT_BUFFER->yy_at_bol=1;
1179 BEGIN(ReadLine);
1180 }
1181<SComment>^[ \t]*{CPPC}"!" | // just //!
1182<SComment>^[ \t]*{CPPC}"!<"/.*\n | // or //!< something
1183<SComment>^[ \t]*{CPPC}"!"[^<]/.*\n { // or //!something
1185 yyextra->readLineCtx=YY_START;
1186 YY_CURRENT_BUFFER->yy_at_bol=1;
1187 BEGIN(ReadLine);
1188 }
1189<SComment>\n[ \t]*{CPPC}"!" |
1190<SComment>\n[ \t]*{CPPC}"!<"/.*\n |
1191<SComment>\n[ \t]*{CPPC}"!"[^<\n]/.*\n {
1193 yyextra->readLineCtx=YY_START;
1194 YY_CURRENT_BUFFER->yy_at_bol=1;
1195 BEGIN(ReadLine);
1196 }
1197<SComment>^[ \t]*{CPPC}"##"/.*\n {
1198 if (!yyextra->inRoseComment)
1199 {
1200 REJECT;
1201 }
1202 else
1203 {
1205 yyextra->readLineCtx=YY_START;
1206 YY_CURRENT_BUFFER->yy_at_bol=1;
1207 BEGIN(ReadLine);
1208 }
1209 }
1210<SComment>\n[ \t]*{CPPC}"##"/.*\n {
1211 if (!yyextra->inRoseComment)
1212 {
1213 REJECT;
1214 }
1215 else
1216 {
1218 yyextra->readLineCtx=YY_START;
1219 YY_CURRENT_BUFFER->yy_at_bol=1;
1220 BEGIN(ReadLine);
1221 }
1222 }
1223<SComment>\n { /* end of special comment */
1226 yyextra->inSpecialComment=false;
1227 yyextra->inRoseComment=false;
1228 yyextra->insertCppCommentMarker=false;
1229 yyextra->readLineCtx = Scan;
1230
1231 BEGIN(Scan);
1232 }
1233<ReadLine,CopyLine>{CCS}"*" {
1235 }
1236<ReadLine,CopyLine>{CCE} {
1238 }
1239<ReadLine,CopyLine>"*" {
1241 }
1242<ReadLine,CopyLine>{RL} {
1244 }
1245<ReadLine,CopyLine>{RL}/{B}{CMD}"ilinebr"{B} {
1247 }
1248<ReadLine,CopyLine>{RLopt}/\n {
1250 yyextra->insertCppCommentMarker=false;
1251 BEGIN(yyextra->readLineCtx);
1252 }
1253<CComment,CNComment,ReadLine>"\<" { /* escaped html comment */
1255 }
1256<CComment,CNComment,ReadLine>{CMD}{CMD}[~a-z_A-Z][a-z_A-Z0-9]*[ \t]* { // escaped command
1258 }
1259
1260<CComment,ReadLine,IncludeFile>{CMD}("include"{OPTS}|"includedoc"{OPTS}*) {
1261 if (!
parseIncludeOptions(yyscanner,std::string_view{yytext,
static_cast<size_t>(yyleng)})) REJECT;
1262 yyextra->includeCtx = YY_START;
1263 yyextra->firstIncludeLine = true;
1264 yyextra->insertCommentCol = yyextra->col;
1265 if (!yyextra->insertCppCommentMarker && (yyextra->includeCtx==ReadLine || yyextra->includeCtx==IncludeFile))
1266 {
1267 yyextra->insertCppCommentMarker = yyextra->mlBrief;
1268 }
1269
1270 BEGIN(IncludeDoc);
1271 }
1272<CComment,ReadLine,IncludeFile>{CMD}("snippet"{OPTS}|"snippetdoc"{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 BEGIN(SnippetDoc);
1283 }
1284<IncludeDoc,SnippetDoc>{B}*
1285<IncludeDoc>{FILEMASK}|"\""[^\n\"]+"\"" {
1287 if (yytext[0]=='"')
1288 {
1289 fileName=fileName.
mid(1,fileName.
length()-2);
1290 }
1292 {
1293 BEGIN(IncludeFile);
1294 }
1295 else
1296 {
1297 BEGIN(yyextra->includeCtx);
1298 }
1299 }
1300<SnippetDoc>({FILEMASK}|"\""[^\n\"]+"\""){B}+ {
1301 yyextra->snippetFileName=yytext;
1302 yyextra->snippetFileName=yyextra->snippetFileName.stripWhiteSpace();
1303 if (yyextra->snippetFileName == "this") yyextra->snippetFileName=yyextra->fileName;
1304 yyextra->snippetName = "";
1305 BEGIN(SnippetDocTag);
1306 }
1307<SnippetDocTag>[^\\@\n]+ {
1308 yyextra->snippetName += yytext;
1309 }
1310<SnippetDocTag>{CMD} {
1311 yyextra->snippetName += yytext;
1312 }
1313<SnippetDocTag>(\n|{CMD}"ilinebr") {
1314 for (int i=(int)yyleng-1;i>=0;i--) unput(yytext[i]);
1315 yyextra->snippetName = yyextra->snippetName.stripWhiteSpace();
1316 DString blockId =
"["+yyextra->snippetName+
"]";
1318 {
1319 BEGIN(IncludeFile);
1320 }
1321 else
1322 {
1323 BEGIN(yyextra->includeCtx);
1324 }
1325 }
1326
1327<IncludeDoc,SnippetDoc>\n {
1330
1331
1332 BEGIN(yyextra->includeCtx);
1333 }
1334<IncludeDoc,SnippetDoc>. { // invalid character
1336 BEGIN(yyextra->includeCtx);
1337 }
1338<CComment,ReadLine,IncludeFile>{CMD}"cond"/[^a-z_A-Z0-9] { // conditional section
1339 yyextra->condCtx = YY_START;
1340 BEGIN(CondLine);
1341 }
1342<CComment,ReadLine,IncludeFile>{CMD}"endcond"/[^a-z_A-Z0-9] { // end of conditional section
1343 bool oldSkip=yyextra->skip;
1345 if (YY_START==CComment && oldSkip && !yyextra->skip)
1346 {
1347
1348 if (yyextra->lang!=SrcLangExt::Python &&
1349 yyextra->lang!=SrcLangExt::VHDL &&
1350 yyextra->lang!=SrcLangExt::Markdown &&
1351 yyextra->lang!=SrcLangExt::Fortran)
1352 {
1353 yyextra->outBuf+='/';
1354 yyextra->outBuf+='*';
1355 yyextra->col+=2;
1356 if (yyextra->specialComment)
1357 {
1358 yyextra->outBuf+='*';
1359 yyextra->col++;
1360 }
1361 }
1362 }
1363 }
1364<CondLine>{B}*{CMD}doxyconfig{B}+{DOXYCFG} {
1366 }
1367<CondLine>([!()&| \ta-z_A-Z0-9.\-]|{CMD}"doxyconfig")+ {
1369 }
1370<CComment,ReadLine,IncludeFile>{CMD}"cond"{WSopt}/\n {
1371 yyextra->condCtx=YY_START;
1373 }
1374<CondLine>\n |
1375<CondLine>. { // forgot section id?
1378 }
1379<CComment,ReadLine,IncludeFile,Verbatim,VerbatimCode>{CMD}[a-z_A-Z][a-z_A-Z0-9-]* { // expand alias without arguments
1380 bool inCppComment = YY_START==ReadLine && yyextra->readLineCtx==SComment;
1381 bool inCComment = YY_START==CComment && yyextra->blockHeadCol>0;
1383 }
1384<CComment,ReadLine,IncludeFile,Verbatim,VerbatimCode>{B}?{CMD}"ilinebr"{B}{CMD}"ialias{" { // expand alias with arguments
1385 yyextra->lastBlockContext=YY_START;
1386 yyextra->blockCount=1;
1387 int extraSpace = (yytext[0]==' '? 1:0);
1388 yyextra->aliasString=yytext+9+extraSpace;
1389 yyextra->aliasCmd=yytext+9+extraSpace;
1390 yyextra->lastEscaped=0;
1391 BEGIN( ReadAliasArgs );
1392 }
1393<CComment,ReadLine,IncludeFile,Verbatim,VerbatimCode>{CMD}[a-z_A-Z][a-z_A-Z0-9-]*"{" { // expand alias with arguments
1394 yyextra->lastBlockContext=YY_START;
1395 yyextra->blockCount=1;
1396 yyextra->aliasString=yytext;
1397 yyextra->aliasCmd=yytext;
1398 yyextra->lastEscaped=0;
1399 BEGIN( ReadAliasArgs );
1400 }
1401<ReadAliasArgs>^[ \t]*"*" {
1403 if (indent>yyextra->blockHeadCol)
1404 {
1405 yyextra->aliasString+=yytext;
1406 }
1407 else
1408 {
1409
1410 }
1411 }
1412<ReadAliasArgs>^[ \t]*{CPPC}[/!]/[^\n]* { // skip leading special comments (see bug 618079)
1413 }
1414<ReadAliasArgs>[^{}\n\\\*]+ {
1415 yyextra->aliasString+=yytext;
1416 yyextra->lastEscaped=false;
1417 }
1418<ReadAliasArgs>"\\" {
1419 if (yyextra->lastEscaped) yyextra->lastEscaped=false;
1420 else yyextra->lastEscaped=true;
1421 yyextra->aliasString+=yytext;
1422 }
1423<ReadAliasArgs>{CMD}("endverbatim"|"endiliteral"|"endlatexonly"|"endhtmlonly"|"endxmlonly"|"enddocbookonly"|"endrtfonly"|"endmanonly"|"f$"|"f]"|"f}"|"f)") { /* end of verbatim block */
1424 yyextra->aliasString+=yytext;
1425 if (yyextra->inVerbatim && &yytext[1]==yyextra->blockName)
1426
1427
1428
1429
1430
1431
1432 {
1434 yyextra->inVerbatim=false;
1435 BEGIN(yyextra->lastCommentContext);
1436 }
1437 }
1438<ReadAliasArgs>\n {
1439 yyextra->aliasString+=yytext;
1440 yyextra->lastEscaped=false;
1441 if (yyextra->inVerbatim)
1442
1443 {
1445 BEGIN( yyextra->lastBlockContext );
1446 }
1447 }
1448<ReadAliasArgs>"{" {
1449 yyextra->aliasString+=yytext;
1450 if (!yyextra->lastEscaped) yyextra->blockCount++;
1451 yyextra->lastEscaped=false;
1452 }
1453<ReadAliasArgs>"}" {
1454 yyextra->aliasString+=yytext;
1455 if (!yyextra->lastEscaped) yyextra->blockCount--;
1456 if (yyextra->blockCount==0)
1457 {
1458 bool inCppComment = yyextra->lastBlockContext==ReadLine && yyextra->readLineCtx==SComment;
1459 bool inCComment = yyextra->lastBlockContext==CComment && yyextra->blockHeadCol>0;
1460 replaceAliases(yyscanner,yyextra->aliasString.view(),inCppComment,inCComment);
1461 BEGIN( yyextra->lastBlockContext );
1462 }
1463 yyextra->lastEscaped=false;
1464 }
1465<ReadAliasArgs>. {
1466 yyextra->aliasString+=yytext;
1467 yyextra->lastEscaped=false;
1468 }
1469<CopyLine>. {
1471 }
1472<CopyLine>\n {
1474 yyextra->insertCppCommentMarker=false;
1475 BEGIN(yyextra->readLineCtx);
1476 }
1477<ReadLine>{CMD}{CMD} |
1478<ReadLine>. {
1480 }
1481<IncludeFile>. {
1483 }
1484<IncludeFile>\n {
1487 }
1488<*>. {
1490 }
1491<<EOF>> {
1492 if (YY_START == ReadAliasArgs)
1493 {
1494 warn(yyextra->fileName,yyextra->lineNr,
1495 "Reached end of file while still searching closing '}}' of an alias argument (probable start: '{}')",
1496 yyextra->aliasCmd);
1497 }
1498 else if (YY_START==Verbatim || YY_START==VerbatimCode)
1499 {
1500 warn(yyextra->fileName,yyextra->lineNr,
1501 "Reached end of file while still searching closing '{}' of a verbatim block starting at line {}",
1502 yyextra->blockName,yyextra->verbatimLine);
1503 }
1504 if (yyextra->includeStack.empty())
1505 {
1506 yyextra->insertCppCommentMarker=false;
1508 }
1509 else
1510 {
1511 std::unique_ptr<commentcnv_FileState> &fs = yyextra->includeStack.back();
1512 YY_BUFFER_STATE oldBuf = YY_CURRENT_BUFFER;
1513 yy_switch_to_buffer(fs->bufState, yyscanner);
1514 yy_delete_buffer(oldBuf, yyscanner);
1515 BEGIN(fs->oldState);
1516 yyextra->fileName = fs->oldFileName;
1517 yyextra->lineNr = fs->oldLineNr;
1518 yyextra->inBuf = fs->oldFileBuf;
1519 yyextra->inBufPos = fs->oldFileBufPos;
1520 yyextra->includeCtx = fs->oldIncludeCtx;
1521 DString lineStr=
" \\ifile \""+yyextra->fileName+
"\" \\iline "+
DString().
setNum(yyextra->lineNr)+
" ";
1522 if (fs->oldRaiseLvl!=yyextra->raiseLevel)
1523 {
1524 lineStr+="\\iraise " + std::to_string(fs->oldRaiseLvl)+ " ";
1525 }
1526 if (fs->oldRaiseLbl!=yyextra->raiseLabel)
1527 {
1528 lineStr+="\\iprefix \"" + fs->oldRaiseLbl + "\" ";
1529 }
1530 lineStr+="\\ilinebr ";
1531 yyextra->raiseLevel = fs->oldRaiseLvl;
1532 yyextra->raiseLabel = fs->oldRaiseLbl;
1534 yyextra->includeStack.pop_back();
1535
1536
1537 }
1538 }
1539
1540<*>\n { fprintf(stderr,"Lex scanner %s (%s) default rule newline for state %s.\n", __FILE__, qPrint(yyextra->fileName),stateToString(YY_START));}
1541 */
1542%%