Doxygen
Loading...
Searching...
No Matches
code.l
Go to the documentation of this file.
-1/******************************************************************************
2 *
3 * Copyright (C) 1997-2020 by Dimitri van Heesch.
4 *
5 * Permission to use, copy, modify, and distribute this software and its
6 * documentation under the terms of the GNU General Public License is hereby
7 * granted. No representations are made about the suitability of this software
8 * for any purpose. It is provided "as is" without express or implied warranty.
9 * See the GNU General Public License for more details.
10 *
11 * Documents produced by Doxygen are derivative works derived from the
12 * input used in their production; they are not affected by this license.
13 *
14 */
13%option never-interactive
14%option prefix="codeYY"
15%option reentrant
16%option extra-type="struct codeYY_state *"
17%top{
18#include <stdint.h>
19// forward declare yyscan_t to improve type safety
20#define YY_TYPEDEF_YY_SCANNER_T
21struct yyguts_t;
22typedef yyguts_t *yyscan_t;
yyguts_t * yyscan_t
Definition code.l:24
23}
25%{
26
27/*
28 * includes
29 */
30
31#include <utility>
32#include <memory>
33#include <algorithm>
34#include <unordered_map>
35#include <unordered_set>
36#include <stack>
37#include <vector>
38#include <string>
39#include <mutex>
40#include <sstream>
41#include <cstdint>
42
43#include <stdio.h>
44#include <assert.h>
45#include <ctype.h>
46
47#include "code.h"
48#include "entry.h"
49#include "doxygen.h"
50#include "message.h"
51#include "outputlist.h"
52#include "util.h"
53#include "membername.h"
54#include "searchindex.h"
55#include "arguments.h"
56#include "config.h"
57#include "groupdef.h"
58#include "classlist.h"
59#include "filedef.h"
60#include "filename.h"
61#include "namespacedef.h"
62#include "tooltip.h"
63#include "scopedtypevariant.h"
64#include "symbolresolver.h"
65#include "dir.h"
66#include "debug.h"
67#include "moduledef.h"
68
69// Toggle for some debugging info
70//#define DBG_CTX(x) fprintf x
71#define DBG_CTX(x) do { } while(0)
72
73#define YY_NO_UNISTD_H 1
74
75#define CLASSBLOCK 1
76#define SCOPEBLOCK 2
77#define INNERBLOCK 3
79// context for an Objective-C method call
80struct ObjCCallCtx
81{
95{
96 OutputCodeList * code = nullptr;
97
98 std::unordered_map< std::string, ScopedTypeVariant > codeClassMap;
105 const char * inputString = nullptr; //!< the code fragment as text
106 yy_size_t inputPosition = 0; //!< read offset during parsing
109 int inputLines = 0; //!< number of line in the code fragment
110 int yyLineNr = 0; //!< current line number
112 bool skipCodify = FALSE; //!< for CSharp files scoped namespace {
124 std::stack<int> scopeStack; //!< 1 if bracket starts a scope,
125 // 2 for internal blocks
126 int anchorCount = 0;
127 std::unique_ptr<FileDef> exampleFileDef;
128 const FileDef * sourceFileDef = nullptr;
130 const Definition * currentDefinition = nullptr;
131 const MemberDef * currentMemberDef = nullptr;
133 const char * currentFontClass = nullptr;
142 int curlyCount = 0;
143 int sharpCount = 0;
148 int lastSpecialCContext = 0;
157 SrcLangExt lang = SrcLangExt::Unknown;
158 bool insideObjC = FALSE;
163
164 std::vector<int> scopeNameLengthStack;
165
167 const Definition *searchCtx = nullptr;
171 int currentCtxId=0;
176 std::stack<ObjCCallCtx*> contextStack;
177 std::unordered_map< int,std::unique_ptr<ObjCCallCtx> > contextMap;
178 std::unordered_map< int, QCString> nameMap;
179 std::unordered_map< int, QCString> objectMap;
180 std::unordered_map< int, QCString> wordMap;
181 std::unordered_map< int, QCString> commentMap;
184 using UsingContext = std::map<std::string,const NamespaceDef*>;
185
191 std::vector<const Definition *> foldStack;
194static bool isCastKeyword(const char *s);
195
196//-------------------------------------------------------------------
197[[maybe_unused]] static const char *stateToString(int state);
198
199static void saveObjCContext(yyscan_t yyscanner);
200static void restoreObjCContext(yyscan_t yyscanner);
201static void pushScope(yyscan_t yyscanner,const QCString &s);
202static void popScope(yyscan_t yyscanner);
203static void setCurrentDoc(yyscan_t yyscanner,const QCString &anchor);
204static void addToSearchIndex(yyscan_t yyscanner,const QCString &text);
205static void setClassScope(yyscan_t yyscanner,const QCString &name);
206static void startCodeLine(yyscan_t yyscanner);
207static void endCodeLine(yyscan_t yyscanner);
208static void nextCodeLine(yyscan_t yyscanner);
209static void startFontClass(yyscan_t yyscanner,const char *s,bool specialComment=false);
210static void endFontClass(yyscan_t yyscanner,bool specialComment=false);
211static void codifyLines(yyscan_t yyscanner,const QCString &text);
212static void incrementFlowKeyWordCount(yyscan_t yyscanner);
213static void writeMultiLineCodeLink(yyscan_t yyscanner,OutputCodeList &ol,
214 const Definition *d,
215 const QCString &text);
216static void addType(yyscan_t yyscanner);
217static void addParmType(yyscan_t yyscanner);
218static void addUsingDirective(yyscan_t yyscanner,const QCString &name);
219static void setParameterList(yyscan_t yyscanner,const MemberDef *md);
220static const ClassDef *stripClassName(yyscan_t yyscanner,const QCString &s,const Definition *d);
221static const MemberDef *setCallContextForVar(yyscan_t yyscanner,const QCString &name);
222static void updateCallContextForSmartPointer(yyscan_t yyscanner);
223static bool getLinkInScope(yyscan_t yyscanner,const QCString &c, // scope
224 const QCString &m, // member
225 const QCString &memberText, // exact text
226 OutputCodeList &ol,
227 const QCString &text,
228 bool varOnly=FALSE
229 );
230static bool getLink(yyscan_t yyscanner,const QCString &className,
231 const QCString &memberName,
232 OutputCodeList &ol,
233 const QCString &text=QCString(),
234 bool varOnly=FALSE);
235static void generateClassOrGlobalLink(yyscan_t yyscanner,OutputCodeList &ol,const QCString &clName,
236 bool typeOnly=FALSE,bool varOnly=FALSE);
237static bool generateClassMemberLink(yyscan_t yyscanner,OutputCodeList &ol,const MemberDef *xmd,const QCString &memName);
238static bool generateClassMemberLink(yyscan_t yyscanner,OutputCodeList &ol,const Definition *def,const QCString &memName);
239static void generateMemberLink(yyscan_t yyscanner,OutputCodeList &ol,const QCString &varName,
240 const QCString &memName);
241static void generatePHPVariableLink(yyscan_t yyscanner,OutputCodeList &ol,const char *varName);
242static void generateFunctionLink(yyscan_t yyscanner,OutputCodeList &ol,const QCString &funcName);
243static int countLines(yyscan_t yyscanner);
244static void writeObjCMethodCall(yyscan_t yyscanner,ObjCCallCtx *ctx);
245static QCString escapeName(yyscan_t yyscanner,const QCString &s);
246static QCString escapeObject(yyscan_t yyscanner,const QCString &s);
247static QCString escapeWord(yyscan_t yyscanner,const QCString &s);
248static QCString escapeComment(yyscan_t yyscanner,const QCString &s);
249static bool skipLanguageSpecificKeyword(yyscan_t yyscanner,const char *kw);
250static int yyread(yyscan_t yyscanner,char *buf,int max_size);
251static void addVariable(yyscan_t yyscanner,QCString type,QCString name);
252static bool startsWithKeyword(const QCString &str,const QCString &kw);
253static void endCodeFold(yyscan_t yyscanner);
254
255/* -----------------------------------------------------------------
256 */
257#undef YY_INPUT
258#define YY_INPUT(buf,result,max_size) result=yyread(yyscanner,buf,max_size);
259
260// otherwise the filename would be the name of the converted file (*.cpp instead of *.l)
261static inline const char *getLexerFILE() {return __FILE__;}
262#include "doxygen_lex.h"
Represents the call context.
A abstract class representing of a compound symbol.
Definition classdef.h:104
The common base class of all entity definitions found in the sources.
Definition definition.h:76
A model of a file symbol.
Definition filedef.h:99
A model of a class/file/namespace member symbol.
Definition memberdef.h:48
Class representing a list of different code generators.
Definition outputlist.h:165
This is an alternative implementation of QCString.
Definition qcstring.h:101
Text streaming class that buffers data.
Definition textstream.h:36
Class that manages the tooltips for a source file.
Definition tooltip.h:26
static bool isCastKeyword(const char *s)
Definition code.l:3962
static void pushScope(yyscan_t yyscanner, const QCString &s)
Definition code.l:2243
static void writeMultiLineCodeLink(yyscan_t yyscanner, OutputCodeList &ol, const Definition *d, const QCString &text)
Definition code.l:2550
static void endCodeLine(yyscan_t yyscanner)
Definition code.l:2478
static bool skipLanguageSpecificKeyword(yyscan_t yyscanner, const char *kw)
Definition code.l:3921
static void generateClassOrGlobalLink(yyscan_t yyscanner, OutputCodeList &ol, const QCString &clName, bool typeOnly=FALSE, bool varOnly=FALSE)
Definition code.l:2907
static void restoreObjCContext(yyscan_t yyscanner)
Definition code.l:4018
static void nextCodeLine(yyscan_t yyscanner)
Definition code.l:2487
static void popScope(yyscan_t yyscanner)
Definition code.l:2261
static void startCodeLine(yyscan_t yyscanner)
Definition code.l:2409
static void codifyLines(yyscan_t yyscanner, const QCString &text)
Definition code.l:2505
static void incrementFlowKeyWordCount(yyscan_t yyscanner)
Definition code.l:2532
static bool startsWithKeyword(const QCString &str, const QCString &kw)
Definition code.l:2171
static int yyread(yyscan_t yyscanner, char *buf, int max_size)
Definition code.l:3971
static int countLines(yyscan_t yyscanner)
Definition code.l:3462
static void addToSearchIndex(yyscan_t yyscanner, const QCString &text)
Definition code.l:2293
static const char * stateToString(int state)
static QCString escapeComment(yyscan_t yyscanner, const QCString &s)
Definition code.l:3911
static void addParmType(yyscan_t yyscanner)
Definition code.l:2600
static QCString escapeObject(yyscan_t yyscanner, const QCString &s)
Definition code.l:3891
static bool getLinkInScope(yyscan_t yyscanner, const QCString &c, const QCString &m, const QCString &memberText, OutputCodeList &ol, const QCString &text, bool varOnly=FALSE)
Definition code.l:2798
static const ClassDef * stripClassName(yyscan_t yyscanner, const QCString &s, const Definition *d)
Definition code.l:2640
static void updateCallContextForSmartPointer(yyscan_t yyscanner)
Definition code.l:2781
static void generateMemberLink(yyscan_t yyscanner, OutputCodeList &ol, const QCString &varName, const QCString &memName)
Definition code.l:3238
static void addUsingDirective(yyscan_t yyscanner, const QCString &name)
Definition code.l:2609
static bool getLink(yyscan_t yyscanner, const QCString &className, const QCString &memberName, OutputCodeList &ol, const QCString &text=QCString(), bool varOnly=FALSE)
Definition code.l:2882
static void startFontClass(yyscan_t yyscanner, const char *s, bool specialComment=false)
Definition code.l:3495
static const MemberDef * setCallContextForVar(yyscan_t yyscanner, const QCString &name)
Definition code.l:2671
static void endFontClass(yyscan_t yyscanner, bool specialComment=false)
Definition code.l:3480
static void generateFunctionLink(yyscan_t yyscanner, OutputCodeList &ol, const QCString &funcName)
Definition code.l:3344
static void addVariable(yyscan_t yyscanner, QCString type, QCString name)
Definition code.l:2178
static const char * getLexerFILE()
Definition code.l:263
static void setClassScope(yyscan_t yyscanner, const QCString &name)
Definition code.l:2301
static bool generateClassMemberLink(yyscan_t yyscanner, OutputCodeList &ol, const MemberDef *xmd, const QCString &memName)
Definition code.l:3133
static QCString escapeWord(yyscan_t yyscanner, const QCString &s)
Definition code.l:3901
static void setCurrentDoc(yyscan_t yyscanner, const QCString &anchor)
Definition code.l:2277
static void setParameterList(yyscan_t yyscanner, const MemberDef *md)
Definition code.l:2623
static void addType(yyscan_t yyscanner)
Definition code.l:2588
static QCString escapeName(yyscan_t yyscanner, const QCString &s)
Definition code.l:3881
static void saveObjCContext(yyscan_t yyscanner)
Definition code.l:3987
static void writeObjCMethodCall(yyscan_t yyscanner, ObjCCallCtx *ctx)
Definition code.l:3511
static void endCodeFold(yyscan_t yyscanner)
Definition code.l:2330
static void generatePHPVariableLink(yyscan_t yyscanner, OutputCodeList &ol, const char *varName)
Definition code.l:3332
std::vector< std::string > StringVector
Definition containers.h:33
#define FALSE
Definition qcstring.h:34
Web server based search engine.
const MemberDef * method
Definition code.l:90
int braceCount
Definition code.l:93
int lexState
Definition code.l:92
QCString objectTypeOrName
Definition code.l:86
TextStream comment
Definition code.l:87
const MemberDef * objectVar
Definition code.l:89
QCString methodName
Definition code.l:85
const ClassDef * objectType
Definition code.l:88
QCString format
Definition code.l:91
int memCallContext
Definition code.l:155
StringVector curClassBases
Definition code.l:102
bool lineNumbers
Definition code.l:131
int bodyCurlyCount
Definition code.l:138
CallContext theCallContext
Definition code.l:190
std::unordered_map< int, QCString > commentMap
Definition code.l:183
int lastCContext
Definition code.l:156
bool includeCodeFragment
Definition code.l:134
bool insideTemplate
Definition code.l:120
const Definition * currentDefinition
Definition code.l:132
std::unique_ptr< FileDef > exampleFileDef
Definition code.l:129
int lastSpecialCContext
Definition code.l:150
std::unordered_map< int, QCString > wordMap
Definition code.l:182
bool inFunctionTryBlock
Definition code.l:146
int braceCount
Definition code.l:184
bool collectXRefs
Definition code.l:170
QCString saveType
Definition code.l:140
QCString delimiter
Definition code.l:141
QCString fileName
Definition code.l:109
const char * currentFontClass
Definition code.l:135
bool insideBody
Definition code.l:137
std::stack< int > scopeStack
1 if bracket starts a scope,
Definition code.l:126
const FileDef * sourceFileDef
Definition code.l:130
std::unordered_map< int, QCString > objectMap
Definition code.l:181
ObjCCallCtx * currentCtx
Definition code.l:172
bool exampleBlock
Definition code.l:116
std::unordered_map< int, std::unique_ptr< ObjCCallCtx > > contextMap
Definition code.l:179
bool inForEachExpression
Definition code.l:147
QCString curClassName
Definition code.l:101
VariableContext theVarContext
Definition code.l:188
QCString type
Definition code.l:121
bool lexInit
Definition code.l:164
int bracketCount
Definition code.l:143
QCString parmName
Definition code.l:105
int anchorCount
Definition code.l:128
int lastSkipCppContext
Definition code.l:152
int curlyCount
Definition code.l:144
TooltipManager tooltipManager
Definition code.l:192
std::vector< int > scopeNameLengthStack
Definition code.l:166
int currentCommentId
Definition code.l:177
QCString name
Definition code.l:122
int sharpCount
Definition code.l:145
QCString exampleName
Definition code.l:117
std::map< std::string, const NamespaceDef * > UsingContext
Definition code.l:186
bool insideCodeLine
Definition code.l:113
const char * inputString
the code fragment as text
Definition code.l:107
const Definition * searchCtx
Definition code.l:169
QCString parmType
Definition code.l:104
QCString absFileName
Definition code.l:110
int isPrefixedWithThis
Definition code.l:168
bool searchingForBody
Definition code.l:136
QCString realScope
Definition code.l:125
int lastTemplCastContext
Definition code.l:149
SrcLangExt lang
Definition code.l:159
SymbolResolver symbolResolver
Definition code.l:191
int currentObjId
Definition code.l:175
int currentWordId
Definition code.l:176
int lastObjCCallContext
Definition code.l:154
QCString args
Definition code.l:123
yy_size_t inputPosition
read offset during parsing
Definition code.l:108
bool insideObjC
Definition code.l:160
bool insideSpecialComment
Definition code.l:162
int lastStringContext
Definition code.l:151
QCString scopeName
Definition code.l:124
int yyLineNr
current line number
Definition code.l:112
int currentCtxId
Definition code.l:173
std::vector< const Definition * > foldStack
Definition code.l:193
bool insideProtocolList
Definition code.l:161
OutputCodeList * code
Definition code.l:98
int lastVerbStringContext
Definition code.l:153
int inputLines
number of line in the code fragment
Definition code.l:111
const MemberDef * currentMemberDef
Definition code.l:133
std::unordered_map< std::string, ScopedTypeVariant > codeClassMap
Definition code.l:100
QCString exampleFile
Definition code.l:118
UsingContext theUsingContext
Definition code.l:189
std::unordered_map< int, QCString > nameMap
Definition code.l:180
bool skipCodify
for CSharp files scoped namespace {
Definition code.l:114
int currentNameId
Definition code.l:174
std::stack< ObjCCallCtx * > contextStack
Definition code.l:178
int skipInlineInitContext
Definition code.l:157
QCString saveName
Definition code.l:139
SrcLangExt
Definition types.h:207
A bunch of utility functions.
264%}
265
266B [ \t]
267Bopt {B}*
268BN [ \t\n\r]
269ID [$a-z_A-Z\x80-\xFF][$a-z_A-Z0-9\x80-\xFF]*
270SEP ("::"|"\\")
271SCOPENAME ("::"{BN}*)?({ID}{BN}*{SEP}{BN}*)*("~"{BN}*)?{ID}
272TEMPLIST "<"[^\"\}\{\‍(\‍)\/\n>]*">"
273SCOPETNAME (((({ID}{TEMPLIST}?){BN}*)?{SEP}{BN}*)*)((~{BN}*)?{ID})
274SCOPEPREFIX ({ID}{TEMPLIST}?{BN}*{SEP}{BN}*)+
275KEYWORD_OBJC ("@public"|"@private"|"@protected"|"@class"|"@implementation"|"@interface"|"@end"|"@selector"|"@protocol"|"@optional"|"@required"|"@throw"|"@synthesize"|"@property")
276 /* please also pay attention to skipLanguageSpecificKeyword when changing the list of keywords. */
277KEYWORD ("asm"|"__assume"|"auto"|"class"|"const"|"delete"|"enum"|"explicit"|"extern"|"false"|"friend"|"gcnew"|"gcroot"|"set"|"get"|"inline"|"internal"|"mutable"|"namespace"|"new"|"null"|"nullptr"|"override"|"operator"|"pin_ptr"|"private"|"protected"|"public"|"raise"|"register"|"remove"|"self"|"sizeof"|"static"|"struct"|"__super"|"function"|"template"|"generic"|"this"|"true"|"typedef"|"typeid"|"typename"|"union"|"using"|"virtual"|"volatile"|"abstract"|"sealed"|"final"|"import"|"synchronized"|"transient"|"alignas"|"alignof"|"concept"|"requires"|"decltype"|{KEYWORD_OBJC}|"constexpr"|"consteval"|"constinit"|"co_await"|"co_return"|"co_yield"|"static_assert"|"_Static_assert"|"noexcept"|"thread_local"|"enum"{B}+("class"|"struct"))
278FLOWKW ("break"|"catch"|"continue"|"default"|"do"|"else"|"finally"|"return"|"switch"|"throw"|"throws"|"@catch"|"@finally")
279FLOWCONDITION ("case"|"for"|"foreach"|"for each"|"goto"|"if"|"try"|"while"|"@try")
280TYPEKW ("bool"|"byte"|"char"|"char8_t"|"char16_t"|"char32_t"|"double"|"float"|"int"|"long"|"object"|"short"|"signed"|"unsigned"|"void"|"wchar_t"|"size_t"|"boolean"|"id"|"SEL"|"string"|"nullptr")
281TYPEKWSL ("LocalObject"|"Object"|"Value")
282CASTKW ("const_cast"|"dynamic_cast"|"reinterpret_cast"|"static_cast")
283CHARLIT (("'"\\‍[0-7]{1,3}"'")|("'"\\."'")|("'"[^' \\\n]{1,4}"'"))
284ARITHOP "+"|"-"|"/"|"*"|"%"|"--"|"++"
285ASSIGNOP "="|"*="|"/="|"%="|"+="|"-="|"<<="|">>="|"&="|"^="|"|="
286LOGICOP "=="|"!="|">"|"<"|">="|"<="|"&&"|"||"|"!"|"<=>"
287BITOP "&"|"|"|"^"|"<<"|">>"|"~"
288OPERATOR {ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}
289RAWBEGIN (u|U|L|u8)?R\"[^ \t\‍(\‍)\\‍]{0,16}"("
290RAWEND ")"[^ \t\‍(\‍)\\‍]{0,16}\"
291MODULE_ID ({ID}".")*{ID}
292
293 /* no comment start / end signs inside square brackets */
294NCOMM [^/\*]
295 //- start: NUMBER -------------------------------------------------------------------------
296 // Note same defines in commentcnv.l: keep in sync
297DECIMAL_INTEGER [1-9][0-9']*[0-9]?[uU]?[lL]?[lL]?
298HEXADECIMAL_INTEGER "0"[xX][0-9a-zA-Z']+[0-9a-zA-Z]?
299OCTAL_INTEGER "0"[0-7][0-7']+[0-7]?
300BINARY_INTEGER "0"[bB][01][01']*[01]?
301INTEGER_NUMBER {DECIMAL_INTEGER}|{HEXADECIMAL_INTEGER}|{OCTAL_INTEGER}|{BINARY_INTEGER}
302
303FP_SUF [fFlL]
304
305DIGIT_SEQ [0-9][0-9']*[0-9]?
306FRAC_CONST {DIGIT_SEQ}"."|{DIGIT_SEQ}?"."{DIGIT_SEQ}
307FP_EXP [eE][+-]?{DIGIT_SEQ}
308DEC_FP1 {FRAC_CONST}{FP_EXP}?{FP_SUF}?
309DEC_FP2 {DIGIT_SEQ}{FP_EXP}{FP_SUF}
310
311HEX_DIGIT_SEQ [0-9a-fA-F][0-9a-fA-F']*[0-9a-fA-F]?
312HEX_FRAC_CONST {HEX_DIGIT_SEQ}"."|{HEX_DIGIT_SEQ}?"."{HEX_DIGIT_SEQ}
313BIN_EXP [pP][+-]?{DIGIT_SEQ}
314HEX_FP1 "0"[xX]{HEX_FRAC_CONST}{BIN_EXP}{FP_SUF}?
315HEX_FP2 "0"[xX]{HEX_DIGIT_SEQ}{BIN_EXP}{FP_SUF}?
316
317FLOAT_DECIMAL {DEC_FP1}|{DEC_FP2}
318FLOAT_HEXADECIMAL {HEX_FP1}|{HEX_FP2}
319FLOAT_NUMBER {FLOAT_DECIMAL}|{FLOAT_HEXADECIMAL}
320NUMBER {INTEGER_NUMBER}|{FLOAT_NUMBER}
321 //- end: NUMBER ---------------------------------------------------------------------------
322
323 // C start comment
324CCS "/\*"
325 // C end comment
326CCE "*\/"
327 // Cpp comment
328CPPC "/\/"
329
330 // ENDIDopt
331ENDIDopt ("::"{ID})*
332 // Optional end qualifiers
333ENDQopt ("const"|"volatile"|"sealed"|"override")({BN}+("const"|"volatile"|"sealed"|"override"))*
334
335%option noyywrap
336
337%x SkipString
338%x SkipStringS
339%x SkipVerbString
340%x SkipCPP
341%x SkipComment
342%x SkipCxxComment
343%x Body
344%x BodyVar
345%x FuncCall
346%x MemberCall
347%x MemberCall2
348%x SkipInits
349%x ClassName
350%x AlignAs
351%x AlignAsEnd
352%x PackageName
353%x ClassVar
354%x CppCliTypeModifierFollowup
355%x Bases
356%x SkipSharp
357%x ReadInclude
358%x TemplDecl
359%x TemplCast
360%x CallEnd
361%x ObjCMethod
362%x ObjCParams
363%x ObjCParamType
364%x ObjCCall
365%x ObjCMName
366%x ObjCSkipStr
367%x ObjCCallComment
368%x OldStyleArgs
369%x ConceptName
370%x UsingName
371%x RawString
372%x InlineInit
373%x ModuleName
374%x ModuleImport
375
376%%
377
378<*>\x0d
379<Body>^([ \t]*"#"[ \t]*("include"|"import")[ \t]*)("<"|"\"") {
380 startFontClass(yyscanner,"preprocessor");
381 yyextra->code->codify(yytext);
382 BEGIN( ReadInclude );
383 }
384<Body>("@interface"|"@implementation"|"@protocol")[ \t\n]+ {
385 yyextra->insideObjC=TRUE;
386 startFontClass(yyscanner,"keyword");
387 codifyLines(yyscanner,yytext);
388 endFontClass(yyscanner);
389 if (!yyextra->insideTemplate)
390 BEGIN( ClassName );
391 }
#define TRUE
Definition qcstring.h:37
392<Body>(("public"|"private"){B}+)?("ref"|"value"|"interface"|"enum"){B}+("class"|"struct") {
393 if (yyextra->insideTemplate) REJECT;
394 startFontClass(yyscanner,"keyword");
395 codifyLines(yyscanner,yytext);
396 endFontClass(yyscanner);
397 BEGIN( ClassName );
398 }
399<Body>"property"|"event"/{BN}* {
400 if (yyextra->insideTemplate) REJECT;
401 startFontClass(yyscanner,"keyword");
402 codifyLines(yyscanner,yytext);
403 endFontClass(yyscanner);
404 }
405<Body>("partial"{B}+)?("class"|"struct"|"union"|"namespace"|"interface"){B}+ {
406 startFontClass(yyscanner,"keyword");
407 codifyLines(yyscanner,yytext);
408 endFontClass(yyscanner);
409 if (!yyextra->insideTemplate)
410 BEGIN( ClassName );
411 }
412<Body>("package")[ \t\n]+ {
413 startFontClass(yyscanner,"keyword");
414 codifyLines(yyscanner,yytext);
415 endFontClass(yyscanner);
416 BEGIN( PackageName );
417 }
418<ClassVar>\n {
419 if (!yyextra->insideObjC) REJECT;
420 codifyLines(yyscanner,yytext);
421 BEGIN(Body);
422 }
423<Body,ClassVar,Bases>"-"|"+" {
424 if (!yyextra->insideObjC || yyextra->insideBody)
425 {
426 yyextra->code->codify(yytext);
427 }
428 else // Start of Objective-C method
429 {
430 DBG_CTX((stderr,"Start of Objective-C method!\n"));
431 yyextra->code->codify(yytext);
432 BEGIN(ObjCMethod);
433 }
434 }
#define DBG_CTX(x)
Definition code.l:73
435<ObjCMethod>":" {
436 yyextra->code->codify(yytext);
437 BEGIN(ObjCParams);
438 }
439<ObjCParams>"(" {
440 yyextra->code->codify(yytext);
441 BEGIN(ObjCParamType);
442 }
443<ObjCParams,ObjCMethod>";"|"{" {
444 yyextra->code->codify(yytext);
445 if (*yytext=='{')
446 {
447 if (yyextra->searchingForBody)
448 {
449 yyextra->searchingForBody=FALSE;
450 yyextra->insideBody=TRUE;
451 }
452 if (yyextra->insideBody) yyextra->bodyCurlyCount++;
453 if (!yyextra->curClassName.isEmpty()) // valid class name
454 {
455 pushScope(yyscanner,yyextra->curClassName);
456 DBG_CTX((stderr,"** scope stack push SCOPEBLOCK\n"));
457 yyextra->scopeStack.push(SCOPEBLOCK);
458 }
459 }
460 yyextra->type.clear();
461 yyextra->name.clear();
462 BEGIN(Body);
463 }
#define SCOPEBLOCK
Definition code.l:78
464<ObjCParams>{ID}{B}*":" {
465 yyextra->code->codify(yytext);
466 }
467<ObjCParamType>{TYPEKW} {
468 startFontClass(yyscanner,"keywordtype");
469 yyextra->code->codify(yytext);
470 endFontClass(yyscanner);
471 yyextra->parmType=yytext;
472 }
473<ObjCParamType>{ID} {
474 generateClassOrGlobalLink(yyscanner,*yyextra->code,yytext);
475 yyextra->parmType=yytext;
476 }
477<ObjCParamType>")" {
478 yyextra->code->codify(yytext);
479 BEGIN(ObjCParams);
480 }
481<ObjCParams>{ID} {
482 yyextra->code->codify(yytext);
483 yyextra->parmName=yytext;
484 addVariable(yyscanner,yyextra->parmType,yyextra->parmName);
485 yyextra->parmType.clear();yyextra->parmName.clear();
486 }
487<ObjCMethod,ObjCParams,ObjCParamType>{ID} {
488 generateClassOrGlobalLink(yyscanner,*yyextra->code,yytext);
489 }
490<ObjCMethod,ObjCParams,ObjCParamType>. {
491 yyextra->code->codify(yytext);
492 }
493<ObjCMethod,ObjCParams,ObjCParamType>\n {
494 codifyLines(yyscanner,yytext);
495 }
496<ReadInclude>[^\n\">]+/(">"|"\"") {
497 //FileInfo *f;
498 bool found = false;
499 bool ambig = false;
500 QCString absIncFileName = determineAbsoluteIncludeName(yyextra->absFileName,yytext);
501 const FileDef *fd=findFileDef(Doxygen::inputNameLinkedMap,absIncFileName,ambig);
502 //printf("looking for include %s -> %s fd=%p\n",yytext,qPrint(absPath),fd);
503 if (fd && fd->isLinkable())
504 {
505 if (ambig) // multiple input files match the name
506 {
507 DBG_CTX((stderr,"===== yes %s is ambiguous\n",yytext));
508 QCString name(Dir::cleanDirPath(yytext));
509 if (!name.isEmpty() && yyextra->sourceFileDef)
510 {
511 const FileName *fn = Doxygen::inputNameLinkedMap->find(name);
512 if (fn)
513 {
514 // see if this source file actually includes the file
515 auto it = std::find_if(fn->begin(),
516 fn->end(),
517 [&sfd=yyextra->sourceFileDef]
518 (const auto &lfd)
519 { return sfd->isIncluded(lfd->absFilePath()); });
520 found = it!=fn->end();
521 }
522 }
523 }
524 else // not ambiguous
525 {
526 found = TRUE;
527 }
528 }
529 DBG_CTX((stderr," include file %s found=%d\n",fd ? qPrint(fd->absFilePath()) : "<none>",found));
530 if (found)
531 {
532 writeMultiLineCodeLink(yyscanner,*yyextra->code,fd,yytext);
533 }
534 else
535 {
536 yyextra->code->codify(yytext);
537 }
538 char c=(char)yyinput(yyscanner);
539 QCString text;
540 text+=c;
541 yyextra->code->codify(text);
542 endFontClass(yyscanner);
543 BEGIN( Body );
544 }
virtual bool isLinkable() const =0
static std::string cleanDirPath(const std::string &path)
Definition dir.cpp:357
static FileNameLinkedMap * inputNameLinkedMap
Definition doxygen.h:104
virtual QCString absFilePath() const =0
Class representing all files with a certain base name.
Definition filename.h:30
const char * qPrint(const char *s)
Definition qcstring.h:687
QCString determineAbsoluteIncludeName(const QCString &curFile, const QCString &incFileName)
Definition util.cpp:3554
FileDef * findFileDef(const FileNameLinkedMap *fnMap, const QCString &n, bool &ambig)
Definition util.cpp:2844
545<Body,Bases>^[ \t]*"#" {
546 startFontClass(yyscanner,"preprocessor");
547 yyextra->lastSkipCppContext = YY_START;
548 yyextra->code->codify(yytext);
549 BEGIN( SkipCPP ) ;
550 }
551<SkipCPP>\" {
552 yyextra->code->codify(yytext);
553 yyextra->lastStringContext=YY_START;
554 BEGIN( SkipString ) ;
555 }
556<SkipCPP>. {
557 yyextra->code->codify(yytext);
558 }
559<SkipCPP>[^\n\/\\\"]+ {
560 yyextra->code->codify(yytext);
561 }
562<SkipCPP>\\‍[\r]?\n {
563 codifyLines(yyscanner,yytext);
564 }
565<SkipCPP>{CPPC}/[^/!] {
566 REJECT;
567 }
568<Body,FuncCall,MemberCall,MemberCall2>"}" {
569 yyextra->theVarContext.popScope();
570 yyextra->theCallContext.popScope(yyextra->name, yyextra->type, yyextra->bracketCount);
571 yyextra->type.clear();
572 yyextra->name.clear();
573
574 if (!yyextra->scopeStack.empty())
575 {
576 int scope = yyextra->scopeStack.top();
577 yyextra->scopeStack.pop();
578 DBG_CTX((stderr,"** scope stack pop SCOPEBLOCK=%d\n",scope==SCOPEBLOCK));
579 if (scope==SCOPEBLOCK || scope==CLASSBLOCK)
580 {
581 popScope(yyscanner);
582 }
583 }
584
585 yyextra->code->codify(yytext);
586
587 DBG_CTX((stderr,"yyextra->bodyCurlyCount=%d\n",yyextra->bodyCurlyCount));
588 if (--yyextra->bodyCurlyCount<=0)
589 {
590 yyextra->insideBody=FALSE;
591 yyextra->currentMemberDef=nullptr;
592 if (yyextra->currentDefinition)
593 yyextra->currentDefinition=yyextra->currentDefinition->getOuterScope();
594 }
595 BEGIN(Body);
596 }
#define CLASSBLOCK
Definition code.l:77
597<Body,ClassVar>"@end" {
598 DBG_CTX((stderr,"End of objc scope fd=%s\n",qPrint(yyextra->sourceFileDef->name())));
599 if (yyextra->sourceFileDef)
600 {
601 const FileDef *fd=yyextra->sourceFileDef;
602 yyextra->insideObjC = fd->name().lower().endsWith(".m") ||
603 fd->name().lower().endsWith(".mm");
604 DBG_CTX((stderr,"insideObjC=%d\n",yyextra->insideObjC));
605 }
606 else
607 {
608 yyextra->insideObjC = FALSE;
609 }
610 if (yyextra->insideBody)
611 {
612 yyextra->theVarContext.popScope();
613
614 if (!yyextra->scopeStack.empty())
615 {
616 int scope = yyextra->scopeStack.top();
617 yyextra->scopeStack.pop();
618 DBG_CTX((stderr,"** scope stack pop SCOPEBLOCK=%d\n",scope==SCOPEBLOCK));
619 if (scope==SCOPEBLOCK || scope==CLASSBLOCK)
620 {
621 popScope(yyscanner);
622 }
623 }
624 yyextra->insideBody=FALSE;
625 }
626
627 startFontClass(yyscanner,"keyword");
628 yyextra->code->codify(yytext);
629 endFontClass(yyscanner);
630
631 yyextra->currentMemberDef=nullptr;
632 if (yyextra->currentDefinition)
633 yyextra->currentDefinition=yyextra->currentDefinition->getOuterScope();
634 BEGIN(Body);
635 }
virtual const QCString & name() const =0
QCString lower() const
Definition qcstring.h:249
bool endsWith(const char *s) const
Definition qcstring.h:524
636<ClassName,ClassVar>";" {
637 if (yyextra->lang==SrcLangExt::CSharp)
638 {
639 yyextra->code->codify(yytext);
640 yyextra->skipCodify = true;
641 unput('{');
642 }
643 else
644 {
645 yyextra->code->codify(yytext);
646 yyextra->searchingForBody=FALSE;
647 BEGIN( Body );
648 }
649 }
650<ClassName,ClassVar>[*&^%]+ {
651 yyextra->type=yyextra->curClassName;
652 yyextra->name.clear();
653 yyextra->code->codify(yytext);
654 BEGIN( Body ); // variable of type struct *
655 }
656<ClassName>"__declspec"{B}*"("{B}*{ID}{B}*")" {
657 startFontClass(yyscanner,"keyword");
658 yyextra->code->codify(yytext);
659 endFontClass(yyscanner);
660 }
661<ClassName>{ID}("."{ID})* |
662<ClassName>{ID}("::"{ID})* {
663 if (yyextra->lang==SrcLangExt::CSharp)
664 yyextra->curClassName=substitute(yytext,".","::");
665 else
666 yyextra->curClassName=yytext;
667 addType(yyscanner);
668 if (yyextra->curClassName=="alignas")
669 {
670 startFontClass(yyscanner,"keyword");
671 yyextra->code->codify(yytext);
672 endFontClass(yyscanner);
673 BEGIN( AlignAs );
674 }
675 else
676 {
677 generateClassOrGlobalLink(yyscanner,*yyextra->code,yytext);
678 BEGIN( ClassVar );
679 }
680 }
QCString substitute(const QCString &s, const QCString &src, const QCString &dst)
substitute all occurrences of src in s by dst
Definition qcstring.cpp:571
681<AlignAs>"(" {
682 yyextra->bracketCount=1;
683 yyextra->code->codify(yytext);
684 BEGIN( AlignAsEnd );
685 }
686<AlignAs>\n { yyextra->yyLineNr++;
687 codifyLines(yyscanner,yytext);
688 }
689<AlignAs>. { yyextra->code->codify(yytext); }
690<AlignAsEnd>"(" { yyextra->code->codify(yytext);
691 yyextra->bracketCount++;
692 }
693<AlignAsEnd>")" {
694 yyextra->code->codify(yytext);
695 if (--yyextra->bracketCount<=0)
696 {
697 BEGIN(ClassName);
698 }
699 }
700<AlignAsEnd>\n { yyextra->yyLineNr++;
701 codifyLines(yyscanner,yytext);
702 }
703<AlignAsEnd>. { yyextra->code->codify(yytext); }
704<ClassName>{ID}("\\"{ID})* { // PHP namespace
705 yyextra->curClassName=substitute(yytext,"\\","::");
706 yyextra->scopeStack.push(CLASSBLOCK);
707 pushScope(yyscanner,yyextra->curClassName);
708 addType(yyscanner);
709 generateClassOrGlobalLink(yyscanner,*yyextra->code,yytext);
710 BEGIN( ClassVar );
711 }
712<ClassName>{ID}{B}*"("{ID}")" { // Obj-C category
713 yyextra->curClassName=removeRedundantWhiteSpace(yytext);
714 yyextra->scopeStack.push(CLASSBLOCK);
715 pushScope(yyscanner,yyextra->curClassName);
716 addType(yyscanner);
717 generateClassOrGlobalLink(yyscanner,*yyextra->code,yytext);
718 BEGIN( ClassVar );
719 }
QCString removeRedundantWhiteSpace(const QCString &s)
Definition util.cpp:568
720<PackageName>{ID}("."{ID})* {
721 yyextra->curClassName=substitute(yytext,".","::");
722 DBG_CTX((stderr,"found package: %s\n",qPrint(yyextra->curClassName)));
723 addType(yyscanner);
724 codifyLines(yyscanner,yytext);
725 }
726<ClassVar>"=" {
727 unput(*yytext);
728 BEGIN( Body );
729 }
730<ClassVar>("extends"|"implements") { // Java, Slice
731 startFontClass(yyscanner,"keyword");
732 codifyLines(yyscanner,yytext);
733 endFontClass(yyscanner);
734 yyextra->curClassBases.clear();
735 BEGIN( Bases );
736 }
737<ClassVar>("sealed"|"abstract")/{BN}*(":"|"{") {
738 DBG_CTX((stderr,"***** C++/CLI modifier %s on yyextra->curClassName=%s\n",yytext,qPrint(yyextra->curClassName)));
739 startFontClass(yyscanner,"keyword");
740 codifyLines(yyscanner,yytext);
741 endFontClass(yyscanner);
742 BEGIN( CppCliTypeModifierFollowup );
743 }
744<ClassVar>{ID} {
745 yyextra->type = yyextra->curClassName;
746 yyextra->name = yytext;
747 if (yyextra->insideBody)
748 {
749 addVariable(yyscanner,yyextra->type,yyextra->name);
750 }
751 generateClassOrGlobalLink(yyscanner,*yyextra->code,yytext);
752 }
753<ClassName,ClassVar,CppCliTypeModifierFollowup>{B}*":"{B}* {
754 codifyLines(yyscanner,yytext);
755 yyextra->curClassBases.clear();
756 BEGIN( Bases );
757 }
758<PackageName>[ \t]*";" |
759<Bases>^{Bopt}/"@"{ID} | // Objective-C interface
760<Bases,ClassName,ClassVar,CppCliTypeModifierFollowup>{B}*"{"{B}* {
761 yyextra->theVarContext.pushScope();
762 if (!yyextra->skipCodify) yyextra->code->codify(yytext);
763 yyextra->skipCodify = false;
764 if (YY_START==ClassVar && yyextra->curClassName.isEmpty())
765 {
766 yyextra->curClassName = yyextra->name;
767 }
768 if (yyextra->searchingForBody)
769 {
770 yyextra->searchingForBody=FALSE;
771 yyextra->insideBody=TRUE;
772 }
773 if (yyextra->insideBody) yyextra->bodyCurlyCount++;
774 if (!yyextra->curClassName.isEmpty()) // valid class name
775 {
776 DBG_CTX((stderr,"** scope stack push CLASSBLOCK\n"));
777 yyextra->scopeStack.push(CLASSBLOCK);
778 pushScope(yyscanner,yyextra->curClassName);
779 DBG_CTX((stderr,"***** yyextra->curClassName=%s\n",qPrint(yyextra->curClassName)));
780 if (yyextra->symbolResolver.resolveClass(yyextra->currentDefinition,yyextra->curClassName,true)==nullptr)
781 {
782 DBG_CTX((stderr,"Adding new class %s\n",qPrint(yyextra->curClassName)));
783 ScopedTypeVariant var(yyextra->curClassName);
784 // insert base classes.
785 for (const auto &s : yyextra->curClassBases)
786 {
787 const ClassDef *bcd=nullptr;
788 auto it = yyextra->codeClassMap.find(s);
789 if (it!=yyextra->codeClassMap.end())
790 {
791 bcd = toClassDef(it->second.globalDef());
792 }
793 if (bcd==nullptr) bcd=yyextra->symbolResolver.resolveClass(yyextra->currentDefinition,s,true);
794 if (bcd && bcd->name()!=yyextra->curClassName)
795 {
796 var.localDef()->insertBaseClass(bcd->name());
797 }
798 }
799 yyextra->codeClassMap.emplace(yyextra->curClassName.str(),std::move(var));
800 }
801 //printf("yyextra->codeClassList.count()=%d\n",yyextra->codeClassList.count());
802 }
803 else // not a class name -> assume inner block
804 {
805 DBG_CTX((stderr,"** scope stack push INNERBLOCK\n"));
806 yyextra->scopeStack.push(INNERBLOCK);
807 }
808 yyextra->curClassName.clear();
809 yyextra->curClassBases.clear();
810 BEGIN( Body );
811 }
ClassDef * toClassDef(Definition *d)
#define INNERBLOCK
Definition code.l:79
812<Bases>"virtual"|"public"|"protected"|"private"|"@public"|"@private"|"@protected" {
813 startFontClass(yyscanner,"keyword");
814 yyextra->code->codify(yytext);
815 endFontClass(yyscanner);
816 }
817<Bases>{SEP}?({ID}{SEP})*{ID} {
818 DBG_CTX((stderr,"%s:addBase(%s)\n",qPrint(yyextra->curClassName),yytext));
819 yyextra->curClassBases.emplace_back(yytext);
820 generateClassOrGlobalLink(yyscanner,*yyextra->code,yytext);
821 }
822<Bases>"<" {
823 yyextra->code->codify(yytext);
824 if (!yyextra->insideObjC)
825 {
826 yyextra->sharpCount=1;
827 BEGIN ( SkipSharp );
828 }
829 else
830 {
831 yyextra->insideProtocolList=TRUE;
832 }
833 }
834<Bases>">" {
835 yyextra->code->codify(yytext);
836 yyextra->insideProtocolList=FALSE;
837 }
838<SkipSharp>"<" {
839 yyextra->code->codify(yytext);
840 ++yyextra->sharpCount;
841 }
842<SkipSharp>">" {
843 yyextra->code->codify(yytext);
844 if (--yyextra->sharpCount<=0)
845 BEGIN ( Bases );
846 }
847<SkipSharp>"\"" {
848 yyextra->code->codify(yytext);
849 yyextra->lastStringContext=YY_START;
850 BEGIN(SkipString);
851 }
852<SkipSharp>"\'" {
853 yyextra->code->codify(yytext);
854 yyextra->lastStringContext=YY_START;
855 BEGIN(SkipStringS);
856 }
857<Bases>"(" {
858 yyextra->code->codify(yytext);
859 yyextra->sharpCount=1;
860 BEGIN ( SkipSharp );
861 }
862<SkipSharp>"(" {
863 yyextra->code->codify(yytext);
864 ++yyextra->sharpCount;
865 }
866<SkipSharp>")" {
867 yyextra->code->codify(yytext);
868 if (--yyextra->sharpCount<=0)
869 BEGIN ( Bases );
870 }
871
872
873<Bases>"," {
874 yyextra->code->codify(yytext);
875 }
876
877
878<Body>{SCOPEPREFIX}?"operator"{B}*"()"{Bopt}/"(" {
879 addType(yyscanner);
880 generateFunctionLink(yyscanner,*yyextra->code,yytext);
881 yyextra->bracketCount=0;
882 yyextra->args.clear();
883 yyextra->name+=yytext;
884 BEGIN( FuncCall );
885 }
886<Body>{SCOPEPREFIX}?"operator"/"(" {
887 addType(yyscanner);
888 generateFunctionLink(yyscanner,*yyextra->code,yytext);
889 yyextra->bracketCount=0;
890 yyextra->args.clear();
891 yyextra->name+=yytext;
892 BEGIN( FuncCall );
893 }
894<Body>{SCOPEPREFIX}?"operator"[^a-z_A-Z0-9\‍(\n]+/"(" {
895 addType(yyscanner);
896 generateFunctionLink(yyscanner,*yyextra->code,yytext);
897 yyextra->bracketCount=0;
898 yyextra->args.clear();
899 yyextra->name+=yytext;
900 BEGIN( FuncCall );
901 }
902<Body,TemplDecl>("template"|"generic")/([^a-zA-Z0-9]) {
903 startFontClass(yyscanner,"keyword");
904 codifyLines(yyscanner,yytext);
905 endFontClass(yyscanner);
906 yyextra->insideTemplate=TRUE;
907 yyextra->sharpCount=0;
908 }
909<Body>"concept"{BN}+ {
910 startFontClass(yyscanner,"keyword");
911 codifyLines(yyscanner,yytext);
912 endFontClass(yyscanner);
913 BEGIN(ConceptName);
914 }
915<Body>"using"{BN}+"namespace"{BN}+ {
916 startFontClass(yyscanner,"keyword");
917 codifyLines(yyscanner,yytext);
918 endFontClass(yyscanner);
919 BEGIN(UsingName);
920 }
921<Body>"using"{BN}+ {
922 startFontClass(yyscanner,"keyword");
923 codifyLines(yyscanner,yytext);
924 endFontClass(yyscanner);
925 BEGIN(UsingName);
926 }
927<Body>"module"/{B}*[:;]? { // 'module X' or 'module : private' or 'module;'
928 if (yyextra->lang!=SrcLangExt::Cpp) REJECT;
929 if (!yyextra->type.isEmpty() || !yyextra->name.isEmpty()) REJECT;
930 startFontClass(yyscanner,"keyword");
931 codifyLines(yyscanner,yytext);
932 endFontClass(yyscanner);
933 BEGIN(ModuleName);
934 }
935<Body>"import"/{B}*[<":]? {
936 if (yyextra->lang!=SrcLangExt::Cpp) REJECT;
937 startFontClass(yyscanner,"keyword");
938 codifyLines(yyscanner,yytext);
939 endFontClass(yyscanner);
940 BEGIN(ModuleImport);
941 }
942<ConceptName>{ID}("::"{ID})* {
943 generateClassOrGlobalLink(yyscanner,*yyextra->code,yytext);
944 }
945<ConceptName>"=" { codifyLines(yyscanner,yytext); BEGIN(Body); }
946<UsingName>{ID}(("::"|"."){ID})* {
947 addUsingDirective(yyscanner,substitute(yytext,".","::"));
948 generateClassOrGlobalLink(yyscanner,*yyextra->code,yytext);
949 BEGIN(Body);
950 }
951<UsingName>\n { codifyLines(yyscanner,yytext); BEGIN(Body); }
952<UsingName>. { codifyLines(yyscanner,yytext); BEGIN(Body); }
953<Body,FuncCall>"$"?"this"("->"|".") { yyextra->code->codify(yytext); // this-> for C++, this. for C#
954 yyextra->isPrefixedWithThis = TRUE;
955 }
956<Body>{KEYWORD}/([^a-z_A-Z0-9]) {
957 if (yyextra->lang==SrcLangExt::Java && qstrcmp("internal",yytext) ==0) REJECT;
958 if (skipLanguageSpecificKeyword(yyscanner,yytext)) REJECT;
959 QCString text=yytext;
960 startFontClass(yyscanner,"keyword");
961 codifyLines(yyscanner,yytext);
962 if (text=="typedef" || text.find("enum ")!=-1) // typedef or strong enum
963 {
964 addType(yyscanner);
965 yyextra->name+=yytext;
966 }
967 endFontClass(yyscanner);
968 }
int find(char c, int index=0, bool cs=TRUE) const
Definition qcstring.cpp:43
int qstrcmp(const char *str1, const char *str2)
Definition qcstring.h:69
969<Body>{KEYWORD}/{B}* {
970 if (skipLanguageSpecificKeyword(yyscanner,yytext)) REJECT;
971 startFontClass(yyscanner,"keyword");
972 codifyLines(yyscanner,yytext);
973 endFontClass(yyscanner);
974 }
975<Body>{KEYWORD}/{BN}*"(" {
976 if (skipLanguageSpecificKeyword(yyscanner,yytext)) REJECT;
977 startFontClass(yyscanner,"keyword");
978 codifyLines(yyscanner,yytext);
979 endFontClass(yyscanner);
980 yyextra->name.clear();yyextra->type.clear();
981 }
982<FuncCall>"in"/{BN}* {
983 if (!yyextra->inForEachExpression) REJECT;
984 startFontClass(yyscanner,"keywordflow");
985 codifyLines(yyscanner,yytext);
986 endFontClass(yyscanner);
987 // insert the variable in the parent scope, see bug 546158
988 yyextra->theVarContext.popScope();
989 addVariable(yyscanner,yyextra->parmType,yyextra->parmName);
990 yyextra->theVarContext.pushScope();
991 yyextra->name.clear();yyextra->type.clear();
992 }
993<Body>{FLOWKW}/{BN}*"(" {
994 startFontClass(yyscanner,"keywordflow");
995 codifyLines(yyscanner,yytext);
996 endFontClass(yyscanner);
997 yyextra->name.clear();yyextra->type.clear();
998 yyextra->inForEachExpression = (qstrcmp(yytext,"for each")==0 || qstrcmp(yytext, "foreach")==0);
999 BEGIN(FuncCall);
1000 }
1001<Body>{FLOWCONDITION}/{BN}*"(" {
1002 incrementFlowKeyWordCount(yyscanner);
1003 startFontClass(yyscanner,"keywordflow");
1004 codifyLines(yyscanner,yytext);
1005 endFontClass(yyscanner);
1006 yyextra->name.clear();yyextra->type.clear();
1007 yyextra->inForEachExpression = (strcmp(yytext,"for each")==0 || strcmp(yytext, "foreach")==0);
1008 BEGIN(FuncCall);
1009 }
1010<Body>{FLOWKW}/([^a-z_A-Z0-9]) {
1011 startFontClass(yyscanner,"keywordflow");
1012 codifyLines(yyscanner,yytext);
1013 endFontClass(yyscanner);
1014 if (yyextra->inFunctionTryBlock && (qstrcmp(yytext,"catch")==0 || qstrcmp(yytext,"finally")==0))
1015 {
1016 yyextra->inFunctionTryBlock=FALSE;
1017 }
1018 }
1019<Body>{FLOWCONDITION}/([^a-z_A-Z0-9]) {
1020 incrementFlowKeyWordCount(yyscanner);
1021 startFontClass(yyscanner,"keywordflow");
1022 codifyLines(yyscanner,yytext);
1023 endFontClass(yyscanner);
1024 if (yyextra->inFunctionTryBlock && (strcmp(yytext,"catch")==0 || strcmp(yytext,"finally")==0))
1025 {
1026 yyextra->inFunctionTryBlock=FALSE;
1027 }
1028 }
1029<Body>{FLOWKW}/{B}* {
1030 startFontClass(yyscanner,"keywordflow");
1031 codifyLines(yyscanner,yytext);
1032 endFontClass(yyscanner);
1033 }
1034<Body>{FLOWCONDITION}/{B}* {
1035 incrementFlowKeyWordCount(yyscanner);
1036 startFontClass(yyscanner,"keywordflow");
1037 codifyLines(yyscanner,yytext);
1038 endFontClass(yyscanner);
1039 }
1040<Body>"*"{B}*")" { // end of cast?
1041 yyextra->code->codify(yytext);
1042 yyextra->theCallContext.popScope(yyextra->name, yyextra->type, yyextra->bracketCount);
1043 yyextra->bracketCount--;
1044 yyextra->parmType = yyextra->name;
1045 BEGIN(FuncCall);
1046 }
1047<Body>"\\‍)"|"\\‍(" {
1048 yyextra->code->codify(yytext);
1049 }
1050<Body>[\\|\‍)\+\-\/\%\~\!] {
1051 yyextra->code->codify(yytext);
1052 yyextra->name.clear();yyextra->type.clear();
1053 if (*yytext==')')
1054 {
1055 yyextra->theCallContext.popScope(yyextra->name, yyextra->type, yyextra->bracketCount);
1056 yyextra->bracketCount--;
1057 if (yyextra->bracketCount<=0)
1058 {
1059 BEGIN(FuncCall);
1060 }
1061 }
1062 }
1063<Body,TemplDecl,ObjCMethod>{TYPEKW}/{B}* {
1064 startFontClass(yyscanner,"keywordtype");
1065 yyextra->code->codify(yytext);
1066 endFontClass(yyscanner);
1067 addType(yyscanner);
1068 yyextra->name+=yytext;
1069 }
1070<Body,TemplDecl,ObjCMethod>{TYPEKWSL}/{B}* {
1071 if (yyextra->lang!=SrcLangExt::Slice)
1072 {
1073 REJECT;
1074 }
1075 else
1076 {
1077 startFontClass(yyscanner,"keywordtype");
1078 yyextra->code->codify(yytext);
1079 endFontClass(yyscanner);
1080 addType(yyscanner);
1081 yyextra->name+=yytext;
1082 }
1083 }
1084<Body>"generic"/{B}*"<"[^\n\/\-\.\{\">]*">"{B}* {
1085 startFontClass(yyscanner,"keyword");
1086 yyextra->code->codify(yytext);
1087 endFontClass(yyscanner);
1088 yyextra->sharpCount=0;
1089 BEGIN(TemplDecl);
1090 }
1091<Body>"template"/{B}*"<"[^\n\/\-\.\{\">]*">"{B}* { // template<...>
1092 startFontClass(yyscanner,"keyword");
1093 yyextra->code->codify(yytext);
1094 endFontClass(yyscanner);
1095 yyextra->sharpCount=0;
1096 BEGIN(TemplDecl);
1097 }
1098<TemplDecl>"class"|"typename" {
1099 startFontClass(yyscanner,"keyword");
1100 codifyLines(yyscanner,yytext);
1101 endFontClass(yyscanner);
1102 }
1103<TemplDecl>"<" {
1104 yyextra->code->codify(yytext);
1105 yyextra->sharpCount++;
1106 }
1107<TemplDecl>">" {
1108 yyextra->code->codify(yytext);
1109 yyextra->sharpCount--;
1110 if (yyextra->sharpCount<=0)
1111 {
1112 BEGIN(Body);
1113 }
1114 }
1115<TemplCast>">" {
1116 startFontClass(yyscanner,"keyword");
1117 codifyLines(yyscanner,yytext);
1118 endFontClass(yyscanner);
1119 BEGIN( yyextra->lastTemplCastContext );
1120 }
1121<TemplCast>{ID}("::"{ID})* {
1122 generateClassOrGlobalLink(yyscanner,*yyextra->code,yytext);
1123 }
1124<TemplCast>("const"|"volatile"){B}* {
1125 startFontClass(yyscanner,"keyword");
1126 codifyLines(yyscanner,yytext);
1127 endFontClass(yyscanner);
1128 }
1129<TemplCast>[*^]* {
1130 codifyLines(yyscanner,yytext);
1131 }
1132<Body,MemberCall2,FuncCall>{CASTKW}{B}*"<" { // static_cast<T>(
1133 startFontClass(yyscanner,"keyword");
1134 codifyLines(yyscanner,yytext);
1135 endFontClass(yyscanner);
1136 yyextra->lastTemplCastContext = YY_START;
1137 BEGIN(TemplCast);
1138 }
1139<Body>"$this->"{SCOPENAME}/{BN}*[;,)\‍]] { // PHP member variable
1140 addType(yyscanner);
1141 generatePHPVariableLink(yyscanner,*yyextra->code,yytext);
1142 yyextra->name+=yytext+7;
1143 }
1144<Body,TemplCast>{SCOPENAME}{B}*"<"[^\n\/\-\.\{\">\‍(']*">"{ENDIDopt}/{B}* { // A<T> *pt;
1145 if (isCastKeyword(yytext) && YY_START==Body)
1146 {
1147 REJECT;
1148 }
1149 addType(yyscanner);
1150 generateClassOrGlobalLink(yyscanner,*yyextra->code,yytext);
1151 yyextra->name+=yytext;
1152 }
1153<ModuleName,ModuleImport>{MODULE_ID}({BN}*":"{BN}*{MODULE_ID})? {
1154 QCString name = yytext;
1155 int i = name.find(':');
1156 QCString partition;
1157 if (i!=-1)
1158 {
1159 partition = name.mid(i+1).stripWhiteSpace();
1160 name = name.left(i).stripWhiteSpace();
1161 }
1163 if (mod)
1164 {
1165 writeMultiLineCodeLink(yyscanner,*yyextra->code,mod,yytext);
1166 }
1167 else
1168 {
1169 codifyLines(yyscanner,yytext);
1170 }
1171 }
static ModuleManager & instance()
ModuleDef * getPrimaryInterface(const QCString &moduleName) const
QCString mid(size_t index, size_t len=static_cast< size_t >(-1)) const
Definition qcstring.h:241
QCString stripWhiteSpace() const
returns a copy of this string with leading and trailing whitespace removed
Definition qcstring.h:260
QCString left(size_t len) const
Definition qcstring.h:229
1172<ModuleName>":"{BN}+"private" {
1173 QCString text=yytext;
1174 int i=text.find('p');
1175 codifyLines(yyscanner,text.left(i));
1176 startFontClass(yyscanner,"keyword");
1177 codifyLines(yyscanner,text.mid(i));
1178 endFontClass(yyscanner);
1179 }
1180<ModuleName>";" { yyextra->code->codify(yytext); BEGIN(Body); }
1181<ModuleName>. { yyextra->code->codify(yytext); }
1182<ModuleName>\n { codifyLines(yyscanner,yytext); }
1183<ModuleImport>["<] { yyextra->code->codify(yytext); BEGIN(ReadInclude); }
1184<ModuleImport>";" { yyextra->code->codify(yytext); BEGIN(Body); }
1185<ModuleImport>. { yyextra->code->codify(yytext); }
1186<ModuleImport>\n { codifyLines(yyscanner,yytext); }
1187
1188<Body>{SCOPENAME}/{BN}*[:;,)\‍]] { // "int var;" or "var, var2" or "debug(f) macro" , or int var : 5;
1189 if (startsWithKeyword(yytext,"typedef") || startsWithKeyword(yytext,"using"))
1190 {
1191 REJECT;
1192 }
1193 addType(yyscanner);
1194 generateClassOrGlobalLink(yyscanner,*yyextra->code,yytext);
1195 yyextra->name+=yytext;
1196 }
1197<Body>{ID}("."{ID})+/{BN}+ { // CSharp/Java scope
1198 if (yyextra->lang==SrcLangExt::CSharp || yyextra->lang==SrcLangExt::Java)
1199 {
1200 addType(yyscanner);
1201 generateClassOrGlobalLink(yyscanner,*yyextra->code,yytext);
1202 yyextra->name+=yytext;
1203 }
1204 else
1205 {
1206 REJECT;
1207 }
1208 }
1209<Body>"export"/{B}* {
1210 if (yyextra->lang!=SrcLangExt::Cpp) REJECT;
1211 startFontClass(yyscanner,"keyword");
1212 codifyLines(yyscanner,yytext);
1213 endFontClass(yyscanner);
1214 }
1215<Body>{SCOPENAME}/{B}* { // p->func()
1216 if (startsWithKeyword(yytext,"typedef") || startsWithKeyword(yytext,"using"))
1217 {
1218 REJECT;
1219 }
1220 addType(yyscanner);
1221 generateClassOrGlobalLink(yyscanner,*yyextra->code,yytext);
1222 yyextra->name+=yytext;
1223 }
1224<Body>"("{B}*("*"{B}*)+{SCOPENAME}+{B}*")"/{B}* { // (*p)->func() but not "if (p) ..."
1225 yyextra->code->codify(yytext);
1226 uint32_t s=0;while (s<(uint32_t)yyleng && !isId(yytext[s])) s++;
1227 uint32_t e=(uint32_t)yyleng-1;while (e>1 && !isId(yytext[e])) e--;
1228 QCString varname = ((QCString)yytext).mid(s,e-s+1);
1229 addType(yyscanner);
1230 yyextra->name=std::move(varname);
1231 }
bool isId(int c)
Definition util.h:207
1232<Body>{SCOPETNAME}{B}*"<"[^\n\/\-\.\{\">]*">"/{BN}*"(" |
1233<Body>{SCOPETNAME}/{BN}*"(" { // a() or c::a() or t<A,B>::a() or A\B\foo()
1234 if (isCastKeyword(yytext))
1235 {
1236 REJECT;
1237 }
1238 addType(yyscanner);
1239 generateFunctionLink(yyscanner,*yyextra->code,yytext);
1240 yyextra->bracketCount=0;
1241 yyextra->args.clear();
1242 yyextra->name+=yytext;
1243 BEGIN( FuncCall );
1244 }
1245<FuncCall,Body,MemberCall,MemberCall2,SkipInits,InlineInit>{RAWBEGIN} {
1246 QCString text(yytext);
1247 uint32_t i=(uint32_t)text.find('R');
1248 yyextra->code->codify(text.left(i+1));
1249 startFontClass(yyscanner,"stringliteral");
1250 yyextra->code->codify(yytext+i+1);
1251 yyextra->lastStringContext=YY_START;
1252 yyextra->inForEachExpression = FALSE;
1253 yyextra->delimiter = extractBeginRawStringDelimiter(yytext);
1254 BEGIN( RawString );
1255 }
QCString extractBeginRawStringDelimiter(const char *rawStart)
Definition util.cpp:6898
1256<FuncCall,Body,MemberCall,MemberCall2,SkipInits,InlineInit,ClassVar,OldStyleArgs>\" {
1257 startFontClass(yyscanner,"stringliteral");
1258 yyextra->code->codify(yytext);
1259 yyextra->lastStringContext=YY_START;
1260 yyextra->inForEachExpression = FALSE;
1261 BEGIN( SkipString );
1262 }
1263<FuncCall,Body,MemberCall,MemberCall2,SkipInits,InlineInit>{NUMBER} { //Note similar code in commentcnv.l
1264 if (yyextra->lang!=SrcLangExt::Cpp) REJECT;
1265 yyextra->code->codify(yytext);
1266 }
1267<FuncCall,Body,MemberCall,MemberCall2,SkipInits,InlineInit>\' {
1268 startFontClass(yyscanner,"stringliteral");
1269 yyextra->code->codify(yytext);
1270 yyextra->lastStringContext=YY_START;
1271 yyextra->inForEachExpression = FALSE;
1272 BEGIN( SkipStringS );
1273 }
1274<SkipString>[^\"\\\r\n]{1,100} {
1275 yyextra->code->codify(yytext);
1276 }
1277<SkipStringS>[^\'\\\r\n]{1,100} {
1278 yyextra->code->codify(yytext);
1279 }
1280<SkipString,SkipStringS>{CPPC}|{CCS} {
1281 yyextra->code->codify(yytext);
1282 }
1283<SkipString>@?\" {
1284 yyextra->code->codify(yytext);
1285 if (yyextra->lastStringContext!=SkipCPP)
1286 {
1287 endFontClass(yyscanner);
1288 }
1289 BEGIN( yyextra->lastStringContext );
1290 }
1291<SkipStringS>\' {
1292 yyextra->code->codify(yytext);
1293 endFontClass(yyscanner);
1294 BEGIN( yyextra->lastStringContext );
1295 }
1296<SkipString,SkipStringS>\\. {
1297 yyextra->code->codify(yytext);
1298 }
1299<RawString>{RAWEND} {
1300 yyextra->code->codify(yytext);
1301 if (extractEndRawStringDelimiter(yytext)==yyextra->delimiter)
1302 {
1303 BEGIN( yyextra->lastStringContext );
1304 }
1305 }
QCString extractEndRawStringDelimiter(const char *rawEnd)
Definition util.cpp:6906
1306<RawString>[^)\n]+ { yyextra->code->codify(yytext); }
1307<RawString>. { yyextra->code->codify(yytext); }
1308<RawString>\n { codifyLines(yyscanner,yytext); }
1309<SkipVerbString>[^"\n]+ {
1310 yyextra->code->codify(yytext);
1311 }
1312<SkipVerbString>\"\" { // escaped quote
1313 yyextra->code->codify(yytext);
1314 }
1315<SkipVerbString>\" { // end of string
1316 yyextra->code->codify(yytext);
1317 endFontClass(yyscanner);
1318 BEGIN( yyextra->lastVerbStringContext );
1319 }
1320<SkipVerbString>. {
1321 yyextra->code->codify(yytext);
1322 }
1323<SkipVerbString>\n {
1324 codifyLines(yyscanner,yytext);
1325 }
1326<Body>":" {
1327 yyextra->code->codify(yytext);
1328 yyextra->name.clear();yyextra->type.clear();
1329 }
1330<Body>"<" {
1331 if (yyextra->insideTemplate)
1332 {
1333 yyextra->sharpCount++;
1334 }
1335 yyextra->code->codify(yytext);
1336 }
1337<Body>">" {
1338 if (yyextra->insideTemplate)
1339 {
1340 if (--yyextra->sharpCount<=0)
1341 {
1342 yyextra->insideTemplate=FALSE;
1343 }
1344 }
1345 yyextra->code->codify(yytext);
1346 }
1347<Body,MemberCall,MemberCall2,FuncCall,OldStyleArgs>"'"((\\0[Xx0-9]+)|(\\.)|(.))"'" {
1348 startFontClass(yyscanner,"charliteral");
1349 yyextra->code->codify(yytext);
1350 endFontClass(yyscanner);
1351 }
1352<Body>"."|"->" {
1353 if (yytext[0]=='-') // -> could be overloaded
1354 {
1356 }
1357 yyextra->code->codify(yytext);
1358 yyextra->memCallContext = YY_START;
1359 BEGIN( MemberCall );
1360 }
1361<MemberCall>{SCOPETNAME}/{BN}*"(" {
1362 if (yyextra->theCallContext.getScope().globalDef())
1363 {
1364 if (!generateClassMemberLink(yyscanner,*yyextra->code,yyextra->theCallContext.getScope().globalDef(),yytext))
1365 {
1366 codifyLines(yyscanner,yytext);
1367 addToSearchIndex(yyscanner,yytext);
1368 }
1369 yyextra->name.clear();
1370 }
1371 else
1372 {
1373 codifyLines(yyscanner,yytext);
1374 addToSearchIndex(yyscanner,yytext);
1375 yyextra->name.clear();
1376 }
1377 yyextra->type.clear();
1378 if (yyextra->memCallContext==Body)
1379 {
1380 BEGIN(FuncCall);
1381 }
1382 else
1383 {
1384 BEGIN(yyextra->memCallContext);
1385 }
1386 }
1387<MemberCall>{SCOPENAME}/{B}* {
1388 if (yyextra->theCallContext.getScope().globalDef())
1389 {
1390 DBG_CTX((stderr,"yyextra->theCallContext.getClass()=%p\n",(void*)yyextra->theCallContext.getScope().globalDef()));
1391 if (!generateClassMemberLink(yyscanner,*yyextra->code,yyextra->theCallContext.getScope().globalDef(),yytext))
1392 {
1393 codifyLines(yyscanner,yytext);
1394 addToSearchIndex(yyscanner,yytext);
1395 }
1396 yyextra->name.clear();
1397 }
1398 else
1399 {
1400 DBG_CTX((stderr,"no class context!\n"));
1401 codifyLines(yyscanner,yytext);
1402 addToSearchIndex(yyscanner,yytext);
1403 yyextra->name.clear();
1404 }
1405 yyextra->type.clear();
1406 BEGIN(yyextra->memCallContext);
1407 }
1408<Body>[,=;\‍[{] {
1409 if (yyextra->insideObjC && *yytext=='[')
1410 {
1411 DBG_CTX((stderr,"Found start of ObjC call!\n"));
1412 // start of a method call
1413 yyextra->contextMap.clear();
1414 yyextra->nameMap.clear();
1415 yyextra->objectMap.clear();
1416 yyextra->wordMap.clear();
1417 yyextra->commentMap.clear();
1418 yyextra->currentCtxId = 0;
1419 yyextra->currentNameId = 0;
1420 yyextra->currentObjId = 0;
1421 yyextra->currentCtx = nullptr;
1422 yyextra->braceCount = 0;
1423 unput('[');
1424 BEGIN(ObjCCall);
1425 }
1426 else
1427 {
1428 if (*yytext!='{') yyextra->code->codify(yytext);
1429 yyextra->saveName = yyextra->name;
1430 yyextra->saveType = yyextra->type;
1431 if (*yytext!='[' && !yyextra->type.isEmpty())
1432 {
1433 //printf("yyextra->scopeStack.bottom()=%p\n",yyextra->scopeStack.bottom());
1434 //if (yyextra->scopeStack.top()!=CLASSBLOCK) // commented out for bug731363
1435 {
1436 //printf("AddVariable: '%s' '%s' context=%d\n",
1437 // qPrint(yyextra->type),qPrint(yyextra->name),yyextra->theVarContext.count());
1438 addVariable(yyscanner,yyextra->type,yyextra->name);
1439 }
1440 yyextra->name.clear();
1441 }
1442 if (*yytext==';' || *yytext=='=' || *yytext=='{')
1443 {
1444 yyextra->type.clear();
1445 yyextra->name.clear();
1446 }
1447 else if (*yytext=='[')
1448 {
1449 yyextra->theCallContext.pushScope(yyextra->name, yyextra->type, yyextra->bracketCount);
1450 }
1451 yyextra->args.clear();
1452 yyextra->parmType.clear();
1453 yyextra->parmName.clear();
1454 if (*yytext=='{')
1455 {
1456 BEGIN( BodyVar );
1457 unput('{');
1458 }
1459 }
1460 }
1461<Body,FuncCall,BodyVar>"{" {
1462 yyextra->theVarContext.pushScope();
1463 yyextra->theCallContext.pushScope(yyextra->name, yyextra->type, yyextra->bracketCount);
1464 yyextra->bracketCount = 0;
1465
1466 DBG_CTX((stderr,"** type='%s' name='%s'\n",qPrint(yyextra->type),qPrint(yyextra->name)));
1467 if (yyextra->type.find("enum ")!=-1)
1468 { // for strong enums we need to start a scope
1469 DBG_CTX((stderr,"** scope stack push SCOPEBLOCK\n"));
1470 pushScope(yyscanner,yyextra->name);
1471 yyextra->scopeStack.push(SCOPEBLOCK);
1472 }
1473 else
1474 {
1475 DBG_CTX((stderr,"** scope stack push INNERBLOCK\n"));
1476 yyextra->scopeStack.push(INNERBLOCK);
1477 }
1478
1479 if (yyextra->searchingForBody)
1480 {
1481 yyextra->searchingForBody=FALSE;
1482 yyextra->insideBody=TRUE;
1483 }
1484 yyextra->code->codify(yytext);
1485 if (yyextra->insideBody)
1486 {
1487 yyextra->bodyCurlyCount++;
1488 }
1489 yyextra->type.clear();
1490 yyextra->name.clear();
1491 BEGIN( Body );
1492 }
1493<ObjCCall,ObjCMName>"["|"{" {
1494 saveObjCContext(yyscanner);
1495 yyextra->currentCtx->format+=*yytext;
1496 BEGIN(ObjCCall);
1497 DBG_CTX((stderr,"open\n"));
1498 }
1499<ObjCCall,ObjCMName>"]"|"}" {
1500 yyextra->currentCtx->format+=*yytext;
1501 restoreObjCContext(yyscanner);
1502 BEGIN(ObjCMName);
1503 if (yyextra->currentCtx==nullptr)
1504 {
1505 // end of call
1506 ObjCCallCtx *ctx = nullptr;
1507 auto it = yyextra->contextMap.find(0);
1508 if (it!=yyextra->contextMap.end())
1509 {
1510 ctx = it->second.get();
1511 }
1512 writeObjCMethodCall(yyscanner,ctx);
1513 BEGIN(Body);
1514 }
1515 DBG_CTX((stderr,"close\n"));
1516 }
1517<ObjCCall,ObjCMName>{CPPC}.* {
1518 yyextra->currentCtx->format+=escapeComment(yyscanner,yytext);
1519 }
1520<ObjCCall,ObjCMName>{CCS} {
1521 yyextra->lastObjCCallContext = YY_START;
1522 yyextra->currentCtx->comment.str(yytext);
1523 BEGIN(ObjCCallComment);
1524 }
1525<ObjCCallComment>{CCE} {
1526 yyextra->currentCtx->comment << yytext;
1527 yyextra->currentCtx->format+=escapeComment(yyscanner,yyextra->currentCtx->comment.str());
1528 BEGIN(yyextra->lastObjCCallContext);
1529 }
1530<ObjCCallComment>[^*\n]+ { yyextra->currentCtx->comment << yytext; }
1531<ObjCCallComment>{CPPC}|{CCS} { yyextra->currentCtx->comment << yytext; }
1532<ObjCCallComment>\n { yyextra->currentCtx->comment << *yytext; }
1533<ObjCCallComment>. { yyextra->currentCtx->comment << *yytext; }
1534<ObjCCall>{ID}({B}*"."{B}*{ID})* {
1535 yyextra->currentCtx->format+=escapeObject(yyscanner,yytext);
1536 if (yyextra->braceCount==0)
1537 {
1538 yyextra->currentCtx->objectTypeOrName=yytext;
1539 DBG_CTX((stderr,"new type=%s\n",qPrint(yyextra->currentCtx->objectTypeOrName)));
1540 BEGIN(ObjCMName);
1541 }
1542 }
1543<ObjCMName>{ID}/{BN}*"]" {
1544 if (yyextra->braceCount==0 &&
1545 yyextra->currentCtx->methodName.isEmpty())
1546 {
1547 yyextra->currentCtx->methodName=yytext;
1548 yyextra->currentCtx->format+=escapeName(yyscanner,yytext);
1549 }
1550 else
1551 {
1552 yyextra->currentCtx->format+=escapeWord(yyscanner,yytext);
1553 }
1554 }
1555<ObjCMName>{ID}/{BN}*":" {
1556 if (yyextra->braceCount==0)
1557 {
1558 yyextra->currentCtx->methodName+=yytext;
1559 yyextra->currentCtx->methodName+=":";
1560 }
1561 yyextra->currentCtx->format+=escapeName(yyscanner,yytext);
1562 }
1563<ObjCSkipStr>[^\n\"$\\‍]* { yyextra->currentCtx->format+=yytext; }
1564<ObjCSkipStr>\\. { yyextra->currentCtx->format+=yytext; }
1565<ObjCSkipStr>"\"" { yyextra->currentCtx->format+=yytext;
1566 BEGIN(yyextra->lastStringContext);
1567 }
1568<ObjCCall,ObjCMName>{CHARLIT} { yyextra->currentCtx->format+=yytext; }
1569<ObjCCall,ObjCMName>"@"?"\"" { yyextra->currentCtx->format+=yytext;
1570 yyextra->lastStringContext=YY_START;
1571 BEGIN(ObjCSkipStr);
1572 }
1573<ObjCCall,ObjCMName,ObjCSkipStr>"$" { yyextra->currentCtx->format+="$$"; }
1574<ObjCCall,ObjCMName>"(" { yyextra->currentCtx->format+=*yytext; yyextra->braceCount++; }
1575<ObjCCall,ObjCMName>")" { yyextra->currentCtx->format+=*yytext; yyextra->braceCount--; }
1576<ObjCSkipStr>"@"/"\"" { // needed to prevent matching the global rule (for C#)
1577 yyextra->currentCtx->format+=yytext;
1578 }
1579<ObjCCall,ObjCMName,ObjCSkipStr>{ID} { yyextra->currentCtx->format+=escapeWord(yyscanner,yytext); }
1580<ObjCCall,ObjCMName,ObjCSkipStr>. { yyextra->currentCtx->format+=*yytext; }
1581<ObjCCall,ObjCMName,ObjCSkipStr>\n { yyextra->currentCtx->format+=*yytext; }
1582
1583<Body>"]" {
1584 yyextra->theCallContext.popScope(yyextra->name, yyextra->type, yyextra->bracketCount);
1585 yyextra->code->codify(yytext);
1586 // TODO: nested arrays like: a[b[0]->func()]->func()
1587 yyextra->name = yyextra->saveName;
1588 yyextra->type = yyextra->saveType;
1589 }
1590<Body>[0-9]+ {
1591 yyextra->code->codify(yytext);
1592 }
1593<Body>[0-9]+[xX][0-9A-Fa-f]+ {
1594 yyextra->code->codify(yytext);
1595 }
1596<MemberCall2,FuncCall>{KEYWORD}/([^a-z_A-Z0-9]) {
1597 //addParmType(yyscanner);
1598 //yyextra->parmName=yytext;
1599 if (skipLanguageSpecificKeyword(yyscanner,yytext)) REJECT;
1600 startFontClass(yyscanner,"keyword");
1601 yyextra->code->codify(yytext);
1602 endFontClass(yyscanner);
1603 }
1604<MemberCall2,FuncCall,OldStyleArgs,TemplCast>{TYPEKW}/([^a-z_A-Z0-9]) {
1605 addParmType(yyscanner);
1606 yyextra->parmName=yytext;
1607 startFontClass(yyscanner,"keywordtype");
1608 yyextra->code->codify(yytext);
1609 endFontClass(yyscanner);
1610 }
1611<MemberCall2,FuncCall,OldStyleArgs,TemplCast>{TYPEKWSL}/([^a-z_A-Z0-9]) {
1612 if (yyextra->lang!=SrcLangExt::Slice)
1613 {
1614 REJECT;
1615 }
1616 else
1617 {
1618 addParmType(yyscanner);
1619 yyextra->parmName=yytext;
1620 startFontClass(yyscanner,"keywordtype");
1621 yyextra->code->codify(yytext);
1622 endFontClass(yyscanner);
1623 }
1624 }
1625<MemberCall2,FuncCall>{FLOWKW}/([^a-z_A-Z0-9]) {
1626 addParmType(yyscanner);
1627 yyextra->parmName=yytext;
1628 startFontClass(yyscanner,"keywordflow");
1629 yyextra->code->codify(yytext);
1630 endFontClass(yyscanner);
1631 }
1632<MemberCall2,FuncCall>{FLOWCONDITION}/([^a-z_A-Z0-9]) {
1633 incrementFlowKeyWordCount(yyscanner);
1634 addParmType(yyscanner);
1635 yyextra->parmName=yytext;
1636 startFontClass(yyscanner,"keywordflow");
1637 yyextra->code->codify(yytext);
1638 endFontClass(yyscanner);
1639 }
1640<MemberCall2,FuncCall>("::")?{ID}(({B}*"<"[^\n\‍[\‍](){}<>']*">")?({B}*"::"{B}*{ID})?)* {
1641 if (isCastKeyword(yytext))
1642 {
1643 REJECT;
1644 }
1645 addParmType(yyscanner);
1646 yyextra->parmName=yytext;
1647 generateClassOrGlobalLink(yyscanner,*yyextra->code,yytext,!yyextra->insideBody);
1648 }
1649<FuncCall>";" { // probably a cast, not a function call
1650 yyextra->code->codify(yytext);
1651 yyextra->inForEachExpression = FALSE;
1652 BEGIN( Body );
1653 }
1654<MemberCall2,FuncCall>, {
1655 yyextra->code->codify(yytext);
1656 addVariable(yyscanner,yyextra->parmType,yyextra->parmName);
1657 yyextra->parmType.clear();yyextra->parmName.clear();
1658 }
1659<MemberCall2,FuncCall>"{" {
1660 if (yyextra->bracketCount>0)
1661 {
1662 yyextra->code->codify(yytext);
1663 yyextra->skipInlineInitContext=YY_START;
1664 yyextra->curlyCount=0;
1665 BEGIN(InlineInit);
1666 }
1667 else
1668 {
1669 REJECT;
1670 }
1671 }
1672<InlineInit>"{" { yyextra->curlyCount++;
1673 yyextra->code->codify(yytext);
1674 }
1675<InlineInit>"}" {
1676 yyextra->code->codify(yytext);
1677 if (--yyextra->curlyCount<=0)
1678 {
1679 BEGIN(yyextra->skipInlineInitContext);
1680 }
1681 }
1682<InlineInit>\n {
1683 codifyLines(yyscanner,yytext);
1684 }
1685<InlineInit>. {
1686 yyextra->code->codify(yytext);
1687 }
1688<MemberCall2,FuncCall>"(" {
1689 yyextra->parmType.clear();yyextra->parmName.clear();
1690 yyextra->code->codify(yytext);
1691 yyextra->bracketCount++;
1692 yyextra->theCallContext.pushScope(yyextra->name, yyextra->type, yyextra->bracketCount);
1693 if (YY_START==FuncCall && !yyextra->insideBody)
1694 {
1695 yyextra->theVarContext.pushScope();
1696 }
1697 }
1698<MemberCall2,FuncCall>{OPERATOR} { // operator
1699 if (qstrcmp(yytext,"*") &&
1700 qstrcmp(yytext,"&") &&
1701 qstrcmp(yytext,"^") &&
1702 qstrcmp(yytext,"%")) // typically a pointer or reference
1703 {
1704 // not a * or &, or C++/CLI's ^ or %
1705 yyextra->parmType.clear();yyextra->parmName.clear();
1706 }
1707 yyextra->code->codify(yytext);
1708 }
1709<MemberCall,MemberCall2,FuncCall>("*"{B}*)?")" {
1710 if (yytext[0]==')') // no a pointer cast
1711 {
1712 DBG_CTX((stderr,"addVariable(%s,%s)\n",qPrint(yyextra->parmType),qPrint(yyextra->parmName)));
1713 if (yyextra->parmType.isEmpty())
1714 {
1715 yyextra->parmType=yyextra->parmName;
1716 yyextra->parmName.clear();
1717 }
1718 addVariable(yyscanner,yyextra->parmType,yyextra->parmName);
1719 }
1720 else
1721 {
1722 yyextra->parmType = yyextra->parmName;
1723 yyextra->parmName.clear();
1724 addVariable(yyscanner,yyextra->parmType,yyextra->parmName);
1725 }
1726 yyextra->theCallContext.popScope(yyextra->name, yyextra->type, yyextra->bracketCount);
1727 yyextra->inForEachExpression = FALSE;
1728 //yyextra->theCallContext.setClass(0); // commented out, otherwise a()->b() does not work for b().
1729 yyextra->code->codify(yytext);
1730 if (--yyextra->bracketCount<=0)
1731 {
1732 if (yyextra->name.isEmpty())
1733 {
1734 BEGIN( Body );
1735 }
1736 else
1737 {
1738 BEGIN( CallEnd );
1739 }
1740 }
1741 }
1742<MemberCall,MemberCall2,FuncCall>[;:] { // recover from unexpected end of call
1743 //if (yytext[0]==';' || yyextra->bracketCount<=0)
1744 if (yyextra->bracketCount<=0)
1745 {
1746 unput(*yytext);
1747 BEGIN(CallEnd);
1748 }
1749 else
1750 {
1751 yyextra->code->codify(yytext);
1752 }
1753 }
1754<CallEnd>[ \t\n]* { codifyLines(yyscanner,yytext); }
1755<CallEnd>[;:] {
1756 codifyLines(yyscanner,yytext);
1757 yyextra->bracketCount=0;
1758 if (*yytext==';') yyextra->searchingForBody=FALSE;
1759 if (!yyextra->type.isEmpty())
1760 {
1761 DBG_CTX((stderr,"add variable yyextra->type=%s yyextra->name=%s)\n",qPrint(yyextra->type),qPrint(yyextra->name)));
1762 addVariable(yyscanner,yyextra->type,yyextra->name);
1763 }
1764 yyextra->parmType.clear();yyextra->parmName.clear();
1765 yyextra->theCallContext.setScope(ScopedTypeVariant());
1766 if (*yytext==';' || yyextra->insideBody)
1767 {
1768 if (!yyextra->insideBody)
1769 {
1770 yyextra->theVarContext.popScope();
1771 }
1772 yyextra->name.clear();yyextra->type.clear();
1773 BEGIN( Body );
1774 }
1775 else
1776 {
1777 yyextra->bracketCount=0;
1778 BEGIN( SkipInits );
1779 }
1780 }
1781<CallEnd>{ENDQopt}/{BN}*(";"|"="|"throw"{BN}*"(") {
1782 startFontClass(yyscanner,"keyword");
1783 codifyLines(yyscanner,yytext);
1784 endFontClass(yyscanner);
1785 }
1786<CallEnd,OldStyleArgs>("const"|"volatile"|"sealed"|"override")*({BN}+("const"|"volatile"|"sealed"|"override"))*{BN}*"{" {
1787 if (yyextra->insideBody)
1788 {
1789 yyextra->theVarContext.pushScope();
1790 }
1791 addVariable(yyscanner,yyextra->parmType,yyextra->parmName);
1792 //yyextra->theCallContext.popScope(yyextra->name, yyextra->type);
1793 yyextra->parmType.clear();yyextra->parmName.clear();
1794 int index = yyextra->name.findRev("::");
1795 DBG_CTX((stderr,"yyextra->name=%s\n",qPrint(yyextra->name)));
1796 if (index!=-1)
1797 {
1798 QCString scope = yyextra->name.left((uint32_t)index);
1799 if (!yyextra->scopeName.isEmpty()) scope.prepend((yyextra->scopeName+"::"));
1800 const ClassDef *cd=yyextra->symbolResolver.resolveClass(Doxygen::globalScope,scope,true);
1801 if (cd)
1802 {
1803 setClassScope(yyscanner,cd->name());
1804 yyextra->scopeStack.push(SCOPEBLOCK);
1805 DBG_CTX((stderr,"** scope stack push SCOPEBLOCK\n"));
1806 }
1807 else
1808 {
1809 //setClassScope(yyscanner,yyextra->realScope);
1810 yyextra->scopeStack.push(INNERBLOCK);
1811 DBG_CTX((stderr,"** scope stack push INNERBLOCK\n"));
1812 }
1813 }
1814 else
1815 {
1816 DBG_CTX((stderr,"** scope stack push INNERBLOCK\n"));
1817 yyextra->scopeStack.push(INNERBLOCK);
1818 }
1819 yytext[yyleng-1]='\0';
1820 QCString cv(yytext);
1821 if (!cv.stripWhiteSpace().isEmpty())
1822 {
1823 startFontClass(yyscanner,"keyword");
1824 codifyLines(yyscanner,yytext);
1825 endFontClass(yyscanner);
1826 }
1827 else // just whitespace
1828 {
1829 codifyLines(yyscanner,yytext);
1830 }
1831 yyextra->code->codify("{");
1832 if (yyextra->searchingForBody)
1833 {
1834 yyextra->searchingForBody=FALSE;
1835 yyextra->insideBody=TRUE;
1836 }
1837 if (yyextra->insideBody) yyextra->bodyCurlyCount++;
1838 yyextra->type.clear(); yyextra->name.clear();
1839 BEGIN( Body );
1840 }
static NamespaceDefMutable * globalScope
Definition doxygen.h:120
QCString & prepend(const char *s)
Definition qcstring.h:422
1841<CallEnd>"try" { // function-try-block
1842 startFontClass(yyscanner,"keyword");
1843 yyextra->code->codify(yytext);
1844 endFontClass(yyscanner);
1845 yyextra->inFunctionTryBlock=TRUE;
1846 }
1847<CallEnd>"requires" { // function-try-block
1848 startFontClass(yyscanner,"keyword");
1849 yyextra->code->codify(yytext);
1850 endFontClass(yyscanner);
1851 }
1852<CallEnd>{ID} {
1853 if (yyextra->insideBody || !yyextra->parmType.isEmpty())
1854 {
1855 REJECT;
1856 }
1857 // could be K&R style definition
1858 addParmType(yyscanner);
1859 yyextra->parmName=yytext;
1860 generateClassOrGlobalLink(yyscanner,*yyextra->code,yytext,!yyextra->insideBody);
1861 BEGIN(OldStyleArgs);
1862 }
1863<OldStyleArgs>{ID} {
1864 addParmType(yyscanner);
1865 yyextra->parmName=yytext;
1866 generateClassOrGlobalLink(yyscanner,*yyextra->code,yytext,!yyextra->insideBody);
1867 }
1868<OldStyleArgs>[,;] {
1869 yyextra->code->codify(yytext);
1870 addVariable(yyscanner,yyextra->parmType,yyextra->parmName);
1871 if (*yytext==';') yyextra->parmType.clear();
1872 yyextra->parmName.clear();
1873 }
1874<CallEnd,OldStyleArgs>"#" {
1875 startFontClass(yyscanner,"preprocessor");
1876 yyextra->lastSkipCppContext = Body;
1877 yyextra->code->codify(yytext);
1878 BEGIN( SkipCPP );
1879 }
1880<CallEnd>. {
1881 unput(*yytext);
1882 if (!yyextra->insideBody)
1883 {
1884 yyextra->theVarContext.popScope();
1885 }
1886 yyextra->name.clear();yyextra->args.clear();
1887 yyextra->parmType.clear();yyextra->parmName.clear();
1888 BEGIN( Body );
1889 }
1890<SkipInits>";" {
1891 yyextra->code->codify(yytext);
1892 yyextra->type.clear(); yyextra->name.clear();
1893 BEGIN( Body );
1894 }
1895<SkipInits>"{" {
1896 yyextra->code->codify(yytext);
1897 if (yyextra->searchingForBody)
1898 {
1899 yyextra->searchingForBody=FALSE;
1900 yyextra->insideBody=TRUE;
1901 }
1902 if (yyextra->insideBody) yyextra->bodyCurlyCount++;
1903 if (yyextra->name.find("::")!=-1)
1904 {
1905 DBG_CTX((stderr,"** scope stack push SCOPEBLOCK\n"));
1906 yyextra->scopeStack.push(SCOPEBLOCK);
1907 setClassScope(yyscanner,yyextra->realScope);
1908 }
1909 else
1910 {
1911 DBG_CTX((stderr,"** scope stack push INNERBLOCK\n"));
1912 yyextra->scopeStack.push(INNERBLOCK);
1913 }
1914 yyextra->type.clear(); yyextra->name.clear();
1915 BEGIN( Body );
1916 }
1917<SkipInits>{ID}{B}*"{" {
1918 QCString text(yytext);
1919 int bracketPos = text.find('{');
1920 int spacePos = text.find(' ');
1921 int len = spacePos==-1 ? bracketPos : spacePos;
1922 generateClassOrGlobalLink(yyscanner,*yyextra->code,text.left(len));
1923 yyextra->code->codify(yytext+len);
1924 }
1925<SkipInits>{ID} {
1926 generateClassOrGlobalLink(yyscanner,*yyextra->code,yytext);
1927 }
1928<FuncCall>{ID}/"(" {
1929 generateFunctionLink(yyscanner,*yyextra->code,yytext);
1930 }
1931<FuncCall>{ID}/("."|"->") {
1932 yyextra->name=yytext;
1933 generateClassOrGlobalLink(yyscanner,*yyextra->code,yytext);
1934 BEGIN( MemberCall2 );
1935 }
1936<FuncCall,MemberCall2>("("{B}*("*"{B}*)+{ID}+{B}*")"{B}*)/("."|"->") {
1937 yyextra->code->codify(yytext);
1938 uint32_t s=0;while (!isId(yytext[s])) s++;
1939 uint32_t e=(uint32_t)yyleng-1;while (e>1 && !isId(yytext[e])) e--;
1940 yyextra->name=((QCString)yytext).mid(s,e-s+1);
1941 BEGIN( MemberCall2 );
1942 }
1943<MemberCall2>{ID}/([ \t\n]*"(") {
1944 if (!yyextra->args.isEmpty())
1945 generateMemberLink(yyscanner,*yyextra->code,yyextra->args,yytext);
1946 else
1947 generateClassOrGlobalLink(yyscanner,*yyextra->code,yytext);
1948 yyextra->args.clear();
1949 BEGIN( FuncCall );
1950 }
1951<MemberCall2>{ID}/([ \t\n]*("."|"->")) {
1952 //yyextra->code->codify(yytext);
1953 yyextra->name=yytext;
1954 generateClassOrGlobalLink(yyscanner,*yyextra->code,yytext);
1955 BEGIN( MemberCall2 );
1956 }
1957<MemberCall2>"->"|"." {
1958 if (yytext[0]=='-') // -> could be overloaded
1959 {
1961 }
1962 yyextra->code->codify(yytext);
1963 yyextra->memCallContext = YY_START;
1964 BEGIN( MemberCall );
1965 }
1966<SkipComment>{CCS}("!"?){CCE} {
1967 yyextra->code->codify(yytext);
1968 endFontClass(yyscanner,true);
1969 BEGIN( yyextra->lastCContext ) ;
1970 }
1971<SkipComment>{CPPC}|{CCS} {
1972 yyextra->code->codify(yytext);
1973 }
1974<SkipComment>[^*\/\n]+ {
1975 yyextra->code->codify(yytext);
1976 }
1977<SkipComment>[ \t]*{CCE} {
1978 yyextra->code->codify(yytext);
1979 endFontClass(yyscanner,true);
1980 if (yyextra->lastCContext==SkipCPP)
1981 {
1982 startFontClass(yyscanner,"preprocessor");
1983 }
1984 BEGIN( yyextra->lastCContext ) ;
1985 }
1986<SkipCxxComment>[^\r\n]*"\\"[\r]?\n { // line continuation
1987 codifyLines(yyscanner,yytext);
1988 }
1989<SkipCxxComment>[^\r\n]+ {
1990 yyextra->code->codify(yytext);
1991 }
1992<SkipCxxComment>\r
1993<SkipCxxComment>\n {
1994 unput('\n');
1995 endFontClass(yyscanner);
1996 BEGIN( yyextra->lastCContext ) ;
1997 }
1998<SkipCxxComment>. {
1999 yyextra->code->codify(yytext);
2000 }
2001<MemberCall>[^a-z_A-Z0-9(\n] {
2002 yyextra->code->codify(yytext);
2003 yyextra->type.clear();
2004 yyextra->name.clear();
2005 BEGIN(yyextra->memCallContext);
2006 }
2007<*>\n({B}*{CPPC}[!/][^\n]*\n)+ { // remove special one-line comment
2008 if (YY_START==SkipCPP) REJECT;
2009 startFontClass(yyscanner,"comment",true);
2010 codifyLines(yyscanner,QCString(yytext).left(yyleng-1));
2011 endFontClass(yyscanner,true);
2012 codifyLines(yyscanner,"\n");
2013 if (YY_START==SkipCxxComment)
2014 {
2015 BEGIN( yyextra->lastCContext ) ;
2016 }
2017 }
2018<SkipCPP>\n/(.|\n) {
2019 endFontClass(yyscanner);
2020 BEGIN( yyextra->lastSkipCppContext ) ;
2021 unput('\n');
2022 }
2023<*>\n{B}*{CPPC}"@"[{}].*\n { // remove one-line group marker
2024 startFontClass(yyscanner,"comment",true);
2025 codifyLines(yyscanner,QCString(yytext).left(yyleng-1));
2026 endFontClass(yyscanner,true);
2027 codifyLines(yyscanner,"\n");
2028 if (YY_START==SkipCxxComment)
2029 {
2030 BEGIN( yyextra->lastCContext ) ;
2031 }
2032 }
2033<*>\n{B}*{CCS}"@"[{}] { // remove one-line group marker
2034 // check is to prevent getting stuck in skipping C++ comments
2035 if (YY_START != SkipComment && YY_START != SkipCxxComment)
2036 {
2037 yyextra->lastCContext = YY_START ;
2038 }
2039 startFontClass(yyscanner,"comment",true);
2040 codifyLines(yyscanner,yytext);
2041 BEGIN(SkipComment);
2042 }
2043<*>^{B}*{CPPC}"@"[{}].*\n { // remove one-line group marker
2044 startFontClass(yyscanner,"comment",true);
2045 codifyLines(yyscanner,QCString(yytext).left(yyleng-1));
2046 endFontClass(yyscanner,true);
2047 codifyLines(yyscanner,"\n");
2048 }
2049<*>^{B}*{CCS}"@"[{}] { // remove multi-line group marker
2050 // check is to prevent getting stuck in skipping C++ comments
2051 if (YY_START != SkipComment && YY_START != SkipCxxComment)
2052 {
2053 yyextra->lastCContext = YY_START ;
2054 }
2055 startFontClass(yyscanner,"comment",true);
2056 yyextra->code->codify(yytext);
2057 BEGIN(SkipComment);
2058 }
2059<*>^{B}*{CPPC}[!/][^\n]* { // remove special one-line comment
2060 startFontClass(yyscanner,"comment",true);
2061 codifyLines(yyscanner,yytext);
2062 endFontClass(yyscanner,true);
2063 }
2064<*>{CPPC}[!/][^\n]* { // strip special one-line comment
2065 if (YY_START==SkipComment || YY_START==SkipString) REJECT;
2066 startFontClass(yyscanner,"comment",true);
2067 codifyLines(yyscanner,yytext);
2068 endFontClass(yyscanner,true);
2069 }
2070<*>\n{B}*{CCS}[!*]/{NCOMM} {
2071 // check is to prevent getting stuck in skipping C++ comments
2072 if (YY_START != SkipComment && YY_START != SkipCxxComment)
2073 {
2074 yyextra->lastCContext = YY_START ;
2075 }
2076 startFontClass(yyscanner,"comment",true);
2077 codifyLines(yyscanner,yytext);
2078 BEGIN(SkipComment);
2079 }
2080<*>^{B}*{CCS}"*"[*]+/[^/] {
2081 // check is to prevent getting stuck in skipping C++ comments
2082 if (YY_START != SkipComment && YY_START != SkipCxxComment)
2083 {
2084 yyextra->lastCContext = YY_START ;
2085 }
2086 // special C "banner" comment block at a new line
2087 startFontClass(yyscanner,"comment",Config_getBool(JAVADOC_BANNER));
2088 yyextra->code->codify(yytext);
2089 BEGIN(SkipComment);
2090 }
#define Config_getBool(name)
Definition config.h:33
2091<*>^{B}*{CCS}[!*]/{NCOMM} { // special C comment block at a new line
2092 // check is to prevent getting stuck in skipping C++ comments
2093 if (YY_START != SkipComment && YY_START != SkipCxxComment)
2094 {
2095 yyextra->lastCContext = YY_START ;
2096 }
2097 startFontClass(yyscanner,"comment",true);
2098 yyextra->code->codify(yytext);
2099 BEGIN(SkipComment);
2100 }
2101<*>{CCS}[!*]/{NCOMM} { // special C comment block half way a line
2102 if (YY_START==SkipString) REJECT;
2103 // check is to prevent getting stuck in skipping C++ comments
2104 if (YY_START != SkipComment && YY_START != SkipCxxComment)
2105 {
2106 yyextra->lastCContext = YY_START ;
2107 }
2108 startFontClass(yyscanner,"comment",true);
2109 yyextra->code->codify(yytext);
2110 BEGIN(SkipComment);
2111 }
2112<*>{CCS}("!"?){CCE} {
2113 if (YY_START==SkipString) REJECT;
2114 bool specialComment = QCString(yytext).find('!')!=-1;
2115 startFontClass(yyscanner,"comment",specialComment);
2116 yyextra->code->codify(yytext);
2117 endFontClass(yyscanner,specialComment);
2118 }
2119<SkipComment>[^\*\n]+ {
2120 yyextra->code->codify(yytext);
2121 }
2122<*>{CCS} {
2123 startFontClass(yyscanner,"comment");
2124 yyextra->code->codify(yytext);
2125 // check is to prevent getting stuck in skipping C++ comments
2126 if (YY_START != SkipComment && YY_START != SkipCxxComment)
2127 {
2128 yyextra->lastCContext = YY_START ;
2129 }
2130 BEGIN( SkipComment ) ;
2131 }
2132<*>[$]?@\" { // C# (interpolated) verbatim string
2133 startFontClass(yyscanner,"stringliteral");
2134 yyextra->code->codify(yytext);
2135 yyextra->lastVerbStringContext=YY_START;
2136 BEGIN(SkipVerbString);
2137 }
2138<*>{CPPC} {
2139 startFontClass(yyscanner,"comment");
2140 yyextra->code->codify(yytext);
2141 yyextra->lastCContext = YY_START ;
2142 BEGIN( SkipCxxComment ) ;
2143 }
2144<*>"("|"[" {
2145 if (yytext[0]=='(') yyextra->bracketCount++;
2146 yyextra->code->codify(yytext);
2147 yyextra->theCallContext.pushScope(yyextra->name, yyextra->type, yyextra->bracketCount);
2148 }
2149<*>")"|"]" {
2150 if (yytext[0]==')') yyextra->bracketCount--;
2151 yyextra->code->codify(yytext);
2152 yyextra->theCallContext.popScope(yyextra->name, yyextra->type, yyextra->bracketCount);
2153 }
2154<*>\n {
2155 codifyLines(yyscanner,yytext);
2156 }
2157<*>[\x80-\xFF]* { // keep utf8 characters together...
2158 yyextra->code->codify(yytext);
2159 }
2160<*>. {
2161 yyextra->code->codify(yytext);
2162 }
2163
2164%%
2165
2166/*@ ----------------------------------------------------------------------------
2167 */
2168
2169static bool startsWithKeyword(const QCString &str,const QCString &kw)
2170{
2171 if (str.length()<kw.length()) return false; // string too short to match
2172 return str==kw || // exact match
2173 (str.startsWith(kw) && !isId(str.at(kw.length()))); // match that is not a substring
2174}
2175
2176static void addVariable(yyscan_t yyscanner,QCString type,QCString name)
2177{
2178 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
2179 DBG_CTX((stderr,"VariableContext::addVariable(%s,%s)\n",qPrint(type),qPrint(name)));
2180 QCString ltype = type.simplifyWhiteSpace();
2181 QCString lname = name.simplifyWhiteSpace();
2182 ltype.stripPrefix("struct ");
2183 ltype.stripPrefix("union ");
2184 if (ltype.isEmpty() || lname.isEmpty()) return;
2185 ltype = substitute(ltype,".","::");
2186 DBG_CTX((stderr,"** addVariable trying: type='%s' name='%s' currentDefinition=%s\n",
2187 qPrint(ltype),qPrint(lname),yyextra->currentDefinition?qPrint(yyextra->currentDefinition->name()):"<none>"));
2188 auto it = yyextra->codeClassMap.find(ltype.str());
2189 if (it!=yyextra->codeClassMap.end()) // look for class definitions inside the code block
2190 {
2191 DBG_CTX((stderr,"** addVariable type='%s' name='%s'\n",qPrint(ltype),qPrint(lname)));
2192 yyextra->theVarContext.addVariable(lname,std::move(it->second)); // add it to a list
2193 }
2194 else
2195 {
2196 auto findVariableType = [&yyscanner,&yyg,&ltype,&lname,&name](const Definition *d) -> const ClassDef *
2197 {
2198 const ClassDef *varDef = yyextra->symbolResolver.resolveClass(d,ltype,true);
2199 int i=0;
2200 if (varDef)
2201 {
2202 DBG_CTX((stderr,"** addVariable type='%s' name='%s'\n",qPrint(ltype),qPrint(lname)));
2203 yyextra->theVarContext.addVariable(lname,ScopedTypeVariant(varDef)); // add it to a list
2204 }
2205 else if ((i=ltype.find('<'))!=-1)
2206 {
2207 // probably a template class
2208 addVariable(yyscanner,ltype.left(i),name);
2209 }
2210 return varDef;
2211 };
2212 const ClassDef *varDef = findVariableType(yyextra->currentDefinition);
2213 if (varDef==nullptr) // also check via using directive
2214 {
2215 for (const auto &[usingName,namespaceDef] : yyextra->theUsingContext)
2216 {
2217 varDef = findVariableType(namespaceDef);
2218 if (varDef) break;
2219 }
2220 }
2221 if (varDef==nullptr)
2222 {
2223 if (!yyextra->theVarContext.atGlobalScope()) // for local variables add a dummy entry so the name
2224 // is hidden to avoid false links to global variables with the same name
2225 // TODO: make this work for namespaces as well!
2226 {
2227 DBG_CTX((stderr,"** addVariable: dummy context for '%s'\n",qPrint(lname)));
2228 yyextra->theVarContext.addVariable(lname,ScopedTypeVariant());
2229 }
2230 else
2231 {
2232 DBG_CTX((stderr,"** addVariable: not adding variable!\n"));
2233 }
2234 }
2235 }
2236}
2237
2238//-------------------------------------------------------------------
2239
2240/*! add class/namespace name s to the scope */
2241static void pushScope(yyscan_t yyscanner,const QCString &s)
2242{
2243 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
2244 yyextra->scopeNameLengthStack.push_back(int(yyextra->scopeName.length()));
2245 if (yyextra->scopeName.isEmpty() || leftScopeMatch(s,yyextra->scopeName))
2246 {
2247 yyextra->scopeName = s;
2248 }
2249 else
2250 {
2251 yyextra->scopeName += "::";
2252 yyextra->scopeName += s;
2253 }
2254 DBG_CTX((stderr,"pushScope(%s) result: '%s'\n",qPrint(s),qPrint(yyextra->scopeName)));
2255}
2256
2257
2258/*! remove the top class/namespace name from the scope */
2259static void popScope(yyscan_t yyscanner)
2260{
2261 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
2262 if (!yyextra->scopeNameLengthStack.empty())
2263 {
2264 int length = yyextra->scopeNameLengthStack.back();
2265 yyextra->scopeNameLengthStack.pop_back();
2266 yyextra->scopeName.resize(length);
2267 }
2268 else
2269 {
2270 //err("Too many end of scopes found!\n");
2271 }
2272 DBG_CTX((stderr,"popScope() result: '%s'\n",qPrint(yyextra->scopeName)));
2273}
2274
2275static void setCurrentDoc(yyscan_t yyscanner,const QCString &anchor)
2276{
2277 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
2278 if (Doxygen::searchIndex.enabled())
2279 {
2280 if (yyextra->searchCtx)
2281 {
2282 Doxygen::searchIndex.setCurrentDoc(yyextra->searchCtx,yyextra->searchCtx->anchor(),FALSE);
2283 }
2284 else
2285 {
2286 Doxygen::searchIndex.setCurrentDoc(yyextra->sourceFileDef,anchor,TRUE);
2287 }
2288 }
2289}
2290
2291static void addToSearchIndex(yyscan_t /*yyscanner*/,const QCString &text)
2292{
2294 {
2295 Doxygen::searchIndex.addWord(text,FALSE);
2296 }
2297}
2298
2299static void setClassScope(yyscan_t yyscanner,const QCString &name)
2300{
2301 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
2302 DBG_CTX((stderr,"setClassScope(%s)\n",qPrint(name)));
2303 QCString n=name;
2304 n=n.simplifyWhiteSpace();
2305 int ts=n.find('<'); // start of template
2306 int te=n.findRev('>'); // end of template
2307 DBG_CTX((stderr,"ts=%d te=%d\n",ts,te));
2308 if (ts!=-1 && te!=-1 && te>ts)
2309 {
2310 // remove template from scope
2311 n=n.left(ts)+n.right(n.length()-te-1);
2312 }
2313 while (!yyextra->scopeNameLengthStack.empty())
2314 {
2315 popScope(yyscanner);
2316 }
2317 yyextra->scopeName.clear();
2318 int i;
2319 while ((i=n.find("::"))!=-1)
2320 {
2321 pushScope(yyscanner,n.left(i));
2322 n = n.mid(i+2);
2323 }
2324 pushScope(yyscanner,n);
2325 DBG_CTX((stderr,"--->New class scope '%s'\n",qPrint(yyextra->scopeName)));
2326}
2327
2328static void endCodeFold(yyscan_t yyscanner)
2329{
2330 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
2331 while (!yyextra->foldStack.empty())
2332 {
2333 const Definition *dd = yyextra->foldStack.back();
2334 if (dd->getEndBodyLine()+1==yyextra->yyLineNr) // +1 to close the section after the end of the body
2335 {
2336 yyextra->code->endFold();
2337 //fprintf(stderr,"%d: end codeFolding for %s [%d..%d]\n",yyextra->yyLineNr,qPrint(dd->name()),dd->getStartDefLine(),dd->getEndBodyLine());
2338 yyextra->foldStack.pop_back();
2339 }
2340 else
2341 {
2342 //fprintf(stderr,"no end of block dd=%s end=%d\n",qPrint(dd->qualifiedName()),dd->getEndBodyLine());
2343 break;
2344 }
2345 }
2346}
2347
2348
2349static void codeFolding(yyscan_t yyscanner,const Definition *d)
2350{
2351 if (Config_getBool(HTML_CODE_FOLDING))
2352 {
2353 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
2354 //fprintf(stderr,"codeFolding at %d\n",yyextra->yyLineNr);
2355 //if (d)
2356 // fprintf(stderr,"%d: codeFolding: candidate=%s [%d..%d]\n",yyextra->yyLineNr,qPrint(d->qualifiedName()),d->getStartDefLine(),d->getEndBodyLine());
2357 endCodeFold(yyscanner);
2358 if (d)
2359 {
2360 int startLine = d->getStartDefLine();
2361 int endLine = d->getEndBodyLine();
2362 if (endLine!=-1 && startLine!=endLine &&
2363 // since the end of a section is closed after the last line, we need to avoid starting a
2364 // new section if the previous section ends at the same line, i.e. something like
2365 // struct X {
2366 // ...
2367 // }; struct S { <- start of S and end of X at the same line
2368 // ...
2369 // };
2370 (yyextra->foldStack.empty() || yyextra->foldStack.back()->getEndBodyLine()!=startLine))
2371 {
2372 //printf("%d: start codeFolding for %s [%d..%d]\n",yyextra->yyLineNr,qPrint(d->name()),d->getStartDefLine(),d->getEndBodyLine());
2374 {
2375 const MemberDef *md = toMemberDef(d);
2376 if (md && md->isDefine())
2377 {
2378 yyextra->code->startFold(yyextra->yyLineNr,"",""); // #define X ...
2379 }
2380 else if (md && md->isCallable())
2381 {
2382 yyextra->code->startFold(yyextra->yyLineNr,"{","}"); // func() { ... }
2383 }
2384 else
2385 {
2386 yyextra->code->startFold(yyextra->yyLineNr,"{","};"); // enum X { ... }
2387 }
2388 }
2390 {
2391 yyextra->code->startFold(yyextra->yyLineNr,"{","};"); // class X { ... };
2392 }
2393 else
2394 {
2395 yyextra->code->startFold(yyextra->yyLineNr,"{","}"); // namespace X {...}
2396 }
2397 yyextra->foldStack.push_back(d);
2398 }
2399 }
2400 }
2401}
2402
2403/*! start a new line of code, inserting a line number if yyextra->sourceFileDef
2404 * is TRUE. If a definition starts at the current line, then the line
2405 * number is linked to the documentation of that definition.
2406 */
2407static void startCodeLine(yyscan_t yyscanner)
2408{
2409 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
2410 //if (yyextra->currentFontClass) { yyextra->code->endFontClass(yyscanner); }
2411 if (yyextra->sourceFileDef && yyextra->lineNumbers)
2412 {
2413 //QCString lineNumber,lineAnchor;
2414 //lineNumber.sprintf("%05d",yyextra->yyLineNr);
2415 //lineAnchor.sprintf("l%05d",yyextra->yyLineNr);
2416
2417 const Definition *d = yyextra->sourceFileDef->getSourceDefinition(yyextra->yyLineNr);
2418 //printf("%s:startCodeLine(%d)=%p\n",qPrint(yyextra->sourceFileDef->name()),yyextra->yyLineNr,(void*)d);
2419 DBG_CTX((stderr,"%s:startCodeLine(%d)=%p\n",qPrint(yyextra->sourceFileDef->name()),yyextra->yyLineNr,(void*)d));
2420 if (!yyextra->includeCodeFragment && d)
2421 {
2422 yyextra->currentDefinition = d;
2423 yyextra->currentMemberDef = yyextra->sourceFileDef->getSourceMember(yyextra->yyLineNr);
2424 yyextra->insideBody = FALSE;
2425 yyextra->searchingForBody = TRUE;
2426 yyextra->realScope = d!=Doxygen::globalScope ? d->name() : "";
2427 yyextra->type.clear();
2428 yyextra->name.clear();
2429 yyextra->args.clear();
2430 yyextra->parmType.clear();
2431 yyextra->parmName.clear();
2432 DBG_CTX((stderr,"Real scope: '%s'\n",qPrint(yyextra->realScope)));
2433 yyextra->bodyCurlyCount = 0;
2434 QCString lineAnchor;
2435 lineAnchor.sprintf("l%05d",yyextra->yyLineNr);
2436 if (yyextra->currentMemberDef)
2437 {
2438 codeFolding(yyscanner,yyextra->currentMemberDef);
2439 yyextra->code->writeLineNumber(yyextra->currentMemberDef->getReference(),
2440 yyextra->currentMemberDef->getOutputFileBase(),
2441 yyextra->currentMemberDef->anchor(),
2442 yyextra->yyLineNr,!yyextra->includeCodeFragment);
2443 setCurrentDoc(yyscanner,lineAnchor);
2444 }
2445 else if (d->isLinkableInProject())
2446 {
2447 codeFolding(yyscanner,d);
2448 yyextra->code->writeLineNumber(d->getReference(),
2449 d->getOutputFileBase(),
2450 QCString(),yyextra->yyLineNr,!yyextra->includeCodeFragment);
2451 setCurrentDoc(yyscanner,lineAnchor);
2452 }
2453 else
2454 {
2455 codeFolding(yyscanner,nullptr);
2456 }
2457 }
2458 else
2459 {
2460 codeFolding(yyscanner,nullptr);
2461 yyextra->code->writeLineNumber(QCString(),QCString(),QCString(),yyextra->yyLineNr,
2462 !yyextra->includeCodeFragment);
2463 }
2464 }
2465 DBG_CTX((stderr,"startCodeLine(%d)\n",yyextra->yyLineNr));
2466 yyextra->code->startCodeLine(yyextra->yyLineNr);
2467 yyextra->insideCodeLine = true;
2468 if (yyextra->currentFontClass)
2469 {
2470 yyextra->code->startFontClass(yyextra->currentFontClass);
2471 }
2472}
2473
2474
2475
2476static void endCodeLine(yyscan_t yyscanner)
2477{
2478 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
2479 DBG_CTX((stderr,"endCodeLine(%d)\n",yyextra->yyLineNr));
2480 endFontClass(yyscanner);
2481 yyextra->code->endCodeLine();
2482 yyextra->insideCodeLine = false;
2483}
2484
2485static void nextCodeLine(yyscan_t yyscanner)
2486{
2487 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
2488 const char * fc = yyextra->currentFontClass;
2489 if (yyextra->insideCodeLine)
2490 {
2491 endCodeLine(yyscanner);
2492 }
2493 if (yyextra->yyLineNr<yyextra->inputLines)
2494 {
2495 yyextra->currentFontClass = fc;
2496 startCodeLine(yyscanner);
2497 }
2498}
2499
2500/*! write a code fragment 'text' that may span multiple lines, inserting
2501 * line numbers for each line.
2502 */
2503static void codifyLines(yyscan_t yyscanner,const QCString &text)
2504{
2505 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
2506 DBG_CTX((stderr,"codifyLines(%d,\"%s\")\n",yyextra->yyLineNr,qPrint(text)));
2507 if (text.isEmpty()) return;
2508 const char *p=text.data(),*sp=p;
2509 char c;
2510 bool done=FALSE;
2511 while (!done)
2512 {
2513 sp=p;
2514 while ((c=*p++) && c!='\n');
2515 if (c=='\n')
2516 {
2517 yyextra->yyLineNr++;
2518 size_t l = static_cast<size_t>(p-sp-1);
2519 yyextra->code->codify(QCString(sp,l));
2520 nextCodeLine(yyscanner);
2521 }
2522 else
2523 {
2524 yyextra->code->codify(sp);
2525 done=TRUE;
2526 }
2527 }
2528}
2529
2530static void incrementFlowKeyWordCount(yyscan_t yyscanner)
2531{
2532 std::lock_guard<std::mutex> lock(Doxygen::countFlowKeywordsMutex);
2533 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
2534 if (yyextra->currentMemberDef && yyextra->currentMemberDef->isFunction())
2535 {
2536 MemberDefMutable *md = toMemberDefMutable(const_cast<MemberDef*>(yyextra->currentMemberDef));
2537 if (md)
2538 {
2540 }
2541 }
2542}
2543
2544/*! writes a link to a fragment \a text that may span multiple lines, inserting
2545 * line numbers for each line. If \a text contains newlines, the link will be
2546 * split into multiple links with the same destination, one for each line.
2547 */
2548static void writeMultiLineCodeLink(yyscan_t yyscanner,OutputCodeList &ol,
2549 const Definition *d,
2550 const QCString &text)
2551{
2552 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
2553 bool sourceTooltips = Config_getBool(SOURCE_TOOLTIPS);
2554 yyextra->tooltipManager.addTooltip(d);
2555 QCString ref = d->getReference();
2556 QCString file = d->getOutputFileBase();
2557 QCString anchor = d->anchor();
2558 QCString tooltip;
2559 if (!sourceTooltips) // fall back to simple "title" tooltips
2560 {
2561 tooltip = d->briefDescriptionAsTooltip();
2562 }
2563 bool done=FALSE;
2564 const char *p=text.data();
2565 while (!done)
2566 {
2567 const char *sp=p;
2568 char c = 0;
2569 while ((c=*p++) && c!='\n') { }
2570 if (c=='\n')
2571 {
2572 yyextra->yyLineNr++;
2573 DBG_CTX((stderr,"writeCodeLink(%s,%s,%s,%s)\n",qPrint(ref),qPrint(file),qPrint(anchor),qPrint(QCString(sp,p-sp-1))));
2574 ol.writeCodeLink(d->codeSymbolType(),ref,file,anchor,QCString(sp,p-sp-1),tooltip);
2575 nextCodeLine(yyscanner);
2576 }
2577 else
2578 {
2579 DBG_CTX((stderr,"writeCodeLink(%s,%s,%s,%s)\n",qPrint(ref),qPrint(file),qPrint(anchor),sp));
2580 ol.writeCodeLink(d->codeSymbolType(),ref,file,anchor,sp,tooltip);
2581 done=TRUE;
2582 }
2583 }
2584}
2585
2586static void addType(yyscan_t yyscanner)
2587{
2588 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
2589 if (yyextra->name=="const") { yyextra->name.clear(); return; }
2590 if (!yyextra->type.isEmpty()) yyextra->type += ' ' ;
2591 yyextra->type += yyextra->name ;
2592 yyextra->name.clear() ;
2593 if (!yyextra->type.isEmpty()) yyextra->type += ' ' ;
2594 yyextra->type += yyextra->args ;
2595 yyextra->args.clear() ;
2596}
2597
2598static void addParmType(yyscan_t yyscanner)
2599{
2600 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
2601 if (yyextra->parmName=="const") { yyextra->parmName.clear(); return; }
2602 if (!yyextra->parmType.isEmpty()) yyextra->parmType += ' ' ;
2603 yyextra->parmType += yyextra->parmName ;
2604 yyextra->parmName.clear() ;
2605}
2606
2607static void addUsingDirective(yyscan_t yyscanner,const QCString &name)
2608{
2609 //printf("AddUsingDirective(%s)\n",qPrint(name));
2610 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
2611 if (yyextra->sourceFileDef && !name.isEmpty())
2612 {
2613 const NamespaceDef *nd = Doxygen::namespaceLinkedMap->find(name);
2614 if (nd)
2615 {
2616 yyextra->theUsingContext.emplace(name.str(),nd);
2617 }
2618 }
2619}
2620
2621static void setParameterList(yyscan_t yyscanner,const MemberDef *md)
2622{
2623 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
2624 for (const Argument &a : md->argumentList())
2625 {
2626 yyextra->parmName = a.name;
2627 yyextra->parmType = a.type;
2628 int i = yyextra->parmType.find('*');
2629 if (i!=-1) yyextra->parmType = yyextra->parmType.left(i);
2630 i = yyextra->parmType.find('&');
2631 if (i!=-1) yyextra->parmType = yyextra->parmType.left(i);
2632 yyextra->parmType.stripPrefix("const ");
2633 yyextra->parmType=yyextra->parmType.stripWhiteSpace();
2634 addVariable(yyscanner,yyextra->parmType,yyextra->parmName);
2635 }
2636}
2637
2638static const ClassDef *stripClassName(yyscan_t yyscanner,const QCString &s,const Definition *d)
2639{
2640 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
2641 DBG_CTX((stderr,"stripClassName(scope=%s,type=%s) scopeName=%s\n",
2642 qPrint(d?d->name():""),qPrint(s),qPrint(yyextra->scopeName)));
2643 int pos=0;
2644 QCString type = s;
2645 QCString className;
2646 QCString templSpec;
2647 while (extractClassNameFromType(type,pos,className,templSpec)!=-1)
2648 {
2649 QCString clName=className+templSpec;
2650 const ClassDef *cd=nullptr;
2651 if (!yyextra->scopeName.isEmpty())
2652 {
2653 cd=yyextra->symbolResolver.resolveClass(d,yyextra->scopeName+"::"+clName,true);
2654 }
2655 if (cd==nullptr)
2656 {
2657 cd=yyextra->symbolResolver.resolveClass(d,clName,true);
2658 }
2659 DBG_CTX((stderr,"stripClass trying '%s' = %p\n",qPrint(clName),(void*)cd));
2660 if (cd)
2661 {
2662 return cd;
2663 }
2664 }
2665
2666 return nullptr;
2667}
2668
2669static const MemberDef *setCallContextForVar(yyscan_t yyscanner,const QCString &name)
2670{
2671 if (name.isEmpty()) return nullptr;
2672 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
2673 DBG_CTX((stderr,"setCallContextForVar(%s) yyextra->scopeName=%s\n",qPrint(name),qPrint(yyextra->scopeName)));
2674
2675 int scopeEnd = name.findRev("::");
2676 if (scopeEnd!=-1) // name with explicit scope
2677 {
2678 QCString scope = name.left(scopeEnd);
2679 QCString locName = name.right(name.length()-scopeEnd-2);
2680 DBG_CTX((stderr,"explicit scope: name=%s scope=%s\n",qPrint(locName),qPrint(scope)));
2681 const ClassDef *mcd = getClass(scope);
2682 if (mcd && !locName.isEmpty())
2683 {
2684 const MemberDef *md=mcd->getMemberByName(locName);
2685 if (md)
2686 {
2687 DBG_CTX((stderr,"name=%s scope=%s\n",qPrint(locName),qPrint(scope)));
2688 yyextra->theCallContext.setScope(ScopedTypeVariant(stripClassName(yyscanner,md->typeString(),md->getOuterScope())));
2689 return md;
2690 }
2691 }
2692 else // check namespace as well
2693 {
2694 const NamespaceDef *mnd = getResolvedNamespace(scope);
2695 if (mnd && !locName.isEmpty())
2696 {
2697 const MemberDef *md=mnd->getMemberByName(locName);
2698 if (md)
2699 {
2700 DBG_CTX((stderr,"name=%s scope=%s\n",qPrint(locName),qPrint(scope)));
2701 yyextra->theCallContext.setScope(ScopedTypeVariant(stripClassName(yyscanner,md->typeString(),md->getOuterScope())));
2702 return md;
2703 }
2704 }
2705 }
2706 }
2707
2708 const ScopedTypeVariant *mcv = yyextra->theVarContext.findVariable(name);
2709 if (mcv)
2710 {
2711 DBG_CTX((stderr,"local variable?\n"));
2712 if (!mcv->isDummy()) // locally found variable
2713 {
2714 DBG_CTX((stderr,"local var '%s' mcd=%s\n",qPrint(name),qPrint(mcv->name())));
2715 yyextra->theCallContext.setScope(*mcv);
2716 }
2717 }
2718 else
2719 {
2720 DBG_CTX((stderr,"class member? scope=%s\n",qPrint(yyextra->scopeName)));
2721 // look for a class member
2722 const ClassDef *mcd = getClass(yyextra->scopeName);
2723 if (mcd)
2724 {
2725 DBG_CTX((stderr,"Inside class %s\n",qPrint(mcd->name())));
2726 const MemberDef *md=mcd->getMemberByName(name);
2727 if (md)
2728 {
2729 DBG_CTX((stderr,"Found member %s\n",qPrint(md->name())));
2730 if (yyextra->scopeStack.empty() || yyextra->scopeStack.top()!=CLASSBLOCK)
2731 {
2732 DBG_CTX((stderr,"class member '%s' mcd=%s\n",qPrint(name),qPrint(mcd->name())));
2733 yyextra->theCallContext.setScope(ScopedTypeVariant(stripClassName(yyscanner,md->typeString(),md->getOuterScope())));
2734 }
2735 return md;
2736 }
2737 }
2738 }
2739
2740 // look for a global member
2741 const MemberName *mn = Doxygen::functionNameLinkedMap->find(name);
2742 if (mn)
2743 {
2744 DBG_CTX((stderr,"global var '%s'\n",qPrint(name)));
2745 if (mn->size()==1) // global defined only once
2746 {
2747 const std::unique_ptr<MemberDef> &md=mn->front();
2748 if (!md->isStatic() || md->getBodyDef()==yyextra->sourceFileDef)
2749 {
2750 yyextra->theCallContext.setScope(ScopedTypeVariant(stripClassName(yyscanner,md->typeString(),md->getOuterScope())));
2751 return md.get();
2752 }
2753 return nullptr;
2754 }
2755 else if (mn->size()>1) // global defined more than once
2756 {
2757 for (const auto &md : *mn)
2758 {
2759 //printf("mn=%p md=%p md->getBodyDef()=%p yyextra->sourceFileDef=%p\n",
2760 // mn,md,
2761 // md->getBodyDef(),yyextra->sourceFileDef);
2762
2763 // in case there are multiple members we could link to, we
2764 // only link to members if defined in the same file or
2765 // defined as external.
2766 if (!md->isStatic() || md->getBodyDef()==yyextra->sourceFileDef)
2767 {
2768 yyextra->theCallContext.setScope(ScopedTypeVariant(stripClassName(yyscanner,md->typeString(),md->getOuterScope())));
2769 DBG_CTX((stderr,"returning member %s in source file %s\n",qPrint(md->name()),qPrint(yyextra->sourceFileDef->name())));
2770 return md.get();
2771 }
2772 }
2773 return nullptr;
2774 }
2775 }
2776 return nullptr;
2777}
2778
2779static void updateCallContextForSmartPointer(yyscan_t yyscanner)
2780{
2781 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
2782 const Definition *d = yyextra->theCallContext.getScope().globalDef();
2783 //printf("updateCallContextForSmartPointer() cd=%s\n",cd ? qPrint(d->name()) : "<none>");
2784 const MemberDef *md = nullptr;
2785 if (d && d->definitionType()==Definition::TypeClass && (md=(toClassDef(d))->isSmartPointer()))
2786 {
2787 const ClassDef *ncd = stripClassName(yyscanner,md->typeString(),md->getOuterScope());
2788 if (ncd)
2789 {
2790 yyextra->theCallContext.setScope(ScopedTypeVariant(ncd));
2791 //printf("Found smart pointer call %s->%s!\n",qPrint(cd->name()),qPrint(ncd->name()));
2792 }
2793 }
2794}
2795
2796static bool getLinkInScope(yyscan_t yyscanner,
2797 const QCString &c, // scope
2798 const QCString &m, // member
2799 const QCString &memberText, // exact text
2800 OutputCodeList &ol,
2801 const QCString &text,
2802 bool varOnly
2803 )
2804{
2805 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
2806 DBG_CTX((stderr,"getLinkInScope: trying '%s'::'%s' varOnly=%d\n",qPrint(c),qPrint(m),varOnly));
2807 GetDefInput input(c,m,"()");
2808 input.currentFile = yyextra->sourceFileDef;
2809 input.insideCode = true;
2810 GetDefResult result = getDefs(input);
2811 DBG_CTX((stderr,"scopeNameLengthStack.size()=%zu\n",yyextra->scopeNameLengthStack.size()));
2812 if (!result.found && !yyextra->scopeNameLengthStack.empty() && c==yyextra->scopeName)
2813 {
2814 QCString localName = yyextra->scopeName.mid(yyextra->scopeNameLengthStack[0]+2); // try also without leading scope
2815 auto it = yyextra->codeClassMap.find(localName.str());
2816 if (it!=yyextra->codeClassMap.end())
2817 {
2818 ScopedTypeVariant ccd = it->second;
2819 if (ccd.localDef() && !ccd.localDef()->baseClasses().empty())
2820 {
2821 for (const auto &bcName : ccd.localDef()->baseClasses())
2822 {
2823 DBG_CTX((stderr,"trying lookup via base class %s\n",qPrint(bcName)));
2824 input.scopeName = bcName;
2825 result = getDefs(input);
2826 if (result.found) break;
2827 }
2828 }
2829 }
2830 }
2831 if (result.found && result.md && (!varOnly || result.md->isVariable()))
2832 {
2833 if (result.md->isLinkable())
2834 {
2835 DBG_CTX((stderr,"found it %s!\n",qPrint(result.md->qualifiedName())));
2836 if (yyextra->exampleBlock)
2837 {
2838 std::lock_guard<std::mutex> lock(Doxygen::addExampleMutex);
2839 QCString anchor;
2840 anchor.sprintf("a%d",yyextra->anchorCount);
2841 DBG_CTX((stderr,"addExampleFile(%s,%s,%s)\n",qPrint(anchor),qPrint(yyextra->exampleName),
2842 qPrint(yyextra->exampleFile)));
2843 MemberDefMutable *mdm = toMemberDefMutable(const_cast<MemberDef*>(result.md));
2844 if (mdm && mdm->addExample(anchor,yyextra->exampleName,yyextra->exampleFile))
2845 {
2846 ol.writeCodeAnchor(anchor);
2847 yyextra->anchorCount++;
2848 }
2849 }
2850
2851 const Definition *d = result.md->getOuterScope()==Doxygen::globalScope ?
2852 result.md->resolveAlias()->getFileDef() : result.md->getOuterScope();
2853 if (result.md->resolveAlias()->getGroupDef()) d = result.md->resolveAlias()->getGroupDef();
2854 if (d && d->isLinkable())
2855 {
2856 const ClassDef *ncd = stripClassName(yyscanner,result.md->typeString(),result.md->getOuterScope());
2857 if (ncd)
2858 {
2859 yyextra->theCallContext.setScope(ScopedTypeVariant(ncd));
2860 }
2861 DBG_CTX((stderr,"yyextra->currentDefinition=%p yyextra->currentMemberDef=%p yyextra->insideBody=%d\n",
2862 (void*)yyextra->currentDefinition,(void*)yyextra->currentMemberDef,yyextra->insideBody));
2863
2864 if (yyextra->currentDefinition && yyextra->currentMemberDef &&
2865 yyextra->insideBody && yyextra->collectXRefs)
2866 {
2867 addDocCrossReference(yyextra->currentMemberDef,result.md);
2868 }
2869 DBG_CTX((stderr,"d->getReference()='%s' d->getOutputBase()='%s' name='%s' member name='%s'\n",qPrint(d->getReference()),qPrint(d->getOutputFileBase()),qPrint(d->name()),qPrint(result.md->name())));
2870
2871 writeMultiLineCodeLink(yyscanner,ol,result.md, !text.isEmpty() ? text : memberText);
2872 addToSearchIndex(yyscanner,!text.isEmpty() ? text : memberText);
2873 return TRUE;
2874 }
2875 }
2876 }
2877 return FALSE;
2878}
2879
2880static bool getLink(yyscan_t yyscanner,
2881 const QCString &className,
2882 const QCString &memberName,
2883 OutputCodeList &ol,
2884 const QCString &text,
2885 bool varOnly)
2886{
2887 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
2888 DBG_CTX((stderr,"getLink(%s,%s) yyextra->curClassName=%s\n",
2889 qPrint(className),qPrint(memberName),qPrint(yyextra->curClassName)));
2890 QCString m=removeRedundantWhiteSpace(memberName);
2891 QCString c=className;
2892 if (!getLinkInScope(yyscanner,c,m,memberName,ol,text,varOnly))
2893 {
2894 if (!yyextra->curClassName.isEmpty())
2895 {
2896 if (!c.isEmpty()) c.prepend("::");
2897 c.prepend(yyextra->curClassName);
2898 return getLinkInScope(yyscanner,c,m,memberName,ol,text,varOnly);
2899 }
2900 return FALSE;
2901 }
2902 return TRUE;
2903}
2904
2905static void generateClassOrGlobalLink(yyscan_t yyscanner,
2906 OutputCodeList &ol,
2907 const QCString &scName,
2908 bool typeOnly,
2909 bool varOnly)
2910{
2911 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
2912 QCString scopeName=scName;
2913 if (!scopeName.isEmpty() && scopeName[0]=='~') // correct for matching negated values i.s.o. destructors.
2914 {
2915 scopeName=scopeName.mid(1);
2916 }
2917 if (scopeName.isEmpty())
2918 {
2919 yyextra->code->codify("~");
2920 return;
2921 }
2922 if (yyextra->insideProtocolList) // for Obj-C
2923 {
2924 scopeName+="-p";
2925 }
2926 if (yyextra->lang==SrcLangExt::PHP)
2927 {
2928 scopeName = substitute(scopeName,"\\","::"); // for PHP namespaces
2929 }
2930 else if (yyextra->lang==SrcLangExt::CSharp || yyextra->lang==SrcLangExt::Java)
2931 {
2932 scopeName = substitute(scopeName,".","::"); // for C#/Java namespaces
2933 }
2934 if (yyextra->currentDefinition==nullptr && !yyextra->scopeName.isEmpty())
2935 {
2936 scopeName = yyextra->scopeName+"::"+scopeName;
2937 }
2938 const ScopedTypeVariant *lcd=nullptr;
2939 const Definition *sym=nullptr;
2940 bool isLocal=FALSE;
2941
2942 DBG_CTX((stderr,"generateClassOrGlobalLink(name=%s) yyextra->scopeName=%s scopeName=%s\n",qPrint(scName),qPrint(yyextra->scopeName),qPrint(scopeName)));
2943 if (!yyextra->isPrefixedWithThis || (lcd=yyextra->theVarContext.findVariable(scopeName))==nullptr) // not a local variable
2944 {
2945 int i=scopeName.find('<');
2946 QCString bareName = scopeName;
2947 if (i!=-1) bareName = bareName.left(i);
2948
2949 auto checkForSymbol = [&yyg,&bareName,&scopeName](const Definition *parent,
2950 const Definition *&sym_)
2951 {
2952 sym_ = yyextra->symbolResolver.resolveSymbol(parent,scopeName,QCString(),false,true);
2953 DBG_CTX((stderr,"non-local variable name=%s sym=%s!\n",
2954 qPrint(scopeName),sym_?qPrint(sym_->name()):"<none>"));
2955 if (sym_==nullptr && !bareName.isEmpty())
2956 {
2957 DBG_CTX((stderr,"bareName=%s\n",qPrint(bareName)));
2958 if (bareName!=scopeName)
2959 {
2960 sym_ = yyextra->symbolResolver.resolveSymbol(parent,bareName,QCString(),false,true); // try unspecialized version
2961 }
2962 }
2963 };
2964 const Definition *d = yyextra->currentDefinition;
2965 DBG_CTX((stderr,"d=%s yyextra->sourceFileDef=%s\n",d?qPrint(d->name()):"<none>",yyextra->sourceFileDef?qPrint(yyextra->sourceFileDef->name()):"<none>"));
2966 checkForSymbol(d,sym);
2967 if (sym==nullptr && d && d->definitionType()==Definition::TypeClass)
2968 {
2969 const FileDef *fd = toClassDef(d)->getFileDef();
2970 if (fd)
2971 {
2972 // also check for using directive in the file that defines this class
2973 for (const auto &nd : fd->getUsedNamespaces())
2974 {
2975 checkForSymbol(nd,sym);
2976 if (sym) break;
2977 }
2978 }
2979 }
2980 if (sym==nullptr)
2981 {
2982 // also check via using directive
2983 for (const auto &[usingName,namespaceDef] : yyextra->theUsingContext)
2984 {
2985 checkForSymbol(namespaceDef,sym);
2986 if (sym) break;
2987 }
2988 }
2989
2990 const NamespaceDef *nd = getResolvedNamespace(scopeName);
2991 if (nd && nd->isLinkable())
2992 {
2993 yyextra->theCallContext.setScope(ScopedTypeVariant(nd));
2994 addToSearchIndex(yyscanner,scopeName);
2995 writeMultiLineCodeLink(yyscanner,*yyextra->code,nd,scName);
2996 return;
2997 }
2998 const ConceptDef *conceptDef = getResolvedConcept(d,bareName);
2999 if (conceptDef && conceptDef->isLinkable())
3000 {
3001 yyextra->theCallContext.setScope(ScopedTypeVariant(conceptDef));
3002 addToSearchIndex(yyscanner,scopeName);
3003 writeMultiLineCodeLink(yyscanner,*yyextra->code,conceptDef,scName);
3004 return;
3005 }
3006 DBG_CTX((stderr,"sym=%s\n",sym?qPrint(sym->name()):"<none>"));
3007 DBG_CTX((stderr,"is found as a type sym=%s nd=%s\n",
3008 sym?qPrint(sym->name()):"<null>",
3009 nd?qPrint(nd->name()):"<null>"));
3010 if (sym==nullptr) // also see if it is variable or enum or enum value
3011 {
3012 if (getLink(yyscanner,yyextra->scopeName,scName,ol,scName,varOnly))
3013 {
3014 return;
3015 }
3016 }
3017 }
3018 else
3019 {
3020 DBG_CTX((stderr,"local variable!\n"));
3021 if (!lcd->isDummy())
3022 {
3023 DBG_CTX((stderr,"non-dummy context lcd=%s!\n",qPrint(lcd->name())));
3024 yyextra->theCallContext.setScope(*lcd);
3025
3026 // to following is needed for links to a global variable, but is
3027 // no good for a link to a local variable that is also a global symbol.
3028
3029 //if (getLink(yyscanner,yyextra->scopeName,scName,ol,scName))
3030 //{
3031 //return;
3032 //}
3033 }
3034 isLocal=TRUE;
3035 DBG_CTX((stderr,"is a local variable sym=%p!\n",(void*)sym));
3036 }
3037 yyextra->isPrefixedWithThis = FALSE; // discard the "this" prefix for the next calls
3038
3039 if (sym && sym->isLinkable()) // is it a linkable class
3040 {
3041 DBG_CTX((stderr,"is linkable class %s\n",qPrint(scName)));
3042 if (yyextra->exampleBlock)
3043 {
3044 std::lock_guard<std::mutex> lock(Doxygen::addExampleMutex);
3045 QCString anchor;
3046 anchor.sprintf("_a%d",yyextra->anchorCount);
3047 DBG_CTX((stderr,"addExampleClass(%s,%s,%s)\n",qPrint(anchor),qPrint(yyextra->exampleName),
3048 qPrint(yyextra->exampleFile)));
3050 {
3051 ClassDefMutable *cdm = toClassDefMutable(const_cast<Definition*>(sym));
3052 if (cdm && cdm->addExample(anchor,yyextra->exampleName,yyextra->exampleFile))
3053 {
3054 ol.writeCodeAnchor(anchor);
3055 yyextra->anchorCount++;
3056 }
3057 }
3058 else if (sym->definitionType()==Definition::TypeMember)
3059 {
3060 MemberDefMutable *mdm = toMemberDefMutable(const_cast<Definition*>(sym));
3061 if (mdm && mdm->addExample(anchor,yyextra->exampleName,yyextra->exampleFile))
3062 {
3063 ol.writeCodeAnchor(anchor);
3064 yyextra->anchorCount++;
3065 }
3066 }
3067 }
3068 writeMultiLineCodeLink(yyscanner,ol,sym,scName);
3069 addToSearchIndex(yyscanner,scopeName);
3070 yyextra->theCallContext.setScope(ScopedTypeVariant(sym));
3071 if (sym && sym->definitionType()==Definition::TypeMember)
3072 {
3073 const MemberDef *md = toMemberDef(sym);
3074 const Definition *d = sym->getOuterScope()==Doxygen::globalScope ?
3075 md->getFileDef() : md->getOuterScope();
3076 if (md->getGroupDef()) d = md->getGroupDef();
3077 if (d && d->isLinkable() && md->isLinkable() &&
3078 yyextra->currentMemberDef && yyextra->collectXRefs)
3079 {
3080 addDocCrossReference(yyextra->currentMemberDef,md);
3081 }
3082 }
3083 }
3084 else // not a class, maybe a global member
3085 {
3086 const MemberDef *md = sym && sym->definitionType()==Definition::TypeMember ? toMemberDef(sym) : nullptr;
3087 DBG_CTX((stderr,"class %s not linkable! cd=%p typeOnly=%d\n",qPrint(scName),(void*)sym,typeOnly));
3088 if (!isLocal && (md || (!sym && !typeOnly))) // not a class, see if it is a global enum/variable/typedef.
3089 {
3090 if (md==nullptr) // not found as a typedef
3091 {
3092 md = setCallContextForVar(yyscanner,scName);
3093 DBG_CTX((stderr,"setCallContextForVar(%s) md=%p yyextra->currentDefinition=%s\n",qPrint(scName),(void*)md,yyextra->currentDefinition ? qPrint(yyextra->currentDefinition->name()) : "<none>"));
3094 if (md && yyextra->currentDefinition)
3095 {
3096 DBG_CTX((stderr,"%s accessible from %s? %d md->getOuterScope=%s\n",
3097 qPrint(md->name()),qPrint(yyextra->currentDefinition->name()),
3098 yyextra->symbolResolver.isAccessibleFrom(yyextra->currentDefinition,md),
3099 qPrint(md->getOuterScope()->name())));
3100 }
3101
3102 if (md && yyextra->currentDefinition &&
3103 yyextra->symbolResolver.isAccessibleFrom(yyextra->currentDefinition,md)==-1)
3104 {
3105 md=nullptr; // variable not accessible
3106 }
3107 }
3108 if (md && (!varOnly || md->isVariable()))
3109 {
3110 DBG_CTX((stderr,"is a global md=%p yyextra->currentDefinition=%s linkable=%d\n",(void*)md,yyextra->currentDefinition?qPrint(yyextra->currentDefinition->name()):"<none>",md->isLinkable()));
3111 if (md->isLinkable())
3112 {
3113 writeMultiLineCodeLink(yyscanner,ol,md,scName);
3114 addToSearchIndex(yyscanner,scName);
3115 if (yyextra->currentMemberDef && yyextra->collectXRefs)
3116 {
3117 addDocCrossReference(yyextra->currentMemberDef,md);
3118 }
3119 return;
3120 }
3121 }
3122 }
3123
3124 // nothing found, just write out the word
3125 DBG_CTX((stderr,"not found!\n"));
3126 codifyLines(yyscanner,scName);
3127 addToSearchIndex(yyscanner,scName);
3128 }
3129}
3130
3131static bool generateClassMemberLink(yyscan_t yyscanner,
3132 OutputCodeList &ol,
3133 const MemberDef *xmd,
3134 const QCString &memName)
3135{
3136 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3137 // extract class definition of the return type in order to resolve
3138 // a->b()->c() like call chains
3139
3140 DBG_CTX((stderr,"type='%s' args='%s' class=%s\n",
3141 qPrint(xmd->typeString()),qPrint(xmd->argsString()),
3142 qPrint(xmd->getClassDef()->name())));
3143
3144 if (yyextra->exampleBlock)
3145 {
3146 std::lock_guard<std::mutex> lock(Doxygen::addExampleMutex);
3147 QCString anchor;
3148 anchor.sprintf("a%d",yyextra->anchorCount);
3149 DBG_CTX((stderr,"addExampleFile(%s,%s,%s)\n",qPrint(anchor),qPrint(yyextra->exampleName),
3150 qPrint(yyextra->exampleFile)));
3151 MemberDefMutable *mdm = toMemberDefMutable(const_cast<MemberDef*>(xmd));
3152 if (mdm && mdm->addExample(anchor,yyextra->exampleName,yyextra->exampleFile))
3153 {
3154 ol.writeCodeAnchor(anchor);
3155 yyextra->anchorCount++;
3156 }
3157 }
3158
3159 const ClassDef *typeClass = stripClassName(yyscanner,removeAnonymousScopes(xmd->typeString()),xmd->getOuterScope());
3160 DBG_CTX((stderr,"%s -> typeName=%p\n",qPrint(xmd->typeString()),(void*)typeClass));
3161 yyextra->theCallContext.setScope(ScopedTypeVariant(typeClass));
3162
3163 const Definition *xd = xmd->getOuterScope()==Doxygen::globalScope ?
3164 xmd->getFileDef() : xmd->getOuterScope();
3165 if (xmd->getGroupDef()) xd = xmd->getGroupDef();
3166 if (xd && xd->isLinkable())
3167 {
3168
3169 DBG_CTX((stderr,"yyextra->currentDefinition=%p yyextra->currentMemberDef=%p xmd=%p yyextra->insideBody=%d\n",
3170 (void*)yyextra->currentDefinition,(void*)yyextra->currentMemberDef,(void*)xmd,yyextra->insideBody));
3171
3172 if (xmd->templateMaster()) xmd = xmd->templateMaster();
3173
3174 if (xmd->isLinkable())
3175 {
3176 // add usage reference
3177 if (yyextra->currentDefinition && yyextra->currentMemberDef &&
3178 yyextra->insideBody && yyextra->collectXRefs)
3179 {
3180 addDocCrossReference(yyextra->currentMemberDef,xmd);
3181 }
3182
3183 // write the actual link
3184 writeMultiLineCodeLink(yyscanner,ol,xmd,memName);
3185 addToSearchIndex(yyscanner,memName);
3186 return TRUE;
3187 }
3188 }
3189
3190 return FALSE;
3191}
3192
3193static bool generateClassMemberLink(yyscan_t yyscanner,
3194 OutputCodeList &ol,
3195 const Definition *def,
3196 const QCString &memName)
3197{
3198 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3199 if (def && def->definitionType()==Definition::TypeClass)
3200 {
3201 const ClassDef *cd = toClassDef(def);
3202 const MemberDef *xmd = cd->getMemberByName(memName);
3203 DBG_CTX((stderr,"generateClassMemberLink(class=%s,member=%s)=%p\n",qPrint(def->name()),qPrint(memName),(void*)xmd));
3204 if (xmd)
3205 {
3206 return generateClassMemberLink(yyscanner,ol,xmd,memName);
3207 }
3208 else
3209 {
3210 const Definition *innerDef = cd->findInnerCompound(memName);
3211 if (innerDef)
3212 {
3213 yyextra->theCallContext.setScope(ScopedTypeVariant(innerDef));
3214 addToSearchIndex(yyscanner,memName);
3215 writeMultiLineCodeLink(yyscanner,*yyextra->code,innerDef,memName);
3216 return TRUE;
3217 }
3218 }
3219 }
3220 else if (def && def->definitionType()==Definition::TypeNamespace)
3221 {
3222 const NamespaceDef *nd = toNamespaceDef(def);
3223 DBG_CTX((stderr,"Looking for %s inside namespace %s\n",qPrint(memName),qPrint(nd->name())));
3224 const Definition *innerDef = nd->findInnerCompound(memName);
3225 if (innerDef)
3226 {
3227 yyextra->theCallContext.setScope(ScopedTypeVariant(innerDef));
3228 addToSearchIndex(yyscanner,memName);
3229 writeMultiLineCodeLink(yyscanner,*yyextra->code,innerDef,memName);
3230 return TRUE;
3231 }
3232 }
3233 return FALSE;
3234}
3235
3236static void generateMemberLink(yyscan_t yyscanner,
3237 OutputCodeList &ol,
3238 const QCString &varName,
3239 const QCString &memName)
3240{
3241 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3242 DBG_CTX((stderr,"generateMemberLink(object=%s,mem=%s) classScope=%s\n",
3243 qPrint(varName),qPrint(memName),qPrint(yyextra->scopeName)));
3244
3245 if (varName.isEmpty()) return;
3246
3247 // look for the variable in the current context
3248 const ScopedTypeVariant *stv = yyextra->theVarContext.findVariable(varName);
3249 if (stv)
3250 {
3251 if (!stv->isDummy())
3252 {
3253 DBG_CTX((stderr,"Class found!\n"));
3254 if (getLink(yyscanner,stv->name(),memName,ol))
3255 {
3256 DBG_CTX((stderr,"Found result!\n"));
3257 return;
3258 }
3259 if (stv->localDef() && !stv->localDef()->baseClasses().empty())
3260 {
3261 for (const auto &bcName : stv->localDef()->baseClasses())
3262 {
3263 if (getLink(yyscanner,bcName,memName,ol))
3264 {
3265 DBG_CTX((stderr,"Found result!\n"));
3266 return;
3267 }
3268 }
3269 }
3270 }
3271 }
3272 else // variable not in current context, maybe it is in a parent context
3273 {
3274 const ClassDef *vcd = yyextra->symbolResolver.resolveClass(yyextra->currentDefinition,yyextra->scopeName,true);
3275 if (vcd && vcd->isLinkable())
3276 {
3277 DBG_CTX((stderr,"Found class %s for variable '%s'\n",qPrint(yyextra->scopeName),qPrint(varName)));
3278 MemberName *vmn=Doxygen::memberNameLinkedMap->find(varName);
3279 if (vmn==nullptr)
3280 {
3281 int vi = 0;
3282 QCString vn=varName;
3283 if ((vi=vn.findRev("::"))!=-1 || (vi=vn.findRev('.'))!=-1) // explicit scope A::b(), probably static member
3284 {
3285 const ClassDef *jcd = getClass(vn.left(vi));
3286 vn=vn.right(vn.length()-vi-2);
3287 vmn=Doxygen::memberNameLinkedMap->find(vn);
3288 //printf("Trying name '%s' scope=%s\n",qPrint(vn),qPrint(scope));
3289 if (vmn)
3290 {
3291 for (const auto &vmd : *vmn)
3292 {
3293 if (vmd->getClassDef()==jcd)
3294 {
3295 DBG_CTX((stderr,"Found variable type=%s\n",qPrint(vmd->typeString())));
3296 const ClassDef *mcd=stripClassName(yyscanner,vmd->typeString(),vmd->getOuterScope());
3297 if (mcd && mcd->isLinkable())
3298 {
3299 if (generateClassMemberLink(yyscanner,ol,mcd,memName)) return;
3300 }
3301 }
3302 }
3303 }
3304 }
3305 }
3306 if (vmn)
3307 {
3308 DBG_CTX((stderr,"There is a variable with name '%s'\n",qPrint(varName)));
3309 for (const auto &vmd : *vmn)
3310 {
3311 if (vmd->getClassDef()==vcd)
3312 {
3313 DBG_CTX((stderr,"Found variable type=%s\n",qPrint(vmd->typeString())));
3314 const ClassDef *mcd=stripClassName(yyscanner,vmd->typeString(),vmd->getOuterScope());
3315 if (mcd && mcd->isLinkable())
3316 {
3317 if (generateClassMemberLink(yyscanner,ol,mcd,memName)) return;
3318 }
3319 }
3320 }
3321 }
3322 }
3323 }
3324 // nothing found -> write result as is
3325 codifyLines(yyscanner,memName);
3326 addToSearchIndex(yyscanner,memName);
3327 return;
3328}
3329
3330static void generatePHPVariableLink(yyscan_t yyscanner,OutputCodeList &ol,const char *varName)
3331{
3332 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3333 QCString name(varName+7); // strip $this->
3334 name.prepend("$");
3335 DBG_CTX((stderr,"generatePHPVariableLink(%s) name=%s scope=%s\n",varName,qPrint(name),qPrint(yyextra->scopeName)));
3336 if (!getLink(yyscanner,yyextra->scopeName,name,ol,varName))
3337 {
3338 codifyLines(yyscanner,varName);
3339 }
3340}
3341
3342static void generateFunctionLink(yyscan_t yyscanner,OutputCodeList &ol,const QCString &funcName)
3343{
3344 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3345 //CodeClassDef *ccd=nullptr;
3346 QCString locScope=yyextra->scopeName;
3347 QCString locFunc=removeRedundantWhiteSpace(funcName);
3348 if (yyextra->lang==SrcLangExt::PHP && locFunc.startsWith("self::")) locFunc=locFunc.mid(4);
3349 QCString funcScope;
3350 QCString funcWithScope=locFunc;
3351 QCString funcWithFullScope=locFunc;
3352 QCString fullScope=locScope;
3353 DBG_CTX((stderr,"*** locScope=%s locFunc=%s\n",qPrint(locScope),qPrint(locFunc)));
3354 int len=2;
3355 int i=locFunc.findRev("::");
3356 if (yyextra->currentMemberDef && yyextra->currentMemberDef->resolveAlias()->getClassDef() &&
3357 funcName==yyextra->currentMemberDef->localName() &&
3358 yyextra->currentMemberDef->getDefLine()==yyextra->yyLineNr &&
3359 generateClassMemberLink(yyscanner,ol,yyextra->currentMemberDef,funcName)
3360 )
3361 {
3362 // special case where funcName is the name of a method that is also
3363 // defined on this line. In this case we can directly link to
3364 // yyextra->currentMemberDef, which is not only faster, but
3365 // in case of overloaded methods, this will make sure that we link to
3366 // the correct method, and thereby get the correct reimplemented relations.
3367 // See also bug 549022.
3368 goto exit;
3369 }
3370 if (i==-1)
3371 {
3372 i=locFunc.findRev(".");
3373 len=1;
3374 }
3375 if (i==-1)
3376 {
3377 i=locFunc.findRev("\\");
3378 len=1; // for PHP
3379 }
3380 if (i>0)
3381 {
3382 funcScope=locFunc.left(i);
3383 locFunc=locFunc.right(locFunc.length()-i-len).stripWhiteSpace();
3384 int ts=locScope.find('<'); // start of template
3385 int te=locScope.findRev('>'); // end of template
3386 DBG_CTX((stderr,"ts=%d te=%d\n",ts,te));
3387 if (ts!=-1 && te!=-1 && te>ts)
3388 {
3389 // remove template from scope
3390 locScope=locScope.left(ts)+locScope.right(locScope.length()-te-1);
3391 }
3392 ts=funcScope.find('<'); // start of template
3393 te=funcScope.findRev('>'); // end of template
3394 DBG_CTX((stderr,"ts=%d te=%d\n",ts,te));
3395 if (ts!=-1 && te!=-1 && te>ts)
3396 {
3397 // remove template from scope
3398 funcScope=funcScope.left(ts)+funcScope.right(funcScope.length()-te-1);
3399 }
3400 if (!funcScope.isEmpty())
3401 {
3402 funcWithScope = funcScope+"::"+locFunc;
3403 if (!locScope.isEmpty())
3404 {
3405 fullScope=locScope+"::"+funcScope;
3406 }
3407 }
3408 if (!locScope.isEmpty())
3409 {
3410 funcWithFullScope = locScope+"::"+funcWithScope;
3411 }
3412 }
3413
3414 if (!fullScope.isEmpty())
3415 {
3416 auto it = yyextra->codeClassMap.find(fullScope.str());
3417 if (it!=yyextra->codeClassMap.end())
3418 {
3419 ScopedTypeVariant ccd = it->second;
3420 if (ccd.localDef() && !ccd.localDef()->baseClasses().empty())
3421 {
3422 for (const auto &bcName : ccd.localDef()->baseClasses())
3423 {
3424 if (getLink(yyscanner,bcName,locFunc,ol,funcName))
3425 {
3426 goto exit;
3427 }
3428 }
3429 }
3430 }
3431 }
3432
3433 if (!locScope.isEmpty() && fullScope!=locScope)
3434 {
3435 auto it = yyextra->codeClassMap.find(locScope.str());
3436 if (it!=yyextra->codeClassMap.end())
3437 {
3438 ScopedTypeVariant ccd = it->second;
3439 if (ccd.localDef() && !ccd.localDef()->baseClasses().empty())
3440 {
3441 for (const auto &bcName : ccd.localDef()->baseClasses())
3442 {
3443 if (getLink(yyscanner,bcName,funcWithScope,ol,funcName))
3444 {
3445 goto exit;
3446 }
3447 }
3448 }
3449 }
3450 }
3451 if (!getLink(yyscanner,locScope,funcWithScope,ol,funcName))
3452 {
3453 generateClassOrGlobalLink(yyscanner,ol,funcName);
3454 }
3455exit:
3456 return;
3457}
3458
3459/*! counts the number of lines in the input */
3460static int countLines(yyscan_t yyscanner)
3461{
3462 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3463 const char *p=yyextra->inputString;
3464 char c = 0;
3465 int count=1;
3466 while ((c=*p))
3467 {
3468 p++ ;
3469 if (c=='\n') count++;
3470 }
3471 if (p>yyextra->inputString && *(p-1)!='\n')
3472 { // last line does not end with a \n, so we add an extra
3473 count++;
3474 }
3475 return count;
3476}
3477
3478static void endFontClass(yyscan_t yyscanner,bool specialComment)
3479{
3480 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3481 if (yyextra->currentFontClass)
3482 {
3483 yyextra->code->endFontClass();
3484 yyextra->currentFontClass=nullptr;
3485 }
3486 if (specialComment && yyextra->insideSpecialComment)
3487 {
3488 yyextra->code->endSpecialComment();
3489 yyextra->insideSpecialComment = false;
3490 }
3491}
3492
3493static void startFontClass(yyscan_t yyscanner,const char *s,bool specialComment)
3494{
3495 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3496 endFontClass(yyscanner);
3497 if (specialComment)
3498 {
3499 yyextra->code->startSpecialComment();
3500 yyextra->insideSpecialComment = true;
3501 }
3502 yyextra->code->startFontClass(s);
3503 yyextra->currentFontClass=s;
3504}
3505
3506//----------------------------------------------------------------------------
3507
3508// recursively writes a linkified Objective-C method call
3509static void writeObjCMethodCall(yyscan_t yyscanner,ObjCCallCtx *ctx)
3510{
3511 if (ctx==nullptr) return;
3512 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3513 char c = 0;
3514 if (!ctx->methodName.isEmpty())
3515 {
3516 DBG_CTX((stderr,"writeObjCMethodCall(%s) obj=%s method=%s\n",
3518 if (!ctx->objectTypeOrName.isEmpty() && ctx->objectTypeOrName.at(0)!='$')
3519 {
3520 DBG_CTX((stderr,"Looking for object=%s method=%s\n",qPrint(ctx->objectTypeOrName),
3521 qPrint(ctx->methodName)));
3522 const ScopedTypeVariant *stv = yyextra->theVarContext.findVariable(ctx->objectTypeOrName);
3523 if (stv!=nullptr) // local variable
3524 {
3525 DBG_CTX((stderr," object is local variable\n"));
3526 if (stv->globalDef() && !ctx->methodName.isEmpty())
3527 {
3528 const ClassDef *cd = toClassDef(stv->globalDef());
3529 if (cd)
3530 {
3531 ctx->method = cd->getMemberByName(ctx->methodName);
3532 }
3533 DBG_CTX((stderr," class=%p method=%p\n",(void*)cd,(void*)ctx->method));
3534 }
3535 }
3536 }
3537 }
3538
3539 DBG_CTX((stderr,"["));
3540 if (!ctx->format.isEmpty())
3541 {
3542 const char *p = ctx->format.data();
3543 bool skip = false;
3544 char skipChar = ' ';
3545 while ((c=*p++)) // for each character in ctx->format
3546 {
3547 if (skip)
3548 {
3549 char s[2];
3550 s[0]=c;s[1]=0;
3551 codifyLines(yyscanner,s);
3552 if (c==skipChar)
3553 {
3554 skip = false;
3555 skipChar = ' ';
3556 }
3557 else if (c=='\\')
3558 {
3559 c = *p++;
3560 s[0]=c;
3561 codifyLines(yyscanner,s);
3562 }
3563 }
3564 else if (c=='$')
3565 {
3566 char nc=*p++;
3567 if (nc=='$') // escaped $
3568 {
3569 yyextra->code->codify("$");
3570 }
3571 else // name fragment or reference to a nested call
3572 {
3573 if (nc=='n') // name fragment
3574 {
3575 nc=*p++;
3576 QCString refIdStr;
3577 while (nc!=0 && isdigit(nc)) { refIdStr+=nc; nc=*p++; }
3578 p--;
3579 int refId=refIdStr.toInt();
3580 auto it = yyextra->nameMap.find(refId);
3581 if (it!=yyextra->nameMap.end())
3582 {
3583 QCString name = it->second;
3584 if (ctx->method && ctx->method->isLinkable())
3585 {
3586 writeMultiLineCodeLink(yyscanner,*yyextra->code,ctx->method,name);
3587 if (yyextra->currentMemberDef && yyextra->collectXRefs)
3588 {
3589 addDocCrossReference(yyextra->currentMemberDef,ctx->method);
3590 }
3591 }
3592 else
3593 {
3594 codifyLines(yyscanner,name);
3595 }
3596 }
3597 else
3598 {
3599 DBG_CTX((stderr,"Invalid name: id=%d\n",refId));
3600 }
3601 }
3602 else if (nc=='o') // reference to potential object name, e.g. 'self', or 'self.var1' or 'self.var1.var2'
3603 {
3604 nc=*p++;
3605 QCString refIdStr;
3606 while (nc!=0 && isdigit(nc)) { refIdStr+=nc; nc=*p++; }
3607 p--;
3608 int refId=refIdStr.toInt();
3609 auto it = yyextra->objectMap.find(refId);
3610 if (it!=yyextra->objectMap.end())
3611 {
3612 QCString object = it->second;
3613 if (object=="self")
3614 {
3615 if (yyextra->currentDefinition &&
3616 yyextra->currentDefinition->definitionType()==Definition::TypeClass)
3617 {
3618 ctx->objectType = toClassDef(yyextra->currentDefinition);
3619 if (ctx->objectType->categoryOf())
3620 {
3621 ctx->objectType = ctx->objectType->categoryOf();
3622 }
3623 if (ctx->objectType && !ctx->methodName.isEmpty())
3624 {
3625 ctx->method = ctx->objectType->getMemberByName(ctx->methodName);
3626 }
3627 }
3628 startFontClass(yyscanner,"keyword");
3629 codifyLines(yyscanner,object);
3630 endFontClass(yyscanner);
3631 }
3632 else if (object=="super")
3633 {
3634 if (yyextra->currentDefinition &&
3635 yyextra->currentDefinition->definitionType()==Definition::TypeClass)
3636 {
3637 const ClassDef *cd = toClassDef(yyextra->currentDefinition);
3638 if (cd->categoryOf())
3639 {
3640 cd = cd->categoryOf();
3641 }
3642 for (const auto &bclass : cd->baseClasses())
3643 {
3644 if (bclass.classDef->compoundType()!=ClassDef::Protocol)
3645 {
3646 ctx->objectType = bclass.classDef;
3647 if (ctx->objectType && !ctx->methodName.isEmpty())
3648 {
3649 ctx->method = ctx->objectType->getMemberByName(ctx->methodName);
3650 }
3651 }
3652 }
3653 }
3654 startFontClass(yyscanner,"keyword");
3655 codifyLines(yyscanner,object);
3656 endFontClass(yyscanner);
3657 }
3658 else if (ctx->objectVar && ctx->objectVar->isLinkable()) // object is class variable
3659 {
3660 writeMultiLineCodeLink(yyscanner,*yyextra->code,ctx->objectVar,object);
3661 if (yyextra->currentMemberDef && yyextra->collectXRefs)
3662 {
3663 addDocCrossReference(yyextra->currentMemberDef,ctx->objectVar);
3664 }
3665 }
3666 else if (ctx->objectType && ctx->objectType->isLinkable()) // object is class name
3667 {
3668 const ClassDef *cd = ctx->objectType;
3669 writeMultiLineCodeLink(yyscanner,*yyextra->code,cd,object);
3670 }
3671 else // object still needs to be resolved
3672 {
3673 int pp=0;
3674 int dotPos=object.find('.',pp);
3675 int len = static_cast<int>(object.length());
3676 if (dotPos==-1) dotPos=len;
3677 const Definition *scope = yyextra->currentDefinition;
3678 //printf("initial scope=%s\n",scope?qPrint(scope->name()):"none");
3679 for (;;)
3680 {
3681 QCString fragment = object.mid(pp,dotPos-pp);
3682 QCString fragmentStripped = fragment.stripWhiteSpace();
3683 //printf("fragment=%s\n",qPrint(fragment));
3684 if (fragmentStripped=="self")
3685 {
3686 if (scope && scope->definitionType()==Definition::TypeClass)
3687 {
3688 scope = ctx->objectType = toClassDef(scope);
3689 }
3690 //printf("self scope=%s\n",scope?qPrint(scope->name()):"none");
3691 startFontClass(yyscanner,"keyword");
3692 codifyLines(yyscanner,fragment);
3693 endFontClass(yyscanner);
3694 }
3695 else
3696 {
3697 const Definition *symbol = yyextra->symbolResolver.resolveSymbol(scope,fragmentStripped,QCString(),false,true);
3698 //printf("scope=%s name=%s -> symbol=%s\n",scope?qPrint(scope->name()):"none",qPrint(fragment),
3699 // symbol?qPrint(symbol->name()):"none");
3700 if (symbol && symbol->definitionType()==Definition::TypeClass)
3701 {
3702 scope = ctx->objectType = toClassDef(symbol);
3703 ctx->method = yyextra->symbolResolver.getTypedef();
3704 }
3705 else if (symbol && symbol->definitionType()==Definition::TypeMember)
3706 {
3707 scope = ctx->objectType = stripClassName(yyscanner,toMemberDef(symbol)->typeString(),scope);
3708 }
3709 if (scope && scope!=Doxygen::globalScope)
3710 {
3711 writeMultiLineCodeLink(yyscanner,*yyextra->code,scope,fragment);
3712 }
3713 else
3714 {
3715 codifyLines(yyscanner,fragment);
3716 }
3717 //printf("new scope=%s\n",scope?qPrint(scope->name()):"none");
3718 }
3719 if (dotPos==len)
3720 {
3721 break;
3722 }
3723 else // find next fragment
3724 {
3725 codifyLines(yyscanner,".");
3726 pp=dotPos+1;
3727 dotPos=object.find('.',pp);
3728 if (dotPos==-1) dotPos=len;
3729 }
3730 }
3731 DBG_CTX((stderr," object is class? %p\n",(void*)ctx->objectType));
3732 if (ctx->objectType) // found class
3733 {
3734 ctx->method = ctx->objectType->getMemberByName(ctx->methodName);
3735 DBG_CTX((stderr," yes->method=%s\n",ctx->method?qPrint(ctx->method->name()):"<none>"));
3736 }
3737 else if (ctx->method==nullptr) // search for class variable with the same name
3738 {
3739 DBG_CTX((stderr," no\n"));
3740 DBG_CTX((stderr,"yyextra->currentDefinition=%p\n",(void*)yyextra->currentDefinition));
3741 if (yyextra->currentDefinition &&
3742 yyextra->currentDefinition->definitionType()==Definition::TypeClass)
3743 {
3744 ctx->objectVar = (toClassDef(yyextra->currentDefinition))->getMemberByName(ctx->objectTypeOrName);
3745 DBG_CTX((stderr," ctx->objectVar=%p\n",(void*)ctx->objectVar));
3746 if (ctx->objectVar)
3747 {
3748 ctx->objectType = stripClassName(yyscanner,ctx->objectVar->typeString(),yyextra->currentDefinition);
3749 DBG_CTX((stderr," ctx->objectType=%p\n",(void*)ctx->objectType));
3750 if (ctx->objectType && !ctx->methodName.isEmpty())
3751 {
3752 ctx->method = ctx->objectType->getMemberByName(ctx->methodName);
3753 DBG_CTX((stderr," ctx->method=%p\n",(void*)ctx->method));
3754 }
3755 }
3756 }
3757 }
3758 }
3759 }
3760 else
3761 {
3762 DBG_CTX((stderr,"Invalid object: id=%d\n",refId));
3763 }
3764 }
3765 else if (nc=='c') // reference to nested call
3766 {
3767 nc=*p++;
3768 QCString refIdStr;
3769 while (nc!=0 && isdigit(nc)) { refIdStr+=nc; nc=*p++; }
3770 p--;
3771 int refId=refIdStr.toInt();
3772 auto it = yyextra->contextMap.find(refId);
3773 if (it!=yyextra->contextMap.end()) // recurse into nested call
3774 {
3775 ObjCCallCtx *ictx = it->second.get();
3776 writeObjCMethodCall(yyscanner,ictx);
3777 if (ictx->method) // link to nested call successfully
3778 {
3779 // get the ClassDef representing the method's return type
3780 if (ictx->method->typeString()=="id")
3781 {
3782 // see if the method name is unique, if so we link to it
3784 //printf("mn->count=%d ictx->method=%s ctx->methodName=%s\n",
3785 // mn==0?-1:(int)mn->count(),
3786 // qPrint(ictx->method->name()),
3787 // qPrint(ctx->methodName));
3788 if (mn && mn->size()==1) // member name unique
3789 {
3790 ctx->method = mn->front().get();
3791 }
3792 }
3793 else
3794 {
3795 ctx->objectType = stripClassName(yyscanner,ictx->method->typeString(),yyextra->currentDefinition);
3796 if (ctx->objectType && !ctx->methodName.isEmpty())
3797 {
3798 ctx->method = ctx->objectType->getMemberByName(ctx->methodName);
3799 }
3800 }
3801 DBG_CTX((stderr," ***** method=%s -> object=%p\n",qPrint(ictx->method->name()),(void*)ctx->objectType));
3802 }
3803 }
3804 else
3805 {
3806 DBG_CTX((stderr,"Invalid context: id=%d\n",refId));
3807 }
3808 }
3809 else if (nc=='w') // some word
3810 {
3811 nc=*p++;
3812 QCString refIdStr;
3813 while (nc!=0 && isdigit(nc)) { refIdStr+=nc; nc=*p++; }
3814 p--;
3815 int refId=refIdStr.toInt();
3816 auto it = yyextra->wordMap.find(refId);
3817 if (it!=yyextra->wordMap.end())
3818 {
3819 QCString word = it->second;
3820 bool isKeyword = word=="self";
3821 if (isKeyword)
3822 {
3823 startFontClass(yyscanner,"keyword");
3824 }
3825 codifyLines(yyscanner,word);
3826 if (isKeyword)
3827 {
3828 endFontClass(yyscanner);
3829 }
3830 }
3831 }
3832 else if (nc=='d') // comment block
3833 {
3834 nc=*p++;
3835 QCString refIdStr;
3836 while (nc!=0 && isdigit(nc)) { refIdStr+=nc; nc=*p++; }
3837 p--;
3838 int refId=refIdStr.toInt();
3839 auto it = yyextra->commentMap.find(refId);
3840 if (it!=yyextra->commentMap.end())
3841 {
3842 QCString comment = it->second;
3843 startFontClass(yyscanner,"comment");
3844 codifyLines(yyscanner,comment);
3845 endFontClass(yyscanner);
3846 }
3847 }
3848 else // illegal marker
3849 {
3850 ASSERT(0); // "invalid escape sequence"
3851 }
3852 }
3853 }
3854 else if (c=='\'' || c == '"')
3855 {
3856 char s[2];
3857 s[0]=c;s[1]=0;
3858 codifyLines(yyscanner,s);
3859 skip = true;
3860 skipChar = c;
3861 }
3862 else // normal non-marker character
3863 {
3864 char s[2];
3865 s[0]=c;s[1]=0;
3866 codifyLines(yyscanner,s);
3867 }
3868 }
3869 }
3870 DBG_CTX((stderr,"%s %s]\n",qPrint(ctx->objectTypeOrName),qPrint(ctx->methodName)));
3871 DBG_CTX((stderr,"}=(type='%s',name='%s')",
3873 qPrint(ctx->methodName)));
3874}
3875
3876// Replaces an Objective-C method name fragment s by a marker of the form
3877// $n12, the number (12) can later be used as a key for obtaining the name
3878// fragment, from yyextra->nameMap
3879static QCString escapeName(yyscan_t yyscanner,const QCString &s)
3880{
3881 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3882 QCString result;
3883 result.sprintf("$n%d",yyextra->currentNameId);
3884 yyextra->nameMap.emplace(yyextra->currentNameId,s);
3885 yyextra->currentNameId++;
3886 return result;
3887}
3888
3889static QCString escapeObject(yyscan_t yyscanner,const QCString &s)
3890{
3891 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3892 QCString result;
3893 result.sprintf("$o%d",yyextra->currentObjId);
3894 yyextra->objectMap.emplace(yyextra->currentObjId,s);
3895 yyextra->currentObjId++;
3896 return result;
3897}
3898
3899static QCString escapeWord(yyscan_t yyscanner,const QCString &s)
3900{
3901 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3902 QCString result;
3903 result.sprintf("$w%d",yyextra->currentWordId);
3904 yyextra->wordMap.emplace(yyextra->currentWordId,s);
3905 yyextra->currentWordId++;
3906 return result;
3907}
3908
3909static QCString escapeComment(yyscan_t yyscanner,const QCString &s)
3910{
3911 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3912 QCString result;
3913 result.sprintf("$d%d",yyextra->currentCommentId);
3914 yyextra->commentMap.emplace(yyextra->currentCommentId,s);
3915 yyextra->currentCommentId++;
3916 return result;
3917}
3918
3919static bool skipLanguageSpecificKeyword(yyscan_t yyscanner,const char *keyword)
3920{
3921 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3922 static const std::unordered_set<std::string> non_cpp_keywords = {
3923 "__assume", "__super", "abstract", "function",
3924 "gcnew", "gcroot", "generic", "get",
3925 "internal", "null", "pin_ptr", "raise",
3926 "remove", "self", "set", "transient",
3927 "sealed"
3928 };
3929 static const std::unordered_set<std::string> non_java_keywords = {
3930 "alignas", "alignof", "and", "and_eq", "asm",
3931 "atomic_cancel", "atomic_commit", "atomic_noexcept", "auto", "bitand",
3932 "bitor", "bool", "char8_t", "char16_t", "char32_t",
3933 "compl", "concept", "consteval", "constexpr", "constinit",
3934 "const_cast", "co_await", "co_return", "co_yield", "decltype",
3935 "delete", "dynamic_cast", "explicit", "export", "extern",
3936 "friend", "inline", "mutable", "namespace", "noexcept",
3937 "not", "not_eq", "nullptr", "operator", "or",
3938 "or_eq", "reflexpr", "register", "reinterpret_cast", "requires",
3939 "signed", "sizeof", "static_assert", "_Static_assert", "static_cast", "struct",
3940 "template", "thread_local", "typedef", "typeid", "typename",
3941 "union", "unsigned", "using", "virtual", "wchar_t",
3942 "xor", "xor_eq", "override", "sealed"
3943 };
3944 bool retval = false;
3945 switch (yyextra->lang)
3946 {
3947 case SrcLangExt::Cpp:
3948 retval = (non_cpp_keywords.find(keyword) != non_cpp_keywords.end());
3949 break;
3950 case SrcLangExt::Java:
3951 retval = (non_java_keywords.find(keyword) != non_java_keywords.end());
3952 break;
3953 default:
3954 retval = false;
3955 break;
3956 }
3957 return retval;
3958}
3959
3960static bool isCastKeyword(const char *keyword)
3961{
3962 QCString s(keyword);
3963 int i=s.find('<');
3964 if (i==-1) return FALSE;
3965 QCString kw = s.left(i).stripWhiteSpace();
3966 return kw=="const_cast" || kw=="static_cast" || kw=="dynamic_cast" || kw=="reinterpret_cast";
3967}
3968
3969static int yyread(yyscan_t yyscanner,char *buf,int max_size)
3970{
3971 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3972 yy_size_t inputPosition = yyextra->inputPosition;
3973 const char *s = yyextra->inputString + inputPosition;
3974 int c=0;
3975 while( c < max_size && *s )
3976 {
3977 *buf++ = *s++;
3978 c++;
3979 }
3980 yyextra->inputPosition += c;
3981 return c;
3982}
3983
3984
3985static void saveObjCContext(yyscan_t yyscanner)
3986{
3987 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3988 if (yyextra->currentCtx)
3989 {
3990 yyextra->currentCtx->format+=QCString().sprintf("$c%d",yyextra->currentCtxId);
3991 if (yyextra->braceCount==0 && YY_START==ObjCCall)
3992 {
3993 yyextra->currentCtx->objectTypeOrName=yyextra->currentCtx->format.mid(1);
3994 DBG_CTX((stderr,"new type=%s\n",qPrint(yyextra->currentCtx->objectTypeOrName)));
3995 }
3996 yyextra->contextStack.push(yyextra->currentCtx);
3997 }
3998 else
3999 {
4000 DBG_CTX((stderr,"Trying to save NULL context!\n"));
4001 }
4002 auto newCtx = std::make_unique<ObjCCallCtx>();
4003 newCtx->id = yyextra->currentCtxId;
4004 newCtx->lexState = YY_START;
4005 newCtx->braceCount = yyextra->braceCount;
4006 newCtx->objectType = nullptr;
4007 newCtx->objectVar = nullptr;
4008 newCtx->method = nullptr;
4009 DBG_CTX((stderr,"save state=%d\n",YY_START));
4010 yyextra->currentCtx = newCtx.get();
4011 yyextra->contextMap.emplace(yyextra->currentCtxId,std::move(newCtx));
4012 yyextra->braceCount = 0;
4013 yyextra->currentCtxId++;
4014}
4015
4016static void restoreObjCContext(yyscan_t yyscanner)
4017{
4018 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
4019 DBG_CTX((stderr,"restore state=%d->%d\n",YY_START,yyextra->currentCtx->lexState));
4020 BEGIN(yyextra->currentCtx->lexState);
4021 yyextra->braceCount = yyextra->currentCtx->braceCount;
4022 if (!yyextra->contextStack.empty())
4023 {
4024 yyextra->currentCtx = yyextra->contextStack.top();
4025 yyextra->contextStack.pop();
4026 }
4027 else
4028 {
4029 yyextra->currentCtx = nullptr;
4030 DBG_CTX((stderr,"Trying to pop context while yyextra->contextStack is empty!\n"));
4031 }
4032}
4033
4035{
4041{
4042 codeYYlex_init_extra(&p->state,&p->yyscanner);
4043#ifdef FLEX_DEBUG
4044 codeYYset_debug(Debug::isFlagSet(Debug::Lex_code)?1:0,p->yyscanner);
4045#endif
4047}
4048
4050{
4051 codeYYlex_destroy(p->yyscanner);
4052}
4053
4055{
4056 struct yyguts_t *yyg = (struct yyguts_t*)p->yyscanner;
4057 DBG_CTX((stderr,"***CodeParser::reset()\n"));
4058 yyextra->theVarContext.clear();
4059 while (!yyextra->scopeNameLengthStack.empty()) yyextra->scopeNameLengthStack.pop_back();
4060 yyextra->codeClassMap.clear();
4061 yyextra->curClassBases.clear();
4062 yyextra->anchorCount = 0;
4063 yyextra->insideCodeLine = false;
4064}
4065
4066void CCodeParser::setInsideCodeLine(bool inp)
4067{
4068 struct yyguts_t *yyg = (struct yyguts_t*)p->yyscanner;
4069 yyextra->insideCodeLine = inp;
4070}
4071
4072bool CCodeParser::insideCodeLine() const
4073{
4074 struct yyguts_t *yyg = (struct yyguts_t*)p->yyscanner;
4075 return yyextra->insideCodeLine;
4076}
4077
4078void CCodeParser::parseCode(OutputCodeList &od,const QCString &scopeName,const QCString &s,
4079 SrcLangExt lang,bool stripCodeComments,const CodeParserOptions &options)
4081 yyscan_t yyscanner = p->yyscanner;
4082 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
4083 DBG_CTX((stderr,"***parseCode() exBlock=%d exName=%s fd=%p scopeName=%s searchCtx=%s\n",
4084 options.isExample(),qPrint(options.exampleName()),(void*)options.fileDef(),
4085 qPrint(scopeName),options.searchCtx()?qPrint(options.searchCtx()->name()):"<none>"));
4086
4087 if (s.isEmpty()) return;
4088
4089 DebugLex debugLex(Debug::Lex_code, __FILE__, options.fileDef() ? qPrint(options.fileDef()->fileName()) :
4090 !options.exampleName().isEmpty() ? qPrint(options.exampleName()) : nullptr);
4091
4092 od.stripCodeComments(stripCodeComments);
4093 yyextra->code = &od;
4094 yyextra->inputString = s.data();
4095 yyextra->fileName = options.fileDef() ? options.fileDef()->fileName():"";
4096 yyextra->absFileName = options.fileDef() ? options.fileDef()->absFilePath():"";
4097 yyextra->inputPosition = 0;
4098 codeYYrestart(nullptr,yyscanner);
4099 yyextra->currentFontClass = nullptr;
4100 yyextra->searchCtx = options.searchCtx();
4101 yyextra->collectXRefs = options.collectXRefs();
4102 yyextra->inFunctionTryBlock = FALSE;
4103 yyextra->symbolResolver.setFileScope(options.fileDef());
4104 yyextra->foldStack.clear();
4105 yyextra->insideSpecialComment = false;
4106 yyextra->yyLineNr = options.startLine()!=-1 ? options.startLine() : 1;
4107 yyextra->inputLines = options.endLine()!=-1 ? options.endLine()+1 : yyextra->yyLineNr + countLines(yyscanner) - 1;
4108 yyextra->curlyCount = 0;
4109 yyextra->bodyCurlyCount = 0;
4110 yyextra->bracketCount = 0;
4111 yyextra->sharpCount = 0;
4112 yyextra->insideTemplate = FALSE;
4113 yyextra->theCallContext.clear();
4114 while (!yyextra->scopeStack.empty()) yyextra->scopeStack.pop();
4115 yyextra->scopeName = scopeName;
4116 DBG_CTX((stderr,"parseCCode %s\n",qPrint(scopeName)));
4117 yyextra->exampleBlock = options.isExample();
4118 yyextra->exampleName = options.exampleName();
4119 yyextra->sourceFileDef = options.fileDef();
4120 yyextra->lineNumbers = options.fileDef() && options.showLineNumbers();
4121 if (options.fileDef()==nullptr)
4122 {
4123 // create a dummy filedef for the example
4124 yyextra->exampleFileDef = createFileDef(QCString(),(!options.exampleName().isEmpty()?options.exampleName():"generated"));
4125 yyextra->sourceFileDef = yyextra->exampleFileDef.get();
4126 }
4127 yyextra->lang = lang;
4128 yyextra->insideObjC = lang==SrcLangExt::ObjC;
4129 if (yyextra->sourceFileDef)
4130 {
4131 setCurrentDoc(yyscanner,"l00001");
4132 }
4133 yyextra->currentDefinition = options.searchCtx() ? options.searchCtx() : getResolvedNamespace(scopeName);
4134 yyextra->currentMemberDef = nullptr;
4135 yyextra->searchingForBody = options.isExample();
4136 yyextra->insideBody = FALSE;
4137 yyextra->bracketCount = 0;
4138 if (!yyextra->exampleName.isEmpty())
4139 {
4140 yyextra->exampleFile = convertNameToFile(yyextra->exampleName+"-example",FALSE,TRUE);
4141 DBG_CTX((stderr,"yyextra->exampleFile=%s\n",qPrint(yyextra->exampleFile)));
4142 }
4143 yyextra->includeCodeFragment = options.inlineFragment();
4144 DBG_CTX((stderr,"** exBlock=%d exName=%s include=%d\n",options.isExample(),qPrint(options.exampleName()),options.inlineFragment()));
4145 if (!yyextra->insideCodeLine)
4146 {
4147 startCodeLine(yyscanner);
4148 }
4149 yyextra->type.clear();
4150 yyextra->name.clear();
4151 yyextra->args.clear();
4152 yyextra->parmName.clear();
4153 yyextra->parmType.clear();
4154 if (options.memberDef()) setParameterList(yyscanner,options.memberDef());
4155 BEGIN( Body );
4156 codeYYlex(yyscanner);
4157 yyextra->lexInit=TRUE;
4158 if (yyextra->insideCodeLine)
4159 {
4160 endCodeLine(yyscanner);
4161 }
4162 if (Config_getBool(HTML_CODE_FOLDING))
4163 {
4164 while (!yyextra->foldStack.empty())
4165 {
4166 yyextra->code->endFold();
4167 yyextra->foldStack.pop_back();
4168 }
4169 }
4170 if (yyextra->exampleFileDef)
4171 {
4172 // delete the temporary file definition used for this example
4173 yyextra->exampleFileDef.reset();
4174 yyextra->sourceFileDef=nullptr;
4175 }
4176 // write the tooltips
4177 yyextra->tooltipManager.writeTooltips(od);
4178}
4179
4180#include "code.l.h"
void resetCodeParserState() override
Resets the state of the code parser.
Definition code.l:4056
void parseCode(OutputCodeList &codeOutIntf, const QCString &scopeName, const QCString &input, SrcLangExt lang, bool stripCodeComments, const CodeParserOptions &options) override
Parses a source file or fragment with the goal to produce highlighted and cross-referenced output.
Definition code.l:4080
CCodeParser()
Definition code.l:4042
void setInsideCodeLine(bool inp)
Definition code.l:4068
~CCodeParser() override
Definition code.l:4051
std::unique_ptr< Private > p
Definition code.h:47
bool insideCodeLine() const
Definition code.l:4074
virtual const BaseClassList & baseClasses() const =0
Returns the list of base classes from which this class directly inherits.
virtual const MemberDef * getMemberByName(const QCString &) const =0
Returns the member with the given name.
virtual ClassDef * categoryOf() const =0
Returns the class of which this is a category (Objective-C only).
virtual FileDef * getFileDef() const =0
Returns the namespace this compound is in, or 0 if it has a global scope.
virtual bool addExample(const QCString &anchor, const QCString &name, const QCString &file)=0
@ Lex_code
Definition debug.h:52
static bool isFlagSet(const DebugMask mask)
Definition debug.cpp:132
virtual int getEndBodyLine() const =0
virtual DefType definitionType() const =0
virtual QCString anchor() const =0
virtual QCString briefDescriptionAsTooltip() const =0
virtual bool isLinkableInProject() const =0
virtual const Definition * findInnerCompound(const QCString &name) const =0
virtual int getStartDefLine() const =0
virtual QCString getReference() const =0
virtual QCString qualifiedName() const =0
virtual CodeSymbolType codeSymbolType() const =0
virtual QCString getOutputFileBase() const =0
virtual Definition * getOuterScope() const =0
static NamespaceLinkedMap * namespaceLinkedMap
Definition doxygen.h:114
static MemberNameLinkedMap * functionNameLinkedMap
Definition doxygen.h:111
static std::mutex countFlowKeywordsMutex
Definition doxygen.h:140
static MemberNameLinkedMap * memberNameLinkedMap
Definition doxygen.h:110
static SearchIndexIntf searchIndex
Definition doxygen.h:123
static std::mutex addExampleMutex
Definition doxygen.h:141
virtual const LinkedRefMap< NamespaceDef > & getUsedNamespaces() const =0
virtual QCString fileName() const =0
std::vector< QCString > baseClasses() const
virtual QCString typeString() const =0
virtual const ClassDef * getClassDef() const =0
virtual GroupDef * getGroupDef()=0
virtual const FileDef * getFileDef() const =0
virtual const ArgumentList & argumentList() const =0
virtual MemberDef * resolveAlias()=0
virtual bool isDefine() const =0
virtual bool isVariable() const =0
virtual QCString argsString() const =0
virtual bool isCallable() const =0
virtual void incrementFlowKeyWordCount()=0
virtual bool addExample(const QCString &anchor, const QCString &name, const QCString &file)=0
Ptr & front()
Definition membername.h:51
size_t size() const
Definition membername.h:48
An abstract interface of a namespace symbol.
virtual const MemberDef * getMemberByName(const QCString &) const =0
void writeCodeLink(CodeSymbolType type, const QCString &ref, const QCString &file, const QCString &anchor, const QCString &name, const QCString &tooltip)
Definition outputlist.h:250
void writeCodeAnchor(const QCString &name)
Definition outputlist.h:276
void stripCodeComments(bool b)
Definition outputlist.h:238
int toInt(bool *ok=nullptr, int base=10) const
Definition qcstring.cpp:254
size_t length() const
Returns the length of the string, not counting the 0-terminator.
Definition qcstring.h:166
bool startsWith(const char *s) const
Definition qcstring.h:507
char & at(size_t i)
Returns a reference to the character at index i.
Definition qcstring.h:593
bool isEmpty() const
Returns TRUE iff the string is empty.
Definition qcstring.h:163
const std::string & str() const
Definition qcstring.h:552
QCString simplifyWhiteSpace() const
return a copy of this string with leading and trailing whitespace removed and multiple whitespace cha...
Definition qcstring.cpp:190
QCString right(size_t len) const
Definition qcstring.h:234
QCString & sprintf(const char *format,...)
Definition qcstring.cpp:29
int findRev(char c, int index=-1, bool cs=TRUE) const
Definition qcstring.cpp:96
const char * data() const
Returns a pointer to the contents of the string in the form of a 0-terminated C string.
Definition qcstring.h:172
bool stripPrefix(const QCString &prefix)
Definition qcstring.h:213
void clear()
Definition qcstring.h:182
const Definition * globalDef() const
QCString name() const
ClassDefMutable * toClassDefMutable(Definition *d)
ClassDef * getClass(const QCString &n)
static void codeFolding(yyscan_t yyscanner, const Definition *d)
Definition code.l:2351
ConceptDef * getResolvedConcept(const Definition *d, const QCString &name)
constexpr DocNodeVariant * parent(DocNodeVariant *n)
returns the parent node of a given node n or nullptr if the node has no parent.
Definition docnode.h:1330
std::unique_ptr< FileDef > createFileDef(const QCString &p, const QCString &n, const QCString &ref, const QCString &dn)
Definition filedef.cpp:268
void addDocCrossReference(const MemberDef *s, const MemberDef *d)
MemberDefMutable * toMemberDefMutable(Definition *d)
MemberDef * toMemberDef(Definition *d)
NamespaceDef * getResolvedNamespace(const QCString &name)
NamespaceDef * toNamespaceDef(Definition *d)
#define ASSERT(x)
Definition qcstring.h:39
This class contains the information about the argument of a function or template.
Definition arguments.h:27
codeYY_state state
Definition code.l:4039
yyscan_t yyscanner
Definition code.l:4038
Options to configure the code parser.
Definition parserintf.h:78
bool isExample() const
Definition parserintf.h:81
const Definition * searchCtx() const
Definition parserintf.h:89
const FileDef * fileDef() const
Definition parserintf.h:83
int endLine() const
Definition parserintf.h:85
const MemberDef * memberDef() const
Definition parserintf.h:87
bool showLineNumbers() const
Definition parserintf.h:88
bool inlineFragment() const
Definition parserintf.h:86
QCString exampleName() const
Definition parserintf.h:82
int startLine() const
Definition parserintf.h:84
bool collectXRefs() const
Definition parserintf.h:90
const FileDef * currentFile
Definition util.h:116
QCString scopeName
Definition util.h:112
bool insideCode
Definition util.h:118
const MemberDef * md
Definition util.h:124
bool found
Definition util.h:123
int extractClassNameFromType(const QCString &type, int &pos, QCString &name, QCString &templSpec, SrcLangExt lang)
Definition util.cpp:4169
bool leftScopeMatch(const QCString &scope, const QCString &name)
Definition util.cpp:882
QCString removeAnonymousScopes(const QCString &str)
Definition util.cpp:162
QCString convertNameToFile(const QCString &name, bool allowDots, bool allowUnderscore)
Definition util.cpp:3458
GetDefResult getDefs(const GetDefInput &input)
Definition util.cpp:2248
const char * comment