497 {
499 }
static char resolveTrigraph(char c)
500<Start>^{B}*"#" {
501 yyextra->yyColNr+=(int)yyleng;
502 yyextra->yyMLines=0;
503 yyextra->potentialDefine=yytext;
504 BEGIN(Command);
505 }
506<Start>^("%top{"|"%{") {
509 BEGIN(LexCopyLine);
510 }
static void outputArray(yyscan_t yyscanner, const char *a, yy_size_t len)
511<Start>^{Bopt}"cpp_quote"{Bopt}"("{Bopt}\" {
512 if (yyextra->insideIDL)
513 {
514 BEGIN(IDLquote);
515 }
516 else
517 {
518 REJECT;
519 }
520 }
521<IDLquote>"\\\\" {
523 }
524<IDLquote>"\\\"" {
526 }
527<IDLquote>"\""{Bopt}")" {
528 BEGIN(Start);
529 }
530<IDLquote>\n {
532 yyextra->yyLineNr++;
533 }
534<IDLquote>. {
536 }
537<Start>^[Cc*].* {
539 if (!yyextra->isFixedFormFtn) REJECT;
541 }
542<Start>^{Bopt}"!".* {
545 }
546<Start>^{Bopt}/[^#] {
548 BEGIN(CopyLine);
549 }
550<Start>^{B}*[a-z_A-Z\x80-\xFF][a-z_A-Z0-9\x80-\xFF]+{B}*"("[^\)\n]*")"/{BN}{1,10}*[:{] { // constructors?
551 int i;
552 for (i=(int)yyleng-1;i>=0;i--)
553 {
554 unput(yytext[i]);
555 }
556 BEGIN(CopyLine);
557 }
558<Start>^{B}*[_A-Z][_A-Z0-9]+{B}*"("[^\(\)\n]*"("[^\)\n]*")"[^\)\n]*")"{B}*\n | // function list macro with one (...) argument, e.g. for K_GLOBAL_STATIC_WITH_ARGS
559<Start>^{B}*[_A-Z][_A-Z0-9]+{B}*"("[^\)\n]*")"{B}*\n | // function like macro
560<Start>^{B}*[_A-Z][_A-Z0-9]+{B}*"("[^\(\)\n]*"("[^\)\n]*")"[^\)\n]*")"/{B}*("//"|"/\*") | // function list macro with one (...) argument followed by comment
561<Start>^{B}*[_A-Z][_A-Z0-9]+{B}*"("[^\)\n]*")"/{B}*("//"|"/\*") { // function like macro followed by comment
564 size_t pos = name.find('(');
566 name=name.left(pos).stripWhiteSpace();
#define Config_getBool(name)
567
569 if (skipFuncMacros && !yyextra->insideFtn &&
570 name!="Q_PROPERTY" &&
571 !(
572 (yyextra->includeStack.empty() || yyextra->curlyCount>0) &&
573 yyextra->macroExpansion &&
575
577 )
578 )
579 {
580
581 if (yytext[yyleng-1] == '\n')
582 {
584 yyextra->yyLineNr++;
585 }
586 }
587 else
588 {
589 int i;
590 for (i=(int)yyleng-1;i>=0;i--)
591 {
592 unput(yytext[i]);
593 }
594 BEGIN(CopyLine);
595 }
596 }
597<CopyLine,LexCopyLine>"extern"{BN}*"\""[^\"]+"\""{BN}*("{")? {
599 yyextra->yyLineNr+=text.
contains(
'\n');
601 }
602<CopyLine,LexCopyLine>{RAWBEGIN} {
605 BEGIN(CopyRawString);
606 }
DString extractBeginRawStringDelimiter(const char *rawStart)
607<CopyLine,LexCopyLine>"{" { // count brackets inside the main file
608 if (yyextra->includeStack.empty())
609 {
610 yyextra->curlyCount++;
611 }
613 }
614<LexCopyLine>^"%}" {
616 }
617<CopyLine,LexCopyLine>"}" { // count brackets inside the main file
618 if (yyextra->includeStack.empty() && yyextra->curlyCount>0)
619 {
620 yyextra->curlyCount--;
621 }
623 }
624<CopyLine,LexCopyLine>"'"\\[0-7]{1,3}"'" {
626 }
627<CopyLine,LexCopyLine>"'"\\."'" {
629 }
630<CopyLine,LexCopyLine>"'"."'" {
632 }
633<CopyLine,LexCopyLine>[$]?@\" {
636 BEGIN( CopyStringCs );
637 }
638<CopyLine,LexCopyLine>"!".* {
641 }
642<CopyLine,LexCopyLine>\" {
645 {
646 BEGIN( CopyString );
647 }
648 else
649 {
650 BEGIN( CopyStringFtnDouble );
651 }
652 }
653<CopyLine,LexCopyLine>\' {
656 BEGIN( CopyStringFtn );
657 }
658<CopyString>[^\"\\\r\n]{1,1000} {
660 }
661<CopyStringCs>[^\"\r\n]{1,1000} {
663 }
664<CopyStringCs>\"\" {
666 }
667<CopyString>\\. {
669 }
670<CopyString,CopyStringCs>\" {
672 BEGIN( CopyLine );
673 }
674<CopyStringFtnDouble>[^\"\\\r\n]{1,1000} {
676 }
677<CopyStringFtnDouble>\\. {
679 }
680<CopyStringFtnDouble>\" {
682 BEGIN( CopyLine );
683 }
684<CopyStringFtn>[^\'\\\r\n]{1,1000} {
686 }
687<CopyStringFtn>\\. {
689 }
690<CopyStringFtn>\' {
692 BEGIN( CopyLine );
693 }
694<CopyRawString>{RAWEND} {
697 {
698 BEGIN( CopyLine );
699 }
700 }
DString extractEndRawStringDelimiter(const char *rawEnd)
701<CopyRawString>[^)]{1,1000} {
703 }
704<CopyRawString>. {
706 }
707<CopyLine,LexCopyLine>{ID}/{BN}{0,80}"(" {
708 yyextra->expectGuard = false;
710
711
712
713
714
715
716
717
718 if ((yyextra->includeStack.empty() || yyextra->curlyCount>0) &&
719 yyextra->macroExpansion &&
722 )
723 {
724
725 yyextra->roundCount=0;
726 yyextra->defArgsStr=yytext;
729 {
734 }
735 else
736 {
737 yyextra->findDefArgContext = CopyLine;
738 BEGIN(FindDefineArgs);
739 }
740 }
741 else
742 {
744 }
745 }
static DString expandMacro(yyscan_t yyscanner, const DString &name)
746<CopyLine>{RulesDelim} {
748 yyextra->lexRulesPart = !yyextra->lexRulesPart;
750 }
751
752<CopyLine>{RulesSharp} {
753 if (!yyextra->lexRulesPart) REJECT;
754 if (yyextra->curlyCount) REJECT;
756 BEGIN(RulesPattern);
757 }
758<RulesPattern>{EscapeRulesChar} {
760 }
761<RulesPattern>{RulesCurly} {
763 }
764<RulesPattern>{StartDouble} {
766 yyextra->lastContext = YY_START;
767 BEGIN(RulesDouble);
768 }
769<RulesDouble,RulesRoundDouble>"\\\\" {
771 }
772<RulesDouble,RulesRoundDouble>"\\\"" {
774 }
775<RulesDouble>"\"" {
777 BEGIN( yyextra->lastContext ) ;
778 }
779<RulesRoundDouble>"\"" {
781 BEGIN(RulesRound) ;
782 }
783<RulesDouble,RulesRoundDouble>. {
785 }
786<RulesPattern>{StartSquare} {
788 yyextra->lastContext = YY_START;
789 BEGIN(RulesSquare);
790 }
791<RulesSquare,RulesRoundSquare>{CHARCE} {
793 }
794<RulesSquare,RulesRoundSquare>"\\[" |
795<RulesSquare,RulesRoundSquare>"\\]" {
797 }
798<RulesSquare>"]" {
800 BEGIN(RulesPattern);
801 }
802<RulesRoundSquare>"]" {
804 BEGIN(RulesRound) ;
805 }
806<RulesSquare,RulesRoundSquare>"\\\\" {
808 }
809<RulesSquare,RulesRoundSquare>. {
811 }
812<RulesPattern>{StartRoundQuest} {
814 yyextra->lastContext = YY_START;
815 BEGIN(RulesRoundQuest);
816 }
817<RulesRoundQuest>{nl} {
819 }
820<RulesRoundQuest>[^)] {
822 }
823<RulesRoundQuest>")" {
825 BEGIN(yyextra->lastContext);
826 }
827<RulesPattern>{StartRound} {
828 yyextra->roundCount++;
830 yyextra->lastContext = YY_START;
831 BEGIN(RulesRound);
832 }
833<RulesRound>{RulesCurly} {
835 }
836<RulesRound>{StartSquare} {
838 BEGIN(RulesRoundSquare);
839 }
840<RulesRound>{StartDouble} {
842 BEGIN(RulesRoundDouble);
843 }
844<RulesRound>{EscapeRulesChar} {
846 }
847<RulesRound>"(" {
848 yyextra->roundCount++;
850 }
851<RulesRound>")" {
852 yyextra->roundCount--;
854 if (!yyextra->roundCount) BEGIN( yyextra->lastContext ) ;
855 }
856<RulesRound>{nl} {
858 }
859<RulesRound>{B} {
861 }
862<RulesRound>. {
864 }
865<RulesPattern>{B} {
867 BEGIN(CopyLine);
868 }
869<RulesPattern>. {
871 }
872
873<CopyLine,LexCopyLine>{ID} {
876 if ((yyextra->includeStack.empty() || yyextra->curlyCount>0) &&
877 yyextra->macroExpansion &&
881 )
882 {
887 }
889 {
891 }
892 else
893 {
895 }
896 }
897<CopyLine,LexCopyLine>"\\"\r?/\n { // strip line continuation characters
899 }
900<CopyLine,LexCopyLine>\\. {
902 }
903<CopyLine,LexCopyLine>. {
905 }
906<CopyLine,LexCopyLine>\n {
908 BEGIN(Start);
909 yyextra->yyLineNr++;
910 yyextra->yyColNr=1;
911 }
912<FindDefineArgs>"(" {
913 yyextra->defArgsStr+='(';
914 yyextra->roundCount++;
915 }
916<FindDefineArgs>")" {
917 yyextra->defArgsStr+=')';
918 yyextra->roundCount--;
919 if (yyextra->roundCount==0)
920 {
922
923 if (yyextra->findDefArgContext==CopyLine)
924 {
926 BEGIN(yyextra->findDefArgContext);
927 }
928 else
929 {
931 yyextra->nospaces=false;
932 BEGIN(Start);
933 }
934 }
935 }
936
static void readIncludeFile(yyscan_t yyscanner, const DString &inc)
937<FindDefineArgs>")"{B}*"(" {
938 yyextra->defArgsStr+=yytext;
939 }
940 */
941<FindDefineArgs>{CHARLIT} {
942 yyextra->defArgsStr+=yytext;
943 }
944<FindDefineArgs>{CCS}[*!]? {
945 yyextra->defArgsStr+=yytext;
946 BEGIN(ArgCopyCComment);
947 }
948<FindDefineArgs>{CPPC}[/!].*\n/{B}*{CPPC}[/!] { // replace multi line C++ style comment by C style comment
950 {
951 if (yytext[3]=='<')
952 {
953 yyextra->defArgsStr+=
DString(
"/**< @brief ")+&yytext[4];
954 }
955 else
956 {
957 yyextra->defArgsStr+=
DString(
"/** @brief ")+&yytext[3];
958 }
959 }
960 else
961 {
962 yyextra->defArgsStr+=
DString(
"/**")+&yytext[3];
963 }
964 BEGIN(ArgCopyCppComment);
965 }
966<FindDefineArgs>{CPPC}[/!].*\n { // replace C++ single line style comment by C style comment
968 {
969 yyextra->defArgsStr+=
DString(
"/**")+&yytext[3]+
" */";
970 }
971 else
972 {
973 if (yytext[3]=='<')
974 {
975 yyextra->defArgsStr+=
DString(
"/**< @brief ")+&yytext[4]+
" */";
976 }
977 else
978 {
979 yyextra->defArgsStr+=
DString(
"/** @brief ")+&yytext[3]+
" */";
980 }
981 }
982 }
983<FindDefineArgs>{CPPC}.*\n { // replace C++ single line style comment by C style comment
985 yyextra->defArgsStr+=
DString(
"/*")+&yytext[2]+
" */";
986 }
987<FindDefineArgs>\" {
988 yyextra->defArgsStr+=*yytext;
989 BEGIN(ReadString);
990 }
991<FindDefineArgs>' {
993 yyextra->defArgsStr+=*yytext;
994 BEGIN(ReadString);
995 }
996<FindDefineArgs>\n {
997 yyextra->defArgsStr+=' ';
998 yyextra->yyLineNr++;
1000 }
1001<FindDefineArgs>"@" {
1002 yyextra->defArgsStr+="@@";
1003 }
1004<FindDefineArgs>. {
1005 yyextra->defArgsStr+=*yytext;
1006 }
1007<ArgCopyCComment>[^*\n]+ {
1008 yyextra->defArgsStr+=yytext;
1009 }
1010<ArgCopyCComment>{CCE} {
1011 yyextra->defArgsStr+=yytext;
1012 BEGIN(FindDefineArgs);
1013 }
1014<ArgCopyCComment>\n {
1015 yyextra->defArgsStr+=yytext;
1016 yyextra->yyLineNr++;
1017 }
1018<ArgCopyCComment>. {
1019 yyextra->defArgsStr+=yytext;
1020 }
1021<ArgCopyCppComment>^{B}*
1022<ArgCopyCppComment>{CPPC}[/!].*\n/{B}*{CPPC}[/!] { // replace multi line C++ style comment by C style comment
1023 const char *startContent = &yytext[3];
1024 if (startContent[0]=='<') startContent++;
1025 yyextra->defArgsStr+=startContent;
1026 }
1027<ArgCopyCppComment>{CPPC}[/!].*\n { // replace C++ multie line style comment by C style comment
1028 const char *startContent = &yytext[3];
1029 if (startContent[0]=='<') startContent++;
1030 yyextra->defArgsStr+=
DString(startContent)+
" */";
1031 BEGIN(FindDefineArgs);
1032 }
1033<ArgCopyCppComment>. { // unexpected character
1034 unput(*yytext);
1035 yyextra->defArgsStr+=" */";
1036 BEGIN(FindDefineArgs);
1037 }
1038<ReadString>"\"" {
1039 yyextra->defArgsStr+=*yytext;
1040 BEGIN(FindDefineArgs);
1041 }
1042<ReadString>"'" {
1044 yyextra->defArgsStr+=*yytext;
1045 BEGIN(FindDefineArgs);
1046 }
1047
1048<ReadString>{CPPC}|{CCS} {
1049 yyextra->defArgsStr+=yytext;
1050 }
1051<ReadString>\\/\r?\n { // line continuation
1052 }
1053<ReadString>\\. {
1054 yyextra->defArgsStr+=yytext;
1055 }
1056<ReadString>. {
1057 yyextra->defArgsStr+=*yytext;
1058 }
1059<Command>("include"|"import"){B}+/{ID} {
1060 yyextra->isImported = yytext[1]=='m';
1061 if (yyextra->macroExpansion)
1062 BEGIN(IncludeID);
1063 }
1064<Command>("include"|"import"){B}*[<"] {
1065 yyextra->isImported = yytext[1]=='m';
1066 char c[2];
1067 c[0]=yytext[yyleng-1];c[1]='\0';
1068 yyextra->incName=c;
1069 BEGIN(Include);
1070 }
1071<Command>("cmake")?"define"{B}+ {
1072 yyextra->potentialDefine +=
substitute(yytext,
"cmake",
" ");
1073
1074 yyextra->yyColNr+=(int)yyleng;
1075 BEGIN(DefName);
1076 }
DString substitute(const DString &s, const DString &src, const DString &dst)
substitute all occurrences of src in s by dst
1077<Command>"cmakedefine01"{B}+ {
1078 yyextra->potentialDefine +=
substitute(yytext,
"cmakedefine01",
" define ");
1079
1080 yyextra->yyColNr+=(int)yyleng;
1081 BEGIN(CmakeDefName01);
1082 }
1083<Command>"ifdef"/{B}*"(" {
1085 yyextra->guardExpr.clear();
1086 BEGIN(DefinedExpr2);
1087 }
static void incrLevel(yyscan_t yyscanner)
1088<Command>"ifdef"/{B}+ {
1089
1091 yyextra->guardExpr.clear();
1092 BEGIN(DefinedExpr1);
1093 }
1094<Command>"ifndef"/{B}*"(" {
1096 yyextra->guardExpr="! ";
1097 BEGIN(DefinedExpr2);
1098 }
1099<Command>"ifndef"/{B}+ {
1101 yyextra->guardExpr="! ";
1102 BEGIN(DefinedExpr1);
1103 }
1104<Command>"if"/[ \t(!] {
1106 yyextra->guardExpr.clear();
1107 BEGIN(Guard);
1108 }
1109<Command>("elif"|"else"{B}*"if")/[ \t(!] {
1111 {
1112 yyextra->guardExpr.clear();
1113 BEGIN(Guard);
1114 }
1115 else
1116 {
1117 yyextra->ifcount=0;
1118 BEGIN(SkipCPPBlock);
1119 }
1120 }
static bool otherCaseDone(yyscan_t yyscanner)
1121<Command>"else"/[^a-z_A-Z0-9\x80-\xFF] {
1123 {
1124 yyextra->ifcount=0;
1125 BEGIN(SkipCPPBlock);
1126 }
1127 else
1128 {
1130 }
1131 }
static void setCaseDone(yyscan_t yyscanner, bool value)
1132<Command>"undef"{B}+ {
1133 BEGIN(UndefName);
1134 }
1135<Command>("elif"|"else"{B}*"if")/[ \t(!] {
1137 {
1138 yyextra->guardExpr.clear();
1139 BEGIN(Guard);
1140 }
1141 }
1142<Command>"endif"/[^a-z_A-Z0-9\x80-\xFF] {
1143
1145 }
static void decrLevel(yyscan_t yyscanner)
1146<Command,IgnoreLine>\n {
1148 BEGIN(Start);
1149 yyextra->yyLineNr++;
1150 }
1151<Command>"pragma"{B}+"once" {
1152 yyextra->expectGuard = false;
1153 if (yyextra->pragmaSet.find(yyextra->fileName.str())!=yyextra->pragmaSet.end())
1154 {
1156 BEGIN(PragmaOnce);
1157 }
1158 else
1159 {
1160 yyextra->pragmaSet.insert(yyextra->fileName.data());
1161 }
1162 }
1163<PragmaOnce>. {}
1164<PragmaOnce>\n {}
1165<PragmaOnce><<EOF>> {
1166 yyextra->expectGuard = false;
1167 BEGIN(Start);
1168 }
1169<Command>{ID} { // unknown directive
1170 BEGIN(IgnoreLine);
1171 }
1172<IgnoreLine>\\[\r]?\n {
1174 yyextra->yyLineNr++;
1175 }
1176<IgnoreLine>.
1177<Command>. { yyextra->potentialDefine += yytext[0]=='\t' ? '\t' : ' ';
1178 yyextra->yyColNr+=(int)yyleng;
1179 }
1180<UndefName>{ID} {
1183
1185 )
1186 {
1187
1189 }
1190 BEGIN(Start);
1191 }
1192<Guard>\\[\r]?\n {
1194 yyextra->guardExpr+=' ';
1195 yyextra->yyLineNr++;
1196 }
1197<Guard>"defined"/{B}*"(" {
1198 BEGIN(DefinedExpr2);
1199 }
1200<Guard>"defined"/{B}+ {
1201 BEGIN(DefinedExpr1);
1202 }
1203<Guard>"true"/{B}|{B}*[\r]?\n { yyextra->guardExpr+="1L"; }
1204<Guard>"false"/{B}|{B}*[\r]?\n { yyextra->guardExpr+="0L"; }
1205<Guard>"not"/{B} { yyextra->guardExpr+='!'; }
1206<Guard>"not_eq"/{B} { yyextra->guardExpr+="!="; }
1207<Guard>"and"/{B} { yyextra->guardExpr+="&&"; }
1208<Guard>"or"/{B} { yyextra->guardExpr+="||"; }
1209<Guard>"bitand"/{B} { yyextra->guardExpr+="&"; }
1210<Guard>"bitor"/{B} { yyextra->guardExpr+="|"; }
1211<Guard>"xor"/{B} { yyextra->guardExpr+="^"; }
1212<Guard>"compl"/{B} { yyextra->guardExpr+="~"; }
1213<Guard>{ID} { yyextra->guardExpr+=yytext; }
1214<Guard>"@" { yyextra->guardExpr+="@@"; }
1215<Guard>. { yyextra->guardExpr+=*yytext; }
1216<Guard>\n {
1217 unput(*yytext);
1218
1219
1222 if (guard)
1223 {
1224 BEGIN(Start);
1225 }
1226 else
1227 {
1228 yyextra->ifcount=0;
1229 BEGIN(SkipCPPBlock);
1230 }
1231 }
static bool computeExpression(yyscan_t yyscanner, const DString &expr)
1232<DefinedExpr1,DefinedExpr2>\\\n { yyextra->yyLineNr++; outputChar(yyscanner,'\n'); }
1233<DefinedExpr1>{ID} {
1234 if (
isDefined(yyscanner,yytext) || yyextra->guardName==yytext)
1235 yyextra->guardExpr+=" 1L ";
1236 else
1237 yyextra->guardExpr+=" 0L ";
1238 yyextra->lastGuardName=yytext;
1239 BEGIN(Guard);
1240 }
1241<DefinedExpr2>{ID} {
1242 if (
isDefined(yyscanner,yytext) || yyextra->guardName==yytext)
1243 yyextra->guardExpr+=" 1L ";
1244 else
1245 yyextra->guardExpr+=" 0L ";
1246 yyextra->lastGuardName=yytext;
1247 }
1248<DefinedExpr1,DefinedExpr2>\n { // should not happen, handle anyway
1249 yyextra->yyLineNr++;
1250 yyextra->ifcount=0;
1251 BEGIN(SkipCPPBlock);
1252 }
1253<DefinedExpr2>")" {
1254 BEGIN(Guard);
1255 }
1256<DefinedExpr1,DefinedExpr2>.
1257<SkipCPPBlock>^{B}*"#" { BEGIN(SkipCommand); }
1258<SkipCPPBlock>^{Bopt}/[^#] { BEGIN(SkipLine); }
1259<SkipCPPBlock>\n { yyextra->yyLineNr++; outputChar(yyscanner,'\n'); }
1260<SkipCPPBlock>.
1261<SkipCommand>"if"(("n")?("def"))?/[ \t(!] {
1263 yyextra->ifcount++;
1264
1265 }
1266<SkipCommand>"else" {
1267
1269 {
1271
1272 BEGIN(Start);
1273 }
1274 }
1275<SkipCommand>("elif"|"else"{B}*"if")/[ \t(!] {
1276 if (yyextra->ifcount==0)
1277 {
1279 {
1280 yyextra->guardExpr.clear();
1281 yyextra->lastGuardName.clear();
1282 BEGIN(Guard);
1283 }
1284 else
1285 {
1286 BEGIN(SkipCPPBlock);
1287 }
1288 }
1289 }
1290<SkipCommand>"endif" {
1291 yyextra->expectGuard = false;
1293 if (--yyextra->ifcount<0)
1294 {
1295
1296 BEGIN(Start);
1297 }
1298 }
1299<SkipCommand>\n {
1301 yyextra->yyLineNr++;
1302 BEGIN(SkipCPPBlock);
1303 }
1304<SkipCommand>{ID} { // unknown directive
1305 BEGIN(SkipLine);
1306 }
1307<SkipCommand>.
1308<SkipLine>[^'"/\n]+
1309<SkipLine>{CHARLIT} { }
1310<SkipLine>\" {
1311 BEGIN(SkipString);
1312 }
1313<SkipLine>.
1314<SkipString>{CPPC}/[^\n]* {
1315 }
1316<SkipLine,SkipCommand,SkipCPPBlock>{CPPC}[^\n]* {
1317 yyextra->lastCPPContext=YY_START;
1318 BEGIN(RemoveCPPComment);
1319 }
1320<SkipString>{CCS}/[^\n]* {
1321 }
1322<SkipLine,SkipCommand,SkipCPPBlock>{CCS}/[^\n]* {
1323 yyextra->lastCContext=YY_START;
1324 BEGIN(RemoveCComment);
1325 }
1326<SkipLine>\n {
1328 yyextra->yyLineNr++;
1329 BEGIN(SkipCPPBlock);
1330 }
1331<SkipString>[^"\\\n]+ { }
1332<SkipString>\\. { }
1333<SkipString>\" {
1334 BEGIN(SkipLine);
1335 }
1336<SkipString>. { }
1337<IncludeID>{ID}{Bopt}/"(" {
1338 yyextra->nospaces=true;
1339 yyextra->roundCount=0;
1340 yyextra->defArgsStr=yytext;
1341 yyextra->findDefArgContext = IncludeID;
1342 BEGIN(FindDefineArgs);
1343 }
1344<IncludeID>{ID} {
1345 yyextra->nospaces=true;
1347 BEGIN(Start);
1348 }
1349<Include>[^\">\n]+[\">] {
1350 yyextra->incName+=yytext;
1351 if (yyextra->isImported)
1352 {
1353 BEGIN(EndImport);
1354 }
1355 else
1356 {
1358 BEGIN(Start);
1359 }
1360 }
1361<EndImport>{ENDIMPORTopt}/\n {
1363 BEGIN(Start);
1364 }
1365<EndImport>\\[\r]?"\n" {
1367 yyextra->yyLineNr++;
1368 }
1369<EndImport>. {
1370 }
1371<DefName>{ID}/("\\\n")*"(" { // define with argument
1372
1373 yyextra->argMap.clear();
1374 yyextra->defArgs = 0;
1375 yyextra->defArgsStr.clear();
1376 yyextra->defText.clear();
1377 yyextra->defLitText.clear();
1378 yyextra->defName = yytext;
1379 yyextra->defVarArgs = false;
1380 yyextra->defExtraSpacing.clear();
1381 yyextra->defContinue = false;
1382 BEGIN(DefineArg);
1383 }
1384<DefName>{ID}{B}+"1"/[ \r\t\n] { // special case: define with 1 -> can be "guard"
1385
1386 yyextra->argMap.clear();
1387 yyextra->defArgs = -1;
1388 yyextra->defArgsStr.clear();
1389 yyextra->defName =
DString(yytext).left(yyleng-1).stripWhiteSpace();
1390 yyextra->defVarArgs = false;
1391
1392
1393 if (yyextra->curlyCount>0 || yyextra->defName!=yyextra->lastGuardName || !yyextra->expectGuard)
1394 {
1395 DString def = yyextra->potentialDefine +
1396 yyextra->defName ;
1398 outputSpaces(yyscanner,yytext+yyextra->defName.length());
1399 yyextra->quoteArg=false;
1400 yyextra->insideComment=false;
1401 yyextra->lastGuardName.clear();
1402 yyextra->defText="1";
1403 yyextra->defLitText="1";
1404 BEGIN(DefineText);
1405 }
1406 else
1407 {
1408
1409 yyextra->defText.clear();
1410 yyextra->defLitText.clear();
1411 BEGIN(Start);
1412 }
1413 yyextra->expectGuard=false;
1414 }
static void outputSpaces(yyscan_t yyscanner, char *s)
1415<DefName,CmakeDefName01>{ID}/{B}*"\n" { // empty define
1416 yyextra->argMap.clear();
1417 yyextra->defArgs = -1;
1418 yyextra->defName = yytext;
1419 yyextra->defArgsStr.clear();
1420 yyextra->defText.clear();
1421 yyextra->defLitText.clear();
1422 yyextra->defVarArgs = false;
1423
1424
1425 if (yyextra->curlyCount>0 || yyextra->defName!=yyextra->lastGuardName || !yyextra->expectGuard)
1426 {
1427 DString def = yyextra->potentialDefine + yyextra->defName;
1429 yyextra->quoteArg=false;
1430 yyextra->insideComment=false;
1431 if (YY_START == CmakeDefName01) yyextra->defText = "0";
1432 else if (yyextra->insideCS) yyextra->defText="1";
1433 BEGIN(DefineText);
1434 }
1435 else
1436 {
1437
1438 yyextra->guardName = yytext;
1439 yyextra->lastGuardName.clear();
1440 BEGIN(Start);
1441 }
1442 yyextra->expectGuard=false;
1443 }
1444<DefName>{ID}/{B}* { // define with content
1445
1446 yyextra->argMap.clear();
1447 yyextra->defArgs = -1;
1448 yyextra->defArgsStr.clear();
1449 yyextra->defText.clear();
1450 yyextra->defLitText.clear();
1451 yyextra->defName = yytext;
1452 yyextra->defVarArgs = false;
1453 DString def = yyextra->potentialDefine +
1454 yyextra->defName +
1455 yyextra->defArgsStr ;
1457 yyextra->quoteArg=false;
1458 yyextra->insideComment=false;
1459 BEGIN(DefineText);
1460 }
1461<DefineArg>"\\\n" {
1462 yyextra->defExtraSpacing+="\n";
1463 yyextra->defContinue = true;
1464 yyextra->yyLineNr++;
1465 }
1466<DefineArg>{B}* { yyextra->defExtraSpacing+=yytext; }
1467<DefineArg>","{B}* { yyextra->defArgsStr+=yytext; }
1468<DefineArg>"("{B}* { yyextra->defArgsStr+=yytext; }
1469<DefineArg>{B}*")"{B}* {
1471 yyextra->defArgsStr+=yytext;
1472 DString def = yyextra->potentialDefine +
1473 yyextra->defName +
1474 yyextra->defArgsStr +
1475 yyextra->defExtraSpacing ;
1477 yyextra->quoteArg=false;
1478 yyextra->insideComment=false;
1479 BEGIN(DefineText);
1480 }
static void extraSpacing(yyscan_t yyscanner)
1481<DefineArg>"..." { // Variadic macro
1482 yyextra->defVarArgs = true;
1483 yyextra->defArgsStr+=yytext;
1484 yyextra->argMap.emplace(std::string("__VA_ARGS__"),yyextra->defArgs);
1485 yyextra->defArgs++;
1486 }
1487<DefineArg>{ID}{B}*("..."?) {
1488
1490 yyextra->defVarArgs = yytext[yyleng-1]=='.';
1491 if (yyextra->defVarArgs)
1492 {
1494 }
1496 yyextra->defArgsStr+=yytext;
1497 yyextra->argMap.emplace(
toStdString(argName),yyextra->defArgs);
1498 yyextra->defArgs++;
1500 }
1501
1502<DefineText>"/ **"|"/ *!" {
1503 yyextra->defText+=yytext;
1504 yyextra->defLitText+=yytext;
1505 yyextra->insideComment=true;
1506 }
1507<DefineText>"* /" {
1508 yyextra->defText+=yytext;
1509 yyextra->defLitText+=yytext;
1510 yyextra->insideComment=false;
1511 }
1512 */
1513<DefineText>{CCS}[^!*] {
1514 yyextra->defLitText+=' ';
1516 yyextra->lastCContext=YY_START;
1517 yyextra->commentCount=1;
1518 BEGIN(SkipCComment);
1519 }
1520<DefineText>{CCS}[!*] {
1521 yyextra->defText+=yytext;
1522 yyextra->defLitText+=yytext;
1523 yyextra->lastCContext=YY_START;
1524 yyextra->commentCount=1;
1525 BEGIN(CopyCComment);
1526 }
1527<DefineText>{CPPC}[!/]? {
1529 yyextra->lastCPPContext=YY_START;
1530 yyextra->defLitText+=' ';
1531 BEGIN(SkipCPPComment);
1532 }
1533<SkipCComment>[/]?{CCE} {
1534 if (yytext[0]==
'/')
outputChar(yyscanner,
'/');
1536 if (--yyextra->commentCount<=0)
1537 {
1538 if (yyextra->lastCContext==Start)
1539
1540
1541 {
1542 YY_CURRENT_BUFFER->yy_at_bol=1;
1543 }
1544 BEGIN(yyextra->lastCContext);
1545 }
1546 }
1547<SkipCComment>{CPPC}("/")* {
1549 }
1550<SkipCComment>{CCS} {
1552
1553 }
1554<SkipCond>{CMD}{CMD} { }
1555<SkipCond>^({B}*"*"+)?{B}{0,3}"~~~"[~]* {
1557 if (!markdownSupport || !yyextra->isSpecialComment)
1558 {
1559 REJECT;
1560 }
1561 else
1562 {
1563 yyextra->fenceChar='~';
1565 BEGIN(SkipCondVerbatim);
1566 }
1567 }
static yy_size_t getFenceSize(char *txt, yy_size_t leng)
1568<SkipCond>^({B}*"*"+)?{B}{0,3}"```"[`]* {
1570 if (!markdownSupport || !yyextra->isSpecialComment)
1571 {
1572 REJECT;
1573 }
1574 else
1575 {
1576 yyextra->fenceChar='`';
1578 BEGIN(SkipCondVerbatim);
1579 }
1580 }
1581<SkipCComment>^({B}*"*"+)?{B}{0,3}"~~~"[~]* {
1583 if (!markdownSupport || !yyextra->isSpecialComment)
1584 {
1585 REJECT;
1586 }
1587 else
1588 {
1590 yyextra->fenceChar='~';
1592 BEGIN(SkipVerbatim);
1593 }
1594 }
1595<SkipCComment>^({B}*"*"+)?{B}{0,3}"```"[`]* {
1597 if (!markdownSupport || !yyextra->isSpecialComment)
1598 {
1599 REJECT;
1600 }
1601 else
1602 {
1604 yyextra->fenceChar='`';
1606 BEGIN(SkipVerbatim);
1607 }
1608 }
1609<SkipCComment>{CMD}{VERBATIM_LINE} |
1610<SkipCComment>{CMD}{LITERAL_BLOCK} { // escaped command
1612 yyextra->yyLineNr+=
DString(yytext).contains(
'\n');
1613 }
1614<SkipCComment>{VERBATIM_LINE}.*/\n { // normal command
1616 }
1617<SkipCComment>{LITERAL_BLOCK} { // normal block command
1619 yyextra->yyLineNr+=
DString(yytext).contains(
'\n');
1620 if (yyextra->isSpecialComment)
1621 {
1623 BEGIN(SkipVerbatim);
1624 }
1625 }
static void determineBlockName(yyscan_t yyscanner)
1626<SkipCond>{CMD}{CMD}"cond"[ \t]+ {}// escaped cond command
1627<SkipCond>{CMD}"cond"/\n |
1628<SkipCond>{CMD}"cond"[ \t]+ { // cond command in a skipped cond section, this section has to be skipped as well
1629
1631 }
1632<SkipCComment>"{"[ \t]*"@code"/[ \t\n] {
1634 yyextra->javaBlock=1;
1635 BEGIN(JavaDocVerbatimCode);
1636 }
1637<SkipCComment>"{"[ \t]*"@literal"/[ \t\n] {
1639 yyextra->javaBlock=1;
1640 BEGIN(JavaDocVerbatimCode);
1641 }
1642<SkipCComment,SkipCPPComment>{CMD}{CMD}"cond"[ \t\n]+ { // escaped cond command
1644 }
1645<SkipCPPComment>{CMD}"cond"[ \t]+ { // conditional section
1646 yyextra->ccomment=true;
1647 yyextra->condCtx=YY_START;
1648 BEGIN(CondLineCpp);
1649 }
1650<SkipCComment>{CMD}"cond"[ \t]+ { // conditional section
1651 yyextra->ccomment=false;
1652 yyextra->condCtx=YY_START;
1653 BEGIN(CondLineC);
1654 }
1655<CondLineC,CondLineCpp>([!()&| \ta-z_A-Z0-9\x80-\xFF.\-]|{CMD}"doxyconfig")+ {
1657 if (yyextra->skip)
1658 {
1659 if (YY_START==CondLineC)
1660 {
1661
1663 yyextra->ccomment=true;
1664 }
1665 else
1666 {
1667 yyextra->ccomment=false;
1668 }
1669 BEGIN(SkipCond);
1670 }
1671 else
1672 {
1673 BEGIN(yyextra->condCtx);
1674 }
1675 }
1676CondLine>{B}*{CMD}doxyconfig{B}+{DOXYCFG} {
1678 }
1679<CondLineC,CondLineCpp>. { // non-guard character
1680 unput(*yytext);
1682 if (yyextra->skip)
1683 {
1684 if (YY_START==CondLineC)
1685 {
1686
1688 yyextra->ccomment=true;
1689 }
1690 else
1691 {
1692 yyextra->ccomment=false;
1693 }
1694 BEGIN(SkipCond);
1695 }
1696 else
1697 {
1698 BEGIN(yyextra->condCtx);
1699 }
1700 }
1701<SkipCComment,SkipCPPComment>{CMD}"cond"{WSopt}/\n { // no guard
1702 if (YY_START==SkipCComment)
1703 {
1704 yyextra->ccomment=true;
1705
1707 }
1708 else
1709 {
1710 yyextra->ccomment=false;
1711 }
1712 yyextra->condCtx=YY_START;
1713 yyextra->condGuardCount=0;
1715 BEGIN(SkipCond);
1716 }
1717<SkipCond>\n { yyextra->yyLineNr++; outputChar(yyscanner,'\n'); }
1718<SkipCond>{VERBATIM_LINE}.*/\n { }
1719<SkipCond>{LITERAL_BLOCK} {
1720 auto numNLs =
DString(yytext).contains(
'\n');
1721 yyextra->yyLineNr+=numNLs;
1722 for (
int i = 0; i < numNLs; i++)
outputChar(yyscanner,
'\n');
1724 BEGIN(SkipCondVerbatim);
1725 }
1726
1727<SkipCond>. { }
1728<SkipCond>"#if"("def")? { yyextra->condGuardCount++; }
1729<SkipCond>"#endif" { yyextra->condGuardCount--; }
1730<SkipCond>[^\/\!*\\@\n#]+ { }
1731<SkipCond>{CPPC}[/!] { yyextra->ccomment=false; }
1732<SkipCond>{CCS}[*!] { yyextra->ccomment=true; }
1733<SkipCond,SkipCComment,SkipCPPComment>{CMD}{CMD}"endcond"/[^a-z_A-Z0-9\x80-\xFF] {
1734 if (!yyextra->skip)
1735 {
1737 }
1738 }
1739<SkipCond>{CMD}"endcond"/[^a-z_A-Z0-9\x80-\xFF] {
1740 bool oldSkip = yyextra->skip;
1742 if (oldSkip && !yyextra->skip)
1743 {
1744 if (yyextra->ccomment)
1745 {
1747 }
1748 BEGIN(yyextra->condCtx);
1749 }
1750 }
static void endCondSection(yyscan_t yyscanner)
1751<SkipCComment,SkipCPPComment>{CMD}"endcond"/[^a-z_A-Z0-9\x80-\xFF] {
1752 bool oldSkip = yyextra->skip;
1754 if (oldSkip && !yyextra->skip)
1755 {
1756 BEGIN(yyextra->condCtx);
1757 }
1758 }
1759<SkipCondVerbatim>{LITERAL_BLOCK_END} { /* end of verbatim block */
1760 if (yytext[1]=='f' && yyextra->blockName==&yytext[2])
1761 {
1762 BEGIN(SkipCond);
1763 }
1764 else if (&yytext[4]==yyextra->blockName)
1765 {
1766 BEGIN(SkipCond);
1767 }
1768 }
1769<SkipVerbatim>{LITERAL_BLOCK_END} { /* end of verbatim block */
1771 if (yytext[1]=='f' && yyextra->blockName==&yytext[2])
1772 {
1773 BEGIN(SkipCComment);
1774 }
1775 else if (&yytext[4]==yyextra->blockName)
1776 {
1777 BEGIN(SkipCComment);
1778 }
1779 }
1780<SkipCondVerbatim>^({B}*"*"+)?{B}{0,3}"~~~"[~]* {
1781 if (yyextra->fenceSize==
getFenceSize(yytext,yyleng) && yyextra->fenceChar==
'~')
1782 {
1783 BEGIN(SkipCond);
1784 }
1785 }
1786<SkipCondVerbatim>^({B}*"*"+)?{B}{0,3}"```"[`]* {
1787 if (yyextra->fenceSize==
getFenceSize(yytext,yyleng) && yyextra->fenceChar==
'`')
1788 {
1789 BEGIN(SkipCond);
1790 }
1791 }
1792<SkipVerbatim>^({B}*"*"+)?{B}{0,3}"~~~"[~]* {
1794 if (yyextra->fenceSize==
getFenceSize(yytext,yyleng) && yyextra->fenceChar==
'~')
1795 {
1796 BEGIN(SkipCComment);
1797 }
1798 }
1799<SkipVerbatim>^({B}*"*"+)?{B}{0,3}"```"[`]* {
1801 if (yyextra->fenceSize==
getFenceSize(yytext,yyleng) && yyextra->fenceChar==
'`')
1802 {
1803 BEGIN(SkipCComment);
1804 }
1805 }
1806<SkipCondVerbatim>{CCE}|{CCS} { }
1807<SkipVerbatim>{CCE}|{CCS} {
1809 }
1810<JavaDocVerbatimCode>"{" {
1811 if (yyextra->javaBlock==0)
1812 {
1813 REJECT;
1814 }
1815 else
1816 {
1817 yyextra->javaBlock++;
1819 }
1820 }
1821<JavaDocVerbatimCode>"}" {
1822 if (yyextra->javaBlock==0)
1823 {
1824 REJECT;
1825 }
1826 else
1827 {
1828 yyextra->javaBlock--;
1829 if (yyextra->javaBlock==0)
1830 {
1832 BEGIN(SkipCComment);
1833 }
1834 else
1835 {
1837 }
1838 }
1839 }
1840<JavaDocVerbatimCode>\n { /* new line in verbatim block */
1842 }
1843<JavaDocVerbatimCode>. { /* any other character */
1845 }
1846<SkipCondVerbatim>[^{*\\@\x06~`\n\/]+ { }
1847<SkipCComment,SkipVerbatim>[^{*\\@\x06~`\n\/]+ {
1849 }
1850<SkipCComment,SkipVerbatim,SkipCondVerbatim>\n {
1851 yyextra->yyLineNr++;
1853 }
1854<SkipCondVerbatim>. { }
1855<SkipCComment,SkipVerbatim>. {
1857 }
1858<CopyCComment>[^*a-z_A-Z\x80-\xFF\n]*[^*a-z_A-Z\x80-\xFF\\\n] {
1859 yyextra->defLitText+=yytext;
1860 yyextra->defText+=
escapeAt(yytext);
1861 }
static DString escapeAt(const DString &text)
1862<CopyCComment>\\[\r]?\n {
1863 yyextra->defLitText+=yytext;
1864 yyextra->defText+=" ";
1865 yyextra->yyLineNr++;
1866 yyextra->yyMLines++;
1867 }
1868<CopyCComment>{CCE} {
1869 yyextra->defLitText+=yytext;
1870 yyextra->defText+=yytext;
1871 BEGIN(yyextra->lastCContext);
1872 }
1873<CopyCComment>\n {
1874 yyextra->yyLineNr++;
1875 yyextra->defLitText+=yytext;
1876 yyextra->defText+=' ';
1877 }
1878<RemoveCComment>{CCE}{B}*"#" { // see bug 594021 for a usecase for this rule
1879 if (yyextra->lastCContext==SkipCPPBlock)
1880 {
1881 BEGIN(SkipCommand);
1882 }
1883 else
1884 {
1885 REJECT;
1886 }
1887 }
1888<RemoveCComment>{CCE} { BEGIN(yyextra->lastCContext); }
1889<RemoveCComment>{CPPC}
1890<RemoveCComment>{CCS}
1891<RemoveCComment>[^*\x06\n]+
1892<RemoveCComment>\n { yyextra->yyLineNr++; outputChar(yyscanner,'\n'); }
1893<RemoveCComment>.
1894<SkipCPPComment>[^\n\/\\@]+ {
1896 }
1897<SkipCPPComment,RemoveCPPComment>\n {
1898 unput(*yytext);
1899 BEGIN(yyextra->lastCPPContext);
1900 }
1901<SkipCPPComment>{CCS} {
1903 }
1904<SkipCPPComment>{CPPC} {
1906 }
1907<SkipCPPComment>[^\x06\@\\\n]+ {
1909 }
1910<SkipCPPComment>. {
1912 }
1913<RemoveCPPComment>{CCS}
1914<RemoveCPPComment>{CPPC}
1915<RemoveCPPComment>[^\x06\n]+
1916<RemoveCPPComment>.
1917<DefineText>"__VA_OPT__("{B}*"##" {
1918 warn(yyextra->fileName,yyextra->yyLineNr,
1919 "'##' may not appear at the beginning of a __VA_OPT__()",
1920 yyextra->defName,yyextra->defLitText.stripWhiteSpace());
1921 yyextra->defText+="__VA_OPT__(";
1922 yyextra->defLitText+="__VA_OPT__(";
1923 }
1924<DefineText>"#"/"__VA_OPT__" {
1925 yyextra->defText+=yytext;
1926 yyextra->defLitText+=yytext;
1927 }
1928<DefineText>"#"/{IDSTART} {
1930 yyextra->quoteArg=true;
1931 yyextra->idStart=true;
1932 yyextra->defLitText+=yytext;
1933 }
1934<DefineText,CopyCComment>{ID} {
1935 yyextra->defLitText+=yytext;
1936 if (YY_START == DefineText)
outputSpaces(yyscanner,yytext);
1937 if (yyextra->quoteArg)
1938 {
1939 yyextra->defText+="\"";
1940 }
1941 if (yyextra->defArgs>0)
1942 {
1943 auto it = yyextra->argMap.find(yytext);
1944 if (it!=yyextra->argMap.end())
1945 {
1946 int n = it->second;
1947 yyextra->defText+='@';
1948 yyextra->defText+=
DString().setNum(n);
1949 }
1950 else
1951 {
1952 if (yyextra->idStart)
1953 {
1954 warn(yyextra->fileName,yyextra->yyLineNr,
1955 "'#' is not followed by a macro parameter '{}': '{}'",
1956 yyextra->defName,yyextra->defLitText.stripWhiteSpace());
1957 }
1958 yyextra->defText+=yytext;
1959 }
1960 }
1961 else
1962 {
1963 yyextra->defText+=yytext;
1964 }
1965 if (yyextra->quoteArg)
1966 {
1967 yyextra->defText+="\"";
1968 }
1969 yyextra->quoteArg=false;
1970 yyextra->idStart=false;
1971 }
1972<CopyCComment>. {
1973 yyextra->defLitText+=yytext;
1974 yyextra->defText+=yytext;
1975 }
1976<DefineText>\\[\r]?\n {
1977 yyextra->defLitText+=yytext;
1980 yyextra->defText += ' ';
1981 yyextra->yyLineNr++;
1982 yyextra->yyMLines++;
1983 }
1984<DefineText>\n {
1986 yyextra->defText = yyextra->defText.stripWhiteSpace();
1987 if (yyextra->defText.startsWith("##"))
1988 {
1989 warn(yyextra->fileName,yyextra->yyLineNr,
1990 "'##' cannot occur at the beginning of a macro definition '{}': '{}'",
1991 yyextra->defName,yyextra->defLitText.stripWhiteSpace());
1992 }
1993 else if (yyextra->defText.endsWith("##"))
1994 {
1995 warn(yyextra->fileName,yyextra->yyLineNr,
1996 "'##' cannot occur at the end of a macro definition '{}': '{}'",
1997 yyextra->defName,yyextra->defLitText.stripWhiteSpace());
1998 }
1999 else if (yyextra->defText.endsWith("#"))
2000 {
2001 warn(yyextra->fileName,yyextra->yyLineNr,
2002 "expected formal parameter after # in macro definition '{}': '{}'",
2003 yyextra->defName,yyextra->defLitText.stripWhiteSpace());
2004 }
2005 if (!comment.
empty())
2006 {
2008 yyextra->defLitText=yyextra->defLitText.left(yyextra->defLitText.length()-comment.
length()-1);
2009 }
2011 yyextra->defLitText+=yytext;
2013
2014 if (yyextra->includeStack.empty() || yyextra->curlyCount>0)
2015 {
2017 }
2018 def=
isDefined(yyscanner,yyextra->defName);
2019 if (def==0)
2020 {
2021
2023 }
2024 else if (def )
2025
2026 {
2027
2028
2030 {
2032 def->
name = yyextra->defName;
2034 def->
nargs = yyextra->defArgs;
2036 def->
lineNr = yyextra->yyLineNr-yyextra->yyMLines;
2038 }
2039 else
2040 {
2041 if (def->
fileName != yyextra->fileName && !yyextra->expandOnlyPredef)
addDefine(yyscanner);
2042
2043 }
2044 }
2045 yyextra->argMap.clear();
2046 yyextra->yyLineNr++;
2047 yyextra->yyColNr=1;
2048 yyextra->lastGuardName.clear();
2049 BEGIN(Start);
2050 }
static DString extractTrailingComment(const DString &s)
static void addMacroDefinition(yyscan_t yyscanner)
static void addDefine(yyscan_t yyscanner)
2051<DefineText>{B}* { outputString(yyscanner,yytext);
2052 yyextra->defText += ' ';
2053 yyextra->defLitText+=yytext;
2054 }
2055<DefineText>{B}*"##"{B}* { outputString(yyscanner,substitute(yytext,"##"," "));
2056 yyextra->defText += "##";
2057 yyextra->defLitText+=yytext;
2058 }
2059<DefineText>"@" { outputString(yyscanner,substitute(yytext,"@@"," "));
2060 yyextra->defText += "@@";
2061 yyextra->defLitText+=yytext;
2062 }
2063<DefineText>\" {
2065 yyextra->defText += *yytext;
2066 yyextra->defLitText+=yytext;
2067 if (!yyextra->insideComment)
2068 {
2069 BEGIN(SkipDoubleQuote);
2070 }
2071 }
2072<DefineText>{NUMBER} {
2074 yyextra->defText += yytext;
2075 yyextra->defLitText+=yytext;
2076 }
2077<DefineText>\' {
2079 yyextra->defText += *yytext;
2080 yyextra->defLitText+=yytext;
2081 if (!yyextra->insideComment)
2082 {
2083 BEGIN(SkipSingleQuote);
2084 }
2085 }
2086<SkipDoubleQuote>{CPPC}[/]? { outputSpaces(yyscanner,yytext);
2087 yyextra->defText += yytext;
2088 yyextra->defLitText+=yytext;
2089 }
2090<SkipDoubleQuote>{CCS}[*]? { outputSpaces(yyscanner,yytext);
2091 yyextra->defText += yytext;
2092 yyextra->defLitText+=yytext;
2093 }
2094<SkipDoubleQuote>\" {
2096 yyextra->defText += *yytext;
2097 yyextra->defLitText+=yytext;
2098 BEGIN(DefineText);
2099 }
2100<SkipSingleQuote,SkipDoubleQuote>\\. {
2102 yyextra->defText += yytext;
2103 yyextra->defLitText+=yytext;
2104 }
2105<SkipSingleQuote>\' {
2107 yyextra->defText += *yytext;
2108 yyextra->defLitText+=yytext;
2109 BEGIN(DefineText);
2110 }
2111<SkipDoubleQuote,SkipSingleQuote>. { outputSpace(yyscanner,yytext[0]);
2112 yyextra->defText += *yytext;
2113 yyextra->defLitText += *yytext;
2114 }
2115<DefineText>. { outputSpace(yyscanner,yytext[0]);
2116 yyextra->defText += *yytext;
2117 yyextra->defLitText += *yytext;
2118 }
2119<<EOF>> {
2120 TRACE(
"End of include file");
2121
2122 if (yyextra->includeStack.empty())
2123 {
2124 TRACE(
"Terminating scanner");
2126 }
2127 else
2128 {
2129 if (!yyextra->levelGuard.empty())
2130 {
2131 if (yyextra->condGuardErrorLine!=0)
2132 {
2133 warn(yyextra->condGuardErrorFileName,yyextra->condGuardErrorLine,
"{}",yyextra->condGuardErrorMessage);
2134 }
2135 else
2136 {
2137 warn(yyextra->fileName,yyextra->yyLineNr,
"More #endif's than #if's found.");
2138 }
2139 }
2140 DString toFileName = yyextra->fileName;
2141 const std::unique_ptr<FileState> &fs=yyextra->includeStack.
back();
2142
2143 YY_BUFFER_STATE oldBuf = YY_CURRENT_BUFFER;
2144 yy_switch_to_buffer( fs->bufState, yyscanner );
2145 yy_delete_buffer( oldBuf, yyscanner );
2146 yyextra->yyLineNr = fs->lineNr;
2147
2148 yyextra->inputBuf = fs->oldFileBuf;
2149 yyextra->inputBufPos = fs->oldFileBufPos;
2150 yyextra->curlyCount = fs->curlyCount;
2151 yyextra->levelGuard = fs->levelGuard;
2153 TRACE(
"switching to {}",yyextra->fileName);
char & back()
Returns a reference to the last character.
2154
2155
2156
2158 lineStr.sprintf(
"# %d \"%s\" 2",yyextra->yyLineNr,
qPrint(yyextra->fileName));
2160
2161 yyextra->includeStack.pop_back();
2162
2163 {
2165
2166
2167
2168
2170 {
2171
2174 }
2175 else
2176 {
2178 {
2180 }
2181 }
2182 }
2183
2184 for (const auto &kv : yyextra->localDefines)
2185 {
2186 auto pair = yyextra->contextDefines.insert(kv);
2187 if (!pair.second)
2188 {
2189 yyextra->contextDefines.erase(pair.first);
2190 yyextra->contextDefines.insert(kv);
2191 }
2192 }
2193 yyextra->localDefines.clear();
2194 }
2195 }
void store(const std::string &fileName, const DefineMap &fromMap)
2196<*>{CCS}/{CCE} |
2197<*>{CCS}[*!]? {
2198 if (YY_START==SkipVerbatim || YY_START == SkipCondVerbatim || YY_START==SkipCond || YY_START==IDLquote || YY_START == PragmaOnce)
2199 {
2200 REJECT;
2201 }
2202 else
2203 {
2205 yyextra->lastCContext=YY_START;
2206 yyextra->commentCount=1;
2207 if (yyleng==3)
2208 {
2209 yyextra->isSpecialComment = true;
2210 yyextra->lastGuardName.clear();
2211 }
2212 else
2213 {
2214 yyextra->isSpecialComment = false;
2215 }
2216 BEGIN(SkipCComment);
2217 }
2218 }
2219<*>{CPPC}[/!]? {
2220 if (YY_START==SkipVerbatim || YY_START == SkipCondVerbatim || YY_START==SkipCond ||
getLanguageFromFileName(yyextra->fileName)==SrcLangExt::Fortran || YY_START==IDLquote || YY_START == PragmaOnce)
2221 {
2222 REJECT;
2223 }
2224 else if (YY_START==RulesRoundDouble)
2225 {
2226 REJECT;
2227 }
2228 else
2229 {
2231 yyextra->lastCPPContext=YY_START;
2232 if (yyleng==3)
2233 {
2234 yyextra->isSpecialComment = true;
2235 yyextra->lastGuardName.clear();
2236 }
2237 else
2238 {
2239 yyextra->isSpecialComment = false;
2240 }
2241 BEGIN(SkipCPPComment);
2242 }
2243 }
2244<*>\n {
2246 yyextra->yyLineNr++;
2247 }
2248<*>. {
2249 yyextra->expectGuard = false;
2251 }
2252
2253%%