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->defLitText+=
' ';
1499 yyextra->lastCContext=YY_START;
1500 yyextra->commentCount=1;
1501 BEGIN(SkipCComment);
1503<DefineText>{CCS}[!*] {
1504 yyextra->defText+=yytext;
1505 yyextra->defLitText+=yytext;
1506 yyextra->lastCContext=YY_START;
1507 yyextra->commentCount=1;
1508 BEGIN(CopyCComment);
1510<DefineText>{CPPC}[!/]? {
1512 yyextra->lastCPPContext=YY_START;
1513 yyextra->defLitText+=
' ';
1514 BEGIN(SkipCPPComment);
1516<SkipCComment>[/]?{CCE} {
1517 if (yytext[0]==
'/')
outputChar(yyscanner,
'/');
1519 if (--yyextra->commentCount<=0)
1521 if (yyextra->lastCContext==Start)
1525 YY_CURRENT_BUFFER->yy_at_bol=1;
1527 BEGIN(yyextra->lastCContext);
1530<SkipCComment>{CPPC}("/")* {
1533<SkipCComment>{CCS} {
1537<SkipCond>{CMD}{CMD} { }
1538<SkipCond>^({B}*"*"+)?{B}{0,3}"~~~"[~]* {
1540 if (!markdownSupport || !yyextra->isSpecialComment)
1546 yyextra->fenceChar=
'~';
1548 BEGIN(SkipCondVerbatim);
1551<SkipCond>^({B}*"*"+)?{B}{0,3}"```"[`]* {
1553 if (!markdownSupport || !yyextra->isSpecialComment)
1559 yyextra->fenceChar=
'`';
1561 BEGIN(SkipCondVerbatim);
1564<SkipCComment>^({B}*"*"+)?{B}{0,3}"~~~"[~]* {
1566 if (!markdownSupport || !yyextra->isSpecialComment)
1573 yyextra->fenceChar=
'~';
1575 BEGIN(SkipVerbatim);
1578<SkipCComment>^({B}*"*"+)?{B}{0,3}"```"[`]* {
1580 if (!markdownSupport || !yyextra->isSpecialComment)
1587 yyextra->fenceChar=
'`';
1589 BEGIN(SkipVerbatim);
1592<SkipCComment>{CMD}{VERBATIM_LINE} |
1593<SkipCComment>{CMD}{LITERAL_BLOCK} {
1597<SkipCComment>{VERBATIM_LINE}.*/\n {
1600<SkipCComment>{LITERAL_BLOCK} {
1603 if (yyextra->isSpecialComment)
1606 BEGIN(SkipVerbatim);
1609<SkipCond>{CMD}{CMD}"cond"[ \t]+ {}
1610<SkipCond>{CMD}"cond"/\n |
1611<SkipCond>{CMD}"cond"[ \t]+ {
1615<SkipCComment>"{"[ \t]*"@code"/[ \t\n] {
1617 yyextra->javaBlock=1;
1618 BEGIN(JavaDocVerbatimCode);
1620<SkipCComment>"{"[ \t]*"@literal"/[ \t\n] {
1622 yyextra->javaBlock=1;
1623 BEGIN(JavaDocVerbatimCode);
1625<SkipCComment,SkipCPPComment>{CMD}{CMD}"cond"[ \t\n]+ {
1628<SkipCPPComment>{CMD}"cond"[ \t]+ {
1629 yyextra->ccomment=
TRUE;
1630 yyextra->condCtx=YY_START;
1633<SkipCComment>{CMD}"cond"[ \t]+ {
1634 yyextra->ccomment=
FALSE;
1635 yyextra->condCtx=YY_START;
1638<CondLineC,CondLineCpp>[!()&| \ta-z_A-Z0-9\x80-\xFF.\-]+ {
1642 if (YY_START==CondLineC)
1646 yyextra->ccomment=
TRUE;
1650 yyextra->ccomment=
FALSE;
1656 BEGIN(yyextra->condCtx);
1659<CondLineC,CondLineCpp>. {
1664 if (YY_START==CondLineC)
1668 yyextra->ccomment=
TRUE;
1672 yyextra->ccomment=
FALSE;
1678 BEGIN(yyextra->condCtx);
1681<SkipCComment,SkipCPPComment>{CMD}"cond"{WSopt}/\n {
1682 if (YY_START==SkipCComment)
1684 yyextra->ccomment=
TRUE;
1690 yyextra->ccomment=
FALSE;
1692 yyextra->condCtx=YY_START;
1693 yyextra->condGuardCount=0;
1697<SkipCond>\n { yyextra->yyLineNr++;
outputChar(yyscanner,
'\n'); }
1698<SkipCond>{VERBATIM_LINE}.*/\n { }
1699<SkipCond>{LITERAL_BLOCK} {
1701 yyextra->yyLineNr+=numNLs;
1702 for (
int i = 0; i < numNLs; i++)
outputChar(yyscanner,
'\n');
1704 BEGIN(SkipCondVerbatim);
1708<SkipCond>"#if"("def")? { yyextra->condGuardCount++; }
1709<SkipCond>"#endif" { yyextra->condGuardCount--; }
1710<SkipCond>[^\/\!*\\@\n#]+ { }
1711<SkipCond>{CPPC}[/!] { yyextra->ccomment=
FALSE; }
1712<SkipCond>{CCS}[*!] { yyextra->ccomment=
TRUE; }
1713<SkipCond,SkipCComment,SkipCPPComment>{CMD}{CMD}"endcond"/[^a-z_A-Z0-9\x80-\xFF] {
1719<SkipCond>{CMD}"endcond"/[^a-z_A-Z0-9\x80-\xFF] {
1720 bool oldSkip = yyextra->skip;
1722 if (oldSkip && !yyextra->skip)
1724 if (yyextra->ccomment)
1728 BEGIN(yyextra->condCtx);
1731<SkipCComment,SkipCPPComment>{CMD}"endcond"/[^a-z_A-Z0-9\x80-\xFF] {
1732 bool oldSkip = yyextra->skip;
1734 if (oldSkip && !yyextra->skip)
1736 BEGIN(yyextra->condCtx);
1739<SkipCondVerbatim>{LITERAL_BLOCK_END} {
1740 if (yytext[1]==
'f' && yyextra->blockName==&yytext[2])
1744 else if (&yytext[4]==yyextra->blockName)
1749<SkipVerbatim>{LITERAL_BLOCK_END} {
1751 if (yytext[1]==
'f' && yyextra->blockName==&yytext[2])
1753 BEGIN(SkipCComment);
1755 else if (&yytext[4]==yyextra->blockName)
1757 BEGIN(SkipCComment);
1760<SkipCondVerbatim>^({B}*"*"+)?{B}{0,3}"~~~"[~]* {
1761 if (yyextra->fenceSize==
getFenceSize(yytext,yyleng) && yyextra->fenceChar==
'~')
1766<SkipCondVerbatim>^({B}*"*"+)?{B}{0,3}"```"[`]* {
1767 if (yyextra->fenceSize==
getFenceSize(yytext,yyleng) && yyextra->fenceChar==
'`')
1772<SkipVerbatim>^({B}*"*"+)?{B}{0,3}"~~~"[~]* {
1774 if (yyextra->fenceSize==
getFenceSize(yytext,yyleng) && yyextra->fenceChar==
'~')
1776 BEGIN(SkipCComment);
1779<SkipVerbatim>^({B}*"*"+)?{B}{0,3}"```"[`]* {
1781 if (yyextra->fenceSize==
getFenceSize(yytext,yyleng) && yyextra->fenceChar==
'`')
1783 BEGIN(SkipCComment);
1786<SkipCondVerbatim>{CCE}|{CCS} { }
1787<SkipVerbatim>{CCE}|{CCS} {
1790<JavaDocVerbatimCode>"{" {
1791 if (yyextra->javaBlock==0)
1797 yyextra->javaBlock++;
1801<JavaDocVerbatimCode>"}" {
1802 if (yyextra->javaBlock==0)
1808 yyextra->javaBlock--;
1809 if (yyextra->javaBlock==0)
1812 BEGIN(SkipCComment);
1820<JavaDocVerbatimCode>\n {
1823<JavaDocVerbatimCode>. {
1826<SkipCondVerbatim>[^{*\\@\x06~`\n\/]+ { }
1827<SkipCComment,SkipVerbatim>[^{*\\@\x06~`\n\/]+ {
1830<SkipCComment,SkipVerbatim,SkipCondVerbatim>\n {
1831 yyextra->yyLineNr++;
1834<SkipCondVerbatim>. { }
1835<SkipCComment,SkipVerbatim>. {
1838<CopyCComment>[^*a-z_A-Z\x80-\xFF\n]*[^*a-z_A-Z\x80-\xFF\\\n] {
1839 yyextra->defLitText+=yytext;
1840 yyextra->defText+=
escapeAt(yytext);
1842<CopyCComment>\\[\r]?\n {
1843 yyextra->defLitText+=yytext;
1844 yyextra->defText+=
" ";
1845 yyextra->yyLineNr++;
1846 yyextra->yyMLines++;
1848<CopyCComment>{CCE} {
1849 yyextra->defLitText+=yytext;
1850 yyextra->defText+=yytext;
1851 BEGIN(yyextra->lastCContext);
1854 yyextra->yyLineNr++;
1855 yyextra->defLitText+=yytext;
1856 yyextra->defText+=
' ';
1858<RemoveCComment>{CCE}{B}*"#" {
1859 if (yyextra->lastCContext==SkipCPPBlock)
1868<RemoveCComment>{CCE} { BEGIN(yyextra->lastCContext); }
1869<RemoveCComment>{CPPC}
1870<RemoveCComment>{CCS}
1871<RemoveCComment>[^*\x06\n]+
1872<RemoveCComment>\n { yyextra->yyLineNr++;
outputChar(yyscanner,
'\n'); }
1874<SkipCPPComment>[^\n\/\\@]+ {
1877<SkipCPPComment,RemoveCPPComment>\n {
1879 BEGIN(yyextra->lastCPPContext);
1881<SkipCPPComment>{CCS} {
1884<SkipCPPComment>{CPPC} {
1887<SkipCPPComment>[^\x06\@\\\n]+ {
1893<RemoveCPPComment>{CCS}
1894<RemoveCPPComment>{CPPC}
1895<RemoveCPPComment>[^\x06\n]+
1897<DefineText>"__VA_OPT__("{B}*"##" {
1898 warn(yyextra->fileName,yyextra->yyLineNr,
1899 "'##' may not appear at the beginning of a __VA_OPT__()",
1900 yyextra->defName,yyextra->defLitText.stripWhiteSpace());
1901 yyextra->defText+=
"__VA_OPT__(";
1902 yyextra->defLitText+=
"__VA_OPT__(";
#define warn(file, line, fmt,...)
1904<DefineText>"#"/"__VA_OPT__" {
1905 yyextra->defText+=yytext;
1906 yyextra->defLitText+=yytext;
1908<DefineText>"#"/{IDSTART} {
1910 yyextra->quoteArg=
TRUE;
1911 yyextra->idStart=
true;
1912 yyextra->defLitText+=yytext;
1914<DefineText,CopyCComment>{ID} {
1915 yyextra->defLitText+=yytext;
1916 if (YY_START == DefineText)
outputSpaces(yyscanner,yytext);
1917 if (yyextra->quoteArg)
1919 yyextra->defText+=
"\"";
1921 if (yyextra->defArgs>0)
1923 auto it = yyextra->argMap.find(yytext);
1924 if (it!=yyextra->argMap.end())
1927 yyextra->defText+=
'@';
1932 if (yyextra->idStart)
1934 warn(yyextra->fileName,yyextra->yyLineNr,
1935 "'#' is not followed by a macro parameter '{}': '{}'",
1936 yyextra->defName,yyextra->defLitText.stripWhiteSpace());
1938 yyextra->defText+=yytext;
1943 yyextra->defText+=yytext;
1945 if (yyextra->quoteArg)
1947 yyextra->defText+=
"\"";
1949 yyextra->quoteArg=
FALSE;
1950 yyextra->idStart=
false;
QCString & setNum(short n)
1953 yyextra->defLitText+=yytext;
1954 yyextra->defText+=yytext;
1956<DefineText>\\[\r]?\n {
1957 yyextra->defLitText+=yytext;
1960 yyextra->defText +=
' ';
1961 yyextra->yyLineNr++;
1962 yyextra->yyMLines++;
1966 yyextra->defText = yyextra->defText.stripWhiteSpace();
1967 if (yyextra->defText.startsWith(
"##"))
1969 warn(yyextra->fileName,yyextra->yyLineNr,
1970 "'##' cannot occur at the beginning of a macro definition '{}': '{}'",
1971 yyextra->defName,yyextra->defLitText.stripWhiteSpace());
1973 else if (yyextra->defText.endsWith(
"##"))
1975 warn(yyextra->fileName,yyextra->yyLineNr,
1976 "'##' cannot occur at the end of a macro definition '{}': '{}'",
1977 yyextra->defName,yyextra->defLitText.stripWhiteSpace());
1979 else if (yyextra->defText.endsWith(
"#"))
1981 warn(yyextra->fileName,yyextra->yyLineNr,
1982 "expected formal parameter after # in macro definition '{}': '{}'",
1983 yyextra->defName,yyextra->defLitText.stripWhiteSpace());
1988 yyextra->defLitText=yyextra->defLitText.left(yyextra->defLitText.length()-
comment.length()-1);
1991 yyextra->defLitText+=yytext;
1994 if (yyextra->includeStack.empty() || yyextra->curlyCount>0)
1998 def=
isDefined(yyscanner,yyextra->defName);
2012 def->
name = yyextra->defName;
2014 def->
nargs = yyextra->defArgs;
2016 def->
lineNr = yyextra->yyLineNr-yyextra->yyMLines;
2021 if (def->
fileName != yyextra->fileName && !yyextra->expandOnlyPredef)
addDefine(yyscanner);
2025 yyextra->argMap.clear();
2026 yyextra->yyLineNr++;
2028 yyextra->lastGuardName.clear();
2032 yyextra->defText +=
' ';
2033 yyextra->defLitText+=yytext;
2036 yyextra->defText +=
"##";
2037 yyextra->defLitText+=yytext;
2040 yyextra->defText +=
"@@";
2041 yyextra->defLitText+=yytext;
2045 yyextra->defText += *yytext;
2046 yyextra->defLitText+=yytext;
2047 if (!yyextra->insideComment)
2049 BEGIN(SkipDoubleQuote);
2052<DefineText>{NUMBER} {
2054 yyextra->defText += yytext;
2055 yyextra->defLitText+=yytext;
2059 yyextra->defText += *yytext;
2060 yyextra->defLitText+=yytext;
2061 if (!yyextra->insideComment)
2063 BEGIN(SkipSingleQuote);
2066<SkipDoubleQuote>{CPPC}[/]? {
outputSpaces(yyscanner,yytext);
2067 yyextra->defText += yytext;
2068 yyextra->defLitText+=yytext;
2070<SkipDoubleQuote>{CCS}[*]? {
outputSpaces(yyscanner,yytext);
2071 yyextra->defText += yytext;
2072 yyextra->defLitText+=yytext;
2074<SkipDoubleQuote>\" {
2076 yyextra->defText += *yytext;
2077 yyextra->defLitText+=yytext;
2080<SkipSingleQuote,SkipDoubleQuote>\\. {
2082 yyextra->defText += yytext;
2083 yyextra->defLitText+=yytext;
2085<SkipSingleQuote>\' {
2087 yyextra->defText += *yytext;
2088 yyextra->defLitText+=yytext;
2091<SkipDoubleQuote,SkipSingleQuote>. {
outputSpace(yyscanner,yytext[0]);
2092 yyextra->defText += *yytext;
2093 yyextra->defLitText += *yytext;
2096 yyextra->defText += *yytext;
2097 yyextra->defLitText += *yytext;
2100 TRACE(
"End of include file");
2102 if (yyextra->includeStack.empty())
2104 TRACE(
"Terminating scanner");
2109 if (!yyextra->levelGuard.empty())
2111 if (yyextra->condGuardErrorLine!=0)
2113 warn(yyextra->condGuardErrorFileName,yyextra->condGuardErrorLine,
"{}",yyextra->condGuardErrorMessage);
2117 warn(yyextra->fileName,yyextra->yyLineNr,
"More #endif's than #if's found.");
2120 QCString toFileName = yyextra->fileName;
2121 const std::unique_ptr<FileState> &fs=yyextra->includeStack.back();
2123 YY_BUFFER_STATE oldBuf = YY_CURRENT_BUFFER;
2124 yy_switch_to_buffer( fs->bufState, yyscanner );
2125 yy_delete_buffer( oldBuf, yyscanner );
2126 yyextra->yyLineNr = fs->lineNr;
2128 yyextra->inputBuf = fs->oldFileBuf;
2129 yyextra->inputBufPos = fs->oldFileBufPos;
2130 yyextra->curlyCount = fs->curlyCount;
2131 yyextra->levelGuard = fs->levelGuard;
2133 TRACE(
"switching to {}",yyextra->fileName);
2138 lineStr.sprintf(
"# %d \"%s\" 2",yyextra->yyLineNr,
qPrint(yyextra->fileName));
2141 yyextra->includeStack.pop_back();
2164 for (
const auto &kv : yyextra->localDefines)
2166 auto pair = yyextra->contextDefines.insert(kv);
2169 yyextra->contextDefines.erase(pair.first);
2170 yyextra->contextDefines.insert(kv);
2173 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)
2178 if (YY_START==SkipVerbatim || YY_START == SkipCondVerbatim || YY_START==SkipCond || YY_START==IDLquote || YY_START == PragmaOnce)
2185 yyextra->lastCContext=YY_START;
2186 yyextra->commentCount=1;
2189 yyextra->isSpecialComment =
true;
2190 yyextra->lastGuardName.clear();
2194 yyextra->isSpecialComment =
false;
2196 BEGIN(SkipCComment);
2200 if (YY_START==SkipVerbatim || YY_START == SkipCondVerbatim || YY_START==SkipCond ||
getLanguageFromFileName(yyextra->fileName)==SrcLangExt::Fortran || YY_START==IDLquote || YY_START == PragmaOnce)
2204 else if (YY_START==RulesRoundDouble)
2211 yyextra->lastCPPContext=YY_START;
2214 yyextra->isSpecialComment =
true;
2215 yyextra->lastGuardName.clear();
2219 yyextra->isSpecialComment =
false;
2221 BEGIN(SkipCPPComment);
2226 yyextra->yyLineNr++;
2229 yyextra->expectGuard =
FALSE;
2239 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
2240 int bytesInBuf =
static_cast<int>(state->inputBuf->size())-state->inputBufPos;
2241 int bytesToCopy = std::min(max_size,bytesInBuf);
2242 memcpy(buf,state->inputBuf->data()+state->inputBufPos,bytesToCopy);
2243 state->inputBufPos+=bytesToCopy;
2249 yy_size_t fenceSize = 0;
2250 for (
size_t i = 0; i < leng; i++)
2252 if (txt[i] !=
' ' && txt[i] !=
'*' && txt[i] !=
'\t')
break;
2255 return leng-fenceSize;
2260 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
2265 if (state->yyFileDef==
nullptr)
2271 if (state->yyFileDef && state->yyFileDef->isReference()) state->yyFileDef=
nullptr;
2276 state->isSource = section.isHeader() || section.isSource();
2281 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
2282 state->levelGuard.push(
false);
2288 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
2290 if (!state->levelGuard.empty())
2292 state->levelGuard.pop();
2296 if (state->condGuardErrorLine!=0)
2298 warn(state->condGuardErrorFileName,state->condGuardErrorLine,
"{}",state->condGuardErrorMessage);
2302 warn(state->fileName,state->yyLineNr,
"More #endif's than #if's found.");
2309 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
2310 if (state->levelGuard.empty())
2312 warn(state->fileName,state->yyLineNr,
"Found an #else without a preceding #if.");
2317 return state->levelGuard.top();
2323 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
2324 state->levelGuard.top()=value;
2330 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
2331 alreadyProcessed =
FALSE;
2332 std::unique_ptr<FileState> fs;
2343 if (state->curlyCount==0)
2348 alreadyProcessed =
TRUE;
2355 alreadyProcessed = std::any_of(
2356 state->includeStack.begin(),
2357 state->includeStack.end(),
2358 [absName](
const std::unique_ptr<FileState> &lfs)
2359 { return lfs->fileName==absName; }
2362 if (alreadyProcessed)
2369 fs = std::make_unique<FileState>();
2378 fs->oldFileBuf = state->inputBuf;
2379 fs->oldFileBufPos = state->inputBufPos;
2387 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
2398 else if (alreadyProcessed)
2403 if (localInclude && !state->fileName.isEmpty())
2405 FileInfo fi(state->fileName.str());
2416 else if (alreadyProcessed)
2422 if (state->pathList.empty())
2426 for (
auto path : state->pathList)
2428 QCString absName = path+
"/"+fileName;
2438 else if (alreadyProcessed)
2471 if (i>=0 && s[i]==
'*')
2474 while (i>0 && !(s[i-1]==
'/' && s[i]==
'*')) i--;
2481 return ((s[i+1]==
'*' || s[i+1]==
'!') && s[i+2]==
'<') ? &s[i-1] :
"";
2513 bool inString=
FALSE;
2518 if (!inString && !inChar)
2520 while (i<s.
length() && !inString && !inChar)
2541 while (i<s.
length() && inChar)
2562 while (i<s.
length() && inString)
2591 std::string e = expr.
str();
2592 static const reg::Ex r(R
"(\s*##\s*)");
2601 const auto &match = *it;
2602 size_t n = match.position();
2603 size_t l = match.length();
2605 if (n+l+1<e.length() && e[
static_cast<int>(n+l)]==
'@' && expr[
static_cast<int>(n+l+1)]==
'-')
2612 e=e.substr(0,n)+e.substr(n+l);
2613 int k=
static_cast<int>(n)-1;
2614 while (k>=0 &&
isId(e[k])) k--;
2615 if (k>0 && e[k]==
'-' && e[k-1]==
'@')
2618 e=e.substr(0,k-1)+e.substr(k+1);
2636 struct yyguts_t * yyg = (
struct yyguts_t*)yyscanner;
2644 while ((cc=
getNextChar(yyscanner,expr,rest,pos))!=EOF && cc!=0)
2660 int &cc, uint32_t &j,
int &len)
2662 bool changed =
false;
2667 while ((cc=
getCurrentChar(yyscanner,expr,rest,j))!=EOF && cc!=
'\n' && isspace(cc))
2675 int prevChar =
'\0';
2677 if ((cc=
getCurrentChar(yyscanner,expr,rest,j))!=EOF && cc ==
'*')
2679 while ((cc=
getNextChar(yyscanner,expr,rest,j))!=EOF && cc!=0)
2681 if (cc ==
'/' && prevChar ==
'*')
break;
2684 if (cc != EOF) changed =
true;
2697 int vl =
static_cast<int>(vaStr.
length());
2698 while ((vo = vaStr.
find(
"__VA_OPT__(",vp))!=-1)
2700 bool hasHash = vo>0 && vaStr.
at(vo-1)==
'#';
2703 result+=vaStr.
mid(vp,vo-vp-1);
2708 result+=vaStr.
mid(vp,vo-vp);
2712 while (bc>0 && ve<vl)
2714 if (vaStr[ve]==
')') bc--;
2715 else if (vaStr[ve]==
'(') bc++;
2719 if (bc==0 && hasOptionalArgs)
2731 result+=vaStr.
mid(vp);
2763 std::map<std::string,std::string> argTable;
2766 int argCountNonEmpty=0;
2772 while ((cc=
getNextChar(yyscanner,expr,rest,j))!=EOF && cc!=0)
2780 while (!done && (argCount<def->nargs || def->
varArgs) &&
2781 ((cc=
getNextChar(yyscanner,expr,rest,j))!=EOF && cc!=0)
2790 while ((cc=
getNextChar(yyscanner,expr,rest,j))!=EOF && cc!=0)
2794 if (c==
'\'' || c==
'\"')
2816 else if (c==
')' || c==
',')
2829 argKey.
sprintf(
"@%d",argCount++);
2830 if (c==
',' || !arg.
isEmpty()) argCountNonEmpty++;
2844 while (!found && (cc=
getNextChar(yyscanner,expr,rest,j))!=EOF && cc!=0)
2851 if ((cc=
getNextChar(yyscanner,expr,rest,j))==EOF || cc==0)
break;
2861 while (!found && (cc=
getNextChar(yyscanner,expr,rest,j))!=EOF && cc!=0)
2868 if ((cc=
getNextChar(yyscanner,expr,rest,j))==EOF || cc==0)
break;
2876 char prevChar =
'\0';
2880 while ((cc=
getNextChar(yyscanner,expr,rest,j))!=EOF && cc!=0)
2884 if (c ==
'/' && prevChar ==
'*')
break;
2897 if (argCount==def->
nargs ||
2908 bool inString=
FALSE;
2918 else if (d.
at(k+1)==
'-')
2929 if (l>=0 && d.
at(l)==
'"') l--;
2930 while (l>=0 && d.
at(l)==
' ') l--;
2931 if (l>0 && d.
at(l)==
'#' && d.
at(l-1)==
'#') hash=
TRUE;
2934 while (k<d.
length() && d.
at(k)>=
'0' && d.
at(k)<=
'9') key+=d.
at(k++);
2939 if (l<(
int)d.
length() && d.
at(l)==
'"') l++;
2940 while (l<(
int)d.
length() && d.
at(l)==
' ') l++;
2941 if (l<(
int)d.
length()-1 && d.
at(l)==
'#' && d.
at(l+1)==
'#') hash=
TRUE;
2944 auto it = argTable.find(key.
str());
2945 if (it!=argTable.end())
2965 if (hash && substArg.
isEmpty())
2976 if (!inString && d.
at(k)==
'\"')
2980 else if (k>2 && inString && d.
at(k)==
'\"' && (d.
at(k-1)!=
'\\' || d.
at(k-2)==
'\\'))
3004 while (p<(
int)expr.
length())
3006 char c=expr.
at(p++);
3011 else if (isalpha(c) || c==
'_')
3021 if (p<(
int)expr.
length()) c=expr.
at(p);
3022 while (p<(
int)expr.
length() && (c!=
'"' || (pc==
'\\' && ppc!=
'\\')))
3030 if (p<(
int)expr.
length()) ++p;
3036 if (p<(
int)expr.
length())
3042 while (p<(
int)expr.
length() && !(pc==
'*' && c==
'/'))
3055#define MAX_EXPANSION_DEPTH 50
3059 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
3060 if (!state->nospaces)
3063 char ccPrev = pos==0 || (int)expr.
length()<pos ? state->prevChar : expr.
at(pos-1);
3064 QCString leftSpace = ccPrev!=
':' && ccPrev!=
' ' ?
" " :
"";
3069 uint32_t j=(uint32_t)resultExpr.
length();
3070 while ((ccNext=
getNextChar(yyscanner,resultExpr,
nullptr,j))!=EOF && ccNext==
' ') { }
3071 if (ccNext != EOF)
unputChar(yyscanner,resultExpr,
nullptr,j,(
char)ccNext);
3075 ccNext=restExpr.
at(0);
3078 QCString rightSpace = ccNext!=
':' && ccNext!=
' ' ?
" " :
"";
3081 resultExpr=leftSpace+resultExpr+rightSpace;
3091 struct yyguts_t * yyg = (
struct yyguts_t*)yyscanner;
3092 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
3099 if (state->expanded.find(expr.
str())!=state->expanded.end() &&
3107 state->expanded.insert(expr.
str());
3111 bool definedTest=
FALSE;
3112 int i=pos, l=0, p=0, len=0;
3117 bool replaced=
FALSE;
3119 macroName=expr.
mid(p,l);
3124 expr=expr.
left(p)+resultExpr+restExpr;
3126 else if (p<2 || !(expr.
at(p-2)==
'@' && expr.
at(p-1)==
'-'))
3128 if (state->expandedDict.find(macroName.
str())==state->expandedDict.end())
3130 bool expanded=
false;
3134 if (yyextra->expandOnlyPredef && def && !def->
isPredefined) def=
nullptr;
3135 if (macroName==
"defined")
3140 else if (definedTest)
3142 if (def) expMacro =
" 1 ";
else expMacro =
" 0 ";
3147 else if (def && def->
nargs==-1)
3156 else if (def && def->
nargs>=0)
3167 resultExpr=expMacro;
3174 state->expandedDict.emplace(
toStdString(macroName),def);
3176 state->expandedDict.erase(
toStdString(macroName));
3185 expr=expr.
left(p)+resultExpr+restExpr;
3241 if (inputStr==
nullptr)
return inputStr;
3242 char term = *inputStr;
3243 if (
term!=
'\'' &&
term!=
'"')
return inputStr;
3248 while ((c=*inputStr))
3277 static const std::vector<std::string> signs = {
"signed",
"unsigned" };
3278 struct TypeInfo { std::string name;
size_t size; };
3279 static const std::vector<TypeInfo> types = {
3280 {
"short int",
sizeof(
short int) },
3281 {
"long long int",
sizeof(
long long int) },
3282 {
"long int",
sizeof(
long int) },
3283 {
"long long",
sizeof(
long long) },
3284 {
"long double",
sizeof(
long double) },
3285 {
"int",
sizeof(int) },
3286 {
"short",
sizeof(short) },
3287 {
"bool",
sizeof(bool) },
3288 {
"long",
sizeof(long) },
3289 {
"char",
sizeof(char) },
3290 {
"float",
sizeof(float) },
3291 {
"double",
sizeof(double) },
3297 auto process_cast_or_sizeof = [](
const char *p) -> std::pair<const char *,size_t>
3300 while (*q==
' ' || *q==
'\t') q++;
3302 size_t size =
sizeof(int);
3303 for (
const auto &sgn : signs)
3305 if (
qstrncmp(q,sgn.c_str(),sgn.length())==0) { q+=sgn.length(); found=
true; }
3307 if (!found || *q==
' ' || *q==
'\t' || *q==
')')
3309 while (*q==
' ' || *q==
'\t') q++;
3310 for (
const auto &t : types)
3312 if (
qstrncmp(q,t.name.c_str(),t.name.length())==0)
3314 q += t.name.length();
3319 while (*q==
' ' || *q==
'\t') q++;
3320 if (*q==
')')
return std::make_pair(++q,size);
3322 return std::make_pair(
nullptr,0);
3327 const char *p=s.
data();
3337 const char *q = process_cast_or_sizeof(p+1).first;
3347 const char *q = p+6;
3348 while (*q==
' ' || *q==
'\t') q++;
3351 auto r = process_cast_or_sizeof(q+1);
3368 else if (*(p+1)==
'E')
3374 else if (isdigit(c))
3384 else if (c==
'd' && !inNum)
3395 while ((c=*p) &&
isId(c)) p++;
3398 else if ((isalpha(c) || c==
'_') && !inNum)
3402 while ((c=*p) &&
isId(c)) p++;
3403 while ((c=*p) && isspace((uint8_t)c)) p++;
3410 if (c==
'(') count++;
3414 if (count==0)
break;
3422 while (*p && !(pc==
'*' && c==
'/'))
3439 while (*p && !(pc==
'*' && c==
'/'))
3456 char lc=(char)tolower(c);
3473 const char *p=s.
data();
3498 while (*p && !(pc==
'*' && c==
'/'))
3500 if (*p==
'@' && *(p+1)==
'@')
3543 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
3547 state->expanded.clear();
3553 return state->constExpParser.parse(state->fileName.data(),state->yyLineNr,e.
str(),ee.
str());
3562 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
3563 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
3564 state->prevChar = yyscanner->yytext_r > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ? *(yyscanner->yytext_r-1) : 0;
3566 state->expanded.
clear();
3576 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
3578 if (name ==
"__LINE__")
3582 else if (name ==
"__FILE__")
3585 resultExpr += yyextra->fileName;
3588 else if (name ==
"__DATE__")
3591 resultExpr += __DATE__;
3594 else if (name ==
"__TIME__")
3597 resultExpr += __TIME__;
3605 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
3607 def.
name = state->defName;
3609 def.
nargs = state->defArgs;
3611 def.
fileDef = state->yyFileDef;
3612 def.
lineNr = state->yyLineNr-state->yyMLines;
3614 def.
varArgs = state->defVarArgs;
3624 auto it = state->localDefines.find(def.
name.
str());
3625 if (it!=state->localDefines.end())
3627 state->localDefines.erase(it);
3629 state->localDefines.emplace(def.
name.
str(),def);
3634 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
3635 if (state->skip)
return;
3640 define.
lineNr = state->yyLineNr - state->yyMLines;
3642 define.
name = state->defName;
3643 define.
args = state->defArgsStr;
3644 define.
fileDef = state->inputFileDef;
3646 QCString litText = state->defLitText;
3647 int l=litText.
find(
'\n');
3657 const char *p=litText.
data()+k;
3659 while ((c=*p++) && (c==
' ' || c==
'\t')) k++;
3663 if (litTextStripped.
contains(
'\n')>=1)
3672 state->macroDefinitions.push_back(define);
3678 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
3679 if (state->includeStack.empty() || state->curlyCount>0) (*state->outputBuf)+=c;
3684 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
3685 if (state->includeStack.empty() || state->curlyCount>0) (*state->outputBuf)+=std::string_view(a,len);
3690 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
3691 if (state->includeStack.empty() || state->curlyCount>0) (*state->outputBuf)+=a.
str();
3713 struct yyguts_t * yyg = (
struct yyguts_t*)yyscanner;
3714 if (!yyextra->defContinue)
return;
3715 for (
int i=0; i< (int)yyleng; i++)
3717 if (yytext[i] ==
'\t')
3718 yyextra->defExtraSpacing+=
'\t';
3720 yyextra->defExtraSpacing+=
' ';
3726 struct yyguts_t * yyg = (
struct yyguts_t*)yyscanner;
3727 yyextra->fenceSize=0;
3729 if (yytext[1]==
'f' && ((c=yytext[2])==
'[' || c==
'{' || c==
'(' || c==
'$'))
3733 case '[': yyextra->blockName=
"]";
break;
3734 case '{': yyextra->blockName=
"}";
break;
3735 case '(': yyextra->blockName=
")";
break;
3736 case '$': yyextra->blockName=
"$";
break;
3739 yyextra->blockName=yyextra->blockName.stripWhiteSpace();
3746 yyextra->blockName=
"uml";
3750 int i = bn.
find(
'{');
3752 yyextra->blockName=bn;
3760 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
3765 (inc.
at(i)==
' ' || inc.
at(i)==
'"' || inc.
at(i)==
'<')
3770 bool localInclude = s>0 && inc.
at(s-1)==
'"';
3773 while (i<inc.
length() && inc.
at(i)!=
'"' && inc.
at(i)!=
'>') i++;
3775 if (s<inc.
length() && i>s)
3785 QCString oldFileName = state->fileName;
3786 FileDef *oldFileDef = state->yyFileDef;
3787 int oldLineNr = state->yyLineNr;
3793 std::unique_ptr<FileState> fs;
3794 bool alreadyProcessed =
FALSE;
3796 fs=
findFile(yyscanner,absIncFileName,localInclude,alreadyProcessed);
3807 for (i=0;i<state->includeStack.size();i++)
3814 if (state->includeStack.empty() && oldFileDef)
3816 PreIncludeInfo *ii = state->includeRelations.find(absIncFileName);
3821 state->includeRelations.add(
3824 ambig ?
nullptr : incFd,
3832 struct yyguts_t * yyg = (
struct yyguts_t*)yyscanner;
3833 fs->bufState = YY_CURRENT_BUFFER;
3834 fs->lineNr = oldLineNr;
3835 fs->fileName = oldFileName;
3836 fs->curlyCount = state->curlyCount;
3838 fs->lexRulesPart = state->lexRulesPart;
3839 fs->levelGuard = state->levelGuard;
3840 while (!state->levelGuard.empty()) state->levelGuard.pop();
3841 state->lexRulesPart =
false;
3844 state->includeStack.push_back(std::move(fs));
3854 state->expectGuard=
TRUE;
3855 state->inputBuf = &fs_ptr->
fileBuf;
3856 state->inputBufPos=0;
3857 yy_switch_to_buffer(yy_create_buffer(0,
YY_BUF_SIZE, yyscanner),yyscanner);
3861 if (alreadyProcessed)
3869 if (state->includeStack.empty() && oldFileDef)
3871 PreIncludeInfo *ii = state->includeRelations.find(absIncFileName);
3876 ii = state->includeRelations.add(absIncFileName,
3878 ambig ?
nullptr : incFd,
3888 for (i=0;i<state->includeStack.size();i++)
3892 if (alreadyProcessed)
3902 if (localInclude && !state->includeStack.empty() && state->curlyCount>0 && !alreadyProcessed)
3904 warn(state->fileName,state->yyLineNr,
"include file {} not found, perhaps you forgot to add its directory to INCLUDE_PATH?",incFileName);
3914 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
3917 bool expResult = prs.
parse(state->fileName.data(),state->yyLineNr,sectId.
data());
3918 state->condStack.emplace(std::make_unique<preYY_CondCtx>(state->fileName,state->yyLineNr,sectId,state->skip));
3928 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
3929 if (state->condGuardCount>0 && state->condGuardErrorLine==0)
3931 state->condGuardErrorLine = state->yyLineNr;
3932 state->condGuardErrorFileName = state->fileName;
3933 state->condGuardErrorMessage =
"more #if's than #endif's in \\cond..\\endcond section";
3935 else if (state->condGuardCount<0 && state->condGuardErrorLine==0)
3937 state->condGuardErrorLine = state->yyLineNr;
3938 state->condGuardErrorFileName = state->fileName;
3939 state->condGuardErrorMessage =
"more #endif's than #if's in \\cond..\\endcond section";
3943 state->condGuardErrorLine = 0;
3945 if (state->condStack.empty())
3947 warn(state->fileName,state->yyLineNr,
"the \\endcond does not have a corresponding \\cond in this file");
3952 const std::unique_ptr<preYY_CondCtx> &ctx = state->condStack.top();
3953 state->skip=ctx->skip;
3954 state->condStack.pop();
3961 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
3962 while (!state->condStack.empty())
3964 state->condStack.pop();
3975 const char *p=text.
data();
3978 if (c==
'@') result+=
"@@";
else result+=c;
3988 case '=':
return '#';
3989 case '/':
return '\\';
3990 case '\'':
return '^';
3991 case '(':
return '[';
3992 case ')':
return ']';
3993 case '!':
return '|';
3994 case '<':
return '{';
3995 case '>':
return '}';
3996 case '-':
return '~';
4010 return expr.
at(pos++);
4012 else if (rest && !rest->
isEmpty())
4021 int cc=yyinput(yyscanner);
4033 return expr.
at(pos);
4035 else if (rest && !rest->
isEmpty())
4043 int cc=yyinput(yyscanner);
4060 char cs[2];cs[0]=c;cs[1]=
'\0';
4076 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
4079 auto findDefine = [&undef,&name](
DefineMap &map)
4082 auto it = map.find(name.
str());
4095 Define *def = findDefine(state->localDefines);
4096 if (def==
nullptr && !undef)
4098 def = findDefine(state->contextDefines);
4105 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
4109 for (
const auto &ds : predefList)
4111 size_t i_equals=ds.find(
'=');
4112 size_t i_obrace=ds.find(
'(');
4113 size_t i_cbrace=ds.find(
')');
4114 bool nonRecursive = i_equals!=std::string::npos && i_equals>0 && ds[i_equals-1]==
':';
4116 if ((i_obrace==0) || (i_equals==0) || (i_equals==1 && ds[i_equals-1]==
':'))
4121 if (i_obrace<i_equals && i_cbrace<i_equals &&
4122 i_obrace!=std::string::npos && i_cbrace!=std::string::npos &&
4126 static const reg::Ex reId(R
"(\a\w*)");
4127 std::map<std::string,int> argMap;
4128 std::string args = ds.substr(i_obrace+1,i_cbrace-i_obrace-1);
4129 bool hasVarArgs = args.find(
"...")!=std::string::npos;
4135 for (; arg_it!=arg_end; ++arg_it)
4137 argMap.emplace(arg_it->
str(),count++);
4141 argMap.emplace(
"__VA_ARGS__",count++);
4145 std::string definition;
4146 std::string in=ds.substr(i_equals+1);
4152 for (; re_it!=re_end; ++re_it)
4154 const auto &match = *re_it;
4155 size_t pi = match.position();
4156 size_t l = match.length();
4157 if (pi>i) definition+=in.substr(i,pi-i);
4159 auto it = argMap.find(match.str());
4160 if (it!=argMap.end())
4162 int argIndex = it->second;
4164 marker.
sprintf(
" @%d ",argIndex);
4165 definition+=marker.
str();
4169 definition+=match.str();
4173 definition+=in.substr(i);
4176 std::string dname = ds.substr(0,i_obrace);
4185 def.
fileDef = state->yyFileDef;
4188 state->contextDefines.emplace(def.
name.
str(),def);
4194 else if (!ds.empty())
4198 if (i_equals==std::string::npos)
4205 int ine=
static_cast<int>(i_equals) - (nonRecursive ? 1 : 0);
4206 def.
name = ds.substr(0,ine);
4214 def.
fileDef = state->yyFileDef;
4216 state->contextDefines.emplace(def.
name.
str(),def);
4232 YY_EXTRA_TYPE state = preYYget_extra(
p->yyscanner);
4239 preYYlex_init_extra(&
p->state,&
p->yyscanner);
4245 preYYlex_destroy(
p->yyscanner);
4252 YY_EXTRA_TYPE state = preYYget_extra(
p->yyscanner);
4253 struct yyguts_t *yyg = (
struct yyguts_t*)
p->yyscanner;
4266 state->curlyCount=0;
4267 state->lexRulesPart=
false;
4268 state->nospaces=
FALSE;
4269 state->inputBuf=&input;
4270 state->inputBufPos=0;
4271 state->outputBuf=&output;
4272 state->includeStack.clear();
4273 state->expandedDict.clear();
4274 state->contextDefines.clear();
4275 state->pragmaSet.clear();
4276 state->condGuardCount=0;
4277 state->condGuardErrorLine=0;
4278 while (!state->levelGuard.empty()) state->levelGuard.pop();
4279 while (!state->condStack.empty()) state->condStack.pop();
4283 state->inputFileDef = state->yyFileDef;
4288 state->yyLineNr = 1;
4294 state->expectGuard =
guessSection(fileName).isHeader();
4295 state->guardName.clear();
4296 state->lastGuardName.clear();
4297 state->guardExpr.clear();
4299 preYYlex(yyscanner);
4301 while (!state->condStack.empty())
4303 const std::unique_ptr<preYY_CondCtx> &ctx = state->condStack.top();
4305 if (ctx->sectionId!=
" ") sectionInfo.
sprintf(
" with label '%s' ",
qPrint(ctx->sectionId.stripWhiteSpace()));
4306 warn(ctx->fileName,ctx->lineNr,
"Conditional section{}does not have "
4307 "a corresponding \\endcond command within this file.",sectionInfo);
4308 state->condStack.pop();
4313 if (!state->levelGuard.empty())
4315 if (yyextra->condGuardErrorLine!=0)
4317 warn(yyextra->condGuardErrorFileName,yyextra->condGuardErrorLine,
"{}",yyextra->condGuardErrorMessage);
4321 warn(state->fileName,state->yyLineNr,
"More #if's than #endif's found (might be in an included file).");
4329 std::string contents;
4337 bool startOfLine =
true;
4338 size_t content_size = output.size() +
4341 contents.reserve(content_size);
4343 while (pos<output.size())
4348 snprintf(lineNrStr,15,
"%05d ",line++);
4349 contents+=lineNrStr;
4351 contents += output[pos];
4352 startOfLine = output[pos]==
'\n';
4357 if (!contents.empty() && contents[contents.length()-1]!=
'\n')
4362 if (yyextra->contextDefines.size()>0)
4366 for (
auto &kv : yyextra->contextDefines)
4370 for (
auto &kv : yyextra->localDefines)
4384 for (
const auto &inc : state->includeRelations)
4386 auto toKind = [](
bool local,
bool imported) ->
IncludeKind
4402 if (inc->fromFileDef)
4404 inc->fromFileDef->addIncludeDependency(inc->toFileDef,inc->includeName,toKind(inc->local,inc->imported));
4406 if (inc->toFileDef && inc->fromFileDef)
4408 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)