15%option never-interactive
18%option extra-type="struct preYY_state *"
22#define YY_TYPEDEF_YY_SCANNER_T
68#define YY_NO_UNISTD_H 1
132 for (
auto &[name,define] : fromMap)
150 if (dpf && includeStack.find(incFile)==includeStack.end())
152 includeStack.insert(incFile);
159 toMap.emplace(name,define);
173 void addInclude(
const std::string &fromFileName,
const std::string &toFileName)
179 it =
m_fileMap.emplace(fromFileName,std::make_unique<DefinesPerFile>(
this)).first;
181 auto &dpf = it->second;
182 dpf->addInclude(toFileName);
191 it =
m_fileMap.emplace(fileName,std::make_unique<DefinesPerFile>(
this)).first;
193 it->second->store(fromMap);
201 auto &dpf = it->second;
202 dpf->retrieve(toMap);
212 return it->second->stored();
222 return it!=
m_fileMap.end() ? it->second.get() :
nullptr;
225 std::unordered_map< std::string, std::unique_ptr<DefinesPerFile> >
m_fileMap;
344static yy_size_t
getFenceSize(
char *txt, yy_size_t leng);
349#define YY_INPUT(buf,result,max_size) result=yyread(yyscanner,buf,max_size);
constant expression parser used for the C preprocessor
A class representing a macro definition.
Local class used to hold the defines for a single file.
void addInclude(const std::string &fileName)
DefinesPerFile(DefineManager *parent)
Creates an empty container for defines.
void retrieveRec(DefineMap &toMap, StringUnorderedSet &includeStack)
void store(const DefineMap &fromMap)
StringUnorderedSet m_includedFiles
void retrieve(DefineMap &toMap)
Class that manages the defines available while preprocessing files.
bool alreadyProcessed(const std::string &fileName) const
void addInclude(const std::string &fromFileName, const std::string &toFileName)
void store(const std::string &fileName, const DefineMap &fromMap)
std::unordered_map< std::string, std::unique_ptr< DefinesPerFile > > m_fileMap
void retrieve(const std::string &fileName, DefineMap &toMap)
DefinesPerFile * find(const std::string &fileName) const
Helper function to return the DefinesPerFile object for a given file name.
A model of a file symbol.
Container class representing a vector of objects with keys.
This is an alternative implementation of QCString.
std::stack< bool > BoolStack
std::unordered_set< std::string > StringUnorderedSet
std::vector< std::string > StringVector
std::map< std::string, int > IntMap
std::vector< Define > DefineList
List of all macro definitions.
constexpr DocNodeVariant * parent(DocNodeVariant *n)
returns the parent node of a given node n or nullptr if the node has no parent.
Portable versions of functions that are platform dependent.
std::map< std::string, Define > DefineMap
A dictionary of managed Define objects.
static void startCondSection(yyscan_t yyscanner, const QCString §Id)
static void setCaseDone(yyscan_t yyscanner, bool value)
static void addMacroDefinition(yyscan_t yyscanner)
static void decrLevel(yyscan_t yyscanner)
static void addDefine(yyscan_t yyscanner)
static void determineBlockName(yyscan_t yyscanner)
static void incrLevel(yyscan_t yyscanner)
static QCString expandMacro(yyscan_t yyscanner, const QCString &name)
static void outputSpaces(yyscan_t yyscanner, char *s)
static void endCondSection(yyscan_t yyscanner)
static Define * isDefined(yyscan_t yyscanner, const QCString &name)
Returns a reference to a Define object given its name or 0 if the Define does not exist.
static void outputString(yyscan_t yyscanner, const QCString &s)
static void setFileName(yyscan_t yyscanner, const QCString &name)
static std::mutex g_globalDefineMutex
static void outputChar(yyscan_t yyscanner, char c)
static QCString extractTrailingComment(const QCString &s)
static int yyread(yyscan_t yyscanner, char *buf, int max_size)
static char resolveTrigraph(char c)
static const char * stateToString(int state)
static DefineManager g_defineManager
static void readIncludeFile(yyscan_t yyscanner, const QCString &inc)
static yy_size_t getFenceSize(char *txt, yy_size_t leng)
static std::mutex g_updateGlobals
static bool otherCaseDone(yyscan_t yyscanner)
static void outputArray(yyscan_t yyscanner, const char *a, yy_size_t len)
static void extraSpacing(yyscan_t yyscanner)
static const char * getLexerFILE()
static QCString escapeAt(const QCString &text)
static bool computeExpression(yyscan_t yyscanner, const QCString &expr)
static void outputSpace(yyscan_t yyscanner, char c)
static std::mutex g_debugMutex
Some helper functions for std::string.
const std::string * oldFileBuf
PreIncludeInfo(const QCString &fn, FileDef *srcFd, FileDef *dstFd, const QCString &iName, bool loc, bool imp)
preYY_CondCtx(const QCString &file, int line, const QCString &id, bool b)
StringUnorderedSet expanded
LinkedMap< PreIncludeInfo > includeRelations
StringUnorderedSet pragmaSet
ConstExpressionParser constExpParser
std::unordered_map< std::string, Define * > expandedDict
std::deque< std::unique_ptr< FileState > > includeStack
std::stack< std::unique_ptr< preYY_CondCtx > > condStack
const std::string * inputBuf
DefineList macroDefinitions
A bunch of utility functions.
359IDSTART [a-z_A-Z\x80-\xFF]
360ID {IDSTART}[a-z_A-Z0-9\x80-\xFF]*
364RAWBEGIN (u|U|L|u8)?R\"[^ \t\(\)\\]{0,16}"("
365RAWEND ")"[^ \t\(\)\\]{0,16}\"
366CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'"))
368FORMULA_START [\\@]("f{"|"f$"|"f["|"f(")
369FORMULA_END [\\@]("f}"|"f$"|"f]"|"f)")
370VERBATIM_START [\\@]("verbatim"|"iliteral"|"latexonly"|"htmlonly"|"xmlonly"|"docbookonly"|"rtfonly"|"manonly"|"dot"|"msc"|"startuml"|"code"("{"[^}]*"}")?){BN}+
371VERBATIM_END [\\@]("endverbatim"|"endiliteral"|"endlatexonly"|"endhtmlonly"|"endxmlonly"|"enddocbookonly"|"endrtfonly"|"endmanonly"|"enddot"|"endmsc"|"enduml"|"endcode")
372VERBATIM_LINE [\\@]"noop"{B}+
373LITERAL_BLOCK {FORMULA_START}|{VERBATIM_START}
374LITERAL_BLOCK_END {FORMULA_END}|{VERBATIM_END}
379RulesSharp "<"[^>\n]*">"
380RulesCurly "{"[^{}\n]*"}"
385EscapeRulesCharOpen "\\["|"\<"|"\\{"|"\\("|"\\\""|"\\ "|"\\\\"
386EscapeRulesCharClose "\\]"|"\>"|"\\}"|"\\)"
387EscapeRulesChar {EscapeRulesCharOpen}|{EscapeRulesCharClose}
413%x CopyStringFtnDouble
430%x JavaDocVerbatimCode
464 yyextra->yyColNr+=(int)yyleng;
466 yyextra->potentialDefine=yytext;
469<Start>^("%top{"|"%{") {
SrcLangExt getLanguageFromFileName(const QCString &fileName, SrcLangExt defLang)
474<Start>^{Bopt}"cpp_quote"{Bopt}"("{Bopt}\" {
475 if (yyextra->insideIDL)
490<IDLquote>"\""{Bopt}")" {
504<Start>^{B}*[a-z_A-Z\x80-\xFF][a-z_A-Z0-9\x80-\xFF]+{B}*"("[^\)\n]*")"/{BN}{1,10}*[:{] {
506 for (i=(
int)yyleng-1;i>=0;i--)
512<Start>^{B}*[_A-Z][_A-Z0-9]+{B}*"("[^\(\)\n]*"("[^\)\n]*")"[^\)\n]*")"{B}*\n |
513<Start>^{B}*[_A-Z][_A-Z0-9]+{B}*"("[^\)\n]*")"{B}*\n |
514<Start>^{B}*[_A-Z][_A-Z0-9]+{B}*"("[^\(\)\n]*"("[^\)\n]*")"[^\)\n]*")"/{B}*("//"|"/\*") |
515<Start>^{B}*[_A-Z][_A-Z0-9]+{B}*"("[^\)\n]*")"/{B}*("//"|"/\*") {
518 int pos = name.find(
'(');
520 name=name.left(pos).stripWhiteSpace();
523 if (skipFuncMacros && !yyextra->insideFtn &&
524 name!=
"Q_PROPERTY" &&
526 (yyextra->includeStack.empty() || yyextra->curlyCount>0) &&
527 yyextra->macroExpansion &&
535 if (yytext[yyleng-1] ==
'\n')
544 for (i=(
int)yyleng-1;i>=0;i--)
#define Config_getBool(name)
551<CopyLine,LexCopyLine>"extern"{BN}*"\""[^\"]+"\""{BN}*("{")? {
553 yyextra->yyLineNr+=text.
contains(
'\n');
int contains(char c, bool cs=TRUE) const
556<CopyLine,LexCopyLine>{RAWBEGIN} {
557 yyextra->delimiter = yytext+2;
558 yyextra->delimiter=yyextra->delimiter.left(yyextra->delimiter.length()-1);
560 BEGIN(CopyRawString);
562<CopyLine,LexCopyLine>"{" {
563 if (yyextra->includeStack.empty())
565 yyextra->curlyCount++;
572<CopyLine,LexCopyLine>"}" {
573 if (yyextra->includeStack.empty() && yyextra->curlyCount>0)
575 yyextra->curlyCount--;
579<CopyLine,LexCopyLine>"'"\\[0-7]{1,3}"'" {
582<CopyLine,LexCopyLine>"'"\\."'" {
585<CopyLine,LexCopyLine>"'"."'" {
588<CopyLine,LexCopyLine>[$]?@\" {
591 BEGIN( CopyStringCs );
593<CopyLine,LexCopyLine>\" {
601 BEGIN( CopyStringFtnDouble );
604<CopyLine,LexCopyLine>\' {
607 BEGIN( CopyStringFtn );
609<CopyString>[^\"\\\r\n]+ {
612<CopyStringCs>[^\"\r\n]+ {
621<CopyString,CopyStringCs>\" {
625<CopyStringFtnDouble>[^\"\\\r\n]+ {
628<CopyStringFtnDouble>\\. {
631<CopyStringFtnDouble>\" {
635<CopyStringFtn>[^\'\\\r\n]+ {
645<CopyRawString>{RAWEND} {
648 delimiter=delimiter.
left(delimiter.
length()-1);
649 if (delimiter==yyextra->delimiter)
size_t length() const
Returns the length of the string, not counting the 0-terminator.
QCString left(size_t len) const
654<CopyRawString>[^)]+ {
660<CopyLine,LexCopyLine>{ID}/{BN}{0,80}"(" {
661 yyextra->expectGuard =
FALSE;
671 if ((yyextra->includeStack.empty() || yyextra->curlyCount>0) &&
672 yyextra->macroExpansion &&
678 yyextra->roundCount=0;
679 yyextra->defArgsStr=yytext;
689 yyextra->findDefArgContext = CopyLine;
690 BEGIN(FindDefineArgs);
698<CopyLine>{RulesDelim} {
700 yyextra->lexRulesPart = !yyextra->lexRulesPart;
704<CopyLine>{RulesSharp} {
705 if (!yyextra->lexRulesPart) REJECT;
706 if (yyextra->curlyCount) REJECT;
710<RulesPattern>{EscapeRulesChar} {
713<RulesPattern>{RulesCurly} {
716<RulesPattern>{StartDouble} {
718 yyextra->lastContext = YY_START;
721<RulesDouble,RulesRoundDouble>"\\\\" {
724<RulesDouble,RulesRoundDouble>"\\\"" {
729 BEGIN( yyextra->lastContext ) ;
731<RulesRoundDouble>"\"" {
735<RulesDouble,RulesRoundDouble>. {
738<RulesPattern>{StartSquare} {
740 yyextra->lastContext = YY_START;
743<RulesSquare,RulesRoundSquare>{CHARCE} {
746<RulesSquare,RulesRoundSquare>"\\[" |
747<RulesSquare,RulesRoundSquare>"\\]" {
754<RulesRoundSquare>"]" {
758<RulesSquare,RulesRoundSquare>"\\\\" {
761<RulesSquare,RulesRoundSquare>. {
764<RulesPattern>{StartRoundQuest} {
766 yyextra->lastContext = YY_START;
767 BEGIN(RulesRoundQuest);
769<RulesRoundQuest>{nl} {
772<RulesRoundQuest>[^)] {
775<RulesRoundQuest>")" {
777 BEGIN(yyextra->lastContext);
779<RulesPattern>{StartRound} {
780 yyextra->roundCount++;
782 yyextra->lastContext = YY_START;
785<RulesRound>{RulesCurly} {
788<RulesRound>{StartSquare} {
790 BEGIN(RulesRoundSquare);
792<RulesRound>{StartDouble} {
794 BEGIN(RulesRoundDouble);
796<RulesRound>{EscapeRulesChar} {
800 yyextra->roundCount++;
804 yyextra->roundCount--;
806 if (!yyextra->roundCount) BEGIN( yyextra->lastContext ) ;
825<CopyLine,LexCopyLine>{ID} {
827 if ((yyextra->includeStack.empty() || yyextra->curlyCount>0) &&
828 yyextra->macroExpansion &&
844<CopyLine,LexCopyLine>"\\"\r?/\n {
847<CopyLine,LexCopyLine>\\. {
850<CopyLine,LexCopyLine>. {
853<CopyLine,LexCopyLine>\n {
860 yyextra->defArgsStr+=
'(';
861 yyextra->roundCount++;
864 yyextra->defArgsStr+=
')';
865 yyextra->roundCount--;
866 if (yyextra->roundCount==0)
870 if (yyextra->findDefArgContext==CopyLine)
873 BEGIN(yyextra->findDefArgContext);
878 yyextra->nospaces=
FALSE;
888<FindDefineArgs>{CHARLIT} {
889 yyextra->defArgsStr+=yytext;
891<FindDefineArgs>{CCS}[*]? {
892 yyextra->defArgsStr+=yytext;
893 BEGIN(ArgCopyCComment);
895<FindDefineArgs>{CPPC}[/!].*\n/{B}*{CPPC}[/!] {
896 yyextra->defArgsStr+=
QCString(
"/**")+&yytext[3];
897 BEGIN(ArgCopyCppComment);
899<FindDefineArgs>{CPPC}[/!].*\n {
900 yyextra->defArgsStr+=
QCString(
"/**")+&yytext[3]+
" */";
903 yyextra->defArgsStr+=*yytext;
908 yyextra->defArgsStr+=*yytext;
912 yyextra->defArgsStr+=
' ';
917 yyextra->defArgsStr+=
"@@";
920 yyextra->defArgsStr+=*yytext;
922<ArgCopyCComment>[^*\n]+ {
923 yyextra->defArgsStr+=yytext;
925<ArgCopyCComment>{CCE} {
926 yyextra->defArgsStr+=yytext;
927 BEGIN(FindDefineArgs);
930 yyextra->defArgsStr+=
' ';
935 yyextra->defArgsStr+=yytext;
937<ArgCopyCppComment>^{B}*
938<ArgCopyCppComment>{CPPC}[/!].*\n/{B}*{CPPC}[/!] {
939 const char *startContent = &yytext[3];
940 if (startContent[0]==
'<') startContent++;
941 yyextra->defArgsStr+=startContent;
943<ArgCopyCppComment>{CPPC}[/!].*\n {
944 const char *startContent = &yytext[3];
945 if (startContent[0]==
'<') startContent++;
946 yyextra->defArgsStr+=
QCString(startContent)+
" */";
947 BEGIN(FindDefineArgs);
949<ArgCopyCppComment>. {
951 yyextra->defArgsStr+=
" */";
952 BEGIN(FindDefineArgs);
955 yyextra->defArgsStr+=*yytext;
956 BEGIN(FindDefineArgs);
960 yyextra->defArgsStr+=*yytext;
961 BEGIN(FindDefineArgs);
964<ReadString>{CPPC}|{CCS} {
965 yyextra->defArgsStr+=yytext;
967<ReadString>\\/\r?\n {
970 yyextra->defArgsStr+=yytext;
973 yyextra->defArgsStr+=*yytext;
975<Command>("include"|"import"){B}+/{ID} {
976 yyextra->isImported = yytext[1]==
'm';
977 if (yyextra->macroExpansion)
980<Command>("include"|"import"){B}*[<"] {
981 yyextra->isImported = yytext[1]==
'm';
983 c[0]=yytext[yyleng-1];c[1]=
'\0';
987<Command>("cmake")?"define"{B}+ {
988 yyextra->potentialDefine +=
substitute(yytext,
"cmake",
" ");
990 yyextra->yyColNr+=(int)yyleng;
QCString substitute(const QCString &s, const QCString &src, const QCString &dst)
substitute all occurrences of src in s by dst
993<Command>"cmakedefine01"{B}+ {
994 yyextra->potentialDefine +=
substitute(yytext,
"cmakedefine01",
" define ");
996 yyextra->yyColNr+=(int)yyleng;
997 BEGIN(CmakeDefName01);
999<Command>"ifdef"/{B}*"(" {
1001 yyextra->guardExpr.clear();
1002 BEGIN(DefinedExpr2);
1004<Command>"ifdef"/{B}+ {
1007 yyextra->guardExpr.clear();
1008 BEGIN(DefinedExpr1);
1010<Command>"ifndef"/{B}*"(" {
1012 yyextra->guardExpr=
"! ";
1013 BEGIN(DefinedExpr2);
1015<Command>"ifndef"/{B}+ {
1017 yyextra->guardExpr=
"! ";
1018 BEGIN(DefinedExpr1);
1020<Command>"if"/[ \t(!] {
1022 yyextra->guardExpr.clear();
1025<Command>("elif"|"else"{B}*"if")/[ \t(!] {
1028 yyextra->guardExpr.clear();
1034 BEGIN(SkipCPPBlock);
1037<Command>"else"/[^a-z_A-Z0-9\x80-\xFF] {
1041 BEGIN(SkipCPPBlock);
1048<Command>"undef"{B}+ {
1051<Command>("elif"|"else"{B}*"if")/[ \t(!] {
1054 yyextra->guardExpr.clear();
1058<Command>"endif"/[^a-z_A-Z0-9\x80-\xFF] {
1062<Command,IgnoreLine>\n {
1065 yyextra->yyLineNr++;
1067<Command>"pragma"{B}+"once" {
1068 yyextra->expectGuard =
FALSE;
1069 if (yyextra->pragmaSet.find(yyextra->fileName.str())!=yyextra->pragmaSet.end())
1076 yyextra->pragmaSet.insert(yyextra->fileName.data());
1081<PragmaOnce><<EOF>> {
1082 yyextra->expectGuard =
FALSE;
1088<IgnoreLine>\\[\r]?\n {
1090 yyextra->yyLineNr++;
1093<Command>. { yyextra->potentialDefine += yytext[0]==
'\t' ?
'\t' :
' ';
1094 yyextra->yyColNr+=(int)yyleng;
1110 yyextra->guardExpr+=
' ';
1111 yyextra->yyLineNr++;
1113<Guard>"defined"/{B}*"(" {
1114 BEGIN(DefinedExpr2);
1116<Guard>"defined"/{B}+ {
1117 BEGIN(DefinedExpr1);
1119<Guard>"true"/{B}|{B}*[\r]?\n { yyextra->guardExpr+=
"1L"; }
1120<Guard>"false"/{B}|{B}*[\r]?\n { yyextra->guardExpr+=
"0L"; }
1121<Guard>"not"/{B} { yyextra->guardExpr+=
'!'; }
1122<Guard>"not_eq"/{B} { yyextra->guardExpr+=
"!="; }
1123<Guard>"and"/{B} { yyextra->guardExpr+=
"&&"; }
1124<Guard>"or"/{B} { yyextra->guardExpr+=
"||"; }
1125<Guard>"bitand"/{B} { yyextra->guardExpr+=
"&"; }
1126<Guard>"bitor"/{B} { yyextra->guardExpr+=
"|"; }
1127<Guard>"xor"/{B} { yyextra->guardExpr+=
"^"; }
1128<Guard>"compl"/{B} { yyextra->guardExpr+=
"~"; }
1129<Guard>{ID} { yyextra->guardExpr+=yytext; }
1130<Guard>"@" { yyextra->guardExpr+=
"@@"; }
1131<Guard>. { yyextra->guardExpr+=*yytext; }
1145 BEGIN(SkipCPPBlock);
1148<DefinedExpr1,DefinedExpr2>\\\n { yyextra->yyLineNr++;
outputChar(yyscanner,
'\n'); }
1150 if (
isDefined(yyscanner,yytext) || yyextra->guardName==yytext)
1151 yyextra->guardExpr+=
" 1L ";
1153 yyextra->guardExpr+=
" 0L ";
1154 yyextra->lastGuardName=yytext;
1158 if (
isDefined(yyscanner,yytext) || yyextra->guardName==yytext)
1159 yyextra->guardExpr+=
" 1L ";
1161 yyextra->guardExpr+=
" 0L ";
1162 yyextra->lastGuardName=yytext;
1164<DefinedExpr1,DefinedExpr2>\n {
1165 yyextra->yyLineNr++;
1167 BEGIN(SkipCPPBlock);
1172<DefinedExpr1,DefinedExpr2>.
1173<SkipCPPBlock>^{B}*"#" { BEGIN(SkipCommand); }
1174<SkipCPPBlock>^{Bopt}/[^#] { BEGIN(SkipLine); }
1175<SkipCPPBlock>\n { yyextra->yyLineNr++;
outputChar(yyscanner,
'\n'); }
1177<SkipCommand>"if"(("n")?("def"))?/[ \t(!] {
1182<SkipCommand>"else" {
1191<SkipCommand>("elif"|"else"{B}*"if")/[ \t(!] {
1192 if (yyextra->ifcount==0)
1196 yyextra->guardExpr.clear();
1197 yyextra->lastGuardName.clear();
1202 BEGIN(SkipCPPBlock);
1206<SkipCommand>"endif" {
1207 yyextra->expectGuard =
FALSE;
1209 if (--yyextra->ifcount<0)
1217 yyextra->yyLineNr++;
1218 BEGIN(SkipCPPBlock);
1225<SkipLine>{CHARLIT} { }
1230<SkipString>{CPPC}/[^\n]* {
1232<SkipLine,SkipCommand,SkipCPPBlock>{CPPC}[^\n]* {
1233 yyextra->lastCPPContext=YY_START;
1234 BEGIN(RemoveCPPComment);
1236<SkipString>{CCS}/[^\n]* {
1238<SkipLine,SkipCommand,SkipCPPBlock>{CCS}/[^\n]* {
1239 yyextra->lastCContext=YY_START;
1240 BEGIN(RemoveCComment);
1244 yyextra->yyLineNr++;
1245 BEGIN(SkipCPPBlock);
1247<SkipString>[^"\\\n]+ { }
1253<IncludeID>{ID}{Bopt}/"(" {
1254 yyextra->nospaces=
TRUE;
1255 yyextra->roundCount=0;
1256 yyextra->defArgsStr=yytext;
1257 yyextra->findDefArgContext = IncludeID;
1258 BEGIN(FindDefineArgs);
1261 yyextra->nospaces=
TRUE;
1265<Include>[^\">\n]+[\">] {
1266 yyextra->incName+=yytext;
1267 if (yyextra->isImported)
1277<EndImport>{ENDIMPORTopt}/\n {
1281<EndImport>\\[\r]?"\n" {
1283 yyextra->yyLineNr++;
1287<DefName>{ID}/("\\\n")*"(" {
1289 yyextra->argMap.clear();
1290 yyextra->defArgs = 0;
1291 yyextra->defArgsStr.clear();
1292 yyextra->defText.clear();
1293 yyextra->defLitText.clear();
1294 yyextra->defName = yytext;
1295 yyextra->defVarArgs =
FALSE;
1296 yyextra->defExtraSpacing.clear();
1297 yyextra->defContinue =
false;
1300<DefName>{ID}{B}+"1"/[ \r\t\n] {
1302 yyextra->argMap.clear();
1303 yyextra->defArgs = -1;
1304 yyextra->defArgsStr.clear();
1306 yyextra->defVarArgs =
FALSE;
1309 if (yyextra->curlyCount>0 || yyextra->defName!=yyextra->lastGuardName || !yyextra->expectGuard)
1311 QCString def = yyextra->potentialDefine +
1314 outputSpaces(yyscanner,yytext+yyextra->defName.length());
1315 yyextra->quoteArg=
FALSE;
1316 yyextra->insideComment=
FALSE;
1317 yyextra->lastGuardName.clear();
1318 yyextra->defText=
"1";
1319 yyextra->defLitText=
"1";
1325 yyextra->defText.clear();
1326 yyextra->defLitText.clear();
1329 yyextra->expectGuard=
FALSE;
QCString stripWhiteSpace() const
returns a copy of this string with leading and trailing whitespace removed
1331<DefName,CmakeDefName01>{ID}/{B}*"\n" {
1332 yyextra->argMap.clear();
1333 yyextra->defArgs = -1;
1334 yyextra->defName = yytext;
1335 yyextra->defArgsStr.clear();
1336 yyextra->defText.clear();
1337 yyextra->defLitText.clear();
1338 yyextra->defVarArgs =
FALSE;
1341 if (yyextra->curlyCount>0 || yyextra->defName!=yyextra->lastGuardName || !yyextra->expectGuard)
1343 QCString def = yyextra->potentialDefine + yyextra->defName;
1345 yyextra->quoteArg=
FALSE;
1346 yyextra->insideComment=
FALSE;
1347 if (YY_START == CmakeDefName01) yyextra->defText =
"0";
1348 else if (yyextra->insideCS) yyextra->defText=
"1";
1354 yyextra->guardName = yytext;
1355 yyextra->lastGuardName.clear();
1358 yyextra->expectGuard=
FALSE;
1362 yyextra->argMap.clear();
1363 yyextra->defArgs = -1;
1364 yyextra->defArgsStr.clear();
1365 yyextra->defText.clear();
1366 yyextra->defLitText.clear();
1367 yyextra->defName = yytext;
1368 yyextra->defVarArgs =
FALSE;
1369 QCString def = yyextra->potentialDefine +
1371 yyextra->defArgsStr ;
1373 yyextra->quoteArg=
FALSE;
1374 yyextra->insideComment=
FALSE;
1378 yyextra->defExtraSpacing+=
"\n";
1379 yyextra->defContinue =
true;
1380 yyextra->yyLineNr++;
1382<DefineArg>{B}* { yyextra->defExtraSpacing+=yytext; }
1383<DefineArg>","{B}* { yyextra->defArgsStr+=yytext; }
1384<DefineArg>"("{B}* { yyextra->defArgsStr+=yytext; }
1385<DefineArg>{B}*")"{B}* {
1387 yyextra->defArgsStr+=yytext;
1388 QCString def = yyextra->potentialDefine +
1390 yyextra->defArgsStr +
1391 yyextra->defExtraSpacing ;
1393 yyextra->quoteArg=
FALSE;
1394 yyextra->insideComment=
FALSE;
1398 yyextra->defVarArgs =
TRUE;
1399 yyextra->defArgsStr+=yytext;
1400 yyextra->argMap.emplace(std::string(
"__VA_ARGS__"),yyextra->defArgs);
1403<DefineArg>{ID}{B}*("..."?) {
1406 yyextra->defVarArgs = yytext[yyleng-1]==
'.';
1407 if (yyextra->defVarArgs)
1412 yyextra->defArgsStr+=yytext;
1413 yyextra->argMap.emplace(
toStdString(argName),yyextra->defArgs);
std::string toStdString(const QCString &s)
1429<DefineText>{CCS}[!*]? {
1430 yyextra->defText+=yytext;
1431 yyextra->defLitText+=yytext;
1432 yyextra->lastCContext=YY_START;
1433 yyextra->commentCount=1;
1434 BEGIN(CopyCComment);
1436<DefineText>{CPPC}[!/]? {
1438 yyextra->lastCPPContext=YY_START;
1439 yyextra->defLitText+=
' ';
1440 BEGIN(SkipCPPComment);
1442<SkipCComment>[/]?{CCE} {
1443 if (yytext[0]==
'/')
outputChar(yyscanner,
'/');
1445 if (--yyextra->commentCount<=0)
1447 if (yyextra->lastCContext==Start)
1451 YY_CURRENT_BUFFER->yy_at_bol=1;
1453 BEGIN(yyextra->lastCContext);
1456<SkipCComment>{CPPC}("/")* {
1459<SkipCComment>{CCS} {
1463<SkipCond>[\\@][\\@] { }
1464<SkipCond>^({B}*"*"+)?{B}{0,3}"~~~"[~]* {
1466 if (!markdownSupport || !yyextra->isSpecialComment)
1472 yyextra->fenceChar=
'~';
1474 BEGIN(SkipCondVerbatim);
1477<SkipCond>^({B}*"*"+)?{B}{0,3}"```"[`]* {
1479 if (!markdownSupport || !yyextra->isSpecialComment)
1485 yyextra->fenceChar=
'`';
1487 BEGIN(SkipCondVerbatim);
1490<SkipCComment>^({B}*"*"+)?{B}{0,3}"~~~"[~]* {
1492 if (!markdownSupport || !yyextra->isSpecialComment)
1499 yyextra->fenceChar=
'~';
1501 BEGIN(SkipVerbatim);
1504<SkipCComment>^({B}*"*"+)?{B}{0,3}"```"[`]* {
1506 if (!markdownSupport || !yyextra->isSpecialComment)
1513 yyextra->fenceChar=
'`';
1515 BEGIN(SkipVerbatim);
1518<SkipCComment>[\\@]{VERBATIM_LINE} |
1519<SkipCComment>[\\@]{LITERAL_BLOCK} {
1523<SkipCComment>{VERBATIM_LINE}.*/\n {
1526<SkipCComment>{LITERAL_BLOCK} {
1530 BEGIN(SkipVerbatim);
1532<SkipCond>[\\@][\\@]"cond"[ \t]+ {}
1533<SkipCond>[\\@]"cond"/\n |
1534<SkipCond>[\\@]"cond"[ \t]+ {
1538<SkipCComment>"{"[ \t]*"@code"/[ \t\n] {
1540 yyextra->javaBlock=1;
1541 BEGIN(JavaDocVerbatimCode);
1543<SkipCComment>"{"[ \t]*"@literal"/[ \t\n] {
1545 yyextra->javaBlock=1;
1546 BEGIN(JavaDocVerbatimCode);
1548<SkipCComment,SkipCPPComment>[\\@][\\@]"cond"[ \t\n]+ {
1551<SkipCPPComment>[\\@]"cond"[ \t]+ {
1552 yyextra->ccomment=
TRUE;
1553 yyextra->condCtx=YY_START;
1556<SkipCComment>[\\@]"cond"[ \t]+ {
1557 yyextra->ccomment=
FALSE;
1558 yyextra->condCtx=YY_START;
1561<CondLineC,CondLineCpp>[!()&| \ta-z_A-Z0-9\x80-\xFF.\-]+ {
1565 if (YY_START==CondLineC)
1569 yyextra->ccomment=
TRUE;
1573 yyextra->ccomment=
FALSE;
1579 BEGIN(yyextra->condCtx);
1582<CondLineC,CondLineCpp>. {
1587 if (YY_START==CondLineC)
1591 yyextra->ccomment=
TRUE;
1595 yyextra->ccomment=
FALSE;
1601 BEGIN(yyextra->condCtx);
1604<SkipCComment,SkipCPPComment>[\\@]"cond"{WSopt}/\n {
1605 if (YY_START==SkipCComment)
1607 yyextra->ccomment=
TRUE;
1613 yyextra->ccomment=
FALSE;
1615 yyextra->condCtx=YY_START;
1619<SkipCond>\n { yyextra->yyLineNr++;
outputChar(yyscanner,
'\n'); }
1620<SkipCond>{VERBATIM_LINE}.*/\n { }
1621<SkipCond>{LITERAL_BLOCK} {
1623 yyextra->yyLineNr+=numNLs;
1624 for (
int i = 0; i < numNLs; i++)
outputChar(yyscanner,
'\n');
1626 BEGIN(SkipCondVerbatim);
1630<SkipCond>[^\/\!*\\@\n]+ { }
1631<SkipCond>{CPPC}[/!] { yyextra->ccomment=
FALSE; }
1632<SkipCond>{CCS}[*!] { yyextra->ccomment=
TRUE; }
1633<SkipCond,SkipCComment,SkipCPPComment>[\\@][\\@]"endcond"/[^a-z_A-Z0-9\x80-\xFF] {
1639<SkipCond>[\\@]"endcond"/[^a-z_A-Z0-9\x80-\xFF] {
1640 bool oldSkip = yyextra->skip;
1642 if (oldSkip && !yyextra->skip)
1644 if (yyextra->ccomment)
1648 BEGIN(yyextra->condCtx);
1651<SkipCComment,SkipCPPComment>[\\@]"endcond"/[^a-z_A-Z0-9\x80-\xFF] {
1652 bool oldSkip = yyextra->skip;
1654 if (oldSkip && !yyextra->skip)
1656 BEGIN(yyextra->condCtx);
1659<SkipCondVerbatim>{LITERAL_BLOCK_END} {
1660 if (yytext[1]==
'f' && yyextra->blockName==&yytext[2])
1664 else if (&yytext[4]==yyextra->blockName)
1669<SkipVerbatim>{LITERAL_BLOCK_END} {
1671 if (yytext[1]==
'f' && yyextra->blockName==&yytext[2])
1673 BEGIN(SkipCComment);
1675 else if (&yytext[4]==yyextra->blockName)
1677 BEGIN(SkipCComment);
1680<SkipCondVerbatim>^({B}*"*"+)?{B}{0,3}"~~~"[~]* {
1681 if (yyextra->fenceSize==
getFenceSize(yytext,yyleng) && yyextra->fenceChar==
'~')
1686<SkipCondVerbatim>^({B}*"*"+)?{B}{0,3}"```"[`]* {
1687 if (yyextra->fenceSize==
getFenceSize(yytext,yyleng) && yyextra->fenceChar==
'`')
1692<SkipVerbatim>^({B}*"*"+)?{B}{0,3}"~~~"[~]* {
1694 if (yyextra->fenceSize==
getFenceSize(yytext,yyleng) && yyextra->fenceChar==
'~')
1696 BEGIN(SkipCComment);
1699<SkipVerbatim>^({B}*"*"+)?{B}{0,3}"```"[`]* {
1701 if (yyextra->fenceSize==
getFenceSize(yytext,yyleng) && yyextra->fenceChar==
'`')
1703 BEGIN(SkipCComment);
1706<SkipCondVerbatim>{CCE}|{CCS} { }
1707<SkipVerbatim>{CCE}|{CCS} {
1710<JavaDocVerbatimCode>"{" {
1711 if (yyextra->javaBlock==0)
1717 yyextra->javaBlock++;
1721<JavaDocVerbatimCode>"}" {
1722 if (yyextra->javaBlock==0)
1728 yyextra->javaBlock--;
1729 if (yyextra->javaBlock==0)
1732 BEGIN(SkipCComment);
1740<JavaDocVerbatimCode>\n {
1743<JavaDocVerbatimCode>. {
1746<SkipCondVerbatim>[^{*\\@\x06~`\n\/]+ { }
1747<SkipCComment,SkipVerbatim>[^{*\\@\x06~`\n\/]+ {
1750<SkipCComment,SkipVerbatim,SkipCondVerbatim>\n {
1751 yyextra->yyLineNr++;
1754<SkipCondVerbatim>. { }
1755<SkipCComment,SkipVerbatim>. {
1758<CopyCComment>[^*a-z_A-Z\x80-\xFF\n]*[^*a-z_A-Z\x80-\xFF\\\n] {
1759 yyextra->defLitText+=yytext;
1760 yyextra->defText+=
escapeAt(yytext);
1762<CopyCComment>\\[\r]?\n {
1763 yyextra->defLitText+=yytext;
1764 yyextra->defText+=
" ";
1765 yyextra->yyLineNr++;
1766 yyextra->yyMLines++;
1768<CopyCComment>{CCE} {
1769 yyextra->defLitText+=yytext;
1770 yyextra->defText+=yytext;
1771 BEGIN(yyextra->lastCContext);
1774 yyextra->yyLineNr++;
1775 yyextra->defLitText+=yytext;
1776 yyextra->defText+=
' ';
1778<RemoveCComment>{CCE}{B}*"#" {
1779 if (yyextra->lastCContext==SkipCPPBlock)
1788<RemoveCComment>{CCE} { BEGIN(yyextra->lastCContext); }
1789<RemoveCComment>{CPPC}
1790<RemoveCComment>{CCS}
1791<RemoveCComment>[^*\x06\n]+
1792<RemoveCComment>\n { yyextra->yyLineNr++;
outputChar(yyscanner,
'\n'); }
1794<SkipCPPComment>[^\n\/\\@]+ {
1797<SkipCPPComment,RemoveCPPComment>\n {
1799 BEGIN(yyextra->lastCPPContext);
1801<SkipCPPComment>{CCS} {
1804<SkipCPPComment>{CPPC} {
1807<SkipCPPComment>[^\x06\@\\\n]+ {
1813<RemoveCPPComment>{CCS}
1814<RemoveCPPComment>{CPPC}
1815<RemoveCPPComment>[^\x06\n]+
1817<DefineText>"#"/{IDSTART} {
1819 yyextra->quoteArg=
TRUE;
1820 yyextra->idStart=
true;
1821 yyextra->defLitText+=yytext;
1823<DefineText,CopyCComment>{ID} {
1824 yyextra->defLitText+=yytext;
1825 if (YY_START == DefineText)
outputSpaces(yyscanner,yytext);
1826 if (yyextra->quoteArg)
1828 yyextra->defText+=
"\"";
1830 if (yyextra->defArgs>0)
1832 auto it = yyextra->argMap.find(yytext);
1833 if (it!=yyextra->argMap.end())
1836 yyextra->defText+=
'@';
1841 if (yyextra->idStart)
1843 warn(yyextra->fileName,yyextra->yyLineNr,
1844 "'#' is not followed by a macro parameter '{}': '{}'",
1845 yyextra->defName,yyextra->defLitText.stripWhiteSpace());
1847 yyextra->defText+=yytext;
1852 yyextra->defText+=yytext;
1854 if (yyextra->quoteArg)
1856 yyextra->defText+=
"\"";
1858 yyextra->quoteArg=
FALSE;
1859 yyextra->idStart=
false;
QCString & setNum(short n)
#define warn(file, line, fmt,...)
1862 yyextra->defLitText+=yytext;
1863 yyextra->defText+=yytext;
1865<DefineText>\\[\r]?\n {
1866 yyextra->defLitText+=yytext;
1869 yyextra->defText +=
' ';
1870 yyextra->yyLineNr++;
1871 yyextra->yyMLines++;
1875 yyextra->defText = yyextra->defText.stripWhiteSpace();
1876 if (yyextra->defText.startsWith(
"##"))
1878 warn(yyextra->fileName,yyextra->yyLineNr,
1879 "'##' cannot occur at the beginning of a macro definition '{}': '{}'",
1880 yyextra->defName,yyextra->defLitText.stripWhiteSpace());
1882 else if (yyextra->defText.endsWith(
"##"))
1884 warn(yyextra->fileName,yyextra->yyLineNr,
1885 "'##' cannot occur at the end of a macro definition '{}': '{}'",
1886 yyextra->defName,yyextra->defLitText.stripWhiteSpace());
1888 else if (yyextra->defText.endsWith(
"#"))
1890 warn(yyextra->fileName,yyextra->yyLineNr,
1891 "expected formal parameter after # in macro definition '{}': '{}'",
1892 yyextra->defName,yyextra->defLitText.stripWhiteSpace());
1897 yyextra->defLitText=yyextra->defLitText.left(yyextra->defLitText.length()-
comment.length()-1);
1900 yyextra->defLitText+=yytext;
1903 if (yyextra->includeStack.empty() || yyextra->curlyCount>0)
1907 def=
isDefined(yyscanner,yyextra->defName);
1921 def->
name = yyextra->defName;
1923 def->
nargs = yyextra->defArgs;
1925 def->
lineNr = yyextra->yyLineNr-yyextra->yyMLines;
1930 if (def->
fileName != yyextra->fileName && !yyextra->expandOnlyPredef)
addDefine(yyscanner);
1934 yyextra->argMap.clear();
1935 yyextra->yyLineNr++;
1937 yyextra->lastGuardName.clear();
1941 yyextra->defText +=
' ';
1942 yyextra->defLitText+=yytext;
1945 yyextra->defText +=
"##";
1946 yyextra->defLitText+=yytext;
1949 yyextra->defText +=
"@@";
1950 yyextra->defLitText+=yytext;
1954 yyextra->defText += *yytext;
1955 yyextra->defLitText+=yytext;
1956 if (!yyextra->insideComment)
1958 BEGIN(SkipDoubleQuote);
1963 yyextra->defText += *yytext;
1964 yyextra->defLitText+=yytext;
1965 if (!yyextra->insideComment)
1967 BEGIN(SkipSingleQuote);
1970<SkipDoubleQuote>{CPPC}[/]? {
outputSpaces(yyscanner,yytext);
1971 yyextra->defText += yytext;
1972 yyextra->defLitText+=yytext;
1974<SkipDoubleQuote>{CCS}[*]? {
outputSpaces(yyscanner,yytext);
1975 yyextra->defText += yytext;
1976 yyextra->defLitText+=yytext;
1978<SkipDoubleQuote>\" {
1980 yyextra->defText += *yytext;
1981 yyextra->defLitText+=yytext;
1984<SkipSingleQuote,SkipDoubleQuote>\\. {
1986 yyextra->defText += yytext;
1987 yyextra->defLitText+=yytext;
1989<SkipSingleQuote>\' {
1991 yyextra->defText += *yytext;
1992 yyextra->defLitText+=yytext;
1995<SkipDoubleQuote,SkipSingleQuote>. {
outputSpace(yyscanner,yytext[0]);
1996 yyextra->defText += *yytext;
1997 yyextra->defLitText += *yytext;
2000 yyextra->defText += *yytext;
2001 yyextra->defLitText += *yytext;
2004 TRACE(
"End of include file");
2006 if (yyextra->includeStack.empty())
2008 TRACE(
"Terminating scanner");
2013 QCString toFileName = yyextra->fileName;
2014 const std::unique_ptr<FileState> &fs=yyextra->includeStack.back();
2016 YY_BUFFER_STATE oldBuf = YY_CURRENT_BUFFER;
2017 yy_switch_to_buffer( fs->bufState, yyscanner );
2018 yy_delete_buffer( oldBuf, yyscanner );
2019 yyextra->yyLineNr = fs->lineNr;
2021 yyextra->inputBuf = fs->oldFileBuf;
2022 yyextra->inputBufPos = fs->oldFileBufPos;
2023 yyextra->curlyCount = fs->curlyCount;
2025 TRACE(
"switching to {}",yyextra->fileName);
2030 lineStr.sprintf(
"# %d \"%s\" 2",yyextra->yyLineNr,
qPrint(yyextra->fileName));
2033 yyextra->includeStack.pop_back();
2056 for (
const auto &kv : yyextra->localDefines)
2058 auto pair = yyextra->contextDefines.insert(kv);
2061 yyextra->contextDefines.erase(pair.first);
2062 yyextra->contextDefines.insert(kv);
2065 yyextra->localDefines.clear();
static bool isFlagSet(const DebugMask mask)
static void print(DebugMask mask, int prio, fmt::format_string< Args... > fmt, Args &&... args)
const std::string & str() const
const char * qPrint(const char *s)
2070 if (YY_START==SkipVerbatim || YY_START == SkipCondVerbatim || YY_START==SkipCond || YY_START==IDLquote || YY_START == PragmaOnce)
2077 yyextra->lastCContext=YY_START;
2078 yyextra->commentCount=1;
2081 yyextra->isSpecialComment =
true;
2082 yyextra->lastGuardName.clear();
2086 yyextra->isSpecialComment =
false;
2088 BEGIN(SkipCComment);
2096 else if (YY_START==RulesRoundDouble)
2103 yyextra->lastCPPContext=YY_START;
2106 yyextra->isSpecialComment =
true;
2107 yyextra->lastGuardName.clear();
2111 yyextra->isSpecialComment =
false;
2113 BEGIN(SkipCPPComment);
2118 yyextra->yyLineNr++;
2121 yyextra->expectGuard =
FALSE;
2131 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
2132 int bytesInBuf =
static_cast<int>(state->inputBuf->size())-state->inputBufPos;
2133 int bytesToCopy = std::min(max_size,bytesInBuf);
2134 memcpy(buf,state->inputBuf->data()+state->inputBufPos,bytesToCopy);
2135 state->inputBufPos+=bytesToCopy;
2141 yy_size_t fenceSize = 0;
2142 for (
size_t i = 0; i < leng; i++)
2144 if (txt[i] !=
' ' && txt[i] !=
'*' && txt[i] !=
'\t')
break;
2147 return leng-fenceSize;
2152 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
2157 if (state->yyFileDef==
nullptr)
2163 if (state->yyFileDef && state->yyFileDef->isReference()) state->yyFileDef=
nullptr;
2168 state->isSource = section.isHeader() || section.isSource();
2173 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
2174 state->levelGuard.push(
false);
2180 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
2182 if (!state->levelGuard.empty())
2184 state->levelGuard.pop();
2188 warn(state->fileName,state->yyLineNr,
"More #endif's than #if's found.");
2194 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
2195 if (state->levelGuard.empty())
2197 warn(state->fileName,state->yyLineNr,
"Found an #else without a preceding #if.");
2202 return state->levelGuard.top();
2208 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
2209 state->levelGuard.top()=value;
2215 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
2216 alreadyProcessed =
FALSE;
2217 std::unique_ptr<FileState> fs;
2228 if (state->curlyCount==0)
2233 alreadyProcessed =
TRUE;
2240 alreadyProcessed = std::any_of(
2241 state->includeStack.begin(),
2242 state->includeStack.end(),
2243 [absName](
const std::unique_ptr<FileState> &lfs)
2244 { return lfs->fileName==absName; }
2247 if (alreadyProcessed)
2254 fs = std::make_unique<FileState>();
2262 fs->oldFileBuf = state->inputBuf;
2263 fs->oldFileBufPos = state->inputBufPos;
2271 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
2282 else if (alreadyProcessed)
2287 if (localInclude && !state->fileName.isEmpty())
2289 FileInfo fi(state->fileName.str());
2300 else if (alreadyProcessed)
2306 if (state->pathList.empty())
2310 for (
auto path : state->pathList)
2312 std::string absName = (path+
"/"+fileName).str();
2322 else if (alreadyProcessed)
2355 if (i>=0 && s[i]==
'*')
2358 while (i>0 && !(s[i-1]==
'/' && s[i]==
'*')) i--;
2365 return ((s[i+1]==
'*' || s[i+1]==
'!') && s[i+2]==
'<') ? &s[i-1] :
"";
2397 bool inString=
FALSE;
2402 if (!inString && !inChar)
2404 while (i<s.
length() && !inString && !inChar)
2425 while (i<s.
length() && inChar)
2446 while (i<s.
length() && inString)
2475 std::string e = expr.
str();
2476 static const reg::Ex r(R
"(\s*##\s*)");
2485 const auto &match = *it;
2486 size_t n = match.position();
2487 size_t l = match.length();
2489 if (n+l+1<e.length() && e[
static_cast<int>(n+l)]==
'@' && expr[
static_cast<int>(n+l+1)]==
'-')
2496 e=e.substr(0,n)+e.substr(n+l);
2497 int k=
static_cast<int>(n)-1;
2498 while (k>=0 &&
isId(e[k])) k--;
2499 if (k>0 && e[k]==
'-' && e[k-1]==
'@')
2502 e=e.substr(0,k-1)+e.substr(k+1);
2520 struct yyguts_t * yyg = (
struct yyguts_t*)yyscanner;
2528 while ((cc=
getNextChar(yyscanner,expr,rest,pos))!=EOF && cc!=0)
2530 if (cc==
'\\') arg+=(char)cc,cc=
getNextChar(yyscanner,expr,rest,pos);
2531 else if (cc==
term)
return;
2537 int &cc, uint32_t &j,
int &len)
2539 bool changed =
false;
2544 while ((cc=
getCurrentChar(yyscanner,expr,rest,j))!=EOF && cc!=
'\n' && isspace(cc))
2552 int prevChar =
'\0';
2554 if ((cc=
getCurrentChar(yyscanner,expr,rest,j))!=EOF && cc ==
'*')
2556 while ((cc=
getNextChar(yyscanner,expr,rest,j))!=EOF && cc!=0)
2558 if (cc ==
'/' && prevChar ==
'*')
break;
2561 if (cc != EOF) changed =
true;
2594 std::map<std::string,std::string> argTable;
2602 while ((cc=
getNextChar(yyscanner,expr,rest,j))!=EOF && cc!=0)
2610 while (!done && (argCount<def->nargs || def->
varArgs) &&
2611 ((cc=
getNextChar(yyscanner,expr,rest,j))!=EOF && cc!=0)
2620 while ((cc=
getNextChar(yyscanner,expr,rest,j))!=EOF && cc!=0)
2624 if (c==
'\'' || c==
'\"')
2644 else if (c==
')' || c==
',')
2654 argKey.
sprintf(
"@%d",argCount++);
2676 if ((cc=
getNextChar(yyscanner,expr,rest,j))==EOF || cc==0)
break;
2693 if ((cc=
getNextChar(yyscanner,expr,rest,j))==EOF || cc==0)
break;
2701 char prevChar =
'\0';
2705 while ((cc=
getNextChar(yyscanner,expr,rest,j))!=EOF && cc!=0)
2709 if (c ==
'/' && prevChar ==
'*')
break;
2722 if (argCount==def->
nargs ||
2731 bool inString=
FALSE;
2741 else if (d.
at(k+1)==
'-')
2752 if (l>=0 && d.
at(l)==
'"') l--;
2753 while (l>=0 && d.
at(l)==
' ') l--;
2754 if (l>0 && d.
at(l)==
'#' && d.
at(l-1)==
'#') hash=
TRUE;
2757 while (k<d.
length() && d.
at(k)>=
'0' && d.
at(k)<=
'9') key+=d.
at(k++);
2762 if (l<(
int)d.
length() && d.
at(l)==
'"') l++;
2763 while (l<(
int)d.
length() && d.
at(l)==
' ') l++;
2764 if (l<(
int)d.
length()-1 && d.
at(l)==
'#' && d.
at(l+1)==
'#') hash=
TRUE;
2767 auto it = argTable.find(key.
str());
2768 if (it!=argTable.end())
2770 QCString substArg = it->second.c_str();
2788 if (hash && substArg.
isEmpty())
2799 if (!inString && d.
at(k)==
'\"')
2803 else if (k>2 && inString && d.
at(k)==
'\"' && (d.
at(k-1)!=
'\\' || d.
at(k-2)==
'\\'))
2827 while (p<(
int)expr.
length())
2829 char c=expr.
at(p++);
2834 else if (isalpha(c) || c==
'_')
2844 if (p<(
int)expr.
length()) c=expr.
at(p);
2845 while (p<(
int)expr.
length() && (c!=
'"' || (pc==
'\\' && ppc!=
'\\')))
2853 if (p<(
int)expr.
length()) ++p;
2859 if (p<(
int)expr.
length())
2865 while (p<(
int)expr.
length() && !(pc==
'*' && c==
'/'))
2878#define MAX_EXPANSION_DEPTH 50
2882 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
2883 if (!state->nospaces)
2886 char ccPrev = pos==0 || (int)expr.
length()<pos ? state->prevChar : expr.
at(pos-1);
2887 QCString leftSpace = ccPrev!=
':' && ccPrev!=
' ' ?
" " :
"";
2892 uint32_t j=(uint32_t)resultExpr.
length();
2893 while ((ccNext=
getNextChar(yyscanner,resultExpr,
nullptr,j))!=EOF && ccNext==
' ') { }
2894 if (ccNext != EOF)
unputChar(yyscanner,resultExpr,
nullptr,j,(
char)ccNext);
2898 ccNext=restExpr.
at(0);
2901 QCString rightSpace = ccNext!=
':' && ccNext!=
' ' ?
" " :
"";
2904 resultExpr=leftSpace+resultExpr+rightSpace;
2914 struct yyguts_t * yyg = (
struct yyguts_t*)yyscanner;
2915 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
2922 if (state->expanded.find(expr.
str())!=state->expanded.end() &&
2930 state->expanded.insert(expr.
str());
2934 bool definedTest=
FALSE;
2935 int i=pos, l=0, p=0, len=0;
2940 bool replaced=
FALSE;
2941 macroName=expr.
mid(p,l);
2943 if (p<2 || !(expr.
at(p-2)==
'@' && expr.
at(p-1)==
'-'))
2945 if (state->expandedDict.find(macroName.
str())==state->expandedDict.end())
2950 if (yyextra->expandOnlyPredef && def && !def->
isPredefined) def=
nullptr;
2951 if (macroName==
"defined")
2956 else if (definedTest)
2958 if (def) expMacro =
" 1 ";
else expMacro =
" 0 ";
2963 else if (def && def->
nargs==-1)
2972 else if (def && def->
nargs>=0)
2989 bool expanded=
false;
2992 state->expandedDict.emplace(
toStdString(macroName),def);
2994 state->expandedDict.erase(
toStdString(macroName));
3003 expr=expr.
left(p)+resultExpr+restExpr;
3059 if (inputStr==
nullptr)
return inputStr;
3060 char term = *inputStr;
3061 if (
term!=
'\'' &&
term!=
'"')
return inputStr;
3066 while ((c=*inputStr))
3095 static const std::vector<std::string> signs = {
"signed",
"unsigned" };
3096 struct TypeInfo { std::string name;
size_t size; };
3097 static const std::vector<TypeInfo> types = {
3098 {
"short int",
sizeof(
short int) },
3099 {
"long long int",
sizeof(
long long int) },
3100 {
"long int",
sizeof(
long int) },
3101 {
"long long",
sizeof(
long long) },
3102 {
"long double",
sizeof(
long double) },
3103 {
"int",
sizeof(int) },
3104 {
"short",
sizeof(short) },
3105 {
"bool",
sizeof(bool) },
3106 {
"long",
sizeof(long) },
3107 {
"char",
sizeof(char) },
3108 {
"float",
sizeof(float) },
3109 {
"double",
sizeof(double) },
3115 auto process_cast_or_sizeof = [](
const char *p) -> std::pair<const char *,size_t>
3118 while (*q==
' ' || *q==
'\t') q++;
3120 size_t size =
sizeof(int);
3121 for (
const auto &sgn : signs)
3123 if (
qstrncmp(q,sgn.c_str(),sgn.length())==0) { q+=sgn.length();
found=
true; }
3125 if (!
found || *q==
' ' || *q==
'\t' || *q==
')')
3127 while (*q==
' ' || *q==
'\t') q++;
3128 for (
const auto &t : types)
3130 if (
qstrncmp(q,t.name.c_str(),t.name.length())==0)
3132 q += t.name.length();
3137 while (*q==
' ' || *q==
'\t') q++;
3138 if (*q==
')')
return std::make_pair(++q,size);
3140 return std::make_pair(
nullptr,0);
3145 const char *p=s.
data();
3155 const char *q = process_cast_or_sizeof(p+1).first;
3165 const char *q = p+6;
3166 while (*q==
' ' || *q==
'\t') q++;
3169 auto r = process_cast_or_sizeof(q+1);
3186 else if (*(p+1)==
'E')
3192 else if (isdigit(c))
3202 else if (c==
'd' && !inNum)
3213 while ((c=*p) &&
isId(c)) p++;
3216 else if ((isalpha(c) || c==
'_') && !inNum)
3220 while ((c=*p) &&
isId(c)) p++;
3221 while ((c=*p) && isspace((uint8_t)c)) p++;
3228 if (c==
'(') count++;
3232 if (count==0)
break;
3240 while (*p && !(pc==
'*' && c==
'/'))
3257 while (*p && !(pc==
'*' && c==
'/'))
3274 char lc=(char)tolower(c);
3291 const char *p=s.
data();
3316 while (*p && !(pc==
'*' && c==
'/'))
3318 if (*p==
'@' && *(p+1)==
'@')
3325 if (*p) result+=c,p++;
3352 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
3356 state->expanded.clear();
3362 return state->constExpParser.parse(state->fileName.data(),state->yyLineNr,e.
str(),ee.
str());
3371 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
3372 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
3373 state->prevChar = yyscanner->yytext_r > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ? *(yyscanner->yytext_r-1) : 0;
3375 state->expanded.
clear();
3385 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
3387 def.
name = state->defName;
3389 def.
nargs = state->defArgs;
3391 def.
fileDef = state->yyFileDef;
3392 def.
lineNr = state->yyLineNr-state->yyMLines;
3394 def.
varArgs = state->defVarArgs;
3404 auto it = state->localDefines.find(def.
name.
str());
3405 if (it!=state->localDefines.end())
3407 state->localDefines.erase(it);
3409 state->localDefines.emplace(def.
name.
str(),def);
3414 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
3415 if (state->skip)
return;
3420 define.
lineNr = state->yyLineNr - state->yyMLines;
3422 define.
name = state->defName;
3423 define.
args = state->defArgsStr;
3424 define.
fileDef = state->inputFileDef;
3426 QCString litText = state->defLitText;
3427 int l=litText.
find(
'\n');
3437 const char *p=litText.
data()+k;
3439 while ((c=*p++) && (c==
' ' || c==
'\t')) k++;
3443 if (litTextStripped.
contains(
'\n')>=1)
3452 state->macroDefinitions.push_back(define);
3458 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
3459 if (state->includeStack.empty() || state->curlyCount>0) (*state->outputBuf)+=c;
3464 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
3465 if (state->includeStack.empty() || state->curlyCount>0) (*state->outputBuf)+=std::string_view(a,len);
3470 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
3471 if (state->includeStack.empty() || state->curlyCount>0) (*state->outputBuf)+=a.
str();
3493 struct yyguts_t * yyg = (
struct yyguts_t*)yyscanner;
3494 if (!yyextra->defContinue)
return;
3495 for (
int i=0; i< (int)yyleng; i++)
3497 if (yytext[i] ==
'\t')
3498 yyextra->defExtraSpacing+=
'\t';
3500 yyextra->defExtraSpacing+=
' ';
3506 struct yyguts_t * yyg = (
struct yyguts_t*)yyscanner;
3507 yyextra->fenceSize=0;
3509 if (yytext[1]==
'f' && ((c=yytext[2])==
'[' || c==
'{' || c==
'(' || c==
'$'))
3513 case '[': yyextra->blockName=
"]";
break;
3514 case '{': yyextra->blockName=
"}";
break;
3515 case '(': yyextra->blockName=
")";
break;
3516 case '$': yyextra->blockName=
"$";
break;
3519 yyextra->blockName=yyextra->blockName.stripWhiteSpace();
3526 yyextra->blockName=
"uml";
3530 int i = bn.
find(
'{');
3532 yyextra->blockName=bn;
3540 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
3545 (inc.
at(i)==
' ' || inc.
at(i)==
'"' || inc.
at(i)==
'<')
3550 bool localInclude = s>0 && inc.
at(s-1)==
'"';
3553 while (i<inc.
length() && inc.
at(i)!=
'"' && inc.
at(i)!=
'>') i++;
3555 if (s<inc.
length() && i>s)
3565 QCString oldFileName = state->fileName;
3566 FileDef *oldFileDef = state->yyFileDef;
3567 int oldLineNr = state->yyLineNr;
3573 std::unique_ptr<FileState> fs;
3574 bool alreadyProcessed =
FALSE;
3576 fs=
findFile(yyscanner,absIncFileName,localInclude,alreadyProcessed);
3587 for (i=0;i<state->includeStack.size();i++)
3594 if (state->includeStack.empty() && oldFileDef)
3596 PreIncludeInfo *ii = state->includeRelations.find(absIncFileName);
3601 state->includeRelations.add(
3604 ambig ?
nullptr : incFd,
3612 struct yyguts_t * yyg = (
struct yyguts_t*)yyscanner;
3613 fs->bufState = YY_CURRENT_BUFFER;
3614 fs->lineNr = oldLineNr;
3615 fs->fileName = oldFileName;
3616 fs->curlyCount = state->curlyCount;
3618 fs->lexRulesPart = state->lexRulesPart;
3619 state->lexRulesPart =
false;
3622 state->includeStack.push_back(std::move(fs));
3632 state->expectGuard=
TRUE;
3633 state->inputBuf = &fs_ptr->
fileBuf;
3634 state->inputBufPos=0;
3635 yy_switch_to_buffer(yy_create_buffer(0,
YY_BUF_SIZE, yyscanner),yyscanner);
3639 if (alreadyProcessed)
3647 if (state->includeStack.empty() && oldFileDef)
3649 PreIncludeInfo *ii = state->includeRelations.find(absIncFileName);
3654 ii = state->includeRelations.add(absIncFileName,
3656 ambig ?
nullptr : incFd,
3666 for (i=0;i<state->includeStack.size();i++)
3670 if (alreadyProcessed)
3680 if (localInclude && !state->includeStack.empty() && state->curlyCount>0 && !alreadyProcessed)
3682 warn(state->fileName,state->yyLineNr,
"include file {} not found, perhaps you forgot to add its directory to INCLUDE_PATH?",incFileName);
3692 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
3695 bool expResult = prs.
parse(state->fileName.data(),state->yyLineNr,sectId.
data());
3696 state->condStack.emplace(std::make_unique<preYY_CondCtx>(state->fileName,state->yyLineNr,sectId,state->skip));
3706 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
3707 if (state->condStack.empty())
3709 warn(state->fileName,state->yyLineNr,
"the \\endcond does not have a corresponding \\cond in this file");
3714 const std::unique_ptr<preYY_CondCtx> &ctx = state->condStack.top();
3715 state->skip=ctx->skip;
3716 state->condStack.pop();
3723 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
3724 while (!state->condStack.empty())
3726 state->condStack.pop();
3737 const char *p=text.
data();
3740 if (c==
'@') result+=
"@@";
else result+=c;
3750 case '=':
return '#';
3751 case '/':
return '\\';
3752 case '\'':
return '^';
3753 case '(':
return '[';
3754 case ')':
return ']';
3755 case '!':
return '|';
3756 case '<':
return '{';
3757 case '>':
return '}';
3758 case '-':
return '~';
3772 return expr.
at(pos++);
3774 else if (rest && !rest->
isEmpty())
3783 int cc=yyinput(yyscanner);
3795 return expr.
at(pos);
3797 else if (rest && !rest->
isEmpty())
3805 int cc=yyinput(yyscanner);
3822 char cs[2];cs[0]=c;cs[1]=
'\0';
3838 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
3841 auto findDefine = [&undef,&name](
DefineMap &map)
3844 auto it = map.find(name.
str());
3857 Define *def = findDefine(state->localDefines);
3858 if (def==
nullptr && !undef)
3860 def = findDefine(state->contextDefines);
3867 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
3871 for (
const auto &ds : predefList)
3873 size_t i_equals=ds.find(
'=');
3874 size_t i_obrace=ds.find(
'(');
3875 size_t i_cbrace=ds.find(
')');
3876 bool nonRecursive = i_equals!=std::string::npos && i_equals>0 && ds[i_equals-1]==
':';
3878 if ((i_obrace==0) || (i_equals==0) || (i_equals==1 && ds[i_equals-1]==
':'))
3883 if (i_obrace<i_equals && i_cbrace<i_equals &&
3884 i_obrace!=std::string::npos && i_cbrace!=std::string::npos &&
3888 static const reg::Ex reId(R
"(\a\w*)");
3889 std::map<std::string,int> argMap;
3890 std::string args = ds.substr(i_obrace+1,i_cbrace-i_obrace-1);
3891 bool hasVarArgs = args.find(
"...")!=std::string::npos;
3897 for (; arg_it!=arg_end; ++arg_it)
3899 argMap.emplace(arg_it->
str(),count++);
3903 argMap.emplace(
"__VA_ARGS__",count++);
3907 std::string definition;
3908 std::string in=ds.substr(i_equals+1);
3914 for (; re_it!=re_end; ++re_it)
3916 const auto &match = *re_it;
3917 size_t pi = match.position();
3918 size_t l = match.length();
3919 if (pi>i) definition+=in.substr(i,pi-i);
3921 auto it = argMap.find(match.str());
3922 if (it!=argMap.end())
3924 int argIndex = it->second;
3926 marker.
sprintf(
" @%d ",argIndex);
3927 definition+=marker.
str();
3931 definition+=match.str();
3935 definition+=in.substr(i);
3938 std::string dname = ds.substr(0,i_obrace);
3947 def.
fileDef = state->yyFileDef;
3950 state->contextDefines.emplace(def.
name.
str(),def);
3956 else if (!ds.empty())
3960 if (i_equals==std::string::npos)
3967 int ine=
static_cast<int>(i_equals) - (nonRecursive ? 1 : 0);
3968 def.
name = ds.substr(0,ine);
3976 def.
fileDef = state->yyFileDef;
3978 state->contextDefines.emplace(def.
name.
str(),def);
3994 YY_EXTRA_TYPE state = preYYget_extra(
p->yyscanner);
4001 preYYlex_init_extra(&
p->state,&
p->yyscanner);
4007 preYYlex_destroy(
p->yyscanner);
4014 YY_EXTRA_TYPE state = preYYget_extra(
p->yyscanner);
4015 struct yyguts_t *yyg = (
struct yyguts_t*)
p->yyscanner;
4028 state->curlyCount=0;
4029 state->lexRulesPart=
false;
4030 state->nospaces=
FALSE;
4031 state->inputBuf=&input;
4032 state->inputBufPos=0;
4033 state->outputBuf=&output;
4034 state->includeStack.clear();
4035 state->expandedDict.clear();
4036 state->contextDefines.clear();
4037 state->pragmaSet.clear();
4038 while (!state->condStack.empty()) state->condStack.pop();
4042 state->inputFileDef = state->yyFileDef;
4047 state->yyLineNr = 1;
4053 state->expectGuard =
guessSection(fileName).isHeader();
4054 state->guardName.clear();
4055 state->lastGuardName.clear();
4056 state->guardExpr.clear();
4058 preYYlex(yyscanner);
4060 while (!state->condStack.empty())
4062 const std::unique_ptr<preYY_CondCtx> &ctx = state->condStack.top();
4064 if (ctx->sectionId!=
" ") sectionInfo.
sprintf(
" with label '%s' ",
qPrint(ctx->sectionId.stripWhiteSpace()));
4065 warn(ctx->fileName,ctx->lineNr,
"Conditional section{}does not have "
4066 "a corresponding \\endcond command within this file.",sectionInfo);
4067 state->condStack.pop();
4076 std::string contents;
4084 bool startOfLine =
true;
4085 size_t content_size = output.size() +
4088 contents.reserve(content_size);
4090 while (pos<output.size())
4095 snprintf(lineNrStr,15,
"%05d ",line++);
4096 contents+=lineNrStr;
4098 contents += output[pos];
4099 startOfLine = output[pos]==
'\n';
4104 if (!contents.empty() && contents[contents.length()-1]!=
'\n')
4109 if (yyextra->contextDefines.size()>0)
4113 for (
auto &kv : yyextra->contextDefines)
4117 for (
auto &kv : yyextra->localDefines)
4131 for (
const auto &inc : state->includeRelations)
4133 auto toKind = [](
bool local,
bool imported) ->
IncludeKind
4149 if (inc->fromFileDef)
4151 inc->fromFileDef->addIncludeDependency(inc->toFileDef,inc->includeName,toKind(inc->local,inc->imported));
4153 if (inc->toFileDef && inc->fromFileDef)
4155 inc->toFileDef->addIncludedByDependency(inc->fromFileDef,inc->fromFileDef->docName(),toKind(inc->local,inc->imported));
Copyright (C) 1997-2015 by Dimitri van Heesch.
bool parse(const QCString &fileName, int lineNr, const QCString &expr)
Copyright (C) 1997-2015 by Dimitri van Heesch.
static StringUnorderedSet expandAsDefinedSet
static FileNameLinkedMap * inputNameLinkedMap
static DefinesPerFileList macroDefinitions
static FileNameLinkedMap * includeNameLinkedMap
Wrapper class for the Entry type.
virtual QCString absFilePath() const =0
Minimal replacement for QFileInfo.
std::string dirPath(bool absPath=true) const
std::string absFilePath() const
void processFile(const QCString &fileName, const std::string &input, std::string &output)
void addSearchDir(const QCString &dir)
std::unique_ptr< Private > p
int find(char c, int index=0, bool cs=TRUE) const
QCString & prepend(const char *s)
QCString mid(size_t index, size_t len=static_cast< size_t >(-1)) const
bool endsWith(const char *s) const
char & at(size_t i)
Returns a reference to the character at index i.
bool isEmpty() const
Returns TRUE iff the string is empty.
QCString right(size_t len) const
size_t size() const
Returns the length of the string, not counting the 0-terminator.
QCString & sprintf(const char *format,...)
const char * data() const
Returns a pointer to the contents of the string in the form of a 0-terminated C string.
Class representing a regular expression.
Iterator class to iterator through matches.
std::string str() const
Return a string representing the matching part.
static int yyread(yyscan_t yyscanner, char *buf, int max_size)
#define Config_getList(name)
static FILE * findFile(const QCString &fileName)
DirIterator end(const DirIterator &) noexcept
#define AUTO_TRACE_ADD(...)
bool isAbsolutePath(const QCString &fileName)
static QCString stringize(const QCString &s)
static int getCurrentChar(yyscan_t yyscanner, const QCString &expr, QCString *rest, uint32_t pos)
static bool expandExpression(yyscan_t yyscanner, QCString &expr, QCString *rest, int pos, int level)
#define MAX_EXPANSION_DEPTH
static int getNextChar(yyscan_t yyscanner, const QCString &expr, QCString *rest, uint32_t &pos)
static QCString removeIdsAndMarkers(const QCString &s)
static void initPredefined(yyscan_t yyscanner, const QCString &fileName)
static void addSeparatorsIfNeeded(yyscan_t yyscanner, const QCString &expr, QCString &resultExpr, QCString &restExpr, int pos)
static int getNextId(const QCString &expr, int p, int *l)
static void returnCharToStream(yyscan_t yyscanner, char c)
static void addTillEndOfString(yyscan_t yyscanner, const QCString &expr, QCString *rest, uint32_t &pos, char term, QCString &arg)
static void forceEndCondSection(yyscan_t yyscanner)
static std::unique_ptr< FileState > checkAndOpenFile(yyscan_t yyscanner, const QCString &fileName, bool &alreadyProcessed)
static const char * processUntilMatchingTerminator(const char *inputStr, QCString &result)
Process string or character literal.
static void unputChar(yyscan_t yyscanner, const QCString &expr, QCString *rest, uint32_t &pos, char c)
static void processConcatOperators(QCString &expr)
static QCString removeMarkers(const QCString &s)
static bool replaceFunctionMacro(yyscan_t yyscanner, const QCString &expr, QCString *rest, int pos, int &len, const Define *def, QCString &result, int level)
static void skipCommentMacroName(yyscan_t yyscanner, const QCString &expr, QCString *rest, int &cc, uint32_t &j, int &len)
int qstrncmp(const char *str1, const char *str2, size_t len)
bool literal_at(const char *data, const char(&str)[N])
returns TRUE iff data points to a substring that matches string literal str
bool readInputFile(const QCString &fileName, std::string &contents, bool filter, bool isSourceCode)
read a file name fileName and optionally filter and transcode it
bool patternMatch(const FileInfo &fi, const StringVector &patList)
QCString determineAbsoluteIncludeName(const QCString &curFile, const QCString &incFileName)
EntryType guessSection(const QCString &name)
FileDef * findFileDef(const FileNameLinkedMap *fnMap, const QCString &n, bool &ambig)