15%option never-interactive
16%option prefix="codeYY"
18%option extra-type="struct codeYY_state *"
22#define YY_TYPEDEF_YY_SCANNER_T
36#include <unordered_map>
37#include <unordered_set>
73#define DBG_CTX(x) do { } while(0)
75#define YY_NO_UNISTD_H 1
179 std::unordered_map< int,std::unique_ptr<ObjCCallCtx> >
contextMap;
238 bool typeOnly=
false,
bool varOnly=
false);
260#define YY_INPUT(buf,result,max_size) result=yyread(yyscanner,buf,max_size);
Represents the call context.
A abstract class representing of a compound symbol.
A String class for use with Doxygen wrapping std::string and adding some additional functionality off...
The common base class of all entity definitions found in the sources.
A model of a file symbol.
A model of a class/file/namespace member symbol.
Class representing a list of different code generators.
Text streaming class that buffers data.
static bool isCastKeyword(const char *s)
static void generateClassOrGlobalLink(yyscan_t yyscanner, OutputCodeList &ol, const DString &clName, bool typeOnly=false, bool varOnly=false)
static bool getLinkInScope(yyscan_t yyscanner, const DString &c, const DString &m, const DString &memberText, OutputCodeList &ol, const DString &text, bool varOnly=false)
static void endCodeLine(yyscan_t yyscanner)
static bool skipLanguageSpecificKeyword(yyscan_t yyscanner, const char *kw)
static void pushScope(yyscan_t yyscanner, const DString &s)
static bool getLink(yyscan_t yyscanner, const DString &className, const DString &memberName, OutputCodeList &ol, const DString &text=DString(), bool varOnly=false)
static DString escapeComment(yyscan_t yyscanner, const DString &s)
static void restoreObjCContext(yyscan_t yyscanner)
static void nextCodeLine(yyscan_t yyscanner)
static void setClassScope(yyscan_t yyscanner, const DString &name)
static void popScope(yyscan_t yyscanner)
static DString escapeName(yyscan_t yyscanner, const DString &s)
static const MemberDef * setCallContextForVar(yyscan_t yyscanner, const DString &name)
static void startCodeLine(yyscan_t yyscanner)
static void setCurrentDoc(yyscan_t yyscanner, const DString &anchor)
static void incrementFlowKeyWordCount(yyscan_t yyscanner)
static int yyread(yyscan_t yyscanner, char *buf, int max_size)
static int countLines(yyscan_t yyscanner)
static const char * stateToString(int state)
static void addParmType(yyscan_t yyscanner)
static void updateCallContextForSmartPointer(yyscan_t yyscanner)
static DString escapeWord(yyscan_t yyscanner, const DString &s)
static void generateFunctionLink(yyscan_t yyscanner, OutputCodeList &ol, const DString &funcName)
static const ClassDef * stripClassName(yyscan_t yyscanner, const DString &s, const Definition *d)
static void addToSearchIndex(yyscan_t yyscanner, const DString &text)
static void addVariable(yyscan_t yyscanner, DString type, DString name)
static void addUsingDirective(yyscan_t yyscanner, const DString &name)
static void generateMemberLink(yyscan_t yyscanner, OutputCodeList &ol, const DString &varName, const DString &memName)
static void codifyLines(yyscan_t yyscanner, const DString &text)
static void startFontClass(yyscan_t yyscanner, const char *s, bool specialComment=false)
static void endFontClass(yyscan_t yyscanner, bool specialComment=false)
static void writeMultiLineCodeLink(yyscan_t yyscanner, OutputCodeList &ol, const Definition *d, const DString &text)
static const char * getLexerFILE()
static bool startsWithKeyword(const DString &str, const DString &kw)
static void setParameterList(yyscan_t yyscanner, const MemberDef *md)
static void addType(yyscan_t yyscanner)
static DString escapeObject(yyscan_t yyscanner, const DString &s)
static void saveObjCContext(yyscan_t yyscanner)
static void writeObjCMethodCall(yyscan_t yyscanner, ObjCCallCtx *ctx)
static void endCodeFold(yyscan_t yyscanner)
static void generatePHPVariableLink(yyscan_t yyscanner, OutputCodeList &ol, const char *varName)
static bool generateClassMemberLink(yyscan_t yyscanner, OutputCodeList &ol, const MemberDef *xmd, const DString &memName)
std::vector< std::string > StringVector
Web server based search engine.
const MemberDef * objectVar
const ClassDef * objectType
std::unordered_map< int, DString > nameMap
StringVector curClassBases
CallContext theCallContext
const Definition * currentDefinition
std::unique_ptr< FileDef > exampleFileDef
const char * currentFontClass
std::stack< int > scopeStack
1 if bracket starts a scope,
const FileDef * sourceFileDef
std::unordered_map< int, std::unique_ptr< ObjCCallCtx > > contextMap
VariableContext theVarContext
std::unordered_map< int, DString > wordMap
TooltipManager tooltipManager
std::vector< int > scopeNameLengthStack
std::map< std::string, const NamespaceDef * > UsingContext
const char * inputString
the code fragment as text
const Definition * searchCtx
std::unordered_map< int, DString > commentMap
SymbolResolver symbolResolver
yy_size_t inputPosition
read offset during parsing
bool insideSpecialComment
std::unordered_map< int, DString > objectMap
int yyLineNr
current line number
std::vector< const Definition * > foldStack
int lastVerbStringContext
int inputLines
number of line in the code fragment
const MemberDef * currentMemberDef
std::unordered_map< std::string, ScopedTypeVariant > codeClassMap
UsingContext theUsingContext
bool skipCodify
for CSharp files scoped namespace {
std::stack< ObjCCallCtx * > contextStack
int skipInlineInitContext
A bunch of utility functions.
271ID [$a-z_A-Z\x80-\xFF][$a-z_A-Z0-9\x80-\xFF]*
273SCOPENAME ("::"{BN}*)?({ID}{BN}*{SEP}{BN}*)*("~"{BN}*)?{ID}
274TEMPLIST "<"[^\"\}\{\(\)\/\n>]*">"
275SCOPETNAME (((({ID}{TEMPLIST}?){BN}*)?{SEP}{BN}*)*)((~{BN}*)?{ID})
276SCOPEPREFIX ({ID}{TEMPLIST}?{BN}*{SEP}{BN}*)+
277KEYWORD_OBJC ("@public"|"@private"|"@protected"|"@class"|"@implementation"|"@interface"|"@end"|"@selector"|"@protocol"|"@optional"|"@required"|"@throw"|"@synthesize"|"@property")
279KEYWORD ("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"))
280FLOWKW ("break"|"catch"|"continue"|"default"|"do"|"else"|"finally"|"return"|"switch"|"throw"|"throws"|"@catch"|"@finally")
281FLOWCONDITION ("case"|"for"|"foreach"|"for each"|"goto"|"if"|"try"|"while"|"@try")
282TYPEKW ("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")
283TYPEKWSL ("LocalObject"|"Object"|"Value")
284CASTKW ("const_cast"|"dynamic_cast"|"reinterpret_cast"|"static_cast")
285CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^' \\\n]{1,4}"'"))
286ARITHOP "+"|"-"|"/"|"*"|"%"|"--"|"++"
287ASSIGNOP "="|"*="|"/="|"%="|"+="|"-="|"<<="|">>="|"&="|"^="|"|="
288LOGICOP "=="|"!="|">"|"<"|">="|"<="|"&&"|"||"|"!"|"<=>"
289BITOP "&"|"|"|"^"|"<<"|">>"|"~"
290OPERATOR {ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}
291RAWBEGIN (u|U|L|u8)?R\"[^ \t\(\)\\]{0,16}"("
292RAWEND ")"[^ \t\(\)\\]{0,16}\"
293MODULE_ID ({ID}".")*{ID}
299DECIMAL_INTEGER [1-9][0-9']*[0-9]?[uU]?[lL]?[lL]?
300HEXADECIMAL_INTEGER "0"[xX][0-9a-zA-Z']+[0-9a-zA-Z]?
301OCTAL_INTEGER "0"[0-7][0-7']+[0-7]?
302BINARY_INTEGER "0"[bB][01][01']*[01]?
303INTEGER_NUMBER {DECIMAL_INTEGER}|{HEXADECIMAL_INTEGER}|{OCTAL_INTEGER}|{BINARY_INTEGER}
307DIGIT_SEQ [0-9][0-9']*[0-9]?
308FRAC_CONST {DIGIT_SEQ}"."|{DIGIT_SEQ}?"."{DIGIT_SEQ}
309FP_EXP [eE][+-]?{DIGIT_SEQ}
310DEC_FP1 {FRAC_CONST}{FP_EXP}?{FP_SUF}?
311DEC_FP2 {DIGIT_SEQ}{FP_EXP}{FP_SUF}
313HEX_DIGIT_SEQ [0-9a-fA-F][0-9a-fA-F']*[0-9a-fA-F]?
314HEX_FRAC_CONST {HEX_DIGIT_SEQ}"."|{HEX_DIGIT_SEQ}?"."{HEX_DIGIT_SEQ}
315BIN_EXP [pP][+-]?{DIGIT_SEQ}
316HEX_FP1 "0"[xX]{HEX_FRAC_CONST}{BIN_EXP}{FP_SUF}?
317HEX_FP2 "0"[xX]{HEX_DIGIT_SEQ}{BIN_EXP}{FP_SUF}?
319FLOAT_DECIMAL {DEC_FP1}|{DEC_FP2}
320FLOAT_HEXADECIMAL {HEX_FP1}|{HEX_FP2}
321FLOAT_NUMBER {FLOAT_DECIMAL}|{FLOAT_HEXADECIMAL}
322NUMBER {INTEGER_NUMBER}|{FLOAT_NUMBER}
335ENDQopt ("const"|"volatile"|"sealed"|"override")({BN}+("const"|"volatile"|"sealed"|"override"))*
356%x CppCliTypeModifierFollowup
381<Body>^([ \t]*"#"[ \t]*("include"|"import")[ \t]*)("<"|"\"") {
383 yyextra->code->codify(yytext);
384 BEGIN( ReadInclude );
386<Body>("@interface"|"@implementation"|"@protocol")[ \t\n]+ {
387 yyextra->insideObjC=
true;
391 if (!yyextra->insideTemplate)
394<Body>(("public"|"private"){B}+)?("ref"|"value"|"interface"|"enum"){B}+("class"|"struct") {
395 if (yyextra->insideTemplate) REJECT;
401<Body>"property"|"event"/{BN}* {
402 if (yyextra->insideTemplate) REJECT;
407<Body>("partial"{B}+)?("class"|"struct"|"union"|"namespace"|"interface"){B}+ {
411 if (!yyextra->insideTemplate)
414<Body>("package")[ \t\n]+ {
418 BEGIN( PackageName );
421 if (!yyextra->insideObjC) REJECT;
425<Body,ClassVar,Bases>"-"|"+" {
426 if (!yyextra->insideObjC || yyextra->insideBody)
428 yyextra->code->codify(yytext);
432 DBG_CTX((stderr,
"Start of Objective-C method!\n"));
433 yyextra->code->codify(yytext);
438 yyextra->code->codify(yytext);
442 yyextra->code->codify(yytext);
443 BEGIN(ObjCParamType);
445<ObjCParams,ObjCMethod>";"|"{" {
446 yyextra->code->codify(yytext);
449 if (yyextra->searchingForBody)
451 yyextra->searchingForBody=
false;
452 yyextra->insideBody=
true;
454 if (yyextra->insideBody) yyextra->bodyCurlyCount++;
455 if (!yyextra->curClassName.empty())
457 pushScope(yyscanner,yyextra->curClassName);
458 DBG_CTX((stderr,
"** scope stack push SCOPEBLOCK\n"));
462 yyextra->type.clear();
463 yyextra->name.clear();
466<ObjCParams>{ID}{B}*":" {
467 yyextra->code->codify(yytext);
469<ObjCParamType>{TYPEKW} {
471 yyextra->code->codify(yytext);
473 yyextra->parmType=yytext;
477 yyextra->parmType=yytext;
480 yyextra->code->codify(yytext);
484 yyextra->code->codify(yytext);
485 yyextra->parmName=yytext;
486 addVariable(yyscanner,yyextra->parmType,yyextra->parmName);
487 yyextra->parmType.clear();yyextra->parmName.clear();
489<ObjCMethod,ObjCParams,ObjCParamType>{ID} {
492<ObjCMethod,ObjCParams,ObjCParamType>. {
493 yyextra->code->codify(yytext);
495<ObjCMethod,ObjCParams,ObjCParamType>\n {
498<ReadInclude>[^\n\">]+/(">"|"\"") {
509 DBG_CTX((stderr,
"===== yes %s is ambiguous\n",yytext));
511 if (!name.empty() && yyextra->sourceFileDef)
517 auto it = std::find_if(fn->begin(),
519 [&sfd=yyextra->sourceFileDef]
521 { return sfd->isIncluded(lfd->absFilePath()); });
522 found = it!=fn->end();
538 yyextra->code->codify(yytext);
540 char c=(char)yyinput(yyscanner);
543 yyextra->code->codify(text);
virtual bool isLinkable() const =0
static std::string cleanDirPath(const std::string &path)
static FileNameLinkedMap * inputNameLinkedMap
virtual DString absFilePath() const =0
Class representing all files with a certain base name.
const T * find(const std::string &key) const
const char * qPrint(const char *s)
FileDef * findFileDef(const FileNameLinkedMap *fnMap, const DString &n, bool &ambig)
DString determineAbsoluteIncludeName(const DString &curFile, const DString &incFileName)
547<Body,Bases>^[ \t]*"#" {
549 yyextra->lastSkipCppContext = YY_START;
550 yyextra->code->codify(yytext);
554 yyextra->code->codify(yytext);
555 yyextra->lastStringContext=YY_START;
556 BEGIN( SkipString ) ;
559 yyextra->code->codify(yytext);
561<SkipCPP>[^\n\/\\\"]+ {
562 yyextra->code->codify(yytext);
567<SkipCPP>{CPPC}/[^/!] {
570<Body,FuncCall,MemberCall,MemberCall2>"}" {
571 yyextra->theVarContext.popScope();
572 yyextra->theCallContext.popScope(yyextra->name, yyextra->type, yyextra->bracketCount);
573 yyextra->type.clear();
574 yyextra->name.clear();
576 if (!yyextra->scopeStack.empty())
578 int scope = yyextra->scopeStack.top();
579 yyextra->scopeStack.pop();
587 yyextra->code->codify(yytext);
589 DBG_CTX((stderr,
"yyextra->bodyCurlyCount=%d\n",yyextra->bodyCurlyCount));
590 if (--yyextra->bodyCurlyCount<=0)
592 yyextra->insideBody=
false;
593 yyextra->currentMemberDef=
nullptr;
594 if (yyextra->currentDefinition)
595 yyextra->currentDefinition=yyextra->currentDefinition->getOuterScope();
599<Body,ClassVar>"@end" {
600 DBG_CTX((stderr,
"End of objc scope fd=%s\n",
qPrint(yyextra->sourceFileDef->name())));
601 if (yyextra->sourceFileDef)
603 const FileDef *fd=yyextra->sourceFileDef;
606 DBG_CTX((stderr,
"insideObjC=%d\n",yyextra->insideObjC));
610 yyextra->insideObjC =
false;
612 if (yyextra->insideBody)
614 yyextra->theVarContext.popScope();
616 if (!yyextra->scopeStack.empty())
618 int scope = yyextra->scopeStack.top();
619 yyextra->scopeStack.pop();
626 yyextra->insideBody=
false;
630 yyextra->code->codify(yytext);
633 yyextra->currentMemberDef=
nullptr;
634 if (yyextra->currentDefinition)
635 yyextra->currentDefinition=yyextra->currentDefinition->getOuterScope();
bool endsWith(const char *s) const
virtual const DString & name() const =0
638<ClassName,ClassVar>";" {
639 if (yyextra->lang==SrcLangExt::CSharp)
641 yyextra->code->codify(yytext);
642 yyextra->skipCodify =
true;
647 yyextra->code->codify(yytext);
648 yyextra->searchingForBody=
false;
652<ClassName,ClassVar>[*&^%]+ {
653 yyextra->type=yyextra->curClassName;
654 yyextra->name.clear();
655 yyextra->code->codify(yytext);
658<ClassName>"__declspec"{B}*"("{B}*{ID}{B}*")" {
660 yyextra->code->codify(yytext);
663<ClassName>{ID}("."{ID})* |
664<ClassName>{ID}("::"{ID})* {
665 if (yyextra->lang==SrcLangExt::CSharp)
666 yyextra->curClassName=
substitute(yytext,
".",
"::");
668 yyextra->curClassName=yytext;
670 if (yyextra->curClassName==
"alignas")
673 yyextra->code->codify(yytext);
DString substitute(const DString &s, const DString &src, const DString &dst)
substitute all occurrences of src in s by dst
684 yyextra->bracketCount=1;
685 yyextra->code->codify(yytext);
688<AlignAs>\n { yyextra->yyLineNr++;
691<AlignAs>. { yyextra->code->codify(yytext); }
692<AlignAsEnd>"(" { yyextra->code->codify(yytext);
693 yyextra->bracketCount++;
696 yyextra->code->codify(yytext);
697 if (--yyextra->bracketCount<=0)
702<AlignAsEnd>\n { yyextra->yyLineNr++;
705<AlignAsEnd>. { yyextra->code->codify(yytext); }
706<ClassName>{ID}("\\"{ID})* {
707 yyextra->curClassName=
substitute(yytext,
"\\",
"::");
709 pushScope(yyscanner,yyextra->curClassName);
714<ClassName>{ID}{B}*"("{ID}")" {
717 pushScope(yyscanner,yyextra->curClassName);
DString removeRedundantWhiteSpace(const DString &s)
722<PackageName>{ID}("."{ID})* {
723 yyextra->curClassName=
substitute(yytext,
".",
"::");
724 DBG_CTX((stderr,
"found package: %s\n",
qPrint(yyextra->curClassName)));
732<ClassVar>("extends"|"implements") {
736 yyextra->curClassBases.clear();
739<ClassVar>("sealed"|"abstract")/{BN}*(":"|"{") {
740 DBG_CTX((stderr,
"***** C++/CLI modifier %s on yyextra->curClassName=%s\n",yytext,
qPrint(yyextra->curClassName)));
744 BEGIN( CppCliTypeModifierFollowup );
747 yyextra->type = yyextra->curClassName;
748 yyextra->name = yytext;
749 if (yyextra->insideBody)
751 addVariable(yyscanner,yyextra->type,yyextra->name);
755<ClassName,ClassVar,CppCliTypeModifierFollowup>{B}*":"{B}* {
757 yyextra->curClassBases.clear();
760<PackageName>[ \t]*";" |
761<Bases>^{Bopt}/"@"{ID} |
762<Bases,ClassName,ClassVar,CppCliTypeModifierFollowup>{B}*"{"{B}* {
763 yyextra->theVarContext.pushScope();
764 if (!yyextra->skipCodify) yyextra->code->codify(yytext);
765 yyextra->skipCodify =
false;
766 if (YY_START==ClassVar && yyextra->curClassName.empty())
768 yyextra->curClassName = yyextra->name;
770 if (yyextra->searchingForBody)
772 yyextra->searchingForBody=
false;
773 yyextra->insideBody=
true;
775 if (yyextra->insideBody) yyextra->bodyCurlyCount++;
776 if (!yyextra->curClassName.empty())
778 DBG_CTX((stderr,
"** scope stack push CLASSBLOCK\n"));
780 pushScope(yyscanner,yyextra->curClassName);
781 DBG_CTX((stderr,
"***** yyextra->curClassName=%s\n",
qPrint(yyextra->curClassName)));
782 if (yyextra->symbolResolver.resolveClass(yyextra->currentDefinition,yyextra->curClassName,
true)==
nullptr)
784 DBG_CTX((stderr,
"Adding new class %s\n",
qPrint(yyextra->curClassName)));
787 for (
const auto &s : yyextra->curClassBases)
790 auto it = yyextra->codeClassMap.find(s);
791 if (it!=yyextra->codeClassMap.end())
795 if (bcd==
nullptr) bcd=yyextra->symbolResolver.resolveClass(yyextra->currentDefinition,s,
true);
796 if (bcd && bcd->
name()!=yyextra->curClassName)
798 var.localDef()->insertBaseClass(bcd->
name());
801 yyextra->codeClassMap.emplace(yyextra->curClassName.str(),std::move(var));
807 DBG_CTX((stderr,
"** scope stack push INNERBLOCK\n"));
810 yyextra->curClassName.clear();
811 yyextra->curClassBases.clear();
ClassDef * toClassDef(Definition *d)
814<Bases>"virtual"|"public"|"protected"|"private"|"@public"|"@private"|"@protected" {
816 yyextra->code->codify(yytext);
819<Bases>{SEP}?({ID}{SEP})*{ID} {
820 DBG_CTX((stderr,
"%s:addBase(%s)\n",
qPrint(yyextra->curClassName),yytext));
821 yyextra->curClassBases.emplace_back(yytext);
825 yyextra->code->codify(yytext);
826 if (!yyextra->insideObjC)
828 yyextra->sharpCount=1;
833 yyextra->insideProtocolList=
true;
837 yyextra->code->codify(yytext);
838 yyextra->insideProtocolList=
false;
841 yyextra->code->codify(yytext);
842 ++yyextra->sharpCount;
845 yyextra->code->codify(yytext);
846 if (--yyextra->sharpCount<=0)
850 yyextra->code->codify(yytext);
851 yyextra->lastStringContext=YY_START;
855 yyextra->code->codify(yytext);
856 yyextra->lastStringContext=YY_START;
860 yyextra->code->codify(yytext);
861 yyextra->sharpCount=1;
865 yyextra->code->codify(yytext);
866 ++yyextra->sharpCount;
869 yyextra->code->codify(yytext);
870 if (--yyextra->sharpCount<=0)
876 yyextra->code->codify(yytext);
880<Body>{SCOPEPREFIX}?"operator"{B}*"()"{Bopt}/"(" {
883 yyextra->bracketCount=0;
884 yyextra->args.clear();
885 yyextra->name+=yytext;
888<Body>{SCOPEPREFIX}?"operator"/"(" {
891 yyextra->bracketCount=0;
892 yyextra->args.clear();
893 yyextra->name+=yytext;
896<Body>{SCOPEPREFIX}?"operator"[^a-z_A-Z0-9\(\n]+/"(" {
899 yyextra->bracketCount=0;
900 yyextra->args.clear();
901 yyextra->name+=yytext;
904<Body,TemplDecl>("template"|"generic")/([^a-zA-Z0-9]) {
908 yyextra->insideTemplate=
true;
909 yyextra->sharpCount=0;
911<Body>"concept"{BN}+ {
917<Body>"using"{BN}+"namespace"{BN}+ {
929<Body>"module"/{B}*[:;]? {
930 if (yyextra->lang!=SrcLangExt::Cpp) REJECT;
931 if (!yyextra->type.empty() || !yyextra->name.empty()) REJECT;
937<Body>"import"/{B}*[<":]? {
938 if (yyextra->lang!=SrcLangExt::Cpp) REJECT;
944<ConceptName>{ID}("::"{ID})* {
947<ConceptName>"=" {
codifyLines(yyscanner,yytext); BEGIN(Body); }
948<UsingName>{ID}(("::"|"."){ID})* {
953<UsingName>\n {
codifyLines(yyscanner,yytext); BEGIN(Body); }
954<UsingName>. {
codifyLines(yyscanner,yytext); BEGIN(Body); }
955<Body,FuncCall>"$"?"this"("->"|".") { yyextra->code->codify(yytext);
956 yyextra->isPrefixedWithThis =
true;
958<Body>{KEYWORD}/([^a-z_A-Z0-9]) {
959 if (yyextra->lang==SrcLangExt::Java &&
dstrcmp(
"internal",yytext) ==0) REJECT;
967 yyextra->name+=yytext;
static constexpr size_t npos
value used to indicate 'not found' or 'to the end of the string', matching std::string::npos
size_t find(char c, size_t pos=0) const
int dstrcmp(const char *str1, const char *str2)
971<Body>{KEYWORD}/{B}* {
977<Body>{KEYWORD}/{BN}*"(" {
982 yyextra->name.clear();yyextra->type.clear();
984<FuncCall>"in"/{BN}* {
985 if (!yyextra->inForEachExpression) REJECT;
990 yyextra->theVarContext.popScope();
991 addVariable(yyscanner,yyextra->parmType,yyextra->parmName);
992 yyextra->theVarContext.pushScope();
993 yyextra->name.clear();yyextra->type.clear();
995<Body>{FLOWKW}/{BN}*"(" {
999 yyextra->name.clear();yyextra->type.clear();
1000 yyextra->inForEachExpression = (
dstrcmp(yytext,
"for each")==0 ||
dstrcmp(yytext,
"foreach")==0);
1003<Body>{FLOWCONDITION}/{BN}*"(" {
1008 yyextra->name.clear();yyextra->type.clear();
1009 yyextra->inForEachExpression = (strcmp(yytext,
"for each")==0 || strcmp(yytext,
"foreach")==0);
1012<Body>{FLOWKW}/([^a-z_A-Z0-9]) {
1016 if (yyextra->inFunctionTryBlock && (
dstrcmp(yytext,
"catch")==0 ||
dstrcmp(yytext,
"finally")==0))
1018 yyextra->inFunctionTryBlock=
false;
1021<Body>{FLOWCONDITION}/([^a-z_A-Z0-9]) {
1026 if (yyextra->inFunctionTryBlock && (strcmp(yytext,
"catch")==0 || strcmp(yytext,
"finally")==0))
1028 yyextra->inFunctionTryBlock=
false;
1031<Body>{FLOWKW}/{B}* {
1036<Body>{FLOWCONDITION}/{B}* {
1043 yyextra->code->codify(yytext);
1044 yyextra->theCallContext.popScope(yyextra->name, yyextra->type, yyextra->bracketCount);
1045 yyextra->bracketCount--;
1046 yyextra->parmType = yyextra->name;
1049<Body>"\\)"|"\\(" {
1050 yyextra->code->codify(yytext);
1052<Body>[\\|\)\+\-\/\%\~\!] {
1053 yyextra->code->codify(yytext);
1054 yyextra->name.clear();yyextra->type.clear();
1057 yyextra->theCallContext.popScope(yyextra->name, yyextra->type, yyextra->bracketCount);
1058 yyextra->bracketCount--;
1059 if (yyextra->bracketCount<=0)
1065<Body,TemplDecl,ObjCMethod>{TYPEKW}/{B}* {
1067 yyextra->code->codify(yytext);
1070 yyextra->name+=yytext;
1072<Body,TemplDecl,ObjCMethod>{TYPEKWSL}/{B}* {
1073 if (yyextra->lang!=SrcLangExt::Slice)
1080 yyextra->code->codify(yytext);
1083 yyextra->name+=yytext;
1086<Body>"generic"/{B}*"<"[^\n\/\-\.\{\">]*">"{B}* {
1088 yyextra->code->codify(yytext);
1090 yyextra->sharpCount=0;
1093<Body>"template"/{B}*"<"[^\n\/\-\.\{\">]*">"{B}* {
1095 yyextra->code->codify(yytext);
1097 yyextra->sharpCount=0;
1100<TemplDecl>"class"|"typename" {
1106 yyextra->code->codify(yytext);
1107 yyextra->sharpCount++;
1110 yyextra->code->codify(yytext);
1111 yyextra->sharpCount--;
1112 if (yyextra->sharpCount<=0)
1121 BEGIN( yyextra->lastTemplCastContext );
1123<TemplCast>{ID}("::"{ID})* {
1126<TemplCast>("const"|"volatile"){B}* {
1134<Body,MemberCall2,FuncCall>{CASTKW}{B}*"<" {
1138 yyextra->lastTemplCastContext = YY_START;
1141<Body>"$this->"{SCOPENAME}/{BN}*[;,)\]] {
1144 yyextra->name+=yytext+7;
1146<Body,TemplCast>{SCOPENAME}{B}*"<"[^\n\/\-\.\{\">\(']*">"{ENDIDopt}/{B}* {
1153 yyextra->name+=yytext;
1155<ModuleName,ModuleImport>{MODULE_ID}({BN}*":"{BN}*{MODULE_ID})? {
1157 size_t i = name.
find(
':');
DString mid(size_t index, size_t len=npos) const
DString stripWhiteSpace() const
returns a copy of this string with leading and trailing whitespace removed
DString left(size_t len) const
static ModuleManager & instance()
ModuleDef * getPrimaryInterface(const DString &moduleName) const
1174<ModuleName>":"{BN}+"private" {
1176 size_t i=text.
find(
'p');
1182<ModuleName>";" { yyextra->code->codify(yytext); BEGIN(Body); }
1183<ModuleName>. { yyextra->code->codify(yytext); }
1185<ModuleImport>["<] { yyextra->code->codify(yytext); BEGIN(ReadInclude); }
1186<ModuleImport>";" { yyextra->code->codify(yytext); BEGIN(Body); }
1187<ModuleImport>. { yyextra->code->codify(yytext); }
1188<ModuleImport>\n {
codifyLines(yyscanner,yytext); }
1190<Body>{SCOPENAME}/{BN}*[:;,)\]] {
1197 yyextra->name+=yytext;
1199<Body>{ID}("."{ID})+/{BN}+ {
1200 if (yyextra->lang==SrcLangExt::CSharp || yyextra->lang==SrcLangExt::Java)
1204 yyextra->name+=yytext;
1211<Body>"export"/{B}* {
1212 if (yyextra->lang!=SrcLangExt::Cpp) REJECT;
1217<Body>{SCOPENAME}/{B}* {
1224 yyextra->name+=yytext;
1226<Body>"("{B}*("*"{B}*)+{SCOPENAME}+{B}*")"/{B}* {
1227 yyextra->code->codify(yytext);
1228 uint32_t s=0;
while (s<(uint32_t)yyleng && !
isId(yytext[s])) s++;
1229 uint32_t e=(uint32_t)yyleng-1;
while (e>1 && !
isId(yytext[e])) e--;
1232 yyextra->name=std::move(varname);
1234<Body>{SCOPETNAME}{B}*"<"[^\n\/\-\.\{\">]*">"/{BN}*"(" |
1235<Body>{SCOPETNAME}/{BN}*"(" {
1242 yyextra->bracketCount=0;
1243 yyextra->args.clear();
1244 yyextra->name+=yytext;
1247<FuncCall,Body,MemberCall,MemberCall2,SkipInits,InlineInit>{RAWBEGIN} {
1249 size_t i=text.
find(
'R');
1250 yyextra->code->codify(text.
left(i+1));
1252 yyextra->code->codify(yytext+i+1);
1253 yyextra->lastStringContext=YY_START;
1254 yyextra->inForEachExpression =
false;
DString extractBeginRawStringDelimiter(const char *rawStart)
1258<FuncCall,Body,MemberCall,MemberCall2,SkipInits,InlineInit,ClassVar,OldStyleArgs>\" {
1260 yyextra->code->codify(yytext);
1261 yyextra->lastStringContext=YY_START;
1262 yyextra->inForEachExpression =
false;
1263 BEGIN( SkipString );
1265<FuncCall,Body,MemberCall,MemberCall2,SkipInits,InlineInit>{NUMBER} {
1266 if (yyextra->lang!=SrcLangExt::Cpp) REJECT;
1267 yyextra->code->codify(yytext);
1269<FuncCall,Body,MemberCall,MemberCall2,SkipInits,InlineInit>\' {
1271 yyextra->code->codify(yytext);
1272 yyextra->lastStringContext=YY_START;
1273 yyextra->inForEachExpression =
false;
1274 BEGIN( SkipStringS );
1276<SkipString>[^\"\\\r\n]{1,100} {
1277 yyextra->code->codify(yytext);
1279<SkipStringS>[^\'\\\r\n]{1,100} {
1280 yyextra->code->codify(yytext);
1282<SkipString,SkipStringS>{CPPC}|{CCS} {
1283 yyextra->code->codify(yytext);
1286 yyextra->code->codify(yytext);
1287 if (yyextra->lastStringContext!=SkipCPP)
1291 BEGIN( yyextra->lastStringContext );
1294 yyextra->code->codify(yytext);
1296 BEGIN( yyextra->lastStringContext );
1298<SkipString,SkipStringS>\\. {
1299 yyextra->code->codify(yytext);
1301<RawString>{RAWEND} {
1302 yyextra->code->codify(yytext);
1305 BEGIN( yyextra->lastStringContext );
DString extractEndRawStringDelimiter(const char *rawEnd)
1308<RawString>[^)\n]+ { yyextra->code->codify(yytext); }
1309<RawString>. { yyextra->code->codify(yytext); }
1311<SkipVerbString>[^"\n]+ {
1312 yyextra->code->codify(yytext);
1314<SkipVerbString>\"\" {
1315 yyextra->code->codify(yytext);
1318 yyextra->code->codify(yytext);
1320 BEGIN( yyextra->lastVerbStringContext );
1323 yyextra->code->codify(yytext);
1329 yyextra->code->codify(yytext);
1330 yyextra->name.clear();yyextra->type.clear();
1333 if (yyextra->insideTemplate)
1335 yyextra->sharpCount++;
1337 yyextra->code->codify(yytext);
1340 if (yyextra->insideTemplate)
1342 if (--yyextra->sharpCount<=0)
1344 yyextra->insideTemplate=
false;
1347 yyextra->code->codify(yytext);
1349<Body,MemberCall,MemberCall2,FuncCall,OldStyleArgs>"'"((\\0[Xx0-9]+)|(\\.)|(.))"'" {
1351 yyextra->code->codify(yytext);
1359 yyextra->code->codify(yytext);
1360 yyextra->memCallContext = YY_START;
1361 BEGIN( MemberCall );
1363<MemberCall>{SCOPETNAME}/{BN}*"(" {
1365 if (yyextra->theCallContext.getScope().globalDef())
1372 yyextra->name.clear();
1378 yyextra->name.clear();
1380 yyextra->type.clear();
1381 if (yyextra->memCallContext==Body)
1387 BEGIN(yyextra->memCallContext);
1390<MemberCall>{SCOPENAME}/{B}* {
1391 if (yyextra->theCallContext.getScope().globalDef())
1393 DBG_CTX((stderr,
"yyextra->theCallContext.getClass()=%p\n",(
void*)yyextra->theCallContext.getScope().globalDef()));
1399 yyextra->name.clear();
1403 DBG_CTX((stderr,
"no class context!\n"));
1406 yyextra->name.clear();
1408 yyextra->type.clear();
1409 BEGIN(yyextra->memCallContext);
1412 if (yyextra->insideObjC && *yytext==
'[')
1414 DBG_CTX((stderr,
"Found start of ObjC call!\n"));
1416 yyextra->contextMap.clear();
1417 yyextra->nameMap.clear();
1418 yyextra->objectMap.clear();
1419 yyextra->wordMap.clear();
1420 yyextra->commentMap.clear();
1421 yyextra->currentCtxId = 0;
1422 yyextra->currentNameId = 0;
1423 yyextra->currentObjId = 0;
1424 yyextra->currentCtx =
nullptr;
1425 yyextra->braceCount = 0;
1431 if (*yytext!=
'{') yyextra->code->codify(yytext);
1432 yyextra->saveName = yyextra->name;
1433 yyextra->saveType = yyextra->type;
1434 if (*yytext!=
'[' && !yyextra->type.empty())
1441 addVariable(yyscanner,yyextra->type,yyextra->name);
1443 yyextra->name.clear();
1445 if (*yytext==
';' || *yytext==
'=' || *yytext==
'{')
1447 yyextra->type.clear();
1448 yyextra->name.clear();
1450 else if (*yytext==
'[')
1452 yyextra->theCallContext.pushScope(yyextra->name, yyextra->type, yyextra->bracketCount);
1454 yyextra->args.clear();
1455 yyextra->parmType.clear();
1456 yyextra->parmName.clear();
1464<Body,FuncCall,BodyVar>"{" {
1465 yyextra->theVarContext.pushScope();
1466 yyextra->theCallContext.pushScope(yyextra->name, yyextra->type, yyextra->bracketCount);
1467 yyextra->bracketCount = 0;
1472 DBG_CTX((stderr,
"** scope stack push SCOPEBLOCK\n"));
1478 DBG_CTX((stderr,
"** scope stack push INNERBLOCK\n"));
1482 if (yyextra->searchingForBody)
1484 yyextra->searchingForBody=
false;
1485 yyextra->insideBody=
true;
1487 yyextra->code->codify(yytext);
1488 if (yyextra->insideBody)
1490 yyextra->bodyCurlyCount++;
1492 yyextra->type.clear();
1493 yyextra->name.clear();
1496<ObjCCall,ObjCMName>"["|"{" {
1498 yyextra->currentCtx->format+=*yytext;
1502<ObjCCall,ObjCMName>"]"|"}" {
1503 yyextra->currentCtx->format+=*yytext;
1506 if (yyextra->currentCtx==
nullptr)
1510 auto it = yyextra->contextMap.find(0);
1511 if (it!=yyextra->contextMap.end())
1513 ctx = it->second.get();
1520<ObjCCall,ObjCMName>{CPPC}.* {
1521 yyextra->currentCtx->format+=
escapeComment(yyscanner,yytext);
1523<ObjCCall,ObjCMName>{CCS} {
1524 yyextra->lastObjCCallContext = YY_START;
1525 yyextra->currentCtx->comment.str(yytext);
1526 BEGIN(ObjCCallComment);
1528<ObjCCallComment>{CCE} {
1529 yyextra->currentCtx->comment << yytext;
1530 yyextra->currentCtx->format+=
escapeComment(yyscanner,yyextra->currentCtx->comment.str());
1531 BEGIN(yyextra->lastObjCCallContext);
1533<ObjCCallComment>[^*\n]+ { yyextra->currentCtx->comment << yytext; }
1534<ObjCCallComment>{CPPC}|{CCS} { yyextra->currentCtx->comment << yytext; }
1535<ObjCCallComment>\n { yyextra->currentCtx->comment << *yytext; }
1536<ObjCCallComment>. { yyextra->currentCtx->comment << *yytext; }
1537<ObjCCall>{ID}({B}*"."{B}*{ID})* {
1538 yyextra->currentCtx->format+=
escapeObject(yyscanner,yytext);
1539 if (yyextra->braceCount==0)
1541 yyextra->currentCtx->objectTypeOrName=yytext;
1542 DBG_CTX((stderr,
"new type=%s\n",
qPrint(yyextra->currentCtx->objectTypeOrName)));
1546<ObjCMName>{ID}/{BN}*"]" {
1547 if (yyextra->braceCount==0 &&
1548 yyextra->currentCtx->methodName.empty())
1550 yyextra->currentCtx->methodName=yytext;
1551 yyextra->currentCtx->format+=
escapeName(yyscanner,yytext);
1555 yyextra->currentCtx->format+=
escapeWord(yyscanner,yytext);
1558<ObjCMName>{ID}/{BN}*":" {
1559 if (yyextra->braceCount==0)
1561 yyextra->currentCtx->methodName+=yytext;
1562 yyextra->currentCtx->methodName+=
":";
1564 yyextra->currentCtx->format+=
escapeName(yyscanner,yytext);
1566<ObjCSkipStr>[^\n\"$\\]* { yyextra->currentCtx->format+=yytext; }
1567<ObjCSkipStr>\\. { yyextra->currentCtx->format+=yytext; }
1568<ObjCSkipStr>"\"" { yyextra->currentCtx->format+=yytext;
1569 BEGIN(yyextra->lastStringContext);
1571<ObjCCall,ObjCMName>{CHARLIT} { yyextra->currentCtx->format+=yytext; }
1572<ObjCCall,ObjCMName>"@"?"\"" { yyextra->currentCtx->format+=yytext;
1573 yyextra->lastStringContext=YY_START;
1576<ObjCCall,ObjCMName,ObjCSkipStr>"$" { yyextra->currentCtx->format+=
"$$"; }
1577<ObjCCall,ObjCMName>"(" { yyextra->currentCtx->format+=*yytext; yyextra->braceCount++; }
1578<ObjCCall,ObjCMName>")" { yyextra->currentCtx->format+=*yytext; yyextra->braceCount--; }
1579<ObjCSkipStr>"@"/"\"" {
1580 yyextra->currentCtx->format+=yytext;
1582<ObjCCall,ObjCMName,ObjCSkipStr>{ID} { yyextra->currentCtx->format+=
escapeWord(yyscanner,yytext); }
1583<ObjCCall,ObjCMName,ObjCSkipStr>. { yyextra->currentCtx->format+=*yytext; }
1584<ObjCCall,ObjCMName,ObjCSkipStr>\n { yyextra->currentCtx->format+=*yytext; }
1587 yyextra->theCallContext.popScope(yyextra->name, yyextra->type, yyextra->bracketCount);
1588 yyextra->code->codify(yytext);
1590 yyextra->name = yyextra->saveName;
1591 yyextra->type = yyextra->saveType;
1594 yyextra->code->codify(yytext);
1596<Body>[0-9]+[xX][0-9A-Fa-f]+ {
1597 yyextra->code->codify(yytext);
1599<MemberCall2,FuncCall>{KEYWORD}/([^a-z_A-Z0-9]) {
1604 yyextra->code->codify(yytext);
1607<MemberCall2,FuncCall,OldStyleArgs,TemplCast>{TYPEKW}/([^a-z_A-Z0-9]) {
1609 yyextra->parmName=yytext;
1611 yyextra->code->codify(yytext);
1614<MemberCall2,FuncCall,OldStyleArgs,TemplCast>{TYPEKWSL}/([^a-z_A-Z0-9]) {
1615 if (yyextra->lang!=SrcLangExt::Slice)
1622 yyextra->parmName=yytext;
1624 yyextra->code->codify(yytext);
1628<MemberCall2,FuncCall>{FLOWKW}/([^a-z_A-Z0-9]) {
1630 yyextra->parmName=yytext;
1632 yyextra->code->codify(yytext);
1635<MemberCall2,FuncCall>{FLOWCONDITION}/([^a-z_A-Z0-9]) {
1638 yyextra->parmName=yytext;
1640 yyextra->code->codify(yytext);
1643<MemberCall2,FuncCall>("::")?{ID}(({B}*"<"[^\n\[\](){}<>']*">")?({B}*"::"{B}*{ID})?)* {
1649 yyextra->parmName=yytext;
1653 yyextra->code->codify(yytext);
1654 yyextra->inForEachExpression =
false;
1657<MemberCall2,FuncCall>, {
1658 yyextra->code->codify(yytext);
1659 addVariable(yyscanner,yyextra->parmType,yyextra->parmName);
1660 yyextra->parmType.clear();yyextra->parmName.clear();
1662<MemberCall2,FuncCall>"{" {
1663 if (yyextra->bracketCount>0)
1665 yyextra->code->codify(yytext);
1666 yyextra->skipInlineInitContext=YY_START;
1667 yyextra->curlyCount=0;
1675<InlineInit>"{" { yyextra->curlyCount++;
1676 yyextra->code->codify(yytext);
1679 yyextra->code->codify(yytext);
1680 if (--yyextra->curlyCount<=0)
1682 BEGIN(yyextra->skipInlineInitContext);
1689 yyextra->code->codify(yytext);
1691<MemberCall2,FuncCall>"(" {
1692 yyextra->parmType.clear();yyextra->parmName.clear();
1693 yyextra->code->codify(yytext);
1694 yyextra->bracketCount++;
1695 yyextra->theCallContext.pushScope(yyextra->name, yyextra->type, yyextra->bracketCount);
1696 if (YY_START==FuncCall && !yyextra->insideBody)
1698 yyextra->theVarContext.pushScope();
1701<MemberCall2,FuncCall>{OPERATOR} {
1708 yyextra->parmType.clear();yyextra->parmName.clear();
1710 yyextra->code->codify(yytext);
1712<MemberCall,MemberCall2,FuncCall>("*"{B}*)?")" {
1715 DBG_CTX((stderr,
"addVariable(%s,%s)\n",
qPrint(yyextra->parmType),
qPrint(yyextra->parmName)));
1716 if (yyextra->parmType.empty())
1718 yyextra->parmType=yyextra->parmName;
1719 yyextra->parmName.clear();
1721 addVariable(yyscanner,yyextra->parmType,yyextra->parmName);
1725 yyextra->parmType = yyextra->parmName;
1726 yyextra->parmName.clear();
1727 addVariable(yyscanner,yyextra->parmType,yyextra->parmName);
1729 yyextra->theCallContext.popScope(yyextra->name, yyextra->type, yyextra->bracketCount);
1730 yyextra->inForEachExpression =
false;
1732 yyextra->code->codify(yytext);
1733 if (--yyextra->bracketCount<=0)
1735 if (yyextra->name.empty())
1745<MemberCall,MemberCall2,FuncCall>[;:] {
1747 if (yyextra->bracketCount<=0)
1754 yyextra->code->codify(yytext);
1757<CallEnd>[ \t\n]* {
codifyLines(yyscanner,yytext); }
1760 yyextra->bracketCount=0;
1761 if (*yytext==
';') yyextra->searchingForBody=
false;
1762 if (!yyextra->type.empty())
1764 DBG_CTX((stderr,
"add variable yyextra->type=%s yyextra->name=%s)\n",
qPrint(yyextra->type),
qPrint(yyextra->name)));
1765 addVariable(yyscanner,yyextra->type,yyextra->name);
1767 yyextra->parmType.clear();yyextra->parmName.clear();
1769 if (*yytext==
';' || yyextra->insideBody)
1771 if (!yyextra->insideBody)
1773 yyextra->theVarContext.popScope();
1775 yyextra->name.clear();yyextra->type.clear();
1780 yyextra->bracketCount=0;
ScopedTypeVariant(GlobalDef d=nullptr)
1785 if (yyextra->lang!=SrcLangExt::CSharp || yyextra->insideBody)
1791 yyextra->code->codify(
"=>");
1795<CallEnd>{ENDQopt}/{BN}*(";"|"="|"throw"{BN}*"(") {
1800<CallEnd,OldStyleArgs>("const"|"volatile"|"sealed"|"override")*({BN}+("const"|"volatile"|"sealed"|"override"))*{BN}*"{" {
1801 if (yyextra->insideBody)
1803 yyextra->theVarContext.pushScope();
1805 addVariable(yyscanner,yyextra->parmType,yyextra->parmName);
1807 yyextra->parmType.clear();yyextra->parmName.clear();
1808 size_t index = yyextra->name.rfind(
"::");
1809 DBG_CTX((stderr,
"yyextra->name=%s\n",
qPrint(yyextra->name)));
1813 if (!yyextra->scopeName.empty()) scope.
prepend((yyextra->scopeName+
"::"));
1819 DBG_CTX((stderr,
"** scope stack push SCOPEBLOCK\n"));
1825 DBG_CTX((stderr,
"** scope stack push INNERBLOCK\n"));
1830 DBG_CTX((stderr,
"** scope stack push INNERBLOCK\n"));
1833 yytext[yyleng-1]=
'\0';
1835 if (!cv.stripWhiteSpace().empty())
1845 yyextra->code->codify(
"{");
1846 if (yyextra->searchingForBody)
1848 yyextra->searchingForBody=
false;
1849 yyextra->insideBody=
true;
1851 if (yyextra->insideBody) yyextra->bodyCurlyCount++;
1852 yyextra->type.clear(); yyextra->name.clear();
DString & prepend(const char *s)
static NamespaceDefMutable * globalScope
1857 yyextra->code->codify(yytext);
1859 yyextra->inFunctionTryBlock=
true;
1861<CallEnd>"requires" {
1863 yyextra->code->codify(yytext);
1867 if (yyextra->insideBody || !yyextra->parmType.empty())
1873 yyextra->parmName=yytext;
1875 BEGIN(OldStyleArgs);
1879 yyextra->parmName=yytext;
1883 yyextra->code->codify(yytext);
1884 addVariable(yyscanner,yyextra->parmType,yyextra->parmName);
1885 if (*yytext==
';') yyextra->parmType.clear();
1886 yyextra->parmName.clear();
1888<CallEnd,OldStyleArgs>"#" {
1890 yyextra->lastSkipCppContext = Body;
1891 yyextra->code->codify(yytext);
1896 if (!yyextra->insideBody)
1898 yyextra->theVarContext.popScope();
1900 yyextra->name.clear();yyextra->args.clear();
1901 yyextra->parmType.clear();yyextra->parmName.clear();
1905 yyextra->code->codify(yytext);
1906 yyextra->type.clear(); yyextra->name.clear();
1910 yyextra->code->codify(yytext);
1911 if (yyextra->searchingForBody)
1913 yyextra->searchingForBody=
false;
1914 yyextra->insideBody=
true;
1916 if (yyextra->insideBody) yyextra->bodyCurlyCount++;
1919 DBG_CTX((stderr,
"** scope stack push SCOPEBLOCK\n"));
1925 DBG_CTX((stderr,
"** scope stack push INNERBLOCK\n"));
1928 yyextra->type.clear(); yyextra->name.clear();
1931<SkipInits>{ID}{B}*"{" {
1933 size_t bracketPos = text.
find(
'{');
1934 size_t spacePos = text.
find(
' ');
1935 size_t len = spacePos==
DString::npos ? bracketPos : spacePos;
1937 yyextra->code->codify(yytext+len);
1945<FuncCall>{ID}/("."|"->") {
1946 yyextra->name=yytext;
1948 BEGIN( MemberCall2 );
1950<FuncCall,MemberCall2>("("{B}*("*"{B}*)+{ID}+{B}*")"{B}*)/("."|"->") {
1951 yyextra->code->codify(yytext);
1952 uint32_t s=0;
while (!
isId(yytext[s])) s++;
1953 uint32_t e=(uint32_t)yyleng-1;
while (e>1 && !
isId(yytext[e])) e--;
1954 yyextra->name=((
DString)yytext).mid(s,e-s+1);
1955 BEGIN( MemberCall2 );
1957<MemberCall2>{ID}/([ \t\n]*"(") {
1958 if (!yyextra->args.empty())
1962 yyextra->args.clear();
1965<MemberCall2>{ID}/([ \t\n]*("."|"->")) {
1967 yyextra->name=yytext;
1969 BEGIN( MemberCall2 );
1971<MemberCall2>"->"|"." {
1976 yyextra->code->codify(yytext);
1977 yyextra->memCallContext = YY_START;
1978 BEGIN( MemberCall );
1980<SkipComment>{CCS}("!"?){CCE} {
1981 yyextra->code->codify(yytext);
1983 BEGIN( yyextra->lastCContext ) ;
1985<SkipComment>{CPPC}|{CCS} {
1986 yyextra->code->codify(yytext);
1988<SkipComment>[^*\/\n]+ {
1989 yyextra->code->codify(yytext);
1991<SkipComment>[ \t]*{CCE} {
1992 yyextra->code->codify(yytext);
1994 if (yyextra->lastCContext==SkipCPP)
1998 BEGIN( yyextra->lastCContext ) ;
2000<SkipCxxComment>[^\r\n]*"\\"[\r]?\n {
2003<SkipCxxComment>[^\r\n]+ {
2004 yyextra->code->codify(yytext);
2010 BEGIN( yyextra->lastCContext ) ;
2013 yyextra->code->codify(yytext);
2015<MemberCall>[^a-z_A-Z0-9(\n] {
2016 yyextra->code->codify(yytext);
2017 yyextra->type.clear();
2018 yyextra->name.clear();
2019 BEGIN(yyextra->memCallContext);
2021<*>\n({B}*{CPPC}[!/][^\n]*\n)+ {
2022 if (YY_START==SkipCPP) REJECT;
2027 if (YY_START==SkipCxxComment)
2029 BEGIN( yyextra->lastCContext ) ;
2034 BEGIN( yyextra->lastSkipCppContext ) ;
2037<*>\n{B}*{CPPC}"@"[{}].*\n {
2042 if (YY_START==SkipCxxComment)
2044 BEGIN( yyextra->lastCContext ) ;
2047<*>\n{B}*{CCS}"@"[{}] {
2049 if (YY_START != SkipComment && YY_START != SkipCxxComment)
2051 yyextra->lastCContext = YY_START ;
2057<*>^{B}*{CPPC}"@"[{}].*\n {
2063<*>^{B}*{CCS}"@"[{}] {
2065 if (YY_START != SkipComment && YY_START != SkipCxxComment)
2067 yyextra->lastCContext = YY_START ;
2070 yyextra->code->codify(yytext);
2073<*>^{B}*{CPPC}[!/][^\n]* {
2078<*>{CPPC}[!/][^\n]* {
2079 if (YY_START==SkipComment || YY_START==SkipString) REJECT;
2084<*>\n{B}*{CCS}[!*]/{NCOMM} {
2086 if (YY_START != SkipComment && YY_START != SkipCxxComment)
2088 yyextra->lastCContext = YY_START ;
2094<*>^{B}*{CCS}"*"[*]+/[^/] {
2096 if (YY_START != SkipComment && YY_START != SkipCxxComment)
2098 yyextra->lastCContext = YY_START ;
2102 yyextra->code->codify(yytext);
#define Config_getBool(name)
2105<*>^{B}*{CCS}[!*]/{NCOMM} {
2107 if (YY_START != SkipComment && YY_START != SkipCxxComment)
2109 yyextra->lastCContext = YY_START ;
2112 yyextra->code->codify(yytext);
2115<*>{CCS}[!*]/{NCOMM} {
2116 if (YY_START==SkipString) REJECT;
2118 if (YY_START != SkipComment && YY_START != SkipCxxComment)
2120 yyextra->lastCContext = YY_START ;
2123 yyextra->code->codify(yytext);
2126<*>{CCS}("!"?){CCE} {
2127 if (YY_START==SkipString) REJECT;
2130 yyextra->code->codify(yytext);
2133<SkipComment>[^\*\n]+ {
2134 yyextra->code->codify(yytext);
2138 yyextra->code->codify(yytext);
2140 if (YY_START != SkipComment && YY_START != SkipCxxComment)
2142 yyextra->lastCContext = YY_START ;
2144 BEGIN( SkipComment ) ;
2148 yyextra->code->codify(yytext);
2149 yyextra->lastVerbStringContext=YY_START;
2150 BEGIN(SkipVerbString);
2154 yyextra->code->codify(yytext);
2155 yyextra->lastCContext = YY_START ;
2156 BEGIN( SkipCxxComment ) ;
2159 if (yytext[0]==
'(') yyextra->bracketCount++;
2160 yyextra->code->codify(yytext);
2161 yyextra->theCallContext.pushScope(yyextra->name, yyextra->type, yyextra->bracketCount);
2164 if (yytext[0]==
')') yyextra->bracketCount--;
2165 yyextra->code->codify(yytext);
2166 yyextra->theCallContext.popScope(yyextra->name, yyextra->type, yyextra->bracketCount);
2172 yyextra->code->codify(yytext);
2175 yyextra->code->codify(yytext);
2192 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
2200 DBG_CTX((stderr,
"** addVariable trying: type='%s' name='%s' currentDefinition=%s\n",
2201 qPrint(ltype),
qPrint(lname),yyextra->currentDefinition?
qPrint(yyextra->currentDefinition->name()):
"<none>"));
2202 auto it = yyextra->codeClassMap.find(ltype.
str());
2203 if (it!=yyextra->codeClassMap.end())
2206 yyextra->theVarContext.addVariable(lname,std::move(it->second));
2210 auto findVariableType = [&yyscanner,&yyg,<ype,&lname,&name](
const Definition *d) ->
const ClassDef *
2212 const ClassDef *varDef = yyextra->symbolResolver.resolveClass(d,ltype,
true);
2225 const ClassDef *varDef = findVariableType(yyextra->currentDefinition);
2226 if (varDef==
nullptr)
2228 for (
const auto &[usingName,namespaceDef] : yyextra->theUsingContext)
2230 varDef = findVariableType(namespaceDef);
2234 if (varDef==
nullptr)
2236 if (!yyextra->theVarContext.atGlobalScope())
2240 DBG_CTX((stderr,
"** addVariable: dummy context for '%s'\n",
qPrint(lname)));
2245 DBG_CTX((stderr,
"** addVariable: not adding variable!\n"));
2256 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
2257 yyextra->scopeNameLengthStack.push_back(
int(yyextra->scopeName.length()));
2258 if (yyextra->scopeName.empty() ||
leftScopeMatch(s,yyextra->scopeName))
2260 yyextra->scopeName = s;
2264 yyextra->scopeName +=
"::";
2265 yyextra->scopeName += s;
2274 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
2275 if (!yyextra->scopeNameLengthStack.empty())
2277 int length = yyextra->scopeNameLengthStack.back();
2278 yyextra->scopeNameLengthStack.pop_back();
2279 yyextra->scopeName.resize(length);
2285 DBG_CTX((stderr,
"popScope() result: '%s'\n",
qPrint(yyextra->scopeName)));
2290 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
2293 if (yyextra->searchCtx)
2314 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
2318 size_t ts=n.
find(
'<');
2319 size_t te=n.
rfind(
'>');
2320 DBG_CTX((stderr,
"ts=%zu te=%zu\n",ts,te));
2326 while (!yyextra->scopeNameLengthStack.empty())
2330 yyextra->scopeName.clear();
2338 DBG_CTX((stderr,
"--->New class scope '%s'\n",
qPrint(yyextra->scopeName)));
2343 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
2344 while (!yyextra->foldStack.empty())
2346 const Definition *dd = yyextra->foldStack.back();
2349 yyextra->code->endFold();
2351 yyextra->foldStack.pop_back();
2366 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
2375 if (endLine!=-1 && startLine!=endLine &&
2383 (yyextra->foldStack.empty() || yyextra->foldStack.back()->getEndBodyLine()!=startLine))
2391 yyextra->code->startFold(yyextra->yyLineNr,
"",
"");
2395 yyextra->code->startFold(yyextra->yyLineNr,
"{",
"}");
2399 yyextra->code->startFold(yyextra->yyLineNr,
"{",
"};");
2404 yyextra->code->startFold(yyextra->yyLineNr,
"{",
"};");
2408 yyextra->code->startFold(yyextra->yyLineNr,
"{",
"}");
2410 yyextra->foldStack.push_back(d);
2422 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
2424 if (yyextra->sourceFileDef && yyextra->lineNumbers)
2430 const Definition *d = yyextra->sourceFileDef->getSourceDefinition(yyextra->yyLineNr);
2432 DBG_CTX((stderr,
"%s:startCodeLine(%d)=%p\n",
qPrint(yyextra->sourceFileDef->name()),yyextra->yyLineNr,(
void*)d));
2433 if (!yyextra->includeCodeFragment && d)
2435 yyextra->currentDefinition = d;
2436 yyextra->currentMemberDef = yyextra->sourceFileDef->getSourceMember(yyextra->yyLineNr);
2437 yyextra->insideBody =
false;
2438 yyextra->searchingForBody =
true;
2440 yyextra->type.
clear();
2441 yyextra->name.clear();
2442 yyextra->args.clear();
2443 yyextra->parmType.clear();
2444 yyextra->parmName.clear();
2445 DBG_CTX((stderr,
"Real scope: '%s'\n",
qPrint(yyextra->realScope)));
2446 yyextra->bodyCurlyCount = 0;
2448 lineAnchor.
sprintf(
"l%05d",yyextra->yyLineNr);
2449 if (yyextra->currentMemberDef)
2452 yyextra->code->writeLineNumber(yyextra->currentMemberDef->getReference(),
2453 yyextra->currentMemberDef->getOutputFileBase(),
2454 yyextra->currentMemberDef->anchor(),
2455 yyextra->yyLineNr,!yyextra->includeCodeFragment);
2463 DString(),yyextra->yyLineNr,!yyextra->includeCodeFragment);
2475 !yyextra->includeCodeFragment);
2478 DBG_CTX((stderr,
"startCodeLine(%d)\n",yyextra->yyLineNr));
2479 yyextra->code->startCodeLine(yyextra->yyLineNr);
2480 yyextra->insideCodeLine =
true;
2481 if (yyextra->currentFontClass)
2483 yyextra->code->startFontClass(yyextra->currentFontClass);
2491 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
2492 DBG_CTX((stderr,
"endCodeLine(%d)\n",yyextra->yyLineNr));
2494 yyextra->code->endCodeLine();
2495 yyextra->insideCodeLine =
false;
2500 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
2501 const char * fc = yyextra->currentFontClass;
2502 if (yyextra->insideCodeLine)
2506 if (yyextra->yyLineNr<yyextra->inputLines)
2508 yyextra->currentFontClass = fc;
2518 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
2519 DBG_CTX((stderr,
"codifyLines(%d,\"%s\")\n",yyextra->yyLineNr,
qPrint(text)));
2520 if (text.
empty())
return;
2521 const char *p=text.
data(),*sp=p;
2527 while ((c=*p++) && c!=
'\n');
2530 yyextra->yyLineNr++;
2531 size_t l =
static_cast<size_t>(p-sp-1);
2532 yyextra->code->codify(
DString(sp,l));
2537 yyextra->code->codify(sp);
2546 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
2547 if (yyextra->currentMemberDef && yyextra->currentMemberDef->isFunction())
2565 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
2567 yyextra->tooltipManager.addTooltip(d);
2572 if (!sourceTooltips)
2577 const char *p=text.
data();
2582 while ((c=*p++) && c!=
'\n') { }
2585 yyextra->yyLineNr++;
2601 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
2602 if (yyextra->name==
"const") { yyextra->name.clear();
return; }
2603 if (!yyextra->type.empty()) yyextra->type +=
' ' ;
2604 yyextra->type += yyextra->name ;
2605 yyextra->name.clear() ;
2606 if (!yyextra->type.empty()) yyextra->type +=
' ' ;
2607 yyextra->type += yyextra->args ;
2608 yyextra->args.clear() ;
2613 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
2614 if (yyextra->parmName==
"const") { yyextra->parmName.clear();
return; }
2615 if (!yyextra->parmType.empty()) yyextra->parmType +=
' ' ;
2616 yyextra->parmType += yyextra->parmName ;
2617 yyextra->parmName.clear() ;
2623 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
2624 if (yyextra->sourceFileDef && !name.
empty())
2629 yyextra->theUsingContext.emplace(name.
str(),nd);
2636 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
2639 yyextra->parmName = a.name;
2640 yyextra->parmType = a.type;
2641 size_t i = yyextra->parmType.find(
'*');
2642 if (i!=
DString::npos) yyextra->parmType = yyextra->parmType.left(i);
2643 i = yyextra->parmType.find(
'&');
2644 if (i!=
DString::npos) yyextra->parmType = yyextra->parmType.left(i);
2645 yyextra->parmType.stripPrefix(
"const ");
2646 yyextra->parmType=yyextra->parmType.stripWhiteSpace();
2647 addVariable(yyscanner,yyextra->parmType,yyextra->parmName);
2653 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
2654 DBG_CTX((stderr,
"stripClassName(scope=%s,type=%s) scopeName=%s\n",
2662 DString clName=className+templSpec;
2664 if (!yyextra->scopeName.empty())
2666 cd=yyextra->symbolResolver.resolveClass(d,yyextra->scopeName+
"::"+clName,
true);
2670 cd=yyextra->symbolResolver.resolveClass(d,clName,
true);
2672 DBG_CTX((stderr,
"stripClass trying '%s' = %p\n",
qPrint(clName),(
void*)cd));
2684 if (name.
empty())
return nullptr;
2685 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
2686 DBG_CTX((stderr,
"setCallContextForVar(%s) yyextra->scopeName=%s\n",
qPrint(name),
qPrint(yyextra->scopeName)));
2688 size_t scopeEnd = name.
rfind(
"::");
2695 if (mcd && !locName.
empty())
2708 if (mnd && !locName.
empty())
2724 DBG_CTX((stderr,
"local variable?\n"));
2728 yyextra->theCallContext.setScope(*mcv);
2733 DBG_CTX((stderr,
"class member? scope=%s\n",
qPrint(yyextra->scopeName)));
2743 if (yyextra->scopeStack.empty() || yyextra->scopeStack.top()!=
CLASSBLOCK)
2760 const std::unique_ptr<MemberDef> &md=mn->
front();
2761 if (!md->isStatic() || md->getBodyDef()==yyextra->sourceFileDef)
2768 else if (mn->
size()>1)
2770 for (
const auto &md : *mn)
2779 if (!md->isStatic() || md->getBodyDef()==yyextra->sourceFileDef)
2782 DBG_CTX((stderr,
"returning member %s in source file %s\n",
qPrint(md->name()),
qPrint(yyextra->sourceFileDef->name())));
2794 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
2795 const Definition *d = yyextra->theCallContext.getScope().globalDef();
2818 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
2819 DBG_CTX((stderr,
"getLinkInScope: trying '%s'::'%s' varOnly=%d\n",
qPrint(c),
qPrint(m),varOnly));
2824 DBG_CTX((stderr,
"scopeNameLengthStack.size()=%zu\n",yyextra->scopeNameLengthStack.size()));
2825 if (!result.
found && !yyextra->scopeNameLengthStack.empty() && c==yyextra->scopeName)
2827 DString localName = yyextra->scopeName.
mid(yyextra->scopeNameLengthStack[0]+2);
2828 auto it = yyextra->codeClassMap.
find(localName.
str());
2829 if (it!=yyextra->codeClassMap.end())
2836 DBG_CTX((stderr,
"trying lookup via base class %s\n",
qPrint(bcName)));
2839 if (result.
found)
break;
2849 if (yyextra->exampleBlock)
2853 anchor.
sprintf(
"a%d",yyextra->anchorCount);
2855 qPrint(yyextra->exampleFile)));
2857 if (mdm && mdm->
addExample(anchor,yyextra->exampleName,yyextra->exampleFile))
2860 yyextra->anchorCount++;
2874 DBG_CTX((stderr,
"yyextra->currentDefinition=%p yyextra->currentMemberDef=%p yyextra->insideBody=%d\n",
2875 (
void*)yyextra->currentDefinition,(
void*)yyextra->currentMemberDef,yyextra->insideBody));
2877 if (yyextra->currentDefinition && yyextra->currentMemberDef &&
2878 yyextra->insideBody && yyextra->collectXRefs)
2900 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
2901 DBG_CTX((stderr,
"getLink(%s,%s) yyextra->curClassName=%s\n",
2907 if (!yyextra->curClassName.empty())
2910 c.
prepend(yyextra->curClassName);
2924 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
2926 if (!scopeName.
empty() && scopeName[0]==
'~')
2928 scopeName=scopeName.
mid(1);
2930 if (scopeName.
empty())
2932 yyextra->code->codify(
"~");
2935 if (yyextra->insideProtocolList)
2939 if (yyextra->lang==SrcLangExt::PHP)
2943 else if (yyextra->lang==SrcLangExt::CSharp || yyextra->lang==SrcLangExt::Java)
2947 if (yyextra->currentDefinition==
nullptr && !yyextra->scopeName.empty())
2949 scopeName = yyextra->scopeName+
"::"+scopeName;
2955 DBG_CTX((stderr,
"generateClassOrGlobalLink(name=%s) yyextra->scopeName=%s scopeName=%s\n",
qPrint(scName),
qPrint(yyextra->scopeName),
qPrint(scopeName)));
2956 if (!yyextra->isPrefixedWithThis || (lcd=yyextra->theVarContext.findVariable(scopeName))==
nullptr)
2961 auto checkForSymbol = [&yyg,&bareName,&scopeName](
const Definition *
parent,
2964 sym_ = yyextra->symbolResolver.resolveSymbol(
parent,scopeName,
DString(),
false,
true);
2965 DBG_CTX((stderr,
"non-local variable name=%s sym=%s!\n",
2966 qPrint(scopeName),sym_?
qPrint(sym_->name()):
"<none>"));
2967 if (sym_==
nullptr && !bareName.
empty())
2970 if (bareName!=scopeName)
2972 sym_ = yyextra->symbolResolver.resolveSymbol(
parent,bareName,
DString(),
false,
true);
2976 const Definition *d = yyextra->currentDefinition;
2977 DBG_CTX((stderr,
"d=%s yyextra->sourceFileDef=%s\n",d?
qPrint(d->
name()):
"<none>",yyextra->sourceFileDef?
qPrint(yyextra->sourceFileDef->name()):
"<none>"));
2978 checkForSymbol(d,sym);
2987 checkForSymbol(nd,sym);
2995 for (
const auto &[usingName,namespaceDef] : yyextra->theUsingContext)
2997 checkForSymbol(namespaceDef,sym);
3019 DBG_CTX((stderr,
"is found as a type sym=%s nd=%s\n",
3024 if (
getLink(yyscanner,yyextra->scopeName,scName,ol,scName,varOnly))
3032 DBG_CTX((stderr,
"local variable!\n"));
3036 yyextra->theCallContext.setScope(*lcd);
3047 DBG_CTX((stderr,
"is a local variable sym=%p!\n",(
void*)sym));
3049 yyextra->isPrefixedWithThis =
false;
3054 if (yyextra->exampleBlock)
3058 anchor.
sprintf(
"_a%d",yyextra->anchorCount);
3059 DBG_CTX((stderr,
"addExampleClass(%s,%s,%s)\n",
qPrint(anchor),
qPrint(yyextra->exampleName),
3060 qPrint(yyextra->exampleFile)));
3064 if (cdm && cdm->
addExample(anchor,yyextra->exampleName,yyextra->exampleFile))
3067 yyextra->anchorCount++;
3073 if (mdm && mdm->
addExample(anchor,yyextra->exampleName,yyextra->exampleFile))
3076 yyextra->anchorCount++;
3089 yyextra->currentMemberDef && yyextra->collectXRefs)
3103 DBG_CTX((stderr,
"class %s not linkable! cd=%p typeOnly=%d\n",
qPrint(scName),(
void*)sym,typeOnly));
3104 if (!isLocal && (md || (!sym && !typeOnly)))
3109 DBG_CTX((stderr,
"setCallContextForVar(%s) md=%p yyextra->currentDefinition=%s\n",
qPrint(scName),(
void*)md,yyextra->currentDefinition ?
qPrint(yyextra->currentDefinition->name()) :
"<none>"));
3110 if (md && yyextra->currentDefinition)
3112 DBG_CTX((stderr,
"%s accessible from %s? %d md->getOuterScope=%s\n",
3113 qPrint(md->name()),
qPrint(yyextra->currentDefinition->name()),
3114 yyextra->symbolResolver.isAccessibleFrom(yyextra->currentDefinition,md),
3115 qPrint(md->getOuterScope()->name())));
3118 if (md && yyextra->currentDefinition &&
3119 yyextra->symbolResolver.isAccessibleFrom(yyextra->currentDefinition,md)==-1)
3126 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()));
3127 if (md->isLinkable())
3131 if (yyextra->currentMemberDef && yyextra->collectXRefs)
3141 DBG_CTX((stderr,
"not found!\n"));
3152 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
3156 DBG_CTX((stderr,
"type='%s' args='%s' class=%s\n",
3160 if (yyextra->exampleBlock)
3164 anchor.
sprintf(
"a%d",yyextra->anchorCount);
3166 qPrint(yyextra->exampleFile)));
3168 if (mdm && mdm->
addExample(anchor,yyextra->exampleName,yyextra->exampleFile))
3171 yyextra->anchorCount++;
3185 DBG_CTX((stderr,
"yyextra->currentDefinition=%p yyextra->currentMemberDef=%p xmd=%p yyextra->insideBody=%d\n",
3186 (
void*)yyextra->currentDefinition,(
void*)yyextra->currentMemberDef,(
void*)xmd,yyextra->insideBody));
3188 if (xmd->templateMaster()) xmd = xmd->templateMaster();
3190 if (xmd->isLinkable())
3193 if (yyextra->currentDefinition && yyextra->currentMemberDef &&
3194 yyextra->insideBody && yyextra->collectXRefs)
3214 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
3219 DBG_CTX((stderr,
"generateClassMemberLink(class=%s,member=%s)=%p\n",
qPrint(def->
name()),
qPrint(memName),(
void*)xmd));
3257 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
3258 DBG_CTX((stderr,
"generateMemberLink(object=%s,mem=%s) classScope=%s\n",
3261 if (varName.
empty())
return;
3269 DBG_CTX((stderr,
"Class found!\n"));
3272 DBG_CTX((stderr,
"Found result!\n"));
3279 if (
getLink(yyscanner,bcName,memName,ol))
3281 DBG_CTX((stderr,
"Found result!\n"));
3290 const ClassDef *vcd = yyextra->symbolResolver.resolveClass(yyextra->currentDefinition,yyextra->scopeName,
true);
3293 DBG_CTX((stderr,
"Found class %s for variable '%s'\n",
qPrint(yyextra->scopeName),
qPrint(varName)));
3306 for (
const auto &vmd : *vmn)
3308 if (vmd->getClassDef()==jcd)
3310 DBG_CTX((stderr,
"Found variable type=%s\n",
qPrint(vmd->typeString())));
3323 DBG_CTX((stderr,
"There is a variable with name '%s'\n",
qPrint(varName)));
3324 for (
const auto &vmd : *vmn)
3326 if (vmd->getClassDef()==vcd)
3328 DBG_CTX((stderr,
"Found variable type=%s\n",
qPrint(vmd->typeString())));
3347 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
3350 DBG_CTX((stderr,
"generatePHPVariableLink(%s) name=%s scope=%s\n",varName,
qPrint(name),
qPrint(yyextra->scopeName)));
3351 if (!
getLink(yyscanner,yyextra->scopeName,name,ol,varName))
3359 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
3361 DString locScope=yyextra->scopeName;
3363 if (yyextra->lang==SrcLangExt::PHP && locFunc.
startsWith(
"self::")) locFunc=locFunc.
mid(4);
3365 DString funcWithScope=locFunc;
3366 DString funcWithFullScope=locFunc;
3370 size_t i=locFunc.
rfind(
"::");
3371 if (yyextra->currentMemberDef && yyextra->currentMemberDef->resolveAlias()->getClassDef() &&
3372 funcName==yyextra->currentMemberDef->localName() &&
3373 yyextra->currentMemberDef->getDefLine()==yyextra->yyLineNr &&
3387 i=locFunc.
rfind(
".");
3392 i=locFunc.
rfind(
"\\");
3397 funcScope=locFunc.
left(i);
3399 size_t ts=locScope.
find(
'<');
3400 size_t te=locScope.
rfind(
'>');
3401 DBG_CTX((stderr,
"ts=%zu te=%zu\n",ts,te));
3405 locScope=locScope.
left(ts)+locScope.
mid(te+1);
3407 ts=funcScope.
find(
'<');
3408 te=funcScope.
rfind(
'>');
3409 DBG_CTX((stderr,
"ts=%zu te=%zu\n",ts,te));
3413 funcScope=funcScope.
left(ts)+funcScope.
mid(te+1);
3415 if (!funcScope.
empty())
3417 funcWithScope = funcScope+
"::"+locFunc;
3418 if (!locScope.
empty())
3420 fullScope=locScope+
"::"+funcScope;
3423 if (!locScope.
empty())
3425 funcWithFullScope = locScope+
"::"+funcWithScope;
3429 if (!fullScope.
empty())
3431 auto it = yyextra->codeClassMap.find(fullScope.
str());
3432 if (it!=yyextra->codeClassMap.end())
3439 if (
getLink(yyscanner,bcName,locFunc,ol,funcName))
3448 if (!locScope.
empty() && fullScope!=locScope)
3450 auto it = yyextra->codeClassMap.find(locScope.
str());
3451 if (it!=yyextra->codeClassMap.end())
3458 if (
getLink(yyscanner,bcName,funcWithScope,ol,funcName))
3466 if (!
getLink(yyscanner,locScope,funcWithScope,ol,funcName))
3477 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
3478 const char *p=yyextra->inputString;
3484 if (c==
'\n') count++;
3486 if (p>yyextra->inputString && *(p-1)!=
'\n')
3495 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
3496 if (yyextra->currentFontClass)
3498 yyextra->code->endFontClass();
3499 yyextra->currentFontClass=
nullptr;
3501 if (specialComment && yyextra->insideSpecialComment)
3503 yyextra->code->endSpecialComment();
3504 yyextra->insideSpecialComment =
false;
3510 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
3514 yyextra->code->startSpecialComment();
3515 yyextra->insideSpecialComment =
true;
3517 yyextra->code->startFontClass(s);
3518 yyextra->currentFontClass=s;
3526 if (ctx==
nullptr)
return;
3527 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
3531 DBG_CTX((stderr,
"writeObjCMethodCall(%s) obj=%s method=%s\n",
3540 DBG_CTX((stderr,
" object is local variable\n"));
3548 DBG_CTX((stderr,
" class=%p method=%p\n",(
void*)cd,(
void*)ctx->
method));
3559 char skipChar =
' ';
3584 yyextra->code->codify(
"$");
3592 while (nc!=0 && isdigit(nc)) { refIdStr+=nc; nc=*p++; }
3594 int refId=refIdStr.
toInt();
3595 auto it = yyextra->nameMap.find(refId);
3596 if (it!=yyextra->nameMap.end())
3602 if (yyextra->currentMemberDef && yyextra->collectXRefs)
3614 DBG_CTX((stderr,
"Invalid name: id=%d\n",refId));
3621 while (nc!=0 && isdigit(nc)) { refIdStr+=nc; nc=*p++; }
3623 int refId=refIdStr.
toInt();
3624 auto it = yyextra->objectMap.find(refId);
3625 if (it!=yyextra->objectMap.end())
3630 if (yyextra->currentDefinition &&
3647 else if (
object==
"super")
3649 if (yyextra->currentDefinition &&
3676 if (yyextra->currentMemberDef && yyextra->collectXRefs)
3689 size_t dotPos =
object.find(
'.',pp);
3690 size_t len =
object.length();
3692 const Definition *scope = yyextra->currentDefinition;
3699 if (fragmentStripped==
"self")
3712 const Definition *symbol = yyextra->symbolResolver.resolveSymbol(scope,fragmentStripped,
DString(),
false,
true);
3718 ctx->
method = yyextra->symbolResolver.getTypedef();
3742 dotPos=
object.find(
'.',pp);
3752 else if (ctx->
method==
nullptr)
3755 DBG_CTX((stderr,
"yyextra->currentDefinition=%p\n",(
void*)yyextra->currentDefinition));
3756 if (yyextra->currentDefinition &&
3777 DBG_CTX((stderr,
"Invalid object: id=%d\n",refId));
3784 while (nc!=0 && isdigit(nc)) { refIdStr+=nc; nc=*p++; }
3786 int refId=refIdStr.
toInt();
3787 auto it = yyextra->contextMap.find(refId);
3788 if (it!=yyextra->contextMap.end())
3803 if (mn && mn->
size()==1)
3821 DBG_CTX((stderr,
"Invalid context: id=%d\n",refId));
3828 while (nc!=0 && isdigit(nc)) { refIdStr+=nc; nc=*p++; }
3830 int refId=refIdStr.
toInt();
3831 auto it = yyextra->wordMap.find(refId);
3832 if (it!=yyextra->wordMap.end())
3835 bool isKeyword = word==
"self";
3851 while (nc!=0 && isdigit(nc)) { refIdStr+=nc; nc=*p++; }
3853 int refId=refIdStr.
toInt();
3854 auto it = yyextra->commentMap.find(refId);
3855 if (it!=yyextra->commentMap.end())
3869 else if (c==
'\'' || c ==
'"')
3886 DBG_CTX((stderr,
"}=(type='%s',name='%s')",
3896 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
3898 result.
sprintf(
"$n%d",yyextra->currentNameId);
3899 yyextra->nameMap.emplace(yyextra->currentNameId,s);
3900 yyextra->currentNameId++;
3906 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
3908 result.
sprintf(
"$o%d",yyextra->currentObjId);
3909 yyextra->objectMap.emplace(yyextra->currentObjId,s);
3910 yyextra->currentObjId++;
3916 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
3918 result.
sprintf(
"$w%d",yyextra->currentWordId);
3919 yyextra->wordMap.emplace(yyextra->currentWordId,s);
3920 yyextra->currentWordId++;
3926 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
3928 result.
sprintf(
"$d%d",yyextra->currentCommentId);
3929 yyextra->commentMap.emplace(yyextra->currentCommentId,s);
3930 yyextra->currentCommentId++;
3936 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
3937 static const std::unordered_set<std::string> non_cpp_keywords = {
3938 "__assume",
"__super",
"abstract",
"function",
3939 "gcnew",
"gcroot",
"generic",
"get",
3940 "internal",
"null",
"pin_ptr",
"raise",
3941 "remove",
"self",
"set",
"transient",
3944 static const std::unordered_set<std::string> non_java_keywords = {
3945 "alignas",
"alignof",
"and",
"and_eq",
"asm",
3946 "atomic_cancel",
"atomic_commit",
"atomic_noexcept",
"auto",
"bitand",
3947 "bitor",
"bool",
"char8_t",
"char16_t",
"char32_t",
3948 "compl",
"concept",
"consteval",
"constexpr",
"constinit",
3949 "const_cast",
"co_await",
"co_return",
"co_yield",
"decltype",
3950 "delete",
"dynamic_cast",
"explicit",
"export",
"extern",
3951 "friend",
"inline",
"mutable",
"namespace",
"noexcept",
3952 "not",
"not_eq",
"nullptr",
"operator",
"or",
3953 "or_eq",
"reflexpr",
"register",
"reinterpret_cast",
"requires",
3954 "signed",
"sizeof",
"static_assert",
"_Static_assert",
"static_cast",
"struct",
3955 "template",
"thread_local",
"typedef",
"typeid",
"typename",
3956 "union",
"unsigned",
"using",
"virtual",
"wchar_t",
3957 "xor",
"xor_eq",
"override",
"sealed"
3959 bool retval =
false;
3960 switch (yyextra->lang)
3962 case SrcLangExt::Cpp:
3963 retval = (non_cpp_keywords.find(keyword) != non_cpp_keywords.end());
3965 case SrcLangExt::Java:
3966 retval = (non_java_keywords.find(keyword) != non_java_keywords.end());
3978 size_t i=s.
find(
'<');
3981 return kw==
"const_cast" || kw==
"static_cast" || kw==
"dynamic_cast" || kw==
"reinterpret_cast";
3986 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
3987 yy_size_t inputPosition = yyextra->inputPosition;
3988 const char *s = yyextra->inputString + inputPosition;
3990 while( c < max_size && *s )
3995 yyextra->inputPosition += c;
4002 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
4003 if (yyextra->currentCtx)
4005 yyextra->currentCtx->format+=
DString().sprintf(
"$c%d",yyextra->currentCtxId);
4006 if (yyextra->braceCount==0 && YY_START==ObjCCall)
4008 yyextra->currentCtx->objectTypeOrName=yyextra->currentCtx->format.mid(1);
4009 DBG_CTX((stderr,
"new type=%s\n",
qPrint(yyextra->currentCtx->objectTypeOrName)));
4011 yyextra->contextStack.push(yyextra->currentCtx);
4015 DBG_CTX((stderr,
"Trying to save NULL context!\n"));
4017 auto newCtx = std::make_unique<ObjCCallCtx>();
4018 newCtx->id = yyextra->currentCtxId;
4019 newCtx->lexState = YY_START;
4020 newCtx->braceCount = yyextra->braceCount;
4021 newCtx->objectType =
nullptr;
4022 newCtx->objectVar =
nullptr;
4023 newCtx->method =
nullptr;
4024 DBG_CTX((stderr,
"save state=%d\n",YY_START));
4025 yyextra->currentCtx = newCtx.get();
4026 yyextra->contextMap.emplace(yyextra->currentCtxId,std::move(newCtx));
4027 yyextra->braceCount = 0;
4028 yyextra->currentCtxId++;
4033 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
4034 DBG_CTX((stderr,
"restore state=%d->%d\n",YY_START,yyextra->currentCtx->lexState));
4035 BEGIN(yyextra->currentCtx->lexState);
4036 yyextra->braceCount = yyextra->currentCtx->braceCount;
4037 if (!yyextra->contextStack.empty())
4039 yyextra->currentCtx = yyextra->contextStack.top();
4040 yyextra->contextStack.pop();
4044 yyextra->currentCtx =
nullptr;
4045 DBG_CTX((stderr,
"Trying to pop context while yyextra->contextStack is empty!\n"));
4057 codeYYlex_init_extra(&
p->state,&
p->yyscanner);
4066 codeYYlex_destroy(
p->yyscanner);
4071 struct yyguts_t *yyg = (
struct yyguts_t*)
p->yyscanner;
4072 DBG_CTX((stderr,
"***CodeParser::reset()\n"));
4073 yyextra->theVarContext.clear();
4074 while (!yyextra->scopeNameLengthStack.empty()) yyextra->scopeNameLengthStack.pop_back();
4075 yyextra->codeClassMap.clear();
4076 yyextra->curClassBases.clear();
4077 yyextra->anchorCount = 0;
4078 yyextra->insideCodeLine =
false;
4083 struct yyguts_t *yyg = (
struct yyguts_t*)
p->yyscanner;
4084 yyextra->insideCodeLine = inp;
4089 struct yyguts_t *yyg = (
struct yyguts_t*)
p->yyscanner;
4090 return yyextra->insideCodeLine;
4097 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
4098 DBG_CTX((stderr,
"***parseCode() exBlock=%d exName=%s fd=%p scopeName=%s searchCtx=%s\n",
4102 if (s.
empty())
return;
4108 yyextra->code = &od;
4109 yyextra->inputString = s.
data();
4112 yyextra->inputPosition = 0;
4113 codeYYrestart(
nullptr,yyscanner);
4114 yyextra->currentFontClass =
nullptr;
4115 yyextra->searchCtx = options.
searchCtx();
4117 yyextra->inFunctionTryBlock =
false;
4118 yyextra->symbolResolver.setFileScope(options.
fileDef());
4119 yyextra->foldStack.clear();
4120 yyextra->insideSpecialComment =
false;
4123 yyextra->curlyCount = 0;
4124 yyextra->bodyCurlyCount = 0;
4125 yyextra->bracketCount = 0;
4126 yyextra->sharpCount = 0;
4127 yyextra->insideTemplate =
false;
4128 yyextra->theCallContext.clear();
4129 while (!yyextra->scopeStack.empty()) yyextra->scopeStack.pop();
4130 yyextra->scopeName = scopeName;
4132 yyextra->exampleBlock = options.
isExample();
4134 yyextra->sourceFileDef = options.
fileDef();
4136 if (options.
fileDef()==
nullptr)
4140 yyextra->sourceFileDef = yyextra->exampleFileDef.get();
4142 yyextra->lang = lang;
4143 yyextra->insideObjC = lang==SrcLangExt::ObjC;
4144 if (yyextra->sourceFileDef)
4149 yyextra->currentMemberDef =
nullptr;
4150 yyextra->searchingForBody = options.
isExample();
4151 yyextra->insideBody =
false;
4152 yyextra->bracketCount = 0;
4153 if (!yyextra->exampleName.empty())
4155 yyextra->exampleFile =
convertNameToFile(yyextra->exampleName+
"-example",
false,
true);
4156 DBG_CTX((stderr,
"yyextra->exampleFile=%s\n",
qPrint(yyextra->exampleFile)));
4160 if (!yyextra->insideCodeLine)
4164 yyextra->type.clear();
4165 yyextra->name.clear();
4166 yyextra->args.clear();
4167 yyextra->parmName.clear();
4168 yyextra->parmType.clear();
4171 codeYYlex(yyscanner);
4172 yyextra->lexInit=
true;
4173 if (yyextra->insideCodeLine)
4179 while (!yyextra->foldStack.empty())
4181 yyextra->code->endFold();
4182 yyextra->foldStack.pop_back();
4185 if (yyextra->exampleFileDef)
4188 yyextra->exampleFileDef.reset();
4189 yyextra->sourceFileDef=
nullptr;
4192 yyextra->tooltipManager.writeTooltips(od);
void resetCodeParserState() override
Resets the state of the code parser.
void setInsideCodeLine(bool inp)
std::unique_ptr< Private > p
void parseCode(OutputCodeList &codeOutIntf, const DString &scopeName, const DString &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.
bool insideCodeLine() const
virtual const MemberDef * getMemberByName(const DString &) const =0
Returns the member with the given name.
virtual const BaseClassList & baseClasses() const =0
Returns the list of base classes from which this class directly inherits.
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 DString &anchor, const DString &name, const DString &file)=0
size_t rfind(char c, size_t pos=npos) const
DString simplifyWhiteSpace() const
return a copy of this string with leading and trailing whitespace removed and multiple whitespace cha...
bool empty() const
Returns true iff the string is empty (std::string compatible alias for isEmpty()).
char & at(size_t i)
Returns a reference to the character at index i.
DString & sprintf(const char *format,...)
int toInt(bool *ok=nullptr, int base=10) const
const std::string & str() const
bool stripPrefix(const DString &prefix)
const char * data() const
Returns a pointer to the contents of the string in the form of a 0-terminated C string.
bool startsWith(const char *s) const
size_t length() const
Returns the length of the string, not counting the 0-terminator.
static bool isFlagSet(const DebugMask mask)
virtual int getEndBodyLine() const =0
virtual DefType definitionType() const =0
virtual DString briefDescriptionAsTooltip() const =0
virtual bool isLinkableInProject() const =0
virtual DString qualifiedName() const =0
virtual DString anchor() const =0
virtual int getStartDefLine() const =0
virtual DString getReference() const =0
virtual CodeSymbolType codeSymbolType() const =0
virtual Definition * getOuterScope() const =0
virtual const Definition * findInnerCompound(const DString &name) const =0
virtual DString getOutputFileBase() const =0
static NamespaceLinkedMap * namespaceLinkedMap
static MemberNameLinkedMap * functionNameLinkedMap
static std::mutex countFlowKeywordsMutex
static MemberNameLinkedMap * memberNameLinkedMap
static SearchIndexIntf searchIndex
static std::mutex addExampleMutex
virtual DString fileName() const =0
virtual const LinkedRefMap< NamespaceDef > & getUsedNamespaces() const =0
std::vector< DString > baseClasses() const
virtual DString argsString() 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 DString typeString() const =0
virtual bool isCallable() const =0
virtual void incrementFlowKeyWordCount()=0
virtual bool addExample(const DString &anchor, const DString &name, const DString &file)=0
An abstract interface of a namespace symbol.
virtual const MemberDef * getMemberByName(const DString &) const =0
void writeCodeAnchor(const DString &name)
void writeCodeLink(CodeSymbolType type, const DString &ref, const DString &file, const DString &anchor, const DString &name, const DString &tooltip)
void stripCodeComments(bool b)
const Definition * globalDef() const
void addWord(const DString &word, bool hiPriority)
void setCurrentDoc(const Definition *ctx, const DString &anchor, bool isSourceFile)
ClassDefMutable * toClassDefMutable(Definition *d)
ClassDef * getClass(const DString &n)
static void codeFolding(yyscan_t yyscanner, const Definition *d)
ConceptDef * getResolvedConcept(const Definition *d, const DString &name)
constexpr DocNodeVariant * parent(DocNodeVariant *n)
returns the parent node of a given node n or nullptr if the node has no parent.
std::unique_ptr< FileDef > createFileDef(const DString &p, const DString &n, const DString &ref, const DString &dn)
void addDocCrossReference(const MemberDef *s, const MemberDef *d)
MemberDefMutable * toMemberDefMutable(Definition *d)
MemberDef * toMemberDef(Definition *d)
NamespaceDef * getResolvedNamespace(const DString &name)
NamespaceDef * toNamespaceDef(Definition *d)
This class contains the information about the argument of a function or template.
Options to configure the code parser.
const Definition * searchCtx() const
DString exampleName() const
const FileDef * fileDef() const
const MemberDef * memberDef() const
bool showLineNumbers() const
bool inlineFragment() const
bool collectXRefs() const
Helper to pass the result parameters from getDefs().
DString convertNameToFile(const DString &name, bool allowDots, bool allowUnderscore)
bool leftScopeMatch(const DString &scope, const DString &name)
GetDefResult getDefs(const GetDefInput &input)
int extractClassNameFromType(const DString &type, int &pos, DString &name, DString &templSpec, SrcLangExt lang)
DString removeAnonymousScopes(const DString &str)