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