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>
74#define DBG_CTX(x) do { } while(0)
76#define YY_NO_UNISTD_H 1
180 std::unordered_map< int,std::unique_ptr<ObjCCallCtx> >
contextMap;
239 bool typeOnly=
false,
bool varOnly=
false);
261#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.
272ID [$a-z_A-Z\x80-\xFF][$a-z_A-Z0-9\x80-\xFF]*
274SCOPENAME ("::"{BN}*)?({ID}{BN}*{SEP}{BN}*)*("~"{BN}*)?{ID}
275TEMPLIST "<"[^\"\}\{\(\)\/\n>]*">"
276SCOPETNAME (((({ID}{TEMPLIST}?){BN}*)?{SEP}{BN}*)*)((~{BN}*)?{ID})
277SCOPEPREFIX ({ID}{TEMPLIST}?{BN}*{SEP}{BN}*)+
278KEYWORD_OBJC ("@public"|"@private"|"@protected"|"@class"|"@implementation"|"@interface"|"@end"|"@selector"|"@protocol"|"@optional"|"@required"|"@throw"|"@synthesize"|"@property")
280KEYWORD ("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"))
281FLOWKW ("break"|"catch"|"continue"|"default"|"do"|"else"|"finally"|"return"|"switch"|"throw"|"throws"|"@catch"|"@finally")
282FLOWCONDITION ("case"|"for"|"foreach"|"for each"|"goto"|"if"|"try"|"while"|"@try")
283TYPEKW ("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")
284TYPEKWSL ("LocalObject"|"Object"|"Value")
285CASTKW ("const_cast"|"dynamic_cast"|"reinterpret_cast"|"static_cast")
286CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^' \\\n]{1,4}"'"))
287ARITHOP "+"|"-"|"/"|"*"|"%"|"--"|"++"
288ASSIGNOP "="|"*="|"/="|"%="|"+="|"-="|"<<="|">>="|"&="|"^="|"|="
289LOGICOP "=="|"!="|">"|"<"|">="|"<="|"&&"|"||"|"!"|"<=>"
290BITOP "&"|"|"|"^"|"<<"|">>"|"~"
291OPERATOR {ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}
292RAWBEGIN (u|U|L|u8)?R\"[^ \t\(\)\\]{0,16}"("
293RAWEND ")"[^ \t\(\)\\]{0,16}\"
294MODULE_ID ({ID}".")*{ID}
300DECIMAL_INTEGER [1-9][0-9']*[0-9]?[uU]?[lL]?[lL]?
301HEXADECIMAL_INTEGER "0"[xX][0-9a-zA-Z']+[0-9a-zA-Z]?
302OCTAL_INTEGER "0"[0-7][0-7']+[0-7]?
303BINARY_INTEGER "0"[bB][01][01']*[01]?
304INTEGER_NUMBER {DECIMAL_INTEGER}|{HEXADECIMAL_INTEGER}|{OCTAL_INTEGER}|{BINARY_INTEGER}
308DIGIT_SEQ [0-9][0-9']*[0-9]?
309FRAC_CONST {DIGIT_SEQ}"."|{DIGIT_SEQ}?"."{DIGIT_SEQ}
310FP_EXP [eE][+-]?{DIGIT_SEQ}
311DEC_FP1 {FRAC_CONST}{FP_EXP}?{FP_SUF}?
312DEC_FP2 {DIGIT_SEQ}{FP_EXP}{FP_SUF}
314HEX_DIGIT_SEQ [0-9a-fA-F][0-9a-fA-F']*[0-9a-fA-F]?
315HEX_FRAC_CONST {HEX_DIGIT_SEQ}"."|{HEX_DIGIT_SEQ}?"."{HEX_DIGIT_SEQ}
316BIN_EXP [pP][+-]?{DIGIT_SEQ}
317HEX_FP1 "0"[xX]{HEX_FRAC_CONST}{BIN_EXP}{FP_SUF}?
318HEX_FP2 "0"[xX]{HEX_DIGIT_SEQ}{BIN_EXP}{FP_SUF}?
320FLOAT_DECIMAL {DEC_FP1}|{DEC_FP2}
321FLOAT_HEXADECIMAL {HEX_FP1}|{HEX_FP2}
322FLOAT_NUMBER {FLOAT_DECIMAL}|{FLOAT_HEXADECIMAL}
323NUMBER {INTEGER_NUMBER}|{FLOAT_NUMBER}
336ENDQopt ("const"|"volatile"|"sealed"|"override")({BN}+("const"|"volatile"|"sealed"|"override"))*
357%x CppCliTypeModifierFollowup
382<Body>^([ \t]*"#"[ \t]*("include"|"import")[ \t]*)("<"|"\"") {
384 yyextra->code->codify(yytext);
385 BEGIN( ReadInclude );
387<Body>("@interface"|"@implementation"|"@protocol")[ \t\n]+ {
388 yyextra->insideObjC=
true;
392 if (!yyextra->insideTemplate)
395<Body>(("public"|"private"){B}+)?("ref"|"value"|"interface"|"enum"){B}+("class"|"struct") {
396 if (yyextra->insideTemplate) REJECT;
402<Body>"property"|"event"/{BN}* {
403 if (yyextra->insideTemplate) REJECT;
408<Body>("partial"{B}+)?("class"|"struct"|"union"|"namespace"|"interface"){B}+ {
412 if (!yyextra->insideTemplate)
415<Body>("package")[ \t\n]+ {
419 BEGIN( PackageName );
422 if (!yyextra->insideObjC) REJECT;
426<Body,ClassVar,Bases>"-"|"+" {
427 if (!yyextra->insideObjC || yyextra->insideBody)
429 yyextra->code->codify(yytext);
433 DBG_CTX((stderr,
"Start of Objective-C method!\n"));
434 yyextra->code->codify(yytext);
439 yyextra->code->codify(yytext);
443 yyextra->code->codify(yytext);
444 BEGIN(ObjCParamType);
446<ObjCParams,ObjCMethod>";"|"{" {
447 yyextra->code->codify(yytext);
450 if (yyextra->searchingForBody)
452 yyextra->searchingForBody=
false;
453 yyextra->insideBody=
true;
455 if (yyextra->insideBody) yyextra->bodyCurlyCount++;
456 if (!yyextra->curClassName.empty())
458 pushScope(yyscanner,yyextra->curClassName);
459 DBG_CTX((stderr,
"** scope stack push SCOPEBLOCK\n"));
463 yyextra->type.clear();
464 yyextra->name.clear();
467<ObjCParams>{ID}{B}*":" {
468 yyextra->code->codify(yytext);
470<ObjCParamType>{TYPEKW} {
472 yyextra->code->codify(yytext);
474 yyextra->parmType=yytext;
478 yyextra->parmType=yytext;
481 yyextra->code->codify(yytext);
485 yyextra->code->codify(yytext);
486 yyextra->parmName=yytext;
487 addVariable(yyscanner,yyextra->parmType,yyextra->parmName);
488 yyextra->parmType.clear();yyextra->parmName.clear();
490<ObjCMethod,ObjCParams,ObjCParamType>{ID} {
493<ObjCMethod,ObjCParams,ObjCParamType>. {
494 yyextra->code->codify(yytext);
496<ObjCMethod,ObjCParams,ObjCParamType>\n {
499<ReadInclude>[^\n\">]+/(">"|"\"") {
510 DBG_CTX((stderr,
"===== yes %s is ambiguous\n",yytext));
512 if (!name.empty() && yyextra->sourceFileDef)
518 auto it = std::find_if(fn->begin(),
520 [&sfd=yyextra->sourceFileDef]
522 { return sfd->isIncluded(lfd->absFilePath()); });
523 found = it!=fn->end();
539 yyextra->code->codify(yytext);
541 char c=(char)yyinput(yyscanner);
544 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.
FileDef * findFileDef(const DString &n, bool &ambig) const
Returns the file definition in fnMap that matches the file name n.
const T * find(const std::string &key) const
const char * qPrint(const char *s)
DString determineAbsoluteIncludeName(const DString &curFile, const DString &incFileName)
548<Body,Bases>^[ \t]*"#" {
550 yyextra->lastSkipCppContext = YY_START;
551 yyextra->code->codify(yytext);
555 yyextra->code->codify(yytext);
556 yyextra->lastStringContext=YY_START;
557 BEGIN( SkipString ) ;
560 yyextra->code->codify(yytext);
562<SkipCPP>[^\n\/\\\"]+ {
563 yyextra->code->codify(yytext);
568<SkipCPP>{CPPC}/[^/!] {
571<Body,FuncCall,MemberCall,MemberCall2>"}" {
572 yyextra->theVarContext.popScope();
573 yyextra->theCallContext.popScope(yyextra->name, yyextra->type, yyextra->bracketCount);
574 yyextra->type.clear();
575 yyextra->name.clear();
577 if (!yyextra->scopeStack.empty())
579 int scope = yyextra->scopeStack.top();
580 yyextra->scopeStack.pop();
588 yyextra->code->codify(yytext);
590 DBG_CTX((stderr,
"yyextra->bodyCurlyCount=%d\n",yyextra->bodyCurlyCount));
591 if (--yyextra->bodyCurlyCount<=0)
593 yyextra->insideBody=
false;
594 yyextra->currentMemberDef=
nullptr;
595 if (yyextra->currentDefinition)
596 yyextra->currentDefinition=yyextra->currentDefinition->getOuterScope();
600<Body,ClassVar>"@end" {
601 DBG_CTX((stderr,
"End of objc scope fd=%s\n",
qPrint(yyextra->sourceFileDef->name())));
602 if (yyextra->sourceFileDef)
604 const FileDef *fd=yyextra->sourceFileDef;
607 DBG_CTX((stderr,
"insideObjC=%d\n",yyextra->insideObjC));
611 yyextra->insideObjC =
false;
613 if (yyextra->insideBody)
615 yyextra->theVarContext.popScope();
617 if (!yyextra->scopeStack.empty())
619 int scope = yyextra->scopeStack.top();
620 yyextra->scopeStack.pop();
627 yyextra->insideBody=
false;
631 yyextra->code->codify(yytext);
634 yyextra->currentMemberDef=
nullptr;
635 if (yyextra->currentDefinition)
636 yyextra->currentDefinition=yyextra->currentDefinition->getOuterScope();
bool endsWith(const char *s) const
virtual const DString & name() const =0
639<ClassName,ClassVar>";" {
640 if (yyextra->lang==SrcLangExt::CSharp)
642 yyextra->code->codify(yytext);
643 yyextra->skipCodify =
true;
648 yyextra->code->codify(yytext);
649 yyextra->searchingForBody=
false;
653<ClassName,ClassVar>[*&^%]+ {
654 yyextra->type=yyextra->curClassName;
655 yyextra->name.clear();
656 yyextra->code->codify(yytext);
659<ClassName>"__declspec"{B}*"("{B}*{ID}{B}*")" {
661 yyextra->code->codify(yytext);
664<ClassName>{ID}("."{ID})* |
665<ClassName>{ID}("::"{ID})* {
666 if (yyextra->lang==SrcLangExt::CSharp)
667 yyextra->curClassName=
substitute(yytext,
".",
"::");
669 yyextra->curClassName=yytext;
671 if (yyextra->curClassName==
"alignas")
674 yyextra->code->codify(yytext);
DString substitute(const DString &s, const DString &src, const DString &dst)
substitute all occurrences of src in s by dst
685 yyextra->bracketCount=1;
686 yyextra->code->codify(yytext);
689<AlignAs>\n { yyextra->yyLineNr++;
692<AlignAs>. { yyextra->code->codify(yytext); }
693<AlignAsEnd>"(" { yyextra->code->codify(yytext);
694 yyextra->bracketCount++;
697 yyextra->code->codify(yytext);
698 if (--yyextra->bracketCount<=0)
703<AlignAsEnd>\n { yyextra->yyLineNr++;
706<AlignAsEnd>. { yyextra->code->codify(yytext); }
707<ClassName>{ID}("\\"{ID})* {
708 yyextra->curClassName=
substitute(yytext,
"\\",
"::");
710 pushScope(yyscanner,yyextra->curClassName);
715<ClassName>{ID}{B}*"("{ID}")" {
718 pushScope(yyscanner,yyextra->curClassName);
DString removeRedundantWhiteSpace(const DString &s)
723<PackageName>{ID}("."{ID})* {
724 yyextra->curClassName=
substitute(yytext,
".",
"::");
725 DBG_CTX((stderr,
"found package: %s\n",
qPrint(yyextra->curClassName)));
733<ClassVar>("extends"|"implements") {
737 yyextra->curClassBases.clear();
740<ClassVar>("sealed"|"abstract")/{BN}*(":"|"{") {
741 DBG_CTX((stderr,
"***** C++/CLI modifier %s on yyextra->curClassName=%s\n",yytext,
qPrint(yyextra->curClassName)));
745 BEGIN( CppCliTypeModifierFollowup );
748 yyextra->type = yyextra->curClassName;
749 yyextra->name = yytext;
750 if (yyextra->insideBody)
752 addVariable(yyscanner,yyextra->type,yyextra->name);
756<ClassName,ClassVar,CppCliTypeModifierFollowup>{B}*":"{B}* {
758 yyextra->curClassBases.clear();
761<PackageName>[ \t]*";" |
762<Bases>^{Bopt}/"@"{ID} |
763<Bases,ClassName,ClassVar,CppCliTypeModifierFollowup>{B}*"{"{B}* {
764 yyextra->theVarContext.pushScope();
765 if (!yyextra->skipCodify) yyextra->code->codify(yytext);
766 yyextra->skipCodify =
false;
767 if (YY_START==ClassVar && yyextra->curClassName.empty())
769 yyextra->curClassName = yyextra->name;
771 if (yyextra->searchingForBody)
773 yyextra->searchingForBody=
false;
774 yyextra->insideBody=
true;
776 if (yyextra->insideBody) yyextra->bodyCurlyCount++;
777 if (!yyextra->curClassName.empty())
779 DBG_CTX((stderr,
"** scope stack push CLASSBLOCK\n"));
781 pushScope(yyscanner,yyextra->curClassName);
782 DBG_CTX((stderr,
"***** yyextra->curClassName=%s\n",
qPrint(yyextra->curClassName)));
783 if (yyextra->symbolResolver.resolveClass(yyextra->currentDefinition,yyextra->curClassName,
true)==
nullptr)
785 DBG_CTX((stderr,
"Adding new class %s\n",
qPrint(yyextra->curClassName)));
788 for (
const auto &s : yyextra->curClassBases)
791 auto it = yyextra->codeClassMap.find(s);
792 if (it!=yyextra->codeClassMap.end())
796 if (bcd==
nullptr) bcd=yyextra->symbolResolver.resolveClass(yyextra->currentDefinition,s,
true);
797 if (bcd && bcd->
name()!=yyextra->curClassName)
799 var.localDef()->insertBaseClass(bcd->
name());
802 yyextra->codeClassMap.emplace(yyextra->curClassName.str(),std::move(var));
808 DBG_CTX((stderr,
"** scope stack push INNERBLOCK\n"));
811 yyextra->curClassName.clear();
812 yyextra->curClassBases.clear();
ClassDef * toClassDef(Definition *d)
815<Bases>"virtual"|"public"|"protected"|"private"|"@public"|"@private"|"@protected" {
817 yyextra->code->codify(yytext);
820<Bases>{SEP}?({ID}{SEP})*{ID} {
821 DBG_CTX((stderr,
"%s:addBase(%s)\n",
qPrint(yyextra->curClassName),yytext));
822 yyextra->curClassBases.emplace_back(yytext);
826 yyextra->code->codify(yytext);
827 if (!yyextra->insideObjC)
829 yyextra->sharpCount=1;
834 yyextra->insideProtocolList=
true;
838 yyextra->code->codify(yytext);
839 yyextra->insideProtocolList=
false;
842 yyextra->code->codify(yytext);
843 ++yyextra->sharpCount;
846 yyextra->code->codify(yytext);
847 if (--yyextra->sharpCount<=0)
851 yyextra->code->codify(yytext);
852 yyextra->lastStringContext=YY_START;
856 yyextra->code->codify(yytext);
857 yyextra->lastStringContext=YY_START;
861 yyextra->code->codify(yytext);
862 yyextra->sharpCount=1;
866 yyextra->code->codify(yytext);
867 ++yyextra->sharpCount;
870 yyextra->code->codify(yytext);
871 if (--yyextra->sharpCount<=0)
877 yyextra->code->codify(yytext);
881<Body>{SCOPEPREFIX}?"operator"{B}*"()"{Bopt}/"(" {
884 yyextra->bracketCount=0;
885 yyextra->args.clear();
886 yyextra->name+=yytext;
889<Body>{SCOPEPREFIX}?"operator"/"(" {
892 yyextra->bracketCount=0;
893 yyextra->args.clear();
894 yyextra->name+=yytext;
897<Body>{SCOPEPREFIX}?"operator"[^a-z_A-Z0-9\(\n]+/"(" {
900 yyextra->bracketCount=0;
901 yyextra->args.clear();
902 yyextra->name+=yytext;
905<Body,TemplDecl>("template"|"generic")/([^a-zA-Z0-9]) {
909 yyextra->insideTemplate=
true;
910 yyextra->sharpCount=0;
912<Body>"concept"{BN}+ {
918<Body>"using"{BN}+"namespace"{BN}+ {
930<Body>"module"/{B}*[:;]? {
931 if (yyextra->lang!=SrcLangExt::Cpp) REJECT;
932 if (!yyextra->type.empty() || !yyextra->name.empty()) REJECT;
938<Body>"import"/{B}*[<":]? {
939 if (yyextra->lang!=SrcLangExt::Cpp) REJECT;
945<ConceptName>{ID}("::"{ID})* {
948<ConceptName>"=" {
codifyLines(yyscanner,yytext); BEGIN(Body); }
949<UsingName>{ID}(("::"|"."){ID})* {
954<UsingName>\n {
codifyLines(yyscanner,yytext); BEGIN(Body); }
955<UsingName>. {
codifyLines(yyscanner,yytext); BEGIN(Body); }
956<Body,FuncCall>"$"?"this"("->"|".") { yyextra->code->codify(yytext);
957 yyextra->isPrefixedWithThis =
true;
959<Body>{KEYWORD}/([^a-z_A-Z0-9]) {
960 if (yyextra->lang==SrcLangExt::Java &&
dstrcmp(
"internal",yytext) ==0) REJECT;
968 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)
972<Body>{KEYWORD}/{B}* {
978<Body>{KEYWORD}/{BN}*"(" {
983 yyextra->name.clear();yyextra->type.clear();
985<FuncCall>"in"/{BN}* {
986 if (!yyextra->inForEachExpression) REJECT;
991 yyextra->theVarContext.popScope();
992 addVariable(yyscanner,yyextra->parmType,yyextra->parmName);
993 yyextra->theVarContext.pushScope();
994 yyextra->name.clear();yyextra->type.clear();
996<Body>{FLOWKW}/{BN}*"(" {
1000 yyextra->name.clear();yyextra->type.clear();
1001 yyextra->inForEachExpression = (
dstrcmp(yytext,
"for each")==0 ||
dstrcmp(yytext,
"foreach")==0);
1004<Body>{FLOWCONDITION}/{BN}*"(" {
1009 yyextra->name.clear();yyextra->type.clear();
1010 yyextra->inForEachExpression = (strcmp(yytext,
"for each")==0 || strcmp(yytext,
"foreach")==0);
1013<Body>{FLOWKW}/([^a-z_A-Z0-9]) {
1017 if (yyextra->inFunctionTryBlock && (
dstrcmp(yytext,
"catch")==0 ||
dstrcmp(yytext,
"finally")==0))
1019 yyextra->inFunctionTryBlock=
false;
1022<Body>{FLOWCONDITION}/([^a-z_A-Z0-9]) {
1027 if (yyextra->inFunctionTryBlock && (strcmp(yytext,
"catch")==0 || strcmp(yytext,
"finally")==0))
1029 yyextra->inFunctionTryBlock=
false;
1032<Body>{FLOWKW}/{B}* {
1037<Body>{FLOWCONDITION}/{B}* {
1044 yyextra->code->codify(yytext);
1045 yyextra->theCallContext.popScope(yyextra->name, yyextra->type, yyextra->bracketCount);
1046 yyextra->bracketCount--;
1047 yyextra->parmType = yyextra->name;
1050<Body>"\\)"|"\\(" {
1051 yyextra->code->codify(yytext);
1053<Body>[\\|\)\+\-\/\%\~\!] {
1054 yyextra->code->codify(yytext);
1055 yyextra->name.clear();yyextra->type.clear();
1058 yyextra->theCallContext.popScope(yyextra->name, yyextra->type, yyextra->bracketCount);
1059 yyextra->bracketCount--;
1060 if (yyextra->bracketCount<=0)
1066<Body,TemplDecl,ObjCMethod>{TYPEKW}/{B}* {
1068 yyextra->code->codify(yytext);
1071 yyextra->name+=yytext;
1073<Body,TemplDecl,ObjCMethod>{TYPEKWSL}/{B}* {
1074 if (yyextra->lang!=SrcLangExt::Slice)
1081 yyextra->code->codify(yytext);
1084 yyextra->name+=yytext;
1087<Body>"generic"/{B}*"<"[^\n\/\-\.\{\">]*">"{B}* {
1089 yyextra->code->codify(yytext);
1091 yyextra->sharpCount=0;
1094<Body>"template"/{B}*"<"[^\n\/\-\.\{\">]*">"{B}* {
1096 yyextra->code->codify(yytext);
1098 yyextra->sharpCount=0;
1101<TemplDecl>"class"|"typename" {
1107 yyextra->code->codify(yytext);
1108 yyextra->sharpCount++;
1111 yyextra->code->codify(yytext);
1112 yyextra->sharpCount--;
1113 if (yyextra->sharpCount<=0)
1122 BEGIN( yyextra->lastTemplCastContext );
1124<TemplCast>{ID}("::"{ID})* {
1127<TemplCast>("const"|"volatile"){B}* {
1135<Body,MemberCall2,FuncCall>{CASTKW}{B}*"<" {
1139 yyextra->lastTemplCastContext = YY_START;
1142<Body>"$this->"{SCOPENAME}/{BN}*[;,)\]] {
1145 yyextra->name+=yytext+7;
1147<Body,TemplCast>{SCOPENAME}{B}*"<"[^\n\/\-\.\{\">\(']*">"{ENDIDopt}/{B}* {
1154 yyextra->name+=yytext;
1156<ModuleName,ModuleImport>{MODULE_ID}({BN}*":"{BN}*{MODULE_ID})? {
1158 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
1175<ModuleName>":"{BN}+"private" {
1177 size_t i=text.
find(
'p');
1183<ModuleName>";" { yyextra->code->codify(yytext); BEGIN(Body); }
1184<ModuleName>. { yyextra->code->codify(yytext); }
1186<ModuleImport>["<] { yyextra->code->codify(yytext); BEGIN(ReadInclude); }
1187<ModuleImport>";" { yyextra->code->codify(yytext); BEGIN(Body); }
1188<ModuleImport>. { yyextra->code->codify(yytext); }
1189<ModuleImport>\n {
codifyLines(yyscanner,yytext); }
1191<Body>{SCOPENAME}/{BN}*[:;,)\]] {
1198 yyextra->name+=yytext;
1200<Body>{ID}("."{ID})+/{BN}+ {
1201 if (yyextra->lang==SrcLangExt::CSharp || yyextra->lang==SrcLangExt::Java)
1205 yyextra->name+=yytext;
1212<Body>"export"/{B}* {
1213 if (yyextra->lang!=SrcLangExt::Cpp) REJECT;
1218<Body>{SCOPENAME}/{B}* {
1225 yyextra->name+=yytext;
1227<Body>"("{B}*("*"{B}*)+{SCOPENAME}+{B}*")"/{B}* {
1228 yyextra->code->codify(yytext);
1229 uint32_t s=0;
while (s<(uint32_t)yyleng && !
isId(yytext[s])) s++;
1230 uint32_t e=(uint32_t)yyleng-1;
while (e>1 && !
isId(yytext[e])) e--;
1233 yyextra->name=std::move(varname);
bool isId(int c)
Returns true if c is a valid character for an identifier.
1235<Body>{SCOPETNAME}{B}*"<"[^\n\/\-\.\{\">]*">"/{BN}*"(" |
1236<Body>{SCOPETNAME}/{BN}*"(" {
1243 yyextra->bracketCount=0;
1244 yyextra->args.clear();
1245 yyextra->name+=yytext;
1248<FuncCall,Body,MemberCall,MemberCall2,SkipInits,InlineInit>{RAWBEGIN} {
1250 size_t i=text.
find(
'R');
1251 yyextra->code->codify(text.
left(i+1));
1253 yyextra->code->codify(yytext+i+1);
1254 yyextra->lastStringContext=YY_START;
1255 yyextra->inForEachExpression =
false;
DString extractBeginRawStringDelimiter(const char *rawStart)
1259<FuncCall,Body,MemberCall,MemberCall2,SkipInits,InlineInit,ClassVar,OldStyleArgs>\" {
1261 yyextra->code->codify(yytext);
1262 yyextra->lastStringContext=YY_START;
1263 yyextra->inForEachExpression =
false;
1264 BEGIN( SkipString );
1266<FuncCall,Body,MemberCall,MemberCall2,SkipInits,InlineInit>{NUMBER} {
1267 if (yyextra->lang!=SrcLangExt::Cpp) REJECT;
1268 yyextra->code->codify(yytext);
1270<FuncCall,Body,MemberCall,MemberCall2,SkipInits,InlineInit>\' {
1272 yyextra->code->codify(yytext);
1273 yyextra->lastStringContext=YY_START;
1274 yyextra->inForEachExpression =
false;
1275 BEGIN( SkipStringS );
1277<SkipString>[^\"\\\r\n]{1,100} {
1278 yyextra->code->codify(yytext);
1280<SkipStringS>[^\'\\\r\n]{1,100} {
1281 yyextra->code->codify(yytext);
1283<SkipString,SkipStringS>{CPPC}|{CCS} {
1284 yyextra->code->codify(yytext);
1287 yyextra->code->codify(yytext);
1288 if (yyextra->lastStringContext!=SkipCPP)
1292 BEGIN( yyextra->lastStringContext );
1295 yyextra->code->codify(yytext);
1297 BEGIN( yyextra->lastStringContext );
1299<SkipString,SkipStringS>\\. {
1300 yyextra->code->codify(yytext);
1302<RawString>{RAWEND} {
1303 yyextra->code->codify(yytext);
1306 BEGIN( yyextra->lastStringContext );
DString extractEndRawStringDelimiter(const char *rawEnd)
1309<RawString>[^)\n]+ { yyextra->code->codify(yytext); }
1310<RawString>. { yyextra->code->codify(yytext); }
1312<SkipVerbString>[^"\n]+ {
1313 yyextra->code->codify(yytext);
1315<SkipVerbString>\"\" {
1316 yyextra->code->codify(yytext);
1319 yyextra->code->codify(yytext);
1321 BEGIN( yyextra->lastVerbStringContext );
1324 yyextra->code->codify(yytext);
1330 yyextra->code->codify(yytext);
1331 yyextra->name.clear();yyextra->type.clear();
1334 if (yyextra->insideTemplate)
1336 yyextra->sharpCount++;
1338 yyextra->code->codify(yytext);
1341 if (yyextra->insideTemplate)
1343 if (--yyextra->sharpCount<=0)
1345 yyextra->insideTemplate=
false;
1348 yyextra->code->codify(yytext);
1350<Body,MemberCall,MemberCall2,FuncCall,OldStyleArgs>"'"((\\0[Xx0-9]+)|(\\.)|(.))"'" {
1352 yyextra->code->codify(yytext);
1360 yyextra->code->codify(yytext);
1361 yyextra->memCallContext = YY_START;
1362 BEGIN( MemberCall );
1364<MemberCall>{SCOPETNAME}/{BN}*"(" {
1366 if (yyextra->theCallContext.getScope().globalDef())
1373 yyextra->name.clear();
1379 yyextra->name.clear();
1381 yyextra->type.clear();
1382 if (yyextra->memCallContext==Body)
1388 BEGIN(yyextra->memCallContext);
1391<MemberCall>{SCOPENAME}/{B}* {
1392 if (yyextra->theCallContext.getScope().globalDef())
1394 DBG_CTX((stderr,
"yyextra->theCallContext.getClass()=%p\n",(
void*)yyextra->theCallContext.getScope().globalDef()));
1400 yyextra->name.clear();
1404 DBG_CTX((stderr,
"no class context!\n"));
1407 yyextra->name.clear();
1409 yyextra->type.clear();
1410 BEGIN(yyextra->memCallContext);
1413 if (yyextra->insideObjC && *yytext==
'[')
1415 DBG_CTX((stderr,
"Found start of ObjC call!\n"));
1417 yyextra->contextMap.clear();
1418 yyextra->nameMap.clear();
1419 yyextra->objectMap.clear();
1420 yyextra->wordMap.clear();
1421 yyextra->commentMap.clear();
1422 yyextra->currentCtxId = 0;
1423 yyextra->currentNameId = 0;
1424 yyextra->currentObjId = 0;
1425 yyextra->currentCtx =
nullptr;
1426 yyextra->braceCount = 0;
1432 if (*yytext!=
'{') yyextra->code->codify(yytext);
1433 yyextra->saveName = yyextra->name;
1434 yyextra->saveType = yyextra->type;
1435 if (*yytext!=
'[' && !yyextra->type.empty())
1442 addVariable(yyscanner,yyextra->type,yyextra->name);
1444 yyextra->name.clear();
1446 if (*yytext==
';' || *yytext==
'=' || *yytext==
'{')
1448 yyextra->type.clear();
1449 yyextra->name.clear();
1451 else if (*yytext==
'[')
1453 yyextra->theCallContext.pushScope(yyextra->name, yyextra->type, yyextra->bracketCount);
1455 yyextra->args.clear();
1456 yyextra->parmType.clear();
1457 yyextra->parmName.clear();
1465<Body,FuncCall,BodyVar>"{" {
1466 yyextra->theVarContext.pushScope();
1467 yyextra->theCallContext.pushScope(yyextra->name, yyextra->type, yyextra->bracketCount);
1468 yyextra->bracketCount = 0;
1473 DBG_CTX((stderr,
"** scope stack push SCOPEBLOCK\n"));
1479 DBG_CTX((stderr,
"** scope stack push INNERBLOCK\n"));
1483 if (yyextra->searchingForBody)
1485 yyextra->searchingForBody=
false;
1486 yyextra->insideBody=
true;
1488 yyextra->code->codify(yytext);
1489 if (yyextra->insideBody)
1491 yyextra->bodyCurlyCount++;
1493 yyextra->type.clear();
1494 yyextra->name.clear();
1497<ObjCCall,ObjCMName>"["|"{" {
1499 yyextra->currentCtx->format+=*yytext;
1503<ObjCCall,ObjCMName>"]"|"}" {
1504 yyextra->currentCtx->format+=*yytext;
1507 if (yyextra->currentCtx==
nullptr)
1511 auto it = yyextra->contextMap.find(0);
1512 if (it!=yyextra->contextMap.end())
1514 ctx = it->second.get();
1521<ObjCCall,ObjCMName>{CPPC}.* {
1522 yyextra->currentCtx->format+=
escapeComment(yyscanner,yytext);
1524<ObjCCall,ObjCMName>{CCS} {
1525 yyextra->lastObjCCallContext = YY_START;
1526 yyextra->currentCtx->comment.str(yytext);
1527 BEGIN(ObjCCallComment);
1529<ObjCCallComment>{CCE} {
1530 yyextra->currentCtx->comment << yytext;
1531 yyextra->currentCtx->format+=
escapeComment(yyscanner,yyextra->currentCtx->comment.str());
1532 BEGIN(yyextra->lastObjCCallContext);
1534<ObjCCallComment>[^*\n]+ { yyextra->currentCtx->comment << yytext; }
1535<ObjCCallComment>{CPPC}|{CCS} { yyextra->currentCtx->comment << yytext; }
1536<ObjCCallComment>\n { yyextra->currentCtx->comment << *yytext; }
1537<ObjCCallComment>. { yyextra->currentCtx->comment << *yytext; }
1538<ObjCCall>{ID}({B}*"."{B}*{ID})* {
1539 yyextra->currentCtx->format+=
escapeObject(yyscanner,yytext);
1540 if (yyextra->braceCount==0)
1542 yyextra->currentCtx->objectTypeOrName=yytext;
1543 DBG_CTX((stderr,
"new type=%s\n",
qPrint(yyextra->currentCtx->objectTypeOrName)));
1547<ObjCMName>{ID}/{BN}*"]" {
1548 if (yyextra->braceCount==0 &&
1549 yyextra->currentCtx->methodName.empty())
1551 yyextra->currentCtx->methodName=yytext;
1552 yyextra->currentCtx->format+=
escapeName(yyscanner,yytext);
1556 yyextra->currentCtx->format+=
escapeWord(yyscanner,yytext);
1559<ObjCMName>{ID}/{BN}*":" {
1560 if (yyextra->braceCount==0)
1562 yyextra->currentCtx->methodName+=yytext;
1563 yyextra->currentCtx->methodName+=
":";
1565 yyextra->currentCtx->format+=
escapeName(yyscanner,yytext);
1567<ObjCSkipStr>[^\n\"$\\]* { yyextra->currentCtx->format+=yytext; }
1568<ObjCSkipStr>\\. { yyextra->currentCtx->format+=yytext; }
1569<ObjCSkipStr>"\"" { yyextra->currentCtx->format+=yytext;
1570 BEGIN(yyextra->lastStringContext);
1572<ObjCCall,ObjCMName>{CHARLIT} { yyextra->currentCtx->format+=yytext; }
1573<ObjCCall,ObjCMName>"@"?"\"" { yyextra->currentCtx->format+=yytext;
1574 yyextra->lastStringContext=YY_START;
1577<ObjCCall,ObjCMName,ObjCSkipStr>"$" { yyextra->currentCtx->format+=
"$$"; }
1578<ObjCCall,ObjCMName>"(" { yyextra->currentCtx->format+=*yytext; yyextra->braceCount++; }
1579<ObjCCall,ObjCMName>")" { yyextra->currentCtx->format+=*yytext; yyextra->braceCount--; }
1580<ObjCSkipStr>"@"/"\"" {
1581 yyextra->currentCtx->format+=yytext;
1583<ObjCCall,ObjCMName,ObjCSkipStr>{ID} { yyextra->currentCtx->format+=
escapeWord(yyscanner,yytext); }
1584<ObjCCall,ObjCMName,ObjCSkipStr>. { yyextra->currentCtx->format+=*yytext; }
1585<ObjCCall,ObjCMName,ObjCSkipStr>\n { yyextra->currentCtx->format+=*yytext; }
1588 yyextra->theCallContext.popScope(yyextra->name, yyextra->type, yyextra->bracketCount);
1589 yyextra->code->codify(yytext);
1591 yyextra->name = yyextra->saveName;
1592 yyextra->type = yyextra->saveType;
1595 yyextra->code->codify(yytext);
1597<Body>[0-9]+[xX][0-9A-Fa-f]+ {
1598 yyextra->code->codify(yytext);
1600<MemberCall2,FuncCall>{KEYWORD}/([^a-z_A-Z0-9]) {
1605 yyextra->code->codify(yytext);
1608<MemberCall2,FuncCall,OldStyleArgs,TemplCast>{TYPEKW}/([^a-z_A-Z0-9]) {
1610 yyextra->parmName=yytext;
1612 yyextra->code->codify(yytext);
1615<MemberCall2,FuncCall,OldStyleArgs,TemplCast>{TYPEKWSL}/([^a-z_A-Z0-9]) {
1616 if (yyextra->lang!=SrcLangExt::Slice)
1623 yyextra->parmName=yytext;
1625 yyextra->code->codify(yytext);
1629<MemberCall2,FuncCall>{FLOWKW}/([^a-z_A-Z0-9]) {
1631 yyextra->parmName=yytext;
1633 yyextra->code->codify(yytext);
1636<MemberCall2,FuncCall>{FLOWCONDITION}/([^a-z_A-Z0-9]) {
1639 yyextra->parmName=yytext;
1641 yyextra->code->codify(yytext);
1644<MemberCall2,FuncCall>("::")?{ID}(({B}*"<"[^\n\[\](){}<>']*">")?({B}*"::"{B}*{ID})?)* {
1650 yyextra->parmName=yytext;
1654 yyextra->code->codify(yytext);
1655 yyextra->inForEachExpression =
false;
1658<MemberCall2,FuncCall>, {
1659 yyextra->code->codify(yytext);
1660 addVariable(yyscanner,yyextra->parmType,yyextra->parmName);
1661 yyextra->parmType.clear();yyextra->parmName.clear();
1663<MemberCall2,FuncCall>"{" {
1664 if (yyextra->bracketCount>0)
1666 yyextra->code->codify(yytext);
1667 yyextra->skipInlineInitContext=YY_START;
1668 yyextra->curlyCount=0;
1676<InlineInit>"{" { yyextra->curlyCount++;
1677 yyextra->code->codify(yytext);
1680 yyextra->code->codify(yytext);
1681 if (--yyextra->curlyCount<=0)
1683 BEGIN(yyextra->skipInlineInitContext);
1690 yyextra->code->codify(yytext);
1692<MemberCall2,FuncCall>"(" {
1693 yyextra->parmType.clear();yyextra->parmName.clear();
1694 yyextra->code->codify(yytext);
1695 yyextra->bracketCount++;
1696 yyextra->theCallContext.pushScope(yyextra->name, yyextra->type, yyextra->bracketCount);
1697 if (YY_START==FuncCall && !yyextra->insideBody)
1699 yyextra->theVarContext.pushScope();
1702<MemberCall2,FuncCall>{OPERATOR} {
1709 yyextra->parmType.clear();yyextra->parmName.clear();
1711 yyextra->code->codify(yytext);
1713<MemberCall,MemberCall2,FuncCall>("*"{B}*)?")" {
1716 DBG_CTX((stderr,
"addVariable(%s,%s)\n",
qPrint(yyextra->parmType),
qPrint(yyextra->parmName)));
1717 if (yyextra->parmType.empty())
1719 yyextra->parmType=yyextra->parmName;
1720 yyextra->parmName.clear();
1722 addVariable(yyscanner,yyextra->parmType,yyextra->parmName);
1726 yyextra->parmType = yyextra->parmName;
1727 yyextra->parmName.clear();
1728 addVariable(yyscanner,yyextra->parmType,yyextra->parmName);
1730 yyextra->theCallContext.popScope(yyextra->name, yyextra->type, yyextra->bracketCount);
1731 yyextra->inForEachExpression =
false;
1733 yyextra->code->codify(yytext);
1734 if (--yyextra->bracketCount<=0)
1736 if (yyextra->name.empty())
1746<MemberCall,MemberCall2,FuncCall>[;:] {
1748 if (yyextra->bracketCount<=0)
1755 yyextra->code->codify(yytext);
1758<CallEnd>[ \t\n]* {
codifyLines(yyscanner,yytext); }
1761 yyextra->bracketCount=0;
1762 if (*yytext==
';') yyextra->searchingForBody=
false;
1763 if (!yyextra->type.empty())
1765 DBG_CTX((stderr,
"add variable yyextra->type=%s yyextra->name=%s)\n",
qPrint(yyextra->type),
qPrint(yyextra->name)));
1766 addVariable(yyscanner,yyextra->type,yyextra->name);
1768 yyextra->parmType.clear();yyextra->parmName.clear();
1770 if (*yytext==
';' || yyextra->insideBody)
1772 if (!yyextra->insideBody)
1774 yyextra->theVarContext.popScope();
1776 yyextra->name.clear();yyextra->type.clear();
1781 yyextra->bracketCount=0;
1786 if (yyextra->lang!=SrcLangExt::CSharp || yyextra->insideBody)
1792 yyextra->code->codify(
"=>");
1796<CallEnd>{ENDQopt}/{BN}*(";"|"="|"throw"{BN}*"(") {
1801<CallEnd,OldStyleArgs>("const"|"volatile"|"sealed"|"override")*({BN}+("const"|"volatile"|"sealed"|"override"))*{BN}*"{" {
1802 if (yyextra->insideBody)
1804 yyextra->theVarContext.pushScope();
1806 addVariable(yyscanner,yyextra->parmType,yyextra->parmName);
1808 yyextra->parmType.clear();yyextra->parmName.clear();
1809 size_t index = yyextra->name.rfind(
"::");
1810 DBG_CTX((stderr,
"yyextra->name=%s\n",
qPrint(yyextra->name)));
1814 if (!yyextra->scopeName.empty()) scope.
prepend((yyextra->scopeName+
"::"));
1820 DBG_CTX((stderr,
"** scope stack push SCOPEBLOCK\n"));
1826 DBG_CTX((stderr,
"** scope stack push INNERBLOCK\n"));
1831 DBG_CTX((stderr,
"** scope stack push INNERBLOCK\n"));
1834 yytext[yyleng-1]=
'\0';
1836 if (!cv.stripWhiteSpace().empty())
1846 yyextra->code->codify(
"{");
1847 if (yyextra->searchingForBody)
1849 yyextra->searchingForBody=
false;
1850 yyextra->insideBody=
true;
1852 if (yyextra->insideBody) yyextra->bodyCurlyCount++;
1853 yyextra->type.clear(); yyextra->name.clear();
DString & prepend(const char *s)
static NamespaceDefMutable * globalScope
1858 yyextra->code->codify(yytext);
1860 yyextra->inFunctionTryBlock=
true;
1862<CallEnd>"requires" {
1864 yyextra->code->codify(yytext);
1868 if (yyextra->insideBody || !yyextra->parmType.empty())
1874 yyextra->parmName=yytext;
1876 BEGIN(OldStyleArgs);
1880 yyextra->parmName=yytext;
1884 yyextra->code->codify(yytext);
1885 addVariable(yyscanner,yyextra->parmType,yyextra->parmName);
1886 if (*yytext==
';') yyextra->parmType.clear();
1887 yyextra->parmName.clear();
1889<CallEnd,OldStyleArgs>"#" {
1891 yyextra->lastSkipCppContext = Body;
1892 yyextra->code->codify(yytext);
1897 if (!yyextra->insideBody)
1899 yyextra->theVarContext.popScope();
1901 yyextra->name.clear();yyextra->args.clear();
1902 yyextra->parmType.clear();yyextra->parmName.clear();
1906 yyextra->code->codify(yytext);
1907 yyextra->type.clear(); yyextra->name.clear();
1911 yyextra->code->codify(yytext);
1912 if (yyextra->searchingForBody)
1914 yyextra->searchingForBody=
false;
1915 yyextra->insideBody=
true;
1917 if (yyextra->insideBody) yyextra->bodyCurlyCount++;
1920 DBG_CTX((stderr,
"** scope stack push SCOPEBLOCK\n"));
1926 DBG_CTX((stderr,
"** scope stack push INNERBLOCK\n"));
1929 yyextra->type.clear(); yyextra->name.clear();
1932<SkipInits>{ID}{B}*"{" {
1934 size_t bracketPos = text.
find(
'{');
1935 size_t spacePos = text.
find(
' ');
1936 size_t len = spacePos==
DString::npos ? bracketPos : spacePos;
1938 yyextra->code->codify(yytext+len);
1946<FuncCall>{ID}/("."|"->") {
1947 yyextra->name=yytext;
1949 BEGIN( MemberCall2 );
1951<FuncCall,MemberCall2>("("{B}*("*"{B}*)+{ID}+{B}*")"{B}*)/("."|"->") {
1952 yyextra->code->codify(yytext);
1953 uint32_t s=0;
while (!
isId(yytext[s])) s++;
1954 uint32_t e=(uint32_t)yyleng-1;
while (e>1 && !
isId(yytext[e])) e--;
1955 yyextra->name=((
DString)yytext).mid(s,e-s+1);
1956 BEGIN( MemberCall2 );
1958<MemberCall2>{ID}/([ \t\n]*"(") {
1959 if (!yyextra->args.empty())
1963 yyextra->args.clear();
1966<MemberCall2>{ID}/([ \t\n]*("."|"->")) {
1968 yyextra->name=yytext;
1970 BEGIN( MemberCall2 );
1972<MemberCall2>"->"|"." {
1977 yyextra->code->codify(yytext);
1978 yyextra->memCallContext = YY_START;
1979 BEGIN( MemberCall );
1981<SkipComment>{CCS}("!"?){CCE} {
1982 yyextra->code->codify(yytext);
1984 BEGIN( yyextra->lastCContext ) ;
1986<SkipComment>{CPPC}|{CCS} {
1987 yyextra->code->codify(yytext);
1989<SkipComment>[^*\/\n]+ {
1990 yyextra->code->codify(yytext);
1992<SkipComment>[ \t]*{CCE} {
1993 yyextra->code->codify(yytext);
1995 if (yyextra->lastCContext==SkipCPP)
1999 BEGIN( yyextra->lastCContext ) ;
2001<SkipCxxComment>[^\r\n]*"\\"[\r]?\n {
2004<SkipCxxComment>[^\r\n]+ {
2005 yyextra->code->codify(yytext);
2011 BEGIN( yyextra->lastCContext ) ;
2014 yyextra->code->codify(yytext);
2016<MemberCall>[^a-z_A-Z0-9(\n] {
2017 yyextra->code->codify(yytext);
2018 yyextra->type.clear();
2019 yyextra->name.clear();
2020 BEGIN(yyextra->memCallContext);
2022<*>\n({B}*{CPPC}[!/][^\n]*\n)+ {
2023 if (YY_START==SkipCPP) REJECT;
2028 if (YY_START==SkipCxxComment)
2030 BEGIN( yyextra->lastCContext ) ;
2035 BEGIN( yyextra->lastSkipCppContext ) ;
2038<*>\n{B}*{CPPC}"@"[{}].*\n {
2043 if (YY_START==SkipCxxComment)
2045 BEGIN( yyextra->lastCContext ) ;
2048<*>\n{B}*{CCS}"@"[{}] {
2050 if (YY_START != SkipComment && YY_START != SkipCxxComment)
2052 yyextra->lastCContext = YY_START ;
2058<*>^{B}*{CPPC}"@"[{}].*\n {
2064<*>^{B}*{CCS}"@"[{}] {
2066 if (YY_START != SkipComment && YY_START != SkipCxxComment)
2068 yyextra->lastCContext = YY_START ;
2071 yyextra->code->codify(yytext);
2074<*>^{B}*{CPPC}[!/][^\n]* {
2079<*>{CPPC}[!/][^\n]* {
2080 if (YY_START==SkipComment || YY_START==SkipString) REJECT;
2085<*>\n{B}*{CCS}[!*]/{NCOMM} {
2087 if (YY_START != SkipComment && YY_START != SkipCxxComment)
2089 yyextra->lastCContext = YY_START ;
2095<*>^{B}*{CCS}"*"[*]+/[^/] {
2097 if (YY_START != SkipComment && YY_START != SkipCxxComment)
2099 yyextra->lastCContext = YY_START ;
2103 yyextra->code->codify(yytext);
#define Config_getBool(name)
2106<*>^{B}*{CCS}[!*]/{NCOMM} {
2108 if (YY_START != SkipComment && YY_START != SkipCxxComment)
2110 yyextra->lastCContext = YY_START ;
2113 yyextra->code->codify(yytext);
2116<*>{CCS}[!*]/{NCOMM} {
2117 if (YY_START==SkipString) REJECT;
2119 if (YY_START != SkipComment && YY_START != SkipCxxComment)
2121 yyextra->lastCContext = YY_START ;
2124 yyextra->code->codify(yytext);
2127<*>{CCS}("!"?){CCE} {
2128 if (YY_START==SkipString) REJECT;
2131 yyextra->code->codify(yytext);
2134<SkipComment>[^\*\n]+ {
2135 yyextra->code->codify(yytext);
2139 yyextra->code->codify(yytext);
2141 if (YY_START != SkipComment && YY_START != SkipCxxComment)
2143 yyextra->lastCContext = YY_START ;
2145 BEGIN( SkipComment ) ;
2149 yyextra->code->codify(yytext);
2150 yyextra->lastVerbStringContext=YY_START;
2151 BEGIN(SkipVerbString);
2155 yyextra->code->codify(yytext);
2156 yyextra->lastCContext = YY_START ;
2157 BEGIN( SkipCxxComment ) ;
2160 if (yytext[0]==
'(') yyextra->bracketCount++;
2161 yyextra->code->codify(yytext);
2162 yyextra->theCallContext.pushScope(yyextra->name, yyextra->type, yyextra->bracketCount);
2165 if (yytext[0]==
')') yyextra->bracketCount--;
2166 yyextra->code->codify(yytext);
2167 yyextra->theCallContext.popScope(yyextra->name, yyextra->type, yyextra->bracketCount);
2173 yyextra->code->codify(yytext);
2176 yyextra->code->codify(yytext);
2193 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
2201 DBG_CTX((stderr,
"** addVariable trying: type='%s' name='%s' currentDefinition=%s\n",
2202 qPrint(ltype),
qPrint(lname),yyextra->currentDefinition?
qPrint(yyextra->currentDefinition->name()):
"<none>"));
2203 auto it = yyextra->codeClassMap.find(ltype.
str());
2204 if (it!=yyextra->codeClassMap.end())
2207 yyextra->theVarContext.addVariable(lname,std::move(it->second));
2211 auto findVariableType = [&yyscanner,&yyg,<ype,&lname,&name](
const Definition *d) ->
const ClassDef *
2213 const ClassDef *varDef = yyextra->symbolResolver.resolveClass(d,ltype,
true);
2226 const ClassDef *varDef = findVariableType(yyextra->currentDefinition);
2227 if (varDef==
nullptr)
2229 for (
const auto &[usingName,namespaceDef] : yyextra->theUsingContext)
2231 varDef = findVariableType(namespaceDef);
2235 if (varDef==
nullptr)
2237 if (!yyextra->theVarContext.atGlobalScope())
2241 DBG_CTX((stderr,
"** addVariable: dummy context for '%s'\n",
qPrint(lname)));
2246 DBG_CTX((stderr,
"** addVariable: not adding variable!\n"));
2257 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
2258 yyextra->scopeNameLengthStack.push_back(
int(yyextra->scopeName.length()));
2259 if (yyextra->scopeName.empty() ||
leftScopeMatch(s,yyextra->scopeName))
2261 yyextra->scopeName = s;
2265 yyextra->scopeName +=
"::";
2266 yyextra->scopeName += s;
2275 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
2276 if (!yyextra->scopeNameLengthStack.empty())
2278 int length = yyextra->scopeNameLengthStack.back();
2279 yyextra->scopeNameLengthStack.pop_back();
2280 yyextra->scopeName.resize(length);
2286 DBG_CTX((stderr,
"popScope() result: '%s'\n",
qPrint(yyextra->scopeName)));
2291 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
2294 if (yyextra->searchCtx)
2315 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
2319 size_t ts=n.
find(
'<');
2320 size_t te=n.
rfind(
'>');
2321 DBG_CTX((stderr,
"ts=%zu te=%zu\n",ts,te));
2327 while (!yyextra->scopeNameLengthStack.empty())
2331 yyextra->scopeName.clear();
2339 DBG_CTX((stderr,
"--->New class scope '%s'\n",
qPrint(yyextra->scopeName)));
2344 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
2345 while (!yyextra->foldStack.empty())
2347 const Definition *dd = yyextra->foldStack.back();
2350 yyextra->code->endFold();
2352 yyextra->foldStack.pop_back();
2367 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
2376 if (endLine!=-1 && startLine!=endLine &&
2384 (yyextra->foldStack.empty() || yyextra->foldStack.back()->getEndBodyLine()!=startLine))
2392 yyextra->code->startFold(yyextra->yyLineNr,
"",
"");
2396 yyextra->code->startFold(yyextra->yyLineNr,
"{",
"}");
2400 yyextra->code->startFold(yyextra->yyLineNr,
"{",
"};");
2405 yyextra->code->startFold(yyextra->yyLineNr,
"{",
"};");
2409 yyextra->code->startFold(yyextra->yyLineNr,
"{",
"}");
2411 yyextra->foldStack.push_back(d);
2423 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
2425 if (yyextra->sourceFileDef && yyextra->lineNumbers)
2431 const Definition *d = yyextra->sourceFileDef->getSourceDefinition(yyextra->yyLineNr);
2433 DBG_CTX((stderr,
"%s:startCodeLine(%d)=%p\n",
qPrint(yyextra->sourceFileDef->name()),yyextra->yyLineNr,(
void*)d));
2434 if (!yyextra->includeCodeFragment && d)
2436 yyextra->currentDefinition = d;
2437 yyextra->currentMemberDef = yyextra->sourceFileDef->getSourceMember(yyextra->yyLineNr);
2438 yyextra->insideBody =
false;
2439 yyextra->searchingForBody =
true;
2441 yyextra->type.
clear();
2442 yyextra->name.clear();
2443 yyextra->args.clear();
2444 yyextra->parmType.clear();
2445 yyextra->parmName.clear();
2446 DBG_CTX((stderr,
"Real scope: '%s'\n",
qPrint(yyextra->realScope)));
2447 yyextra->bodyCurlyCount = 0;
2449 lineAnchor.
sprintf(
"l%05d",yyextra->yyLineNr);
2450 if (yyextra->currentMemberDef)
2453 yyextra->code->writeLineNumber(yyextra->currentMemberDef->getReference(),
2454 yyextra->currentMemberDef->getOutputFileBase(),
2455 yyextra->currentMemberDef->anchor(),
2456 yyextra->yyLineNr,!yyextra->includeCodeFragment);
2464 DString(),yyextra->yyLineNr,!yyextra->includeCodeFragment);
2476 !yyextra->includeCodeFragment);
2479 DBG_CTX((stderr,
"startCodeLine(%d)\n",yyextra->yyLineNr));
2480 yyextra->code->startCodeLine(yyextra->yyLineNr);
2481 yyextra->insideCodeLine =
true;
2482 if (yyextra->currentFontClass)
2484 yyextra->code->startFontClass(yyextra->currentFontClass);
2492 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
2493 DBG_CTX((stderr,
"endCodeLine(%d)\n",yyextra->yyLineNr));
2495 yyextra->code->endCodeLine();
2496 yyextra->insideCodeLine =
false;
2501 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
2502 const char * fc = yyextra->currentFontClass;
2503 if (yyextra->insideCodeLine)
2507 if (yyextra->yyLineNr<yyextra->inputLines)
2509 yyextra->currentFontClass = fc;
2519 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
2520 DBG_CTX((stderr,
"codifyLines(%d,\"%s\")\n",yyextra->yyLineNr,
qPrint(text)));
2521 if (text.
empty())
return;
2522 const char *p=text.
data(),*sp=p;
2528 while ((c=*p++) && c!=
'\n');
2531 yyextra->yyLineNr++;
2532 size_t l =
static_cast<size_t>(p-sp-1);
2533 yyextra->code->codify(
DString(sp,l));
2538 yyextra->code->codify(sp);
2547 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
2548 if (yyextra->currentMemberDef && yyextra->currentMemberDef->isFunction())
2566 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
2568 yyextra->tooltipManager.addTooltip(d);
2573 if (!sourceTooltips)
2578 const char *p=text.
data();
2583 while ((c=*p++) && c!=
'\n') { }
2586 yyextra->yyLineNr++;
2602 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
2603 if (yyextra->name==
"const") { yyextra->name.clear();
return; }
2604 if (!yyextra->type.empty()) yyextra->type +=
' ' ;
2605 yyextra->type += yyextra->name ;
2606 yyextra->name.clear() ;
2607 if (!yyextra->type.empty()) yyextra->type +=
' ' ;
2608 yyextra->type += yyextra->args ;
2609 yyextra->args.clear() ;
2614 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
2615 if (yyextra->parmName==
"const") { yyextra->parmName.clear();
return; }
2616 if (!yyextra->parmType.empty()) yyextra->parmType +=
' ' ;
2617 yyextra->parmType += yyextra->parmName ;
2618 yyextra->parmName.clear() ;
2624 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
2625 if (yyextra->sourceFileDef && !name.
empty())
2630 yyextra->theUsingContext.emplace(name.
str(),nd);
2637 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
2640 yyextra->parmName = a.name;
2641 yyextra->parmType = a.type;
2642 size_t i = yyextra->parmType.find(
'*');
2643 if (i!=
DString::npos) yyextra->parmType = yyextra->parmType.left(i);
2644 i = yyextra->parmType.find(
'&');
2645 if (i!=
DString::npos) yyextra->parmType = yyextra->parmType.left(i);
2646 yyextra->parmType.stripPrefix(
"const ");
2647 yyextra->parmType=yyextra->parmType.stripWhiteSpace();
2648 addVariable(yyscanner,yyextra->parmType,yyextra->parmName);
2654 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
2655 DBG_CTX((stderr,
"stripClassName(scope=%s,type=%s) scopeName=%s\n",
2663 DString clName=className+templSpec;
2665 if (!yyextra->scopeName.empty())
2667 cd=yyextra->symbolResolver.resolveClass(d,yyextra->scopeName+
"::"+clName,
true);
2671 cd=yyextra->symbolResolver.resolveClass(d,clName,
true);
2673 DBG_CTX((stderr,
"stripClass trying '%s' = %p\n",
qPrint(clName),(
void*)cd));
2685 if (name.
empty())
return nullptr;
2686 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
2687 DBG_CTX((stderr,
"setCallContextForVar(%s) yyextra->scopeName=%s\n",
qPrint(name),
qPrint(yyextra->scopeName)));
2689 size_t scopeEnd = name.
rfind(
"::");
2696 if (mcd && !locName.
empty())
2709 if (mnd && !locName.
empty())
2725 DBG_CTX((stderr,
"local variable?\n"));
2729 yyextra->theCallContext.setScope(*mcv);
2734 DBG_CTX((stderr,
"class member? scope=%s\n",
qPrint(yyextra->scopeName)));
2744 if (yyextra->scopeStack.empty() || yyextra->scopeStack.top()!=
CLASSBLOCK)
2761 const std::unique_ptr<MemberDef> &md=mn->
front();
2762 if (!md->isStatic() || md->getBodyDef()==yyextra->sourceFileDef)
2769 else if (mn->
size()>1)
2771 for (
const auto &md : *mn)
2780 if (!md->isStatic() || md->getBodyDef()==yyextra->sourceFileDef)
2783 DBG_CTX((stderr,
"returning member %s in source file %s\n",
qPrint(md->name()),
qPrint(yyextra->sourceFileDef->name())));
2795 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
2796 const Definition *d = yyextra->theCallContext.getScope().globalDef();
2819 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
2820 DBG_CTX((stderr,
"getLinkInScope: trying '%s'::'%s' varOnly=%d\n",
qPrint(c),
qPrint(m),varOnly));
2825 DBG_CTX((stderr,
"scopeNameLengthStack.size()=%zu\n",yyextra->scopeNameLengthStack.size()));
2826 if (!result.
found && !yyextra->scopeNameLengthStack.empty() && c==yyextra->scopeName)
2828 DString localName = yyextra->scopeName.
mid(yyextra->scopeNameLengthStack[0]+2);
2829 auto it = yyextra->codeClassMap.
find(localName.
str());
2830 if (it!=yyextra->codeClassMap.end())
2837 DBG_CTX((stderr,
"trying lookup via base class %s\n",
qPrint(bcName)));
2840 if (result.
found)
break;
2850 if (yyextra->exampleBlock)
2854 anchor.
sprintf(
"a%d",yyextra->anchorCount);
2856 qPrint(yyextra->exampleFile)));
2858 if (mdm && mdm->
addExample(anchor,yyextra->exampleName,yyextra->exampleFile))
2861 yyextra->anchorCount++;
2875 DBG_CTX((stderr,
"yyextra->currentDefinition=%p yyextra->currentMemberDef=%p yyextra->insideBody=%d\n",
2876 (
void*)yyextra->currentDefinition,(
void*)yyextra->currentMemberDef,yyextra->insideBody));
2878 if (yyextra->currentDefinition && yyextra->currentMemberDef &&
2879 yyextra->insideBody && yyextra->collectXRefs)
2901 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
2902 DBG_CTX((stderr,
"getLink(%s,%s) yyextra->curClassName=%s\n",
2908 if (!yyextra->curClassName.empty())
2911 c.
prepend(yyextra->curClassName);
2925 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
2927 if (!scopeName.
empty() && scopeName[0]==
'~')
2929 scopeName=scopeName.
mid(1);
2931 if (scopeName.
empty())
2933 yyextra->code->codify(
"~");
2936 if (yyextra->insideProtocolList)
2940 if (yyextra->lang==SrcLangExt::PHP)
2944 else if (yyextra->lang==SrcLangExt::CSharp || yyextra->lang==SrcLangExt::Java)
2948 if (yyextra->currentDefinition==
nullptr && !yyextra->scopeName.empty())
2950 scopeName = yyextra->scopeName+
"::"+scopeName;
2956 DBG_CTX((stderr,
"generateClassOrGlobalLink(name=%s) yyextra->scopeName=%s scopeName=%s\n",
qPrint(scName),
qPrint(yyextra->scopeName),
qPrint(scopeName)));
2957 if (!yyextra->isPrefixedWithThis || (lcd=yyextra->theVarContext.findVariable(scopeName))==
nullptr)
2962 auto checkForSymbol = [&yyg,&bareName,&scopeName](
const Definition *
parent,
2965 sym_ = yyextra->symbolResolver.resolveSymbol(
parent,scopeName,
DString(),
false,
true);
2966 DBG_CTX((stderr,
"non-local variable name=%s sym=%s!\n",
2967 qPrint(scopeName),sym_?
qPrint(sym_->name()):
"<none>"));
2968 if (sym_==
nullptr && !bareName.
empty())
2971 if (bareName!=scopeName)
2973 sym_ = yyextra->symbolResolver.resolveSymbol(
parent,bareName,
DString(),
false,
true);
2977 const Definition *d = yyextra->currentDefinition;
2978 DBG_CTX((stderr,
"d=%s yyextra->sourceFileDef=%s\n",d?
qPrint(d->
name()):
"<none>",yyextra->sourceFileDef?
qPrint(yyextra->sourceFileDef->name()):
"<none>"));
2979 checkForSymbol(d,sym);
2988 checkForSymbol(nd,sym);
2996 for (
const auto &[usingName,namespaceDef] : yyextra->theUsingContext)
2998 checkForSymbol(namespaceDef,sym);
3020 DBG_CTX((stderr,
"is found as a type sym=%s nd=%s\n",
3025 if (
getLink(yyscanner,yyextra->scopeName,scName,ol,scName,varOnly))
3033 DBG_CTX((stderr,
"local variable!\n"));
3037 yyextra->theCallContext.setScope(*lcd);
3048 DBG_CTX((stderr,
"is a local variable sym=%p!\n",(
void*)sym));
3050 yyextra->isPrefixedWithThis =
false;
3055 if (yyextra->exampleBlock)
3059 anchor.
sprintf(
"_a%d",yyextra->anchorCount);
3060 DBG_CTX((stderr,
"addExampleClass(%s,%s,%s)\n",
qPrint(anchor),
qPrint(yyextra->exampleName),
3061 qPrint(yyextra->exampleFile)));
3065 if (cdm && cdm->
addExample(anchor,yyextra->exampleName,yyextra->exampleFile))
3068 yyextra->anchorCount++;
3074 if (mdm && mdm->
addExample(anchor,yyextra->exampleName,yyextra->exampleFile))
3077 yyextra->anchorCount++;
3090 yyextra->currentMemberDef && yyextra->collectXRefs)
3104 DBG_CTX((stderr,
"class %s not linkable! cd=%p typeOnly=%d\n",
qPrint(scName),(
void*)sym,typeOnly));
3105 if (!isLocal && (md || (!sym && !typeOnly)))
3110 DBG_CTX((stderr,
"setCallContextForVar(%s) md=%p yyextra->currentDefinition=%s\n",
qPrint(scName),(
void*)md,yyextra->currentDefinition ?
qPrint(yyextra->currentDefinition->name()) :
"<none>"));
3111 if (md && yyextra->currentDefinition)
3113 DBG_CTX((stderr,
"%s accessible from %s? %d md->getOuterScope=%s\n",
3114 qPrint(md->name()),
qPrint(yyextra->currentDefinition->name()),
3115 yyextra->symbolResolver.isAccessibleFrom(yyextra->currentDefinition,md),
3116 qPrint(md->getOuterScope()->name())));
3119 if (md && yyextra->currentDefinition &&
3120 yyextra->symbolResolver.isAccessibleFrom(yyextra->currentDefinition,md)==-1)
3127 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()));
3128 if (md->isLinkable())
3132 if (yyextra->currentMemberDef && yyextra->collectXRefs)
3142 DBG_CTX((stderr,
"not found!\n"));
3153 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
3157 DBG_CTX((stderr,
"type='%s' args='%s' class=%s\n",
3161 if (yyextra->exampleBlock)
3165 anchor.
sprintf(
"a%d",yyextra->anchorCount);
3167 qPrint(yyextra->exampleFile)));
3169 if (mdm && mdm->
addExample(anchor,yyextra->exampleName,yyextra->exampleFile))
3172 yyextra->anchorCount++;
3186 DBG_CTX((stderr,
"yyextra->currentDefinition=%p yyextra->currentMemberDef=%p xmd=%p yyextra->insideBody=%d\n",
3187 (
void*)yyextra->currentDefinition,(
void*)yyextra->currentMemberDef,(
void*)xmd,yyextra->insideBody));
3189 if (xmd->templateMaster()) xmd = xmd->templateMaster();
3191 if (xmd->isLinkable())
3194 if (yyextra->currentDefinition && yyextra->currentMemberDef &&
3195 yyextra->insideBody && yyextra->collectXRefs)
3215 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
3220 DBG_CTX((stderr,
"generateClassMemberLink(class=%s,member=%s)=%p\n",
qPrint(def->
name()),
qPrint(memName),(
void*)xmd));
3258 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
3259 DBG_CTX((stderr,
"generateMemberLink(object=%s,mem=%s) classScope=%s\n",
3262 if (varName.
empty())
return;
3270 DBG_CTX((stderr,
"Class found!\n"));
3273 DBG_CTX((stderr,
"Found result!\n"));
3280 if (
getLink(yyscanner,bcName,memName,ol))
3282 DBG_CTX((stderr,
"Found result!\n"));
3291 const ClassDef *vcd = yyextra->symbolResolver.resolveClass(yyextra->currentDefinition,yyextra->scopeName,
true);
3294 DBG_CTX((stderr,
"Found class %s for variable '%s'\n",
qPrint(yyextra->scopeName),
qPrint(varName)));
3307 for (
const auto &vmd : *vmn)
3309 if (vmd->getClassDef()==jcd)
3311 DBG_CTX((stderr,
"Found variable type=%s\n",
qPrint(vmd->typeString())));
3324 DBG_CTX((stderr,
"There is a variable with name '%s'\n",
qPrint(varName)));
3325 for (
const auto &vmd : *vmn)
3327 if (vmd->getClassDef()==vcd)
3329 DBG_CTX((stderr,
"Found variable type=%s\n",
qPrint(vmd->typeString())));
3348 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
3351 DBG_CTX((stderr,
"generatePHPVariableLink(%s) name=%s scope=%s\n",varName,
qPrint(name),
qPrint(yyextra->scopeName)));
3352 if (!
getLink(yyscanner,yyextra->scopeName,name,ol,varName))
3360 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
3362 DString locScope=yyextra->scopeName;
3364 if (yyextra->lang==SrcLangExt::PHP && locFunc.
startsWith(
"self::")) locFunc=locFunc.
mid(4);
3366 DString funcWithScope=locFunc;
3367 DString funcWithFullScope=locFunc;
3371 size_t i=locFunc.
rfind(
"::");
3372 if (yyextra->currentMemberDef && yyextra->currentMemberDef->resolveAlias()->getClassDef() &&
3373 funcName==yyextra->currentMemberDef->localName() &&
3374 yyextra->currentMemberDef->getDefLine()==yyextra->yyLineNr &&
3388 i=locFunc.
rfind(
".");
3393 i=locFunc.
rfind(
"\\");
3398 funcScope=locFunc.
left(i);
3400 size_t ts=locScope.
find(
'<');
3401 size_t te=locScope.
rfind(
'>');
3402 DBG_CTX((stderr,
"ts=%zu te=%zu\n",ts,te));
3406 locScope=locScope.
left(ts)+locScope.
mid(te+1);
3408 ts=funcScope.
find(
'<');
3409 te=funcScope.
rfind(
'>');
3410 DBG_CTX((stderr,
"ts=%zu te=%zu\n",ts,te));
3414 funcScope=funcScope.
left(ts)+funcScope.
mid(te+1);
3416 if (!funcScope.
empty())
3418 funcWithScope = funcScope+
"::"+locFunc;
3419 if (!locScope.
empty())
3421 fullScope=locScope+
"::"+funcScope;
3424 if (!locScope.
empty())
3426 funcWithFullScope = locScope+
"::"+funcWithScope;
3430 if (!fullScope.
empty())
3432 auto it = yyextra->codeClassMap.find(fullScope.
str());
3433 if (it!=yyextra->codeClassMap.end())
3440 if (
getLink(yyscanner,bcName,locFunc,ol,funcName))
3449 if (!locScope.
empty() && fullScope!=locScope)
3451 auto it = yyextra->codeClassMap.find(locScope.
str());
3452 if (it!=yyextra->codeClassMap.end())
3459 if (
getLink(yyscanner,bcName,funcWithScope,ol,funcName))
3467 if (!
getLink(yyscanner,locScope,funcWithScope,ol,funcName))
3478 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
3479 const char *p=yyextra->inputString;
3485 if (c==
'\n') count++;
3487 if (p>yyextra->inputString && *(p-1)!=
'\n')
3496 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
3497 if (yyextra->currentFontClass)
3499 yyextra->code->endFontClass();
3500 yyextra->currentFontClass=
nullptr;
3502 if (specialComment && yyextra->insideSpecialComment)
3504 yyextra->code->endSpecialComment();
3505 yyextra->insideSpecialComment =
false;
3511 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
3515 yyextra->code->startSpecialComment();
3516 yyextra->insideSpecialComment =
true;
3518 yyextra->code->startFontClass(s);
3519 yyextra->currentFontClass=s;
3527 if (ctx==
nullptr)
return;
3528 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
3532 DBG_CTX((stderr,
"writeObjCMethodCall(%s) obj=%s method=%s\n",
3541 DBG_CTX((stderr,
" object is local variable\n"));
3549 DBG_CTX((stderr,
" class=%p method=%p\n",(
void*)cd,(
void*)ctx->
method));
3560 char skipChar =
' ';
3585 yyextra->code->codify(
"$");
3593 while (nc!=0 && isdigit(nc)) { refIdStr+=nc; nc=*p++; }
3595 int refId=refIdStr.
toInt();
3596 auto it = yyextra->nameMap.find(refId);
3597 if (it!=yyextra->nameMap.end())
3603 if (yyextra->currentMemberDef && yyextra->collectXRefs)
3615 DBG_CTX((stderr,
"Invalid name: id=%d\n",refId));
3622 while (nc!=0 && isdigit(nc)) { refIdStr+=nc; nc=*p++; }
3624 int refId=refIdStr.
toInt();
3625 auto it = yyextra->objectMap.find(refId);
3626 if (it!=yyextra->objectMap.end())
3631 if (yyextra->currentDefinition &&
3648 else if (
object==
"super")
3650 if (yyextra->currentDefinition &&
3677 if (yyextra->currentMemberDef && yyextra->collectXRefs)
3690 size_t dotPos =
object.find(
'.',pp);
3691 size_t len =
object.length();
3693 const Definition *scope = yyextra->currentDefinition;
3700 if (fragmentStripped==
"self")
3713 const Definition *symbol = yyextra->symbolResolver.resolveSymbol(scope,fragmentStripped,
DString(),
false,
true);
3719 ctx->
method = yyextra->symbolResolver.getTypedef();
3743 dotPos=
object.find(
'.',pp);
3753 else if (ctx->
method==
nullptr)
3756 DBG_CTX((stderr,
"yyextra->currentDefinition=%p\n",(
void*)yyextra->currentDefinition));
3757 if (yyextra->currentDefinition &&
3778 DBG_CTX((stderr,
"Invalid object: id=%d\n",refId));
3785 while (nc!=0 && isdigit(nc)) { refIdStr+=nc; nc=*p++; }
3787 int refId=refIdStr.
toInt();
3788 auto it = yyextra->contextMap.find(refId);
3789 if (it!=yyextra->contextMap.end())
3804 if (mn && mn->
size()==1)
3822 DBG_CTX((stderr,
"Invalid context: id=%d\n",refId));
3829 while (nc!=0 && isdigit(nc)) { refIdStr+=nc; nc=*p++; }
3831 int refId=refIdStr.
toInt();
3832 auto it = yyextra->wordMap.find(refId);
3833 if (it!=yyextra->wordMap.end())
3836 bool isKeyword = word==
"self";
3852 while (nc!=0 && isdigit(nc)) { refIdStr+=nc; nc=*p++; }
3854 int refId=refIdStr.
toInt();
3855 auto it = yyextra->commentMap.find(refId);
3856 if (it!=yyextra->commentMap.end())
3870 else if (c==
'\'' || c ==
'"')
3887 DBG_CTX((stderr,
"}=(type='%s',name='%s')",
3897 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
3899 result.
sprintf(
"$n%d",yyextra->currentNameId);
3900 yyextra->nameMap.emplace(yyextra->currentNameId,s);
3901 yyextra->currentNameId++;
3907 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
3909 result.
sprintf(
"$o%d",yyextra->currentObjId);
3910 yyextra->objectMap.emplace(yyextra->currentObjId,s);
3911 yyextra->currentObjId++;
3917 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
3919 result.
sprintf(
"$w%d",yyextra->currentWordId);
3920 yyextra->wordMap.emplace(yyextra->currentWordId,s);
3921 yyextra->currentWordId++;
3927 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
3929 result.
sprintf(
"$d%d",yyextra->currentCommentId);
3930 yyextra->commentMap.emplace(yyextra->currentCommentId,s);
3931 yyextra->currentCommentId++;
3937 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
3938 static const std::unordered_set<std::string> non_cpp_keywords = {
3939 "__assume",
"__super",
"abstract",
"function",
3940 "gcnew",
"gcroot",
"generic",
"get",
3941 "internal",
"null",
"pin_ptr",
"raise",
3942 "remove",
"self",
"set",
"transient",
3945 static const std::unordered_set<std::string> non_java_keywords = {
3946 "alignas",
"alignof",
"and",
"and_eq",
"asm",
3947 "atomic_cancel",
"atomic_commit",
"atomic_noexcept",
"auto",
"bitand",
3948 "bitor",
"bool",
"char8_t",
"char16_t",
"char32_t",
3949 "compl",
"concept",
"consteval",
"constexpr",
"constinit",
3950 "const_cast",
"co_await",
"co_return",
"co_yield",
"decltype",
3951 "delete",
"dynamic_cast",
"explicit",
"export",
"extern",
3952 "friend",
"inline",
"mutable",
"namespace",
"noexcept",
3953 "not",
"not_eq",
"nullptr",
"operator",
"or",
3954 "or_eq",
"reflexpr",
"register",
"reinterpret_cast",
"requires",
3955 "signed",
"sizeof",
"static_assert",
"_Static_assert",
"static_cast",
"struct",
3956 "template",
"thread_local",
"typedef",
"typeid",
"typename",
3957 "union",
"unsigned",
"using",
"virtual",
"wchar_t",
3958 "xor",
"xor_eq",
"override",
"sealed"
3960 bool retval =
false;
3961 switch (yyextra->lang)
3963 case SrcLangExt::Cpp:
3964 retval = (non_cpp_keywords.find(keyword) != non_cpp_keywords.end());
3966 case SrcLangExt::Java:
3967 retval = (non_java_keywords.find(keyword) != non_java_keywords.end());
3979 size_t i=s.
find(
'<');
3982 return kw==
"const_cast" || kw==
"static_cast" || kw==
"dynamic_cast" || kw==
"reinterpret_cast";
3987 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
3988 yy_size_t inputPosition = yyextra->inputPosition;
3989 const char *s = yyextra->inputString + inputPosition;
3991 while( c < max_size && *s )
3996 yyextra->inputPosition += c;
4003 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
4004 if (yyextra->currentCtx)
4006 yyextra->currentCtx->format+=
DString().
sprintf(
"$c%d",yyextra->currentCtxId);
4007 if (yyextra->braceCount==0 && YY_START==ObjCCall)
4009 yyextra->currentCtx->objectTypeOrName=yyextra->currentCtx->format.mid(1);
4010 DBG_CTX((stderr,
"new type=%s\n",
qPrint(yyextra->currentCtx->objectTypeOrName)));
4012 yyextra->contextStack.push(yyextra->currentCtx);
4016 DBG_CTX((stderr,
"Trying to save NULL context!\n"));
4018 auto newCtx = std::make_unique<ObjCCallCtx>();
4019 newCtx->id = yyextra->currentCtxId;
4020 newCtx->lexState = YY_START;
4021 newCtx->braceCount = yyextra->braceCount;
4022 newCtx->objectType =
nullptr;
4023 newCtx->objectVar =
nullptr;
4024 newCtx->method =
nullptr;
4025 DBG_CTX((stderr,
"save state=%d\n",YY_START));
4026 yyextra->currentCtx = newCtx.get();
4027 yyextra->contextMap.emplace(yyextra->currentCtxId,std::move(newCtx));
4028 yyextra->braceCount = 0;
4029 yyextra->currentCtxId++;
4034 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
4035 DBG_CTX((stderr,
"restore state=%d->%d\n",YY_START,yyextra->currentCtx->lexState));
4036 BEGIN(yyextra->currentCtx->lexState);
4037 yyextra->braceCount = yyextra->currentCtx->braceCount;
4038 if (!yyextra->contextStack.empty())
4040 yyextra->currentCtx = yyextra->contextStack.top();
4041 yyextra->contextStack.pop();
4045 yyextra->currentCtx =
nullptr;
4046 DBG_CTX((stderr,
"Trying to pop context while yyextra->contextStack is empty!\n"));
4058 codeYYlex_init_extra(&
p->state,&
p->yyscanner);
4067 codeYYlex_destroy(
p->yyscanner);
4072 struct yyguts_t *yyg = (
struct yyguts_t*)
p->yyscanner;
4073 DBG_CTX((stderr,
"***CodeParser::reset()\n"));
4074 yyextra->theVarContext.clear();
4075 while (!yyextra->scopeNameLengthStack.empty()) yyextra->scopeNameLengthStack.pop_back();
4076 yyextra->codeClassMap.clear();
4077 yyextra->curClassBases.clear();
4078 yyextra->anchorCount = 0;
4079 yyextra->insideCodeLine =
false;
4084 struct yyguts_t *yyg = (
struct yyguts_t*)
p->yyscanner;
4085 yyextra->insideCodeLine = inp;
4090 struct yyguts_t *yyg = (
struct yyguts_t*)
p->yyscanner;
4091 return yyextra->insideCodeLine;
4098 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
4099 DBG_CTX((stderr,
"***parseCode() exBlock=%d exName=%s fd=%p scopeName=%s searchCtx=%s\n",
4103 if (s.
empty())
return;
4109 yyextra->code = &od;
4110 yyextra->inputString = s.
data();
4113 yyextra->inputPosition = 0;
4114 codeYYrestart(
nullptr,yyscanner);
4115 yyextra->currentFontClass =
nullptr;
4116 yyextra->searchCtx = options.
searchCtx();
4118 yyextra->inFunctionTryBlock =
false;
4119 yyextra->symbolResolver.setFileScope(options.
fileDef());
4120 yyextra->foldStack.clear();
4121 yyextra->insideSpecialComment =
false;
4124 yyextra->curlyCount = 0;
4125 yyextra->bodyCurlyCount = 0;
4126 yyextra->bracketCount = 0;
4127 yyextra->sharpCount = 0;
4128 yyextra->insideTemplate =
false;
4129 yyextra->theCallContext.clear();
4130 while (!yyextra->scopeStack.empty()) yyextra->scopeStack.pop();
4131 yyextra->scopeName = scopeName;
4133 yyextra->exampleBlock = options.
isExample();
4135 yyextra->sourceFileDef = options.
fileDef();
4137 if (options.
fileDef()==
nullptr)
4141 yyextra->sourceFileDef = yyextra->exampleFileDef.get();
4143 yyextra->lang = lang;
4144 yyextra->insideObjC = lang==SrcLangExt::ObjC;
4145 if (yyextra->sourceFileDef)
4150 yyextra->currentMemberDef =
nullptr;
4151 yyextra->searchingForBody = options.
isExample();
4152 yyextra->insideBody =
false;
4153 yyextra->bracketCount = 0;
4154 if (!yyextra->exampleName.empty())
4156 yyextra->exampleFile =
convertNameToFile(yyextra->exampleName+
"-example",
false,
true);
4157 DBG_CTX((stderr,
"yyextra->exampleFile=%s\n",
qPrint(yyextra->exampleFile)));
4161 if (!yyextra->insideCodeLine)
4165 yyextra->type.clear();
4166 yyextra->name.clear();
4167 yyextra->args.clear();
4168 yyextra->parmName.clear();
4169 yyextra->parmType.clear();
4172 codeYYlex(yyscanner);
4173 yyextra->lexInit=
true;
4174 if (yyextra->insideCodeLine)
4180 while (!yyextra->foldStack.empty())
4182 yyextra->code->endFold();
4183 yyextra->foldStack.pop_back();
4186 if (yyextra->exampleFileDef)
4189 yyextra->exampleFileDef.reset();
4190 yyextra->sourceFileDef=
nullptr;
4193 yyextra->tooltipManager.writeTooltips(od);
This class contains the information about the argument of a function or template.
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 file in which this compound's definition can be found.
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 internal white...
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)
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
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)