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"|"mermaid"|"startuml"|"code"("{"[^}]*"}")?){BN}+
376VERBATIM_END {CMD}("endverbatim"|"endiliteral"|"endlatexonly"|"endhtmlonly"|"endxmlonly"|"enddocbookonly"|"endrtfonly"|"endmanonly"|"enddot"|"endmsc"|"endmermaid"|"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 {
969 yyextra->defArgsStr+=
QCString(
"/*")+&yytext[2]+
" */";
972 yyextra->defArgsStr+=*yytext;
977 yyextra->defArgsStr+=*yytext;
981 yyextra->defArgsStr+=
' ';
986 yyextra->defArgsStr+=
"@@";
989 yyextra->defArgsStr+=*yytext;
991<ArgCopyCComment>[^*\n]+ {
992 yyextra->defArgsStr+=yytext;
994<ArgCopyCComment>{CCE} {
995 yyextra->defArgsStr+=yytext;
996 BEGIN(FindDefineArgs);
999 yyextra->defArgsStr+=yytext;
1000 yyextra->yyLineNr++;
1003 yyextra->defArgsStr+=yytext;
1005<ArgCopyCppComment>^{B}*
1006<ArgCopyCppComment>{CPPC}[/!].*\n/{B}*{CPPC}[/!] {
1007 const char *startContent = &yytext[3];
1008 if (startContent[0]==
'<') startContent++;
1009 yyextra->defArgsStr+=startContent;
1011<ArgCopyCppComment>{CPPC}[/!].*\n {
1012 const char *startContent = &yytext[3];
1013 if (startContent[0]==
'<') startContent++;
1014 yyextra->defArgsStr+=
QCString(startContent)+
" */";
1015 BEGIN(FindDefineArgs);
1017<ArgCopyCppComment>. {
1019 yyextra->defArgsStr+=
" */";
1020 BEGIN(FindDefineArgs);
1023 yyextra->defArgsStr+=*yytext;
1024 BEGIN(FindDefineArgs);
1028 yyextra->defArgsStr+=*yytext;
1029 BEGIN(FindDefineArgs);
1032<ReadString>{CPPC}|{CCS} {
1033 yyextra->defArgsStr+=yytext;
1035<ReadString>\\/\r?\n {
1038 yyextra->defArgsStr+=yytext;
1041 yyextra->defArgsStr+=*yytext;
1043<Command>("include"|"import"){B}+/{ID} {
1044 yyextra->isImported = yytext[1]==
'm';
1045 if (yyextra->macroExpansion)
1048<Command>("include"|"import"){B}*[<"] {
1049 yyextra->isImported = yytext[1]==
'm';
1051 c[0]=yytext[yyleng-1];c[1]=
'\0';
1055<Command>("cmake")?"define"{B}+ {
1056 yyextra->potentialDefine +=
substitute(yytext,
"cmake",
" ");
1058 yyextra->yyColNr+=(int)yyleng;
QCString substitute(const QCString &s, const QCString &src, const QCString &dst)
substitute all occurrences of src in s by dst
1061<Command>"cmakedefine01"{B}+ {
1062 yyextra->potentialDefine +=
substitute(yytext,
"cmakedefine01",
" define ");
1064 yyextra->yyColNr+=(int)yyleng;
1065 BEGIN(CmakeDefName01);
1067<Command>"ifdef"/{B}*"(" {
1069 yyextra->guardExpr.clear();
1070 BEGIN(DefinedExpr2);
1072<Command>"ifdef"/{B}+ {
1075 yyextra->guardExpr.clear();
1076 BEGIN(DefinedExpr1);
1078<Command>"ifndef"/{B}*"(" {
1080 yyextra->guardExpr=
"! ";
1081 BEGIN(DefinedExpr2);
1083<Command>"ifndef"/{B}+ {
1085 yyextra->guardExpr=
"! ";
1086 BEGIN(DefinedExpr1);
1088<Command>"if"/[ \t(!] {
1090 yyextra->guardExpr.clear();
1093<Command>("elif"|"else"{B}*"if")/[ \t(!] {
1096 yyextra->guardExpr.clear();
1102 BEGIN(SkipCPPBlock);
1105<Command>"else"/[^a-z_A-Z0-9\x80-\xFF] {
1109 BEGIN(SkipCPPBlock);
1116<Command>"undef"{B}+ {
1119<Command>("elif"|"else"{B}*"if")/[ \t(!] {
1122 yyextra->guardExpr.clear();
1126<Command>"endif"/[^a-z_A-Z0-9\x80-\xFF] {
1130<Command,IgnoreLine>\n {
1133 yyextra->yyLineNr++;
1135<Command>"pragma"{B}+"once" {
1136 yyextra->expectGuard =
FALSE;
1137 if (yyextra->pragmaSet.find(yyextra->fileName.str())!=yyextra->pragmaSet.end())
1144 yyextra->pragmaSet.insert(yyextra->fileName.data());
1149<PragmaOnce><<EOF>> {
1150 yyextra->expectGuard =
FALSE;
1156<IgnoreLine>\\[\r]?\n {
1158 yyextra->yyLineNr++;
1161<Command>. { yyextra->potentialDefine += yytext[0]==
'\t' ?
'\t' :
' ';
1162 yyextra->yyColNr+=(int)yyleng;
1178 yyextra->guardExpr+=
' ';
1179 yyextra->yyLineNr++;
1181<Guard>"defined"/{B}*"(" {
1182 BEGIN(DefinedExpr2);
1184<Guard>"defined"/{B}+ {
1185 BEGIN(DefinedExpr1);
1187<Guard>"true"/{B}|{B}*[\r]?\n { yyextra->guardExpr+=
"1L"; }
1188<Guard>"false"/{B}|{B}*[\r]?\n { yyextra->guardExpr+=
"0L"; }
1189<Guard>"not"/{B} { yyextra->guardExpr+=
'!'; }
1190<Guard>"not_eq"/{B} { yyextra->guardExpr+=
"!="; }
1191<Guard>"and"/{B} { yyextra->guardExpr+=
"&&"; }
1192<Guard>"or"/{B} { yyextra->guardExpr+=
"||"; }
1193<Guard>"bitand"/{B} { yyextra->guardExpr+=
"&"; }
1194<Guard>"bitor"/{B} { yyextra->guardExpr+=
"|"; }
1195<Guard>"xor"/{B} { yyextra->guardExpr+=
"^"; }
1196<Guard>"compl"/{B} { yyextra->guardExpr+=
"~"; }
1197<Guard>{ID} { yyextra->guardExpr+=yytext; }
1198<Guard>"@" { yyextra->guardExpr+=
"@@"; }
1199<Guard>. { yyextra->guardExpr+=*yytext; }
1213 BEGIN(SkipCPPBlock);
1216<DefinedExpr1,DefinedExpr2>\\\n { yyextra->yyLineNr++;
outputChar(yyscanner,
'\n'); }
1218 if (
isDefined(yyscanner,yytext) || yyextra->guardName==yytext)
1219 yyextra->guardExpr+=
" 1L ";
1221 yyextra->guardExpr+=
" 0L ";
1222 yyextra->lastGuardName=yytext;
1226 if (
isDefined(yyscanner,yytext) || yyextra->guardName==yytext)
1227 yyextra->guardExpr+=
" 1L ";
1229 yyextra->guardExpr+=
" 0L ";
1230 yyextra->lastGuardName=yytext;
1232<DefinedExpr1,DefinedExpr2>\n {
1233 yyextra->yyLineNr++;
1235 BEGIN(SkipCPPBlock);
1240<DefinedExpr1,DefinedExpr2>.
1241<SkipCPPBlock>^{B}*"#" { BEGIN(SkipCommand); }
1242<SkipCPPBlock>^{Bopt}/[^#] { BEGIN(SkipLine); }
1243<SkipCPPBlock>\n { yyextra->yyLineNr++;
outputChar(yyscanner,
'\n'); }
1245<SkipCommand>"if"(("n")?("def"))?/[ \t(!] {
1250<SkipCommand>"else" {
1259<SkipCommand>("elif"|"else"{B}*"if")/[ \t(!] {
1260 if (yyextra->ifcount==0)
1264 yyextra->guardExpr.clear();
1265 yyextra->lastGuardName.clear();
1270 BEGIN(SkipCPPBlock);
1274<SkipCommand>"endif" {
1275 yyextra->expectGuard =
FALSE;
1277 if (--yyextra->ifcount<0)
1285 yyextra->yyLineNr++;
1286 BEGIN(SkipCPPBlock);
1293<SkipLine>{CHARLIT} { }
1298<SkipString>{CPPC}/[^\n]* {
1300<SkipLine,SkipCommand,SkipCPPBlock>{CPPC}[^\n]* {
1301 yyextra->lastCPPContext=YY_START;
1302 BEGIN(RemoveCPPComment);
1304<SkipString>{CCS}/[^\n]* {
1306<SkipLine,SkipCommand,SkipCPPBlock>{CCS}/[^\n]* {
1307 yyextra->lastCContext=YY_START;
1308 BEGIN(RemoveCComment);
1312 yyextra->yyLineNr++;
1313 BEGIN(SkipCPPBlock);
1315<SkipString>[^"\\\n]+ { }
1321<IncludeID>{ID}{Bopt}/"(" {
1322 yyextra->nospaces=
TRUE;
1323 yyextra->roundCount=0;
1324 yyextra->defArgsStr=yytext;
1325 yyextra->findDefArgContext = IncludeID;
1326 BEGIN(FindDefineArgs);
1329 yyextra->nospaces=
TRUE;
1333<Include>[^\">\n]+[\">] {
1334 yyextra->incName+=yytext;
1335 if (yyextra->isImported)
1345<EndImport>{ENDIMPORTopt}/\n {
1349<EndImport>\\[\r]?"\n" {
1351 yyextra->yyLineNr++;
1355<DefName>{ID}/("\\\n")*"(" {
1357 yyextra->argMap.clear();
1358 yyextra->defArgs = 0;
1359 yyextra->defArgsStr.clear();
1360 yyextra->defText.clear();
1361 yyextra->defLitText.clear();
1362 yyextra->defName = yytext;
1363 yyextra->defVarArgs =
FALSE;
1364 yyextra->defExtraSpacing.clear();
1365 yyextra->defContinue =
false;
1368<DefName>{ID}{B}+"1"/[ \r\t\n] {
1370 yyextra->argMap.clear();
1371 yyextra->defArgs = -1;
1372 yyextra->defArgsStr.clear();
1374 yyextra->defVarArgs =
FALSE;
1377 if (yyextra->curlyCount>0 || yyextra->defName!=yyextra->lastGuardName || !yyextra->expectGuard)
1379 QCString def = yyextra->potentialDefine +
1382 outputSpaces(yyscanner,yytext+yyextra->defName.length());
1383 yyextra->quoteArg=
FALSE;
1384 yyextra->insideComment=
FALSE;
1385 yyextra->lastGuardName.clear();
1386 yyextra->defText=
"1";
1387 yyextra->defLitText=
"1";
1393 yyextra->defText.clear();
1394 yyextra->defLitText.clear();
1397 yyextra->expectGuard=
FALSE;
QCString stripWhiteSpace() const
returns a copy of this string with leading and trailing whitespace removed
QCString left(size_t len) const
1399<DefName,CmakeDefName01>{ID}/{B}*"\n" {
1400 yyextra->argMap.clear();
1401 yyextra->defArgs = -1;
1402 yyextra->defName = yytext;
1403 yyextra->defArgsStr.clear();
1404 yyextra->defText.clear();
1405 yyextra->defLitText.clear();
1406 yyextra->defVarArgs =
FALSE;
1409 if (yyextra->curlyCount>0 || yyextra->defName!=yyextra->lastGuardName || !yyextra->expectGuard)
1411 QCString def = yyextra->potentialDefine + yyextra->defName;
1413 yyextra->quoteArg=
FALSE;
1414 yyextra->insideComment=
FALSE;
1415 if (YY_START == CmakeDefName01) yyextra->defText =
"0";
1416 else if (yyextra->insideCS) yyextra->defText=
"1";
1422 yyextra->guardName = yytext;
1423 yyextra->lastGuardName.clear();
1426 yyextra->expectGuard=
FALSE;
1430 yyextra->argMap.clear();
1431 yyextra->defArgs = -1;
1432 yyextra->defArgsStr.clear();
1433 yyextra->defText.clear();
1434 yyextra->defLitText.clear();
1435 yyextra->defName = yytext;
1436 yyextra->defVarArgs =
FALSE;
1437 QCString def = yyextra->potentialDefine +
1439 yyextra->defArgsStr ;
1441 yyextra->quoteArg=
FALSE;
1442 yyextra->insideComment=
FALSE;
1446 yyextra->defExtraSpacing+=
"\n";
1447 yyextra->defContinue =
true;
1448 yyextra->yyLineNr++;
1450<DefineArg>{B}* { yyextra->defExtraSpacing+=yytext; }
1451<DefineArg>","{B}* { yyextra->defArgsStr+=yytext; }
1452<DefineArg>"("{B}* { yyextra->defArgsStr+=yytext; }
1453<DefineArg>{B}*")"{B}* {
1455 yyextra->defArgsStr+=yytext;
1456 QCString def = yyextra->potentialDefine +
1458 yyextra->defArgsStr +
1459 yyextra->defExtraSpacing ;
1461 yyextra->quoteArg=
FALSE;
1462 yyextra->insideComment=
FALSE;
1466 yyextra->defVarArgs =
TRUE;
1467 yyextra->defArgsStr+=yytext;
1468 yyextra->argMap.emplace(std::string(
"__VA_ARGS__"),yyextra->defArgs);
1471<DefineArg>{ID}{B}*("..."?) {
1474 yyextra->defVarArgs = yytext[yyleng-1]==
'.';
1475 if (yyextra->defVarArgs)
1480 yyextra->defArgsStr+=yytext;
1481 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)
1497<DefineText>{CCS}[^!*] {
1498 yyextra->defLitText+=
' ';
1500 yyextra->lastCContext=YY_START;
1501 yyextra->commentCount=1;
1502 BEGIN(SkipCComment);
1504<DefineText>{CCS}[!*] {
1505 yyextra->defText+=yytext;
1506 yyextra->defLitText+=yytext;
1507 yyextra->lastCContext=YY_START;
1508 yyextra->commentCount=1;
1509 BEGIN(CopyCComment);
1511<DefineText>{CPPC}[!/]? {
1513 yyextra->lastCPPContext=YY_START;
1514 yyextra->defLitText+=
' ';
1515 BEGIN(SkipCPPComment);
1517<SkipCComment>[/]?{CCE} {
1518 if (yytext[0]==
'/')
outputChar(yyscanner,
'/');
1520 if (--yyextra->commentCount<=0)
1522 if (yyextra->lastCContext==Start)
1526 YY_CURRENT_BUFFER->yy_at_bol=1;
1528 BEGIN(yyextra->lastCContext);
1531<SkipCComment>{CPPC}("/")* {
1534<SkipCComment>{CCS} {
1538<SkipCond>{CMD}{CMD} { }
1539<SkipCond>^({B}*"*"+)?{B}{0,3}"~~~"[~]* {
1541 if (!markdownSupport || !yyextra->isSpecialComment)
1547 yyextra->fenceChar=
'~';
1549 BEGIN(SkipCondVerbatim);
1552<SkipCond>^({B}*"*"+)?{B}{0,3}"```"[`]* {
1554 if (!markdownSupport || !yyextra->isSpecialComment)
1560 yyextra->fenceChar=
'`';
1562 BEGIN(SkipCondVerbatim);
1565<SkipCComment>^({B}*"*"+)?{B}{0,3}"~~~"[~]* {
1567 if (!markdownSupport || !yyextra->isSpecialComment)
1574 yyextra->fenceChar=
'~';
1576 BEGIN(SkipVerbatim);
1579<SkipCComment>^({B}*"*"+)?{B}{0,3}"```"[`]* {
1581 if (!markdownSupport || !yyextra->isSpecialComment)
1588 yyextra->fenceChar=
'`';
1590 BEGIN(SkipVerbatim);
1593<SkipCComment>{CMD}{VERBATIM_LINE} |
1594<SkipCComment>{CMD}{LITERAL_BLOCK} {
1598<SkipCComment>{VERBATIM_LINE}.*/\n {
1601<SkipCComment>{LITERAL_BLOCK} {
1604 if (yyextra->isSpecialComment)
1607 BEGIN(SkipVerbatim);
1610<SkipCond>{CMD}{CMD}"cond"[ \t]+ {}
1611<SkipCond>{CMD}"cond"/\n |
1612<SkipCond>{CMD}"cond"[ \t]+ {
1616<SkipCComment>"{"[ \t]*"@code"/[ \t\n] {
1618 yyextra->javaBlock=1;
1619 BEGIN(JavaDocVerbatimCode);
1621<SkipCComment>"{"[ \t]*"@literal"/[ \t\n] {
1623 yyextra->javaBlock=1;
1624 BEGIN(JavaDocVerbatimCode);
1626<SkipCComment,SkipCPPComment>{CMD}{CMD}"cond"[ \t\n]+ {
1629<SkipCPPComment>{CMD}"cond"[ \t]+ {
1630 yyextra->ccomment=
TRUE;
1631 yyextra->condCtx=YY_START;
1634<SkipCComment>{CMD}"cond"[ \t]+ {
1635 yyextra->ccomment=
FALSE;
1636 yyextra->condCtx=YY_START;
1639<CondLineC,CondLineCpp>[!()&| \ta-z_A-Z0-9\x80-\xFF.\-]+ {
1643 if (YY_START==CondLineC)
1647 yyextra->ccomment=
TRUE;
1651 yyextra->ccomment=
FALSE;
1657 BEGIN(yyextra->condCtx);
1660<CondLineC,CondLineCpp>. {
1665 if (YY_START==CondLineC)
1669 yyextra->ccomment=
TRUE;
1673 yyextra->ccomment=
FALSE;
1679 BEGIN(yyextra->condCtx);
1682<SkipCComment,SkipCPPComment>{CMD}"cond"{WSopt}/\n {
1683 if (YY_START==SkipCComment)
1685 yyextra->ccomment=
TRUE;
1691 yyextra->ccomment=
FALSE;
1693 yyextra->condCtx=YY_START;
1694 yyextra->condGuardCount=0;
1698<SkipCond>\n { yyextra->yyLineNr++;
outputChar(yyscanner,
'\n'); }
1699<SkipCond>{VERBATIM_LINE}.*/\n { }
1700<SkipCond>{LITERAL_BLOCK} {
1702 yyextra->yyLineNr+=numNLs;
1703 for (
int i = 0; i < numNLs; i++)
outputChar(yyscanner,
'\n');
1705 BEGIN(SkipCondVerbatim);
1709<SkipCond>"#if"("def")? { yyextra->condGuardCount++; }
1710<SkipCond>"#endif" { yyextra->condGuardCount--; }
1711<SkipCond>[^\/\!*\\@\n#]+ { }
1712<SkipCond>{CPPC}[/!] { yyextra->ccomment=
FALSE; }
1713<SkipCond>{CCS}[*!] { yyextra->ccomment=
TRUE; }
1714<SkipCond,SkipCComment,SkipCPPComment>{CMD}{CMD}"endcond"/[^a-z_A-Z0-9\x80-\xFF] {
1720<SkipCond>{CMD}"endcond"/[^a-z_A-Z0-9\x80-\xFF] {
1721 bool oldSkip = yyextra->skip;
1723 if (oldSkip && !yyextra->skip)
1725 if (yyextra->ccomment)
1729 BEGIN(yyextra->condCtx);
1732<SkipCComment,SkipCPPComment>{CMD}"endcond"/[^a-z_A-Z0-9\x80-\xFF] {
1733 bool oldSkip = yyextra->skip;
1735 if (oldSkip && !yyextra->skip)
1737 BEGIN(yyextra->condCtx);
1740<SkipCondVerbatim>{LITERAL_BLOCK_END} {
1741 if (yytext[1]==
'f' && yyextra->blockName==&yytext[2])
1745 else if (&yytext[4]==yyextra->blockName)
1750<SkipVerbatim>{LITERAL_BLOCK_END} {
1752 if (yytext[1]==
'f' && yyextra->blockName==&yytext[2])
1754 BEGIN(SkipCComment);
1756 else if (&yytext[4]==yyextra->blockName)
1758 BEGIN(SkipCComment);
1761<SkipCondVerbatim>^({B}*"*"+)?{B}{0,3}"~~~"[~]* {
1762 if (yyextra->fenceSize==
getFenceSize(yytext,yyleng) && yyextra->fenceChar==
'~')
1767<SkipCondVerbatim>^({B}*"*"+)?{B}{0,3}"```"[`]* {
1768 if (yyextra->fenceSize==
getFenceSize(yytext,yyleng) && yyextra->fenceChar==
'`')
1773<SkipVerbatim>^({B}*"*"+)?{B}{0,3}"~~~"[~]* {
1775 if (yyextra->fenceSize==
getFenceSize(yytext,yyleng) && yyextra->fenceChar==
'~')
1777 BEGIN(SkipCComment);
1780<SkipVerbatim>^({B}*"*"+)?{B}{0,3}"```"[`]* {
1782 if (yyextra->fenceSize==
getFenceSize(yytext,yyleng) && yyextra->fenceChar==
'`')
1784 BEGIN(SkipCComment);
1787<SkipCondVerbatim>{CCE}|{CCS} { }
1788<SkipVerbatim>{CCE}|{CCS} {
1791<JavaDocVerbatimCode>"{" {
1792 if (yyextra->javaBlock==0)
1798 yyextra->javaBlock++;
1802<JavaDocVerbatimCode>"}" {
1803 if (yyextra->javaBlock==0)
1809 yyextra->javaBlock--;
1810 if (yyextra->javaBlock==0)
1813 BEGIN(SkipCComment);
1821<JavaDocVerbatimCode>\n {
1824<JavaDocVerbatimCode>. {
1827<SkipCondVerbatim>[^{*\\@\x06~`\n\/]+ { }
1828<SkipCComment,SkipVerbatim>[^{*\\@\x06~`\n\/]+ {
1831<SkipCComment,SkipVerbatim,SkipCondVerbatim>\n {
1832 yyextra->yyLineNr++;
1835<SkipCondVerbatim>. { }
1836<SkipCComment,SkipVerbatim>. {
1839<CopyCComment>[^*a-z_A-Z\x80-\xFF\n]*[^*a-z_A-Z\x80-\xFF\\\n] {
1840 yyextra->defLitText+=yytext;
1841 yyextra->defText+=
escapeAt(yytext);
1843<CopyCComment>\\[\r]?\n {
1844 yyextra->defLitText+=yytext;
1845 yyextra->defText+=
" ";
1846 yyextra->yyLineNr++;
1847 yyextra->yyMLines++;
1849<CopyCComment>{CCE} {
1850 yyextra->defLitText+=yytext;
1851 yyextra->defText+=yytext;
1852 BEGIN(yyextra->lastCContext);
1855 yyextra->yyLineNr++;
1856 yyextra->defLitText+=yytext;
1857 yyextra->defText+=
' ';
1859<RemoveCComment>{CCE}{B}*"#" {
1860 if (yyextra->lastCContext==SkipCPPBlock)
1869<RemoveCComment>{CCE} { BEGIN(yyextra->lastCContext); }
1870<RemoveCComment>{CPPC}
1871<RemoveCComment>{CCS}
1872<RemoveCComment>[^*\x06\n]+
1873<RemoveCComment>\n { yyextra->yyLineNr++;
outputChar(yyscanner,
'\n'); }
1875<SkipCPPComment>[^\n\/\\@]+ {
1878<SkipCPPComment,RemoveCPPComment>\n {
1880 BEGIN(yyextra->lastCPPContext);
1882<SkipCPPComment>{CCS} {
1885<SkipCPPComment>{CPPC} {
1888<SkipCPPComment>[^\x06\@\\\n]+ {
1894<RemoveCPPComment>{CCS}
1895<RemoveCPPComment>{CPPC}
1896<RemoveCPPComment>[^\x06\n]+
1898<DefineText>"__VA_OPT__("{B}*"##" {
1899 warn(yyextra->fileName,yyextra->yyLineNr,
1900 "'##' may not appear at the beginning of a __VA_OPT__()",
1901 yyextra->defName,yyextra->defLitText.stripWhiteSpace());
1902 yyextra->defText+=
"__VA_OPT__(";
1903 yyextra->defLitText+=
"__VA_OPT__(";
#define warn(file, line, fmt,...)
1905<DefineText>"#"/"__VA_OPT__" {
1906 yyextra->defText+=yytext;
1907 yyextra->defLitText+=yytext;
1909<DefineText>"#"/{IDSTART} {
1911 yyextra->quoteArg=
TRUE;
1912 yyextra->idStart=
true;
1913 yyextra->defLitText+=yytext;
1915<DefineText,CopyCComment>{ID} {
1916 yyextra->defLitText+=yytext;
1917 if (YY_START == DefineText)
outputSpaces(yyscanner,yytext);
1918 if (yyextra->quoteArg)
1920 yyextra->defText+=
"\"";
1922 if (yyextra->defArgs>0)
1924 auto it = yyextra->argMap.find(yytext);
1925 if (it!=yyextra->argMap.end())
1928 yyextra->defText+=
'@';
1933 if (yyextra->idStart)
1935 warn(yyextra->fileName,yyextra->yyLineNr,
1936 "'#' is not followed by a macro parameter '{}': '{}'",
1937 yyextra->defName,yyextra->defLitText.stripWhiteSpace());
1939 yyextra->defText+=yytext;
1944 yyextra->defText+=yytext;
1946 if (yyextra->quoteArg)
1948 yyextra->defText+=
"\"";
1950 yyextra->quoteArg=
FALSE;
1951 yyextra->idStart=
false;
QCString & setNum(short n)
1954 yyextra->defLitText+=yytext;
1955 yyextra->defText+=yytext;
1957<DefineText>\\[\r]?\n {
1958 yyextra->defLitText+=yytext;
1961 yyextra->defText +=
' ';
1962 yyextra->yyLineNr++;
1963 yyextra->yyMLines++;
1967 yyextra->defText = yyextra->defText.stripWhiteSpace();
1968 if (yyextra->defText.startsWith(
"##"))
1970 warn(yyextra->fileName,yyextra->yyLineNr,
1971 "'##' cannot occur at the beginning of a macro definition '{}': '{}'",
1972 yyextra->defName,yyextra->defLitText.stripWhiteSpace());
1974 else if (yyextra->defText.endsWith(
"##"))
1976 warn(yyextra->fileName,yyextra->yyLineNr,
1977 "'##' cannot occur at the end of a macro definition '{}': '{}'",
1978 yyextra->defName,yyextra->defLitText.stripWhiteSpace());
1980 else if (yyextra->defText.endsWith(
"#"))
1982 warn(yyextra->fileName,yyextra->yyLineNr,
1983 "expected formal parameter after # in macro definition '{}': '{}'",
1984 yyextra->defName,yyextra->defLitText.stripWhiteSpace());
1989 yyextra->defLitText=yyextra->defLitText.left(yyextra->defLitText.length()-comment.
length()-1);
1992 yyextra->defLitText+=yytext;
1995 if (yyextra->includeStack.empty() || yyextra->curlyCount>0)
1999 def=
isDefined(yyscanner,yyextra->defName);
2013 def->
name = yyextra->defName;
2015 def->
nargs = yyextra->defArgs;
2017 def->
lineNr = yyextra->yyLineNr-yyextra->yyMLines;
2022 if (def->
fileName != yyextra->fileName && !yyextra->expandOnlyPredef)
addDefine(yyscanner);
2026 yyextra->argMap.clear();
2027 yyextra->yyLineNr++;
2029 yyextra->lastGuardName.clear();
bool isEmpty() const
Returns TRUE iff the string is empty.
2033 yyextra->defText +=
' ';
2034 yyextra->defLitText+=yytext;
2037 yyextra->defText +=
"##";
2038 yyextra->defLitText+=yytext;
2041 yyextra->defText +=
"@@";
2042 yyextra->defLitText+=yytext;
2046 yyextra->defText += *yytext;
2047 yyextra->defLitText+=yytext;
2048 if (!yyextra->insideComment)
2050 BEGIN(SkipDoubleQuote);
2053<DefineText>{NUMBER} {
2055 yyextra->defText += yytext;
2056 yyextra->defLitText+=yytext;
2060 yyextra->defText += *yytext;
2061 yyextra->defLitText+=yytext;
2062 if (!yyextra->insideComment)
2064 BEGIN(SkipSingleQuote);
2067<SkipDoubleQuote>{CPPC}[/]? {
outputSpaces(yyscanner,yytext);
2068 yyextra->defText += yytext;
2069 yyextra->defLitText+=yytext;
2071<SkipDoubleQuote>{CCS}[*]? {
outputSpaces(yyscanner,yytext);
2072 yyextra->defText += yytext;
2073 yyextra->defLitText+=yytext;
2075<SkipDoubleQuote>\" {
2077 yyextra->defText += *yytext;
2078 yyextra->defLitText+=yytext;
2081<SkipSingleQuote,SkipDoubleQuote>\\. {
2083 yyextra->defText += yytext;
2084 yyextra->defLitText+=yytext;
2086<SkipSingleQuote>\' {
2088 yyextra->defText += *yytext;
2089 yyextra->defLitText+=yytext;
2092<SkipDoubleQuote,SkipSingleQuote>. {
outputSpace(yyscanner,yytext[0]);
2093 yyextra->defText += *yytext;
2094 yyextra->defLitText += *yytext;
2097 yyextra->defText += *yytext;
2098 yyextra->defLitText += *yytext;
2101 TRACE(
"End of include file");
2103 if (yyextra->includeStack.empty())
2105 TRACE(
"Terminating scanner");
2110 if (!yyextra->levelGuard.empty())
2112 if (yyextra->condGuardErrorLine!=0)
2114 warn(yyextra->condGuardErrorFileName,yyextra->condGuardErrorLine,
"{}",yyextra->condGuardErrorMessage);
2118 warn(yyextra->fileName,yyextra->yyLineNr,
"More #endif's than #if's found.");
2121 QCString toFileName = yyextra->fileName;
2122 const std::unique_ptr<FileState> &fs=yyextra->includeStack.back();
2124 YY_BUFFER_STATE oldBuf = YY_CURRENT_BUFFER;
2125 yy_switch_to_buffer( fs->bufState, yyscanner );
2126 yy_delete_buffer( oldBuf, yyscanner );
2127 yyextra->yyLineNr = fs->lineNr;
2129 yyextra->inputBuf = fs->oldFileBuf;
2130 yyextra->inputBufPos = fs->oldFileBufPos;
2131 yyextra->curlyCount = fs->curlyCount;
2132 yyextra->levelGuard = fs->levelGuard;
2134 TRACE(
"switching to {}",yyextra->fileName);
2139 lineStr.sprintf(
"# %d \"%s\" 2",yyextra->yyLineNr,
qPrint(yyextra->fileName));
2142 yyextra->includeStack.pop_back();
2165 for (
const auto &kv : yyextra->localDefines)
2167 auto pair = yyextra->contextDefines.insert(kv);
2170 yyextra->contextDefines.erase(pair.first);
2171 yyextra->contextDefines.insert(kv);
2174 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)
2179 if (YY_START==SkipVerbatim || YY_START == SkipCondVerbatim || YY_START==SkipCond || YY_START==IDLquote || YY_START == PragmaOnce)
2186 yyextra->lastCContext=YY_START;
2187 yyextra->commentCount=1;
2190 yyextra->isSpecialComment =
true;
2191 yyextra->lastGuardName.clear();
2195 yyextra->isSpecialComment =
false;
2197 BEGIN(SkipCComment);
2201 if (YY_START==SkipVerbatim || YY_START == SkipCondVerbatim || YY_START==SkipCond ||
getLanguageFromFileName(yyextra->fileName)==SrcLangExt::Fortran || YY_START==IDLquote || YY_START == PragmaOnce)
2205 else if (YY_START==RulesRoundDouble)
2212 yyextra->lastCPPContext=YY_START;
2215 yyextra->isSpecialComment =
true;
2216 yyextra->lastGuardName.clear();
2220 yyextra->isSpecialComment =
false;
2222 BEGIN(SkipCPPComment);
2227 yyextra->yyLineNr++;
2230 yyextra->expectGuard =
FALSE;
2240 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
2241 int bytesInBuf =
static_cast<int>(state->inputBuf->size())-state->inputBufPos;
2242 int bytesToCopy = std::min(max_size,bytesInBuf);
2243 memcpy(buf,state->inputBuf->data()+state->inputBufPos,bytesToCopy);
2244 state->inputBufPos+=bytesToCopy;
2250 yy_size_t fenceSize = 0;
2251 for (
size_t i = 0; i < leng; i++)
2253 if (txt[i] !=
' ' && txt[i] !=
'*' && txt[i] !=
'\t')
break;
2256 return leng-fenceSize;
2261 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
2266 if (state->yyFileDef==
nullptr)
2272 if (state->yyFileDef && state->yyFileDef->isReference()) state->yyFileDef=
nullptr;
2277 state->isSource = section.isHeader() || section.isSource();
2282 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
2283 state->levelGuard.push(
false);
2289 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
2291 if (!state->levelGuard.empty())
2293 state->levelGuard.pop();
2297 if (state->condGuardErrorLine!=0)
2299 warn(state->condGuardErrorFileName,state->condGuardErrorLine,
"{}",state->condGuardErrorMessage);
2303 warn(state->fileName,state->yyLineNr,
"More #endif's than #if's found.");
2310 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
2311 if (state->levelGuard.empty())
2313 warn(state->fileName,state->yyLineNr,
"Found an #else without a preceding #if.");
2318 return state->levelGuard.top();
2324 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
2325 state->levelGuard.top()=value;
2331 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
2332 alreadyProcessed =
FALSE;
2333 std::unique_ptr<FileState> fs;
2344 if (state->curlyCount==0)
2349 alreadyProcessed =
TRUE;
2356 alreadyProcessed = std::any_of(
2357 state->includeStack.begin(),
2358 state->includeStack.end(),
2359 [absName](
const std::unique_ptr<FileState> &lfs)
2360 { return lfs->fileName==absName; }
2363 if (alreadyProcessed)
2370 fs = std::make_unique<FileState>();
2379 fs->oldFileBuf = state->inputBuf;
2380 fs->oldFileBufPos = state->inputBufPos;
2388 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
2399 else if (alreadyProcessed)
2404 if (localInclude && !state->fileName.isEmpty())
2406 FileInfo fi(state->fileName.str());
2417 else if (alreadyProcessed)
2423 if (state->pathList.empty())
2427 for (
auto path : state->pathList)
2429 QCString absName = path+
"/"+fileName;
2439 else if (alreadyProcessed)
2472 if (i>=0 && s[i]==
'*')
2475 while (i>0 && !(s[i-1]==
'/' && s[i]==
'*')) i--;
2482 return ((s[i+1]==
'*' || s[i+1]==
'!') && s[i+2]==
'<') ? &s[i-1] :
"";
2514 bool inString=
FALSE;
2519 if (!inString && !inChar)
2521 while (i<s.
length() && !inString && !inChar)
2542 while (i<s.
length() && inChar)
2563 while (i<s.
length() && inString)
2592 std::string e = expr.
str();
2593 static const reg::Ex r(R
"(\s*##\s*)");
2602 const auto &match = *it;
2603 size_t n = match.position();
2604 size_t l = match.length();
2606 if (n+l+1<e.length() && e[
static_cast<int>(n+l)]==
'@' && expr[
static_cast<int>(n+l+1)]==
'-')
2613 e=e.substr(0,n)+e.substr(n+l);
2614 int k=
static_cast<int>(n)-1;
2615 while (k>=0 &&
isId(e[k])) k--;
2616 if (k>0 && e[k]==
'-' && e[k-1]==
'@')
2619 e=e.substr(0,k-1)+e.substr(k+1);
2637 struct yyguts_t * yyg = (
struct yyguts_t*)yyscanner;
2645 while ((cc=
getNextChar(yyscanner,expr,rest,pos))!=EOF && cc!=0)
2664 while ((cc=
getNextChar(yyscanner,expr,rest,pos))!=EOF && cc!=0)
2677 int &cc, uint32_t &j,
int &len)
2679 bool changed =
false;
2684 while ((cc=
getCurrentChar(yyscanner,expr,rest,j))!=EOF && cc!=
'\n' && isspace(cc))
2692 int prevChar =
'\0';
2694 if ((cc=
getCurrentChar(yyscanner,expr,rest,j))!=EOF && cc ==
'*')
2696 while ((cc=
getNextChar(yyscanner,expr,rest,j))!=EOF && cc!=0)
2698 if (cc ==
'/' && prevChar ==
'*')
break;
2701 if (cc != EOF) changed =
true;
2714 int vl =
static_cast<int>(vaStr.
length());
2715 while ((vo = vaStr.
find(
"__VA_OPT__(",vp))!=-1)
2717 bool hasHash = vo>0 && vaStr.
at(vo-1)==
'#';
2720 result+=vaStr.
mid(vp,vo-vp-1);
2725 result+=vaStr.
mid(vp,vo-vp);
2729 while (bc>0 && ve<vl)
2731 if (vaStr[ve]==
')') bc--;
2732 else if (vaStr[ve]==
'(') bc++;
2736 if (bc==0 && hasOptionalArgs)
2748 result+=vaStr.
mid(vp);
2780 std::map<std::string,std::string> argTable;
2783 int argCountNonEmpty=0;
2789 while ((cc=
getNextChar(yyscanner,expr,rest,j))!=EOF && cc!=0)
2797 while (!done && (argCount<def->nargs || def->
varArgs) &&
2798 ((cc=
getNextChar(yyscanner,expr,rest,j))!=EOF && cc!=0)
2807 while ((cc=
getNextChar(yyscanner,expr,rest,j))!=EOF && cc!=0)
2811 if (c==
'\'' || c==
'\"')
2844 else if (c==
')' || c==
',')
2857 argKey.
sprintf(
"@%d",argCount++);
2858 if (c==
',' || !arg.
isEmpty()) argCountNonEmpty++;
2872 while (!found && (cc=
getNextChar(yyscanner,expr,rest,j))!=EOF && cc!=0)
2879 if ((cc=
getNextChar(yyscanner,expr,rest,j))==EOF || cc==0)
break;
2889 while (!found && (cc=
getNextChar(yyscanner,expr,rest,j))!=EOF && cc!=0)
2896 if ((cc=
getNextChar(yyscanner,expr,rest,j))==EOF || cc==0)
break;
2904 char prevChar =
'\0';
2908 while ((cc=
getNextChar(yyscanner,expr,rest,j))!=EOF && cc!=0)
2912 if (c ==
'/' && prevChar ==
'*')
break;
2925 if (argCount==def->
nargs ||
2936 bool inString=
FALSE;
2946 else if (d.
at(k+1)==
'-')
2957 if (l>=0 && d.
at(l)==
'"') l--;
2958 while (l>=0 && d.
at(l)==
' ') l--;
2959 if (l>0 && d.
at(l)==
'#' && d.
at(l-1)==
'#') hash=
TRUE;
2962 while (k<d.
length() && d.
at(k)>=
'0' && d.
at(k)<=
'9') key+=d.
at(k++);
2967 if (l<(
int)d.
length() && d.
at(l)==
'"') l++;
2968 while (l<(
int)d.
length() && d.
at(l)==
' ') l++;
2969 if (l<(
int)d.
length()-1 && d.
at(l)==
'#' && d.
at(l+1)==
'#') hash=
TRUE;
2972 auto it = argTable.find(key.
str());
2973 if (it!=argTable.end())
2993 if (hash && substArg.
isEmpty())
3004 if (!inString && d.
at(k)==
'\"')
3008 else if (k>2 && inString && d.
at(k)==
'\"' && (d.
at(k-1)!=
'\\' || d.
at(k-2)==
'\\'))
3032 while (p<(
int)expr.
length())
3034 char c=expr.
at(p++);
3039 else if (isalpha(c) || c==
'_')
3049 if (p<(
int)expr.
length()) c=expr.
at(p);
3050 while (p<(
int)expr.
length() && (c!=
'"' || (pc==
'\\' && ppc!=
'\\')))
3058 if (p<(
int)expr.
length()) ++p;
3064 if (p<(
int)expr.
length())
3070 while (p<(
int)expr.
length() && !(pc==
'*' && c==
'/'))
3083#define MAX_EXPANSION_DEPTH 50
3087 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
3088 if (!state->nospaces)
3091 char ccPrev = pos==0 || (int)expr.
length()<pos ? state->prevChar : expr.
at(pos-1);
3092 QCString leftSpace = ccPrev!=
':' && ccPrev!=
' ' ?
" " :
"";
3097 uint32_t j=(uint32_t)resultExpr.
length();
3098 while ((ccNext=
getNextChar(yyscanner,resultExpr,
nullptr,j))!=EOF && ccNext==
' ') { }
3099 if (ccNext != EOF)
unputChar(yyscanner,resultExpr,
nullptr,j,(
char)ccNext);
3103 ccNext=restExpr.
at(0);
3106 QCString rightSpace = ccNext!=
':' && ccNext!=
' ' ?
" " :
"";
3109 resultExpr=leftSpace+resultExpr+rightSpace;
3119 struct yyguts_t * yyg = (
struct yyguts_t*)yyscanner;
3120 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
3127 if (state->expanded.find(expr.
str())!=state->expanded.end() &&
3135 state->expanded.insert(expr.
str());
3139 bool definedTest=
FALSE;
3140 int i=pos, l=0, p=0, len=0;
3145 bool replaced=
FALSE;
3147 macroName=expr.
mid(p,l);
3152 expr=expr.
left(p)+resultExpr+restExpr;
3154 else if (p<2 || !(expr.
at(p-2)==
'@' && expr.
at(p-1)==
'-'))
3156 if (state->expandedDict.find(macroName.
str())==state->expandedDict.end())
3158 bool expanded=
false;
3162 if (yyextra->expandOnlyPredef && def && !def->
isPredefined) def=
nullptr;
3163 if (macroName==
"defined")
3168 else if (definedTest)
3170 if (def) expMacro =
" 1 ";
else expMacro =
" 0 ";
3175 else if (def && def->
nargs==-1)
3184 else if (def && def->
nargs>=0)
3195 resultExpr=expMacro;
3202 state->expandedDict.emplace(
toStdString(macroName),def);
3204 state->expandedDict.erase(
toStdString(macroName));
3213 expr=expr.
left(p)+resultExpr+restExpr;
3269 if (inputStr==
nullptr)
return inputStr;
3270 char term = *inputStr;
3271 if (
term!=
'\'' &&
term!=
'"')
return inputStr;
3276 while ((c=*inputStr))
3305 static const std::vector<std::string> signs = {
"signed",
"unsigned" };
3306 struct TypeInfo { std::string name;
size_t size; };
3307 static const std::vector<TypeInfo> types = {
3308 {
"short int",
sizeof(
short int) },
3309 {
"long long int",
sizeof(
long long int) },
3310 {
"long int",
sizeof(
long int) },
3311 {
"long long",
sizeof(
long long) },
3312 {
"long double",
sizeof(
long double) },
3313 {
"int",
sizeof(int) },
3314 {
"short",
sizeof(short) },
3315 {
"bool",
sizeof(bool) },
3316 {
"long",
sizeof(long) },
3317 {
"char",
sizeof(char) },
3318 {
"float",
sizeof(float) },
3319 {
"double",
sizeof(double) },
3325 auto process_cast_or_sizeof = [](
const char *p) -> std::pair<const char *,size_t>
3328 while (*q==
' ' || *q==
'\t') q++;
3330 size_t size =
sizeof(int);
3331 for (
const auto &sgn : signs)
3333 if (
qstrncmp(q,sgn.c_str(),sgn.length())==0) { q+=sgn.length(); found=
true; }
3335 if (!found || *q==
' ' || *q==
'\t' || *q==
')')
3337 while (*q==
' ' || *q==
'\t') q++;
3338 for (
const auto &t : types)
3340 if (
qstrncmp(q,t.name.c_str(),t.name.length())==0)
3342 q += t.name.length();
3347 while (*q==
' ' || *q==
'\t') q++;
3348 if (*q==
')')
return std::make_pair(++q,size);
3350 return std::make_pair(
nullptr,0);
3355 const char *p=s.
data();
3365 const char *q = process_cast_or_sizeof(p+1).first;
3375 const char *q = p+6;
3376 while (*q==
' ' || *q==
'\t') q++;
3379 auto r = process_cast_or_sizeof(q+1);
3396 else if (*(p+1)==
'E')
3402 else if (isdigit(c))
3412 else if (c==
'd' && !inNum)
3423 while ((c=*p) &&
isId(c)) p++;
3426 else if ((isalpha(c) || c==
'_') && !inNum)
3430 while ((c=*p) &&
isId(c)) p++;
3431 while ((c=*p) && isspace((uint8_t)c)) p++;
3438 if (c==
'(') count++;
3442 if (count==0)
break;
3450 while (*p && !(pc==
'*' && c==
'/'))
3467 while (*p && !(pc==
'*' && c==
'/'))
3484 char lc=(char)tolower(c);
3501 const char *p=s.
data();
3526 while (*p && !(pc==
'*' && c==
'/'))
3528 if (*p==
'@' && *(p+1)==
'@')
3571 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
3575 state->expanded.clear();
3581 return state->constExpParser.parse(state->fileName.data(),state->yyLineNr,e.
str(),ee.
str());
3590 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
3591 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
3592 state->prevChar = yyscanner->yytext_r > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ? *(yyscanner->yytext_r-1) : 0;
3594 state->expanded.
clear();
3604 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
3606 if (name ==
"__LINE__")
3610 else if (name ==
"__FILE__")
3613 resultExpr += yyextra->fileName;
3616 else if (name ==
"__DATE__")
3619 resultExpr += __DATE__;
3622 else if (name ==
"__TIME__")
3625 resultExpr += __TIME__;
3633 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
3635 def.
name = state->defName;
3637 def.
nargs = state->defArgs;
3639 def.
fileDef = state->yyFileDef;
3640 def.
lineNr = state->yyLineNr-state->yyMLines;
3642 def.
varArgs = state->defVarArgs;
3652 auto it = state->localDefines.find(def.
name.
str());
3653 if (it!=state->localDefines.end())
3655 state->localDefines.erase(it);
3657 state->localDefines.emplace(def.
name.
str(),def);
3662 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
3663 if (state->skip)
return;
3668 define.
lineNr = state->yyLineNr - state->yyMLines;
3670 define.
name = state->defName;
3671 define.
args = state->defArgsStr;
3672 define.
fileDef = state->inputFileDef;
3674 QCString litText = state->defLitText;
3675 int l=litText.
find(
'\n');
3685 const char *p=litText.
data()+k;
3687 while ((c=*p++) && (c==
' ' || c==
'\t')) k++;
3691 if (litTextStripped.
contains(
'\n')>=1)
3700 state->macroDefinitions.push_back(define);
3706 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
3707 if (state->includeStack.empty() || state->curlyCount>0) (*state->outputBuf)+=c;
3712 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
3713 if (state->includeStack.empty() || state->curlyCount>0) (*state->outputBuf)+=std::string_view(a,len);
3718 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
3719 if (state->includeStack.empty() || state->curlyCount>0) (*state->outputBuf)+=a.
str();
3741 struct yyguts_t * yyg = (
struct yyguts_t*)yyscanner;
3742 if (!yyextra->defContinue)
return;
3743 for (
int i=0; i< (int)yyleng; i++)
3745 if (yytext[i] ==
'\t')
3746 yyextra->defExtraSpacing+=
'\t';
3748 yyextra->defExtraSpacing+=
' ';
3754 struct yyguts_t * yyg = (
struct yyguts_t*)yyscanner;
3755 yyextra->fenceSize=0;
3757 if (yytext[1]==
'f' && ((c=yytext[2])==
'[' || c==
'{' || c==
'(' || c==
'$'))
3761 case '[': yyextra->blockName=
"]";
break;
3762 case '{': yyextra->blockName=
"}";
break;
3763 case '(': yyextra->blockName=
")";
break;
3764 case '$': yyextra->blockName=
"$";
break;
3767 yyextra->blockName=yyextra->blockName.stripWhiteSpace();
3774 yyextra->blockName=
"uml";
3778 int i = bn.
find(
'{');
3780 yyextra->blockName=bn;
3788 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
3793 (inc.
at(i)==
' ' || inc.
at(i)==
'"' || inc.
at(i)==
'<')
3798 bool localInclude = s>0 && inc.
at(s-1)==
'"';
3801 while (i<inc.
length() && inc.
at(i)!=
'"' && inc.
at(i)!=
'>') i++;
3803 if (s<inc.
length() && i>s)
3813 QCString oldFileName = state->fileName;
3814 FileDef *oldFileDef = state->yyFileDef;
3815 int oldLineNr = state->yyLineNr;
3821 std::unique_ptr<FileState> fs;
3822 bool alreadyProcessed =
FALSE;
3824 fs=
findFile(yyscanner,absIncFileName,localInclude,alreadyProcessed);
3835 for (i=0;i<state->includeStack.size();i++)
3842 if (state->includeStack.empty() && oldFileDef)
3844 PreIncludeInfo *ii = state->includeRelations.find(absIncFileName);
3849 state->includeRelations.add(
3852 ambig ?
nullptr : incFd,
3860 struct yyguts_t * yyg = (
struct yyguts_t*)yyscanner;
3861 fs->bufState = YY_CURRENT_BUFFER;
3862 fs->lineNr = oldLineNr;
3863 fs->fileName = oldFileName;
3864 fs->curlyCount = state->curlyCount;
3866 fs->lexRulesPart = state->lexRulesPart;
3867 fs->levelGuard = state->levelGuard;
3868 while (!state->levelGuard.empty()) state->levelGuard.pop();
3869 state->lexRulesPart =
false;
3872 state->includeStack.push_back(std::move(fs));
3882 state->expectGuard=
TRUE;
3883 state->inputBuf = &fs_ptr->
fileBuf;
3884 state->inputBufPos=0;
3885 yy_switch_to_buffer(yy_create_buffer(0,
YY_BUF_SIZE, yyscanner),yyscanner);
3889 if (alreadyProcessed)
3897 if (state->includeStack.empty() && oldFileDef)
3899 PreIncludeInfo *ii = state->includeRelations.find(absIncFileName);
3904 ii = state->includeRelations.add(absIncFileName,
3906 ambig ?
nullptr : incFd,
3916 for (i=0;i<state->includeStack.size();i++)
3920 if (alreadyProcessed)
3930 if (localInclude && !state->includeStack.empty() && state->curlyCount>0 && !alreadyProcessed)
3932 warn(state->fileName,state->yyLineNr,
"include file {} not found, perhaps you forgot to add its directory to INCLUDE_PATH?",incFileName);
3942 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
3945 bool expResult = prs.
parse(state->fileName.data(),state->yyLineNr,sectId.
data());
3946 state->condStack.emplace(std::make_unique<preYY_CondCtx>(state->fileName,state->yyLineNr,sectId,state->skip));
3956 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
3957 if (state->condGuardCount>0 && state->condGuardErrorLine==0)
3959 state->condGuardErrorLine = state->yyLineNr;
3960 state->condGuardErrorFileName = state->fileName;
3961 state->condGuardErrorMessage =
"more #if's than #endif's in \\cond..\\endcond section";
3963 else if (state->condGuardCount<0 && state->condGuardErrorLine==0)
3965 state->condGuardErrorLine = state->yyLineNr;
3966 state->condGuardErrorFileName = state->fileName;
3967 state->condGuardErrorMessage =
"more #endif's than #if's in \\cond..\\endcond section";
3971 state->condGuardErrorLine = 0;
3973 if (state->condStack.empty())
3975 warn(state->fileName,state->yyLineNr,
"the \\endcond does not have a corresponding \\cond in this file");
3980 const std::unique_ptr<preYY_CondCtx> &ctx = state->condStack.top();
3981 state->skip=ctx->skip;
3982 state->condStack.pop();
3989 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
3990 while (!state->condStack.empty())
3992 state->condStack.pop();
4003 const char *p=text.
data();
4006 if (c==
'@') result+=
"@@";
else result+=c;
4016 case '=':
return '#';
4017 case '/':
return '\\';
4018 case '\'':
return '^';
4019 case '(':
return '[';
4020 case ')':
return ']';
4021 case '!':
return '|';
4022 case '<':
return '{';
4023 case '>':
return '}';
4024 case '-':
return '~';
4038 return expr.
at(pos++);
4040 else if (rest && !rest->
isEmpty())
4049 int cc=yyinput(yyscanner);
4061 return expr.
at(pos);
4063 else if (rest && !rest->
isEmpty())
4071 int cc=yyinput(yyscanner);
4088 char cs[2];cs[0]=c;cs[1]=
'\0';
4104 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
4107 auto findDefine = [&undef,&name](
DefineMap &map)
4110 auto it = map.find(name.
str());
4123 Define *def = findDefine(state->localDefines);
4124 if (def==
nullptr && !undef)
4126 def = findDefine(state->contextDefines);
4133 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
4137 for (
const auto &ds : predefList)
4139 size_t i_equals=ds.find(
'=');
4140 size_t i_obrace=ds.find(
'(');
4141 size_t i_cbrace=ds.find(
')');
4142 bool nonRecursive = i_equals!=std::string::npos && i_equals>0 && ds[i_equals-1]==
':';
4144 if ((i_obrace==0) || (i_equals==0) || (i_equals==1 && ds[i_equals-1]==
':'))
4149 if (i_obrace<i_equals && i_cbrace<i_equals &&
4150 i_obrace!=std::string::npos && i_cbrace!=std::string::npos &&
4154 static const reg::Ex reId(R
"(\a\w*)");
4155 std::map<std::string,int> argMap;
4156 std::string args = ds.substr(i_obrace+1,i_cbrace-i_obrace-1);
4157 bool hasVarArgs = args.find(
"...")!=std::string::npos;
4163 for (; arg_it!=arg_end; ++arg_it)
4165 argMap.emplace(arg_it->
str(),count++);
4169 argMap.emplace(
"__VA_ARGS__",count++);
4173 std::string definition;
4174 std::string in=ds.substr(i_equals+1);
4180 for (; re_it!=re_end; ++re_it)
4182 const auto &match = *re_it;
4183 size_t pi = match.position();
4184 size_t l = match.length();
4185 if (pi>i) definition+=in.substr(i,pi-i);
4187 auto it = argMap.find(match.str());
4188 if (it!=argMap.end())
4190 int argIndex = it->second;
4192 marker.
sprintf(
" @%d ",argIndex);
4193 definition+=marker.
str();
4197 definition+=match.str();
4201 definition+=in.substr(i);
4204 std::string dname = ds.substr(0,i_obrace);
4213 def.
fileDef = state->yyFileDef;
4216 state->contextDefines.emplace(def.
name.
str(),def);
4222 else if (!ds.empty())
4226 if (i_equals==std::string::npos)
4233 int ine=
static_cast<int>(i_equals) - (nonRecursive ? 1 : 0);
4234 def.
name = ds.substr(0,ine);
4242 def.
fileDef = state->yyFileDef;
4244 state->contextDefines.emplace(def.
name.
str(),def);
4260 YY_EXTRA_TYPE state = preYYget_extra(
p->yyscanner);
4267 preYYlex_init_extra(&
p->state,&
p->yyscanner);
4273 preYYlex_destroy(
p->yyscanner);
4280 YY_EXTRA_TYPE state = preYYget_extra(
p->yyscanner);
4281 struct yyguts_t *yyg = (
struct yyguts_t*)
p->yyscanner;
4294 state->curlyCount=0;
4295 state->lexRulesPart=
false;
4296 state->nospaces=
FALSE;
4297 state->inputBuf=&input;
4298 state->inputBufPos=0;
4299 state->outputBuf=&output;
4300 state->includeStack.clear();
4301 state->expandedDict.clear();
4302 state->contextDefines.clear();
4303 state->pragmaSet.clear();
4304 state->condGuardCount=0;
4305 state->condGuardErrorLine=0;
4306 while (!state->levelGuard.empty()) state->levelGuard.pop();
4307 while (!state->condStack.empty()) state->condStack.pop();
4311 state->inputFileDef = state->yyFileDef;
4316 state->yyLineNr = 1;
4322 state->expectGuard =
guessSection(fileName).isHeader();
4323 state->guardName.clear();
4324 state->lastGuardName.clear();
4325 state->guardExpr.clear();
4327 preYYlex(yyscanner);
4329 while (!state->condStack.empty())
4331 const std::unique_ptr<preYY_CondCtx> &ctx = state->condStack.top();
4333 if (ctx->sectionId!=
" ") sectionInfo.
sprintf(
" with label '%s' ",
qPrint(ctx->sectionId.stripWhiteSpace()));
4334 warn(ctx->fileName,ctx->lineNr,
"Conditional section{}does not have "
4335 "a corresponding \\endcond command within this file.",sectionInfo);
4336 state->condStack.pop();
4341 if (!state->levelGuard.empty())
4343 if (yyextra->condGuardErrorLine!=0)
4345 warn(yyextra->condGuardErrorFileName,yyextra->condGuardErrorLine,
"{}",yyextra->condGuardErrorMessage);
4349 warn(state->fileName,state->yyLineNr,
"More #if's than #endif's found (might be in an included file).");
4357 std::string contents;
4365 bool startOfLine =
true;
4366 size_t content_size = output.size() +
4369 contents.reserve(content_size);
4371 while (pos<output.size())
4376 snprintf(lineNrStr,15,
"%05d ",line++);
4377 contents+=lineNrStr;
4379 contents += output[pos];
4380 startOfLine = output[pos]==
'\n';
4385 if (!contents.empty() && contents[contents.length()-1]!=
'\n')
4390 if (yyextra->contextDefines.size()>0)
4394 for (
auto &kv : yyextra->contextDefines)
4398 for (
auto &kv : yyextra->localDefines)
4412 for (
const auto &inc : state->includeRelations)
4414 auto toKind = [](
bool local,
bool imported) ->
IncludeKind
4430 if (inc->fromFileDef)
4432 inc->fromFileDef->addIncludeDependency(inc->toFileDef,inc->includeName,toKind(inc->local,inc->imported));
4434 if (inc->toFileDef && inc->fromFileDef)
4436 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.
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 void addTillEndOfComment(yyscan_t yyscanner, const QCString &expr, QCString *rest, uint32_t &pos, char term, QCString &arg)
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)