15%option never-interactive
18%option extra-type="struct preYY_state *"
22#define YY_TYPEDEF_YY_SCANNER_T
66#define YY_NO_UNISTD_H 1
131 for (
auto &[name,define] : fromMap)
149 if (dpf && includeStack.find(incFile)==includeStack.end())
151 includeStack.insert(incFile);
158 toMap.emplace(name,define);
172 void addInclude(
const std::string &fromFileName,
const std::string &toFileName)
178 it =
m_fileMap.emplace(fromFileName,std::make_unique<DefinesPerFile>(
this)).first;
180 auto &dpf = it->second;
181 dpf->addInclude(toFileName);
190 it =
m_fileMap.emplace(fileName,std::make_unique<DefinesPerFile>(
this)).first;
192 it->second->store(fromMap);
200 auto &dpf = it->second;
201 dpf->retrieve(toMap);
211 return it->second->stored();
221 return it!=
m_fileMap.end() ? it->second.get() :
nullptr;
224 std::unordered_map< std::string, std::unique_ptr<DefinesPerFile> >
m_fileMap;
348static yy_size_t
getFenceSize(
char *txt, yy_size_t leng);
353#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 QCString expandStandardMacro(yyscan_t yyscanner, const QCString &name)
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
QCString condGuardErrorMessage
const std::string * inputBuf
QCString condGuardErrorFileName
DefineList macroDefinitions
A bunch of utility functions.
363IDSTART [a-z_A-Z\x80-\xFF]
364ID {IDSTART}[a-z_A-Z0-9\x80-\xFF]*
368RAWBEGIN (u|U|L|u8)?R\"[^ \t\(\)\\]{0,16}"("
369RAWEND ")"[^ \t\(\)\\]{0,16}\"
370CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'"))
373FORMULA_START {CMD}("f{"|"f$"|"f["|"f(")
374FORMULA_END {CMD}("f}"|"f$"|"f]"|"f)")
375VERBATIM_START {CMD}("verbatim"|"iliteral"|"latexonly"|"htmlonly"|"xmlonly"|"docbookonly"|"rtfonly"|"manonly"|"dot"|"msc"|"startuml"|"code"("{"[^}]*"}")?){BN}+
376VERBATIM_END {CMD}("endverbatim"|"endiliteral"|"endlatexonly"|"endhtmlonly"|"endxmlonly"|"enddocbookonly"|"endrtfonly"|"endmanonly"|"enddot"|"endmsc"|"enduml"|"endcode")
377VERBATIM_LINE {CMD}"noop"{B}+
378LITERAL_BLOCK {FORMULA_START}|{VERBATIM_START}
379LITERAL_BLOCK_END {FORMULA_END}|{VERBATIM_END}
384RulesSharp "<"[^>\n]*">"
385RulesCurly "{"[^{}\n]*"}"
390EscapeRulesCharOpen "\\["|"\<"|"\\{"|"\\("|"\\\""|"\\ "|"\\\\"
391EscapeRulesCharClose "\\]"|"\>"|"\\}"|"\\)"
392EscapeRulesChar {EscapeRulesCharOpen}|{EscapeRulesCharClose}
408DECIMAL_INTEGER [1-9][0-9']*[0-9]?[uU]?[lL]?[lL]?
409HEXADECIMAL_INTEGER "0"[xX][0-9a-zA-Z']+[0-9a-zA-Z]?
410OCTAL_INTEGER "0"[0-7][0-7']+[0-7]?
411BINARY_INTEGER "0"[bB][01][01']*[01]?
412INTEGER_NUMBER {DECIMAL_INTEGER}|{HEXADECIMAL_INTEGER}|{OCTAL_INTEGER}|{BINARY_INTEGER}
416DIGIT_SEQ [0-9][0-9']*[0-9]?
417FRAC_CONST {DIGIT_SEQ}"."|{DIGIT_SEQ}?"."{DIGIT_SEQ}
418FP_EXP [eE][+-]?{DIGIT_SEQ}
419DEC_FP1 {FRAC_CONST}{FP_EXP}?{FP_SUF}?
420DEC_FP2 {DIGIT_SEQ}{FP_EXP}{FP_SUF}
422HEX_DIGIT_SEQ [0-9a-fA-F][0-9a-fA-F']*[0-9a-fA-F]?
423HEX_FRAC_CONST {HEX_DIGIT_SEQ}"."|{HEX_DIGIT_SEQ}?"."{HEX_DIGIT_SEQ}
424BIN_EXP [pP][+-]?{DIGIT_SEQ}
425HEX_FP1 "0"[xX]{HEX_FRAC_CONST}{BIN_EXP}{FP_SUF}?
426HEX_FP2 "0"[xX]{HEX_DIGIT_SEQ}{BIN_EXP}{FP_SUF}?
428FLOAT_DECIMAL {DEC_FP1}|{DEC_FP2}
429FLOAT_HEXADECIMAL {HEX_FP1}|{HEX_FP2}
430FLOAT_NUMBER {FLOAT_DECIMAL}|{FLOAT_HEXADECIMAL}
431NUMBER {INTEGER_NUMBER}|{FLOAT_NUMBER}
447%x CopyStringFtnDouble
464%x JavaDocVerbatimCode
498 yyextra->yyColNr+=(int)yyleng;
500 yyextra->potentialDefine=yytext;
503<Start>^("%top{"|"%{") {
SrcLangExt getLanguageFromFileName(const QCString &fileName, SrcLangExt defLang)
508<Start>^{Bopt}"cpp_quote"{Bopt}"("{Bopt}\" {
509 if (yyextra->insideIDL)
524<IDLquote>"\""{Bopt}")" {
538<Start>^{B}*[a-z_A-Z\x80-\xFF][a-z_A-Z0-9\x80-\xFF]+{B}*"("[^\)\n]*")"/{BN}{1,10}*[:{] {
540 for (i=(
int)yyleng-1;i>=0;i--)
546<Start>^{B}*[_A-Z][_A-Z0-9]+{B}*"("[^\(\)\n]*"("[^\)\n]*")"[^\)\n]*")"{B}*\n |
547<Start>^{B}*[_A-Z][_A-Z0-9]+{B}*"("[^\)\n]*")"{B}*\n |
548<Start>^{B}*[_A-Z][_A-Z0-9]+{B}*"("[^\(\)\n]*"("[^\)\n]*")"[^\)\n]*")"/{B}*("//"|"/\*") |
549<Start>^{B}*[_A-Z][_A-Z0-9]+{B}*"("[^\)\n]*")"/{B}*("//"|"/\*") {
552 int pos = name.find(
'(');
554 name=name.left(pos).stripWhiteSpace();
557 if (skipFuncMacros && !yyextra->insideFtn &&
558 name!=
"Q_PROPERTY" &&
560 (yyextra->includeStack.empty() || yyextra->curlyCount>0) &&
561 yyextra->macroExpansion &&
569 if (yytext[yyleng-1] ==
'\n')
578 for (i=(
int)yyleng-1;i>=0;i--)
#define Config_getBool(name)
585<CopyLine,LexCopyLine>"extern"{BN}*"\""[^\"]+"\""{BN}*("{")? {
587 yyextra->yyLineNr+=text.
contains(
'\n');
int contains(char c, bool cs=TRUE) const
590<CopyLine,LexCopyLine>{RAWBEGIN} {
593 BEGIN(CopyRawString);
QCString extractBeginRawStringDelimiter(const char *rawStart)
595<CopyLine,LexCopyLine>"{" {
596 if (yyextra->includeStack.empty())
598 yyextra->curlyCount++;
605<CopyLine,LexCopyLine>"}" {
606 if (yyextra->includeStack.empty() && yyextra->curlyCount>0)
608 yyextra->curlyCount--;
612<CopyLine,LexCopyLine>"'"\\[0-7]{1,3}"'" {
615<CopyLine,LexCopyLine>"'"\\."'" {
618<CopyLine,LexCopyLine>"'"."'" {
621<CopyLine,LexCopyLine>[$]?@\" {
624 BEGIN( CopyStringCs );
626<CopyLine,LexCopyLine>\" {
634 BEGIN( CopyStringFtnDouble );
637<CopyLine,LexCopyLine>\' {
640 BEGIN( CopyStringFtn );
642<CopyString>[^\"\\\r\n]{1,1000} {
645<CopyStringCs>[^\"\r\n]{1,1000} {
654<CopyString,CopyStringCs>\" {
658<CopyStringFtnDouble>[^\"\\\r\n]{1,1000} {
661<CopyStringFtnDouble>\\. {
664<CopyStringFtnDouble>\" {
668<CopyStringFtn>[^\'\\\r\n]{1,1000} {
678<CopyRawString>{RAWEND} {
QCString extractEndRawStringDelimiter(const char *rawEnd)
685<CopyRawString>[^)]{1,1000} {
691<CopyLine,LexCopyLine>{ID}/{BN}{0,80}"(" {
692 yyextra->expectGuard =
FALSE;
702 if ((yyextra->includeStack.empty() || yyextra->curlyCount>0) &&
703 yyextra->macroExpansion &&
709 yyextra->roundCount=0;
710 yyextra->defArgsStr=yytext;
721 yyextra->findDefArgContext = CopyLine;
722 BEGIN(FindDefineArgs);
730<CopyLine>{RulesDelim} {
732 yyextra->lexRulesPart = !yyextra->lexRulesPart;
736<CopyLine>{RulesSharp} {
737 if (!yyextra->lexRulesPart) REJECT;
738 if (yyextra->curlyCount) REJECT;
742<RulesPattern>{EscapeRulesChar} {
745<RulesPattern>{RulesCurly} {
748<RulesPattern>{StartDouble} {
750 yyextra->lastContext = YY_START;
753<RulesDouble,RulesRoundDouble>"\\\\" {
756<RulesDouble,RulesRoundDouble>"\\\"" {
761 BEGIN( yyextra->lastContext ) ;
763<RulesRoundDouble>"\"" {
767<RulesDouble,RulesRoundDouble>. {
770<RulesPattern>{StartSquare} {
772 yyextra->lastContext = YY_START;
775<RulesSquare,RulesRoundSquare>{CHARCE} {
778<RulesSquare,RulesRoundSquare>"\\[" |
779<RulesSquare,RulesRoundSquare>"\\]" {
786<RulesRoundSquare>"]" {
790<RulesSquare,RulesRoundSquare>"\\\\" {
793<RulesSquare,RulesRoundSquare>. {
796<RulesPattern>{StartRoundQuest} {
798 yyextra->lastContext = YY_START;
799 BEGIN(RulesRoundQuest);
801<RulesRoundQuest>{nl} {
804<RulesRoundQuest>[^)] {
807<RulesRoundQuest>")" {
809 BEGIN(yyextra->lastContext);
811<RulesPattern>{StartRound} {
812 yyextra->roundCount++;
814 yyextra->lastContext = YY_START;
817<RulesRound>{RulesCurly} {
820<RulesRound>{StartSquare} {
822 BEGIN(RulesRoundSquare);
824<RulesRound>{StartDouble} {
826 BEGIN(RulesRoundDouble);
828<RulesRound>{EscapeRulesChar} {
832 yyextra->roundCount++;
836 yyextra->roundCount--;
838 if (!yyextra->roundCount) BEGIN( yyextra->lastContext ) ;
857<CopyLine,LexCopyLine>{ID} {
860 if ((yyextra->includeStack.empty() || yyextra->curlyCount>0) &&
861 yyextra->macroExpansion &&
881<CopyLine,LexCopyLine>"\\"\r?/\n {
884<CopyLine,LexCopyLine>\\. {
887<CopyLine,LexCopyLine>. {
890<CopyLine,LexCopyLine>\n {
897 yyextra->defArgsStr+=
'(';
898 yyextra->roundCount++;
901 yyextra->defArgsStr+=
')';
902 yyextra->roundCount--;
903 if (yyextra->roundCount==0)
907 if (yyextra->findDefArgContext==CopyLine)
910 BEGIN(yyextra->findDefArgContext);
915 yyextra->nospaces=
FALSE;
925<FindDefineArgs>{CHARLIT} {
926 yyextra->defArgsStr+=yytext;
928<FindDefineArgs>{CCS}[*!]? {
929 yyextra->defArgsStr+=yytext;
930 BEGIN(ArgCopyCComment);
932<FindDefineArgs>{CPPC}[/!].*\n/{B}*{CPPC}[/!] {
937 yyextra->defArgsStr+=
QCString(
"/**< @brief ")+&yytext[4];
941 yyextra->defArgsStr+=
QCString(
"/** @brief ")+&yytext[3];
946 yyextra->defArgsStr+=
QCString(
"/**")+&yytext[3];
948 BEGIN(ArgCopyCppComment);
950<FindDefineArgs>{CPPC}[/!].*\n {
953 yyextra->defArgsStr+=
QCString(
"/**")+&yytext[3]+
" */";
959 yyextra->defArgsStr+=
QCString(
"/**< @brief ")+&yytext[4]+
" */";
963 yyextra->defArgsStr+=
QCString(
"/** @brief ")+&yytext[3]+
" */";
967<FindDefineArgs>{CPPC}.*\n {
968 yyextra->defArgsStr+=
QCString(
"/*")+&yytext[2]+
" */";
971 yyextra->defArgsStr+=*yytext;
976 yyextra->defArgsStr+=*yytext;
980 yyextra->defArgsStr+=
' ';
985 yyextra->defArgsStr+=
"@@";
988 yyextra->defArgsStr+=*yytext;
990<ArgCopyCComment>[^*\n]+ {
991 yyextra->defArgsStr+=yytext;
993<ArgCopyCComment>{CCE} {
994 yyextra->defArgsStr+=yytext;
995 BEGIN(FindDefineArgs);
998 yyextra->defArgsStr+=yytext;
1002 yyextra->defArgsStr+=yytext;
1004<ArgCopyCppComment>^{B}*
1005<ArgCopyCppComment>{CPPC}[/!].*\n/{B}*{CPPC}[/!] {
1006 const char *startContent = &yytext[3];
1007 if (startContent[0]==
'<') startContent++;
1008 yyextra->defArgsStr+=startContent;
1010<ArgCopyCppComment>{CPPC}[/!].*\n {
1011 const char *startContent = &yytext[3];
1012 if (startContent[0]==
'<') startContent++;
1013 yyextra->defArgsStr+=
QCString(startContent)+
" */";
1014 BEGIN(FindDefineArgs);
1016<ArgCopyCppComment>. {
1018 yyextra->defArgsStr+=
" */";
1019 BEGIN(FindDefineArgs);
1022 yyextra->defArgsStr+=*yytext;
1023 BEGIN(FindDefineArgs);
1027 yyextra->defArgsStr+=*yytext;
1028 BEGIN(FindDefineArgs);
1031<ReadString>{CPPC}|{CCS} {
1032 yyextra->defArgsStr+=yytext;
1034<ReadString>\\/\r?\n {
1037 yyextra->defArgsStr+=yytext;
1040 yyextra->defArgsStr+=*yytext;
1042<Command>("include"|"import"){B}+/{ID} {
1043 yyextra->isImported = yytext[1]==
'm';
1044 if (yyextra->macroExpansion)
1047<Command>("include"|"import"){B}*[<"] {
1048 yyextra->isImported = yytext[1]==
'm';
1050 c[0]=yytext[yyleng-1];c[1]=
'\0';
1054<Command>("cmake")?"define"{B}+ {
1055 yyextra->potentialDefine +=
substitute(yytext,
"cmake",
" ");
1057 yyextra->yyColNr+=(int)yyleng;
QCString substitute(const QCString &s, const QCString &src, const QCString &dst)
substitute all occurrences of src in s by dst
1060<Command>"cmakedefine01"{B}+ {
1061 yyextra->potentialDefine +=
substitute(yytext,
"cmakedefine01",
" define ");
1063 yyextra->yyColNr+=(int)yyleng;
1064 BEGIN(CmakeDefName01);
1066<Command>"ifdef"/{B}*"(" {
1068 yyextra->guardExpr.clear();
1069 BEGIN(DefinedExpr2);
1071<Command>"ifdef"/{B}+ {
1074 yyextra->guardExpr.clear();
1075 BEGIN(DefinedExpr1);
1077<Command>"ifndef"/{B}*"(" {
1079 yyextra->guardExpr=
"! ";
1080 BEGIN(DefinedExpr2);
1082<Command>"ifndef"/{B}+ {
1084 yyextra->guardExpr=
"! ";
1085 BEGIN(DefinedExpr1);
1087<Command>"if"/[ \t(!] {
1089 yyextra->guardExpr.clear();
1092<Command>("elif"|"else"{B}*"if")/[ \t(!] {
1095 yyextra->guardExpr.clear();
1101 BEGIN(SkipCPPBlock);
1104<Command>"else"/[^a-z_A-Z0-9\x80-\xFF] {
1108 BEGIN(SkipCPPBlock);
1115<Command>"undef"{B}+ {
1118<Command>("elif"|"else"{B}*"if")/[ \t(!] {
1121 yyextra->guardExpr.clear();
1125<Command>"endif"/[^a-z_A-Z0-9\x80-\xFF] {
1129<Command,IgnoreLine>\n {
1132 yyextra->yyLineNr++;
1134<Command>"pragma"{B}+"once" {
1135 yyextra->expectGuard =
FALSE;
1136 if (yyextra->pragmaSet.find(yyextra->fileName.str())!=yyextra->pragmaSet.end())
1143 yyextra->pragmaSet.insert(yyextra->fileName.data());
1148<PragmaOnce><<EOF>> {
1149 yyextra->expectGuard =
FALSE;
1155<IgnoreLine>\\[\r]?\n {
1157 yyextra->yyLineNr++;
1160<Command>. { yyextra->potentialDefine += yytext[0]==
'\t' ?
'\t' :
' ';
1161 yyextra->yyColNr+=(int)yyleng;
1177 yyextra->guardExpr+=
' ';
1178 yyextra->yyLineNr++;
1180<Guard>"defined"/{B}*"(" {
1181 BEGIN(DefinedExpr2);
1183<Guard>"defined"/{B}+ {
1184 BEGIN(DefinedExpr1);
1186<Guard>"true"/{B}|{B}*[\r]?\n { yyextra->guardExpr+=
"1L"; }
1187<Guard>"false"/{B}|{B}*[\r]?\n { yyextra->guardExpr+=
"0L"; }
1188<Guard>"not"/{B} { yyextra->guardExpr+=
'!'; }
1189<Guard>"not_eq"/{B} { yyextra->guardExpr+=
"!="; }
1190<Guard>"and"/{B} { yyextra->guardExpr+=
"&&"; }
1191<Guard>"or"/{B} { yyextra->guardExpr+=
"||"; }
1192<Guard>"bitand"/{B} { yyextra->guardExpr+=
"&"; }
1193<Guard>"bitor"/{B} { yyextra->guardExpr+=
"|"; }
1194<Guard>"xor"/{B} { yyextra->guardExpr+=
"^"; }
1195<Guard>"compl"/{B} { yyextra->guardExpr+=
"~"; }
1196<Guard>{ID} { yyextra->guardExpr+=yytext; }
1197<Guard>"@" { yyextra->guardExpr+=
"@@"; }
1198<Guard>. { yyextra->guardExpr+=*yytext; }
1212 BEGIN(SkipCPPBlock);
1215<DefinedExpr1,DefinedExpr2>\\\n { yyextra->yyLineNr++;
outputChar(yyscanner,
'\n'); }
1217 if (
isDefined(yyscanner,yytext) || yyextra->guardName==yytext)
1218 yyextra->guardExpr+=
" 1L ";
1220 yyextra->guardExpr+=
" 0L ";
1221 yyextra->lastGuardName=yytext;
1225 if (
isDefined(yyscanner,yytext) || yyextra->guardName==yytext)
1226 yyextra->guardExpr+=
" 1L ";
1228 yyextra->guardExpr+=
" 0L ";
1229 yyextra->lastGuardName=yytext;
1231<DefinedExpr1,DefinedExpr2>\n {
1232 yyextra->yyLineNr++;
1234 BEGIN(SkipCPPBlock);
1239<DefinedExpr1,DefinedExpr2>.
1240<SkipCPPBlock>^{B}*"#" { BEGIN(SkipCommand); }
1241<SkipCPPBlock>^{Bopt}/[^#] { BEGIN(SkipLine); }
1242<SkipCPPBlock>\n { yyextra->yyLineNr++;
outputChar(yyscanner,
'\n'); }
1244<SkipCommand>"if"(("n")?("def"))?/[ \t(!] {
1249<SkipCommand>"else" {
1258<SkipCommand>("elif"|"else"{B}*"if")/[ \t(!] {
1259 if (yyextra->ifcount==0)
1263 yyextra->guardExpr.clear();
1264 yyextra->lastGuardName.clear();
1269 BEGIN(SkipCPPBlock);
1273<SkipCommand>"endif" {
1274 yyextra->expectGuard =
FALSE;
1276 if (--yyextra->ifcount<0)
1284 yyextra->yyLineNr++;
1285 BEGIN(SkipCPPBlock);
1292<SkipLine>{CHARLIT} { }
1297<SkipString>{CPPC}/[^\n]* {
1299<SkipLine,SkipCommand,SkipCPPBlock>{CPPC}[^\n]* {
1300 yyextra->lastCPPContext=YY_START;
1301 BEGIN(RemoveCPPComment);
1303<SkipString>{CCS}/[^\n]* {
1305<SkipLine,SkipCommand,SkipCPPBlock>{CCS}/[^\n]* {
1306 yyextra->lastCContext=YY_START;
1307 BEGIN(RemoveCComment);
1311 yyextra->yyLineNr++;
1312 BEGIN(SkipCPPBlock);
1314<SkipString>[^"\\\n]+ { }
1320<IncludeID>{ID}{Bopt}/"(" {
1321 yyextra->nospaces=
TRUE;
1322 yyextra->roundCount=0;
1323 yyextra->defArgsStr=yytext;
1324 yyextra->findDefArgContext = IncludeID;
1325 BEGIN(FindDefineArgs);
1328 yyextra->nospaces=
TRUE;
1332<Include>[^\">\n]+[\">] {
1333 yyextra->incName+=yytext;
1334 if (yyextra->isImported)
1344<EndImport>{ENDIMPORTopt}/\n {
1348<EndImport>\\[\r]?"\n" {
1350 yyextra->yyLineNr++;
1354<DefName>{ID}/("\\\n")*"(" {
1356 yyextra->argMap.clear();
1357 yyextra->defArgs = 0;
1358 yyextra->defArgsStr.clear();
1359 yyextra->defText.clear();
1360 yyextra->defLitText.clear();
1361 yyextra->defName = yytext;
1362 yyextra->defVarArgs =
FALSE;
1363 yyextra->defExtraSpacing.clear();
1364 yyextra->defContinue =
false;
1367<DefName>{ID}{B}+"1"/[ \r\t\n] {
1369 yyextra->argMap.clear();
1370 yyextra->defArgs = -1;
1371 yyextra->defArgsStr.clear();
1373 yyextra->defVarArgs =
FALSE;
1376 if (yyextra->curlyCount>0 || yyextra->defName!=yyextra->lastGuardName || !yyextra->expectGuard)
1378 QCString def = yyextra->potentialDefine +
1381 outputSpaces(yyscanner,yytext+yyextra->defName.length());
1382 yyextra->quoteArg=
FALSE;
1383 yyextra->insideComment=
FALSE;
1384 yyextra->lastGuardName.clear();
1385 yyextra->defText=
"1";
1386 yyextra->defLitText=
"1";
1392 yyextra->defText.clear();
1393 yyextra->defLitText.clear();
1396 yyextra->expectGuard=
FALSE;
QCString stripWhiteSpace() const
returns a copy of this string with leading and trailing whitespace removed
QCString left(size_t len) const
1398<DefName,CmakeDefName01>{ID}/{B}*"\n" {
1399 yyextra->argMap.clear();
1400 yyextra->defArgs = -1;
1401 yyextra->defName = yytext;
1402 yyextra->defArgsStr.clear();
1403 yyextra->defText.clear();
1404 yyextra->defLitText.clear();
1405 yyextra->defVarArgs =
FALSE;
1408 if (yyextra->curlyCount>0 || yyextra->defName!=yyextra->lastGuardName || !yyextra->expectGuard)
1410 QCString def = yyextra->potentialDefine + yyextra->defName;
1412 yyextra->quoteArg=
FALSE;
1413 yyextra->insideComment=
FALSE;
1414 if (YY_START == CmakeDefName01) yyextra->defText =
"0";
1415 else if (yyextra->insideCS) yyextra->defText=
"1";
1421 yyextra->guardName = yytext;
1422 yyextra->lastGuardName.clear();
1425 yyextra->expectGuard=
FALSE;
1429 yyextra->argMap.clear();
1430 yyextra->defArgs = -1;
1431 yyextra->defArgsStr.clear();
1432 yyextra->defText.clear();
1433 yyextra->defLitText.clear();
1434 yyextra->defName = yytext;
1435 yyextra->defVarArgs =
FALSE;
1436 QCString def = yyextra->potentialDefine +
1438 yyextra->defArgsStr ;
1440 yyextra->quoteArg=
FALSE;
1441 yyextra->insideComment=
FALSE;
1445 yyextra->defExtraSpacing+=
"\n";
1446 yyextra->defContinue =
true;
1447 yyextra->yyLineNr++;
1449<DefineArg>{B}* { yyextra->defExtraSpacing+=yytext; }
1450<DefineArg>","{B}* { yyextra->defArgsStr+=yytext; }
1451<DefineArg>"("{B}* { yyextra->defArgsStr+=yytext; }
1452<DefineArg>{B}*")"{B}* {
1454 yyextra->defArgsStr+=yytext;
1455 QCString def = yyextra->potentialDefine +
1457 yyextra->defArgsStr +
1458 yyextra->defExtraSpacing ;
1460 yyextra->quoteArg=
FALSE;
1461 yyextra->insideComment=
FALSE;
1465 yyextra->defVarArgs =
TRUE;
1466 yyextra->defArgsStr+=yytext;
1467 yyextra->argMap.emplace(std::string(
"__VA_ARGS__"),yyextra->defArgs);
1470<DefineArg>{ID}{B}*("..."?) {
1473 yyextra->defVarArgs = yytext[yyleng-1]==
'.';
1474 if (yyextra->defVarArgs)
1479 yyextra->defArgsStr+=yytext;
1480 yyextra->argMap.emplace(
toStdString(argName),yyextra->defArgs);
size_t length() const
Returns the length of the string, not counting the 0-terminator.
std::string toStdString(const QCString &s)
1496<DefineText>{CCS}[!*]? {
1497 yyextra->defText+=yytext;
1498 yyextra->defLitText+=yytext;
1499 yyextra->lastCContext=YY_START;
1500 yyextra->commentCount=1;
1501 BEGIN(CopyCComment);
1503<DefineText>{CPPC}[!/]? {
1505 yyextra->lastCPPContext=YY_START;
1506 yyextra->defLitText+=
' ';
1507 BEGIN(SkipCPPComment);
1509<SkipCComment>[/]?{CCE} {
1510 if (yytext[0]==
'/')
outputChar(yyscanner,
'/');
1512 if (--yyextra->commentCount<=0)
1514 if (yyextra->lastCContext==Start)
1518 YY_CURRENT_BUFFER->yy_at_bol=1;
1520 BEGIN(yyextra->lastCContext);
1523<SkipCComment>{CPPC}("/")* {
1526<SkipCComment>{CCS} {
1530<SkipCond>{CMD}{CMD} { }
1531<SkipCond>^({B}*"*"+)?{B}{0,3}"~~~"[~]* {
1533 if (!markdownSupport || !yyextra->isSpecialComment)
1539 yyextra->fenceChar=
'~';
1541 BEGIN(SkipCondVerbatim);
1544<SkipCond>^({B}*"*"+)?{B}{0,3}"```"[`]* {
1546 if (!markdownSupport || !yyextra->isSpecialComment)
1552 yyextra->fenceChar=
'`';
1554 BEGIN(SkipCondVerbatim);
1557<SkipCComment>^({B}*"*"+)?{B}{0,3}"~~~"[~]* {
1559 if (!markdownSupport || !yyextra->isSpecialComment)
1566 yyextra->fenceChar=
'~';
1568 BEGIN(SkipVerbatim);
1571<SkipCComment>^({B}*"*"+)?{B}{0,3}"```"[`]* {
1573 if (!markdownSupport || !yyextra->isSpecialComment)
1580 yyextra->fenceChar=
'`';
1582 BEGIN(SkipVerbatim);
1585<SkipCComment>{CMD}{VERBATIM_LINE} |
1586<SkipCComment>{CMD}{LITERAL_BLOCK} {
1590<SkipCComment>{VERBATIM_LINE}.*/\n {
1593<SkipCComment>{LITERAL_BLOCK} {
1596 if (yyextra->isSpecialComment)
1599 BEGIN(SkipVerbatim);
1602<SkipCond>{CMD}{CMD}"cond"[ \t]+ {}
1603<SkipCond>{CMD}"cond"/\n |
1604<SkipCond>{CMD}"cond"[ \t]+ {
1608<SkipCComment>"{"[ \t]*"@code"/[ \t\n] {
1610 yyextra->javaBlock=1;
1611 BEGIN(JavaDocVerbatimCode);
1613<SkipCComment>"{"[ \t]*"@literal"/[ \t\n] {
1615 yyextra->javaBlock=1;
1616 BEGIN(JavaDocVerbatimCode);
1618<SkipCComment,SkipCPPComment>{CMD}{CMD}"cond"[ \t\n]+ {
1621<SkipCPPComment>{CMD}"cond"[ \t]+ {
1622 yyextra->ccomment=
TRUE;
1623 yyextra->condCtx=YY_START;
1626<SkipCComment>{CMD}"cond"[ \t]+ {
1627 yyextra->ccomment=
FALSE;
1628 yyextra->condCtx=YY_START;
1631<CondLineC,CondLineCpp>[!()&| \ta-z_A-Z0-9\x80-\xFF.\-]+ {
1635 if (YY_START==CondLineC)
1639 yyextra->ccomment=
TRUE;
1643 yyextra->ccomment=
FALSE;
1649 BEGIN(yyextra->condCtx);
1652<CondLineC,CondLineCpp>. {
1657 if (YY_START==CondLineC)
1661 yyextra->ccomment=
TRUE;
1665 yyextra->ccomment=
FALSE;
1671 BEGIN(yyextra->condCtx);
1674<SkipCComment,SkipCPPComment>{CMD}"cond"{WSopt}/\n {
1675 if (YY_START==SkipCComment)
1677 yyextra->ccomment=
TRUE;
1683 yyextra->ccomment=
FALSE;
1685 yyextra->condCtx=YY_START;
1686 yyextra->condGuardCount=0;
1690<SkipCond>\n { yyextra->yyLineNr++;
outputChar(yyscanner,
'\n'); }
1691<SkipCond>{VERBATIM_LINE}.*/\n { }
1692<SkipCond>{LITERAL_BLOCK} {
1694 yyextra->yyLineNr+=numNLs;
1695 for (
int i = 0; i < numNLs; i++)
outputChar(yyscanner,
'\n');
1697 BEGIN(SkipCondVerbatim);
1701<SkipCond>"#if"("def")? { yyextra->condGuardCount++; }
1702<SkipCond>"#endif" { yyextra->condGuardCount--; }
1703<SkipCond>[^\/\!*\\@\n#]+ { }
1704<SkipCond>{CPPC}[/!] { yyextra->ccomment=
FALSE; }
1705<SkipCond>{CCS}[*!] { yyextra->ccomment=
TRUE; }
1706<SkipCond,SkipCComment,SkipCPPComment>{CMD}{CMD}"endcond"/[^a-z_A-Z0-9\x80-\xFF] {
1712<SkipCond>{CMD}"endcond"/[^a-z_A-Z0-9\x80-\xFF] {
1713 bool oldSkip = yyextra->skip;
1715 if (oldSkip && !yyextra->skip)
1717 if (yyextra->ccomment)
1721 BEGIN(yyextra->condCtx);
1724<SkipCComment,SkipCPPComment>{CMD}"endcond"/[^a-z_A-Z0-9\x80-\xFF] {
1725 bool oldSkip = yyextra->skip;
1727 if (oldSkip && !yyextra->skip)
1729 BEGIN(yyextra->condCtx);
1732<SkipCondVerbatim>{LITERAL_BLOCK_END} {
1733 if (yytext[1]==
'f' && yyextra->blockName==&yytext[2])
1737 else if (&yytext[4]==yyextra->blockName)
1742<SkipVerbatim>{LITERAL_BLOCK_END} {
1744 if (yytext[1]==
'f' && yyextra->blockName==&yytext[2])
1746 BEGIN(SkipCComment);
1748 else if (&yytext[4]==yyextra->blockName)
1750 BEGIN(SkipCComment);
1753<SkipCondVerbatim>^({B}*"*"+)?{B}{0,3}"~~~"[~]* {
1754 if (yyextra->fenceSize==
getFenceSize(yytext,yyleng) && yyextra->fenceChar==
'~')
1759<SkipCondVerbatim>^({B}*"*"+)?{B}{0,3}"```"[`]* {
1760 if (yyextra->fenceSize==
getFenceSize(yytext,yyleng) && yyextra->fenceChar==
'`')
1765<SkipVerbatim>^({B}*"*"+)?{B}{0,3}"~~~"[~]* {
1767 if (yyextra->fenceSize==
getFenceSize(yytext,yyleng) && yyextra->fenceChar==
'~')
1769 BEGIN(SkipCComment);
1772<SkipVerbatim>^({B}*"*"+)?{B}{0,3}"```"[`]* {
1774 if (yyextra->fenceSize==
getFenceSize(yytext,yyleng) && yyextra->fenceChar==
'`')
1776 BEGIN(SkipCComment);
1779<SkipCondVerbatim>{CCE}|{CCS} { }
1780<SkipVerbatim>{CCE}|{CCS} {
1783<JavaDocVerbatimCode>"{" {
1784 if (yyextra->javaBlock==0)
1790 yyextra->javaBlock++;
1794<JavaDocVerbatimCode>"}" {
1795 if (yyextra->javaBlock==0)
1801 yyextra->javaBlock--;
1802 if (yyextra->javaBlock==0)
1805 BEGIN(SkipCComment);
1813<JavaDocVerbatimCode>\n {
1816<JavaDocVerbatimCode>. {
1819<SkipCondVerbatim>[^{*\\@\x06~`\n\/]+ { }
1820<SkipCComment,SkipVerbatim>[^{*\\@\x06~`\n\/]+ {
1823<SkipCComment,SkipVerbatim,SkipCondVerbatim>\n {
1824 yyextra->yyLineNr++;
1827<SkipCondVerbatim>. { }
1828<SkipCComment,SkipVerbatim>. {
1831<CopyCComment>[^*a-z_A-Z\x80-\xFF\n]*[^*a-z_A-Z\x80-\xFF\\\n] {
1832 yyextra->defLitText+=yytext;
1833 yyextra->defText+=
escapeAt(yytext);
1835<CopyCComment>\\[\r]?\n {
1836 yyextra->defLitText+=yytext;
1837 yyextra->defText+=
" ";
1838 yyextra->yyLineNr++;
1839 yyextra->yyMLines++;
1841<CopyCComment>{CCE} {
1842 yyextra->defLitText+=yytext;
1843 yyextra->defText+=yytext;
1844 BEGIN(yyextra->lastCContext);
1847 yyextra->yyLineNr++;
1848 yyextra->defLitText+=yytext;
1849 yyextra->defText+=
' ';
1851<RemoveCComment>{CCE}{B}*"#" {
1852 if (yyextra->lastCContext==SkipCPPBlock)
1861<RemoveCComment>{CCE} { BEGIN(yyextra->lastCContext); }
1862<RemoveCComment>{CPPC}
1863<RemoveCComment>{CCS}
1864<RemoveCComment>[^*\x06\n]+
1865<RemoveCComment>\n { yyextra->yyLineNr++;
outputChar(yyscanner,
'\n'); }
1867<SkipCPPComment>[^\n\/\\@]+ {
1870<SkipCPPComment,RemoveCPPComment>\n {
1872 BEGIN(yyextra->lastCPPContext);
1874<SkipCPPComment>{CCS} {
1877<SkipCPPComment>{CPPC} {
1880<SkipCPPComment>[^\x06\@\\\n]+ {
1886<RemoveCPPComment>{CCS}
1887<RemoveCPPComment>{CPPC}
1888<RemoveCPPComment>[^\x06\n]+
1890<DefineText>"__VA_OPT__("{B}*"##" {
1891 warn(yyextra->fileName,yyextra->yyLineNr,
1892 "'##' may not appear at the beginning of a __VA_OPT__()",
1893 yyextra->defName,yyextra->defLitText.stripWhiteSpace());
1894 yyextra->defText+=
"__VA_OPT__(";
1895 yyextra->defLitText+=
"__VA_OPT__(";
#define warn(file, line, fmt,...)
1897<DefineText>"#"/"__VA_OPT__" {
1898 yyextra->defText+=yytext;
1899 yyextra->defLitText+=yytext;
1901<DefineText>"#"/{IDSTART} {
1903 yyextra->quoteArg=
TRUE;
1904 yyextra->idStart=
true;
1905 yyextra->defLitText+=yytext;
1907<DefineText,CopyCComment>{ID} {
1908 yyextra->defLitText+=yytext;
1909 if (YY_START == DefineText)
outputSpaces(yyscanner,yytext);
1910 if (yyextra->quoteArg)
1912 yyextra->defText+=
"\"";
1914 if (yyextra->defArgs>0)
1916 auto it = yyextra->argMap.find(yytext);
1917 if (it!=yyextra->argMap.end())
1920 yyextra->defText+=
'@';
1925 if (yyextra->idStart)
1927 warn(yyextra->fileName,yyextra->yyLineNr,
1928 "'#' is not followed by a macro parameter '{}': '{}'",
1929 yyextra->defName,yyextra->defLitText.stripWhiteSpace());
1931 yyextra->defText+=yytext;
1936 yyextra->defText+=yytext;
1938 if (yyextra->quoteArg)
1940 yyextra->defText+=
"\"";
1942 yyextra->quoteArg=
FALSE;
1943 yyextra->idStart=
false;
QCString & setNum(short n)
1946 yyextra->defLitText+=yytext;
1947 yyextra->defText+=yytext;
1949<DefineText>\\[\r]?\n {
1950 yyextra->defLitText+=yytext;
1953 yyextra->defText +=
' ';
1954 yyextra->yyLineNr++;
1955 yyextra->yyMLines++;
1959 yyextra->defText = yyextra->defText.stripWhiteSpace();
1960 if (yyextra->defText.startsWith(
"##"))
1962 warn(yyextra->fileName,yyextra->yyLineNr,
1963 "'##' cannot occur at the beginning of a macro definition '{}': '{}'",
1964 yyextra->defName,yyextra->defLitText.stripWhiteSpace());
1966 else if (yyextra->defText.endsWith(
"##"))
1968 warn(yyextra->fileName,yyextra->yyLineNr,
1969 "'##' cannot occur at the end of a macro definition '{}': '{}'",
1970 yyextra->defName,yyextra->defLitText.stripWhiteSpace());
1972 else if (yyextra->defText.endsWith(
"#"))
1974 warn(yyextra->fileName,yyextra->yyLineNr,
1975 "expected formal parameter after # in macro definition '{}': '{}'",
1976 yyextra->defName,yyextra->defLitText.stripWhiteSpace());
1981 yyextra->defLitText=yyextra->defLitText.left(yyextra->defLitText.length()-
comment.length()-1);
1984 yyextra->defLitText+=yytext;
1987 if (yyextra->includeStack.empty() || yyextra->curlyCount>0)
1991 def=
isDefined(yyscanner,yyextra->defName);
2005 def->
name = yyextra->defName;
2007 def->
nargs = yyextra->defArgs;
2009 def->
lineNr = yyextra->yyLineNr-yyextra->yyMLines;
2014 if (def->
fileName != yyextra->fileName && !yyextra->expandOnlyPredef)
addDefine(yyscanner);
2018 yyextra->argMap.clear();
2019 yyextra->yyLineNr++;
2021 yyextra->lastGuardName.clear();
2025 yyextra->defText +=
' ';
2026 yyextra->defLitText+=yytext;
2029 yyextra->defText +=
"##";
2030 yyextra->defLitText+=yytext;
2033 yyextra->defText +=
"@@";
2034 yyextra->defLitText+=yytext;
2038 yyextra->defText += *yytext;
2039 yyextra->defLitText+=yytext;
2040 if (!yyextra->insideComment)
2042 BEGIN(SkipDoubleQuote);
2045<DefineText>{NUMBER} {
2047 yyextra->defText += yytext;
2048 yyextra->defLitText+=yytext;
2052 yyextra->defText += *yytext;
2053 yyextra->defLitText+=yytext;
2054 if (!yyextra->insideComment)
2056 BEGIN(SkipSingleQuote);
2059<SkipDoubleQuote>{CPPC}[/]? {
outputSpaces(yyscanner,yytext);
2060 yyextra->defText += yytext;
2061 yyextra->defLitText+=yytext;
2063<SkipDoubleQuote>{CCS}[*]? {
outputSpaces(yyscanner,yytext);
2064 yyextra->defText += yytext;
2065 yyextra->defLitText+=yytext;
2067<SkipDoubleQuote>\" {
2069 yyextra->defText += *yytext;
2070 yyextra->defLitText+=yytext;
2073<SkipSingleQuote,SkipDoubleQuote>\\. {
2075 yyextra->defText += yytext;
2076 yyextra->defLitText+=yytext;
2078<SkipSingleQuote>\' {
2080 yyextra->defText += *yytext;
2081 yyextra->defLitText+=yytext;
2084<SkipDoubleQuote,SkipSingleQuote>. {
outputSpace(yyscanner,yytext[0]);
2085 yyextra->defText += *yytext;
2086 yyextra->defLitText += *yytext;
2089 yyextra->defText += *yytext;
2090 yyextra->defLitText += *yytext;
2093 TRACE(
"End of include file");
2095 if (yyextra->includeStack.empty())
2097 TRACE(
"Terminating scanner");
2102 if (!yyextra->levelGuard.empty())
2104 if (yyextra->condGuardErrorLine!=0)
2106 warn(yyextra->condGuardErrorFileName,yyextra->condGuardErrorLine,
"{}",yyextra->condGuardErrorMessage);
2110 warn(yyextra->fileName,yyextra->yyLineNr,
"More #endif's than #if's found.");
2113 QCString toFileName = yyextra->fileName;
2114 const std::unique_ptr<FileState> &fs=yyextra->includeStack.back();
2116 YY_BUFFER_STATE oldBuf = YY_CURRENT_BUFFER;
2117 yy_switch_to_buffer( fs->bufState, yyscanner );
2118 yy_delete_buffer( oldBuf, yyscanner );
2119 yyextra->yyLineNr = fs->lineNr;
2121 yyextra->inputBuf = fs->oldFileBuf;
2122 yyextra->inputBufPos = fs->oldFileBufPos;
2123 yyextra->curlyCount = fs->curlyCount;
2124 yyextra->levelGuard = fs->levelGuard;
2126 TRACE(
"switching to {}",yyextra->fileName);
2131 lineStr.sprintf(
"# %d \"%s\" 2",yyextra->yyLineNr,
qPrint(yyextra->fileName));
2134 yyextra->includeStack.pop_back();
2157 for (
const auto &kv : yyextra->localDefines)
2159 auto pair = yyextra->contextDefines.insert(kv);
2162 yyextra->contextDefines.erase(pair.first);
2163 yyextra->contextDefines.insert(kv);
2166 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)
2171 if (YY_START==SkipVerbatim || YY_START == SkipCondVerbatim || YY_START==SkipCond || YY_START==IDLquote || YY_START == PragmaOnce)
2178 yyextra->lastCContext=YY_START;
2179 yyextra->commentCount=1;
2182 yyextra->isSpecialComment =
true;
2183 yyextra->lastGuardName.clear();
2187 yyextra->isSpecialComment =
false;
2189 BEGIN(SkipCComment);
2193 if (YY_START==SkipVerbatim || YY_START == SkipCondVerbatim || YY_START==SkipCond ||
getLanguageFromFileName(yyextra->fileName)==SrcLangExt::Fortran || YY_START==IDLquote || YY_START == PragmaOnce)
2197 else if (YY_START==RulesRoundDouble)
2204 yyextra->lastCPPContext=YY_START;
2207 yyextra->isSpecialComment =
true;
2208 yyextra->lastGuardName.clear();
2212 yyextra->isSpecialComment =
false;
2214 BEGIN(SkipCPPComment);
2219 yyextra->yyLineNr++;
2222 yyextra->expectGuard =
FALSE;
2232 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
2233 int bytesInBuf =
static_cast<int>(state->inputBuf->size())-state->inputBufPos;
2234 int bytesToCopy = std::min(max_size,bytesInBuf);
2235 memcpy(buf,state->inputBuf->data()+state->inputBufPos,bytesToCopy);
2236 state->inputBufPos+=bytesToCopy;
2242 yy_size_t fenceSize = 0;
2243 for (
size_t i = 0; i < leng; i++)
2245 if (txt[i] !=
' ' && txt[i] !=
'*' && txt[i] !=
'\t')
break;
2248 return leng-fenceSize;
2253 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
2258 if (state->yyFileDef==
nullptr)
2264 if (state->yyFileDef && state->yyFileDef->isReference()) state->yyFileDef=
nullptr;
2269 state->isSource = section.isHeader() || section.isSource();
2274 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
2275 state->levelGuard.push(
false);
2281 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
2283 if (!state->levelGuard.empty())
2285 state->levelGuard.pop();
2289 if (state->condGuardErrorLine!=0)
2291 warn(state->condGuardErrorFileName,state->condGuardErrorLine,
"{}",state->condGuardErrorMessage);
2295 warn(state->fileName,state->yyLineNr,
"More #endif's than #if's found.");
2302 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
2303 if (state->levelGuard.empty())
2305 warn(state->fileName,state->yyLineNr,
"Found an #else without a preceding #if.");
2310 return state->levelGuard.top();
2316 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
2317 state->levelGuard.top()=value;
2323 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
2324 alreadyProcessed =
FALSE;
2325 std::unique_ptr<FileState> fs;
2336 if (state->curlyCount==0)
2341 alreadyProcessed =
TRUE;
2348 alreadyProcessed = std::any_of(
2349 state->includeStack.begin(),
2350 state->includeStack.end(),
2351 [absName](
const std::unique_ptr<FileState> &lfs)
2352 { return lfs->fileName==absName; }
2355 if (alreadyProcessed)
2362 fs = std::make_unique<FileState>();
2371 fs->oldFileBuf = state->inputBuf;
2372 fs->oldFileBufPos = state->inputBufPos;
2380 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
2391 else if (alreadyProcessed)
2396 if (localInclude && !state->fileName.isEmpty())
2398 FileInfo fi(state->fileName.str());
2409 else if (alreadyProcessed)
2415 if (state->pathList.empty())
2419 for (
auto path : state->pathList)
2421 QCString absName = path+
"/"+fileName;
2431 else if (alreadyProcessed)
2464 if (i>=0 && s[i]==
'*')
2467 while (i>0 && !(s[i-1]==
'/' && s[i]==
'*')) i--;
2474 return ((s[i+1]==
'*' || s[i+1]==
'!') && s[i+2]==
'<') ? &s[i-1] :
"";
2506 bool inString=
FALSE;
2511 if (!inString && !inChar)
2513 while (i<s.
length() && !inString && !inChar)
2534 while (i<s.
length() && inChar)
2555 while (i<s.
length() && inString)
2584 std::string e = expr.
str();
2585 static const reg::Ex r(R
"(\s*##\s*)");
2594 const auto &match = *it;
2595 size_t n = match.position();
2596 size_t l = match.length();
2598 if (n+l+1<e.length() && e[
static_cast<int>(n+l)]==
'@' && expr[
static_cast<int>(n+l+1)]==
'-')
2605 e=e.substr(0,n)+e.substr(n+l);
2606 int k=
static_cast<int>(n)-1;
2607 while (k>=0 &&
isId(e[k])) k--;
2608 if (k>0 && e[k]==
'-' && e[k-1]==
'@')
2611 e=e.substr(0,k-1)+e.substr(k+1);
2629 struct yyguts_t * yyg = (
struct yyguts_t*)yyscanner;
2637 while ((cc=
getNextChar(yyscanner,expr,rest,pos))!=EOF && cc!=0)
2653 int &cc, uint32_t &j,
int &len)
2655 bool changed =
false;
2660 while ((cc=
getCurrentChar(yyscanner,expr,rest,j))!=EOF && cc!=
'\n' && isspace(cc))
2668 int prevChar =
'\0';
2670 if ((cc=
getCurrentChar(yyscanner,expr,rest,j))!=EOF && cc ==
'*')
2672 while ((cc=
getNextChar(yyscanner,expr,rest,j))!=EOF && cc!=0)
2674 if (cc ==
'/' && prevChar ==
'*')
break;
2677 if (cc != EOF) changed =
true;
2690 int vl =
static_cast<int>(vaStr.
length());
2691 while ((vo = vaStr.
find(
"__VA_OPT__(",vp))!=-1)
2693 bool hasHash = vo>0 && vaStr.
at(vo-1)==
'#';
2696 result+=vaStr.
mid(vp,vo-vp-1);
2701 result+=vaStr.
mid(vp,vo-vp);
2705 while (bc>0 && ve<vl)
2707 if (vaStr[ve]==
')') bc--;
2708 else if (vaStr[ve]==
'(') bc++;
2712 if (bc==0 && hasOptionalArgs)
2724 result+=vaStr.
mid(vp);
2756 std::map<std::string,std::string> argTable;
2759 int argCountNonEmpty=0;
2765 while ((cc=
getNextChar(yyscanner,expr,rest,j))!=EOF && cc!=0)
2773 while (!done && (argCount<def->nargs || def->
varArgs) &&
2774 ((cc=
getNextChar(yyscanner,expr,rest,j))!=EOF && cc!=0)
2783 while ((cc=
getNextChar(yyscanner,expr,rest,j))!=EOF && cc!=0)
2787 if (c==
'\'' || c==
'\"')
2809 else if (c==
')' || c==
',')
2822 argKey.
sprintf(
"@%d",argCount++);
2823 if (c==
',' || !arg.
isEmpty()) argCountNonEmpty++;
2837 while (!found && (cc=
getNextChar(yyscanner,expr,rest,j))!=EOF && cc!=0)
2844 if ((cc=
getNextChar(yyscanner,expr,rest,j))==EOF || cc==0)
break;
2854 while (!found && (cc=
getNextChar(yyscanner,expr,rest,j))!=EOF && cc!=0)
2861 if ((cc=
getNextChar(yyscanner,expr,rest,j))==EOF || cc==0)
break;
2869 char prevChar =
'\0';
2873 while ((cc=
getNextChar(yyscanner,expr,rest,j))!=EOF && cc!=0)
2877 if (c ==
'/' && prevChar ==
'*')
break;
2890 if (argCount==def->
nargs ||
2901 bool inString=
FALSE;
2911 else if (d.
at(k+1)==
'-')
2922 if (l>=0 && d.
at(l)==
'"') l--;
2923 while (l>=0 && d.
at(l)==
' ') l--;
2924 if (l>0 && d.
at(l)==
'#' && d.
at(l-1)==
'#') hash=
TRUE;
2927 while (k<d.
length() && d.
at(k)>=
'0' && d.
at(k)<=
'9') key+=d.
at(k++);
2932 if (l<(
int)d.
length() && d.
at(l)==
'"') l++;
2933 while (l<(
int)d.
length() && d.
at(l)==
' ') l++;
2934 if (l<(
int)d.
length()-1 && d.
at(l)==
'#' && d.
at(l+1)==
'#') hash=
TRUE;
2937 auto it = argTable.find(key.
str());
2938 if (it!=argTable.end())
2958 if (hash && substArg.
isEmpty())
2969 if (!inString && d.
at(k)==
'\"')
2973 else if (k>2 && inString && d.
at(k)==
'\"' && (d.
at(k-1)!=
'\\' || d.
at(k-2)==
'\\'))
2997 while (p<(
int)expr.
length())
2999 char c=expr.
at(p++);
3004 else if (isalpha(c) || c==
'_')
3014 if (p<(
int)expr.
length()) c=expr.
at(p);
3015 while (p<(
int)expr.
length() && (c!=
'"' || (pc==
'\\' && ppc!=
'\\')))
3023 if (p<(
int)expr.
length()) ++p;
3029 if (p<(
int)expr.
length())
3035 while (p<(
int)expr.
length() && !(pc==
'*' && c==
'/'))
3048#define MAX_EXPANSION_DEPTH 50
3052 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
3053 if (!state->nospaces)
3056 char ccPrev = pos==0 || (int)expr.
length()<pos ? state->prevChar : expr.
at(pos-1);
3057 QCString leftSpace = ccPrev!=
':' && ccPrev!=
' ' ?
" " :
"";
3062 uint32_t j=(uint32_t)resultExpr.
length();
3063 while ((ccNext=
getNextChar(yyscanner,resultExpr,
nullptr,j))!=EOF && ccNext==
' ') { }
3064 if (ccNext != EOF)
unputChar(yyscanner,resultExpr,
nullptr,j,(
char)ccNext);
3068 ccNext=restExpr.
at(0);
3071 QCString rightSpace = ccNext!=
':' && ccNext!=
' ' ?
" " :
"";
3074 resultExpr=leftSpace+resultExpr+rightSpace;
3084 struct yyguts_t * yyg = (
struct yyguts_t*)yyscanner;
3085 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
3092 if (state->expanded.find(expr.
str())!=state->expanded.end() &&
3100 state->expanded.insert(expr.
str());
3104 bool definedTest=
FALSE;
3105 int i=pos, l=0, p=0, len=0;
3110 bool replaced=
FALSE;
3112 macroName=expr.
mid(p,l);
3117 expr=expr.
left(p)+resultExpr+restExpr;
3119 else if (p<2 || !(expr.
at(p-2)==
'@' && expr.
at(p-1)==
'-'))
3121 if (state->expandedDict.find(macroName.
str())==state->expandedDict.end())
3123 bool expanded=
false;
3127 if (yyextra->expandOnlyPredef && def && !def->
isPredefined) def=
nullptr;
3128 if (macroName==
"defined")
3133 else if (definedTest)
3135 if (def) expMacro =
" 1 ";
else expMacro =
" 0 ";
3140 else if (def && def->
nargs==-1)
3149 else if (def && def->
nargs>=0)
3160 resultExpr=expMacro;
3167 state->expandedDict.emplace(
toStdString(macroName),def);
3169 state->expandedDict.erase(
toStdString(macroName));
3178 expr=expr.
left(p)+resultExpr+restExpr;
3234 if (inputStr==
nullptr)
return inputStr;
3235 char term = *inputStr;
3236 if (
term!=
'\'' &&
term!=
'"')
return inputStr;
3241 while ((c=*inputStr))
3270 static const std::vector<std::string> signs = {
"signed",
"unsigned" };
3271 struct TypeInfo { std::string name;
size_t size; };
3272 static const std::vector<TypeInfo> types = {
3273 {
"short int",
sizeof(
short int) },
3274 {
"long long int",
sizeof(
long long int) },
3275 {
"long int",
sizeof(
long int) },
3276 {
"long long",
sizeof(
long long) },
3277 {
"long double",
sizeof(
long double) },
3278 {
"int",
sizeof(int) },
3279 {
"short",
sizeof(short) },
3280 {
"bool",
sizeof(bool) },
3281 {
"long",
sizeof(long) },
3282 {
"char",
sizeof(char) },
3283 {
"float",
sizeof(float) },
3284 {
"double",
sizeof(double) },
3290 auto process_cast_or_sizeof = [](
const char *p) -> std::pair<const char *,size_t>
3293 while (*q==
' ' || *q==
'\t') q++;
3295 size_t size =
sizeof(int);
3296 for (
const auto &sgn : signs)
3298 if (
qstrncmp(q,sgn.c_str(),sgn.length())==0) { q+=sgn.length(); found=
true; }
3300 if (!found || *q==
' ' || *q==
'\t' || *q==
')')
3302 while (*q==
' ' || *q==
'\t') q++;
3303 for (
const auto &t : types)
3305 if (
qstrncmp(q,t.name.c_str(),t.name.length())==0)
3307 q += t.name.length();
3312 while (*q==
' ' || *q==
'\t') q++;
3313 if (*q==
')')
return std::make_pair(++q,size);
3315 return std::make_pair(
nullptr,0);
3320 const char *p=s.
data();
3330 const char *q = process_cast_or_sizeof(p+1).first;
3340 const char *q = p+6;
3341 while (*q==
' ' || *q==
'\t') q++;
3344 auto r = process_cast_or_sizeof(q+1);
3361 else if (*(p+1)==
'E')
3367 else if (isdigit(c))
3377 else if (c==
'd' && !inNum)
3388 while ((c=*p) &&
isId(c)) p++;
3391 else if ((isalpha(c) || c==
'_') && !inNum)
3395 while ((c=*p) &&
isId(c)) p++;
3396 while ((c=*p) && isspace((uint8_t)c)) p++;
3403 if (c==
'(') count++;
3407 if (count==0)
break;
3415 while (*p && !(pc==
'*' && c==
'/'))
3432 while (*p && !(pc==
'*' && c==
'/'))
3449 char lc=(char)tolower(c);
3466 const char *p=s.
data();
3491 while (*p && !(pc==
'*' && c==
'/'))
3493 if (*p==
'@' && *(p+1)==
'@')
3536 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
3540 state->expanded.clear();
3546 return state->constExpParser.parse(state->fileName.data(),state->yyLineNr,e.
str(),ee.
str());
3555 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
3556 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
3557 state->prevChar = yyscanner->yytext_r > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ? *(yyscanner->yytext_r-1) : 0;
3559 state->expanded.
clear();
3569 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
3571 if (name ==
"__LINE__")
3575 else if (name ==
"__FILE__")
3578 resultExpr += yyextra->fileName;
3581 else if (name ==
"__DATE__")
3584 resultExpr += __DATE__;
3587 else if (name ==
"__TIME__")
3590 resultExpr += __TIME__;
3598 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
3600 def.
name = state->defName;
3602 def.
nargs = state->defArgs;
3604 def.
fileDef = state->yyFileDef;
3605 def.
lineNr = state->yyLineNr-state->yyMLines;
3607 def.
varArgs = state->defVarArgs;
3617 auto it = state->localDefines.find(def.
name.
str());
3618 if (it!=state->localDefines.end())
3620 state->localDefines.erase(it);
3622 state->localDefines.emplace(def.
name.
str(),def);
3627 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
3628 if (state->skip)
return;
3633 define.
lineNr = state->yyLineNr - state->yyMLines;
3635 define.
name = state->defName;
3636 define.
args = state->defArgsStr;
3637 define.
fileDef = state->inputFileDef;
3639 QCString litText = state->defLitText;
3640 int l=litText.
find(
'\n');
3650 const char *p=litText.
data()+k;
3652 while ((c=*p++) && (c==
' ' || c==
'\t')) k++;
3656 if (litTextStripped.
contains(
'\n')>=1)
3665 state->macroDefinitions.push_back(define);
3671 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
3672 if (state->includeStack.empty() || state->curlyCount>0) (*state->outputBuf)+=c;
3677 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
3678 if (state->includeStack.empty() || state->curlyCount>0) (*state->outputBuf)+=std::string_view(a,len);
3683 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
3684 if (state->includeStack.empty() || state->curlyCount>0) (*state->outputBuf)+=a.
str();
3706 struct yyguts_t * yyg = (
struct yyguts_t*)yyscanner;
3707 if (!yyextra->defContinue)
return;
3708 for (
int i=0; i< (int)yyleng; i++)
3710 if (yytext[i] ==
'\t')
3711 yyextra->defExtraSpacing+=
'\t';
3713 yyextra->defExtraSpacing+=
' ';
3719 struct yyguts_t * yyg = (
struct yyguts_t*)yyscanner;
3720 yyextra->fenceSize=0;
3722 if (yytext[1]==
'f' && ((c=yytext[2])==
'[' || c==
'{' || c==
'(' || c==
'$'))
3726 case '[': yyextra->blockName=
"]";
break;
3727 case '{': yyextra->blockName=
"}";
break;
3728 case '(': yyextra->blockName=
")";
break;
3729 case '$': yyextra->blockName=
"$";
break;
3732 yyextra->blockName=yyextra->blockName.stripWhiteSpace();
3739 yyextra->blockName=
"uml";
3743 int i = bn.
find(
'{');
3745 yyextra->blockName=bn;
3753 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
3758 (inc.
at(i)==
' ' || inc.
at(i)==
'"' || inc.
at(i)==
'<')
3763 bool localInclude = s>0 && inc.
at(s-1)==
'"';
3766 while (i<inc.
length() && inc.
at(i)!=
'"' && inc.
at(i)!=
'>') i++;
3768 if (s<inc.
length() && i>s)
3778 QCString oldFileName = state->fileName;
3779 FileDef *oldFileDef = state->yyFileDef;
3780 int oldLineNr = state->yyLineNr;
3786 std::unique_ptr<FileState> fs;
3787 bool alreadyProcessed =
FALSE;
3789 fs=
findFile(yyscanner,absIncFileName,localInclude,alreadyProcessed);
3800 for (i=0;i<state->includeStack.size();i++)
3807 if (state->includeStack.empty() && oldFileDef)
3809 PreIncludeInfo *ii = state->includeRelations.find(absIncFileName);
3814 state->includeRelations.add(
3817 ambig ?
nullptr : incFd,
3825 struct yyguts_t * yyg = (
struct yyguts_t*)yyscanner;
3826 fs->bufState = YY_CURRENT_BUFFER;
3827 fs->lineNr = oldLineNr;
3828 fs->fileName = oldFileName;
3829 fs->curlyCount = state->curlyCount;
3831 fs->lexRulesPart = state->lexRulesPart;
3832 fs->levelGuard = state->levelGuard;
3833 while (!state->levelGuard.empty()) state->levelGuard.pop();
3834 state->lexRulesPart =
false;
3837 state->includeStack.push_back(std::move(fs));
3847 state->expectGuard=
TRUE;
3848 state->inputBuf = &fs_ptr->
fileBuf;
3849 state->inputBufPos=0;
3850 yy_switch_to_buffer(yy_create_buffer(0,
YY_BUF_SIZE, yyscanner),yyscanner);
3854 if (alreadyProcessed)
3862 if (state->includeStack.empty() && oldFileDef)
3864 PreIncludeInfo *ii = state->includeRelations.find(absIncFileName);
3869 ii = state->includeRelations.add(absIncFileName,
3871 ambig ?
nullptr : incFd,
3881 for (i=0;i<state->includeStack.size();i++)
3885 if (alreadyProcessed)
3895 if (localInclude && !state->includeStack.empty() && state->curlyCount>0 && !alreadyProcessed)
3897 warn(state->fileName,state->yyLineNr,
"include file {} not found, perhaps you forgot to add its directory to INCLUDE_PATH?",incFileName);
3907 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
3910 bool expResult = prs.
parse(state->fileName.data(),state->yyLineNr,sectId.
data());
3911 state->condStack.emplace(std::make_unique<preYY_CondCtx>(state->fileName,state->yyLineNr,sectId,state->skip));
3921 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
3922 if (state->condGuardCount>0 && state->condGuardErrorLine==0)
3924 state->condGuardErrorLine = state->yyLineNr;
3925 state->condGuardErrorFileName = state->fileName;
3926 state->condGuardErrorMessage =
"more #if's than #endif's in \\cond..\\endcond section";
3928 else if (state->condGuardCount<0 && state->condGuardErrorLine==0)
3930 state->condGuardErrorLine = state->yyLineNr;
3931 state->condGuardErrorFileName = state->fileName;
3932 state->condGuardErrorMessage =
"more #endif's than #if's in \\cond..\\endcond section";
3936 state->condGuardErrorLine = 0;
3938 if (state->condStack.empty())
3940 warn(state->fileName,state->yyLineNr,
"the \\endcond does not have a corresponding \\cond in this file");
3945 const std::unique_ptr<preYY_CondCtx> &ctx = state->condStack.top();
3946 state->skip=ctx->skip;
3947 state->condStack.pop();
3954 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
3955 while (!state->condStack.empty())
3957 state->condStack.pop();
3968 const char *p=text.
data();
3971 if (c==
'@') result+=
"@@";
else result+=c;
3981 case '=':
return '#';
3982 case '/':
return '\\';
3983 case '\'':
return '^';
3984 case '(':
return '[';
3985 case ')':
return ']';
3986 case '!':
return '|';
3987 case '<':
return '{';
3988 case '>':
return '}';
3989 case '-':
return '~';
4003 return expr.
at(pos++);
4005 else if (rest && !rest->
isEmpty())
4014 int cc=yyinput(yyscanner);
4026 return expr.
at(pos);
4028 else if (rest && !rest->
isEmpty())
4036 int cc=yyinput(yyscanner);
4053 char cs[2];cs[0]=c;cs[1]=
'\0';
4069 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
4072 auto findDefine = [&undef,&name](
DefineMap &map)
4075 auto it = map.find(name.
str());
4088 Define *def = findDefine(state->localDefines);
4089 if (def==
nullptr && !undef)
4091 def = findDefine(state->contextDefines);
4098 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
4102 for (
const auto &ds : predefList)
4104 size_t i_equals=ds.find(
'=');
4105 size_t i_obrace=ds.find(
'(');
4106 size_t i_cbrace=ds.find(
')');
4107 bool nonRecursive = i_equals!=std::string::npos && i_equals>0 && ds[i_equals-1]==
':';
4109 if ((i_obrace==0) || (i_equals==0) || (i_equals==1 && ds[i_equals-1]==
':'))
4114 if (i_obrace<i_equals && i_cbrace<i_equals &&
4115 i_obrace!=std::string::npos && i_cbrace!=std::string::npos &&
4119 static const reg::Ex reId(R
"(\a\w*)");
4120 std::map<std::string,int> argMap;
4121 std::string args = ds.substr(i_obrace+1,i_cbrace-i_obrace-1);
4122 bool hasVarArgs = args.find(
"...")!=std::string::npos;
4128 for (; arg_it!=arg_end; ++arg_it)
4130 argMap.emplace(arg_it->
str(),count++);
4134 argMap.emplace(
"__VA_ARGS__",count++);
4138 std::string definition;
4139 std::string in=ds.substr(i_equals+1);
4145 for (; re_it!=re_end; ++re_it)
4147 const auto &match = *re_it;
4148 size_t pi = match.position();
4149 size_t l = match.length();
4150 if (pi>i) definition+=in.substr(i,pi-i);
4152 auto it = argMap.find(match.str());
4153 if (it!=argMap.end())
4155 int argIndex = it->second;
4157 marker.
sprintf(
" @%d ",argIndex);
4158 definition+=marker.
str();
4162 definition+=match.str();
4166 definition+=in.substr(i);
4169 std::string dname = ds.substr(0,i_obrace);
4178 def.
fileDef = state->yyFileDef;
4181 state->contextDefines.emplace(def.
name.
str(),def);
4187 else if (!ds.empty())
4191 if (i_equals==std::string::npos)
4198 int ine=
static_cast<int>(i_equals) - (nonRecursive ? 1 : 0);
4199 def.
name = ds.substr(0,ine);
4207 def.
fileDef = state->yyFileDef;
4209 state->contextDefines.emplace(def.
name.
str(),def);
4225 YY_EXTRA_TYPE state = preYYget_extra(
p->yyscanner);
4232 preYYlex_init_extra(&
p->state,&
p->yyscanner);
4238 preYYlex_destroy(
p->yyscanner);
4245 YY_EXTRA_TYPE state = preYYget_extra(
p->yyscanner);
4246 struct yyguts_t *yyg = (
struct yyguts_t*)
p->yyscanner;
4259 state->curlyCount=0;
4260 state->lexRulesPart=
false;
4261 state->nospaces=
FALSE;
4262 state->inputBuf=&input;
4263 state->inputBufPos=0;
4264 state->outputBuf=&output;
4265 state->includeStack.clear();
4266 state->expandedDict.clear();
4267 state->contextDefines.clear();
4268 state->pragmaSet.clear();
4269 state->condGuardCount=0;
4270 state->condGuardErrorLine=0;
4271 while (!state->levelGuard.empty()) state->levelGuard.pop();
4272 while (!state->condStack.empty()) state->condStack.pop();
4276 state->inputFileDef = state->yyFileDef;
4281 state->yyLineNr = 1;
4287 state->expectGuard =
guessSection(fileName).isHeader();
4288 state->guardName.clear();
4289 state->lastGuardName.clear();
4290 state->guardExpr.clear();
4292 preYYlex(yyscanner);
4294 while (!state->condStack.empty())
4296 const std::unique_ptr<preYY_CondCtx> &ctx = state->condStack.top();
4298 if (ctx->sectionId!=
" ") sectionInfo.
sprintf(
" with label '%s' ",
qPrint(ctx->sectionId.stripWhiteSpace()));
4299 warn(ctx->fileName,ctx->lineNr,
"Conditional section{}does not have "
4300 "a corresponding \\endcond command within this file.",sectionInfo);
4301 state->condStack.pop();
4306 if (!state->levelGuard.empty())
4308 if (yyextra->condGuardErrorLine!=0)
4310 warn(yyextra->condGuardErrorFileName,yyextra->condGuardErrorLine,
"{}",yyextra->condGuardErrorMessage);
4314 warn(state->fileName,state->yyLineNr,
"More #if's than #endif's found (might be in an included file).");
4322 std::string contents;
4330 bool startOfLine =
true;
4331 size_t content_size = output.size() +
4334 contents.reserve(content_size);
4336 while (pos<output.size())
4341 snprintf(lineNrStr,15,
"%05d ",line++);
4342 contents+=lineNrStr;
4344 contents += output[pos];
4345 startOfLine = output[pos]==
'\n';
4350 if (!contents.empty() && contents[contents.length()-1]!=
'\n')
4355 if (yyextra->contextDefines.size()>0)
4359 for (
auto &kv : yyextra->contextDefines)
4363 for (
auto &kv : yyextra->localDefines)
4377 for (
const auto &inc : state->includeRelations)
4379 auto toKind = [](
bool local,
bool imported) ->
IncludeKind
4395 if (inc->fromFileDef)
4397 inc->fromFileDef->addIncludeDependency(inc->toFileDef,inc->includeName,toKind(inc->local,inc->imported));
4399 if (inc->toFileDef && inc->fromFileDef)
4401 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.
Class to iterate 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 QCString expandVAOpt(const QCString &vaStr, bool hasOptionalArgs)
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)
void addTerminalCharIfMissing(std::string &s, char c)
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)