15%option never-interactive
18%option extra-type="struct preYY_state *"
22#define YY_TYPEDEF_YY_SCANNER_T
68#define YY_NO_UNISTD_H 1
133 for (
auto &[name,define] : fromMap)
151 if (dpf && includeStack.find(incFile)==includeStack.end())
153 includeStack.insert(incFile);
160 toMap.emplace(name,define);
174 void addInclude(
const std::string &fromFileName,
const std::string &toFileName)
180 it =
m_fileMap.emplace(fromFileName,std::make_unique<DefinesPerFile>(
this)).first;
182 auto &dpf = it->second;
183 dpf->addInclude(toFileName);
192 it =
m_fileMap.emplace(fileName,std::make_unique<DefinesPerFile>(
this)).first;
194 it->second->store(fromMap);
202 auto &dpf = it->second;
203 dpf->retrieve(toMap);
213 return it->second->stored();
223 return it!=
m_fileMap.end() ? it->second.get() :
nullptr;
226 std::unordered_map< std::string, std::unique_ptr<DefinesPerFile> >
m_fileMap;
351static yy_size_t
getFenceSize(
char *txt, yy_size_t leng);
356#define YY_INPUT(buf,result,max_size) result=yyread(yyscanner,buf,max_size);
constant expression parser used for the C preprocessor
A String class for use with Doxygen wrapping std::string and adding some additional functionality off...
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.
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.
static DString expandMacro(yyscan_t yyscanner, const DString &name)
static DString extractTrailingComment(const DString &s)
std::map< std::string, Define > DefineMap
A dictionary of managed Define objects.
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 DString expandStandardMacro(yyscan_t yyscanner, const DString &name)
static bool computeExpression(yyscan_t yyscanner, const DString &expr)
static void incrLevel(yyscan_t yyscanner)
static void outputSpaces(yyscan_t yyscanner, char *s)
static DString escapeAt(const DString &text)
static std::mutex g_globalDefineMutex
static void outputChar(yyscan_t yyscanner, char c)
static char resolveTrigraph(char c)
static void outputString(yyscan_t yyscanner, const DString &s)
static void setFileName(yyscan_t yyscanner, const DString &name)
static DefineManager g_defineManager
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 void outputSpace(yyscan_t yyscanner, char c)
static Define * isDefined(yyscan_t yyscanner, const DString &name)
Returns a reference to a Define object given its name or 0 if the Define does not exist.
static std::mutex g_debugMutex
Some helper functions for std::string.
const std::string * oldFileBuf
PreIncludeInfo(const DString &fn, FileDef *srcFd, FileDef *dstFd, const DString &iName, bool loc, bool imp)
preYY_CondCtx(const DString &file, int line, const DString &id, bool b)
StringUnorderedSet expanded
LinkedMap< PreIncludeInfo > includeRelations
DString condGuardErrorMessage
StringUnorderedSet pragmaSet
ConstExpressionParser constExpParser
std::unordered_map< std::string, Define * > expandedDict
std::deque< std::unique_ptr< FileState > > includeStack
std::stack< std::unique_ptr< preYY_CondCtx > > condStack
const std::string * inputBuf
DString condGuardErrorFileName
DefineList macroDefinitions
A bunch of utility functions.
366IDSTART [a-z_A-Z\x80-\xFF]
367ID {IDSTART}[a-z_A-Z0-9\x80-\xFF]*
371RAWBEGIN (u|U|L|u8)?R\"[^ \t\(\)\\]{0,16}"("
372RAWEND ")"[^ \t\(\)\\]{0,16}\"
373CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'"))
376FORMULA_START {CMD}("f{"|"f$"|"f["|"f(")
377FORMULA_END {CMD}("f}"|"f$"|"f]"|"f)")
378VERBATIM_START {CMD}("verbatim"|"iliteral"|"latexonly"|"htmlonly"|"xmlonly"|"docbookonly"|"rtfonly"|"manonly"|"dot"|"msc"|"mermaid"|"startuml"|"code"("{"[^}]*"}")?){BN}+
379VERBATIM_END {CMD}("endverbatim"|"endiliteral"|"endlatexonly"|"endhtmlonly"|"endxmlonly"|"enddocbookonly"|"endrtfonly"|"endmanonly"|"enddot"|"endmsc"|"endmermaid"|"enduml"|"endcode")
380VERBATIM_LINE {CMD}"noop"{B}+
381LITERAL_BLOCK {FORMULA_START}|{VERBATIM_START}
382LITERAL_BLOCK_END {FORMULA_END}|{VERBATIM_END}
387RulesSharp "<"[^>\n]*">"
388RulesCurly "{"[^{}\n]*"}"
393EscapeRulesCharOpen "\\["|"\<"|"\\{"|"\\("|"\\\""|"\\ "|"\\\\"
394EscapeRulesCharClose "\\]"|"\>"|"\\}"|"\\)"
395EscapeRulesChar {EscapeRulesCharOpen}|{EscapeRulesCharClose}
397DOXYCFG [A-Z][A-Z_0-9]*
412DECIMAL_INTEGER [1-9][0-9']*[0-9]?[uU]?[lL]?[lL]?
413HEXADECIMAL_INTEGER "0"[xX][0-9a-zA-Z']+[0-9a-zA-Z]?
414OCTAL_INTEGER "0"[0-7][0-7']+[0-7]?
415BINARY_INTEGER "0"[bB][01][01']*[01]?
416INTEGER_NUMBER {DECIMAL_INTEGER}|{HEXADECIMAL_INTEGER}|{OCTAL_INTEGER}|{BINARY_INTEGER}
420DIGIT_SEQ [0-9][0-9']*[0-9]?
421FRAC_CONST {DIGIT_SEQ}"."|{DIGIT_SEQ}?"."{DIGIT_SEQ}
422FP_EXP [eE][+-]?{DIGIT_SEQ}
423DEC_FP1 {FRAC_CONST}{FP_EXP}?{FP_SUF}?
424DEC_FP2 {DIGIT_SEQ}{FP_EXP}{FP_SUF}
426HEX_DIGIT_SEQ [0-9a-fA-F][0-9a-fA-F']*[0-9a-fA-F]?
427HEX_FRAC_CONST {HEX_DIGIT_SEQ}"."|{HEX_DIGIT_SEQ}?"."{HEX_DIGIT_SEQ}
428BIN_EXP [pP][+-]?{DIGIT_SEQ}
429HEX_FP1 "0"[xX]{HEX_FRAC_CONST}{BIN_EXP}{FP_SUF}?
430HEX_FP2 "0"[xX]{HEX_DIGIT_SEQ}{BIN_EXP}{FP_SUF}?
432FLOAT_DECIMAL {DEC_FP1}|{DEC_FP2}
433FLOAT_HEXADECIMAL {HEX_FP1}|{HEX_FP2}
434FLOAT_NUMBER {FLOAT_DECIMAL}|{FLOAT_HEXADECIMAL}
435NUMBER {INTEGER_NUMBER}|{FLOAT_NUMBER}
451%x CopyStringFtnDouble
468%x JavaDocVerbatimCode
502 yyextra->yyColNr+=(int)yyleng;
504 yyextra->potentialDefine=yytext;
507<Start>^("%top{"|"%{") {
SrcLangExt getLanguageFromFileName(const DString &fileName, SrcLangExt defLang)
512<Start>^{Bopt}"cpp_quote"{Bopt}"("{Bopt}\" {
513 if (yyextra->insideIDL)
528<IDLquote>"\""{Bopt}")" {
540 if (!yyextra->isFixedFormFtn) REJECT;
551<Start>^{B}*[a-z_A-Z\x80-\xFF][a-z_A-Z0-9\x80-\xFF]+{B}*"("[^\)\n]*")"/{BN}{1,10}*[:{] {
553 for (i=(
int)yyleng-1;i>=0;i--)
559<Start>^{B}*[_A-Z][_A-Z0-9]+{B}*"("[^\(\)\n]*"("[^\)\n]*")"[^\)\n]*")"{B}*\n |
560<Start>^{B}*[_A-Z][_A-Z0-9]+{B}*"("[^\)\n]*")"{B}*\n |
561<Start>^{B}*[_A-Z][_A-Z0-9]+{B}*"("[^\(\)\n]*"("[^\)\n]*")"[^\)\n]*")"/{B}*("//"|"/\*") |
562<Start>^{B}*[_A-Z][_A-Z0-9]+{B}*"("[^\)\n]*")"/{B}*("//"|"/\*") {
565 size_t pos = name.find(
'(');
567 name=name.left(pos).stripWhiteSpace();
570 if (skipFuncMacros && !yyextra->insideFtn &&
571 name!=
"Q_PROPERTY" &&
573 (yyextra->includeStack.empty() || yyextra->curlyCount>0) &&
574 yyextra->macroExpansion &&
582 if (yytext[yyleng-1] ==
'\n')
591 for (i=(
int)yyleng-1;i>=0;i--)
static constexpr size_t npos
value used to indicate 'not found' or 'to the end of the string', matching std::string::npos
#define Config_getBool(name)
598<CopyLine,LexCopyLine>"extern"{BN}*"\""[^\"]+"\""{BN}*("{")? {
600 yyextra->yyLineNr+=text.
contains(
'\n');
int contains(char c, bool cs=true) const
603<CopyLine,LexCopyLine>{RAWBEGIN} {
606 BEGIN(CopyRawString);
DString extractBeginRawStringDelimiter(const char *rawStart)
608<CopyLine,LexCopyLine>"{" {
609 if (yyextra->includeStack.empty())
611 yyextra->curlyCount++;
618<CopyLine,LexCopyLine>"}" {
619 if (yyextra->includeStack.empty() && yyextra->curlyCount>0)
621 yyextra->curlyCount--;
625<CopyLine,LexCopyLine>"'"\\[0-7]{1,3}"'" {
628<CopyLine,LexCopyLine>"'"\\."'" {
631<CopyLine,LexCopyLine>"'"."'" {
634<CopyLine,LexCopyLine>[$]?@\" {
637 BEGIN( CopyStringCs );
639<CopyLine,LexCopyLine>"!".* {
643<CopyLine,LexCopyLine>\" {
651 BEGIN( CopyStringFtnDouble );
654<CopyLine,LexCopyLine>\' {
657 BEGIN( CopyStringFtn );
659<CopyString>[^\"\\\r\n]{1,1000} {
662<CopyStringCs>[^\"\r\n]{1,1000} {
671<CopyString,CopyStringCs>\" {
675<CopyStringFtnDouble>[^\"\\\r\n]{1,1000} {
678<CopyStringFtnDouble>\\. {
681<CopyStringFtnDouble>\" {
685<CopyStringFtn>[^\'\\\r\n]{1,1000} {
695<CopyRawString>{RAWEND} {
DString extractEndRawStringDelimiter(const char *rawEnd)
702<CopyRawString>[^)]{1,1000} {
708<CopyLine,LexCopyLine>{ID}/{BN}{0,80}"(" {
709 yyextra->expectGuard =
false;
719 if ((yyextra->includeStack.empty() || yyextra->curlyCount>0) &&
720 yyextra->macroExpansion &&
726 yyextra->roundCount=0;
727 yyextra->defArgsStr=yytext;
738 yyextra->findDefArgContext = CopyLine;
739 BEGIN(FindDefineArgs);
747<CopyLine>{RulesDelim} {
749 yyextra->lexRulesPart = !yyextra->lexRulesPart;
753<CopyLine>{RulesSharp} {
754 if (!yyextra->lexRulesPart) REJECT;
755 if (yyextra->curlyCount) REJECT;
759<RulesPattern>{EscapeRulesChar} {
762<RulesPattern>{RulesCurly} {
765<RulesPattern>{StartDouble} {
767 yyextra->lastContext = YY_START;
770<RulesDouble,RulesRoundDouble>"\\\\" {
773<RulesDouble,RulesRoundDouble>"\\\"" {
778 BEGIN( yyextra->lastContext ) ;
780<RulesRoundDouble>"\"" {
784<RulesDouble,RulesRoundDouble>. {
787<RulesPattern>{StartSquare} {
789 yyextra->lastContext = YY_START;
792<RulesSquare,RulesRoundSquare>{CHARCE} {
795<RulesSquare,RulesRoundSquare>"\\[" |
796<RulesSquare,RulesRoundSquare>"\\]" {
803<RulesRoundSquare>"]" {
807<RulesSquare,RulesRoundSquare>"\\\\" {
810<RulesSquare,RulesRoundSquare>. {
813<RulesPattern>{StartRoundQuest} {
815 yyextra->lastContext = YY_START;
816 BEGIN(RulesRoundQuest);
818<RulesRoundQuest>{nl} {
821<RulesRoundQuest>[^)] {
824<RulesRoundQuest>")" {
826 BEGIN(yyextra->lastContext);
828<RulesPattern>{StartRound} {
829 yyextra->roundCount++;
831 yyextra->lastContext = YY_START;
834<RulesRound>{RulesCurly} {
837<RulesRound>{StartSquare} {
839 BEGIN(RulesRoundSquare);
841<RulesRound>{StartDouble} {
843 BEGIN(RulesRoundDouble);
845<RulesRound>{EscapeRulesChar} {
849 yyextra->roundCount++;
853 yyextra->roundCount--;
855 if (!yyextra->roundCount) BEGIN( yyextra->lastContext ) ;
874<CopyLine,LexCopyLine>{ID} {
877 if ((yyextra->includeStack.empty() || yyextra->curlyCount>0) &&
878 yyextra->macroExpansion &&
898<CopyLine,LexCopyLine>"\\"\r?/\n {
901<CopyLine,LexCopyLine>\\. {
904<CopyLine,LexCopyLine>. {
907<CopyLine,LexCopyLine>\n {
914 yyextra->defArgsStr+=
'(';
915 yyextra->roundCount++;
918 yyextra->defArgsStr+=
')';
919 yyextra->roundCount--;
920 if (yyextra->roundCount==0)
924 if (yyextra->findDefArgContext==CopyLine)
927 BEGIN(yyextra->findDefArgContext);
932 yyextra->nospaces=
false;
942<FindDefineArgs>{CHARLIT} {
943 yyextra->defArgsStr+=yytext;
945<FindDefineArgs>{CCS}[*!]? {
946 yyextra->defArgsStr+=yytext;
947 BEGIN(ArgCopyCComment);
949<FindDefineArgs>{CPPC}[/!].*\n/{B}*{CPPC}[/!] {
954 yyextra->defArgsStr+=
DString(
"/**< @brief ")+&yytext[4];
958 yyextra->defArgsStr+=
DString(
"/** @brief ")+&yytext[3];
963 yyextra->defArgsStr+=
DString(
"/**")+&yytext[3];
965 BEGIN(ArgCopyCppComment);
967<FindDefineArgs>{CPPC}[/!].*\n {
970 yyextra->defArgsStr+=
DString(
"/**")+&yytext[3]+
" */";
976 yyextra->defArgsStr+=
DString(
"/**< @brief ")+&yytext[4]+
" */";
980 yyextra->defArgsStr+=
DString(
"/** @brief ")+&yytext[3]+
" */";
984<FindDefineArgs>{CPPC}.*\n {
986 yyextra->defArgsStr+=
DString(
"/*")+&yytext[2]+
" */";
989 yyextra->defArgsStr+=*yytext;
994 yyextra->defArgsStr+=*yytext;
998 yyextra->defArgsStr+=
' ';
1002<FindDefineArgs>"@" {
1003 yyextra->defArgsStr+=
"@@";
1006 yyextra->defArgsStr+=*yytext;
1008<ArgCopyCComment>[^*\n]+ {
1009 yyextra->defArgsStr+=yytext;
1011<ArgCopyCComment>{CCE} {
1012 yyextra->defArgsStr+=yytext;
1013 BEGIN(FindDefineArgs);
1015<ArgCopyCComment>\n {
1016 yyextra->defArgsStr+=yytext;
1017 yyextra->yyLineNr++;
1020 yyextra->defArgsStr+=yytext;
1022<ArgCopyCppComment>^{B}*
1023<ArgCopyCppComment>{CPPC}[/!].*\n/{B}*{CPPC}[/!] {
1024 const char *startContent = &yytext[3];
1025 if (startContent[0]==
'<') startContent++;
1026 yyextra->defArgsStr+=startContent;
1028<ArgCopyCppComment>{CPPC}[/!].*\n {
1029 const char *startContent = &yytext[3];
1030 if (startContent[0]==
'<') startContent++;
1031 yyextra->defArgsStr+=
DString(startContent)+
" */";
1032 BEGIN(FindDefineArgs);
1034<ArgCopyCppComment>. {
1036 yyextra->defArgsStr+=
" */";
1037 BEGIN(FindDefineArgs);
1040 yyextra->defArgsStr+=*yytext;
1041 BEGIN(FindDefineArgs);
1045 yyextra->defArgsStr+=*yytext;
1046 BEGIN(FindDefineArgs);
1049<ReadString>{CPPC}|{CCS} {
1050 yyextra->defArgsStr+=yytext;
1052<ReadString>\\/\r?\n {
1055 yyextra->defArgsStr+=yytext;
1058 yyextra->defArgsStr+=*yytext;
1060<Command>("include"|"import"){B}+/{ID} {
1061 yyextra->isImported = yytext[1]==
'm';
1062 if (yyextra->macroExpansion)
1065<Command>("include"|"import"){B}*[<"] {
1066 yyextra->isImported = yytext[1]==
'm';
1068 c[0]=yytext[yyleng-1];c[1]=
'\0';
1072<Command>("cmake")?"define"{B}+ {
1073 yyextra->potentialDefine +=
substitute(yytext,
"cmake",
" ");
1075 yyextra->yyColNr+=(int)yyleng;
DString substitute(const DString &s, const DString &src, const DString &dst)
substitute all occurrences of src in s by dst
1078<Command>"cmakedefine01"{B}+ {
1079 yyextra->potentialDefine +=
substitute(yytext,
"cmakedefine01",
" define ");
1081 yyextra->yyColNr+=(int)yyleng;
1082 BEGIN(CmakeDefName01);
1084<Command>"ifdef"/{B}*"(" {
1086 yyextra->guardExpr.clear();
1087 BEGIN(DefinedExpr2);
1089<Command>"ifdef"/{B}+ {
1092 yyextra->guardExpr.clear();
1093 BEGIN(DefinedExpr1);
1095<Command>"ifndef"/{B}*"(" {
1097 yyextra->guardExpr=
"! ";
1098 BEGIN(DefinedExpr2);
1100<Command>"ifndef"/{B}+ {
1102 yyextra->guardExpr=
"! ";
1103 BEGIN(DefinedExpr1);
1105<Command>"if"/[ \t(!] {
1107 yyextra->guardExpr.clear();
1110<Command>("elif"|"else"{B}*"if")/[ \t(!] {
1113 yyextra->guardExpr.clear();
1119 BEGIN(SkipCPPBlock);
1122<Command>"else"/[^a-z_A-Z0-9\x80-\xFF] {
1126 BEGIN(SkipCPPBlock);
1133<Command>"undef"{B}+ {
1136<Command>("elif"|"else"{B}*"if")/[ \t(!] {
1139 yyextra->guardExpr.clear();
1143<Command>"endif"/[^a-z_A-Z0-9\x80-\xFF] {
1147<Command,IgnoreLine>\n {
1150 yyextra->yyLineNr++;
1152<Command>"pragma"{B}+"once" {
1153 yyextra->expectGuard =
false;
1154 if (yyextra->pragmaSet.find(yyextra->fileName.str())!=yyextra->pragmaSet.end())
1161 yyextra->pragmaSet.insert(yyextra->fileName.data());
1166<PragmaOnce><<EOF>> {
1167 yyextra->expectGuard =
false;
1173<IgnoreLine>\\[\r]?\n {
1175 yyextra->yyLineNr++;
1178<Command>. { yyextra->potentialDefine += yytext[0]==
'\t' ?
'\t' :
' ';
1179 yyextra->yyColNr+=(int)yyleng;
1195 yyextra->guardExpr+=
' ';
1196 yyextra->yyLineNr++;
1198<Guard>"defined"/{B}*"(" {
1199 BEGIN(DefinedExpr2);
1201<Guard>"defined"/{B}+ {
1202 BEGIN(DefinedExpr1);
1204<Guard>"true"/{B}|{B}*[\r]?\n { yyextra->guardExpr+=
"1L"; }
1205<Guard>"false"/{B}|{B}*[\r]?\n { yyextra->guardExpr+=
"0L"; }
1206<Guard>"not"/{B} { yyextra->guardExpr+=
'!'; }
1207<Guard>"not_eq"/{B} { yyextra->guardExpr+=
"!="; }
1208<Guard>"and"/{B} { yyextra->guardExpr+=
"&&"; }
1209<Guard>"or"/{B} { yyextra->guardExpr+=
"||"; }
1210<Guard>"bitand"/{B} { yyextra->guardExpr+=
"&"; }
1211<Guard>"bitor"/{B} { yyextra->guardExpr+=
"|"; }
1212<Guard>"xor"/{B} { yyextra->guardExpr+=
"^"; }
1213<Guard>"compl"/{B} { yyextra->guardExpr+=
"~"; }
1214<Guard>{ID} { yyextra->guardExpr+=yytext; }
1215<Guard>"@" { yyextra->guardExpr+=
"@@"; }
1216<Guard>. { yyextra->guardExpr+=*yytext; }
1230 BEGIN(SkipCPPBlock);
1233<DefinedExpr1,DefinedExpr2>\\\n { yyextra->yyLineNr++;
outputChar(yyscanner,
'\n'); }
1235 if (
isDefined(yyscanner,yytext) || yyextra->guardName==yytext)
1236 yyextra->guardExpr+=
" 1L ";
1238 yyextra->guardExpr+=
" 0L ";
1239 yyextra->lastGuardName=yytext;
1243 if (
isDefined(yyscanner,yytext) || yyextra->guardName==yytext)
1244 yyextra->guardExpr+=
" 1L ";
1246 yyextra->guardExpr+=
" 0L ";
1247 yyextra->lastGuardName=yytext;
1249<DefinedExpr1,DefinedExpr2>\n {
1250 yyextra->yyLineNr++;
1252 BEGIN(SkipCPPBlock);
1257<DefinedExpr1,DefinedExpr2>.
1258<SkipCPPBlock>^{B}*"#" { BEGIN(SkipCommand); }
1259<SkipCPPBlock>^{Bopt}/[^#] { BEGIN(SkipLine); }
1260<SkipCPPBlock>\n { yyextra->yyLineNr++;
outputChar(yyscanner,
'\n'); }
1262<SkipCommand>"if"(("n")?("def"))?/[ \t(!] {
1267<SkipCommand>"else" {
1276<SkipCommand>("elif"|"else"{B}*"if")/[ \t(!] {
1277 if (yyextra->ifcount==0)
1281 yyextra->guardExpr.clear();
1282 yyextra->lastGuardName.clear();
1287 BEGIN(SkipCPPBlock);
1291<SkipCommand>"endif" {
1292 yyextra->expectGuard =
false;
1294 if (--yyextra->ifcount<0)
1302 yyextra->yyLineNr++;
1303 BEGIN(SkipCPPBlock);
1310<SkipLine>{CHARLIT} { }
1315<SkipString>{CPPC}/[^\n]* {
1317<SkipLine,SkipCommand,SkipCPPBlock>{CPPC}[^\n]* {
1318 yyextra->lastCPPContext=YY_START;
1319 BEGIN(RemoveCPPComment);
1321<SkipString>{CCS}/[^\n]* {
1323<SkipLine,SkipCommand,SkipCPPBlock>{CCS}/[^\n]* {
1324 yyextra->lastCContext=YY_START;
1325 BEGIN(RemoveCComment);
1329 yyextra->yyLineNr++;
1330 BEGIN(SkipCPPBlock);
1332<SkipString>[^"\\\n]+ { }
1338<IncludeID>{ID}{Bopt}/"(" {
1339 yyextra->nospaces=
true;
1340 yyextra->roundCount=0;
1341 yyextra->defArgsStr=yytext;
1342 yyextra->findDefArgContext = IncludeID;
1343 BEGIN(FindDefineArgs);
1346 yyextra->nospaces=
true;
1350<Include>[^\">\n]+[\">] {
1351 yyextra->incName+=yytext;
1352 if (yyextra->isImported)
1362<EndImport>{ENDIMPORTopt}/\n {
1366<EndImport>\\[\r]?"\n" {
1368 yyextra->yyLineNr++;
1372<DefName>{ID}/("\\\n")*"(" {
1374 yyextra->argMap.clear();
1375 yyextra->defArgs = 0;
1376 yyextra->defArgsStr.clear();
1377 yyextra->defText.clear();
1378 yyextra->defLitText.clear();
1379 yyextra->defName = yytext;
1380 yyextra->defVarArgs =
false;
1381 yyextra->defExtraSpacing.clear();
1382 yyextra->defContinue =
false;
1385<DefName>{ID}{B}+"1"/[ \r\t\n] {
1387 yyextra->argMap.clear();
1388 yyextra->defArgs = -1;
1389 yyextra->defArgsStr.clear();
1390 yyextra->defName =
DString(yytext).left(yyleng-1).stripWhiteSpace();
1391 yyextra->defVarArgs =
false;
1394 if (yyextra->curlyCount>0 || yyextra->defName!=yyextra->lastGuardName || !yyextra->expectGuard)
1396 DString def = yyextra->potentialDefine +
1399 outputSpaces(yyscanner,yytext+yyextra->defName.length());
1400 yyextra->quoteArg=
false;
1401 yyextra->insideComment=
false;
1402 yyextra->lastGuardName.clear();
1403 yyextra->defText=
"1";
1404 yyextra->defLitText=
"1";
1410 yyextra->defText.clear();
1411 yyextra->defLitText.clear();
1414 yyextra->expectGuard=
false;
1416<DefName,CmakeDefName01>{ID}/{B}*"\n" {
1417 yyextra->argMap.clear();
1418 yyextra->defArgs = -1;
1419 yyextra->defName = yytext;
1420 yyextra->defArgsStr.clear();
1421 yyextra->defText.clear();
1422 yyextra->defLitText.clear();
1423 yyextra->defVarArgs =
false;
1426 if (yyextra->curlyCount>0 || yyextra->defName!=yyextra->lastGuardName || !yyextra->expectGuard)
1428 DString def = yyextra->potentialDefine + yyextra->defName;
1430 yyextra->quoteArg=
false;
1431 yyextra->insideComment=
false;
1432 if (YY_START == CmakeDefName01) yyextra->defText =
"0";
1433 else if (yyextra->insideCS) yyextra->defText=
"1";
1439 yyextra->guardName = yytext;
1440 yyextra->lastGuardName.clear();
1443 yyextra->expectGuard=
false;
1447 yyextra->argMap.clear();
1448 yyextra->defArgs = -1;
1449 yyextra->defArgsStr.clear();
1450 yyextra->defText.clear();
1451 yyextra->defLitText.clear();
1452 yyextra->defName = yytext;
1453 yyextra->defVarArgs =
false;
1454 DString def = yyextra->potentialDefine +
1456 yyextra->defArgsStr ;
1458 yyextra->quoteArg=
false;
1459 yyextra->insideComment=
false;
1463 yyextra->defExtraSpacing+=
"\n";
1464 yyextra->defContinue =
true;
1465 yyextra->yyLineNr++;
1467<DefineArg>{B}* { yyextra->defExtraSpacing+=yytext; }
1468<DefineArg>","{B}* { yyextra->defArgsStr+=yytext; }
1469<DefineArg>"("{B}* { yyextra->defArgsStr+=yytext; }
1470<DefineArg>{B}*")"{B}* {
1472 yyextra->defArgsStr+=yytext;
1473 DString def = yyextra->potentialDefine +
1475 yyextra->defArgsStr +
1476 yyextra->defExtraSpacing ;
1478 yyextra->quoteArg=
false;
1479 yyextra->insideComment=
false;
1483 yyextra->defVarArgs =
true;
1484 yyextra->defArgsStr+=yytext;
1485 yyextra->argMap.emplace(std::string(
"__VA_ARGS__"),yyextra->defArgs);
1488<DefineArg>{ID}{B}*("..."?) {
1491 yyextra->defVarArgs = yytext[yyleng-1]==
'.';
1492 if (yyextra->defVarArgs)
1497 yyextra->defArgsStr+=yytext;
1498 yyextra->argMap.emplace(
toStdString(argName),yyextra->defArgs);
DString stripWhiteSpace() const
returns a copy of this string with leading and trailing whitespace removed
DString left(size_t len) const
size_t length() const
Returns the length of the string, not counting the 0-terminator.
std::string toStdString(const DString &s)
1514<DefineText>{CCS}[^!*] {
1515 yyextra->defLitText+=
' ';
1517 yyextra->lastCContext=YY_START;
1518 yyextra->commentCount=1;
1519 BEGIN(SkipCComment);
1521<DefineText>{CCS}[!*] {
1522 yyextra->defText+=yytext;
1523 yyextra->defLitText+=yytext;
1524 yyextra->lastCContext=YY_START;
1525 yyextra->commentCount=1;
1526 BEGIN(CopyCComment);
1528<DefineText>{CPPC}[!/]? {
1530 yyextra->lastCPPContext=YY_START;
1531 yyextra->defLitText+=
' ';
1532 BEGIN(SkipCPPComment);
1534<SkipCComment>[/]?{CCE} {
1535 if (yytext[0]==
'/')
outputChar(yyscanner,
'/');
1537 if (--yyextra->commentCount<=0)
1539 if (yyextra->lastCContext==Start)
1543 YY_CURRENT_BUFFER->yy_at_bol=1;
1545 BEGIN(yyextra->lastCContext);
1548<SkipCComment>{CPPC}("/")* {
1551<SkipCComment>{CCS} {
1555<SkipCond>{CMD}{CMD} { }
1556<SkipCond>^({B}*"*"+)?{B}{0,3}"~~~"[~]* {
1558 if (!markdownSupport || !yyextra->isSpecialComment)
1564 yyextra->fenceChar=
'~';
1566 BEGIN(SkipCondVerbatim);
1569<SkipCond>^({B}*"*"+)?{B}{0,3}"```"[`]* {
1571 if (!markdownSupport || !yyextra->isSpecialComment)
1577 yyextra->fenceChar=
'`';
1579 BEGIN(SkipCondVerbatim);
1582<SkipCComment>^({B}*"*"+)?{B}{0,3}"~~~"[~]* {
1584 if (!markdownSupport || !yyextra->isSpecialComment)
1591 yyextra->fenceChar=
'~';
1593 BEGIN(SkipVerbatim);
1596<SkipCComment>^({B}*"*"+)?{B}{0,3}"```"[`]* {
1598 if (!markdownSupport || !yyextra->isSpecialComment)
1605 yyextra->fenceChar=
'`';
1607 BEGIN(SkipVerbatim);
1610<SkipCComment>{CMD}{VERBATIM_LINE} |
1611<SkipCComment>{CMD}{LITERAL_BLOCK} {
1613 yyextra->yyLineNr+=
DString(yytext).contains(
'\n');
1615<SkipCComment>{VERBATIM_LINE}.*/\n {
1618<SkipCComment>{LITERAL_BLOCK} {
1620 yyextra->yyLineNr+=
DString(yytext).contains(
'\n');
1621 if (yyextra->isSpecialComment)
1624 BEGIN(SkipVerbatim);
1627<SkipCond>{CMD}{CMD}"cond"[ \t]+ {}
1628<SkipCond>{CMD}"cond"/\n |
1629<SkipCond>{CMD}"cond"[ \t]+ {
static void startCondSection(yyscan_t yyscanner, const DString §Id)
1633<SkipCComment>"{"[ \t]*"@code"/[ \t\n] {
1635 yyextra->javaBlock=1;
1636 BEGIN(JavaDocVerbatimCode);
1638<SkipCComment>"{"[ \t]*"@literal"/[ \t\n] {
1640 yyextra->javaBlock=1;
1641 BEGIN(JavaDocVerbatimCode);
1643<SkipCComment,SkipCPPComment>{CMD}{CMD}"cond"[ \t\n]+ {
1646<SkipCPPComment>{CMD}"cond"[ \t]+ {
1647 yyextra->ccomment=
true;
1648 yyextra->condCtx=YY_START;
1651<SkipCComment>{CMD}"cond"[ \t]+ {
1652 yyextra->ccomment=
false;
1653 yyextra->condCtx=YY_START;
1656<CondLineC,CondLineCpp>([!()&| \ta-z_A-Z0-9\x80-\xFF.\-]|{CMD}"doxyconfig")+ {
1660 if (YY_START==CondLineC)
1664 yyextra->ccomment=
true;
1668 yyextra->ccomment=
false;
1674 BEGIN(yyextra->condCtx);
1677CondLine>{B}*{CMD}doxyconfig{B}+{DOXYCFG} {
1680<CondLineC,CondLineCpp>. {
1685 if (YY_START==CondLineC)
1689 yyextra->ccomment=
true;
1693 yyextra->ccomment=
false;
1699 BEGIN(yyextra->condCtx);
1702<SkipCComment,SkipCPPComment>{CMD}"cond"{WSopt}/\n {
1703 if (YY_START==SkipCComment)
1705 yyextra->ccomment=
true;
1711 yyextra->ccomment=
false;
1713 yyextra->condCtx=YY_START;
1714 yyextra->condGuardCount=0;
1718<SkipCond>\n { yyextra->yyLineNr++;
outputChar(yyscanner,
'\n'); }
1719<SkipCond>{VERBATIM_LINE}.*/\n { }
1720<SkipCond>{LITERAL_BLOCK} {
1721 auto numNLs =
DString(yytext).contains(
'\n');
1722 yyextra->yyLineNr+=numNLs;
1723 for (
int i = 0; i < numNLs; i++)
outputChar(yyscanner,
'\n');
1725 BEGIN(SkipCondVerbatim);
1729<SkipCond>"#if"("def")? { yyextra->condGuardCount++; }
1730<SkipCond>"#endif" { yyextra->condGuardCount--; }
1731<SkipCond>[^\/\!*\\@\n#]+ { }
1732<SkipCond>{CPPC}[/!] { yyextra->ccomment=
false; }
1733<SkipCond>{CCS}[*!] { yyextra->ccomment=
true; }
1734<SkipCond,SkipCComment,SkipCPPComment>{CMD}{CMD}"endcond"/[^a-z_A-Z0-9\x80-\xFF] {
1740<SkipCond>{CMD}"endcond"/[^a-z_A-Z0-9\x80-\xFF] {
1741 bool oldSkip = yyextra->skip;
1743 if (oldSkip && !yyextra->skip)
1745 if (yyextra->ccomment)
1749 BEGIN(yyextra->condCtx);
1752<SkipCComment,SkipCPPComment>{CMD}"endcond"/[^a-z_A-Z0-9\x80-\xFF] {
1753 bool oldSkip = yyextra->skip;
1755 if (oldSkip && !yyextra->skip)
1757 BEGIN(yyextra->condCtx);
1760<SkipCondVerbatim>{LITERAL_BLOCK_END} {
1761 if (yytext[1]==
'f' && yyextra->blockName==&yytext[2])
1765 else if (&yytext[4]==yyextra->blockName)
1770<SkipVerbatim>{LITERAL_BLOCK_END} {
1772 if (yytext[1]==
'f' && yyextra->blockName==&yytext[2])
1774 BEGIN(SkipCComment);
1776 else if (&yytext[4]==yyextra->blockName)
1778 BEGIN(SkipCComment);
1781<SkipCondVerbatim>^({B}*"*"+)?{B}{0,3}"~~~"[~]* {
1782 if (yyextra->fenceSize==
getFenceSize(yytext,yyleng) && yyextra->fenceChar==
'~')
1787<SkipCondVerbatim>^({B}*"*"+)?{B}{0,3}"```"[`]* {
1788 if (yyextra->fenceSize==
getFenceSize(yytext,yyleng) && yyextra->fenceChar==
'`')
1793<SkipVerbatim>^({B}*"*"+)?{B}{0,3}"~~~"[~]* {
1795 if (yyextra->fenceSize==
getFenceSize(yytext,yyleng) && yyextra->fenceChar==
'~')
1797 BEGIN(SkipCComment);
1800<SkipVerbatim>^({B}*"*"+)?{B}{0,3}"```"[`]* {
1802 if (yyextra->fenceSize==
getFenceSize(yytext,yyleng) && yyextra->fenceChar==
'`')
1804 BEGIN(SkipCComment);
1807<SkipCondVerbatim>{CCE}|{CCS} { }
1808<SkipVerbatim>{CCE}|{CCS} {
1811<JavaDocVerbatimCode>"{" {
1812 if (yyextra->javaBlock==0)
1818 yyextra->javaBlock++;
1822<JavaDocVerbatimCode>"}" {
1823 if (yyextra->javaBlock==0)
1829 yyextra->javaBlock--;
1830 if (yyextra->javaBlock==0)
1833 BEGIN(SkipCComment);
1841<JavaDocVerbatimCode>\n {
1844<JavaDocVerbatimCode>. {
1847<SkipCondVerbatim>[^{*\\@\x06~`\n\/]+ { }
1848<SkipCComment,SkipVerbatim>[^{*\\@\x06~`\n\/]+ {
1851<SkipCComment,SkipVerbatim,SkipCondVerbatim>\n {
1852 yyextra->yyLineNr++;
1855<SkipCondVerbatim>. { }
1856<SkipCComment,SkipVerbatim>. {
1859<CopyCComment>[^*a-z_A-Z\x80-\xFF\n]*[^*a-z_A-Z\x80-\xFF\\\n] {
1860 yyextra->defLitText+=yytext;
1861 yyextra->defText+=
escapeAt(yytext);
1863<CopyCComment>\\[\r]?\n {
1864 yyextra->defLitText+=yytext;
1865 yyextra->defText+=
" ";
1866 yyextra->yyLineNr++;
1867 yyextra->yyMLines++;
1869<CopyCComment>{CCE} {
1870 yyextra->defLitText+=yytext;
1871 yyextra->defText+=yytext;
1872 BEGIN(yyextra->lastCContext);
1875 yyextra->yyLineNr++;
1876 yyextra->defLitText+=yytext;
1877 yyextra->defText+=
' ';
1879<RemoveCComment>{CCE}{B}*"#" {
1880 if (yyextra->lastCContext==SkipCPPBlock)
1889<RemoveCComment>{CCE} { BEGIN(yyextra->lastCContext); }
1890<RemoveCComment>{CPPC}
1891<RemoveCComment>{CCS}
1892<RemoveCComment>[^*\x06\n]+
1893<RemoveCComment>\n { yyextra->yyLineNr++;
outputChar(yyscanner,
'\n'); }
1895<SkipCPPComment>[^\n\/\\@]+ {
1898<SkipCPPComment,RemoveCPPComment>\n {
1900 BEGIN(yyextra->lastCPPContext);
1902<SkipCPPComment>{CCS} {
1905<SkipCPPComment>{CPPC} {
1908<SkipCPPComment>[^\x06\@\\\n]+ {
1914<RemoveCPPComment>{CCS}
1915<RemoveCPPComment>{CPPC}
1916<RemoveCPPComment>[^\x06\n]+
1918<DefineText>"__VA_OPT__("{B}*"##" {
1919 warn(yyextra->fileName,yyextra->yyLineNr,
1920 "'##' may not appear at the beginning of a __VA_OPT__()",
1921 yyextra->defName,yyextra->defLitText.stripWhiteSpace());
1922 yyextra->defText+=
"__VA_OPT__(";
1923 yyextra->defLitText+=
"__VA_OPT__(";
#define warn(file, line, fmt,...)
1925<DefineText>"#"/"__VA_OPT__" {
1926 yyextra->defText+=yytext;
1927 yyextra->defLitText+=yytext;
1929<DefineText>"#"/{IDSTART} {
1931 yyextra->quoteArg=
true;
1932 yyextra->idStart=
true;
1933 yyextra->defLitText+=yytext;
1935<DefineText,CopyCComment>{ID} {
1936 yyextra->defLitText+=yytext;
1937 if (YY_START == DefineText)
outputSpaces(yyscanner,yytext);
1938 if (yyextra->quoteArg)
1940 yyextra->defText+=
"\"";
1942 if (yyextra->defArgs>0)
1944 auto it = yyextra->argMap.find(yytext);
1945 if (it!=yyextra->argMap.end())
1948 yyextra->defText+=
'@';
1949 yyextra->defText+=
DString().setNum(n);
1953 if (yyextra->idStart)
1955 warn(yyextra->fileName,yyextra->yyLineNr,
1956 "'#' is not followed by a macro parameter '{}': '{}'",
1957 yyextra->defName,yyextra->defLitText.stripWhiteSpace());
1959 yyextra->defText+=yytext;
1964 yyextra->defText+=yytext;
1966 if (yyextra->quoteArg)
1968 yyextra->defText+=
"\"";
1970 yyextra->quoteArg=
false;
1971 yyextra->idStart=
false;
1974 yyextra->defLitText+=yytext;
1975 yyextra->defText+=yytext;
1977<DefineText>\\[\r]?\n {
1978 yyextra->defLitText+=yytext;
1981 yyextra->defText +=
' ';
1982 yyextra->yyLineNr++;
1983 yyextra->yyMLines++;
1987 yyextra->defText = yyextra->defText.stripWhiteSpace();
1988 if (yyextra->defText.startsWith(
"##"))
1990 warn(yyextra->fileName,yyextra->yyLineNr,
1991 "'##' cannot occur at the beginning of a macro definition '{}': '{}'",
1992 yyextra->defName,yyextra->defLitText.stripWhiteSpace());
1994 else if (yyextra->defText.endsWith(
"##"))
1996 warn(yyextra->fileName,yyextra->yyLineNr,
1997 "'##' cannot occur at the end of a macro definition '{}': '{}'",
1998 yyextra->defName,yyextra->defLitText.stripWhiteSpace());
2000 else if (yyextra->defText.endsWith(
"#"))
2002 warn(yyextra->fileName,yyextra->yyLineNr,
2003 "expected formal parameter after # in macro definition '{}': '{}'",
2004 yyextra->defName,yyextra->defLitText.stripWhiteSpace());
2006 if (!comment.
empty())
2009 yyextra->defLitText=yyextra->defLitText.left(yyextra->defLitText.length()-comment.
length()-1);
2012 yyextra->defLitText+=yytext;
2015 if (yyextra->includeStack.empty() || yyextra->curlyCount>0)
2019 def=
isDefined(yyscanner,yyextra->defName);
2033 def->
name = yyextra->defName;
2035 def->
nargs = yyextra->defArgs;
2037 def->
lineNr = yyextra->yyLineNr-yyextra->yyMLines;
2042 if (def->
fileName != yyextra->fileName && !yyextra->expandOnlyPredef)
addDefine(yyscanner);
2046 yyextra->argMap.clear();
2047 yyextra->yyLineNr++;
2049 yyextra->lastGuardName.clear();
bool empty() const
Returns true iff the string is empty (std::string compatible alias for isEmpty()).
2053 yyextra->defText +=
' ';
2054 yyextra->defLitText+=yytext;
2057 yyextra->defText +=
"##";
2058 yyextra->defLitText+=yytext;
2061 yyextra->defText +=
"@@";
2062 yyextra->defLitText+=yytext;
2066 yyextra->defText += *yytext;
2067 yyextra->defLitText+=yytext;
2068 if (!yyextra->insideComment)
2070 BEGIN(SkipDoubleQuote);
2073<DefineText>{NUMBER} {
2075 yyextra->defText += yytext;
2076 yyextra->defLitText+=yytext;
2080 yyextra->defText += *yytext;
2081 yyextra->defLitText+=yytext;
2082 if (!yyextra->insideComment)
2084 BEGIN(SkipSingleQuote);
2087<SkipDoubleQuote>{CPPC}[/]? {
outputSpaces(yyscanner,yytext);
2088 yyextra->defText += yytext;
2089 yyextra->defLitText+=yytext;
2091<SkipDoubleQuote>{CCS}[*]? {
outputSpaces(yyscanner,yytext);
2092 yyextra->defText += yytext;
2093 yyextra->defLitText+=yytext;
2095<SkipDoubleQuote>\" {
2097 yyextra->defText += *yytext;
2098 yyextra->defLitText+=yytext;
2101<SkipSingleQuote,SkipDoubleQuote>\\. {
2103 yyextra->defText += yytext;
2104 yyextra->defLitText+=yytext;
2106<SkipSingleQuote>\' {
2108 yyextra->defText += *yytext;
2109 yyextra->defLitText+=yytext;
2112<SkipDoubleQuote,SkipSingleQuote>. {
outputSpace(yyscanner,yytext[0]);
2113 yyextra->defText += *yytext;
2114 yyextra->defLitText += *yytext;
2117 yyextra->defText += *yytext;
2118 yyextra->defLitText += *yytext;
2121 TRACE(
"End of include file");
2123 if (yyextra->includeStack.empty())
2125 TRACE(
"Terminating scanner");
2130 if (!yyextra->levelGuard.empty())
2132 if (yyextra->condGuardErrorLine!=0)
2134 warn(yyextra->condGuardErrorFileName,yyextra->condGuardErrorLine,
"{}",yyextra->condGuardErrorMessage);
2138 warn(yyextra->fileName,yyextra->yyLineNr,
"More #endif's than #if's found.");
2141 DString toFileName = yyextra->fileName;
2142 const std::unique_ptr<FileState> &fs=yyextra->includeStack.
back();
2144 YY_BUFFER_STATE oldBuf = YY_CURRENT_BUFFER;
2145 yy_switch_to_buffer( fs->bufState, yyscanner );
2146 yy_delete_buffer( oldBuf, yyscanner );
2147 yyextra->yyLineNr = fs->lineNr;
2149 yyextra->inputBuf = fs->oldFileBuf;
2150 yyextra->inputBufPos = fs->oldFileBufPos;
2151 yyextra->curlyCount = fs->curlyCount;
2152 yyextra->levelGuard = fs->levelGuard;
2154 TRACE(
"switching to {}",yyextra->fileName);
2159 lineStr.sprintf(
"# %d \"%s\" 2",yyextra->yyLineNr,
qPrint(yyextra->fileName));
2162 yyextra->includeStack.pop_back();
2185 for (
const auto &kv : yyextra->localDefines)
2187 auto pair = yyextra->contextDefines.insert(kv);
2190 yyextra->contextDefines.erase(pair.first);
2191 yyextra->contextDefines.insert(kv);
2194 yyextra->localDefines.clear();
char & back()
Returns a reference to the last character.
const std::string & str() const
static bool isFlagSet(const DebugMask mask)
static void print(DebugMask mask, int prio, fmt::format_string< Args... > fmt, Args &&... args)
const char * qPrint(const char *s)
2199 if (YY_START==SkipVerbatim || YY_START == SkipCondVerbatim || YY_START==SkipCond || YY_START==IDLquote || YY_START == PragmaOnce)
2206 yyextra->lastCContext=YY_START;
2207 yyextra->commentCount=1;
2210 yyextra->isSpecialComment =
true;
2211 yyextra->lastGuardName.clear();
2215 yyextra->isSpecialComment =
false;
2217 BEGIN(SkipCComment);
2221 if (YY_START==SkipVerbatim || YY_START == SkipCondVerbatim || YY_START==SkipCond ||
getLanguageFromFileName(yyextra->fileName)==SrcLangExt::Fortran || YY_START==IDLquote || YY_START == PragmaOnce)
2225 else if (YY_START==RulesRoundDouble)
2232 yyextra->lastCPPContext=YY_START;
2235 yyextra->isSpecialComment =
true;
2236 yyextra->lastGuardName.clear();
2240 yyextra->isSpecialComment =
false;
2242 BEGIN(SkipCPPComment);
2247 yyextra->yyLineNr++;
2250 yyextra->expectGuard =
false;
2260 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
2261 int bytesInBuf =
static_cast<int>(state->inputBuf->size())-state->inputBufPos;
2262 int bytesToCopy = std::min(max_size,bytesInBuf);
2263 memcpy(buf,state->inputBuf->data()+state->inputBufPos,bytesToCopy);
2264 state->inputBufPos+=bytesToCopy;
2270 yy_size_t fenceSize = 0;
2271 for (
size_t i = 0; i < leng; i++)
2273 if (txt[i] !=
' ' && txt[i] !=
'*' && txt[i] !=
'\t')
break;
2276 return leng-fenceSize;
2281 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
2286 if (state->yyFileDef==
nullptr)
2292 if (state->yyFileDef && state->yyFileDef->isReference()) state->yyFileDef=
nullptr;
2296 state->isFixedFormFtn =
false;
2297 if (state->insideFtn)
2303 state->isSource = section.isHeader() || section.isSource();
2308 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
2309 state->levelGuard.push(
false);
2315 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
2317 if (!state->levelGuard.empty())
2319 state->levelGuard.pop();
2323 if (state->condGuardErrorLine!=0)
2325 warn(state->condGuardErrorFileName,state->condGuardErrorLine,
"{}",state->condGuardErrorMessage);
2329 warn(state->fileName,state->yyLineNr,
"More #endif's than #if's found.");
2336 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
2337 if (state->levelGuard.empty())
2339 warn(state->fileName,state->yyLineNr,
"Found an #else without a preceding #if.");
2344 return state->levelGuard.top();
2350 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
2351 state->levelGuard.top()=value;
2357 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
2358 alreadyProcessed =
false;
2359 std::unique_ptr<FileState> fs;
2370 if (state->curlyCount==0)
2375 alreadyProcessed =
true;
2382 alreadyProcessed = std::any_of(
2383 state->includeStack.begin(),
2384 state->includeStack.end(),
2385 [absName](
const std::unique_ptr<FileState> &lfs)
2386 { return lfs->fileName==absName; }
2389 if (alreadyProcessed)
2396 fs = std::make_unique<FileState>();
2405 fs->oldFileBuf = state->inputBuf;
2406 fs->oldFileBufPos = state->inputBufPos;
2414 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
2425 else if (alreadyProcessed)
2430 if (localInclude && !state->fileName.empty())
2432 FileInfo fi(state->fileName.str());
2443 else if (alreadyProcessed)
2449 if (state->pathList.empty())
2453 for (
auto path : state->pathList)
2455 DString absName = path+
"/"+fileName;
2465 else if (alreadyProcessed)
2488 if (s.
empty())
return "";
2498 if (i>=0 && s[i]==
'*')
2501 while (i>0 && !(s[i-1]==
'/' && s[i]==
'*')) i--;
2508 return ((s[i+1]==
'*' || s[i+1]==
'!') && s[i+2]==
'<') ? &s[i-1] :
"";
2540 bool inString=
false;
2545 if (!inString && !inChar)
2547 while (i<s.
length() && !inString && !inChar)
2568 while (i<s.
length() && inChar)
2589 while (i<s.
length() && inString)
2616 if (expr.
empty())
return;
2618 std::string e = expr.
str();
2619 static const reg::Ex r(R
"(\s*##\s*)");
2628 const auto &match = *it;
2629 size_t n = match.position();
2630 size_t l = match.length();
2632 if (n+l+1<e.length() && e[
static_cast<int>(n+l)]==
'@' && expr[
static_cast<int>(n+l+1)]==
'-')
2639 e=e.substr(0,n)+e.substr(n+l);
2640 int k=
static_cast<int>(n)-1;
2641 while (k>=0 &&
isId(e[k])) k--;
2642 if (k>0 && e[k]==
'-' && e[k-1]==
'@')
2645 e=e.substr(0,k-1)+e.substr(k+1);
2663 struct yyguts_t * yyg = (
struct yyguts_t*)yyscanner;
2671 while ((cc=
getNextChar(yyscanner,expr,rest,pos))!=EOF && cc!=0)
2690 while ((cc=
getNextChar(yyscanner,expr,rest,pos))!=EOF && cc!=0)
2703 int &cc, uint32_t &j,
int &len)
2705 bool changed =
false;
2710 while ((cc=
getCurrentChar(yyscanner,expr,rest,j))!=EOF && cc!=
'\n' && isspace(cc))
2718 int prevChar =
'\0';
2720 if ((cc=
getCurrentChar(yyscanner,expr,rest,j))!=EOF && cc ==
'*')
2722 while ((cc=
getNextChar(yyscanner,expr,rest,j))!=EOF && cc!=0)
2724 if (cc ==
'/' && prevChar ==
'*')
break;
2727 if (cc != EOF) changed =
true;
2740 size_t vl = vaStr.
length();
2743 bool hasHash = vo>0 && vaStr.
at(vo-1)==
'#';
2746 result+=vaStr.
mid(vp,vo-vp-1);
2751 result+=vaStr.
mid(vp,vo-vp);
2755 while (bc>0 && ve<vl)
2757 if (vaStr[ve]==
')') bc--;
2758 else if (vaStr[ve]==
'(') bc++;
2762 if (bc==0 && hasOptionalArgs)
2774 result+=vaStr.
mid(vp);
2806 std::map<std::string,std::string> argTable;
2809 int argCountNonEmpty=0;
2815 while ((cc=
getNextChar(yyscanner,expr,rest,j))!=EOF && cc!=0)
2823 while (!done && (argCount<def->nargs || def->
varArgs) &&
2824 ((cc=
getNextChar(yyscanner,expr,rest,j))!=EOF && cc!=0)
2833 while ((cc=
getNextChar(yyscanner,expr,rest,j))!=EOF && cc!=0)
2837 if (c==
'\'' || c==
'\"')
2870 else if (c==
')' || c==
',')
2883 argKey.
sprintf(
"@%d",argCount++);
2884 if (c==
',' || !arg.
empty()) argCountNonEmpty++;
2898 while (!found && (cc=
getNextChar(yyscanner,expr,rest,j))!=EOF && cc!=0)
2905 if ((cc=
getNextChar(yyscanner,expr,rest,j))==EOF || cc==0)
break;
2915 while (!found && (cc=
getNextChar(yyscanner,expr,rest,j))!=EOF && cc!=0)
2922 if ((cc=
getNextChar(yyscanner,expr,rest,j))==EOF || cc==0)
break;
2930 char prevChar =
'\0';
2934 while ((cc=
getNextChar(yyscanner,expr,rest,j))!=EOF && cc!=0)
2938 if (c ==
'/' && prevChar ==
'*')
break;
2951 if (argCount==def->
nargs ||
2962 bool inString=
false;
2972 else if (d.
at(k+1)==
'-')
2981 int l=
static_cast<int>(k)-1;
2983 if (l>=0 && d.
at(l)==
'"') l--;
2984 while (l>=0 && d.
at(l)==
' ') l--;
2985 if (l>0 && d.
at(l)==
'#' && d.
at(l-1)==
'#') hash=
true;
2988 while (k<d.
length() && d.
at(k)>=
'0' && d.
at(k)<=
'9') key+=d.
at(k++);
2993 if (l<(
int)d.
length() && d.
at(l)==
'"') l++;
2994 while (l<(
int)d.
length() && d.
at(l)==
' ') l++;
2995 if (l<(
int)d.
length()-1 && d.
at(l)==
'#' && d.
at(l+1)==
'#') hash=
true;
2998 auto it = argTable.find(key.
str());
2999 if (it!=argTable.end())
3001 DString substArg = it->second;
3019 if (hash && substArg.
empty())
3030 if (!inString && d.
at(k)==
'\"')
3034 else if (k>2 && inString && d.
at(k)==
'\"' && (d.
at(k-1)!=
'\\' || d.
at(k-2)==
'\\'))
3058 while (p<(
int)expr.
length())
3060 char c=expr.
at(p++);
3065 else if (isalpha(c) || c==
'_')
3075 if (p<(
int)expr.
length()) c=expr.
at(p);
3076 while (p<(
int)expr.
length() && (c!=
'"' || (pc==
'\\' && ppc!=
'\\')))
3084 if (p<(
int)expr.
length()) ++p;
3090 if (p<(
int)expr.
length())
3096 while (p<(
int)expr.
length() && !(pc==
'*' && c==
'/'))
3109#define MAX_EXPANSION_DEPTH 50
3113 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
3114 if (!state->nospaces)
3117 char ccPrev = pos==0 || (int)expr.
length()<pos ? state->prevChar : expr.
at(pos-1);
3118 DString leftSpace = ccPrev!=
':' && ccPrev!=
' ' ?
" " :
"";
3121 if (restExpr.
empty())
3123 uint32_t j=(uint32_t)resultExpr.
length();
3124 while ((ccNext=
getNextChar(yyscanner,resultExpr,
nullptr,j))!=EOF && ccNext==
' ') { }
3125 if (ccNext != EOF)
unputChar(yyscanner,resultExpr,
nullptr,j,(
char)ccNext);
3129 ccNext=restExpr.
at(0);
3132 DString rightSpace = ccNext!=
':' && ccNext!=
' ' ?
" " :
"";
3135 resultExpr=leftSpace+resultExpr+rightSpace;
3145 struct yyguts_t * yyg = (
struct yyguts_t*)yyscanner;
3146 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
3153 if (state->expanded.find(expr.
str())!=state->expanded.end() &&
3161 state->expanded.insert(expr.
str());
3165 bool definedTest=
false;
3166 int i=pos, l=0, p=0, len=0;
3171 bool replaced=
false;
3173 macroName=expr.
mid(p,l);
3178 expr=expr.
left(p)+resultExpr+restExpr;
3180 else if (p<2 || !(expr.
at(p-2)==
'@' && expr.
at(p-1)==
'-'))
3182 if (state->expandedDict.find(macroName.
str())==state->expandedDict.end())
3184 bool expanded=
false;
3188 if (yyextra->expandOnlyPredef && def && !def->
isPredefined) def=
nullptr;
3189 if (macroName==
"defined")
3194 else if (definedTest)
3196 if (def) expMacro =
" 1 ";
else expMacro =
" 0 ";
3201 else if (def && def->
nargs==-1)
3210 else if (def && def->
nargs>=0)
3221 resultExpr=expMacro;
3228 state->expandedDict.emplace(
toStdString(macroName),def);
3230 state->expandedDict.erase(
toStdString(macroName));
3239 expr=expr.
left(p)+resultExpr+restExpr;
3245 expr=expr.
left(p)+
"@-"+expr.
mid(p);
3257 expr=expr.
left(p)+
"@-"+expr.
mid(p);
3295 if (inputStr==
nullptr)
return inputStr;
3296 char term = *inputStr;
3297 if (
term!=
'\'' &&
term!=
'"')
return inputStr;
3302 while ((c=*inputStr))
3331 static const std::vector<std::string> signs = {
"signed",
"unsigned" };
3332 struct TypeInfo { std::string name;
size_t size; };
3333 static const std::vector<TypeInfo> types = {
3334 {
"short int",
sizeof(
short int) },
3335 {
"long long int",
sizeof(
long long int) },
3336 {
"long int",
sizeof(
long int) },
3337 {
"long long",
sizeof(
long long) },
3338 {
"long double",
sizeof(
long double) },
3339 {
"int",
sizeof(int) },
3340 {
"short",
sizeof(short) },
3341 {
"bool",
sizeof(bool) },
3342 {
"long",
sizeof(long) },
3343 {
"char",
sizeof(char) },
3344 {
"float",
sizeof(float) },
3345 {
"double",
sizeof(double) },
3351 auto process_cast_or_sizeof = [](
const char *p) -> std::pair<const char *,size_t>
3354 while (*q==
' ' || *q==
'\t') q++;
3356 size_t size =
sizeof(int);
3357 for (
const auto &sgn : signs)
3359 if (
dstrncmp(q,sgn.c_str(),sgn.length())==0) { q+=sgn.length(); found=
true; }
3361 if (!found || *q==
' ' || *q==
'\t' || *q==
')')
3363 while (*q==
' ' || *q==
'\t') q++;
3364 for (
const auto &t : types)
3366 if (
dstrncmp(q,t.name.c_str(),t.name.length())==0)
3368 q += t.name.length();
3373 while (*q==
' ' || *q==
'\t') q++;
3374 if (*q==
')')
return std::make_pair(++q,size);
3376 return std::make_pair(
nullptr,0);
3380 if (s.
empty())
return s;
3381 const char *p=s.
data();
3391 const char *q = process_cast_or_sizeof(p+1).first;
3401 const char *q = p+6;
3402 while (*q==
' ' || *q==
'\t') q++;
3405 auto r = process_cast_or_sizeof(q+1);
3422 else if (*(p+1)==
'E')
3428 else if (isdigit(c))
3438 else if (c==
'd' && !inNum)
3449 while ((c=*p) &&
isId(c)) p++;
3452 else if ((isalpha(c) || c==
'_') && !inNum)
3456 while ((c=*p) &&
isId(c)) p++;
3457 while ((c=*p) && isspace((uint8_t)c)) p++;
3464 if (c==
'(') count++;
3468 if (count==0)
break;
3476 while (*p && !(pc==
'*' && c==
'/'))
3493 while (*p && !(pc==
'*' && c==
'/'))
3510 char lc=(char)tolower(c);
3511 if (!
isId(lc) && lc!=
'.' ) inNum=
false;
3526 if (s.
empty())
return s;
3527 const char *p=s.
data();
3552 while (*p && !(pc==
'*' && c==
'/'))
3554 if (*p==
'@' && *(p+1)==
'@')
3597 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
3601 state->expanded.clear();
3605 if (e.
empty())
return false;
3607 return state->constExpParser.parse(state->fileName.data(),state->yyLineNr,e.
str(),ee.
str());
3616 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
3617 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
3618 state->prevChar = yyscanner->yytext_r > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ? *(yyscanner->yytext_r-1) : 0;
3620 state->expanded.
clear();
3630 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
3632 if (name ==
"__LINE__")
3634 return DString().setNum(yyextra->yyLineNr);
3636 else if (name ==
"__FILE__")
3639 resultExpr += yyextra->fileName;
3642 else if (name ==
"__DATE__")
3645 resultExpr += __DATE__;
3648 else if (name ==
"__TIME__")
3651 resultExpr += __TIME__;
3659 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
3661 def.
name = state->defName;
3663 def.
nargs = state->defArgs;
3665 def.
fileDef = state->yyFileDef;
3666 def.
lineNr = state->yyLineNr-state->yyMLines;
3668 def.
varArgs = state->defVarArgs;
3678 auto it = state->localDefines.find(def.
name.
str());
3679 if (it!=state->localDefines.end())
3681 state->localDefines.erase(it);
3683 state->localDefines.emplace(def.
name.
str(),def);
3688 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
3689 if (state->skip)
return;
3694 define.
lineNr = state->yyLineNr - state->yyMLines;
3696 define.
name = state->defName;
3697 define.
args = state->defArgsStr;
3698 define.
fileDef = state->inputFileDef;
3700 DString litText = state->defLitText;
3701 size_t l=litText.
find(
'\n');
3705 litText = litText.
mid(l+1);
3711 const char *p=litText.
data()+k;
3713 while ((c=*p++) && (c==
' ' || c==
'\t')) k++;
3717 if (litTextStripped.
contains(
'\n')>=1)
3726 state->macroDefinitions.push_back(define);
3732 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
3733 if (state->includeStack.empty() || state->curlyCount>0) (*state->outputBuf)+=c;
3738 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
3739 if (state->includeStack.empty() || state->curlyCount>0) (*state->outputBuf)+=std::string_view(a,len);
3744 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
3745 if (state->includeStack.empty() || state->curlyCount>0) (*state->outputBuf)+=a.
str();
3767 struct yyguts_t * yyg = (
struct yyguts_t*)yyscanner;
3768 if (!yyextra->defContinue)
return;
3769 for (
int i=0; i< (int)yyleng; i++)
3771 if (yytext[i] ==
'\t')
3772 yyextra->defExtraSpacing+=
'\t';
3774 yyextra->defExtraSpacing+=
' ';
3780 struct yyguts_t * yyg = (
struct yyguts_t*)yyscanner;
3781 yyextra->fenceSize=0;
3783 if (yytext[1]==
'f' && ((c=yytext[2])==
'[' || c==
'{' || c==
'(' || c==
'$'))
3787 case '[': yyextra->blockName=
"]";
break;
3788 case '{': yyextra->blockName=
"}";
break;
3789 case '(': yyextra->blockName=
")";
break;
3790 case '$': yyextra->blockName=
"$";
break;
3793 yyextra->blockName=yyextra->blockName.stripWhiteSpace();
3800 yyextra->blockName=
"uml";
3804 if (
size_t i = bn.
find(
'{');
3806 yyextra->blockName=bn;
3814 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
3819 (inc.
at(i)==
' ' || inc.
at(i)==
'"' || inc.
at(i)==
'<')
3824 bool localInclude = s>0 && inc.
at(s-1)==
'"';
3827 while (i<inc.
length() && inc.
at(i)!=
'"' && inc.
at(i)!=
'>') i++;
3829 if (s<inc.
length() && i>s)
3839 DString oldFileName = state->fileName;
3840 FileDef *oldFileDef = state->yyFileDef;
3841 int oldLineNr = state->yyLineNr;
3847 std::unique_ptr<FileState> fs;
3848 bool alreadyProcessed =
false;
3850 fs=
findFile(yyscanner,absIncFileName,localInclude,alreadyProcessed);
3861 for (i=0;i<state->includeStack.size();i++)
3868 if (state->includeStack.empty() && oldFileDef)
3870 PreIncludeInfo *ii = state->includeRelations.find(absIncFileName);
3875 state->includeRelations.add(
3878 ambig ?
nullptr : incFd,
3886 struct yyguts_t * yyg = (
struct yyguts_t*)yyscanner;
3887 fs->bufState = YY_CURRENT_BUFFER;
3888 fs->lineNr = oldLineNr;
3889 fs->fileName = oldFileName;
3890 fs->curlyCount = state->curlyCount;
3892 fs->lexRulesPart = state->lexRulesPart;
3893 fs->levelGuard = state->levelGuard;
3894 while (!state->levelGuard.empty()) state->levelGuard.pop();
3895 state->lexRulesPart =
false;
3898 state->includeStack.push_back(std::move(fs));
3908 state->expectGuard=
true;
3909 state->inputBuf = &fs_ptr->
fileBuf;
3910 state->inputBufPos=0;
3911 yy_switch_to_buffer(yy_create_buffer(0,
YY_BUF_SIZE, yyscanner),yyscanner);
3915 if (alreadyProcessed)
3923 if (state->includeStack.empty() && oldFileDef)
3925 PreIncludeInfo *ii = state->includeRelations.find(absIncFileName);
3930 ii = state->includeRelations.add(absIncFileName,
3932 ambig ?
nullptr : incFd,
3942 for (i=0;i<state->includeStack.size();i++)
3946 if (alreadyProcessed)
3956 if (localInclude && !state->includeStack.empty() && state->curlyCount>0 && !alreadyProcessed)
3958 warn(state->fileName,state->yyLineNr,
"include file {} not found, perhaps you forgot to add its directory to INCLUDE_PATH?",incFileName);
3968 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
3971 bool expResult = prs.
parse(state->fileName.data(),state->yyLineNr,sectId.
data());
3972 state->condStack.emplace(std::make_unique<preYY_CondCtx>(state->fileName,state->yyLineNr,sectId,state->skip));
3982 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
3983 if (state->condGuardCount>0 && state->condGuardErrorLine==0)
3985 state->condGuardErrorLine = state->yyLineNr;
3986 state->condGuardErrorFileName = state->fileName;
3987 state->condGuardErrorMessage =
"more #if's than #endif's in \\cond..\\endcond section";
3989 else if (state->condGuardCount<0 && state->condGuardErrorLine==0)
3991 state->condGuardErrorLine = state->yyLineNr;
3992 state->condGuardErrorFileName = state->fileName;
3993 state->condGuardErrorMessage =
"more #endif's than #if's in \\cond..\\endcond section";
3997 state->condGuardErrorLine = 0;
3999 if (state->condStack.empty())
4001 warn(state->fileName,state->yyLineNr,
"the \\endcond does not have a corresponding \\cond in this file");
4006 const std::unique_ptr<preYY_CondCtx> &ctx = state->condStack.top();
4007 state->skip=ctx->skip;
4008 state->condStack.pop();
4015 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
4016 while (!state->condStack.empty())
4018 state->condStack.pop();
4029 const char *p=text.
data();
4032 if (c==
'@') result+=
"@@";
else result+=c;
4042 case '=':
return '#';
4043 case '/':
return '\\';
4044 case '\'':
return '^';
4045 case '(':
return '[';
4046 case ')':
return ']';
4047 case '!':
return '|';
4048 case '<':
return '{';
4049 case '>':
return '}';
4050 case '-':
return '~';
4064 return expr.
at(pos++);
4066 else if (rest && !rest->
empty())
4075 int cc=yyinput(yyscanner);
4087 return expr.
at(pos);
4089 else if (rest && !rest->
empty())
4097 int cc=yyinput(yyscanner);
4114 char cs[2];cs[0]=c;cs[1]=
'\0';
4130 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
4133 auto findDefine = [&undef,&name](
DefineMap &map)
4136 auto it = map.find(name.
str());
4149 Define *def = findDefine(state->localDefines);
4150 if (def==
nullptr && !undef)
4152 def = findDefine(state->contextDefines);
4159 YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
4163 for (
const auto &ds : predefList)
4165 size_t i_equals=ds.find(
'=');
4166 size_t i_obrace=ds.find(
'(');
4167 size_t i_cbrace=ds.find(
')');
4168 bool nonRecursive = i_equals!=std::string::npos && i_equals>0 && ds[i_equals-1]==
':';
4170 if ((i_obrace==0) || (i_equals==0) || (i_equals==1 && ds[i_equals-1]==
':'))
4175 if (i_obrace<i_equals && i_cbrace<i_equals &&
4176 i_obrace!=std::string::npos && i_cbrace!=std::string::npos &&
4180 static const reg::Ex reId(R
"(\a\w*)");
4181 std::map<std::string,int> argMap;
4182 std::string args = ds.substr(i_obrace+1,i_cbrace-i_obrace-1);
4183 bool hasVarArgs = args.find(
"...")!=std::string::npos;
4189 for (; arg_it!=arg_end; ++arg_it)
4191 argMap.emplace(arg_it->
str(),count++);
4195 argMap.emplace(
"__VA_ARGS__",count++);
4199 std::string definition;
4200 std::string in=ds.substr(i_equals+1);
4206 for (; re_it!=re_end; ++re_it)
4208 const auto &match = *re_it;
4209 size_t pi = match.position();
4210 size_t l = match.length();
4211 if (pi>i) definition+=in.substr(i,pi-i);
4213 auto it = argMap.find(match.str());
4214 if (it!=argMap.end())
4216 int argIndex = it->second;
4218 marker.
sprintf(
" @%d ",argIndex);
4219 definition+=marker.
str();
4223 definition+=match.str();
4227 definition+=in.substr(i);
4230 std::string dname = ds.substr(0,i_obrace);
4239 def.
fileDef = state->yyFileDef;
4242 state->contextDefines.emplace(def.
name.
str(),def);
4248 else if (!ds.empty())
4252 if (i_equals==std::string::npos)
4259 int ine=
static_cast<int>(i_equals) - (nonRecursive ? 1 : 0);
4268 def.
fileDef = state->yyFileDef;
4270 state->contextDefines.emplace(def.
name.
str(),def);
4286 YY_EXTRA_TYPE state = preYYget_extra(
p->yyscanner);
4293 preYYlex_init_extra(&
p->state,&
p->yyscanner);
4299 preYYlex_destroy(
p->yyscanner);
4306 YY_EXTRA_TYPE state = preYYget_extra(
p->yyscanner);
4307 struct yyguts_t *yyg = (
struct yyguts_t*)
p->yyscanner;
4320 state->curlyCount=0;
4321 state->lexRulesPart=
false;
4322 state->nospaces=
false;
4323 state->inputBuf=&input;
4324 state->inputBufPos=0;
4325 state->outputBuf=&output;
4326 state->includeStack.clear();
4327 state->expandedDict.clear();
4328 state->contextDefines.clear();
4329 state->pragmaSet.clear();
4330 state->condGuardCount=0;
4331 state->condGuardErrorLine=0;
4332 while (!state->levelGuard.empty()) state->levelGuard.pop();
4333 while (!state->condStack.empty()) state->condStack.pop();
4337 state->inputFileDef = state->yyFileDef;
4342 state->yyLineNr = 1;
4349 state->guardName.clear();
4350 state->lastGuardName.clear();
4351 state->guardExpr.clear();
4353 preYYlex(yyscanner);
4355 while (!state->condStack.empty())
4357 const std::unique_ptr<preYY_CondCtx> &ctx = state->condStack.top();
4359 if (ctx->sectionId!=
" ") sectionInfo.
sprintf(
" with label '%s' ",
qPrint(ctx->sectionId.stripWhiteSpace()));
4360 warn(ctx->fileName,ctx->lineNr,
"Conditional section{}does not have "
4361 "a corresponding \\endcond command within this file.",sectionInfo);
4362 state->condStack.pop();
4367 if (!state->levelGuard.empty())
4369 if (yyextra->condGuardErrorLine!=0)
4371 warn(yyextra->condGuardErrorFileName,yyextra->condGuardErrorLine,
"{}",yyextra->condGuardErrorMessage);
4375 warn(state->fileName,state->yyLineNr,
"More #if's than #endif's found (might be in an included file).");
4383 std::string contents;
4391 bool startOfLine =
true;
4392 size_t content_size = output.size() +
4395 contents.reserve(content_size);
4397 while (pos<output.size())
4402 snprintf(lineNrStr,15,
"%05d ",line++);
4403 contents+=lineNrStr;
4405 contents += output[pos];
4406 startOfLine = output[pos]==
'\n';
4411 if (!contents.empty() && contents[contents.length()-1]!=
'\n')
4416 if (yyextra->contextDefines.size()>0)
4420 for (
auto &kv : yyextra->contextDefines)
4424 for (
auto &kv : yyextra->localDefines)
4438 for (
const auto &inc : state->includeRelations)
4440 auto toKind = [](
bool local,
bool imported) ->
IncludeKind
4456 if (inc->fromFileDef)
4458 inc->fromFileDef->addIncludeDependency(inc->toFileDef,inc->includeName,toKind(inc->local,inc->imported));
4460 if (inc->toFileDef && inc->fromFileDef)
4462 inc->toFileDef->addIncludedByDependency(inc->fromFileDef,inc->fromFileDef->docName(),toKind(inc->local,inc->imported));
Copyright (C) 1997-2015 by Dimitri van Heesch.
bool parse(const DString &fileName, int lineNr, const DString &expr)
parses and evaluates the given expression.
DString & setNum(short n)
DString mid(size_t index, size_t len=npos) const
DString substr(size_t pos=0, size_t count=npos) const
Returns a substring of length count starting at pos.
char & at(size_t i)
Returns a reference to the character at index i.
DString right(size_t len) const
size_t size() const
Returns the length of the string, not counting the 0-terminator.
DString & prepend(const char *s)
size_t find(char c, size_t pos=0) const
DString & 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.
bool endsWith(const char *s) const
static StringUnorderedSet expandAsDefinedSet
static FileNameLinkedMap * inputNameLinkedMap
static DefinesPerFileList macroDefinitions
static FileNameLinkedMap * includeNameLinkedMap
Wrapper class for the Entry type.
static EntryType guessSection(const DString &name)
virtual DString absFilePath() const =0
Minimal replacement for QFileInfo.
bool match(const PatternList &patList, bool caseSenseNames, PatternElem *elem=nullptr, PatternGet getter=[](const std::string &s){ return s;}) const
Match the file name against a list of patterns.
std::string dirPath(bool absPath=true) const
std::string absFilePath() const
FileDef * findFileDef(const DString &n, bool &ambig) const
Returns the file definition in fnMap that matches the file name n.
void processFile(const DString &fileName, const std::string &input, std::string &output)
void addSearchDir(const DString &dir)
std::unique_ptr< Private > p
Class representing a regular expression.
Class to iterate through matches.
std::string str() const
Return a string representing the matching part.
#define Config_getList(name)
static FILE * findFile(const DString &fileName)
DirIterator end(const DirIterator &) noexcept
#define AUTO_TRACE_ADD(...)
int dstrncmp(const char *str1, const char *str2, size_t len)
bool isId(int c)
Returns true if c is a valid character for an identifier.
bool recognizeFixedForm(const DString &contents, FortranFormat format)
FortranFormat convertFileNameFortranParserCode(const DString &fn)
bool isAbsolutePath(const DString &fileName)
static void addSeparatorsIfNeeded(yyscan_t yyscanner, const DString &expr, DString &resultExpr, DString &restExpr, int pos)
static std::unique_ptr< FileState > checkAndOpenFile(yyscan_t yyscanner, const DString &fileName, bool &alreadyProcessed)
#define MAX_EXPANSION_DEPTH
static DString stringize(const DString &s)
static void processConcatOperators(DString &expr)
static void skipCommentMacroName(yyscan_t yyscanner, const DString &expr, DString *rest, int &cc, uint32_t &j, int &len)
static int getNextId(const DString &expr, int p, int *l)
static void unputChar(yyscan_t yyscanner, const DString &expr, DString *rest, uint32_t &pos, char c)
static void returnCharToStream(yyscan_t yyscanner, char c)
static int getCurrentChar(yyscan_t yyscanner, const DString &expr, DString *rest, uint32_t pos)
static const char * processUntilMatchingTerminator(const char *inputStr, DString &result)
Process string or character literal.
static void forceEndCondSection(yyscan_t yyscanner)
static DString expandVAOpt(const DString &vaStr, bool hasOptionalArgs)
static void addTillEndOfComment(yyscan_t yyscanner, const DString &expr, DString *rest, uint32_t &pos, char term, DString &arg)
static bool replaceFunctionMacro(yyscan_t yyscanner, const DString &expr, DString *rest, int pos, int &len, const Define *def, DString &result, int level)
static DString removeMarkers(const DString &s)
static void addTillEndOfString(yyscan_t yyscanner, const DString &expr, DString *rest, uint32_t &pos, char term, DString &arg)
static int getNextChar(yyscan_t yyscanner, const DString &expr, DString *rest, uint32_t &pos)
static void initPredefined(yyscan_t yyscanner, const DString &fileName)
static DString removeIdsAndMarkers(const DString &s)
static bool expandExpression(yyscan_t yyscanner, DString &expr, DString *rest, int pos, int level)
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 useCaseSenseNames()
Returns true if the names of the symbols can be case sensitive.
bool readInputFile(const DString &fileName, std::string &contents, bool filter, bool isSourceCode)
read a file name fileName and optionally filter and transcode it
DString determineAbsoluteIncludeName(const DString &curFile, const DString &incFileName)