498 {
500 }
static char resolveTrigraph(char c)
501<Start>^{B}*"#" {
502 yyextra->yyColNr+=(int)yyleng;
503 yyextra->yyMLines=0;
504 yyextra->potentialDefine=yytext;
505 BEGIN(Command);
506 }
507<Start>^("%top{"|"%{") {
510 BEGIN(LexCopyLine);
511 }
static void outputArray(yyscan_t yyscanner, const char *a, yy_size_t len)
512<Start>^{Bopt}"cpp_quote"{Bopt}"("{Bopt}\" {
513 if (yyextra->insideIDL)
514 {
515 BEGIN(IDLquote);
516 }
517 else
518 {
519 REJECT;
520 }
521 }
522<IDLquote>"\\\\" {
524 }
525<IDLquote>"\\\"" {
527 }
528<IDLquote>"\""{Bopt}")" {
529 BEGIN(Start);
530 }
531<IDLquote>\n {
533 yyextra->yyLineNr++;
534 }
535<IDLquote>. {
537 }
538<Start>^[Cc*].* {
540 if (!yyextra->isFixedFormFtn) REJECT;
542 }
543<Start>^{Bopt}"!".* {
546 }
547<Start>^{Bopt}/[^#] {
549 BEGIN(CopyLine);
550 }
551<Start>^{B}*[a-z_A-Z\x80-\xFF][a-z_A-Z0-9\x80-\xFF]+{B}*"("[^\)\n]*")"/{BN}{1,10}*[:{] { // constructors?
552 int i;
553 for (i=(int)yyleng-1;i>=0;i--)
554 {
555 unput(yytext[i]);
556 }
557 BEGIN(CopyLine);
558 }
559<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
560<Start>^{B}*[_A-Z][_A-Z0-9]+{B}*"("[^\)\n]*")"{B}*\n | // function like macro
561<Start>^{B}*[_A-Z][_A-Z0-9]+{B}*"("[^\(\)\n]*"("[^\)\n]*")"[^\)\n]*")"/{B}*("//"|"/\*") | // function list macro with one (...) argument followed by comment
562<Start>^{B}*[_A-Z][_A-Z0-9]+{B}*"("[^\)\n]*")"/{B}*("//"|"/\*") { // function like macro followed by comment
565 size_t pos = name.find('(');
567 name=name.left(pos).stripWhiteSpace();
#define Config_getBool(name)
568
570 if (skipFuncMacros && !yyextra->insideFtn &&
571 name!="Q_PROPERTY" &&
572 !(
573 (yyextra->includeStack.empty() || yyextra->curlyCount>0) &&
574 yyextra->macroExpansion &&
576
578 )
579 )
580 {
581
582 if (yytext[yyleng-1] == '\n')
583 {
585 yyextra->yyLineNr++;
586 }
587 }
588 else
589 {
590 int i;
591 for (i=(int)yyleng-1;i>=0;i--)
592 {
593 unput(yytext[i]);
594 }
595 BEGIN(CopyLine);
596 }
597 }
598<CopyLine,LexCopyLine>"extern"{BN}*"\""[^\"]+"\""{BN}*("{")? {
600 yyextra->yyLineNr+=text.
contains(
'\n');
602 }
603<CopyLine,LexCopyLine>{RAWBEGIN} {
606 BEGIN(CopyRawString);
607 }
DString extractBeginRawStringDelimiter(const char *rawStart)
608<CopyLine,LexCopyLine>"{" { // count brackets inside the main file
609 if (yyextra->includeStack.empty())
610 {
611 yyextra->curlyCount++;
612 }
614 }
615<LexCopyLine>^"%}" {
617 }
618<CopyLine,LexCopyLine>"}" { // count brackets inside the main file
619 if (yyextra->includeStack.empty() && yyextra->curlyCount>0)
620 {
621 yyextra->curlyCount--;
622 }
624 }
625<CopyLine,LexCopyLine>"'"\\[0-7]{1,3}"'" {
627 }
628<CopyLine,LexCopyLine>"'"\\."'" {
630 }
631<CopyLine,LexCopyLine>"'"."'" {
633 }
634<CopyLine,LexCopyLine>[$]?@\" {
637 BEGIN( CopyStringCs );
638 }
639<CopyLine,LexCopyLine>"!".* {
642 }
643<CopyLine,LexCopyLine>\" {
646 {
647 BEGIN( CopyString );
648 }
649 else
650 {
651 BEGIN( CopyStringFtnDouble );
652 }
653 }
654<CopyLine,LexCopyLine>\' {
657 BEGIN( CopyStringFtn );
658 }
659<CopyString>[^\"\\\r\n]{1,1000} {
661 }
662<CopyStringCs>[^\"\r\n]{1,1000} {
664 }
665<CopyStringCs>\"\" {
667 }
668<CopyString>\\. {
670 }
671<CopyString,CopyStringCs>\" {
673 BEGIN( CopyLine );
674 }
675<CopyStringFtnDouble>[^\"\\\r\n]{1,1000} {
677 }
678<CopyStringFtnDouble>\\. {
680 }
681<CopyStringFtnDouble>\" {
683 BEGIN( CopyLine );
684 }
685<CopyStringFtn>[^\'\\\r\n]{1,1000} {
687 }
688<CopyStringFtn>\\. {
690 }
691<CopyStringFtn>\' {
693 BEGIN( CopyLine );
694 }
695<CopyRawString>{RAWEND} {
698 {
699 BEGIN( CopyLine );
700 }
701 }
DString extractEndRawStringDelimiter(const char *rawEnd)
702<CopyRawString>[^)]{1,1000} {
704 }
705<CopyRawString>. {
707 }
708<CopyLine,LexCopyLine>{ID}/{BN}{0,80}"(" {
709 yyextra->expectGuard = false;
711
712
713
714
715
716
717
718
719 if ((yyextra->includeStack.empty() || yyextra->curlyCount>0) &&
720 yyextra->macroExpansion &&
723 )
724 {
725
726 yyextra->roundCount=0;
727 yyextra->defArgsStr=yytext;
730 {
735 }
736 else
737 {
738 yyextra->findDefArgContext = CopyLine;
739 BEGIN(FindDefineArgs);
740 }
741 }
742 else
743 {
745 }
746 }
static DString expandMacro(yyscan_t yyscanner, const DString &name)
747<CopyLine>{RulesDelim} {
749 yyextra->lexRulesPart = !yyextra->lexRulesPart;
751 }
752
753<CopyLine>{RulesSharp} {
754 if (!yyextra->lexRulesPart) REJECT;
755 if (yyextra->curlyCount) REJECT;
757 BEGIN(RulesPattern);
758 }
759<RulesPattern>{EscapeRulesChar} {
761 }
762<RulesPattern>{RulesCurly} {
764 }
765<RulesPattern>{StartDouble} {
767 yyextra->lastContext = YY_START;
768 BEGIN(RulesDouble);
769 }
770<RulesDouble,RulesRoundDouble>"\\\\" {
772 }
773<RulesDouble,RulesRoundDouble>"\\\"" {
775 }
776<RulesDouble>"\"" {
778 BEGIN( yyextra->lastContext ) ;
779 }
780<RulesRoundDouble>"\"" {
782 BEGIN(RulesRound) ;
783 }
784<RulesDouble,RulesRoundDouble>. {
786 }
787<RulesPattern>{StartSquare} {
789 yyextra->lastContext = YY_START;
790 BEGIN(RulesSquare);
791 }
792<RulesSquare,RulesRoundSquare>{CHARCE} {
794 }
795<RulesSquare,RulesRoundSquare>"\\[" |
796<RulesSquare,RulesRoundSquare>"\\]" {
798 }
799<RulesSquare>"]" {
801 BEGIN(RulesPattern);
802 }
803<RulesRoundSquare>"]" {
805 BEGIN(RulesRound) ;
806 }
807<RulesSquare,RulesRoundSquare>"\\\\" {
809 }
810<RulesSquare,RulesRoundSquare>. {
812 }
813<RulesPattern>{StartRoundQuest} {
815 yyextra->lastContext = YY_START;
816 BEGIN(RulesRoundQuest);
817 }
818<RulesRoundQuest>{nl} {
820 }
821<RulesRoundQuest>[^)] {
823 }
824<RulesRoundQuest>")" {
826 BEGIN(yyextra->lastContext);
827 }
828<RulesPattern>{StartRound} {
829 yyextra->roundCount++;
831 yyextra->lastContext = YY_START;
832 BEGIN(RulesRound);
833 }
834<RulesRound>{RulesCurly} {
836 }
837<RulesRound>{StartSquare} {
839 BEGIN(RulesRoundSquare);
840 }
841<RulesRound>{StartDouble} {
843 BEGIN(RulesRoundDouble);
844 }
845<RulesRound>{EscapeRulesChar} {
847 }
848<RulesRound>"(" {
849 yyextra->roundCount++;
851 }
852<RulesRound>")" {
853 yyextra->roundCount--;
855 if (!yyextra->roundCount) BEGIN( yyextra->lastContext ) ;
856 }
857<RulesRound>{nl} {
859 }
860<RulesRound>{B} {
862 }
863<RulesRound>. {
865 }
866<RulesPattern>{B} {
868 BEGIN(CopyLine);
869 }
870<RulesPattern>. {
872 }
873
874<CopyLine,LexCopyLine>{ID} {
877 if ((yyextra->includeStack.empty() || yyextra->curlyCount>0) &&
878 yyextra->macroExpansion &&
882 )
883 {
888 }
890 {
892 }
893 else
894 {
896 }
897 }
898<CopyLine,LexCopyLine>"\\"\r?/\n { // strip line continuation characters
900 }
901<CopyLine,LexCopyLine>\\. {
903 }
904<CopyLine,LexCopyLine>. {
906 }
907<CopyLine,LexCopyLine>\n {
909 BEGIN(Start);
910 yyextra->yyLineNr++;
911 yyextra->yyColNr=1;
912 }
913<FindDefineArgs>"(" {
914 yyextra->defArgsStr+='(';
915 yyextra->roundCount++;
916 }
917<FindDefineArgs>")" {
918 yyextra->defArgsStr+=')';
919 yyextra->roundCount--;
920 if (yyextra->roundCount==0)
921 {
923
924 if (yyextra->findDefArgContext==CopyLine)
925 {
927 BEGIN(yyextra->findDefArgContext);
928 }
929 else
930 {
932 yyextra->nospaces=false;
933 BEGIN(Start);
934 }
935 }
936 }
937
static void readIncludeFile(yyscan_t yyscanner, const DString &inc)
938<FindDefineArgs>")"{B}*"(" {
939 yyextra->defArgsStr+=yytext;
940 }
941 */
942<FindDefineArgs>{CHARLIT} {
943 yyextra->defArgsStr+=yytext;
944 }
945<FindDefineArgs>{CCS}[*!]? {
946 yyextra->defArgsStr+=yytext;
947 BEGIN(ArgCopyCComment);
948 }
949<FindDefineArgs>{CPPC}[/!].*\n/{B}*{CPPC}[/!] { // replace multi line C++ style comment by C style comment
951 {
952 if (yytext[3]=='<')
953 {
954 yyextra->defArgsStr+=
DString(
"/**< @brief ")+&yytext[4];
955 }
956 else
957 {
958 yyextra->defArgsStr+=
DString(
"/** @brief ")+&yytext[3];
959 }
960 }
961 else
962 {
963 yyextra->defArgsStr+=
DString(
"/**")+&yytext[3];
964 }
965 BEGIN(ArgCopyCppComment);
966 }
967<FindDefineArgs>{CPPC}[/!].*\n { // replace C++ single line style comment by C style comment
969 {
970 yyextra->defArgsStr+=
DString(
"/**")+&yytext[3]+
" */";
971 }
972 else
973 {
974 if (yytext[3]=='<')
975 {
976 yyextra->defArgsStr+=
DString(
"/**< @brief ")+&yytext[4]+
" */";
977 }
978 else
979 {
980 yyextra->defArgsStr+=
DString(
"/** @brief ")+&yytext[3]+
" */";
981 }
982 }
983 }
984<FindDefineArgs>{CPPC}.*\n { // replace C++ single line style comment by C style comment
986 yyextra->defArgsStr+=
DString(
"/*")+&yytext[2]+
" */";
987 }
988<FindDefineArgs>\" {
989 yyextra->defArgsStr+=*yytext;
990 BEGIN(ReadString);
991 }
992<FindDefineArgs>' {
994 yyextra->defArgsStr+=*yytext;
995 BEGIN(ReadString);
996 }
997<FindDefineArgs>\n {
998 yyextra->defArgsStr+=' ';
999 yyextra->yyLineNr++;
1001 }
1002<FindDefineArgs>"@" {
1003 yyextra->defArgsStr+="@@";
1004 }
1005<FindDefineArgs>. {
1006 yyextra->defArgsStr+=*yytext;
1007 }
1008<ArgCopyCComment>[^*\n]+ {
1009 yyextra->defArgsStr+=yytext;
1010 }
1011<ArgCopyCComment>{CCE} {
1012 yyextra->defArgsStr+=yytext;
1013 BEGIN(FindDefineArgs);
1014 }
1015<ArgCopyCComment>\n {
1016 yyextra->defArgsStr+=yytext;
1017 yyextra->yyLineNr++;
1018 }
1019<ArgCopyCComment>. {
1020 yyextra->defArgsStr+=yytext;
1021 }
1022<ArgCopyCppComment>^{B}*
1023<ArgCopyCppComment>{CPPC}[/!].*\n/{B}*{CPPC}[/!] { // replace multi line C++ style comment by C style comment
1024 const char *startContent = &yytext[3];
1025 if (startContent[0]=='<') startContent++;
1026 yyextra->defArgsStr+=startContent;
1027 }
1028<ArgCopyCppComment>{CPPC}[/!].*\n { // replace C++ multie line style comment by C style comment
1029 const char *startContent = &yytext[3];
1030 if (startContent[0]=='<') startContent++;
1031 yyextra->defArgsStr+=
DString(startContent)+
" */";
1032 BEGIN(FindDefineArgs);
1033 }
1034<ArgCopyCppComment>. { // unexpected character
1035 unput(*yytext);
1036 yyextra->defArgsStr+=" */";
1037 BEGIN(FindDefineArgs);
1038 }
1039<ReadString>"\"" {
1040 yyextra->defArgsStr+=*yytext;
1041 BEGIN(FindDefineArgs);
1042 }
1043<ReadString>"'" {
1045 yyextra->defArgsStr+=*yytext;
1046 BEGIN(FindDefineArgs);
1047 }
1048
1049<ReadString>{CPPC}|{CCS} {
1050 yyextra->defArgsStr+=yytext;
1051 }
1052<ReadString>\\/\r?\n { // line continuation
1053 }
1054<ReadString>\\. {
1055 yyextra->defArgsStr+=yytext;
1056 }
1057<ReadString>. {
1058 yyextra->defArgsStr+=*yytext;
1059 }
1060<Command>("include"|"import"){B}+/{ID} {
1061 yyextra->isImported = yytext[1]=='m';
1062 if (yyextra->macroExpansion)
1063 BEGIN(IncludeID);
1064 }
1065<Command>("include"|"import"){B}*[<"] {
1066 yyextra->isImported = yytext[1]=='m';
1067 char c[2];
1068 c[0]=yytext[yyleng-1];c[1]='\0';
1069 yyextra->incName=c;
1070 BEGIN(Include);
1071 }
1072<Command>("cmake")?"define"{B}+ {
1073 yyextra->potentialDefine +=
substitute(yytext,
"cmake",
" ");
1074
1075 yyextra->yyColNr+=(int)yyleng;
1076 BEGIN(DefName);
1077 }
DString substitute(const DString &s, const DString &src, const DString &dst)
substitute all occurrences of src in s by dst
1078<Command>"cmakedefine01"{B}+ {
1079 yyextra->potentialDefine +=
substitute(yytext,
"cmakedefine01",
" define ");
1080
1081 yyextra->yyColNr+=(int)yyleng;
1082 BEGIN(CmakeDefName01);
1083 }
1084<Command>"ifdef"/{B}*"(" {
1086 yyextra->guardExpr.clear();
1087 BEGIN(DefinedExpr2);
1088 }
static void incrLevel(yyscan_t yyscanner)
1089<Command>"ifdef"/{B}+ {
1090
1092 yyextra->guardExpr.clear();
1093 BEGIN(DefinedExpr1);
1094 }
1095<Command>"ifndef"/{B}*"(" {
1097 yyextra->guardExpr="! ";
1098 BEGIN(DefinedExpr2);
1099 }
1100<Command>"ifndef"/{B}+ {
1102 yyextra->guardExpr="! ";
1103 BEGIN(DefinedExpr1);
1104 }
1105<Command>"if"/[ \t(!] {
1107 yyextra->guardExpr.clear();
1108 BEGIN(Guard);
1109 }
1110<Command>("elif"|"else"{B}*"if")/[ \t(!] {
1112 {
1113 yyextra->guardExpr.clear();
1114 BEGIN(Guard);
1115 }
1116 else
1117 {
1118 yyextra->ifcount=0;
1119 BEGIN(SkipCPPBlock);
1120 }
1121 }
static bool otherCaseDone(yyscan_t yyscanner)
1122<Command>"else"/[^a-z_A-Z0-9\x80-\xFF] {
1124 {
1125 yyextra->ifcount=0;
1126 BEGIN(SkipCPPBlock);
1127 }
1128 else
1129 {
1131 }
1132 }
static void setCaseDone(yyscan_t yyscanner, bool value)
1133<Command>"undef"{B}+ {
1134 BEGIN(UndefName);
1135 }
1136<Command>("elif"|"else"{B}*"if")/[ \t(!] {
1138 {
1139 yyextra->guardExpr.clear();
1140 BEGIN(Guard);
1141 }
1142 }
1143<Command>"endif"/[^a-z_A-Z0-9\x80-\xFF] {
1144
1146 }
static void decrLevel(yyscan_t yyscanner)
1147<Command,IgnoreLine>\n {
1149 BEGIN(Start);
1150 yyextra->yyLineNr++;
1151 }
1152<Command>"pragma"{B}+"once" {
1153 yyextra->expectGuard = false;
1154 if (yyextra->pragmaSet.find(yyextra->fileName.str())!=yyextra->pragmaSet.end())
1155 {
1157 BEGIN(PragmaOnce);
1158 }
1159 else
1160 {
1161 yyextra->pragmaSet.insert(yyextra->fileName.data());
1162 }
1163 }
1164<PragmaOnce>. {}
1165<PragmaOnce>\n {}
1166<PragmaOnce><<EOF>> {
1167 yyextra->expectGuard = false;
1168 BEGIN(Start);
1169 }
1170<Command>{ID} { // unknown directive
1171 BEGIN(IgnoreLine);
1172 }
1173<IgnoreLine>\\[\r]?\n {
1175 yyextra->yyLineNr++;
1176 }
1177<IgnoreLine>.
1178<Command>. { yyextra->potentialDefine += yytext[0]=='\t' ? '\t' : ' ';
1179 yyextra->yyColNr+=(int)yyleng;
1180 }
1181<UndefName>{ID} {
1184
1186 )
1187 {
1188
1190 }
1191 BEGIN(Start);
1192 }
1193<Guard>\\[\r]?\n {
1195 yyextra->guardExpr+=' ';
1196 yyextra->yyLineNr++;
1197 }
1198<Guard>"defined"/{B}*"(" {
1199 BEGIN(DefinedExpr2);
1200 }
1201<Guard>"defined"/{B}+ {
1202 BEGIN(DefinedExpr1);
1203 }
1204<Guard>"true"/{B}|{B}*[\r]?\n { yyextra->guardExpr+="1L"; }
1205<Guard>"false"/{B}|{B}*[\r]?\n { yyextra->guardExpr+="0L"; }
1206<Guard>"not"/{B} { yyextra->guardExpr+='!'; }
1207<Guard>"not_eq"/{B} { yyextra->guardExpr+="!="; }
1208<Guard>"and"/{B} { yyextra->guardExpr+="&&"; }
1209<Guard>"or"/{B} { yyextra->guardExpr+="||"; }
1210<Guard>"bitand"/{B} { yyextra->guardExpr+="&"; }
1211<Guard>"bitor"/{B} { yyextra->guardExpr+="|"; }
1212<Guard>"xor"/{B} { yyextra->guardExpr+="^"; }
1213<Guard>"compl"/{B} { yyextra->guardExpr+="~"; }
1214<Guard>{ID} { yyextra->guardExpr+=yytext; }
1215<Guard>"@" { yyextra->guardExpr+="@@"; }
1216<Guard>. { yyextra->guardExpr+=*yytext; }
1217<Guard>\n {
1218 unput(*yytext);
1219
1220
1223 if (guard)
1224 {
1225 BEGIN(Start);
1226 }
1227 else
1228 {
1229 yyextra->ifcount=0;
1230 BEGIN(SkipCPPBlock);
1231 }
1232 }
static bool computeExpression(yyscan_t yyscanner, const DString &expr)
1233<DefinedExpr1,DefinedExpr2>\\\n { yyextra->yyLineNr++; outputChar(yyscanner,'\n'); }
1234<DefinedExpr1>{ID} {
1235 if (
isDefined(yyscanner,yytext) || yyextra->guardName==yytext)
1236 yyextra->guardExpr+=" 1L ";
1237 else
1238 yyextra->guardExpr+=" 0L ";
1239 yyextra->lastGuardName=yytext;
1240 BEGIN(Guard);
1241 }
1242<DefinedExpr2>{ID} {
1243 if (
isDefined(yyscanner,yytext) || yyextra->guardName==yytext)
1244 yyextra->guardExpr+=" 1L ";
1245 else
1246 yyextra->guardExpr+=" 0L ";
1247 yyextra->lastGuardName=yytext;
1248 }
1249<DefinedExpr1,DefinedExpr2>\n { // should not happen, handle anyway
1250 yyextra->yyLineNr++;
1251 yyextra->ifcount=0;
1252 BEGIN(SkipCPPBlock);
1253 }
1254<DefinedExpr2>")" {
1255 BEGIN(Guard);
1256 }
1257<DefinedExpr1,DefinedExpr2>.
1258<SkipCPPBlock>^{B}*"#" { BEGIN(SkipCommand); }
1259<SkipCPPBlock>^{Bopt}/[^#] { BEGIN(SkipLine); }
1260<SkipCPPBlock>\n { yyextra->yyLineNr++; outputChar(yyscanner,'\n'); }
1261<SkipCPPBlock>.
1262<SkipCommand>"if"(("n")?("def"))?/[ \t(!] {
1264 yyextra->ifcount++;
1265
1266 }
1267<SkipCommand>"else" {
1268
1270 {
1272
1273 BEGIN(Start);
1274 }
1275 }
1276<SkipCommand>("elif"|"else"{B}*"if")/[ \t(!] {
1277 if (yyextra->ifcount==0)
1278 {
1280 {
1281 yyextra->guardExpr.clear();
1282 yyextra->lastGuardName.clear();
1283 BEGIN(Guard);
1284 }
1285 else
1286 {
1287 BEGIN(SkipCPPBlock);
1288 }
1289 }
1290 }
1291<SkipCommand>"endif" {
1292 yyextra->expectGuard = false;
1294 if (--yyextra->ifcount<0)
1295 {
1296
1297 BEGIN(Start);
1298 }
1299 }
1300<SkipCommand>\n {
1302 yyextra->yyLineNr++;
1303 BEGIN(SkipCPPBlock);
1304 }
1305<SkipCommand>{ID} { // unknown directive
1306 BEGIN(SkipLine);
1307 }
1308<SkipCommand>.
1309<SkipLine>[^'"/\n]+
1310<SkipLine>{CHARLIT} { }
1311<SkipLine>\" {
1312 BEGIN(SkipString);
1313 }
1314<SkipLine>.
1315<SkipString>{CPPC}/[^\n]* {
1316 }
1317<SkipLine,SkipCommand,SkipCPPBlock>{CPPC}[^\n]* {
1318 yyextra->lastCPPContext=YY_START;
1319 BEGIN(RemoveCPPComment);
1320 }
1321<SkipString>{CCS}/[^\n]* {
1322 }
1323<SkipLine,SkipCommand,SkipCPPBlock>{CCS}/[^\n]* {
1324 yyextra->lastCContext=YY_START;
1325 BEGIN(RemoveCComment);
1326 }
1327<SkipLine>\n {
1329 yyextra->yyLineNr++;
1330 BEGIN(SkipCPPBlock);
1331 }
1332<SkipString>[^"\\\n]+ { }
1333<SkipString>\\. { }
1334<SkipString>\" {
1335 BEGIN(SkipLine);
1336 }
1337<SkipString>. { }
1338<IncludeID>{ID}{Bopt}/"(" {
1339 yyextra->nospaces=true;
1340 yyextra->roundCount=0;
1341 yyextra->defArgsStr=yytext;
1342 yyextra->findDefArgContext = IncludeID;
1343 BEGIN(FindDefineArgs);
1344 }
1345<IncludeID>{ID} {
1346 yyextra->nospaces=true;
1348 BEGIN(Start);
1349 }
1350<Include>[^\">\n]+[\">] {
1351 yyextra->incName+=yytext;
1352 if (yyextra->isImported)
1353 {
1354 BEGIN(EndImport);
1355 }
1356 else
1357 {
1359 BEGIN(Start);
1360 }
1361 }
1362<EndImport>{ENDIMPORTopt}/\n {
1364 BEGIN(Start);
1365 }
1366<EndImport>\\[\r]?"\n" {
1368 yyextra->yyLineNr++;
1369 }
1370<EndImport>. {
1371 }
1372<DefName>{ID}/("\\\n")*"(" { // define with argument
1373
1374 yyextra->argMap.clear();
1375 yyextra->defArgs = 0;
1376 yyextra->defArgsStr.clear();
1377 yyextra->defText.clear();
1378 yyextra->defLitText.clear();
1379 yyextra->defName = yytext;
1380 yyextra->defVarArgs = false;
1381 yyextra->defExtraSpacing.clear();
1382 yyextra->defContinue = false;
1383 BEGIN(DefineArg);
1384 }
1385<DefName>{ID}{B}+"1"/[ \r\t\n] { // special case: define with 1 -> can be "guard"
1386
1387 yyextra->argMap.clear();
1388 yyextra->defArgs = -1;
1389 yyextra->defArgsStr.clear();
1391 yyextra->defVarArgs = false;
1392
1393
1394 if (yyextra->curlyCount>0 || yyextra->defName!=yyextra->lastGuardName || !yyextra->expectGuard)
1395 {
1396 DString def = yyextra->potentialDefine +
1397 yyextra->defName ;
1399 outputSpaces(yyscanner,yytext+yyextra->defName.length());
1400 yyextra->quoteArg=false;
1401 yyextra->insideComment=false;
1402 yyextra->lastGuardName.clear();
1403 yyextra->defText="1";
1404 yyextra->defLitText="1";
1405 BEGIN(DefineText);
1406 }
1407 else
1408 {
1409
1410 yyextra->defText.clear();
1411 yyextra->defLitText.clear();
1412 BEGIN(Start);
1413 }
1414 yyextra->expectGuard=false;
1415 }
static void outputSpaces(yyscan_t yyscanner, char *s)
1416<DefName,CmakeDefName01>{ID}/{B}*"\n" { // empty define
1417 yyextra->argMap.clear();
1418 yyextra->defArgs = -1;
1419 yyextra->defName = yytext;
1420 yyextra->defArgsStr.clear();
1421 yyextra->defText.clear();
1422 yyextra->defLitText.clear();
1423 yyextra->defVarArgs = false;
1424
1425
1426 if (yyextra->curlyCount>0 || yyextra->defName!=yyextra->lastGuardName || !yyextra->expectGuard)
1427 {
1428 DString def = yyextra->potentialDefine + yyextra->defName;
1430 yyextra->quoteArg=false;
1431 yyextra->insideComment=false;
1432 if (YY_START == CmakeDefName01) yyextra->defText = "0";
1433 else if (yyextra->insideCS) yyextra->defText="1";
1434 BEGIN(DefineText);
1435 }
1436 else
1437 {
1438
1439 yyextra->guardName = yytext;
1440 yyextra->lastGuardName.clear();
1441 BEGIN(Start);
1442 }
1443 yyextra->expectGuard=false;
1444 }
1445<DefName>{ID}/{B}* { // define with content
1446
1447 yyextra->argMap.clear();
1448 yyextra->defArgs = -1;
1449 yyextra->defArgsStr.clear();
1450 yyextra->defText.clear();
1451 yyextra->defLitText.clear();
1452 yyextra->defName = yytext;
1453 yyextra->defVarArgs = false;
1454 DString def = yyextra->potentialDefine +
1455 yyextra->defName +
1456 yyextra->defArgsStr ;
1458 yyextra->quoteArg=false;
1459 yyextra->insideComment=false;
1460 BEGIN(DefineText);
1461 }
1462<DefineArg>"\\\n" {
1463 yyextra->defExtraSpacing+="\n";
1464 yyextra->defContinue = true;
1465 yyextra->yyLineNr++;
1466 }
1467<DefineArg>{B}* { yyextra->defExtraSpacing+=yytext; }
1468<DefineArg>","{B}* { yyextra->defArgsStr+=yytext; }
1469<DefineArg>"("{B}* { yyextra->defArgsStr+=yytext; }
1470<DefineArg>{B}*")"{B}* {
1472 yyextra->defArgsStr+=yytext;
1473 DString def = yyextra->potentialDefine +
1474 yyextra->defName +
1475 yyextra->defArgsStr +
1476 yyextra->defExtraSpacing ;
1478 yyextra->quoteArg=false;
1479 yyextra->insideComment=false;
1480 BEGIN(DefineText);
1481 }
static void extraSpacing(yyscan_t yyscanner)
1482<DefineArg>"..." { // Variadic macro
1483 yyextra->defVarArgs = true;
1484 yyextra->defArgsStr+=yytext;
1485 yyextra->argMap.emplace(std::string("__VA_ARGS__"),yyextra->defArgs);
1486 yyextra->defArgs++;
1487 }
1488<DefineArg>{ID}{B}*("..."?) {
1489
1491 yyextra->defVarArgs = yytext[yyleng-1]=='.';
1492 if (yyextra->defVarArgs)
1493 {
1495 }
1497 yyextra->defArgsStr+=yytext;
1498 yyextra->argMap.emplace(
toStdString(argName),yyextra->defArgs);
1499 yyextra->defArgs++;
1501 }
1502
1503<DefineText>"/ **"|"/ *!" {
1504 yyextra->defText+=yytext;
1505 yyextra->defLitText+=yytext;
1506 yyextra->insideComment=true;
1507 }
1508<DefineText>"* /" {
1509 yyextra->defText+=yytext;
1510 yyextra->defLitText+=yytext;
1511 yyextra->insideComment=false;
1512 }
1513 */
1514<DefineText>{CCS}[^!*] {
1515 yyextra->defLitText+=' ';
1517 yyextra->lastCContext=YY_START;
1518 yyextra->commentCount=1;
1519 BEGIN(SkipCComment);
1520 }
1521<DefineText>{CCS}[!*] {
1522 yyextra->defText+=yytext;
1523 yyextra->defLitText+=yytext;
1524 yyextra->lastCContext=YY_START;
1525 yyextra->commentCount=1;
1526 BEGIN(CopyCComment);
1527 }
1528<DefineText>{CPPC}[!/]? {
1530 yyextra->lastCPPContext=YY_START;
1531 yyextra->defLitText+=' ';
1532 BEGIN(SkipCPPComment);
1533 }
1534<SkipCComment>[/]?{CCE} {
1535 if (yytext[0]==
'/')
outputChar(yyscanner,
'/');
1537 if (--yyextra->commentCount<=0)
1538 {
1539 if (yyextra->lastCContext==Start)
1540
1541
1542 {
1543 YY_CURRENT_BUFFER->yy_at_bol=1;
1544 }
1545 BEGIN(yyextra->lastCContext);
1546 }
1547 }
1548<SkipCComment>{CPPC}("/")* {
1550 }
1551<SkipCComment>{CCS} {
1553
1554 }
1555<SkipCond>{CMD}{CMD} { }
1556<SkipCond>^({B}*"*"+)?{B}{0,3}"~~~"[~]* {
1558 if (!markdownSupport || !yyextra->isSpecialComment)
1559 {
1560 REJECT;
1561 }
1562 else
1563 {
1564 yyextra->fenceChar='~';
1566 BEGIN(SkipCondVerbatim);
1567 }
1568 }
static yy_size_t getFenceSize(char *txt, yy_size_t leng)
1569<SkipCond>^({B}*"*"+)?{B}{0,3}"```"[`]* {
1571 if (!markdownSupport || !yyextra->isSpecialComment)
1572 {
1573 REJECT;
1574 }
1575 else
1576 {
1577 yyextra->fenceChar='`';
1579 BEGIN(SkipCondVerbatim);
1580 }
1581 }
1582<SkipCComment>^({B}*"*"+)?{B}{0,3}"~~~"[~]* {
1584 if (!markdownSupport || !yyextra->isSpecialComment)
1585 {
1586 REJECT;
1587 }
1588 else
1589 {
1591 yyextra->fenceChar='~';
1593 BEGIN(SkipVerbatim);
1594 }
1595 }
1596<SkipCComment>^({B}*"*"+)?{B}{0,3}"```"[`]* {
1598 if (!markdownSupport || !yyextra->isSpecialComment)
1599 {
1600 REJECT;
1601 }
1602 else
1603 {
1605 yyextra->fenceChar='`';
1607 BEGIN(SkipVerbatim);
1608 }
1609 }
1610<SkipCComment>{CMD}{VERBATIM_LINE} |
1611<SkipCComment>{CMD}{LITERAL_BLOCK} { // escaped command
1614 }
1615<SkipCComment>{VERBATIM_LINE}.*/\n { // normal command
1617 }
1618<SkipCComment>{LITERAL_BLOCK} { // normal block command
1621 if (yyextra->isSpecialComment)
1622 {
1624 BEGIN(SkipVerbatim);
1625 }
1626 }
static void determineBlockName(yyscan_t yyscanner)
1627<SkipCond>{CMD}{CMD}"cond"[ \t]+ {}// escaped cond command
1628<SkipCond>{CMD}"cond"/\n |
1629<SkipCond>{CMD}"cond"[ \t]+ { // cond command in a skipped cond section, this section has to be skipped as well
1630
1632 }
static void startCondSection(yyscan_t yyscanner, const DString §Id)
1633<SkipCComment>"{"[ \t]*"@code"/[ \t\n] {
1635 yyextra->javaBlock=1;
1636 BEGIN(JavaDocVerbatimCode);
1637 }
1638<SkipCComment>"{"[ \t]*"@literal"/[ \t\n] {
1640 yyextra->javaBlock=1;
1641 BEGIN(JavaDocVerbatimCode);
1642 }
1643<SkipCComment,SkipCPPComment>{CMD}{CMD}"cond"[ \t\n]+ { // escaped cond command
1645 }
1646<SkipCPPComment>{CMD}"cond"[ \t]+ { // conditional section
1647 yyextra->ccomment=true;
1648 yyextra->condCtx=YY_START;
1649 BEGIN(CondLineCpp);
1650 }
1651<SkipCComment>{CMD}"cond"[ \t]+ { // conditional section
1652 yyextra->ccomment=false;
1653 yyextra->condCtx=YY_START;
1654 BEGIN(CondLineC);
1655 }
1656<CondLineC,CondLineCpp>([!()&| \ta-z_A-Z0-9\x80-\xFF.\-]|{CMD}"doxyconfig")+ {
1658 if (yyextra->skip)
1659 {
1660 if (YY_START==CondLineC)
1661 {
1662
1664 yyextra->ccomment=true;
1665 }
1666 else
1667 {
1668 yyextra->ccomment=false;
1669 }
1670 BEGIN(SkipCond);
1671 }
1672 else
1673 {
1674 BEGIN(yyextra->condCtx);
1675 }
1676 }
1677CondLine>{B}*{CMD}doxyconfig{B}+{DOXYCFG} {
1679 }
1680<CondLineC,CondLineCpp>. { // non-guard character
1681 unput(*yytext);
1683 if (yyextra->skip)
1684 {
1685 if (YY_START==CondLineC)
1686 {
1687
1689 yyextra->ccomment=true;
1690 }
1691 else
1692 {
1693 yyextra->ccomment=false;
1694 }
1695 BEGIN(SkipCond);
1696 }
1697 else
1698 {
1699 BEGIN(yyextra->condCtx);
1700 }
1701 }
1702<SkipCComment,SkipCPPComment>{CMD}"cond"{WSopt}/\n { // no guard
1703 if (YY_START==SkipCComment)
1704 {
1705 yyextra->ccomment=true;
1706
1708 }
1709 else
1710 {
1711 yyextra->ccomment=false;
1712 }
1713 yyextra->condCtx=YY_START;
1714 yyextra->condGuardCount=0;
1716 BEGIN(SkipCond);
1717 }
1718<SkipCond>\n { yyextra->yyLineNr++; outputChar(yyscanner,'\n'); }
1719<SkipCond>{VERBATIM_LINE}.*/\n { }
1720<SkipCond>{LITERAL_BLOCK} {
1722 yyextra->yyLineNr+=numNLs;
1723 for (
int i = 0; i < numNLs; i++)
outputChar(yyscanner,
'\n');
1725 BEGIN(SkipCondVerbatim);
1726 }
1727
1728<SkipCond>. { }
1729<SkipCond>"#if"("def")? { yyextra->condGuardCount++; }
1730<SkipCond>"#endif" { yyextra->condGuardCount--; }
1731<SkipCond>[^\/\!*\\@\n#]+ { }
1732<SkipCond>{CPPC}[/!] { yyextra->ccomment=false; }
1733<SkipCond>{CCS}[*!] { yyextra->ccomment=true; }
1734<SkipCond,SkipCComment,SkipCPPComment>{CMD}{CMD}"endcond"/[^a-z_A-Z0-9\x80-\xFF] {
1735 if (!yyextra->skip)
1736 {
1738 }
1739 }
1740<SkipCond>{CMD}"endcond"/[^a-z_A-Z0-9\x80-\xFF] {
1741 bool oldSkip = yyextra->skip;
1743 if (oldSkip && !yyextra->skip)
1744 {
1745 if (yyextra->ccomment)
1746 {
1748 }
1749 BEGIN(yyextra->condCtx);
1750 }
1751 }
static void endCondSection(yyscan_t yyscanner)
1752<SkipCComment,SkipCPPComment>{CMD}"endcond"/[^a-z_A-Z0-9\x80-\xFF] {
1753 bool oldSkip = yyextra->skip;
1755 if (oldSkip && !yyextra->skip)
1756 {
1757 BEGIN(yyextra->condCtx);
1758 }
1759 }
1760<SkipCondVerbatim>{LITERAL_BLOCK_END} { /* end of verbatim block */
1761 if (yytext[1]=='f' && yyextra->blockName==&yytext[2])
1762 {
1763 BEGIN(SkipCond);
1764 }
1765 else if (&yytext[4]==yyextra->blockName)
1766 {
1767 BEGIN(SkipCond);
1768 }
1769 }
1770<SkipVerbatim>{LITERAL_BLOCK_END} { /* end of verbatim block */
1772 if (yytext[1]=='f' && yyextra->blockName==&yytext[2])
1773 {
1774 BEGIN(SkipCComment);
1775 }
1776 else if (&yytext[4]==yyextra->blockName)
1777 {
1778 BEGIN(SkipCComment);
1779 }
1780 }
1781<SkipCondVerbatim>^({B}*"*"+)?{B}{0,3}"~~~"[~]* {
1782 if (yyextra->fenceSize==
getFenceSize(yytext,yyleng) && yyextra->fenceChar==
'~')
1783 {
1784 BEGIN(SkipCond);
1785 }
1786 }
1787<SkipCondVerbatim>^({B}*"*"+)?{B}{0,3}"```"[`]* {
1788 if (yyextra->fenceSize==
getFenceSize(yytext,yyleng) && yyextra->fenceChar==
'`')
1789 {
1790 BEGIN(SkipCond);
1791 }
1792 }
1793<SkipVerbatim>^({B}*"*"+)?{B}{0,3}"~~~"[~]* {
1795 if (yyextra->fenceSize==
getFenceSize(yytext,yyleng) && yyextra->fenceChar==
'~')
1796 {
1797 BEGIN(SkipCComment);
1798 }
1799 }
1800<SkipVerbatim>^({B}*"*"+)?{B}{0,3}"```"[`]* {
1802 if (yyextra->fenceSize==
getFenceSize(yytext,yyleng) && yyextra->fenceChar==
'`')
1803 {
1804 BEGIN(SkipCComment);
1805 }
1806 }
1807<SkipCondVerbatim>{CCE}|{CCS} { }
1808<SkipVerbatim>{CCE}|{CCS} {
1810 }
1811<JavaDocVerbatimCode>"{" {
1812 if (yyextra->javaBlock==0)
1813 {
1814 REJECT;
1815 }
1816 else
1817 {
1818 yyextra->javaBlock++;
1820 }
1821 }
1822<JavaDocVerbatimCode>"}" {
1823 if (yyextra->javaBlock==0)
1824 {
1825 REJECT;
1826 }
1827 else
1828 {
1829 yyextra->javaBlock--;
1830 if (yyextra->javaBlock==0)
1831 {
1833 BEGIN(SkipCComment);
1834 }
1835 else
1836 {
1838 }
1839 }
1840 }
1841<JavaDocVerbatimCode>\n { /* new line in verbatim block */
1843 }
1844<JavaDocVerbatimCode>. { /* any other character */
1846 }
1847<SkipCondVerbatim>[^{*\\@\x06~`\n\/]+ { }
1848<SkipCComment,SkipVerbatim>[^{*\\@\x06~`\n\/]+ {
1850 }
1851<SkipCComment,SkipVerbatim,SkipCondVerbatim>\n {
1852 yyextra->yyLineNr++;
1854 }
1855<SkipCondVerbatim>. { }
1856<SkipCComment,SkipVerbatim>. {
1858 }
1859<CopyCComment>[^*a-z_A-Z\x80-\xFF\n]*[^*a-z_A-Z\x80-\xFF\\\n] {
1860 yyextra->defLitText+=yytext;
1861 yyextra->defText+=
escapeAt(yytext);
1862 }
static DString escapeAt(const DString &text)
1863<CopyCComment>\\[\r]?\n {
1864 yyextra->defLitText+=yytext;
1865 yyextra->defText+=" ";
1866 yyextra->yyLineNr++;
1867 yyextra->yyMLines++;
1868 }
1869<CopyCComment>{CCE} {
1870 yyextra->defLitText+=yytext;
1871 yyextra->defText+=yytext;
1872 BEGIN(yyextra->lastCContext);
1873 }
1874<CopyCComment>\n {
1875 yyextra->yyLineNr++;
1876 yyextra->defLitText+=yytext;
1877 yyextra->defText+=' ';
1878 }
1879<RemoveCComment>{CCE}{B}*"#" { // see bug 594021 for a usecase for this rule
1880 if (yyextra->lastCContext==SkipCPPBlock)
1881 {
1882 BEGIN(SkipCommand);
1883 }
1884 else
1885 {
1886 REJECT;
1887 }
1888 }
1889<RemoveCComment>{CCE} { BEGIN(yyextra->lastCContext); }
1890<RemoveCComment>{CPPC}
1891<RemoveCComment>{CCS}
1892<RemoveCComment>[^*\x06\n]+
1893<RemoveCComment>\n { yyextra->yyLineNr++; outputChar(yyscanner,'\n'); }
1894<RemoveCComment>.
1895<SkipCPPComment>[^\n\/\\@]+ {
1897 }
1898<SkipCPPComment,RemoveCPPComment>\n {
1899 unput(*yytext);
1900 BEGIN(yyextra->lastCPPContext);
1901 }
1902<SkipCPPComment>{CCS} {
1904 }
1905<SkipCPPComment>{CPPC} {
1907 }
1908<SkipCPPComment>[^\x06\@\\\n]+ {
1910 }
1911<SkipCPPComment>. {
1913 }
1914<RemoveCPPComment>{CCS}
1915<RemoveCPPComment>{CPPC}
1916<RemoveCPPComment>[^\x06\n]+
1917<RemoveCPPComment>.
1918<DefineText>"__VA_OPT__("{B}*"##" {
1919 warn(yyextra->fileName,yyextra->yyLineNr,
1920 "'##' may not appear at the beginning of a __VA_OPT__()",
1921 yyextra->defName,yyextra->defLitText.stripWhiteSpace());
1922 yyextra->defText+="__VA_OPT__(";
1923 yyextra->defLitText+="__VA_OPT__(";
1924 }
1925<DefineText>"#"/"__VA_OPT__" {
1926 yyextra->defText+=yytext;
1927 yyextra->defLitText+=yytext;
1928 }
1929<DefineText>"#"/{IDSTART} {
1931 yyextra->quoteArg=true;
1932 yyextra->idStart=true;
1933 yyextra->defLitText+=yytext;
1934 }
1935<DefineText,CopyCComment>{ID} {
1936 yyextra->defLitText+=yytext;
1937 if (YY_START == DefineText)
outputSpaces(yyscanner,yytext);
1938 if (yyextra->quoteArg)
1939 {
1940 yyextra->defText+="\"";
1941 }
1942 if (yyextra->defArgs>0)
1943 {
1944 auto it = yyextra->argMap.find(yytext);
1945 if (it!=yyextra->argMap.end())
1946 {
1947 int n = it->second;
1948 yyextra->defText+='@';
1950 }
1951 else
1952 {
1953 if (yyextra->idStart)
1954 {
1955 warn(yyextra->fileName,yyextra->yyLineNr,
1956 "'#' is not followed by a macro parameter '{}': '{}'",
1957 yyextra->defName,yyextra->defLitText.stripWhiteSpace());
1958 }
1959 yyextra->defText+=yytext;
1960 }
1961 }
1962 else
1963 {
1964 yyextra->defText+=yytext;
1965 }
1966 if (yyextra->quoteArg)
1967 {
1968 yyextra->defText+="\"";
1969 }
1970 yyextra->quoteArg=false;
1971 yyextra->idStart=false;
1972 }
1973<CopyCComment>. {
1974 yyextra->defLitText+=yytext;
1975 yyextra->defText+=yytext;
1976 }
1977<DefineText>\\[\r]?\n {
1978 yyextra->defLitText+=yytext;
1981 yyextra->defText += ' ';
1982 yyextra->yyLineNr++;
1983 yyextra->yyMLines++;
1984 }
1985<DefineText>\n {
1987 yyextra->defText = yyextra->defText.stripWhiteSpace();
1988 if (yyextra->defText.startsWith("##"))
1989 {
1990 warn(yyextra->fileName,yyextra->yyLineNr,
1991 "'##' cannot occur at the beginning of a macro definition '{}': '{}'",
1992 yyextra->defName,yyextra->defLitText.stripWhiteSpace());
1993 }
1994 else if (yyextra->defText.endsWith("##"))
1995 {
1996 warn(yyextra->fileName,yyextra->yyLineNr,
1997 "'##' cannot occur at the end of a macro definition '{}': '{}'",
1998 yyextra->defName,yyextra->defLitText.stripWhiteSpace());
1999 }
2000 else if (yyextra->defText.endsWith("#"))
2001 {
2002 warn(yyextra->fileName,yyextra->yyLineNr,
2003 "expected formal parameter after # in macro definition '{}': '{}'",
2004 yyextra->defName,yyextra->defLitText.stripWhiteSpace());
2005 }
2006 if (!comment.
empty())
2007 {
2009 yyextra->defLitText=yyextra->defLitText.left(yyextra->defLitText.length()-comment.
length()-1);
2010 }
2012 yyextra->defLitText+=yytext;
2014
2015 if (yyextra->includeStack.empty() || yyextra->curlyCount>0)
2016 {
2018 }
2019 def=
isDefined(yyscanner,yyextra->defName);
2020 if (def==0)
2021 {
2022
2024 }
2025 else if (def )
2026
2027 {
2028
2029
2031 {
2033 def->
name = yyextra->defName;
2035 def->
nargs = yyextra->defArgs;
2037 def->
lineNr = yyextra->yyLineNr-yyextra->yyMLines;
2039 }
2040 else
2041 {
2042 if (def->
fileName != yyextra->fileName && !yyextra->expandOnlyPredef)
addDefine(yyscanner);
2043
2044 }
2045 }
2046 yyextra->argMap.clear();
2047 yyextra->yyLineNr++;
2048 yyextra->yyColNr=1;
2049 yyextra->lastGuardName.clear();
2050 BEGIN(Start);
2051 }
static DString extractTrailingComment(const DString &s)
static void addMacroDefinition(yyscan_t yyscanner)
static void addDefine(yyscan_t yyscanner)
2052<DefineText>{B}* { outputString(yyscanner,yytext);
2053 yyextra->defText += ' ';
2054 yyextra->defLitText+=yytext;
2055 }
2056<DefineText>{B}*"##"{B}* { outputString(yyscanner,substitute(yytext,"##"," "));
2057 yyextra->defText += "##";
2058 yyextra->defLitText+=yytext;
2059 }
2060<DefineText>"@" { outputString(yyscanner,substitute(yytext,"@@"," "));
2061 yyextra->defText += "@@";
2062 yyextra->defLitText+=yytext;
2063 }
2064<DefineText>\" {
2066 yyextra->defText += *yytext;
2067 yyextra->defLitText+=yytext;
2068 if (!yyextra->insideComment)
2069 {
2070 BEGIN(SkipDoubleQuote);
2071 }
2072 }
2073<DefineText>{NUMBER} {
2075 yyextra->defText += yytext;
2076 yyextra->defLitText+=yytext;
2077 }
2078<DefineText>\' {
2080 yyextra->defText += *yytext;
2081 yyextra->defLitText+=yytext;
2082 if (!yyextra->insideComment)
2083 {
2084 BEGIN(SkipSingleQuote);
2085 }
2086 }
2087<SkipDoubleQuote>{CPPC}[/]? { outputSpaces(yyscanner,yytext);
2088 yyextra->defText += yytext;
2089 yyextra->defLitText+=yytext;
2090 }
2091<SkipDoubleQuote>{CCS}[*]? { outputSpaces(yyscanner,yytext);
2092 yyextra->defText += yytext;
2093 yyextra->defLitText+=yytext;
2094 }
2095<SkipDoubleQuote>\" {
2097 yyextra->defText += *yytext;
2098 yyextra->defLitText+=yytext;
2099 BEGIN(DefineText);
2100 }
2101<SkipSingleQuote,SkipDoubleQuote>\\. {
2103 yyextra->defText += yytext;
2104 yyextra->defLitText+=yytext;
2105 }
2106<SkipSingleQuote>\' {
2108 yyextra->defText += *yytext;
2109 yyextra->defLitText+=yytext;
2110 BEGIN(DefineText);
2111 }
2112<SkipDoubleQuote,SkipSingleQuote>. { outputSpace(yyscanner,yytext[0]);
2113 yyextra->defText += *yytext;
2114 yyextra->defLitText += *yytext;
2115 }
2116<DefineText>. { outputSpace(yyscanner,yytext[0]);
2117 yyextra->defText += *yytext;
2118 yyextra->defLitText += *yytext;
2119 }
2120<<EOF>> {
2121 TRACE(
"End of include file");
2122
2123 if (yyextra->includeStack.empty())
2124 {
2125 TRACE(
"Terminating scanner");
2127 }
2128 else
2129 {
2130 if (!yyextra->levelGuard.empty())
2131 {
2132 if (yyextra->condGuardErrorLine!=0)
2133 {
2134 warn(yyextra->condGuardErrorFileName,yyextra->condGuardErrorLine,
"{}",yyextra->condGuardErrorMessage);
2135 }
2136 else
2137 {
2138 warn(yyextra->fileName,yyextra->yyLineNr,
"More #endif's than #if's found.");
2139 }
2140 }
2141 DString toFileName = yyextra->fileName;
2142 const std::unique_ptr<FileState> &fs=yyextra->includeStack.
back();
2143
2144 YY_BUFFER_STATE oldBuf = YY_CURRENT_BUFFER;
2145 yy_switch_to_buffer( fs->bufState, yyscanner );
2146 yy_delete_buffer( oldBuf, yyscanner );
2147 yyextra->yyLineNr = fs->lineNr;
2148
2149 yyextra->inputBuf = fs->oldFileBuf;
2150 yyextra->inputBufPos = fs->oldFileBufPos;
2151 yyextra->curlyCount = fs->curlyCount;
2152 yyextra->levelGuard = fs->levelGuard;
2154 TRACE(
"switching to {}",yyextra->fileName);
char & back()
Returns a reference to the last character.
2155
2156
2157
2159 lineStr.sprintf(
"# %d \"%s\" 2",yyextra->yyLineNr,
qPrint(yyextra->fileName));
2161
2162 yyextra->includeStack.pop_back();
2163
2164 {
2166
2167
2168
2169
2171 {
2172
2175 }
2176 else
2177 {
2179 {
2181 }
2182 }
2183 }
2184
2185 for (const auto &kv : yyextra->localDefines)
2186 {
2187 auto pair = yyextra->contextDefines.insert(kv);
2188 if (!pair.second)
2189 {
2190 yyextra->contextDefines.erase(pair.first);
2191 yyextra->contextDefines.insert(kv);
2192 }
2193 }
2194 yyextra->localDefines.clear();
2195 }
2196 }
void store(const std::string &fileName, const DefineMap &fromMap)
2197<*>{CCS}/{CCE} |
2198<*>{CCS}[*!]? {
2199 if (YY_START==SkipVerbatim || YY_START == SkipCondVerbatim || YY_START==SkipCond || YY_START==IDLquote || YY_START == PragmaOnce)
2200 {
2201 REJECT;
2202 }
2203 else
2204 {
2206 yyextra->lastCContext=YY_START;
2207 yyextra->commentCount=1;
2208 if (yyleng==3)
2209 {
2210 yyextra->isSpecialComment = true;
2211 yyextra->lastGuardName.clear();
2212 }
2213 else
2214 {
2215 yyextra->isSpecialComment = false;
2216 }
2217 BEGIN(SkipCComment);
2218 }
2219 }
2220<*>{CPPC}[/!]? {
2221 if (YY_START==SkipVerbatim || YY_START == SkipCondVerbatim || YY_START==SkipCond ||
getLanguageFromFileName(yyextra->fileName)==SrcLangExt::Fortran || YY_START==IDLquote || YY_START == PragmaOnce)
2222 {
2223 REJECT;
2224 }
2225 else if (YY_START==RulesRoundDouble)
2226 {
2227 REJECT;
2228 }
2229 else
2230 {
2232 yyextra->lastCPPContext=YY_START;
2233 if (yyleng==3)
2234 {
2235 yyextra->isSpecialComment = true;
2236 yyextra->lastGuardName.clear();
2237 }
2238 else
2239 {
2240 yyextra->isSpecialComment = false;
2241 }
2242 BEGIN(SkipCPPComment);
2243 }
2244 }
2245<*>\n {
2247 yyextra->yyLineNr++;
2248 }
2249<*>. {
2250 yyextra->expectGuard = false;
2252 }
2253
2254%%