499 {
501 }
static char resolveTrigraph(char c)
502<Start>^{B}*"#" {
503 yyextra->yyColNr+=(int)yyleng;
504 yyextra->yyMLines=0;
505 yyextra->potentialDefine=yytext;
506 BEGIN(Command);
507 }
508<Start>^("%top{"|"%{") {
511 BEGIN(LexCopyLine);
512 }
static void outputArray(yyscan_t yyscanner, const char *a, yy_size_t len)
513<Start>^{Bopt}"cpp_quote"{Bopt}"("{Bopt}\" {
514 if (yyextra->insideIDL)
515 {
516 BEGIN(IDLquote);
517 }
518 else
519 {
520 REJECT;
521 }
522 }
523<IDLquote>"\\\\" {
525 }
526<IDLquote>"\\\"" {
528 }
529<IDLquote>"\""{Bopt}")" {
530 BEGIN(Start);
531 }
532<IDLquote>\n {
534 yyextra->yyLineNr++;
535 }
536<IDLquote>. {
538 }
539<Start>^[Cc*].* {
541 if (!yyextra->isFixedFormFtn) REJECT;
543 }
544<Start>^{Bopt}"!".* {
547 }
548<Start>^{Bopt}/[^#] {
550 BEGIN(CopyLine);
551 }
552<Start>^{B}*[a-z_A-Z\x80-\xFF][a-z_A-Z0-9\x80-\xFF]+{B}*"("[^\)\n]*")"/{BN}{1,10}*[:{] { // constructors?
553 int i;
554 for (i=(int)yyleng-1;i>=0;i--)
555 {
556 unput(yytext[i]);
557 }
558 BEGIN(CopyLine);
559 }
560<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
561<Start>^{B}*[_A-Z][_A-Z0-9]+{B}*"("[^\)\n]*")"{B}*\n | // function like macro
562<Start>^{B}*[_A-Z][_A-Z0-9]+{B}*"("[^\(\)\n]*"("[^\)\n]*")"[^\)\n]*")"/{B}*("//"|"/\*") | // function list macro with one (...) argument followed by comment
563<Start>^{B}*[_A-Z][_A-Z0-9]+{B}*"("[^\)\n]*")"/{B}*("//"|"/\*") { // function like macro followed by comment
566 size_t pos =
name.find(
'(');
568 name=
name.left(pos).stripWhiteSpace();
#define Config_getBool(name)
569
571 if (skipFuncMacros && !yyextra->insideFtn &&
572 name!="Q_PROPERTY" &&
573 !(
574 (yyextra->includeStack.empty() || yyextra->curlyCount>0) &&
575 yyextra->macroExpansion &&
577
579 )
580 )
581 {
582
583 if (yytext[yyleng-1] == '\n')
584 {
586 yyextra->yyLineNr++;
587 }
588 }
589 else
590 {
591 int i;
592 for (i=(int)yyleng-1;i>=0;i--)
593 {
594 unput(yytext[i]);
595 }
596 BEGIN(CopyLine);
597 }
598 }
599<CopyLine,LexCopyLine>"extern"{BN}*"\""[^\"]+"\""{BN}*("{")? {
601 yyextra->yyLineNr+=text.
contains(
'\n');
603 }
604<CopyLine,LexCopyLine>{RAWBEGIN} {
607 BEGIN(CopyRawString);
608 }
DString extractBeginRawStringDelimiter(const char *rawStart)
609<CopyLine,LexCopyLine>"{" { // count brackets inside the main file
610 if (yyextra->includeStack.empty())
611 {
612 yyextra->curlyCount++;
613 }
615 }
616<LexCopyLine>^"%}" {
618 }
619<CopyLine,LexCopyLine>"}" { // count brackets inside the main file
620 if (yyextra->includeStack.empty() && yyextra->curlyCount>0)
621 {
622 yyextra->curlyCount--;
623 }
625 }
626<CopyLine,LexCopyLine>"'"\\[0-7]{1,3}"'" {
628 }
629<CopyLine,LexCopyLine>"'"\\."'" {
631 }
632<CopyLine,LexCopyLine>"'"."'" {
634 }
635<CopyLine,LexCopyLine>[$]?@\" {
638 BEGIN( CopyStringCs );
639 }
640<CopyLine,LexCopyLine>"!".* {
643 }
644<CopyLine,LexCopyLine>\" {
647 {
648 BEGIN( CopyString );
649 }
650 else
651 {
652 BEGIN( CopyStringFtnDouble );
653 }
654 }
655<CopyLine,LexCopyLine>\' {
658 BEGIN( CopyStringFtn );
659 }
660<CopyString>[^\"\\\r\n]{1,1000} {
662 }
663<CopyStringCs>[^\"\r\n]{1,1000} {
665 }
666<CopyStringCs>\"\" {
668 }
669<CopyString>\\. {
671 }
672<CopyString,CopyStringCs>\" {
674 BEGIN( CopyLine );
675 }
676<CopyStringFtnDouble>[^\"\\\r\n]{1,1000} {
678 }
679<CopyStringFtnDouble>\\. {
681 }
682<CopyStringFtnDouble>\" {
684 BEGIN( CopyLine );
685 }
686<CopyStringFtn>[^\'\\\r\n]{1,1000} {
688 }
689<CopyStringFtn>\\. {
691 }
692<CopyStringFtn>\' {
694 BEGIN( CopyLine );
695 }
696<CopyRawString>{RAWEND} {
699 {
700 BEGIN( CopyLine );
701 }
702 }
DString extractEndRawStringDelimiter(const char *rawEnd)
703<CopyRawString>[^)]{1,1000} {
705 }
706<CopyRawString>. {
708 }
709<CopyLine,LexCopyLine>{ID}/{BN}{0,80}"(" {
710 yyextra->expectGuard = false;
712
713
714
715
716
717
718
719
720 if ((yyextra->includeStack.empty() || yyextra->curlyCount>0) &&
721 yyextra->macroExpansion &&
724 )
725 {
726
727 yyextra->roundCount=0;
728 yyextra->defArgsStr=yytext;
731 {
736 }
737 else
738 {
739 yyextra->findDefArgContext = CopyLine;
740 BEGIN(FindDefineArgs);
741 }
742 }
743 else
744 {
746 }
747 }
static DString expandMacro(yyscan_t yyscanner, const DString &name)
748<CopyLine>{RulesDelim} {
750 yyextra->lexRulesPart = !yyextra->lexRulesPart;
752 }
753
754<CopyLine>{RulesSharp} {
755 if (!yyextra->lexRulesPart) REJECT;
756 if (yyextra->curlyCount) REJECT;
758 BEGIN(RulesPattern);
759 }
760<RulesPattern>{EscapeRulesChar} {
762 }
763<RulesPattern>{RulesCurly} {
765 }
766<RulesPattern>{StartDouble} {
768 yyextra->lastContext = YY_START;
769 BEGIN(RulesDouble);
770 }
771<RulesDouble,RulesRoundDouble>"\\\\" {
773 }
774<RulesDouble,RulesRoundDouble>"\\\"" {
776 }
777<RulesDouble>"\"" {
779 BEGIN( yyextra->lastContext ) ;
780 }
781<RulesRoundDouble>"\"" {
783 BEGIN(RulesRound) ;
784 }
785<RulesDouble,RulesRoundDouble>. {
787 }
788<RulesPattern>{StartSquare} {
790 yyextra->lastContext = YY_START;
791 BEGIN(RulesSquare);
792 }
793<RulesSquare,RulesRoundSquare>{CHARCE} {
795 }
796<RulesSquare,RulesRoundSquare>"\\[" |
797<RulesSquare,RulesRoundSquare>"\\]" {
799 }
800<RulesSquare>"]" {
802 BEGIN(RulesPattern);
803 }
804<RulesRoundSquare>"]" {
806 BEGIN(RulesRound) ;
807 }
808<RulesSquare,RulesRoundSquare>"\\\\" {
810 }
811<RulesSquare,RulesRoundSquare>. {
813 }
814<RulesPattern>{StartRoundQuest} {
816 yyextra->lastContext = YY_START;
817 BEGIN(RulesRoundQuest);
818 }
819<RulesRoundQuest>{nl} {
821 }
822<RulesRoundQuest>[^)] {
824 }
825<RulesRoundQuest>")" {
827 BEGIN(yyextra->lastContext);
828 }
829<RulesPattern>{StartRound} {
830 yyextra->roundCount++;
832 yyextra->lastContext = YY_START;
833 BEGIN(RulesRound);
834 }
835<RulesRound>{RulesCurly} {
837 }
838<RulesRound>{StartSquare} {
840 BEGIN(RulesRoundSquare);
841 }
842<RulesRound>{StartDouble} {
844 BEGIN(RulesRoundDouble);
845 }
846<RulesRound>{EscapeRulesChar} {
848 }
849<RulesRound>"(" {
850 yyextra->roundCount++;
852 }
853<RulesRound>")" {
854 yyextra->roundCount--;
856 if (!yyextra->roundCount) BEGIN( yyextra->lastContext ) ;
857 }
858<RulesRound>{nl} {
860 }
861<RulesRound>{B} {
863 }
864<RulesRound>. {
866 }
867<RulesPattern>{B} {
869 BEGIN(CopyLine);
870 }
871<RulesPattern>. {
873 }
874
875<CopyLine,LexCopyLine>{ID} {
878 if ((yyextra->includeStack.empty() || yyextra->curlyCount>0) &&
879 yyextra->macroExpansion &&
883 )
884 {
889 }
891 {
893 }
894 else
895 {
897 }
898 }
899<CopyLine,LexCopyLine>"\\"\r?/\n { // strip line continuation characters
901 }
902<CopyLine,LexCopyLine>\\. {
904 }
905<CopyLine,LexCopyLine>. {
907 }
908<CopyLine,LexCopyLine>\n {
910 BEGIN(Start);
911 yyextra->yyLineNr++;
912 yyextra->yyColNr=1;
913 }
914<FindDefineArgs>"(" {
915 yyextra->defArgsStr+='(';
916 yyextra->roundCount++;
917 }
918<FindDefineArgs>")" {
919 yyextra->defArgsStr+=')';
920 yyextra->roundCount--;
921 if (yyextra->roundCount==0)
922 {
924
925 if (yyextra->findDefArgContext==CopyLine)
926 {
928 BEGIN(yyextra->findDefArgContext);
929 }
930 else
931 {
933 yyextra->nospaces=false;
934 BEGIN(Start);
935 }
936 }
937 }
938
static void readIncludeFile(yyscan_t yyscanner, const DString &inc)
939<FindDefineArgs>")"{B}*"(" {
940 yyextra->defArgsStr+=yytext;
941 }
942 */
943<FindDefineArgs>{CHARLIT} {
944 yyextra->defArgsStr+=yytext;
945 }
946<FindDefineArgs>{CCS}[*!]? {
947 yyextra->defArgsStr+=yytext;
948 BEGIN(ArgCopyCComment);
949 }
950<FindDefineArgs>{CPPC}[/!].*\n/{B}*{CPPC}[/!] { // replace multi line C++ style comment by C style comment
952 {
953 if (yytext[3]=='<')
954 {
955 yyextra->defArgsStr+=
DString(
"/**< @brief ")+&yytext[4];
956 }
957 else
958 {
959 yyextra->defArgsStr+=
DString(
"/** @brief ")+&yytext[3];
960 }
961 }
962 else
963 {
964 yyextra->defArgsStr+=
DString(
"/**")+&yytext[3];
965 }
966 BEGIN(ArgCopyCppComment);
967 }
968<FindDefineArgs>{CPPC}[/!].*\n { // replace C++ single line style comment by C style comment
970 {
971 yyextra->defArgsStr+=
DString(
"/**")+&yytext[3]+
" */";
972 }
973 else
974 {
975 if (yytext[3]=='<')
976 {
977 yyextra->defArgsStr+=
DString(
"/**< @brief ")+&yytext[4]+
" */";
978 }
979 else
980 {
981 yyextra->defArgsStr+=
DString(
"/** @brief ")+&yytext[3]+
" */";
982 }
983 }
984 }
985<FindDefineArgs>{CPPC}.*\n { // replace C++ single line style comment by C style comment
987 yyextra->defArgsStr+=
DString(
"/*")+&yytext[2]+
" */";
988 }
989<FindDefineArgs>\" {
990 yyextra->defArgsStr+=*yytext;
991 BEGIN(ReadString);
992 }
993<FindDefineArgs>' {
995 yyextra->defArgsStr+=*yytext;
996 BEGIN(ReadString);
997 }
998<FindDefineArgs>\n {
999 yyextra->defArgsStr+=' ';
1000 yyextra->yyLineNr++;
1002 }
1003<FindDefineArgs>"@" {
1004 yyextra->defArgsStr+="@@";
1005 }
1006<FindDefineArgs>. {
1007 yyextra->defArgsStr+=*yytext;
1008 }
1009<ArgCopyCComment>[^*\n]+ {
1010 yyextra->defArgsStr+=yytext;
1011 }
1012<ArgCopyCComment>{CCE} {
1013 yyextra->defArgsStr+=yytext;
1014 BEGIN(FindDefineArgs);
1015 }
1016<ArgCopyCComment>\n {
1017 yyextra->defArgsStr+=yytext;
1018 yyextra->yyLineNr++;
1019 }
1020<ArgCopyCComment>. {
1021 yyextra->defArgsStr+=yytext;
1022 }
1023<ArgCopyCppComment>^{B}*
1024<ArgCopyCppComment>{CPPC}[/!].*\n/{B}*{CPPC}[/!] { // replace multi line C++ style comment by C style comment
1025 const char *startContent = &yytext[3];
1026 if (startContent[0]=='<') startContent++;
1027 yyextra->defArgsStr+=startContent;
1028 }
1029<ArgCopyCppComment>{CPPC}[/!].*\n { // replace C++ multie line style comment by C style comment
1030 const char *startContent = &yytext[3];
1031 if (startContent[0]=='<') startContent++;
1032 yyextra->defArgsStr+=
DString(startContent)+
" */";
1033 BEGIN(FindDefineArgs);
1034 }
1035<ArgCopyCppComment>. { // unexpected character
1036 unput(*yytext);
1037 yyextra->defArgsStr+=" */";
1038 BEGIN(FindDefineArgs);
1039 }
1040<ReadString>"\"" {
1041 yyextra->defArgsStr+=*yytext;
1042 BEGIN(FindDefineArgs);
1043 }
1044<ReadString>"'" {
1046 yyextra->defArgsStr+=*yytext;
1047 BEGIN(FindDefineArgs);
1048 }
1049
1050<ReadString>{CPPC}|{CCS} {
1051 yyextra->defArgsStr+=yytext;
1052 }
1053<ReadString>\\/\r?\n { // line continuation
1054 }
1055<ReadString>\\. {
1056 yyextra->defArgsStr+=yytext;
1057 }
1058<ReadString>. {
1059 yyextra->defArgsStr+=*yytext;
1060 }
1061<Command>("include"|"import"){B}+/{ID} {
1062 yyextra->isImported = yytext[1]=='m';
1063 if (yyextra->macroExpansion)
1064 BEGIN(IncludeID);
1065 }
1066<Command>("include"|"import"){B}*[<"] {
1067 yyextra->isImported = yytext[1]=='m';
1068 char c[2];
1069 c[0]=yytext[yyleng-1];c[1]='\0';
1070 yyextra->incName=c;
1071 BEGIN(Include);
1072 }
1073<Command>("cmake")?"define"{B}+ {
1074 yyextra->potentialDefine +=
substitute(yytext,
"cmake",
" ");
1075
1076 yyextra->yyColNr+=(int)yyleng;
1077 BEGIN(DefName);
1078 }
DString substitute(const DString &s, const DString &src, const DString &dst)
substitute all occurrences of src in s by dst
1079<Command>"cmakedefine01"{B}+ {
1080 yyextra->potentialDefine +=
substitute(yytext,
"cmakedefine01",
" define ");
1081
1082 yyextra->yyColNr+=(int)yyleng;
1083 BEGIN(CmakeDefName01);
1084 }
1085<Command>"ifdef"/{B}*"(" {
1087 yyextra->guardExpr.clear();
1088 BEGIN(DefinedExpr2);
1089 }
static void incrLevel(yyscan_t yyscanner)
1090<Command>"ifdef"/{B}+ {
1091
1093 yyextra->guardExpr.clear();
1094 BEGIN(DefinedExpr1);
1095 }
1096<Command>"ifndef"/{B}*"(" {
1098 yyextra->guardExpr="! ";
1099 BEGIN(DefinedExpr2);
1100 }
1101<Command>"ifndef"/{B}+ {
1103 yyextra->guardExpr="! ";
1104 BEGIN(DefinedExpr1);
1105 }
1106<Command>"if"/[ \t(!] {
1108 yyextra->guardExpr.clear();
1109 BEGIN(Guard);
1110 }
1111<Command>("elif"|"else"{B}*"if")/[ \t(!] {
1113 {
1114 yyextra->guardExpr.clear();
1115 BEGIN(Guard);
1116 }
1117 else
1118 {
1119 yyextra->ifcount=0;
1120 BEGIN(SkipCPPBlock);
1121 }
1122 }
static bool otherCaseDone(yyscan_t yyscanner)
1123<Command>"else"/[^a-z_A-Z0-9\x80-\xFF] {
1125 {
1126 yyextra->ifcount=0;
1127 BEGIN(SkipCPPBlock);
1128 }
1129 else
1130 {
1132 }
1133 }
static void setCaseDone(yyscan_t yyscanner, bool value)
1134<Command>"undef"{B}+ {
1135 BEGIN(UndefName);
1136 }
1137<Command>("elif"|"else"{B}*"if")/[ \t(!] {
1139 {
1140 yyextra->guardExpr.clear();
1141 BEGIN(Guard);
1142 }
1143 }
1144<Command>"endif"/[^a-z_A-Z0-9\x80-\xFF] {
1145
1147 }
static void decrLevel(yyscan_t yyscanner)
1148<Command,IgnoreLine>\n {
1150 BEGIN(Start);
1151 yyextra->yyLineNr++;
1152 }
1153<Command>"pragma"{B}+"once" {
1154 yyextra->expectGuard = false;
1155 if (yyextra->pragmaSet.find(yyextra->fileName.str())!=yyextra->pragmaSet.end())
1156 {
1158 BEGIN(PragmaOnce);
1159 }
1160 else
1161 {
1162 yyextra->pragmaSet.insert(yyextra->fileName.data());
1163 }
1164 }
1165<PragmaOnce>. {}
1166<PragmaOnce>\n {}
1167<PragmaOnce><<EOF>> {
1168 yyextra->expectGuard = false;
1169 BEGIN(Start);
1170 }
1171<Command>{ID} { // unknown directive
1172 BEGIN(IgnoreLine);
1173 }
1174<IgnoreLine>\\[\r]?\n {
1176 yyextra->yyLineNr++;
1177 }
1178<IgnoreLine>.
1179<Command>. { yyextra->potentialDefine += yytext[0]=='\t' ? '\t' : ' ';
1180 yyextra->yyColNr+=(int)yyleng;
1181 }
1182<UndefName>{ID} {
1185
1187 )
1188 {
1189
1191 }
1192 BEGIN(Start);
1193 }
1194<Guard>\\[\r]?\n {
1196 yyextra->guardExpr+=' ';
1197 yyextra->yyLineNr++;
1198 }
1199<Guard>"defined"/{B}*"(" {
1200 BEGIN(DefinedExpr2);
1201 }
1202<Guard>"defined"/{B}+ {
1203 BEGIN(DefinedExpr1);
1204 }
1205<Guard>"true"/{B}|{B}*[\r]?\n { yyextra->guardExpr+="1L"; }
1206<Guard>"false"/{B}|{B}*[\r]?\n { yyextra->guardExpr+="0L"; }
1207<Guard>"not"/{B} { yyextra->guardExpr+='!'; }
1208<Guard>"not_eq"/{B} { yyextra->guardExpr+="!="; }
1209<Guard>"and"/{B} { yyextra->guardExpr+="&&"; }
1210<Guard>"or"/{B} { yyextra->guardExpr+="||"; }
1211<Guard>"bitand"/{B} { yyextra->guardExpr+="&"; }
1212<Guard>"bitor"/{B} { yyextra->guardExpr+="|"; }
1213<Guard>"xor"/{B} { yyextra->guardExpr+="^"; }
1214<Guard>"compl"/{B} { yyextra->guardExpr+="~"; }
1215<Guard>{ID} { yyextra->guardExpr+=yytext; }
1216<Guard>"@" { yyextra->guardExpr+="@@"; }
1217<Guard>. { yyextra->guardExpr+=*yytext; }
1218<Guard>\n {
1219 unput(*yytext);
1220
1221
1224 if (guard)
1225 {
1226 BEGIN(Start);
1227 }
1228 else
1229 {
1230 yyextra->ifcount=0;
1231 BEGIN(SkipCPPBlock);
1232 }
1233 }
static bool computeExpression(yyscan_t yyscanner, const DString &expr)
1234<DefinedExpr1,DefinedExpr2>\\\n { yyextra->yyLineNr++; outputChar(yyscanner,'\n'); }
1235<DefinedExpr1>{ID} {
1236 if (
isDefined(yyscanner,yytext) || yyextra->guardName==yytext)
1237 yyextra->guardExpr+=" 1L ";
1238 else
1239 yyextra->guardExpr+=" 0L ";
1240 yyextra->lastGuardName=yytext;
1241 BEGIN(Guard);
1242 }
1243<DefinedExpr2>{ID} {
1244 if (
isDefined(yyscanner,yytext) || yyextra->guardName==yytext)
1245 yyextra->guardExpr+=" 1L ";
1246 else
1247 yyextra->guardExpr+=" 0L ";
1248 yyextra->lastGuardName=yytext;
1249 }
1250<DefinedExpr1,DefinedExpr2>\n { // should not happen, handle anyway
1251 yyextra->yyLineNr++;
1252 yyextra->ifcount=0;
1253 BEGIN(SkipCPPBlock);
1254 }
1255<DefinedExpr2>")" {
1256 BEGIN(Guard);
1257 }
1258<DefinedExpr1,DefinedExpr2>.
1259<SkipCPPBlock>^{B}*"#" { BEGIN(SkipCommand); }
1260<SkipCPPBlock>^{Bopt}/[^#] { BEGIN(SkipLine); }
1261<SkipCPPBlock>\n { yyextra->yyLineNr++; outputChar(yyscanner,'\n'); }
1262<SkipCPPBlock>.
1263<SkipCommand>"if"(("n")?("def"))?/[ \t(!] {
1265 yyextra->ifcount++;
1266
1267 }
1268<SkipCommand>"else" {
1269
1271 {
1273
1274 BEGIN(Start);
1275 }
1276 }
1277<SkipCommand>("elif"|"else"{B}*"if")/[ \t(!] {
1278 if (yyextra->ifcount==0)
1279 {
1281 {
1282 yyextra->guardExpr.clear();
1283 yyextra->lastGuardName.clear();
1284 BEGIN(Guard);
1285 }
1286 else
1287 {
1288 BEGIN(SkipCPPBlock);
1289 }
1290 }
1291 }
1292<SkipCommand>"endif" {
1293 yyextra->expectGuard = false;
1295 if (--yyextra->ifcount<0)
1296 {
1297
1298 BEGIN(Start);
1299 }
1300 }
1301<SkipCommand>\n {
1303 yyextra->yyLineNr++;
1304 BEGIN(SkipCPPBlock);
1305 }
1306<SkipCommand>{ID} { // unknown directive
1307 BEGIN(SkipLine);
1308 }
1309<SkipCommand>.
1310<SkipLine>[^'"/\n]+
1311<SkipLine>{CHARLIT} { }
1312<SkipLine>\" {
1313 BEGIN(SkipString);
1314 }
1315<SkipLine>.
1316<SkipString>{CPPC}/[^\n]* {
1317 }
1318<SkipLine,SkipCommand,SkipCPPBlock>{CPPC}[^\n]* {
1319 yyextra->lastCPPContext=YY_START;
1320 BEGIN(RemoveCPPComment);
1321 }
1322<SkipString>{CCS}/[^\n]* {
1323 }
1324<SkipLine,SkipCommand,SkipCPPBlock>{CCS}/[^\n]* {
1325 yyextra->lastCContext=YY_START;
1326 BEGIN(RemoveCComment);
1327 }
1328<SkipLine>\n {
1330 yyextra->yyLineNr++;
1331 BEGIN(SkipCPPBlock);
1332 }
1333<SkipString>[^"\\\n]+ { }
1334<SkipString>\\. { }
1335<SkipString>\" {
1336 BEGIN(SkipLine);
1337 }
1338<SkipString>. { }
1339<IncludeID>{ID}{Bopt}/"(" {
1340 yyextra->nospaces=true;
1341 yyextra->roundCount=0;
1342 yyextra->defArgsStr=yytext;
1343 yyextra->findDefArgContext = IncludeID;
1344 BEGIN(FindDefineArgs);
1345 }
1346<IncludeID>{ID} {
1347 yyextra->nospaces=true;
1349 BEGIN(Start);
1350 }
1351<Include>[^\">\n]+[\">] {
1352 yyextra->incName+=yytext;
1353 if (yyextra->isImported)
1354 {
1355 BEGIN(EndImport);
1356 }
1357 else
1358 {
1360 BEGIN(Start);
1361 }
1362 }
1363<EndImport>{ENDIMPORTopt}/\n {
1365 BEGIN(Start);
1366 }
1367<EndImport>\\[\r]?"\n" {
1369 yyextra->yyLineNr++;
1370 }
1371<EndImport>. {
1372 }
1373<DefName>{ID}/("\\\n")*"(" { // define with argument
1374
1375 yyextra->argMap.clear();
1376 yyextra->defArgs = 0;
1377 yyextra->defArgsStr.clear();
1378 yyextra->defText.clear();
1379 yyextra->defLitText.clear();
1380 yyextra->defName = yytext;
1381 yyextra->defVarArgs = false;
1382 yyextra->defExtraSpacing.clear();
1383 yyextra->defContinue = false;
1384 BEGIN(DefineArg);
1385 }
1386<DefName>{ID}{B}+"1"/[ \r\t\n] { // special case: define with 1 -> can be "guard"
1387
1388 yyextra->argMap.clear();
1389 yyextra->defArgs = -1;
1390 yyextra->defArgsStr.clear();
1392 yyextra->defVarArgs = false;
1393
1394
1395 if (yyextra->curlyCount>0 || yyextra->defName!=yyextra->lastGuardName || !yyextra->expectGuard)
1396 {
1397 DString def = yyextra->potentialDefine +
1398 yyextra->defName ;
1400 outputSpaces(yyscanner,yytext+yyextra->defName.length());
1401 yyextra->quoteArg=false;
1402 yyextra->insideComment=false;
1403 yyextra->lastGuardName.clear();
1404 yyextra->defText="1";
1405 yyextra->defLitText="1";
1406 BEGIN(DefineText);
1407 }
1408 else
1409 {
1410
1411 yyextra->defText.clear();
1412 yyextra->defLitText.clear();
1413 BEGIN(Start);
1414 }
1415 yyextra->expectGuard=false;
1416 }
static void outputSpaces(yyscan_t yyscanner, char *s)
1417<DefName,CmakeDefName01>{ID}/{B}*"\n" { // empty define
1418 yyextra->argMap.clear();
1419 yyextra->defArgs = -1;
1420 yyextra->defName = yytext;
1421 yyextra->defArgsStr.clear();
1422 yyextra->defText.clear();
1423 yyextra->defLitText.clear();
1424 yyextra->defVarArgs = false;
1425
1426
1427 if (yyextra->curlyCount>0 || yyextra->defName!=yyextra->lastGuardName || !yyextra->expectGuard)
1428 {
1429 DString def = yyextra->potentialDefine + yyextra->defName;
1431 yyextra->quoteArg=false;
1432 yyextra->insideComment=false;
1433 if (YY_START == CmakeDefName01) yyextra->defText = "0";
1434 else if (yyextra->insideCS) yyextra->defText="1";
1435 BEGIN(DefineText);
1436 }
1437 else
1438 {
1439
1440 yyextra->guardName = yytext;
1441 yyextra->lastGuardName.clear();
1442 BEGIN(Start);
1443 }
1444 yyextra->expectGuard=false;
1445 }
1446<DefName>{ID}/{B}* { // define with content
1447
1448 yyextra->argMap.clear();
1449 yyextra->defArgs = -1;
1450 yyextra->defArgsStr.clear();
1451 yyextra->defText.clear();
1452 yyextra->defLitText.clear();
1453 yyextra->defName = yytext;
1454 yyextra->defVarArgs = false;
1455 DString def = yyextra->potentialDefine +
1456 yyextra->defName +
1457 yyextra->defArgsStr ;
1459 yyextra->quoteArg=false;
1460 yyextra->insideComment=false;
1461 BEGIN(DefineText);
1462 }
1463<DefineArg>"\\\n" {
1464 yyextra->defExtraSpacing+="\n";
1465 yyextra->defContinue = true;
1466 yyextra->yyLineNr++;
1467 }
1468<DefineArg>{B}* { yyextra->defExtraSpacing+=yytext; }
1469<DefineArg>","{B}* { yyextra->defArgsStr+=yytext; }
1470<DefineArg>"("{B}* { yyextra->defArgsStr+=yytext; }
1471<DefineArg>{B}*")"{B}* {
1473 yyextra->defArgsStr+=yytext;
1474 DString def = yyextra->potentialDefine +
1475 yyextra->defName +
1476 yyextra->defArgsStr +
1477 yyextra->defExtraSpacing ;
1479 yyextra->quoteArg=false;
1480 yyextra->insideComment=false;
1481 BEGIN(DefineText);
1482 }
static void extraSpacing(yyscan_t yyscanner)
1483<DefineArg>"..." { // Variadic macro
1484 yyextra->defVarArgs = true;
1485 yyextra->defArgsStr+=yytext;
1486 yyextra->argMap.emplace(std::string("__VA_ARGS__"),yyextra->defArgs);
1487 yyextra->defArgs++;
1488 }
1489<DefineArg>{ID}{B}*("..."?) {
1490
1492 yyextra->defVarArgs = yytext[yyleng-1]=='.';
1493 if (yyextra->defVarArgs)
1494 {
1496 }
1498 yyextra->defArgsStr+=yytext;
1499 yyextra->argMap.emplace(
toStdString(argName),yyextra->defArgs);
1500 yyextra->defArgs++;
1502 }
1503
1504<DefineText>"/ **"|"/ *!" {
1505 yyextra->defText+=yytext;
1506 yyextra->defLitText+=yytext;
1507 yyextra->insideComment=true;
1508 }
1509<DefineText>"* /" {
1510 yyextra->defText+=yytext;
1511 yyextra->defLitText+=yytext;
1512 yyextra->insideComment=false;
1513 }
1514 */
1515<DefineText>{CCS}[^!*] {
1516 yyextra->defLitText+=' ';
1518 yyextra->lastCContext=YY_START;
1519 yyextra->commentCount=1;
1520 BEGIN(SkipCComment);
1521 }
1522<DefineText>{CCS}[!*] {
1523 yyextra->defText+=yytext;
1524 yyextra->defLitText+=yytext;
1525 yyextra->lastCContext=YY_START;
1526 yyextra->commentCount=1;
1527 BEGIN(CopyCComment);
1528 }
1529<DefineText>{CPPC}[!/]? {
1531 yyextra->lastCPPContext=YY_START;
1532 yyextra->defLitText+=' ';
1533 BEGIN(SkipCPPComment);
1534 }
1535<SkipCComment>[/]?{CCE} {
1536 if (yytext[0]==
'/')
outputChar(yyscanner,
'/');
1538 if (--yyextra->commentCount<=0)
1539 {
1540 if (yyextra->lastCContext==Start)
1541
1542
1543 {
1544 YY_CURRENT_BUFFER->yy_at_bol=1;
1545 }
1546 BEGIN(yyextra->lastCContext);
1547 }
1548 }
1549<SkipCComment>{CPPC}("/")* {
1551 }
1552<SkipCComment>{CCS} {
1554
1555 }
1556<SkipCond>{CMD}{CMD} { }
1557<SkipCond>^({B}*"*"+)?{B}{0,3}"~~~"[~]* {
1559 if (!markdownSupport || !yyextra->isSpecialComment)
1560 {
1561 REJECT;
1562 }
1563 else
1564 {
1565 yyextra->fenceChar='~';
1567 BEGIN(SkipCondVerbatim);
1568 }
1569 }
static yy_size_t getFenceSize(char *txt, yy_size_t leng)
1570<SkipCond>^({B}*"*"+)?{B}{0,3}"```"[`]* {
1572 if (!markdownSupport || !yyextra->isSpecialComment)
1573 {
1574 REJECT;
1575 }
1576 else
1577 {
1578 yyextra->fenceChar='`';
1580 BEGIN(SkipCondVerbatim);
1581 }
1582 }
1583<SkipCComment>^({B}*"*"+)?{B}{0,3}"~~~"[~]* {
1585 if (!markdownSupport || !yyextra->isSpecialComment)
1586 {
1587 REJECT;
1588 }
1589 else
1590 {
1592 yyextra->fenceChar='~';
1594 BEGIN(SkipVerbatim);
1595 }
1596 }
1597<SkipCComment>^({B}*"*"+)?{B}{0,3}"```"[`]* {
1599 if (!markdownSupport || !yyextra->isSpecialComment)
1600 {
1601 REJECT;
1602 }
1603 else
1604 {
1606 yyextra->fenceChar='`';
1608 BEGIN(SkipVerbatim);
1609 }
1610 }
1611<SkipCComment>{CMD}{VERBATIM_LINE} |
1612<SkipCComment>{CMD}{LITERAL_BLOCK} { // escaped command
1615 }
1616<SkipCComment>{VERBATIM_LINE}.*/\n { // normal command
1618 }
1619<SkipCComment>{LITERAL_BLOCK} { // normal block command
1622 if (yyextra->isSpecialComment)
1623 {
1625 BEGIN(SkipVerbatim);
1626 }
1627 }
static void determineBlockName(yyscan_t yyscanner)
1628<SkipCond>{CMD}{CMD}"cond"[ \t]+ {}// escaped cond command
1629<SkipCond>{CMD}"cond"/\n |
1630<SkipCond>{CMD}"cond"[ \t]+ { // cond command in a skipped cond section, this section has to be skipped as well
1631
1633 }
static void startCondSection(yyscan_t yyscanner, const DString §Id)
1634<SkipCComment>"{"[ \t]*"@code"/[ \t\n] {
1636 yyextra->javaBlock=1;
1637 BEGIN(JavaDocVerbatimCode);
1638 }
1639<SkipCComment>"{"[ \t]*"@literal"/[ \t\n] {
1641 yyextra->javaBlock=1;
1642 BEGIN(JavaDocVerbatimCode);
1643 }
1644<SkipCComment,SkipCPPComment>{CMD}{CMD}"cond"[ \t\n]+ { // escaped cond command
1646 }
1647<SkipCPPComment>{CMD}"cond"[ \t]+ { // conditional section
1648 yyextra->ccomment=true;
1649 yyextra->condCtx=YY_START;
1650 BEGIN(CondLineCpp);
1651 }
1652<SkipCComment>{CMD}"cond"[ \t]+ { // conditional section
1653 yyextra->ccomment=false;
1654 yyextra->condCtx=YY_START;
1655 BEGIN(CondLineC);
1656 }
1657<CondLineC,CondLineCpp>([!()&| \ta-z_A-Z0-9\x80-\xFF.\-]|{CMD}"doxyconfig")+ {
1659 if (yyextra->skip)
1660 {
1661 if (YY_START==CondLineC)
1662 {
1663
1665 yyextra->ccomment=true;
1666 }
1667 else
1668 {
1669 yyextra->ccomment=false;
1670 }
1671 BEGIN(SkipCond);
1672 }
1673 else
1674 {
1675 BEGIN(yyextra->condCtx);
1676 }
1677 }
1678CondLine>{B}*{CMD}doxyconfig{B}+{DOXYCFG} {
1680 }
1681<CondLineC,CondLineCpp>. { // non-guard character
1682 unput(*yytext);
1684 if (yyextra->skip)
1685 {
1686 if (YY_START==CondLineC)
1687 {
1688
1690 yyextra->ccomment=true;
1691 }
1692 else
1693 {
1694 yyextra->ccomment=false;
1695 }
1696 BEGIN(SkipCond);
1697 }
1698 else
1699 {
1700 BEGIN(yyextra->condCtx);
1701 }
1702 }
1703<SkipCComment,SkipCPPComment>{CMD}"cond"{WSopt}/\n { // no guard
1704 if (YY_START==SkipCComment)
1705 {
1706 yyextra->ccomment=true;
1707
1709 }
1710 else
1711 {
1712 yyextra->ccomment=false;
1713 }
1714 yyextra->condCtx=YY_START;
1715 yyextra->condGuardCount=0;
1717 BEGIN(SkipCond);
1718 }
1719<SkipCond>\n { yyextra->yyLineNr++; outputChar(yyscanner,'\n'); }
1720<SkipCond>{VERBATIM_LINE}.*/\n { }
1721<SkipCond>{LITERAL_BLOCK} {
1723 yyextra->yyLineNr+=numNLs;
1724 for (
int i = 0; i < numNLs; i++)
outputChar(yyscanner,
'\n');
1726 BEGIN(SkipCondVerbatim);
1727 }
1728
1729<SkipCond>. { }
1730<SkipCond>"#if"("def")? { yyextra->condGuardCount++; }
1731<SkipCond>"#endif" { yyextra->condGuardCount--; }
1732<SkipCond>[^\/\!*\\@\n#]+ { }
1733<SkipCond>{CPPC}[/!] { yyextra->ccomment=false; }
1734<SkipCond>{CCS}[*!] { yyextra->ccomment=true; }
1735<SkipCond,SkipCComment,SkipCPPComment>{CMD}{CMD}"endcond"/[^a-z_A-Z0-9\x80-\xFF] {
1736 if (!yyextra->skip)
1737 {
1739 }
1740 }
1741<SkipCond>{CMD}"endcond"/[^a-z_A-Z0-9\x80-\xFF] {
1742 bool oldSkip = yyextra->skip;
1744 if (oldSkip && !yyextra->skip)
1745 {
1746 if (yyextra->ccomment)
1747 {
1749 }
1750 BEGIN(yyextra->condCtx);
1751 }
1752 }
static void endCondSection(yyscan_t yyscanner)
1753<SkipCComment,SkipCPPComment>{CMD}"endcond"/[^a-z_A-Z0-9\x80-\xFF] {
1754 bool oldSkip = yyextra->skip;
1756 if (oldSkip && !yyextra->skip)
1757 {
1758 BEGIN(yyextra->condCtx);
1759 }
1760 }
1761<SkipCondVerbatim>{LITERAL_BLOCK_END} { /* end of verbatim block */
1762 if (yytext[1]=='f' && yyextra->blockName==&yytext[2])
1763 {
1764 BEGIN(SkipCond);
1765 }
1766 else if (&yytext[4]==yyextra->blockName)
1767 {
1768 BEGIN(SkipCond);
1769 }
1770 }
1771<SkipVerbatim>{LITERAL_BLOCK_END} { /* end of verbatim block */
1773 if (yytext[1]=='f' && yyextra->blockName==&yytext[2])
1774 {
1775 BEGIN(SkipCComment);
1776 }
1777 else if (&yytext[4]==yyextra->blockName)
1778 {
1779 BEGIN(SkipCComment);
1780 }
1781 }
1782<SkipCondVerbatim>^({B}*"*"+)?{B}{0,3}"~~~"[~]* {
1783 if (yyextra->fenceSize==
getFenceSize(yytext,yyleng) && yyextra->fenceChar==
'~')
1784 {
1785 BEGIN(SkipCond);
1786 }
1787 }
1788<SkipCondVerbatim>^({B}*"*"+)?{B}{0,3}"```"[`]* {
1789 if (yyextra->fenceSize==
getFenceSize(yytext,yyleng) && yyextra->fenceChar==
'`')
1790 {
1791 BEGIN(SkipCond);
1792 }
1793 }
1794<SkipVerbatim>^({B}*"*"+)?{B}{0,3}"~~~"[~]* {
1796 if (yyextra->fenceSize==
getFenceSize(yytext,yyleng) && yyextra->fenceChar==
'~')
1797 {
1798 BEGIN(SkipCComment);
1799 }
1800 }
1801<SkipVerbatim>^({B}*"*"+)?{B}{0,3}"```"[`]* {
1803 if (yyextra->fenceSize==
getFenceSize(yytext,yyleng) && yyextra->fenceChar==
'`')
1804 {
1805 BEGIN(SkipCComment);
1806 }
1807 }
1808<SkipCondVerbatim>{CCE}|{CCS} { }
1809<SkipVerbatim>{CCE}|{CCS} {
1811 }
1812<JavaDocVerbatimCode>"{" {
1813 if (yyextra->javaBlock==0)
1814 {
1815 REJECT;
1816 }
1817 else
1818 {
1819 yyextra->javaBlock++;
1821 }
1822 }
1823<JavaDocVerbatimCode>"}" {
1824 if (yyextra->javaBlock==0)
1825 {
1826 REJECT;
1827 }
1828 else
1829 {
1830 yyextra->javaBlock--;
1831 if (yyextra->javaBlock==0)
1832 {
1834 BEGIN(SkipCComment);
1835 }
1836 else
1837 {
1839 }
1840 }
1841 }
1842<JavaDocVerbatimCode>\n { /* new line in verbatim block */
1844 }
1845<JavaDocVerbatimCode>. { /* any other character */
1847 }
1848<SkipCondVerbatim>[^{*\\@\x06~`\n\/]+ { }
1849<SkipCComment,SkipVerbatim>[^{*\\@\x06~`\n\/]+ {
1851 }
1852<SkipCComment,SkipVerbatim,SkipCondVerbatim>\n {
1853 yyextra->yyLineNr++;
1855 }
1856<SkipCondVerbatim>. { }
1857<SkipCComment,SkipVerbatim>. {
1859 }
1860<CopyCComment>[^*a-z_A-Z\x80-\xFF\n]*[^*a-z_A-Z\x80-\xFF\\\n] {
1861 yyextra->defLitText+=yytext;
1862 yyextra->defText+=
escapeAt(yytext);
1863 }
static DString escapeAt(const DString &text)
1864<CopyCComment>\\[\r]?\n {
1865 yyextra->defLitText+=yytext;
1866 yyextra->defText+=" ";
1867 yyextra->yyLineNr++;
1868 yyextra->yyMLines++;
1869 }
1870<CopyCComment>{CCE} {
1871 yyextra->defLitText+=yytext;
1872 yyextra->defText+=yytext;
1873 BEGIN(yyextra->lastCContext);
1874 }
1875<CopyCComment>\n {
1876 yyextra->yyLineNr++;
1877 yyextra->defLitText+=yytext;
1878 yyextra->defText+=' ';
1879 }
1880<RemoveCComment>{CCE}{B}*"#" { // see bug 594021 for a usecase for this rule
1881 if (yyextra->lastCContext==SkipCPPBlock)
1882 {
1883 BEGIN(SkipCommand);
1884 }
1885 else
1886 {
1887 REJECT;
1888 }
1889 }
1890<RemoveCComment>{CCE} { BEGIN(yyextra->lastCContext); }
1891<RemoveCComment>{CPPC}
1892<RemoveCComment>{CCS}
1893<RemoveCComment>[^*\x06\n]+
1894<RemoveCComment>\n { yyextra->yyLineNr++; outputChar(yyscanner,'\n'); }
1895<RemoveCComment>.
1896<SkipCPPComment>[^\n\/\\@]+ {
1898 }
1899<SkipCPPComment,RemoveCPPComment>\n {
1900 unput(*yytext);
1901 BEGIN(yyextra->lastCPPContext);
1902 }
1903<SkipCPPComment>{CCS} {
1905 }
1906<SkipCPPComment>{CPPC} {
1908 }
1909<SkipCPPComment>[^\x06\@\\\n]+ {
1911 }
1912<SkipCPPComment>. {
1914 }
1915<RemoveCPPComment>{CCS}
1916<RemoveCPPComment>{CPPC}
1917<RemoveCPPComment>[^\x06\n]+
1918<RemoveCPPComment>.
1919<DefineText>"__VA_OPT__("{B}*"##" {
1920 warn(yyextra->fileName,yyextra->yyLineNr,
1921 "'##' may not appear at the beginning of a __VA_OPT__()",
1922 yyextra->defName,yyextra->defLitText.stripWhiteSpace());
1923 yyextra->defText+="__VA_OPT__(";
1924 yyextra->defLitText+="__VA_OPT__(";
1925 }
1926<DefineText>"#"/"__VA_OPT__" {
1927 yyextra->defText+=yytext;
1928 yyextra->defLitText+=yytext;
1929 }
1930<DefineText>"#"/{IDSTART} {
1932 yyextra->quoteArg=true;
1933 yyextra->idStart=true;
1934 yyextra->defLitText+=yytext;
1935 }
1936<DefineText,CopyCComment>{ID} {
1937 yyextra->defLitText+=yytext;
1938 if (YY_START == DefineText)
outputSpaces(yyscanner,yytext);
1939 if (yyextra->quoteArg)
1940 {
1941 yyextra->defText+="\"";
1942 }
1943 if (yyextra->defArgs>0)
1944 {
1945 auto it = yyextra->argMap.find(yytext);
1946 if (it!=yyextra->argMap.end())
1947 {
1948 int n = it->second;
1949 yyextra->defText+='@';
1951 }
1952 else
1953 {
1954 if (yyextra->idStart)
1955 {
1956 warn(yyextra->fileName,yyextra->yyLineNr,
1957 "'#' is not followed by a macro parameter '{}': '{}'",
1958 yyextra->defName,yyextra->defLitText.stripWhiteSpace());
1959 }
1960 yyextra->defText+=yytext;
1961 }
1962 }
1963 else
1964 {
1965 yyextra->defText+=yytext;
1966 }
1967 if (yyextra->quoteArg)
1968 {
1969 yyextra->defText+="\"";
1970 }
1971 yyextra->quoteArg=false;
1972 yyextra->idStart=false;
1973 }
1974<CopyCComment>. {
1975 yyextra->defLitText+=yytext;
1976 yyextra->defText+=yytext;
1977 }
1978<DefineText>\\[\r]?\n {
1979 yyextra->defLitText+=yytext;
1982 yyextra->defText += ' ';
1983 yyextra->yyLineNr++;
1984 yyextra->yyMLines++;
1985 }
1986<DefineText>\n {
1988 yyextra->defText = yyextra->defText.stripWhiteSpace();
1989 if (yyextra->defText.startsWith("##"))
1990 {
1991 warn(yyextra->fileName,yyextra->yyLineNr,
1992 "'##' cannot occur at the beginning of a macro definition '{}': '{}'",
1993 yyextra->defName,yyextra->defLitText.stripWhiteSpace());
1994 }
1995 else if (yyextra->defText.endsWith("##"))
1996 {
1997 warn(yyextra->fileName,yyextra->yyLineNr,
1998 "'##' cannot occur at the end of a macro definition '{}': '{}'",
1999 yyextra->defName,yyextra->defLitText.stripWhiteSpace());
2000 }
2001 else if (yyextra->defText.endsWith("#"))
2002 {
2003 warn(yyextra->fileName,yyextra->yyLineNr,
2004 "expected formal parameter after # in macro definition '{}': '{}'",
2005 yyextra->defName,yyextra->defLitText.stripWhiteSpace());
2006 }
2007 if (!comment.
empty())
2008 {
2010 yyextra->defLitText=yyextra->defLitText.left(yyextra->defLitText.length()-comment.
length()-1);
2011 }
2013 yyextra->defLitText+=yytext;
2015
2016 if (yyextra->includeStack.empty() || yyextra->curlyCount>0)
2017 {
2019 }
2020 def=
isDefined(yyscanner,yyextra->defName);
2021 if (def==0)
2022 {
2023
2025 }
2026 else if (def )
2027
2028 {
2029
2030
2032 {
2034 def->
name = yyextra->defName;
2036 def->
nargs = yyextra->defArgs;
2038 def->
lineNr = yyextra->yyLineNr-yyextra->yyMLines;
2040 }
2041 else
2042 {
2043 if (def->
fileName != yyextra->fileName && !yyextra->expandOnlyPredef)
addDefine(yyscanner);
2044
2045 }
2046 }
2047 yyextra->argMap.clear();
2048 yyextra->yyLineNr++;
2049 yyextra->yyColNr=1;
2050 yyextra->lastGuardName.clear();
2051 BEGIN(Start);
2052 }
static DString extractTrailingComment(const DString &s)
static void addMacroDefinition(yyscan_t yyscanner)
static void addDefine(yyscan_t yyscanner)
2053<DefineText>{B}* { outputString(yyscanner,yytext);
2054 yyextra->defText += ' ';
2055 yyextra->defLitText+=yytext;
2056 }
2057<DefineText>{B}*"##"{B}* { outputString(yyscanner,substitute(yytext,"##"," "));
2058 yyextra->defText += "##";
2059 yyextra->defLitText+=yytext;
2060 }
2061<DefineText>"@" { outputString(yyscanner,substitute(yytext,"@@"," "));
2062 yyextra->defText += "@@";
2063 yyextra->defLitText+=yytext;
2064 }
2065<DefineText>\" {
2067 yyextra->defText += *yytext;
2068 yyextra->defLitText+=yytext;
2069 if (!yyextra->insideComment)
2070 {
2071 BEGIN(SkipDoubleQuote);
2072 }
2073 }
2074<DefineText>{NUMBER} {
2076 yyextra->defText += yytext;
2077 yyextra->defLitText+=yytext;
2078 }
2079<DefineText>\' {
2081 yyextra->defText += *yytext;
2082 yyextra->defLitText+=yytext;
2083 if (!yyextra->insideComment)
2084 {
2085 BEGIN(SkipSingleQuote);
2086 }
2087 }
2088<SkipDoubleQuote>{CPPC}[/]? { outputSpaces(yyscanner,yytext);
2089 yyextra->defText += yytext;
2090 yyextra->defLitText+=yytext;
2091 }
2092<SkipDoubleQuote>{CCS}[*]? { outputSpaces(yyscanner,yytext);
2093 yyextra->defText += yytext;
2094 yyextra->defLitText+=yytext;
2095 }
2096<SkipDoubleQuote>\" {
2098 yyextra->defText += *yytext;
2099 yyextra->defLitText+=yytext;
2100 BEGIN(DefineText);
2101 }
2102<SkipSingleQuote,SkipDoubleQuote>\\. {
2104 yyextra->defText += yytext;
2105 yyextra->defLitText+=yytext;
2106 }
2107<SkipSingleQuote>\' {
2109 yyextra->defText += *yytext;
2110 yyextra->defLitText+=yytext;
2111 BEGIN(DefineText);
2112 }
2113<SkipDoubleQuote,SkipSingleQuote>. { outputSpace(yyscanner,yytext[0]);
2114 yyextra->defText += *yytext;
2115 yyextra->defLitText += *yytext;
2116 }
2117<DefineText>. { outputSpace(yyscanner,yytext[0]);
2118 yyextra->defText += *yytext;
2119 yyextra->defLitText += *yytext;
2120 }
2121<<EOF>> {
2122 TRACE(
"End of include file");
2123
2124 if (yyextra->includeStack.empty())
2125 {
2126 TRACE(
"Terminating scanner");
2128 }
2129 else
2130 {
2131 if (!yyextra->levelGuard.empty())
2132 {
2133 if (yyextra->condGuardErrorLine!=0)
2134 {
2135 warn(yyextra->condGuardErrorFileName,yyextra->condGuardErrorLine,
"{}",yyextra->condGuardErrorMessage);
2136 }
2137 else
2138 {
2139 warn(yyextra->fileName,yyextra->yyLineNr,
"More #endif's than #if's found.");
2140 }
2141 }
2142 DString toFileName = yyextra->fileName;
2143 const std::unique_ptr<FileState> &fs=yyextra->includeStack.
back();
2144
2145 YY_BUFFER_STATE oldBuf = YY_CURRENT_BUFFER;
2146 yy_switch_to_buffer( fs->bufState, yyscanner );
2147 yy_delete_buffer( oldBuf, yyscanner );
2148 yyextra->yyLineNr = fs->lineNr;
2149
2150 yyextra->inputBuf = fs->oldFileBuf;
2151 yyextra->inputBufPos = fs->oldFileBufPos;
2152 yyextra->curlyCount = fs->curlyCount;
2153 yyextra->levelGuard = fs->levelGuard;
2155 TRACE(
"switching to {}",yyextra->fileName);
char & back()
Returns a reference to the last character.
2156
2157
2158
2160 lineStr.sprintf(
"# %d \"%s\" 2",yyextra->yyLineNr,
qPrint(yyextra->fileName));
2162
2163 yyextra->includeStack.pop_back();
2164
2165 {
2167
2168
2169
2170
2172 {
2173
2176 }
2177 else
2178 {
2180 {
2182 }
2183 }
2184 }
2185
2186 for (const auto &kv : yyextra->localDefines)
2187 {
2188 auto pair = yyextra->contextDefines.insert(kv);
2189 if (!pair.second)
2190 {
2191 yyextra->contextDefines.erase(pair.first);
2192 yyextra->contextDefines.insert(kv);
2193 }
2194 }
2195 yyextra->localDefines.clear();
2196 }
2197 }
void store(const std::string &fileName, const DefineMap &fromMap)
2198<*>{CCS}/{CCE} |
2199<*>{CCS}[*!]? {
2200 if (YY_START==SkipVerbatim || YY_START == SkipCondVerbatim || YY_START==SkipCond || YY_START==IDLquote || YY_START == PragmaOnce)
2201 {
2202 REJECT;
2203 }
2204 else
2205 {
2207 yyextra->lastCContext=YY_START;
2208 yyextra->commentCount=1;
2209 if (yyleng==3)
2210 {
2211 yyextra->isSpecialComment = true;
2212 yyextra->lastGuardName.clear();
2213 }
2214 else
2215 {
2216 yyextra->isSpecialComment = false;
2217 }
2218 BEGIN(SkipCComment);
2219 }
2220 }
2221<*>{CPPC}[/!]? {
2222 if (YY_START==SkipVerbatim || YY_START == SkipCondVerbatim || YY_START==SkipCond ||
getLanguageFromFileName(yyextra->fileName)==SrcLangExt::Fortran || YY_START==IDLquote || YY_START == PragmaOnce)
2223 {
2224 REJECT;
2225 }
2226 else if (YY_START==RulesRoundDouble)
2227 {
2228 REJECT;
2229 }
2230 else
2231 {
2233 yyextra->lastCPPContext=YY_START;
2234 if (yyleng==3)
2235 {
2236 yyextra->isSpecialComment = true;
2237 yyextra->lastGuardName.clear();
2238 }
2239 else
2240 {
2241 yyextra->isSpecialComment = false;
2242 }
2243 BEGIN(SkipCPPComment);
2244 }
2245 }
2246<*>\n {
2248 yyextra->yyLineNr++;
2249 }
2250<*>. {
2251 yyextra->expectGuard = false;
2253 }
2254
2255%%