1 /******************************************************************************
5 * Copyright (C) 1997-2014 by Dimitri van Heesch.
7 * Permission to use, copy, modify, and distribute this software and its
8 * documentation under the terms of the GNU General Public License is hereby
9 * granted. No representations are made about the suitability of this software
10 * for any purpose. It is provided "as is" without express or implied warranty.
11 * See the GNU General Public License for more details.
13 * Documents produced by Doxygen are derivative works derived from the
14 * input used in their production; they are not affected by this license.
32 #include "outputlist.h"
34 #include "membername.h"
35 #include "searchindex.h"
36 #include "arguments.h"
39 #include "classlist.h"
42 #include "namespacedef.h"
45 // Toggle for some debugging info
46 //#define DBG_CTX(x) fprintf x
47 #define DBG_CTX(x) do { } while(0)
49 #define YY_NEVER_INTERACTIVE 1
51 #define CLASSBLOCK (int *)4
52 #define SCOPEBLOCK (int *)8
53 #define INNERBLOCK (int *)12
55 /* -----------------------------------------------------------------
59 static CodeOutputInterface * g_code;
61 static ClassSDict *g_codeClassSDict = 0;
62 static QCString g_curClassName;
63 static QStrList g_curClassBases;
65 static QCString g_parmType;
66 static QCString g_parmName;
68 static const char * g_inputString; //!< the code fragment as text
69 static int g_inputPosition; //!< read offset during parsing
70 static int g_inputLines; //!< number of line in the code fragment
71 static int g_yyLineNr; //!< current line number
72 static int g_yyColNr; //!< current column number
73 static bool g_needsTermination;
75 static bool g_exampleBlock;
76 static QCString g_exampleName;
77 static QCString g_exampleFile;
79 static bool g_insideTemplate = FALSE;
80 static QCString g_type;
81 static QCString g_name;
82 static QCString g_args;
83 static QCString g_classScope;
84 static QCString g_realScope;
85 static QStack<int> g_scopeStack; //!< 1 if bracket starts a scope,
86 // 2 for internal blocks
87 static int g_anchorCount;
88 static FileDef * g_sourceFileDef;
89 static bool g_lineNumbers;
90 static Definition * g_currentDefinition;
91 static MemberDef * g_currentMemberDef;
92 static bool g_includeCodeFragment;
93 static const char * g_currentFontClass;
94 static bool g_searchingForBody;
95 static bool g_insideBody;
96 static int g_bodyCurlyCount;
97 static QCString g_saveName;
98 static QCString g_saveType;
99 static QCString g_delimiter;
101 static int g_bracketCount = 0;
102 static int g_curlyCount = 0;
103 static int g_sharpCount = 0;
104 static bool g_inFunctionTryBlock = FALSE;
105 static bool g_inForEachExpression = FALSE;
107 static int g_lastTemplCastContext;
108 static int g_lastSpecialCContext;
109 static int g_lastStringContext;
110 static int g_lastSkipCppContext;
111 static int g_lastVerbStringContext;
112 static int g_memCallContext;
113 static int g_lastCContext;
114 static int g_skipInlineInitContext;
116 static bool g_insideObjC;
117 static bool g_insideJava;
118 static bool g_insideCS;
119 static bool g_insidePHP;
120 static bool g_insideProtocolList;
122 static bool g_lexInit = FALSE;
124 static QStack<int> g_classScopeLengthStack;
126 static Definition *g_searchCtx;
127 static bool g_collectXRefs;
129 // context for an Objective-C method call
134 QCString objectTypeOrName;
135 ClassDef *objectType;
136 MemberDef *objectVar;
143 // globals for objective-C method calls
144 static ObjCCallCtx *g_currentCtx=0;
145 static int g_currentCtxId=0;
146 static int g_currentNameId=0;
147 static int g_currentObjId=0;
148 static int g_currentWordId=0;
149 static QStack<ObjCCallCtx> g_contextStack;
150 static QIntDict<ObjCCallCtx> g_contextDict;
151 static QIntDict<QCString> g_nameDict;
152 static QIntDict<QCString> g_objectDict;
153 static QIntDict<QCString> g_wordDict;
154 static int g_braceCount=0;
156 static void saveObjCContext();
157 static void restoreObjCContext();
159 static QCString g_forceTagReference;
162 //-------------------------------------------------------------------
164 /*! Represents a stack of variable to class mappings as found in the
165 * code. Each scope is enclosed in pushScope() and popScope() calls.
166 * Variables are added by calling addVariables() and one can search
167 * for variable using findVariable().
169 class VariableContext
172 static const ClassDef *dummyContext;
174 class Scope : public SDict<ClassDef>
177 Scope() : SDict<ClassDef>(17) {}
182 m_scopes.setAutoDelete(TRUE);
184 virtual ~VariableContext()
190 m_scopes.append(new Scope);
191 DBG_CTX((stderr,"** Push var context %d\n",m_scopes.count()));
196 if (m_scopes.count()>0)
198 DBG_CTX((stderr,"** Pop var context %d\n",m_scopes.count()));
199 m_scopes.remove(m_scopes.count()-1);
203 DBG_CTX((stderr,"** ILLEGAL: Pop var context\n"));
210 m_globalScope.clear();
213 void clearExceptGlobal()
215 DBG_CTX((stderr,"** Clear var context\n"));
219 void addVariable(const QCString &type,const QCString &name);
220 ClassDef *findVariable(const QCString &name);
222 int count() const { return m_scopes.count(); }
226 QList<Scope> m_scopes;
229 void VariableContext::addVariable(const QCString &type,const QCString &name)
231 //printf("VariableContext::addVariable(%s,%s)\n",type.data(),name.data());
232 QCString ltype = type.simplifyWhiteSpace();
233 QCString lname = name.simplifyWhiteSpace();
234 if (ltype.left(7)=="struct ")
236 ltype = ltype.right(ltype.length()-7);
238 else if (ltype.left(6)=="union ")
240 ltype = ltype.right(ltype.length()-6);
242 if (ltype.isEmpty() || lname.isEmpty()) return;
243 DBG_CTX((stderr,"** addVariable trying: type='%s' name='%s' g_currentDefinition=%s\n",
244 ltype.data(),lname.data(),g_currentDefinition?g_currentDefinition->name().data():"<none>"));
245 Scope *scope = m_scopes.count()==0 ? &m_globalScope : m_scopes.getLast();
249 (varType=g_codeClassSDict->find(ltype)) || // look for class definitions inside the code block
250 (varType=getResolvedClass(g_currentDefinition,g_sourceFileDef,ltype)) // look for global class definitions
253 DBG_CTX((stderr,"** addVariable type='%s' name='%s'\n",ltype.data(),lname.data()));
254 scope->append(lname,varType); // add it to a list
256 else if ((i=ltype.find('<'))!=-1)
258 // probably a template class
259 QCString typeName(ltype.left(i));
260 ClassDef* newDef = 0;
261 QCString templateArgs(ltype.right(ltype.length() - i));
263 ( // look for class definitions inside the code block
264 (varType=g_codeClassSDict->find(typeName)) ||
265 // otherwise look for global class definitions
266 (varType=getResolvedClass(g_currentDefinition,g_sourceFileDef,typeName,0,0,TRUE,TRUE))
267 ) && // and it must be a template
268 varType->templateArguments())
270 newDef = varType->getVariableInstance( templateArgs );
274 DBG_CTX((stderr,"** addVariable type='%s' templ='%s' name='%s'\n",typeName.data(),templateArgs.data(),lname.data()));
275 scope->append(lname, newDef);
279 // Doesn't seem to be a template. Try just the base name.
280 addVariable(typeName,name);
285 if (m_scopes.count()>0) // for local variables add a dummy entry so the name
286 // is hidden to avoid false links to global variables with the same name
287 // TODO: make this work for namespaces as well!
289 DBG_CTX((stderr,"** addVariable: dummy context for '%s'\n",lname.data()));
290 scope->append(lname,dummyContext);
294 DBG_CTX((stderr,"** addVariable: not adding variable!\n"));
299 ClassDef *VariableContext::findVariable(const QCString &name)
301 if (name.isEmpty()) return 0;
302 ClassDef *result = 0;
303 QListIterator<Scope> sli(m_scopes);
306 // search from inner to outer scope
307 for (sli.toLast();(scope=sli.current());--sli)
309 result = scope->find(key);
312 DBG_CTX((stderr,"** findVariable(%s)=%p\n",name.data(),result));
316 // nothing found -> also try the global scope
317 result=m_globalScope.find(name);
318 DBG_CTX((stderr,"** findVariable(%s)=%p\n",name.data(),result));
322 static VariableContext g_theVarContext;
323 const ClassDef *VariableContext::dummyContext = (ClassDef*)0x8;
325 //-------------------------------------------------------------------
332 Ctx() : name(g_name), type(g_type), cd(0) {}
340 m_classList.append(new Ctx);
341 m_classList.setAutoDelete(TRUE);
343 virtual ~CallContext() {}
344 void setClass(ClassDef *cd)
346 Ctx *ctx = m_classList.getLast();
349 DBG_CTX((stderr,"** Set call context %s (%p)\n",cd==0 ? "<null>" : cd->name().data(),cd));
355 m_classList.append(new Ctx);
356 DBG_CTX((stderr,"** Push call context %d\n",m_classList.count()));
360 if (m_classList.count()>1)
362 DBG_CTX((stderr,"** Pop call context %d\n",m_classList.count()));
363 Ctx *ctx = m_classList.getLast();
369 m_classList.removeLast();
373 DBG_CTX((stderr,"** ILLEGAL: Pop call context\n"));
378 DBG_CTX((stderr,"** Clear call context\n"));
380 m_classList.append(new Ctx);
382 ClassDef *getClass() const
384 Ctx *ctx = m_classList.getLast();
385 if (ctx) return ctx->cd; else return 0;
389 QList<Ctx> m_classList;
392 static CallContext g_theCallContext;
394 //-------------------------------------------------------------------
396 /*! add class/namespace name s to the scope */
397 static void pushScope(const char *s)
399 g_classScopeLengthStack.push(new int(g_classScope.length()));
400 if (g_classScope.isEmpty() || leftScopeMatch(s,g_classScope))
406 g_classScope += "::";
409 //printf("pushScope(%s) result: `%s'\n",s,g_classScope.data());
412 /*! remove the top class/namespace name from the scope */
413 static void popScope()
415 if (!g_classScopeLengthStack.isEmpty())
417 int *pLength = g_classScopeLengthStack.pop();
418 g_classScope.truncate(*pLength);
423 //err("Too many end of scopes found!\n");
425 //printf("popScope() result: `%s'\n",g_classScope.data());
428 static void setCurrentDoc(const QCString &anchor)
430 if (Doxygen::searchIndex)
434 g_code->setCurrentDoc(g_searchCtx,g_searchCtx->anchor(),FALSE);
438 g_code->setCurrentDoc(g_sourceFileDef,anchor,TRUE);
443 static void addToSearchIndex(const char *text)
445 if (Doxygen::searchIndex)
447 g_code->addWord(text,FALSE);
451 static void setClassScope(const QCString &name)
453 //printf("setClassScope(%s)\n",name.data());
455 n=n.simplifyWhiteSpace();
456 int ts=n.find('<'); // start of template
457 int te=n.findRev('>'); // end of template
458 //printf("ts=%d te=%d\n",ts,te);
459 if (ts!=-1 && te!=-1 && te>ts)
461 // remove template from scope
462 n=n.left(ts)+n.right(n.length()-te-1);
464 while (!g_classScopeLengthStack.isEmpty())
468 g_classScope.resize(0);
470 while ((i=n.find("::"))!=-1)
472 pushScope(n.left(i));
476 //printf("--->New class scope `%s'\n",g_classScope.data());
479 /*! start a new line of code, inserting a line number if g_sourceFileDef
480 * is TRUE. If a definition starts at the current line, then the line
481 * number is linked to the documentation of that definition.
483 static void startCodeLine()
485 //if (g_currentFontClass) { g_code->endFontClass(); }
486 if (g_sourceFileDef && g_lineNumbers)
488 //QCString lineNumber,lineAnchor;
489 //lineNumber.sprintf("%05d",g_yyLineNr);
490 //lineAnchor.sprintf("l%05d",g_yyLineNr);
492 Definition *d = g_sourceFileDef->getSourceDefinition(g_yyLineNr);
493 //printf("%s:startCodeLine(%d)=%p\n",g_sourceFileDef->name().data(),g_yyLineNr,d);
494 if (!g_includeCodeFragment && d)
496 g_currentDefinition = d;
497 g_currentMemberDef = g_sourceFileDef->getSourceMember(g_yyLineNr);
498 g_insideBody = FALSE;
499 g_searchingForBody = TRUE;
500 g_realScope = d->name();
505 g_parmType.resize(0);
506 g_parmName.resize(0);
507 //printf("Real scope: `%s'\n",g_realScope.data());
508 g_bodyCurlyCount = 0;
510 lineAnchor.sprintf("l%05d",g_yyLineNr);
511 if (g_currentMemberDef)
513 g_code->writeLineNumber(g_currentMemberDef->getReference(),
514 g_currentMemberDef->getOutputFileBase(),
515 g_currentMemberDef->anchor(),g_yyLineNr);
516 setCurrentDoc(lineAnchor);
518 else if (d->isLinkableInProject())
520 g_code->writeLineNumber(d->getReference(),
521 d->getOutputFileBase(),
523 setCurrentDoc(lineAnchor);
528 g_code->writeLineNumber(0,0,0,g_yyLineNr);
531 DBG_CTX((stderr,"startCodeLine(%d)\n",g_yyLineNr));
532 g_code->startCodeLine(g_sourceFileDef && g_lineNumbers);
533 if (g_currentFontClass)
535 g_code->startFontClass(g_currentFontClass);
540 static void endFontClass();
541 static void startFontClass(const char *s);
543 static void endCodeLine()
545 DBG_CTX((stderr,"endCodeLine(%d)\n",g_yyLineNr));
547 g_code->endCodeLine();
550 static void nextCodeLine()
552 const char * fc = g_currentFontClass;
554 if (g_yyLineNr<g_inputLines)
556 g_currentFontClass = fc;
561 /*! write a code fragment `text' that may span multiple lines, inserting
562 * line numbers for each line.
564 static void codifyLines(const char *text)
566 //printf("codifyLines(%d,\"%s\")\n",g_yyLineNr,text);
567 const char *p=text,*sp=p;
573 while ((c=*p++) && c!='\n') { g_yyColNr++; }
579 int l = (int)(p-sp-1);
580 char *tmp = (char*)malloc(l+1);
595 /*! writes a link to a fragment \a text that may span multiple lines, inserting
596 * line numbers for each line. If \a text contains newlines, the link will be
597 * split into multiple links with the same destination, one for each line.
599 static void writeMultiLineCodeLink(CodeOutputInterface &ol,
603 static bool sourceTooltips = Config_getBool("SOURCE_TOOLTIPS");
604 TooltipManager::instance()->addTooltip(d);
605 QCString ref = d->getReference();
606 QCString file = d->getOutputFileBase();
607 QCString anchor = d->anchor();
609 if (!sourceTooltips) // fall back to simple "title" tooltips
611 tooltip = d->briefDescriptionAsTooltip();
614 char *p=(char *)text;
619 while ((c=*p++) && c!='\n') { }
624 //printf("writeCodeLink(%s,%s,%s,%s)\n",ref,file,anchor,sp);
625 ol.writeCodeLink(ref,file,anchor,sp,tooltip);
630 //printf("writeCodeLink(%s,%s,%s,%s)\n",ref,file,anchor,sp);
631 ol.writeCodeLink(ref,file,anchor,sp,tooltip);
637 static void addType()
639 if (g_name=="const") { g_name.resize(0); return; }
640 if (!g_type.isEmpty()) g_type += ' ' ;
643 if (!g_type.isEmpty()) g_type += ' ' ;
648 static void addParmType()
650 if (g_parmName=="const") { g_parmName.resize(0); return; }
651 if (!g_parmType.isEmpty()) g_parmType += ' ' ;
652 g_parmType += g_parmName ;
653 g_parmName.resize(0) ;
656 static void addUsingDirective(const char *name)
658 if (g_sourceFileDef && name)
660 NamespaceDef *nd = Doxygen::namespaceSDict->find(name);
663 g_sourceFileDef->addUsingDirective(nd);
668 static void setParameterList(MemberDef *md)
670 g_classScope = md->getClassDef() ? md->getClassDef()->name().data() : "";
671 ArgumentList *al = md->argumentList();
673 ArgumentListIterator it(*al);
675 for (;(a=it.current());++it)
677 g_parmName = a->name.copy();
678 g_parmType = a->type.copy();
679 int i = g_parmType.find('*');
680 if (i!=-1) g_parmType = g_parmType.left(i);
681 i = g_parmType.find('&');
682 if (i!=-1) g_parmType = g_parmType.left(i);
683 g_parmType.stripPrefix("const ");
684 g_parmType=g_parmType.stripWhiteSpace();
685 g_theVarContext.addVariable(g_parmType,g_parmName);
689 static ClassDef *stripClassName(const char *s,Definition *d=g_currentDefinition)
695 while (extractClassNameFromType(type,pos,className,templSpec)!=-1)
697 QCString clName=className+templSpec;
699 if (!g_classScope.isEmpty())
701 cd=getResolvedClass(d,g_sourceFileDef,g_classScope+"::"+clName);
705 cd=getResolvedClass(d,g_sourceFileDef,clName);
707 //printf("stripClass trying `%s' = %p\n",clName.data(),cd);
717 static MemberDef *setCallContextForVar(const QCString &name)
719 if (name.isEmpty()) return 0;
720 DBG_CTX((stderr,"setCallContextForVar(%s) g_classScope=%s\n",name.data(),g_classScope.data()));
722 int scopeEnd = name.findRev("::");
723 if (scopeEnd!=-1) // name with explicit scope
725 QCString scope = name.left(scopeEnd);
726 QCString locName = name.right(name.length()-scopeEnd-2);
727 //printf("explicit scope: name=%s scope=%s\n",locName.data(),scope.data());
728 ClassDef *mcd = getClass(scope);
729 if (mcd && !locName.isEmpty())
731 MemberDef *md=mcd->getMemberByName(locName);
734 //printf("name=%s scope=%s\n",locName.data(),scope.data());
735 g_theCallContext.setClass(stripClassName(md->typeString(),md->getOuterScope()));
739 else // check namespace as well
741 NamespaceDef *mnd = getResolvedNamespace(scope);
742 if (mnd && !locName.isEmpty())
744 MemberDef *md=mnd->getMemberByName(locName);
747 //printf("name=%s scope=%s\n",locName.data(),scope.data());
748 g_theCallContext.setClass(stripClassName(md->typeString(),md->getOuterScope()));
756 ClassDef *mcd = g_theVarContext.findVariable(name);
757 if (mcd) // local variable
759 DBG_CTX((stderr,"local variable?\n"));
760 if (mcd!=VariableContext::dummyContext)
762 DBG_CTX((stderr,"local var `%s' mcd=%s\n",name.data(),mcd->name().data()));
763 g_theCallContext.setClass(mcd);
768 DBG_CTX((stderr,"class member? scope=%s\n",g_classScope.data()));
769 // look for a class member
770 mcd = getClass(g_classScope);
773 DBG_CTX((stderr,"Inside class %s\n",mcd->name().data()));
774 MemberDef *md=mcd->getMemberByName(name);
777 DBG_CTX((stderr,"Found member %s\n",md->name().data()));
778 if (g_scopeStack.top()!=CLASSBLOCK)
780 DBG_CTX((stderr,"class member `%s' mcd=%s\n",name.data(),mcd->name().data()));
781 g_theCallContext.setClass(stripClassName(md->typeString(),md->getOuterScope()));
788 // look for a global member
789 if ((mn=Doxygen::functionNameSDict->find(name)))
791 //printf("global var `%s'\n",name.data());
792 if (mn->count()==1) // global defined only once
794 MemberDef *md=mn->getFirst();
795 if (!md->isStatic() || md->getBodyDef()==g_sourceFileDef)
797 g_theCallContext.setClass(stripClassName(md->typeString(),md->getOuterScope()));
802 else if (mn->count()>1) // global defined more than once
804 MemberNameIterator it(*mn);
806 for (;(md=it.current());++it)
808 //printf("mn=%p md=%p md->getBodyDef()=%p g_sourceFileDef=%p\n",
810 // md->getBodyDef(),g_sourceFileDef);
812 // in case there are multiple members we could link to, we
813 // only link to members if defined in the same file or
814 // defined as external.
815 if ((!md->isStatic() || md->getBodyDef()==g_sourceFileDef) &&
816 (g_forceTagReference.isEmpty() || g_forceTagReference==md->getReference())
819 g_theCallContext.setClass(stripClassName(md->typeString(),md->getOuterScope()));
820 //printf("returning member %s in source file %s\n",md->name().data(),g_sourceFileDef->name().data());
830 static void updateCallContextForSmartPointer()
832 ClassDef *cd = g_theCallContext.getClass();
833 //printf("updateCallContextForSmartPointer() cd=%s\n",cd ? cd->name().data() : "<none>");
835 if (cd && (md=cd->isSmartPointer()))
837 ClassDef *ncd = stripClassName(md->typeString(),md->getOuterScope());
840 g_theCallContext.setClass(ncd);
841 //printf("Found smart pointer call %s->%s!\n",cd->name().data(),ncd->name().data());
846 static bool getLinkInScope(const QCString &c, // scope
847 const QCString &m, // member
848 const char *memberText, // exact text
849 CodeOutputInterface &ol,
859 DBG_CTX((stderr,"getLinkInScope: trying `%s'::`%s' varOnly=%d\n",c.data(),m.data(),varOnly));
860 if (getDefs(c,m,"()",md,cd,fd,nd,gd,FALSE,g_sourceFileDef,FALSE,g_forceTagReference) &&
861 md->isLinkable() && (!varOnly || md->isVariable()))
863 //printf("found it %s!\n",md->qualifiedName().data());
867 anchor.sprintf("a%d",g_anchorCount);
868 //printf("addExampleFile(%s,%s,%s)\n",anchor.data(),g_exampleName.data(),
869 // g_exampleFile.data());
870 if (md->addExample(anchor,g_exampleName,g_exampleFile))
872 ol.writeCodeAnchor(anchor);
877 Definition *d = md->getOuterScope()==Doxygen::globalScope ?
878 md->getFileDef() : md->getOuterScope();
879 if (md->getGroupDef()) d = md->getGroupDef();
880 if (d && d->isLinkable())
882 g_theCallContext.setClass(stripClassName(md->typeString(),md->getOuterScope()));
883 //printf("g_currentDefinition=%p g_currentMemberDef=%p g_insideBody=%d\n",
884 // g_currentDefinition,g_currentMemberDef,g_insideBody);
886 if (g_currentDefinition && g_currentMemberDef &&
887 md!=g_currentMemberDef && g_insideBody && g_collectXRefs)
889 addDocCrossReference(g_currentMemberDef,md);
891 //printf("d->getReference()=`%s' d->getOutputBase()=`%s' name=`%s' member name=`%s'\n",d->getReference().data(),d->getOutputFileBase().data(),d->name().data(),md->name().data());
893 writeMultiLineCodeLink(ol,md, text ? text : memberText);
894 addToSearchIndex(text ? text : memberText);
901 static bool getLink(const char *className,
902 const char *memberName,
903 CodeOutputInterface &ol,
907 //printf("getLink(%s,%s) g_curClassName=%s\n",className,memberName,g_curClassName.data());
908 QCString m=removeRedundantWhiteSpace(memberName);
909 QCString c=className;
910 if (!getLinkInScope(c,m,memberName,ol,text,varOnly))
912 if (!g_curClassName.isEmpty())
914 if (!c.isEmpty()) c.prepend("::");
915 c.prepend(g_curClassName);
916 return getLinkInScope(c,m,memberName,ol,text,varOnly);
923 static void generateClassOrGlobalLink(CodeOutputInterface &ol,const char *clName,
924 bool typeOnly=FALSE,bool varOnly=FALSE)
927 if (*clName=='~') // correct for matching negated values i.s.o. destructors.
932 QCString className=clName;
933 if (className.isEmpty()) return;
934 if (g_insideProtocolList) // for Obj-C
940 className = substitute(className,"\\","::"); // for PHP namespaces
942 else if (g_insideCS || g_insideJava)
944 className = substitute(className,".","::"); // for PHP namespaces
946 ClassDef *cd=0,*lcd=0;
950 //printf("generateClassOrGlobalLink(className=%s)\n",className.data());
951 if ((lcd=g_theVarContext.findVariable(className))==0) // not a local variable
953 Definition *d = g_currentDefinition;
954 //printf("d=%s g_sourceFileDef=%s\n",d?d->name().data():"<none>",g_sourceFileDef?g_sourceFileDef->name().data():"<none>");
955 cd = getResolvedClass(d,g_sourceFileDef,className,&md);
956 DBG_CTX((stderr,"non-local variable name=%s context=%d cd=%s md=%s!\n",
957 className.data(),g_theVarContext.count(),cd?cd->name().data():"<none>",
958 md?md->name().data():"<none>"));
959 if (cd==0 && md==0 && (i=className.find('<'))!=-1)
961 QCString bareName = className.left(i); //stripTemplateSpecifiersFromScope(className);
962 DBG_CTX((stderr,"bareName=%s\n",bareName.data()));
963 if (bareName!=className)
965 cd=getResolvedClass(d,g_sourceFileDef,bareName,&md); // try unspecialized version
968 //printf("md=%s\n",md?md->name().data():"<none>");
969 DBG_CTX((stderr,"is found as a type %s\n",cd?cd->name().data():"<null>"));
970 if (cd==0 && md==0) // also see if it is variable or enum or enum value
972 if (getLink(g_classScope,clName,ol,clName,varOnly))
980 //printf("local variable!\n");
981 if (lcd!=VariableContext::dummyContext)
983 //printf("non-dummy context lcd=%s!\n",lcd->name().data());
984 g_theCallContext.setClass(lcd);
986 // to following is needed for links to a global variable, but is
987 // no good for a link to a local variable that is also a global symbol.
989 //if (getLink(g_classScope,clName,ol,clName))
995 DBG_CTX((stderr,"is a local variable cd=%p!\n",cd));
997 if (cd && cd->isLinkable()) // is it a linkable class
999 DBG_CTX((stderr,"is linkable class %s\n",clName));
1003 anchor.sprintf("_a%d",g_anchorCount);
1004 //printf("addExampleClass(%s,%s,%s)\n",anchor.data(),g_exampleName.data(),
1005 // g_exampleFile.data());
1006 if (cd->addExample(anchor,g_exampleName,g_exampleFile))
1008 ol.writeCodeAnchor(anchor);
1012 writeMultiLineCodeLink(ol,cd,clName);
1013 addToSearchIndex(className);
1014 g_theCallContext.setClass(cd);
1017 Definition *d = md->getOuterScope()==Doxygen::globalScope ?
1018 md->getFileDef() : md->getOuterScope();
1019 if (md->getGroupDef()) d = md->getGroupDef();
1020 if (d && d->isLinkable() && md->isLinkable() &&
1021 g_currentMemberDef && g_collectXRefs)
1023 addDocCrossReference(g_currentMemberDef,md);
1027 else // not a class, maybe a global member
1029 DBG_CTX((stderr,"class %s not linkable! cd=%p md=%p typeOnly=%d\n",clName,cd,md,typeOnly));
1030 if (!isLocal && (md!=0 || (cd==0 && !typeOnly))) // not a class, see if it is a global enum/variable/typedef.
1032 if (md==0) // not found as a typedef
1034 md = setCallContextForVar(clName);
1035 //printf("setCallContextForVar(%s) md=%p g_currentDefinition=%p\n",clName,md,g_currentDefinition);
1036 if (md && g_currentDefinition)
1038 DBG_CTX((stderr,"%s accessible from %s? %d md->getOuterScope=%s\n",
1039 md->name().data(),g_currentDefinition->name().data(),
1040 isAccessibleFrom(g_currentDefinition,g_sourceFileDef,md),
1041 md->getOuterScope()->name().data()));
1044 if (md && g_currentDefinition &&
1045 isAccessibleFrom(g_currentDefinition,g_sourceFileDef,md)==-1)
1047 md=0; // variable not accessible
1050 if (md && (!varOnly || md->isVariable()))
1052 DBG_CTX((stderr,"is a global md=%p g_currentDefinition=%s linkable=%d\n",md,g_currentDefinition?g_currentDefinition->name().data():"<none>",md->isLinkable()));
1053 if (md->isLinkable())
1056 if (!g_forceTagReference.isEmpty()) // explicit reference to symbol in tag file
1058 text=g_forceTagReference;
1059 if (text.right(4)==".tag") // strip .tag if present
1061 text=text.left(text.length()-4);
1063 text+=getLanguageSpecificSeparator(md->getLanguage());
1066 md->setLocalName(text);
1068 else // normal reference
1072 writeMultiLineCodeLink(ol,md,text);
1073 addToSearchIndex(clName);
1074 if (g_currentMemberDef && g_collectXRefs)
1076 addDocCrossReference(g_currentMemberDef,md);
1083 // nothing found, just write out the word
1084 DBG_CTX((stderr,"not found!\n"));
1085 codifyLines(clName);
1086 addToSearchIndex(clName);
1090 static bool generateClassMemberLink(CodeOutputInterface &ol,MemberDef *xmd,const char *memName)
1092 // extract class definition of the return type in order to resolve
1093 // a->b()->c() like call chains
1095 //printf("type=`%s' args=`%s' class=%s\n",
1096 // xmd->typeString(),xmd->argsString(),
1097 // xmd->getClassDef()->name().data());
1102 anchor.sprintf("a%d",g_anchorCount);
1103 //printf("addExampleFile(%s,%s,%s)\n",anchor.data(),g_exampleName.data(),
1104 // g_exampleFile.data());
1105 if (xmd->addExample(anchor,g_exampleName,g_exampleFile))
1107 ol.writeCodeAnchor(anchor);
1112 ClassDef *typeClass = stripClassName(removeAnonymousScopes(xmd->typeString()),xmd->getOuterScope());
1113 DBG_CTX((stderr,"%s -> typeName=%p\n",xmd->typeString(),typeClass));
1114 g_theCallContext.setClass(typeClass);
1116 Definition *xd = xmd->getOuterScope()==Doxygen::globalScope ?
1117 xmd->getFileDef() : xmd->getOuterScope();
1118 if (xmd->getGroupDef()) xd = xmd->getGroupDef();
1119 if (xd && xd->isLinkable())
1122 //printf("g_currentDefiniton=%p g_currentMemberDef=%p xmd=%p g_insideBody=%d\n",g_currentDefinition,g_currentMemberDef,xmd,g_insideBody);
1124 if (xmd->templateMaster()) xmd = xmd->templateMaster();
1126 if (xmd->isLinkable())
1128 // add usage reference
1129 if (g_currentDefinition && g_currentMemberDef &&
1130 /*xmd!=g_currentMemberDef &&*/ g_insideBody && g_collectXRefs)
1132 addDocCrossReference(g_currentMemberDef,xmd);
1135 // write the actual link
1136 writeMultiLineCodeLink(ol,xmd,memName);
1137 addToSearchIndex(memName);
1145 static bool generateClassMemberLink(CodeOutputInterface &ol,ClassDef *mcd,const char *memName)
1149 MemberDef *xmd = mcd->getMemberByName(memName);
1150 //printf("generateClassMemberLink(class=%s,member=%s)=%p\n",mcd->name().data(),memName,xmd);
1153 return generateClassMemberLink(ol,xmd,memName);
1160 static void generateMemberLink(CodeOutputInterface &ol,const QCString &varName,
1163 //printf("generateMemberLink(object=%s,mem=%s) classScope=%s\n",
1164 // varName.data(),memName,g_classScope.data());
1166 if (varName.isEmpty()) return;
1168 // look for the variable in the current context
1169 ClassDef *vcd = g_theVarContext.findVariable(varName);
1172 if (vcd!=VariableContext::dummyContext)
1174 //printf("Class found!\n");
1175 if (getLink(vcd->name(),memName,ol))
1177 //printf("Found result!\n");
1180 if (vcd->baseClasses())
1182 BaseClassListIterator bcli(*vcd->baseClasses());
1183 for ( ; bcli.current() ; ++bcli)
1185 if (getLink(bcli.current()->classDef->name(),memName,ol))
1187 //printf("Found result!\n");
1194 else // variable not in current context, maybe it is in a parent context
1196 vcd = getResolvedClass(g_currentDefinition,g_sourceFileDef,g_classScope);
1197 if (vcd && vcd->isLinkable())
1199 //printf("Found class %s for variable `%s'\n",g_classScope.data(),varName.data());
1200 MemberName *vmn=Doxygen::memberNameSDict->find(varName);
1204 QCString vn=varName;
1206 if ((vi=vn.findRev("::"))!=-1 || (vi=vn.findRev('.'))!=-1) // explicit scope A::b(), probably static member
1208 ClassDef *jcd = getClass(vn.left(vi));
1209 vn=vn.right(vn.length()-vi-2);
1210 vmn=Doxygen::memberNameSDict->find(vn);
1211 //printf("Trying name `%s' scope=%s\n",vn.data(),scope.data());
1214 MemberNameIterator vmni(*vmn);
1216 for (;(vmd=vmni.current());++vmni)
1218 if (/*(vmd->isVariable() || vmd->isFunction()) && */
1219 vmd->getClassDef()==jcd)
1221 //printf("Found variable type=%s\n",vmd->typeString());
1222 ClassDef *mcd=stripClassName(vmd->typeString(),vmd->getOuterScope());
1223 if (mcd && mcd->isLinkable())
1225 if (generateClassMemberLink(ol,mcd,memName)) return;
1234 //printf("There is a variable with name `%s'\n",varName);
1235 MemberNameIterator vmni(*vmn);
1237 for (;(vmd=vmni.current());++vmni)
1239 if (/*(vmd->isVariable() || vmd->isFunction()) && */
1240 vmd->getClassDef()==vcd)
1242 //printf("Found variable type=%s\n",vmd->typeString());
1243 ClassDef *mcd=stripClassName(vmd->typeString(),vmd->getOuterScope());
1244 if (mcd && mcd->isLinkable())
1246 if (generateClassMemberLink(ol,mcd,memName)) return;
1253 // nothing found -> write result as is
1254 codifyLines(memName);
1255 addToSearchIndex(memName);
1259 static void generatePHPVariableLink(CodeOutputInterface &ol,const char *varName)
1261 QCString name = varName+7; // strip $this->
1263 //printf("generatePHPVariableLink(%s) name=%s scope=%s\n",varName,name.data(),g_classScope.data());
1264 if (!getLink(g_classScope,name,ol,varName))
1266 codifyLines(varName);
1270 static void generateFunctionLink(CodeOutputInterface &ol,const char *funcName)
1272 //CodeClassDef *ccd=0;
1274 QCString locScope=g_classScope;
1275 QCString locFunc=removeRedundantWhiteSpace(funcName);
1277 QCString funcWithScope=locFunc;
1278 QCString funcWithFullScope=locFunc;
1279 QCString fullScope=locScope;
1280 DBG_CTX((stdout,"*** locScope=%s locFunc=%s\n",locScope.data(),locFunc.data()));
1282 int i=locFunc.findRev("::");
1283 if (g_currentMemberDef && g_currentMemberDef->getClassDef() &&
1284 funcName==g_currentMemberDef->localName() &&
1285 g_currentMemberDef->getDefLine()==g_yyLineNr &&
1286 generateClassMemberLink(ol,g_currentMemberDef,funcName)
1289 // special case where funcName is the name of a method that is also
1290 // defined on this line. In this case we can directly link to
1291 // g_currentMemberDef, which is not only faster, but
1292 // in case of overloaded methods, this will make sure that we link to
1293 // the correct method, and thereby get the correct reimplemented relations.
1294 // See also bug 549022.
1297 if (i==-1) i=locFunc.findRev("."),len=1;
1298 if (i==-1) i=locFunc.findRev("\\"),len=1; // for PHP
1301 funcScope=locFunc.left(i);
1302 locFunc=locFunc.right(locFunc.length()-i-len).stripWhiteSpace();
1303 int ts=locScope.find('<'); // start of template
1304 int te=locScope.findRev('>'); // end of template
1305 //printf("ts=%d te=%d\n",ts,te);
1306 if (ts!=-1 && te!=-1 && te>ts)
1308 // remove template from scope
1309 locScope=locScope.left(ts)+locScope.right(locScope.length()-te-1);
1311 ts=funcScope.find('<'); // start of template
1312 te=funcScope.findRev('>'); // end of template
1313 //printf("ts=%d te=%d\n",ts,te);
1314 if (ts!=-1 && te!=-1 && te>ts)
1316 // remove template from scope
1317 funcScope=funcScope.left(ts)+funcScope.right(funcScope.length()-te-1);
1319 if (!funcScope.isEmpty())
1321 funcWithScope = funcScope+"::"+locFunc;
1322 if (!locScope.isEmpty())
1324 fullScope=locScope+"::"+funcScope;
1327 if (!locScope.isEmpty())
1329 funcWithFullScope = locScope+"::"+funcWithScope;
1332 if (!fullScope.isEmpty() && (ccd=g_codeClassSDict->find(fullScope)))
1334 //printf("using classScope %s\n",g_classScope.data());
1335 if (ccd->baseClasses())
1337 BaseClassListIterator bcli(*ccd->baseClasses());
1338 for ( ; bcli.current() ; ++bcli)
1340 if (getLink(bcli.current()->classDef->name(),locFunc,ol,funcName))
1347 if (!locScope.isEmpty() && fullScope!=locScope && (ccd=g_codeClassSDict->find(locScope)))
1349 //printf("using classScope %s\n",g_classScope.data());
1350 if (ccd->baseClasses())
1352 BaseClassListIterator bcli(*ccd->baseClasses());
1353 for ( ; bcli.current() ; ++bcli)
1355 if (getLink(bcli.current()->classDef->name(),funcWithScope,ol,funcName))
1362 if (!getLink(locScope,funcWithScope,ol,funcName))
1364 generateClassOrGlobalLink(ol,funcName);
1367 g_forceTagReference.resize(0);
1371 /*! counts the number of lines in the input */
1372 static int countLines()
1374 const char *p=g_inputString;
1380 if (c=='\n') count++;
1382 if (p>g_inputString && *(p-1)!='\n')
1383 { // last line does not end with a \n, so we add an extra
1384 // line and explicitly terminate the line after parsing.
1386 g_needsTermination=TRUE;
1391 static void endFontClass()
1393 if (g_currentFontClass)
1395 g_code->endFontClass();
1396 g_currentFontClass=0;
1400 static void startFontClass(const char *s)
1403 g_code->startFontClass(s);
1404 g_currentFontClass=s;
1407 //----------------------------------------------------------------------------
1409 // recursively writes a linkified Objective-C method call
1410 static void writeObjCMethodCall(ObjCCallCtx *ctx)
1414 const char *p = ctx->format.data();
1415 if (!ctx->methodName.isEmpty())
1417 //printf("writeObjCMethodCall(%s) obj=%s method=%s\n",
1418 // ctx->format.data(),ctx->objectTypeOrName.data(),ctx->methodName.data());
1419 if (!ctx->objectTypeOrName.isEmpty() && ctx->objectTypeOrName.at(0)!='$')
1421 //printf("Looking for object=%s method=%s\n",ctx->objectTypeOrName.data(),
1422 // ctx->methodName.data());
1423 ClassDef *cd = g_theVarContext.findVariable(ctx->objectTypeOrName);
1424 if (cd==0) // not a local variable
1426 if (ctx->objectTypeOrName=="self")
1428 if (g_currentDefinition &&
1429 g_currentDefinition->definitionType()==Definition::TypeClass)
1431 ctx->objectType = (ClassDef *)g_currentDefinition;
1436 ctx->objectType = getResolvedClass(
1437 g_currentDefinition,
1439 ctx->objectTypeOrName,
1442 //printf(" object is class? %p\n",ctx->objectType);
1443 if (ctx->objectType) // found class
1445 ctx->method = ctx->objectType->getMemberByName(ctx->methodName);
1446 //printf(" yes->method=%s\n",ctx->method?ctx->method->name().data():"<none>");
1448 else if (ctx->method==0) // search for class variable with the same name
1451 //printf("g_currentDefinition=%p\n",g_currentDefinition);
1452 if (g_currentDefinition &&
1453 g_currentDefinition->definitionType()==Definition::TypeClass)
1455 ctx->objectVar = ((ClassDef *)g_currentDefinition)->getMemberByName(ctx->objectTypeOrName);
1456 //printf(" ctx->objectVar=%p\n",ctx->objectVar);
1459 ctx->objectType = stripClassName(ctx->objectVar->typeString());
1460 //printf(" ctx->objectType=%p\n",ctx->objectType);
1461 if (ctx->objectType)
1463 ctx->method = ctx->objectType->getMemberByName(ctx->methodName);
1464 //printf(" ctx->method=%p\n",ctx->method);
1470 else // local variable
1472 //printf(" object is local variable\n");
1473 if (cd!=VariableContext::dummyContext)
1475 ctx->method = cd->getMemberByName(ctx->methodName);
1476 //printf(" class=%p method=%p\n",cd,ctx->method);
1483 while ((c=*p++)) // for each character in ctx->format
1488 if (nc=='$') // escaped $
1490 g_code->codify("$");
1492 else // name fragment or reference to a nested call
1494 if (nc=='n') // name fragment
1498 while (nc!=0 && isdigit(nc)) { refIdStr+=nc; nc=*p++; }
1500 int refId=refIdStr.toInt();
1501 QCString *pName = g_nameDict.find(refId);
1504 if (ctx->method && ctx->method->isLinkable())
1506 writeMultiLineCodeLink(*g_code,ctx->method,pName->data());
1507 if (g_currentMemberDef && g_collectXRefs)
1509 addDocCrossReference(g_currentMemberDef,ctx->method);
1514 codifyLines(pName->data());
1519 //printf("Invalid name: id=%d\n",refId);
1522 else if (nc=='o') // reference to potential object name
1526 while (nc!=0 && isdigit(nc)) { refIdStr+=nc; nc=*p++; }
1528 int refId=refIdStr.toInt();
1529 QCString *pObject = g_objectDict.find(refId);
1532 if (*pObject=="self")
1534 if (g_currentDefinition &&
1535 g_currentDefinition->definitionType()==Definition::TypeClass)
1537 ctx->objectType = (ClassDef *)g_currentDefinition;
1538 if (ctx->objectType->categoryOf())
1540 ctx->objectType = ctx->objectType->categoryOf();
1542 if (ctx->objectType)
1544 ctx->method = ctx->objectType->getMemberByName(ctx->methodName);
1547 startFontClass("keyword");
1548 codifyLines(pObject->data());
1551 else if (*pObject=="super")
1553 if (g_currentDefinition &&
1554 g_currentDefinition->definitionType()==Definition::TypeClass)
1556 ClassDef *cd = (ClassDef *)g_currentDefinition;
1557 if (cd->categoryOf())
1559 cd = cd->categoryOf();
1561 BaseClassList *bcd = cd->baseClasses();
1562 if (bcd) // get direct base class (there should be only one)
1564 BaseClassListIterator bli(*bcd);
1565 BaseClassDef *bclass;
1566 for (bli.toFirst();(bclass=bli.current());++bli)
1568 if (bclass->classDef->compoundType()!=ClassDef::Protocol)
1570 ctx->objectType = bclass->classDef;
1571 if (ctx->objectType)
1573 ctx->method = ctx->objectType->getMemberByName(ctx->methodName);
1579 startFontClass("keyword");
1580 codifyLines(pObject->data());
1583 else if (ctx->objectVar && ctx->objectVar->isLinkable()) // object is class variable
1585 writeMultiLineCodeLink(*g_code,ctx->objectVar,pObject->data());
1586 if (g_currentMemberDef && g_collectXRefs)
1588 addDocCrossReference(g_currentMemberDef,ctx->objectVar);
1591 else if (ctx->objectType &&
1592 ctx->objectType!=VariableContext::dummyContext &&
1593 ctx->objectType->isLinkable()
1594 ) // object is class name
1596 ClassDef *cd = ctx->objectType;
1597 writeMultiLineCodeLink(*g_code,cd,pObject->data());
1599 else // object still needs to be resolved
1601 ClassDef *cd = getResolvedClass(g_currentDefinition,
1602 g_sourceFileDef, *pObject);
1603 if (cd && cd->isLinkable())
1605 if (ctx->objectType==0) ctx->objectType=cd;
1606 writeMultiLineCodeLink(*g_code,cd,pObject->data());
1610 codifyLines(pObject->data());
1616 //printf("Invalid object: id=%d\n",refId);
1619 else if (nc=='c') // reference to nested call
1623 while (nc!=0 && isdigit(nc)) { refIdStr+=nc; nc=*p++; }
1625 int refId=refIdStr.toInt();
1626 ObjCCallCtx *ictx = g_contextDict.find(refId);
1627 if (ictx) // recurse into nested call
1629 writeObjCMethodCall(ictx);
1630 if (ictx->method) // link to nested call successfully
1632 // get the ClassDef representing the method's return type
1633 if (QCString(ictx->method->typeString())=="id")
1635 // see if the method name is unique, if so we link to it
1636 MemberName *mn=Doxygen::memberNameSDict->find(ctx->methodName);
1637 //printf("mn->count=%d ictx->method=%s ctx->methodName=%s\n",
1638 // mn==0?-1:(int)mn->count(),
1639 // ictx->method->name().data(),
1640 // ctx->methodName.data());
1641 if (mn && mn->count()==1) // member name unique
1643 ctx->method = mn->getFirst();
1648 ctx->objectType = stripClassName(ictx->method->typeString());
1649 if (ctx->objectType)
1651 ctx->method = ctx->objectType->getMemberByName(ctx->methodName);
1654 //printf(" ***** method=%s -> object=%p\n",ictx->method->name().data(),ctx->objectType);
1659 //printf("Invalid context: id=%d\n",refId);
1662 else if (nc=='w') // some word
1666 while (nc!=0 && isdigit(nc)) { refIdStr+=nc; nc=*p++; }
1668 int refId=refIdStr.toInt();
1669 QCString *pWord = g_wordDict.find(refId);
1672 codifyLines(pWord->data());
1675 else // illegal marker
1677 ASSERT(!"invalid escape sequence");
1681 else // normal non-marker character
1688 //printf("%s %s]\n",ctx->objectTypeOrName.data(),ctx->methodName.data());
1689 //printf("}=(type='%s',name='%s')",
1690 // ctx->objectTypeOrName.data(),
1691 // ctx->methodName.data());
1694 // Replaces an Objective-C method name fragment s by a marker of the form
1695 // $n12, the number (12) can later be used as a key for obtaining the name
1696 // fragment, from g_nameDict
1697 static QCString escapeName(const char *s)
1700 result.sprintf("$n%d",g_currentNameId);
1701 g_nameDict.insert(g_currentNameId,new QCString(s));
1706 static QCString escapeObject(const char *s)
1709 result.sprintf("$o%d",g_currentObjId);
1710 g_objectDict.insert(g_currentObjId,new QCString(s));
1715 static QCString escapeWord(const char *s)
1718 result.sprintf("$w%d",g_currentWordId);
1719 g_wordDict.insert(g_currentWordId,new QCString(s));
1724 /* -----------------------------------------------------------------
1727 #define YY_INPUT(buf,result,max_size) result=yyread(buf,max_size);
1729 static int yyread(char *buf,int max_size)
1732 while( c < max_size && g_inputString[g_inputPosition] )
1734 *buf = g_inputString[g_inputPosition++] ;
1744 ID "$"?[a-z_A-Z\x80-\xFF][a-z_A-Z0-9\x80-\xFF]*
1747 SCOPENAME ({SEP}{BN}*)?({ID}{BN}*{SEP}{BN}*)*("~"{BN}*)?{ID}
1748 SCOPENAMECS ({SEPCS}{BN}*)?({ID}{BN}*{SEPCS}{BN}*)*("~"{BN}*)?{ID}
1749 TEMPLIST "<"[^\"\}\{\(\)\/\n\>]*">"
1750 SCOPETNAME (((({ID}{TEMPLIST}?){BN}*)?{SEP}{BN}*)*)((~{BN}*)?{ID})
1751 SCOPEPREFIX ({ID}{TEMPLIST}?{BN}*{SEP}{BN}*)+
1752 KEYWORD_OBJC ("@public"|"@private"|"@protected"|"@class"|"@implementation"|"@interface"|"@end"|"@selector"|"@protocol"|"@optional"|"@required"|"@throw"|"@synthesize"|"@property")
1753 KEYWORD ("asm"|"__assume"|"auto"|"class"|"const"|"delete"|"enum"|"explicit"|"extern"|"false"|"friend"|"gcnew"|"gcroot"|"get"|"inline"|"internal"|"mutable"|"namespace"|"new"|"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"|"final"|"import"|"synchronized"|"transient"|"alignas"|"alignof"|{KEYWORD_OBJC})
1754 FLOWKW ("break"|"case"|"catch"|"continue"|"default"|"do"|"else"|"finally"|"for"|"foreach"|"for each"|"goto"|"if"|"return"|"switch"|"throw"|"throws"|"try"|"while"|"@try"|"@catch"|"@finally")
1755 TYPEKW ("bool"|"char"|"double"|"float"|"int"|"long"|"object"|"short"|"signed"|"unsigned"|"void"|"wchar_t"|"size_t"|"boolean"|"id"|"SEL"|"string"|"nullptr")
1756 CASTKW ("const_cast"|"dynamic_cast"|"reinterpret_cast"|"static_cast")
1757 CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^' \\\n]{1,4}"'"))
1758 ARITHOP "+"|"-"|"/"|"*"|"%"|"--"|"++"
1759 ASSIGNOP "="|"*="|"/="|"%="|"+="|"-="|"<<="|">>="|"&="|"^="|"|="
1760 LOGICOP "=="|"!="|">"|"<"|">="|"<="|"&&"|"||"|"!"
1761 BITOP "&"|"|"|"^"|"<<"|">>"|"~"
1762 OPERATOR {ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}
1763 RAWBEGIN (u|U|L|u8)?R\"[^ \t\(\)\\]{0,16}"("
1764 RAWEND ")"[^ \t\(\)\\]{0,16}\"
1774 %x RemoveSpecialCComment
1775 %x StripSpecialCComment
1786 %x CppCliTypeModifierFollowup
1807 <Body>^([ \t]*"#"[ \t]*("include"|"import")[ \t]*)("<"|"\"") {
1808 startFontClass("preprocessor");
1809 g_code->codify(yytext);
1810 BEGIN( ReadInclude );
1812 <Body>("@interface"|"@implementation"|"@protocol")[ \t\n]+ {
1814 startFontClass("keyword");
1815 codifyLines(yytext);
1817 if (!g_insideTemplate)
1820 <Body>(("public"|"private"){B}+)?("ref"|"value"|"interface"|"enum"){B}+("class"|"struct") {
1821 if (g_insideTemplate) REJECT;
1822 startFontClass("keyword");
1823 codifyLines(yytext);
1827 <Body>"property"|"event"/{BN}* {
1828 if (g_insideTemplate) REJECT;
1829 startFontClass("keyword");
1830 codifyLines(yytext);
1833 <Body>(KEYWORD_CPPCLI_DATATYPE|("partial"{B}+)?"class"|"struct"|"union"|"namespace"|"interface"){B}+ {
1834 startFontClass("keyword");
1835 codifyLines(yytext);
1837 if (!g_insideTemplate)
1840 <Body>("package")[ \t\n]+ {
1841 startFontClass("keyword");
1842 codifyLines(yytext);
1844 BEGIN( PackageName );
1847 if (!g_insideObjC) REJECT;
1848 codifyLines(yytext);
1851 <Body,ClassVar,Bases>"-"|"+" {
1852 if (!g_insideObjC || g_insideBody)
1854 g_code->codify(yytext);
1856 else // Start of Objective-C method
1858 //printf("Method!\n");
1859 g_code->codify(yytext);
1864 g_code->codify(yytext);
1868 g_code->codify(yytext);
1869 BEGIN(ObjCParamType);
1871 <ObjCParams,ObjCMethod>";"|"{" {
1872 g_code->codify(yytext);
1876 if (g_searchingForBody)
1878 g_searchingForBody=FALSE;
1881 if (g_insideBody) g_bodyCurlyCount++;
1882 if (!g_curClassName.isEmpty()) // valid class name
1884 pushScope(g_curClassName);
1885 DBG_CTX((stderr,"** scope stack push SCOPEBLOCK\n"));
1886 g_scopeStack.push(SCOPEBLOCK);
1893 <ObjCParams>{ID}{B}*":" {
1894 g_code->codify(yytext);
1896 <ObjCParamType>{TYPEKW} {
1897 startFontClass("keywordtype");
1898 g_code->codify(yytext);
1902 <ObjCParamType>{ID} {
1903 generateClassOrGlobalLink(*g_code,yytext);
1906 <ObjCParamType>")" {
1907 g_code->codify(yytext);
1911 g_code->codify(yytext);
1913 g_theVarContext.addVariable(g_parmType,g_parmName);
1914 g_parmType.resize(0);g_parmName.resize(0);
1916 <ObjCMethod,ObjCParams,ObjCParamType>{ID} {
1917 generateClassOrGlobalLink(*g_code,yytext);
1919 <ObjCMethod,ObjCParams,ObjCParamType>. {
1920 g_code->codify(yytext);
1922 <ObjCMethod,ObjCParams,ObjCParamType>\n {
1923 codifyLines(yytext);
1925 <ReadInclude>[^\n\"\>]+/(">"|"\"") {
1929 //QCString absPath = yytext;
1930 //if (g_sourceFileDef && QDir::isRelativePath(absPath))
1932 // absPath = QDir::cleanDirPath(g_sourceFileDef->getPath()+"/"+absPath);
1935 FileDef *fd=findFileDef(Doxygen::inputNameDict,yytext,ambig);
1936 //printf("looking for include %s -> %s fd=%p\n",yytext,absPath.data(),fd);
1937 if (fd && fd->isLinkable())
1939 if (ambig) // multiple input files match the name
1941 //printf("===== yes %s is ambiguous\n",yytext);
1942 QCString name = QDir::cleanDirPath(yytext).utf8();
1943 if (!name.isEmpty() && g_sourceFileDef)
1945 FileName *fn = Doxygen::inputNameDict->find(name);
1948 FileNameIterator fni(*fn);
1949 // for each include name
1950 for (fni.toFirst();!found && (fd=fni.current());++fni)
1952 // see if this source file actually includes the file
1953 found = g_sourceFileDef->isIncluded(fd->absFilePath());
1954 //printf(" include file %s found=%d\n",fd->absFilePath().data(),found);
1959 else // not ambiguous
1964 //printf(" include file %s found=%d\n",fd ? fd->absFilePath().data() : "<none>",found);
1967 writeMultiLineCodeLink(*g_code,fd,yytext);
1971 g_code->codify(yytext);
1976 g_code->codify(text);
1980 <Body,Bases>^[ \t]*"#" {
1981 startFontClass("preprocessor");
1982 g_lastSkipCppContext = YY_START;
1983 g_code->codify(yytext);
1987 g_code->codify(yytext);
1989 <SkipCPP>[^\n\/\\]+ {
1990 g_code->codify(yytext);
1992 <SkipCPP>\\[\r]?\n {
1993 codifyLines(yytext);
1996 g_code->codify(yytext);
1998 <Body,FuncCall>"{" {
1999 g_theVarContext.pushScope();
2001 DBG_CTX((stderr,"** scope stack push INNERBLOCK\n"));
2002 g_scopeStack.push(INNERBLOCK);
2004 if (g_searchingForBody)
2006 g_searchingForBody=FALSE;
2009 g_code->codify(yytext);
2019 <Body,MemberCall,MemberCall2>"}" {
2020 g_theVarContext.popScope();
2024 int *scope = g_scopeStack.pop();
2025 DBG_CTX((stderr,"** scope stack pop SCOPEBLOCK=%d\n",scope==SCOPEBLOCK));
2026 if (scope==SCOPEBLOCK || scope==CLASSBLOCK)
2031 g_code->codify(yytext);
2033 DBG_CTX((stderr,"g_bodyCurlyCount=%d\n",g_bodyCurlyCount));
2034 if (--g_bodyCurlyCount<=0)
2037 g_currentMemberDef=0;
2038 if (g_currentDefinition)
2039 g_currentDefinition=g_currentDefinition->getOuterScope();
2043 <Body,ClassVar>"@end" {
2044 //printf("End of objc scope fd=%s\n",g_sourceFileDef->name().data());
2045 if (g_sourceFileDef)
2047 FileDef *fd=g_sourceFileDef;
2048 g_insideObjC = fd->name().lower().right(2)==".m" ||
2049 fd->name().lower().right(3)==".mm";
2050 //printf("insideObjC=%d\n",g_insideObjC);
2054 g_insideObjC = FALSE;
2058 g_theVarContext.popScope();
2060 int *scope = g_scopeStack.pop();
2061 DBG_CTX((stderr,"** scope stack pop SCOPEBLOCK=%d\n",scope==SCOPEBLOCK));
2062 if (scope==SCOPEBLOCK || scope==CLASSBLOCK)
2069 startFontClass("keyword");
2070 g_code->codify(yytext);
2073 g_currentMemberDef=0;
2074 if (g_currentDefinition)
2075 g_currentDefinition=g_currentDefinition->getOuterScope();
2078 <ClassName,ClassVar>";" {
2079 g_code->codify(yytext);
2080 g_searchingForBody=FALSE;
2083 <ClassName,ClassVar>[*&^%]+ {
2084 g_type=g_curClassName.copy();
2086 g_code->codify(yytext);
2087 BEGIN( Body ); // variable of type struct *
2089 <ClassName>"__declspec"{B}*"("{B}*{ID}{B}*")" {
2090 startFontClass("keyword");
2091 g_code->codify(yytext);
2094 <ClassName>{ID}("::"{ID})* {
2095 g_curClassName=yytext;
2097 if (g_curClassName=="alignas")
2099 startFontClass("keyword");
2100 g_code->codify(yytext);
2106 generateClassOrGlobalLink(*g_code,yytext);
2112 g_code->codify(yytext);
2113 BEGIN( AlignAsEnd );
2115 <AlignAs>\n { g_yyLineNr++;
2116 codifyLines(yytext);
2118 <AlignAs>. { g_code->codify(yytext); }
2119 <AlignAsEnd>"(" { g_code->codify(yytext);
2123 g_code->codify(yytext);
2124 if (--g_bracketCount<=0)
2129 <AlignAsEnd>\n { g_yyLineNr++;
2130 codifyLines(yytext);
2132 <AlignAsEnd>. { g_code->codify(yytext); }
2133 <ClassName>{ID}("\\"{ID})* { // PHP namespace
2134 g_curClassName=substitute(yytext,"\\","::");
2135 g_scopeStack.push(CLASSBLOCK);
2136 pushScope(g_curClassName);
2138 generateClassOrGlobalLink(*g_code,yytext);
2141 <ClassName>{ID}{B}*"("{ID}")" { // Obj-C category
2142 g_curClassName=removeRedundantWhiteSpace(yytext);
2143 g_scopeStack.push(CLASSBLOCK);
2144 pushScope(g_curClassName);
2146 generateClassOrGlobalLink(*g_code,yytext);
2149 <PackageName>{ID}("."{ID})* {
2150 g_curClassName=substitute(yytext,".","::");
2151 //printf("found package: %s\n",g_curClassName.data());
2153 codifyLines(yytext);
2159 <ClassVar>("extends"|"implements") { // Java
2160 startFontClass("keyword");
2161 codifyLines(yytext);
2163 g_curClassBases.clear();
2166 <ClassVar>("sealed"|"abstract")/{BN}*(":"|"{") {
2167 DBG_CTX((stderr,"***** C++/CLI modifier %s on g_curClassName=%s\n",yytext,g_curClassName.data()));
2168 startFontClass("keyword");
2169 codifyLines(yytext);
2171 BEGIN( CppCliTypeModifierFollowup );
2174 g_type = g_curClassName.copy();
2178 g_theVarContext.addVariable(g_type,g_name);
2180 generateClassOrGlobalLink(*g_code,yytext);
2182 <ClassName,ClassVar,CppCliTypeModifierFollowup>{B}*":"{B}* {
2183 codifyLines(yytext);
2184 g_curClassBases.clear();
2187 <PackageName>[ \t]*";" |
2188 <Bases>^{B}*/"@"{ID} | // Objective-C interface
2189 <Bases,ClassName,ClassVar,CppCliTypeModifierFollowup>{B}*"{"{B}* {
2190 g_theVarContext.pushScope();
2191 g_code->codify(yytext);
2193 if (YY_START==ClassVar && g_curClassName.isEmpty())
2195 g_curClassName = g_name.copy();
2197 if (g_searchingForBody)
2199 g_searchingForBody=FALSE;
2202 if (g_insideBody) g_bodyCurlyCount++;
2203 if (!g_curClassName.isEmpty()) // valid class name
2205 DBG_CTX((stderr,"** scope stack push CLASSBLOCK\n"));
2206 g_scopeStack.push(CLASSBLOCK);
2207 pushScope(g_curClassName);
2208 DBG_CTX((stderr,"***** g_curClassName=%s\n",g_curClassName.data()));
2209 if (getResolvedClass(g_currentDefinition,g_sourceFileDef,g_curClassName)==0)
2211 DBG_CTX((stderr,"Adding new class %s\n",g_curClassName.data()));
2212 ClassDef *ncd=new ClassDef("<code>",1,1,
2213 g_curClassName,ClassDef::Class,0,0,FALSE);
2214 g_codeClassSDict->append(g_curClassName,ncd);
2215 // insert base classes.
2216 char *s=g_curClassBases.first();
2220 bcd=g_codeClassSDict->find(s);
2221 if (bcd==0) bcd=getResolvedClass(g_currentDefinition,g_sourceFileDef,s);
2222 if (bcd && bcd!=ncd)
2224 ncd->insertBaseClass(bcd,s,Public,Normal);
2226 s=g_curClassBases.next();
2229 //printf("g_codeClassList.count()=%d\n",g_codeClassList.count());
2231 else // not a class name -> assume inner block
2233 DBG_CTX((stderr,"** scope stack push INNERBLOCK\n"));
2234 g_scopeStack.push(INNERBLOCK);
2236 g_curClassName.resize(0);
2237 g_curClassBases.clear();
2240 <Bases>"virtual"|"public"|"protected"|"private"|"@public"|"@private"|"@protected" {
2241 startFontClass("keyword");
2242 g_code->codify(yytext);
2245 <Bases>{SEP}?({ID}{SEP})*{ID} {
2246 DBG_CTX((stderr,"%s:addBase(%s)\n",g_curClassName.data(),yytext));
2247 g_curClassBases.inSort(yytext);
2248 generateClassOrGlobalLink(*g_code,yytext);
2251 g_code->codify(yytext);
2255 BEGIN ( SkipSharp );
2259 g_insideProtocolList=TRUE;
2263 g_code->codify(yytext);
2264 g_insideProtocolList=FALSE;
2267 g_code->codify(yytext);
2271 g_code->codify(yytext);
2272 if (--g_sharpCount<=0)
2276 g_code->codify(yytext);
2278 BEGIN ( SkipSharp );
2281 g_code->codify(yytext);
2285 g_code->codify(yytext);
2286 if (--g_sharpCount<=0)
2292 g_code->codify(yytext);
2296 <Body>{SCOPEPREFIX}?"operator"{B}*"()"{B}*/"(" {
2298 generateFunctionLink(*g_code,yytext);
2304 <Body>{SCOPEPREFIX}?"operator"/"(" {
2306 generateFunctionLink(*g_code,yytext);
2312 <Body>{SCOPEPREFIX}?"operator"[^a-z_A-Z0-9\(\n]+/"(" {
2314 generateFunctionLink(*g_code,yytext);
2320 <Body,TemplDecl>("template"|"generic")/([^a-zA-Z0-9]) {
2321 startFontClass("keyword");
2322 codifyLines(yytext);
2324 g_insideTemplate=TRUE;
2327 <Body>"using"{BN}+"namespace"{BN}+ {
2328 startFontClass("keyword");
2329 codifyLines(yytext);
2333 <UsingName>{ID}("::"{ID})* { addUsingDirective(yytext);
2334 generateClassOrGlobalLink(*g_code,yytext);
2335 DBG_CTX((stderr,"** scope stack push CLASSBLOCK\n"));
2336 g_scopeStack.push(CLASSBLOCK);
2340 <UsingName>\n { codifyLines(yytext); BEGIN(Body); }
2341 <UsingName>. { codifyLines(yytext); BEGIN(Body); }
2342 <Body,FuncCall>"$"?"this"("->"|".") { g_code->codify(yytext); // this-> for C++, this. for C#
2344 <Body>{KEYWORD}/([^a-z_A-Z0-9]) {
2345 startFontClass("keyword");
2346 codifyLines(yytext);
2347 if (QCString(yytext)=="typedef")
2354 <Body>{KEYWORD}/{B}* {
2355 startFontClass("keyword");
2356 codifyLines(yytext);
2359 <Body>{KEYWORD}/{BN}*"(" {
2360 startFontClass("keyword");
2361 codifyLines(yytext);
2363 g_name.resize(0);g_type.resize(0);
2365 <FuncCall>"in"/{BN}* {
2366 if (!g_inForEachExpression) REJECT;
2367 startFontClass("keywordflow");
2368 codifyLines(yytext);
2370 // insert the variable in the parent scope, see bug 546158
2371 g_theVarContext.popScope();
2372 g_theVarContext.addVariable(g_parmType,g_parmName);
2373 g_theVarContext.pushScope();
2374 g_name.resize(0);g_type.resize(0);
2376 <Body>{FLOWKW}/{BN}*"(" {
2377 startFontClass("keywordflow");
2378 codifyLines(yytext);
2380 g_name.resize(0);g_type.resize(0);
2381 g_inForEachExpression = (qstrcmp(yytext,"for each")==0 || qstrcmp(yytext, "foreach")==0);
2384 <Body>{FLOWKW}/([^a-z_A-Z0-9]) {
2385 startFontClass("keywordflow");
2386 codifyLines(yytext);
2388 if (g_inFunctionTryBlock && (qstrcmp(yytext,"catch")==0 || qstrcmp(yytext,"finally")==0))
2390 g_inFunctionTryBlock=FALSE;
2393 <Body>{FLOWKW}/{B}* {
2394 startFontClass("keywordflow");
2395 codifyLines(yytext);
2398 <Body>"*"{B}*")" { // end of cast?
2399 g_code->codify(yytext);
2400 g_theCallContext.popScope();
2402 g_parmType = g_name;
2405 <Body>[\\|\)\+\-\/\%\~\!] {
2406 g_code->codify(yytext);
2407 g_name.resize(0);g_type.resize(0);
2410 g_theCallContext.popScope();
2415 <Body,TemplDecl,ObjCMethod>{TYPEKW}/{B}* {
2416 startFontClass("keywordtype");
2417 g_code->codify(yytext);
2422 <Body>"generic"/{B}*"<"[^\n\/\-\.\{\"\>]*">"{B}* {
2423 startFontClass("keyword");
2424 g_code->codify(yytext);
2429 <Body>"template"/{B}*"<"[^\n\/\-\.\{\"\>]*">"{B}* { // template<...>
2430 startFontClass("keyword");
2431 g_code->codify(yytext);
2436 <TemplDecl>"class"|"typename" {
2437 startFontClass("keyword");
2438 codifyLines(yytext);
2442 g_code->codify(yytext);
2446 g_code->codify(yytext);
2448 if (g_sharpCount<=0)
2454 startFontClass("keyword");
2455 codifyLines(yytext);
2457 BEGIN( g_lastTemplCastContext );
2459 <TemplCast>{ID}("::"{ID})* {
2460 generateClassOrGlobalLink(*g_code,yytext);
2462 <TemplCast>("const"|"volatile"){B}* {
2463 startFontClass("keyword");
2464 codifyLines(yytext);
2468 codifyLines(yytext);
2470 <Body,FuncCall>{CASTKW}"<" { // static_cast<T>(
2471 startFontClass("keyword");
2472 codifyLines(yytext);
2474 g_lastTemplCastContext = YY_START;
2477 <Body>"$this->"{SCOPENAME}/{BN}*[;,)\]] { // PHP member variable
2479 generatePHPVariableLink(*g_code,yytext);
2482 <Body,TemplCast>{SCOPENAME}{B}*"<"[^\n\/\-\.\{\"\>]*">"("::"{ID})*/{B}* { // A<T> *pt;
2483 int i=QCString(yytext).find('<');
2484 QCString kw = QCString(yytext).left(i).stripWhiteSpace();
2485 if (kw.right(5)=="_cast" && YY_START==Body)
2490 generateClassOrGlobalLink(*g_code,yytext);
2493 <Body>{SCOPENAMECS}/{BN}*[;,)\]] { // "int var;" or "var, var2" or "debug(f) macro"
2494 if (!g_insideCS && !g_insideJava)
2501 // changed this to generateFunctionLink, see bug 624514
2502 //generateClassOrGlobalLink(*g_code,yytext,FALSE,TRUE);
2503 generateFunctionLink(*g_code,yytext);
2507 <Body>{SCOPENAME}/{BN}*[;,)\]] { // "int var;" or "var, var2" or "debug(f) macro"
2509 // changed this to generateFunctionLink, see bug 624514
2510 //generateClassOrGlobalLink(*g_code,yytext,FALSE,TRUE);
2511 generateFunctionLink(*g_code,yytext);
2514 <Body>{SCOPENAMECS}/{B}* { // p->func()
2515 if (!g_insideCS && !g_insideJava)
2522 generateClassOrGlobalLink(*g_code,yytext);
2526 <Body>{SCOPENAME}/{B}* { // p->func()
2528 generateClassOrGlobalLink(*g_code,yytext);
2531 <Body>"("{B}*("*"{B}*)+{SCOPENAME}*{B}*")"/{B}* { // (*p)->func() but not "if (p) ..."
2532 g_code->codify(yytext);
2533 int s=0;while (s<(int)yyleng && !isId(yytext[s])) s++;
2534 int e=(int)yyleng-1;while (e>=0 && !isId(yytext[e])) e--;
2535 QCString varname = ((QCString)yytext).mid(s,e-s+1);
2539 <Body>{SCOPETNAME}/{BN}*"(" { // a() or c::a() or t<A,B>::a() or A\B\foo()
2541 generateFunctionLink(*g_code,yytext);
2547 <FuncCall,Body,MemberCall,MemberCall2,SkipInits,InlineInit>{RAWBEGIN} {
2548 QCString text=yytext;
2549 int i=text.find('R');
2550 g_code->codify(text.left(i+1));
2551 startFontClass("stringliteral");
2552 g_code->codify(yytext+i+1);
2553 g_lastStringContext=YY_START;
2554 g_inForEachExpression = FALSE;
2555 g_delimiter = yytext+i+2;
2556 g_delimiter=g_delimiter.left(g_delimiter.length()-1);
2559 <FuncCall,Body,MemberCall,MemberCall2,SkipInits,InlineInit>\" {
2560 startFontClass("stringliteral");
2561 g_code->codify(yytext);
2562 g_lastStringContext=YY_START;
2563 g_inForEachExpression = FALSE;
2564 BEGIN( SkipString );
2566 <FuncCall,Body,MemberCall,MemberCall2,SkipInits,InlineInit>\' {
2567 startFontClass("stringliteral");
2568 g_code->codify(yytext);
2569 g_lastStringContext=YY_START;
2570 g_inForEachExpression = FALSE;
2571 BEGIN( SkipStringS );
2573 <SkipString>[^\"\\\r\n]* {
2574 g_code->codify(yytext);
2576 <SkipStringS>[^\'\\\r\n]* {
2577 g_code->codify(yytext);
2579 <SkipString,SkipStringS>"//"|"/*" {
2580 g_code->codify(yytext);
2583 g_code->codify(yytext);
2585 BEGIN( g_lastStringContext );
2588 g_code->codify(yytext);
2590 BEGIN( g_lastStringContext );
2592 <SkipString,SkipStringS>\\. {
2593 g_code->codify(yytext);
2595 <RawString>{RAWEND} {
2596 g_code->codify(yytext);
2597 QCString delimiter = yytext+1;
2598 delimiter=delimiter.left(delimiter.length()-1);
2599 if (delimiter==g_delimiter)
2601 BEGIN( g_lastStringContext );
2604 <RawString>[^)\n]+ { g_code->codify(yytext); }
2605 <RawString>. { g_code->codify(yytext); }
2606 <RawString>\n { codifyLines(yytext); }
2607 <SkipVerbString>[^"\n]+ {
2608 g_code->codify(yytext);
2610 <SkipVerbString>\"\" { // escaped quote
2611 g_code->codify(yytext);
2613 <SkipVerbString>\" { // end of string
2614 g_code->codify(yytext);
2616 BEGIN( g_lastVerbStringContext );
2619 g_code->codify(yytext);
2621 <SkipVerbString>\n {
2622 codifyLines(yytext);
2625 g_code->codify(yytext);
2626 g_name.resize(0);g_type.resize(0);
2629 if (g_insideTemplate)
2633 g_code->codify(yytext);
2636 if (g_insideTemplate)
2638 if (--g_sharpCount<=0)
2640 g_insideTemplate=FALSE;
2643 g_code->codify(yytext);
2645 <Body,MemberCall,MemberCall2,FuncCall>"'"((\\0[Xx0-9]+)|(\\.)|(.))"'" {
2646 startFontClass("charliteral");
2647 g_code->codify(yytext);
2651 if (yytext[0]=='-') // -> could be overloaded
2653 updateCallContextForSmartPointer();
2655 g_code->codify(yytext);
2656 g_memCallContext = YY_START;
2657 BEGIN( MemberCall );
2659 <MemberCall>{SCOPETNAME}/{BN}*"(" {
2660 if (g_theCallContext.getClass())
2662 if (!generateClassMemberLink(*g_code,g_theCallContext.getClass(),yytext))
2664 g_code->codify(yytext);
2665 addToSearchIndex(yytext);
2671 g_code->codify(yytext);
2672 addToSearchIndex(yytext);
2677 if (g_memCallContext==Body)
2683 BEGIN(g_memCallContext);
2686 <MemberCall>{SCOPENAME}/{B}* {
2687 if (g_theCallContext.getClass())
2689 DBG_CTX((stderr,"g_theCallContext.getClass()=%p\n",g_theCallContext.getClass()));
2690 if (!generateClassMemberLink(*g_code,g_theCallContext.getClass(),yytext))
2692 g_code->codify(yytext);
2693 addToSearchIndex(yytext);
2699 DBG_CTX((stderr,"no class context!\n"));
2700 g_code->codify(yytext);
2701 addToSearchIndex(yytext);
2705 BEGIN(g_memCallContext);
2708 if (g_insideObjC && *yytext=='[')
2710 //printf("Found start of ObjC call!\n");
2711 // start of a method call
2712 g_contextDict.setAutoDelete(TRUE);
2713 g_nameDict.setAutoDelete(TRUE);
2714 g_objectDict.setAutoDelete(TRUE);
2715 g_wordDict.setAutoDelete(TRUE);
2716 g_contextDict.clear();
2718 g_objectDict.clear();
2721 g_currentNameId = 0;
2730 g_code->codify(yytext);
2731 g_saveName = g_name.copy();
2732 g_saveType = g_type.copy();
2733 if (*yytext!='[' && !g_type.isEmpty())
2735 //printf("g_scopeStack.bottom()=%p\n",g_scopeStack.bottom());
2736 if (g_scopeStack.top()!=CLASSBLOCK)
2738 //printf("AddVariable: '%s' '%s' context=%d\n",
2739 // g_type.data(),g_name.data(),g_theVarContext.count());
2740 g_theVarContext.addVariable(g_type,g_name);
2744 if (*yytext==';' || *yytext=='=')
2749 else if (*yytext=='[')
2751 g_theCallContext.pushScope();
2754 g_parmType.resize(0);
2755 g_parmName.resize(0);
2759 <ObjCMemberCall>{ID} {
2760 if (qstrcmp(yytext,"self")==0 || qstrcmp(yytext,"super")==0)
2762 // TODO: get proper base class for "super"
2763 g_theCallContext.setClass(getClass(g_curClassName));
2764 startFontClass("keyword");
2765 g_code->codify(yytext);
2770 generateClassOrGlobalLink(*g_code,yytext);
2773 BEGIN(ObjCMemberCall2);
2775 <ObjCMemberCall>"[" {
2776 g_code->codify(yytext);
2777 g_theCallContext.pushScope();
2779 <ObjCMemberCall2>{ID}":"? {
2781 if (g_theCallContext.getClass())
2783 //printf("Calling method %s\n",g_name.data());
2784 if (!generateClassMemberLink(*g_code,g_theCallContext.getClass(),g_name))
2786 g_code->codify(yytext);
2787 addToSearchIndex(g_name);
2792 g_code->codify(yytext);
2793 addToSearchIndex(g_name);
2796 BEGIN(ObjCMemberCall3);
2798 <ObjCMemberCall2,ObjCMemberCall3>"]" {
2799 g_theCallContext.popScope();
2800 g_code->codify(yytext);
2804 <ObjCCall,ObjCMName>"[" {
2806 g_currentCtx->format+=*yytext;
2810 <ObjCCall,ObjCMName>"]" {
2811 g_currentCtx->format+=*yytext;
2812 restoreObjCContext();
2814 if (g_currentCtx==0)
2817 writeObjCMethodCall(g_contextDict.find(0));
2820 //printf("close\n");
2823 g_currentCtx->format+=escapeObject(yytext);
2824 if (g_braceCount==0)
2826 g_currentCtx->objectTypeOrName=yytext;
2827 //printf("new type=%s\n",g_currentCtx->objectTypeOrName.data());
2831 <ObjCMName>{ID}/{BN}*"]" {
2832 if (g_braceCount==0 &&
2833 g_currentCtx->methodName.isEmpty())
2835 g_currentCtx->methodName=yytext;
2836 g_currentCtx->format+=escapeName(yytext);
2840 g_currentCtx->format+=escapeWord(yytext);
2843 <ObjCMName>{ID}/{BN}*":" {
2844 if (g_braceCount==0)
2846 g_currentCtx->methodName+=yytext;
2847 g_currentCtx->methodName+=":";
2849 g_currentCtx->format+=escapeName(yytext);
2851 <ObjCSkipStr>[^\n\"$\\]* { g_currentCtx->format+=yytext; }
2852 <ObjCSkipStr>\\. { g_currentCtx->format+=yytext; }
2853 <ObjCSkipStr>"\"" { g_currentCtx->format+=yytext;
2854 BEGIN(g_lastStringContext);
2856 <ObjCCall,ObjCMName>{CHARLIT} { g_currentCtx->format+=yytext; }
2857 <ObjCCall,ObjCMName>"@"?"\"" { g_currentCtx->format+=yytext;
2858 g_lastStringContext=YY_START;
2861 <ObjCCall,ObjCMName,ObjCSkipStr>"$" { g_currentCtx->format+="$$"; }
2862 <ObjCCall,ObjCMName>"(" { g_currentCtx->format+=*yytext; g_braceCount++; }
2863 <ObjCCall,ObjCMName>")" { g_currentCtx->format+=*yytext; g_braceCount--; }
2864 <ObjCSkipStr>"@"/"\"" { // needed to prevent matching the global rule (for C#)
2865 g_currentCtx->format+=yytext;
2867 <ObjCCall,ObjCMName,ObjCSkipStr>{ID} { g_currentCtx->format+=escapeWord(yytext); }
2868 <ObjCCall,ObjCMName,ObjCSkipStr>. { g_currentCtx->format+=*yytext; }
2869 <ObjCCall,ObjCMName,ObjCSkipStr>\n { g_currentCtx->format+=*yytext; }
2872 g_theCallContext.popScope();
2873 g_code->codify(yytext);
2874 // TODO: nested arrays like: a[b[0]->func()]->func()
2875 g_name = g_saveName.copy();
2876 g_type = g_saveType.copy();
2879 g_code->codify(yytext);
2881 <Body>[0-9]+[xX][0-9A-Fa-f]+ {
2882 g_code->codify(yytext);
2884 <MemberCall2,FuncCall>{KEYWORD}/([^a-z_A-Z0-9]) {
2886 //g_parmName=yytext;
2887 startFontClass("keyword");
2888 g_code->codify(yytext);
2891 <MemberCall2,FuncCall,OldStyleArgs,TemplCast>{TYPEKW}/([^a-z_A-Z0-9]) {
2894 startFontClass("keywordtype");
2895 g_code->codify(yytext);
2898 <MemberCall2,FuncCall>{FLOWKW}/([^a-z_A-Z0-9]) {
2901 startFontClass("keywordflow");
2902 g_code->codify(yytext);
2905 <MemberCall2,FuncCall>{ID}(({B}*"<"[^\n\[\](){}<>]*">")?({B}*"::"{B}*{ID})?)* {
2908 generateClassOrGlobalLink(*g_code,yytext,!g_insideBody);
2910 <FuncCall>";" { // probably a cast, not a function call
2911 g_code->codify(yytext);
2912 g_inForEachExpression = FALSE;
2915 <MemberCall2,FuncCall>, {
2916 g_code->codify(yytext);
2917 g_theVarContext.addVariable(g_parmType,g_parmName);
2918 g_parmType.resize(0);g_parmName.resize(0);
2920 <MemberCall2,FuncCall>"{" {
2921 if (g_bracketCount>0)
2923 g_code->codify(yytext);
2924 g_skipInlineInitContext=YY_START;
2933 <InlineInit>"{" { g_curlyCount++;
2934 g_code->codify(yytext);
2937 g_code->codify(yytext);
2938 if (--g_curlyCount<=0)
2940 BEGIN(g_skipInlineInitContext);
2944 codifyLines(yytext);
2947 g_code->codify(yytext);
2949 <MemberCall2,FuncCall>"(" {
2950 g_parmType.resize(0);g_parmName.resize(0);
2951 g_code->codify(yytext);
2953 g_theCallContext.pushScope();
2954 if (YY_START==FuncCall && !g_insideBody)
2956 g_theVarContext.pushScope();
2959 <MemberCall2,FuncCall>{OPERATOR} { // operator
2960 if (qstrcmp(yytext,"*") &&
2961 qstrcmp(yytext,"&") &&
2962 qstrcmp(yytext,"^") &&
2963 qstrcmp(yytext,"%")) // typically a pointer or reference
2965 // not a * or &, or C++/CLI's ^ or %
2966 g_parmType.resize(0);g_parmName.resize(0);
2968 g_code->codify(yytext);
2970 <MemberCall,MemberCall2,FuncCall>("*"{B}*)?")" {
2971 if (yytext[0]==')') // no a pointer cast
2973 //printf("addVariable(%s,%s)\n",g_parmType.data(),g_parmName.data());
2974 g_theVarContext.addVariable(g_parmType,g_parmName);
2978 g_parmType.resize(0);
2979 g_parmName.resize(0);
2981 g_theCallContext.popScope();
2982 g_inForEachExpression = FALSE;
2983 //g_theCallContext.setClass(0); // commented out, otherwise a()->b() does not work for b().
2984 g_code->codify(yytext);
2985 if (--g_bracketCount<=0)
2987 if (g_name.isEmpty())
2997 <CallEnd>[ \t\n]* { codifyLines(yytext); }
2999 <MemberCall2,FuncCall>")"[ \t\n]*[;:] {
3002 codifyLines(yytext);
3004 if (*yytext==';') g_searchingForBody=FALSE;
3005 if (!g_type.isEmpty())
3007 DBG_CTX((stderr,"add variable g_type=%s g_name=%s)\n",g_type.data(),g_name.data()));
3008 g_theVarContext.addVariable(g_type,g_name);
3010 g_parmType.resize(0);g_parmName.resize(0);
3011 g_theCallContext.setClass(0);
3012 if (*yytext==';' || g_insideBody)
3016 g_theVarContext.popScope();
3018 g_name.resize(0);g_type.resize(0);
3027 <CallEnd>("const"|"volatile"|"sealed"|"override")({BN}+("const"|"volatile"|"sealed"|"override"))*/{BN}*(";"|"="|"throw"{BN}*"(") {
3028 startFontClass("keyword");
3029 codifyLines(yytext);
3032 <CallEnd,OldStyleArgs>("const"|"volatile"|"sealed"|"override")*({BN}+("const"|"volatile"|"sealed"|"override"))*{BN}*"{" {
3035 g_theVarContext.pushScope();
3037 g_theVarContext.addVariable(g_parmType,g_parmName);
3038 //g_theCallContext.popScope();
3039 g_parmType.resize(0);g_parmName.resize(0);
3040 int index = g_name.findRev("::");
3041 DBG_CTX((stderr,"g_name=%s\n",g_name.data()));
3044 QCString scope = g_name.left(index);
3045 if (!g_classScope.isEmpty()) scope.prepend(g_classScope+"::");
3046 ClassDef *cd=getResolvedClass(Doxygen::globalScope,g_sourceFileDef,scope);
3049 setClassScope(cd->name());
3050 g_scopeStack.push(SCOPEBLOCK);
3051 DBG_CTX((stderr,"** scope stack push SCOPEBLOCK\n"));
3055 //setClassScope(g_realScope);
3056 g_scopeStack.push(INNERBLOCK);
3057 DBG_CTX((stderr,"** scope stack push INNERBLOCK\n"));
3062 DBG_CTX((stderr,"** scope stack push INNERBLOCK\n"));
3063 g_scopeStack.push(INNERBLOCK);
3065 yytext[yyleng-1]='\0';
3066 QCString cv(yytext);
3067 if (!cv.stripWhiteSpace().isEmpty())
3069 startFontClass("keyword");
3070 codifyLines(yytext);
3073 else // just whitespace
3075 codifyLines(yytext);
3077 g_code->codify("{");
3078 if (g_searchingForBody)
3080 g_searchingForBody=FALSE;
3083 if (g_insideBody) g_bodyCurlyCount++;
3085 g_type.resize(0); g_name.resize(0);
3088 <CallEnd>"try" { // function-try-block
3089 startFontClass("keyword");
3090 g_code->codify(yytext);
3092 g_inFunctionTryBlock=TRUE;
3095 if (g_insideBody || !g_parmType.isEmpty())
3099 // could be K&R style definition
3102 generateClassOrGlobalLink(*g_code,yytext,!g_insideBody);
3103 BEGIN(OldStyleArgs);
3105 <OldStyleArgs>{ID} {
3108 generateClassOrGlobalLink(*g_code,yytext,!g_insideBody);
3110 <OldStyleArgs>[,;] {
3111 g_code->codify(yytext);
3112 g_theVarContext.addVariable(g_parmType,g_parmName);
3113 if (*yytext==';') g_parmType.resize(0);
3114 g_parmName.resize(0);
3116 <CallEnd,OldStyleArgs>"#" {
3117 startFontClass("preprocessor");
3118 g_lastSkipCppContext = Body;
3119 g_code->codify(yytext);
3126 g_theVarContext.popScope();
3128 g_name.resize(0);g_args.resize(0);
3129 g_parmType.resize(0);g_parmName.resize(0);
3133 g_code->codify(yytext);
3134 g_type.resize(0); g_name.resize(0);
3138 g_code->codify(yytext);
3140 if (g_searchingForBody)
3142 g_searchingForBody=FALSE;
3145 if (g_insideBody) g_bodyCurlyCount++;
3146 if (g_name.find("::")!=-1)
3148 DBG_CTX((stderr,"** scope stack push SCOPEBLOCK\n"));
3149 g_scopeStack.push(SCOPEBLOCK);
3150 setClassScope(g_realScope);
3154 DBG_CTX((stderr,"** scope stack push INNERBLOCK\n"));
3155 g_scopeStack.push(INNERBLOCK);
3157 g_type.resize(0); g_name.resize(0);
3161 generateClassOrGlobalLink(*g_code,yytext);
3163 <FuncCall>{ID}/"(" {
3164 generateFunctionLink(*g_code,yytext);
3166 <FuncCall>{ID}/("."|"->") {
3168 generateClassOrGlobalLink(*g_code,yytext);
3169 BEGIN( MemberCall2 );
3171 <FuncCall,MemberCall2>("("{B}*("*"{B}*)+{ID}*{B}*")"{B}*)/("."|"->") {
3172 g_code->codify(yytext);
3173 int s=0;while (!isId(yytext[s])) s++;
3174 int e=(int)yyleng-1;while (!isId(yytext[e])) e--;
3175 g_name=((QCString)yytext).mid(s,e-s+1);
3176 BEGIN( MemberCall2 );
3178 <MemberCall2>{ID}/([ \t\n]*"(") {
3179 if (!g_args.isEmpty())
3180 generateMemberLink(*g_code,g_args,yytext);
3182 generateClassOrGlobalLink(*g_code,yytext);
3186 <MemberCall2>{ID}/([ \t\n]*("."|"->")) {
3187 //g_code->codify(yytext);
3189 generateClassOrGlobalLink(*g_code,yytext);
3190 BEGIN( MemberCall2 );
3192 <MemberCall2>"->"|"." {
3193 if (yytext[0]=='-') // -> could be overloaded
3195 updateCallContextForSmartPointer();
3197 g_code->codify(yytext);
3198 g_memCallContext = YY_START;
3199 BEGIN( MemberCall );
3201 <SkipComment>"/*"("!"?)"*/" {
3202 g_code->codify(yytext);
3204 BEGIN( g_lastCContext ) ;
3206 <SkipComment>"//"|"/*" {
3207 g_code->codify(yytext);
3209 <SkipComment>[^*/\n]+ {
3210 g_code->codify(yytext);
3212 <SkipComment>[ \t]*"*/" {
3213 g_code->codify(yytext);
3215 if (g_lastCContext==SkipCPP)
3217 startFontClass("preprocessor");
3219 BEGIN( g_lastCContext ) ;
3221 <SkipCxxComment>[^\r\n]*"\\"[\r]?\n { // line continuation
3222 codifyLines(yytext);
3224 <SkipCxxComment>[^\r\n]+ {
3225 g_code->codify(yytext);
3228 <SkipCxxComment>\n {
3231 BEGIN( g_lastCContext ) ;
3234 g_code->codify(yytext);
3236 <RemoveSpecialCComment>"*/"{B}*\n({B}*\n)*({B}*(("//@"[{}])|("/*@"[{}]"*/")){B}*\n)?{B}*"/*"[*!]/[^/*] {
3237 g_yyLineNr+=QCString(yytext).contains('\n');
3239 <RemoveSpecialCComment>"*/"{B}*\n({B}*\n)*({B}*(("//@"[{}])|("/*@"[{}]"*/")){B}*\n)? {
3240 g_yyLineNr+=QCString(yytext).contains('\n');
3242 if (g_lastSpecialCContext==SkipCxxComment)
3243 { // force end of C++ comment here
3245 BEGIN( g_lastCContext ) ;
3249 BEGIN(g_lastSpecialCContext);
3252 <RemoveSpecialCComment>"*/" {
3253 BEGIN(g_lastSpecialCContext);
3255 <RemoveSpecialCComment>[^*\n]+
3256 <RemoveSpecialCComment>"//"|"/*"
3257 <RemoveSpecialCComment>\n { g_yyLineNr++; }
3258 <RemoveSpecialCComment>.
3259 <MemberCall>[^a-z_A-Z0-9(\n] {
3260 g_code->codify(yytext);
3263 BEGIN(g_memCallContext);
3265 <*>\n({B}*"//"[!/][^\n]*\n)+ { // remove special one-line comment
3266 if (YY_START==SkipCPP) REJECT;
3267 if (Config_getBool("STRIP_CODE_COMMENTS"))
3269 g_yyLineNr+=((QCString)yytext).contains('\n');
3274 startFontClass("comment");
3275 codifyLines(yytext);
3278 if (YY_START==SkipCxxComment)
3281 BEGIN( g_lastCContext ) ;
3286 codifyLines(yytext);
3287 BEGIN( g_lastSkipCppContext ) ;
3289 <*>\n{B}*"//@"[{}].*\n { // remove one-line group marker
3290 if (Config_getBool("STRIP_CODE_COMMENTS"))
3297 startFontClass("comment");
3298 codifyLines(yytext);
3301 if (YY_START==SkipCxxComment)
3304 BEGIN( g_lastCContext ) ;
3307 <*>\n{B}*"/*@"[{}] { // remove one-line group marker
3308 if (Config_getBool("STRIP_CODE_COMMENTS"))
3310 g_lastSpecialCContext = YY_START;
3312 BEGIN(RemoveSpecialCComment);
3316 // check is to prevent getting stuck in skipping C++ comments
3317 if (YY_START != SkipCxxComment)
3319 g_lastCContext = YY_START ;
3321 startFontClass("comment");
3322 codifyLines(yytext);
3326 <*>^{B}*"//@"[{}].*\n { // remove one-line group marker
3327 if (Config_getBool("STRIP_CODE_COMMENTS"))
3334 startFontClass("comment");
3335 codifyLines(yytext);
3339 <*>^{B}*"/*@"[{}] { // remove multi-line group marker
3340 if (Config_getBool("STRIP_CODE_COMMENTS"))
3342 g_lastSpecialCContext = YY_START;
3343 BEGIN(RemoveSpecialCComment);
3347 // check is to prevent getting stuck in skipping C++ comments
3348 if (YY_START != SkipCxxComment)
3350 g_lastCContext = YY_START ;
3352 startFontClass("comment");
3353 g_code->codify(yytext);
3357 <*>^{B}*"//"[!/][^\n]*\n { // remove special one-line comment
3358 if (Config_getBool("STRIP_CODE_COMMENTS"))
3365 startFontClass("comment");
3366 codifyLines(yytext);
3370 <*>"//"[!/][^\n]*\n { // strip special one-line comment
3371 if (YY_START==SkipComment || YY_START==SkipString) REJECT;
3372 if (Config_getBool("STRIP_CODE_COMMENTS"))
3374 char c[2]; c[0]='\n'; c[1]=0;
3379 startFontClass("comment");
3380 codifyLines(yytext);
3384 <*>"/*[tag:"[^\]\n]*"]*/"{B}* { // special pattern /*[tag:filename]*/ to force linking to a tag file
3385 g_forceTagReference=yytext;
3386 int s=g_forceTagReference.find(':');
3387 int e=g_forceTagReference.findRev(']');
3388 g_forceTagReference = g_forceTagReference.mid(s+1,e-s-1);
3390 <*>\n{B}*"/*"[!*]/[^/*] {
3391 if (Config_getBool("STRIP_CODE_COMMENTS"))
3393 g_lastSpecialCContext = YY_START;
3395 BEGIN(RemoveSpecialCComment);
3399 // check is to prevent getting stuck in skipping C++ comments
3400 if (YY_START != SkipCxxComment)
3402 g_lastCContext = YY_START ;
3404 startFontClass("comment");
3405 codifyLines(yytext);
3409 <*>^{B}*"/*"[!*]/[^/*] { // special C comment block at a new line
3410 if (Config_getBool("STRIP_CODE_COMMENTS"))
3412 g_lastSpecialCContext = YY_START;
3413 BEGIN(RemoveSpecialCComment);
3417 // check is to prevent getting stuck in skipping C++ comments
3418 if (YY_START != SkipCxxComment)
3420 g_lastCContext = YY_START ;
3422 startFontClass("comment");
3423 g_code->codify(yytext);
3427 <*>"/*"[!*]/[^/*] { // special C comment block half way a line
3428 if (YY_START==SkipString) REJECT;
3429 if (Config_getBool("STRIP_CODE_COMMENTS"))
3431 g_lastSpecialCContext = YY_START;
3432 BEGIN(RemoveSpecialCComment);
3436 // check is to prevent getting stuck in skipping C++ comments
3437 if (YY_START != SkipCxxComment)
3439 g_lastCContext = YY_START ;
3441 startFontClass("comment");
3442 g_code->codify(yytext);
3447 if (YY_START==SkipString) REJECT;
3448 if (!Config_getBool("STRIP_CODE_COMMENTS"))
3450 startFontClass("comment");
3451 g_code->codify(yytext);
3456 startFontClass("comment");
3457 g_code->codify(yytext);
3458 // check is to prevent getting stuck in skipping C++ comments
3459 if (YY_START != SkipCxxComment)
3461 g_lastCContext = YY_START ;
3463 BEGIN( SkipComment ) ;
3465 <*>@\" { // C# verbatim string
3466 startFontClass("stringliteral");
3467 g_code->codify(yytext);
3468 g_lastVerbStringContext=YY_START;
3469 BEGIN(SkipVerbString);
3472 startFontClass("comment");
3473 g_code->codify(yytext);
3474 g_lastCContext = YY_START ;
3475 BEGIN( SkipCxxComment ) ;
3478 g_code->codify(yytext);
3479 g_theCallContext.pushScope();
3482 g_code->codify(yytext);
3483 g_theCallContext.popScope();
3487 codifyLines(yytext);
3491 g_code->codify(yytext);
3494 <*>([ \t\n]*"\n"){2,} { // combine multiple blank lines
3495 //QCString sepLine=yytext;
3496 //g_code->codify("\n\n");
3497 //g_yyLineNr+=sepLine.contains('\n');
3498 //char sepLine[3]="\n\n";
3499 codifyLines(yytext);
3505 /*@ ----------------------------------------------------------------------------
3508 static void saveObjCContext()
3512 g_currentCtx->format+=QCString().sprintf("$c%d",g_currentCtxId);
3513 if (g_braceCount==0 && YY_START==ObjCCall)
3515 g_currentCtx->objectTypeOrName=g_currentCtx->format.mid(1);
3516 //printf("new type=%s\n",g_currentCtx->objectTypeOrName.data());
3518 g_contextStack.push(g_currentCtx);
3522 //printf("Trying to save NULL context!\n");
3524 ObjCCallCtx *newCtx = new ObjCCallCtx;
3525 newCtx->id = g_currentCtxId;
3526 newCtx->lexState = YY_START;
3527 newCtx->braceCount = g_braceCount;
3528 newCtx->objectType = 0;
3529 newCtx->objectVar = 0;
3531 //printf("save state=%d\n",YY_START);
3532 g_contextDict.insert(g_currentCtxId,newCtx);
3533 g_currentCtx = newCtx;
3538 static void restoreObjCContext()
3540 //printf("restore state=%d->%d\n",YY_START,g_currentCtx->lexState);
3541 BEGIN(g_currentCtx->lexState);
3542 g_braceCount = g_currentCtx->braceCount;
3543 if (!g_contextStack.isEmpty())
3545 g_currentCtx = g_contextStack.pop();
3550 //printf("Trying to pop context while g_contextStack is empty!\n");
3554 void resetCCodeParserState()
3556 //printf("***initParseCodeContext()\n");
3557 g_forceTagReference.resize(0);
3558 g_theVarContext.clear();
3559 g_classScopeLengthStack.setAutoDelete(TRUE);
3560 g_classScopeLengthStack.clear();
3561 delete g_codeClassSDict;
3562 g_codeClassSDict = new ClassSDict(17);
3563 g_codeClassSDict->setAutoDelete(TRUE);
3564 g_codeClassSDict->clear();
3565 g_curClassBases.clear();
3569 void parseCCode(CodeOutputInterface &od,const char *className,const QCString &s,
3570 SrcLangExt lang,bool exBlock, const char *exName,FileDef *fd,
3571 int startLine,int endLine,bool inlineFragment,
3572 MemberDef *memberDef,bool showLineNumbers,Definition *searchCtx,
3575 //printf("***parseCode() exBlock=%d exName=%s fd=%p className=%s searchCtx=%s\n",
3576 // exBlock,exName,fd,className,searchCtx?searchCtx->name().data():"<none>");
3578 if (s.isEmpty()) return;
3580 printlex(yy_flex_debug, TRUE, __FILE__, fd ? fd->fileName().data(): NULL);
3582 TooltipManager::instance()->clearTooltips();
3583 if (g_codeClassSDict==0)
3585 resetCCodeParserState();
3589 g_inputPosition = 0;
3590 g_currentFontClass = 0;
3591 g_needsTermination = FALSE;
3592 g_searchCtx = searchCtx;
3593 g_collectXRefs = collectXRefs;
3594 g_inFunctionTryBlock = FALSE;
3596 g_inputLines = endLine+1;
3598 g_inputLines = countLines();
3601 g_yyLineNr = startLine;
3606 g_bodyCurlyCount = 0;
3609 g_insideTemplate = FALSE;
3610 g_theCallContext.clear();
3611 g_scopeStack.clear();
3612 g_classScope = className;
3613 //printf("parseCCode %s\n",className);
3614 g_exampleBlock = exBlock;
3615 g_exampleName = exName;
3616 g_sourceFileDef = fd;
3617 g_lineNumbers = fd!=0 && showLineNumbers;
3618 bool cleanupSourceDef = FALSE;
3621 // create a dummy filedef for the example
3622 g_sourceFileDef = new FileDef("",(exName?exName:"generated"));
3623 cleanupSourceDef = TRUE;
3625 g_insideObjC = lang==SrcLangExt_ObjC;
3626 g_insideJava = lang==SrcLangExt_Java;
3627 g_insideCS = lang==SrcLangExt_CSharp;
3628 g_insidePHP = lang==SrcLangExt_PHP;
3629 if (g_sourceFileDef)
3631 setCurrentDoc("l00001");
3633 g_currentDefinition = 0;
3634 g_currentMemberDef = 0;
3635 g_searchingForBody = exBlock;
3636 g_insideBody = FALSE;
3638 if (!g_exampleName.isEmpty())
3640 g_exampleFile = convertNameToFile(g_exampleName+"-example",FALSE,TRUE);
3641 //printf("g_exampleFile=%s\n",g_exampleFile.data());
3643 g_includeCodeFragment = inlineFragment;
3644 //printf("** exBlock=%d exName=%s include=%d\n",exBlock,exName,inlineFragment);
3649 g_parmName.resize(0);
3650 g_parmType.resize(0);
3651 if (memberDef) setParameterList(memberDef);
3652 codeYYrestart( codeYYin );
3656 if (g_needsTermination)
3659 DBG_CTX((stderr,"endCodeLine(%d)\n",g_yyLineNr));
3660 g_code->endCodeLine();
3664 TooltipManager::instance()->writeTooltips(*g_code);
3666 if (cleanupSourceDef)
3668 // delete the temporary file definition used for this example
3669 delete g_sourceFileDef;
3673 printlex(yy_flex_debug, FALSE, __FILE__, fd ? fd->fileName().data(): NULL);
3677 void codeFreeScanner()
3679 #if defined(YY_FLEX_SUBMINOR_VERSION)
3682 codeYYlex_destroy();
3689 #if !defined(YY_FLEX_SUBMINOR_VERSION)
3690 extern "C" { // some bogus code to keep the compiler happy
3691 void codeYYdummy() { yy_flex_realloc(0,0); }
3693 #elif YY_FLEX_SUBMINOR_VERSION<33
3694 #error "You seem to be using a version of flex newer than 2.5.4 but older than 2.5.33. These versions do NOT work with doxygen! Please use version <=2.5.4 or >=2.5.33 or expect things to be parsed wrongly!"