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