15%option never-interactive
16%option prefix="codeYY"
18%option extra-type="struct codeYY_state *"
22#define YY_TYPEDEF_YY_SCANNER_T
40#include <unordered_map>
41#include <unordered_set>
70#define DBG_CTX(x) do { } while(0)
72#define YY_NO_UNISTD_H 1
176 std::unordered_map< int,std::unique_ptr<ObjCCallCtx> >
contextMap;
235 bool typeOnly=
false,
bool varOnly=
false);
257#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.
268ID [$a-z_A-Z\x80-\xFF][$a-z_A-Z0-9\x80-\xFF]*
270SCOPENAME ("::"{BN}*)?({ID}{BN}*{SEP}{BN}*)*("~"{BN}*)?{ID}
271TEMPLIST "<"[^\"\}\{\(\)\/\n>]*">"
272SCOPETNAME (((({ID}{TEMPLIST}?){BN}*)?{SEP}{BN}*)*)((~{BN}*)?{ID})
273SCOPEPREFIX ({ID}{TEMPLIST}?{BN}*{SEP}{BN}*)+
274KEYWORD_OBJC ("@public"|"@private"|"@protected"|"@class"|"@implementation"|"@interface"|"@end"|"@selector"|"@protocol"|"@optional"|"@required"|"@throw"|"@synthesize"|"@property")
276KEYWORD ("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"))
277FLOWKW ("break"|"catch"|"continue"|"default"|"do"|"else"|"finally"|"return"|"switch"|"throw"|"throws"|"@catch"|"@finally")
278FLOWCONDITION ("case"|"for"|"foreach"|"for each"|"goto"|"if"|"try"|"while"|"@try")
279TYPEKW ("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")
280TYPEKWSL ("LocalObject"|"Object"|"Value")
281CASTKW ("const_cast"|"dynamic_cast"|"reinterpret_cast"|"static_cast")
282CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^' \\\n]{1,4}"'"))
283ARITHOP "+"|"-"|"/"|"*"|"%"|"--"|"++"
284ASSIGNOP "="|"*="|"/="|"%="|"+="|"-="|"<<="|">>="|"&="|"^="|"|="
285LOGICOP "=="|"!="|">"|"<"|">="|"<="|"&&"|"||"|"!"|"<=>"
286BITOP "&"|"|"|"^"|"<<"|">>"|"~"
287OPERATOR {ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}
288RAWBEGIN (u|U|L|u8)?R\"[^ \t\(\)\\]{0,16}"("
289RAWEND ")"[^ \t\(\)\\]{0,16}\"
290MODULE_ID ({ID}".")*{ID}
296DECIMAL_INTEGER [1-9][0-9']*[0-9]?[uU]?[lL]?[lL]?
297HEXADECIMAL_INTEGER "0"[xX][0-9a-zA-Z']+[0-9a-zA-Z]?
298OCTAL_INTEGER "0"[0-7][0-7']+[0-7]?
299BINARY_INTEGER "0"[bB][01][01']*[01]?
300INTEGER_NUMBER {DECIMAL_INTEGER}|{HEXADECIMAL_INTEGER}|{OCTAL_INTEGER}|{BINARY_INTEGER}
304DIGIT_SEQ [0-9][0-9']*[0-9]?
305FRAC_CONST {DIGIT_SEQ}"."|{DIGIT_SEQ}?"."{DIGIT_SEQ}
306FP_EXP [eE][+-]?{DIGIT_SEQ}
307DEC_FP1 {FRAC_CONST}{FP_EXP}?{FP_SUF}?
308DEC_FP2 {DIGIT_SEQ}{FP_EXP}{FP_SUF}
310HEX_DIGIT_SEQ [0-9a-fA-F][0-9a-fA-F']*[0-9a-fA-F]?
311HEX_FRAC_CONST {HEX_DIGIT_SEQ}"."|{HEX_DIGIT_SEQ}?"."{HEX_DIGIT_SEQ}
312BIN_EXP [pP][+-]?{DIGIT_SEQ}
313HEX_FP1 "0"[xX]{HEX_FRAC_CONST}{BIN_EXP}{FP_SUF}?
314HEX_FP2 "0"[xX]{HEX_DIGIT_SEQ}{BIN_EXP}{FP_SUF}?
316FLOAT_DECIMAL {DEC_FP1}|{DEC_FP2}
317FLOAT_HEXADECIMAL {HEX_FP1}|{HEX_FP2}
318FLOAT_NUMBER {FLOAT_DECIMAL}|{FLOAT_HEXADECIMAL}
319NUMBER {INTEGER_NUMBER}|{FLOAT_NUMBER}
332ENDQopt ("const"|"volatile"|"sealed"|"override")({BN}+("const"|"volatile"|"sealed"|"override"))*
353%x CppCliTypeModifierFollowup
378<Body>^([ \t]*"#"[ \t]*("include"|"import")[ \t]*)("<"|"\"") {
380 yyextra->code->codify(yytext);
381 BEGIN( ReadInclude );
383<Body>("@interface"|"@implementation"|"@protocol")[ \t\n]+ {
384 yyextra->insideObjC=
true;
388 if (!yyextra->insideTemplate)
391<Body>(("public"|"private"){B}+)?("ref"|"value"|"interface"|"enum"){B}+("class"|"struct") {
392 if (yyextra->insideTemplate) REJECT;
398<Body>"property"|"event"/{BN}* {
399 if (yyextra->insideTemplate) REJECT;
404<Body>("partial"{B}+)?("class"|"struct"|"union"|"namespace"|"interface"){B}+ {
408 if (!yyextra->insideTemplate)
411<Body>("package")[ \t\n]+ {
415 BEGIN( PackageName );
418 if (!yyextra->insideObjC) REJECT;
422<Body,ClassVar,Bases>"-"|"+" {
423 if (!yyextra->insideObjC || yyextra->insideBody)
425 yyextra->code->codify(yytext);
429 DBG_CTX((stderr,
"Start of Objective-C method!\n"));
430 yyextra->code->codify(yytext);
435 yyextra->code->codify(yytext);
439 yyextra->code->codify(yytext);
440 BEGIN(ObjCParamType);
442<ObjCParams,ObjCMethod>";"|"{" {
443 yyextra->code->codify(yytext);
446 if (yyextra->searchingForBody)
448 yyextra->searchingForBody=
false;
449 yyextra->insideBody=
true;
451 if (yyextra->insideBody) yyextra->bodyCurlyCount++;
452 if (!yyextra->curClassName.empty())
454 pushScope(yyscanner,yyextra->curClassName);
455 DBG_CTX((stderr,
"** scope stack push SCOPEBLOCK\n"));
459 yyextra->type.clear();
460 yyextra->name.clear();
463<ObjCParams>{ID}{B}*":" {
464 yyextra->code->codify(yytext);
466<ObjCParamType>{TYPEKW} {
468 yyextra->code->codify(yytext);
470 yyextra->parmType=yytext;
474 yyextra->parmType=yytext;
477 yyextra->code->codify(yytext);
481 yyextra->code->codify(yytext);
482 yyextra->parmName=yytext;
483 addVariable(yyscanner,yyextra->parmType,yyextra->parmName);
484 yyextra->parmType.clear();yyextra->parmName.clear();
486<ObjCMethod,ObjCParams,ObjCParamType>{ID} {
489<ObjCMethod,ObjCParams,ObjCParamType>. {
490 yyextra->code->codify(yytext);
492<ObjCMethod,ObjCParams,ObjCParamType>\n {
495<ReadInclude>[^\n\">]+/(">"|"\"") {
506 DBG_CTX((stderr,
"===== yes %s is ambiguous\n",yytext));
508 if (!name.empty() && yyextra->sourceFileDef)
514 auto it = std::find_if(fn->begin(),
516 [&sfd=yyextra->sourceFileDef]
518 { return sfd->isIncluded(lfd->absFilePath()); });
519 found = it!=fn->end();
535 yyextra->code->codify(yytext);
537 char c=(char)yyinput(yyscanner);
540 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)
544<Body,Bases>^[ \t]*"#" {
546 yyextra->lastSkipCppContext = YY_START;
547 yyextra->code->codify(yytext);
551 yyextra->code->codify(yytext);
552 yyextra->lastStringContext=YY_START;
553 BEGIN( SkipString ) ;
556 yyextra->code->codify(yytext);
558<SkipCPP>[^\n\/\\\"]+ {
559 yyextra->code->codify(yytext);
564<SkipCPP>{CPPC}/[^/!] {
567<Body,FuncCall,MemberCall,MemberCall2>"}" {
568 yyextra->theVarContext.popScope();
569 yyextra->theCallContext.popScope(yyextra->name, yyextra->type, yyextra->bracketCount);
570 yyextra->type.clear();
571 yyextra->name.clear();
573 if (!yyextra->scopeStack.empty())
575 int scope = yyextra->scopeStack.top();
576 yyextra->scopeStack.pop();
584 yyextra->code->codify(yytext);
586 DBG_CTX((stderr,
"yyextra->bodyCurlyCount=%d\n",yyextra->bodyCurlyCount));
587 if (--yyextra->bodyCurlyCount<=0)
589 yyextra->insideBody=
false;
590 yyextra->currentMemberDef=
nullptr;
591 if (yyextra->currentDefinition)
592 yyextra->currentDefinition=yyextra->currentDefinition->getOuterScope();
596<Body,ClassVar>"@end" {
597 DBG_CTX((stderr,
"End of objc scope fd=%s\n",
qPrint(yyextra->sourceFileDef->name())));
598 if (yyextra->sourceFileDef)
600 const FileDef *fd=yyextra->sourceFileDef;
603 DBG_CTX((stderr,
"insideObjC=%d\n",yyextra->insideObjC));
607 yyextra->insideObjC =
false;
609 if (yyextra->insideBody)
611 yyextra->theVarContext.popScope();
613 if (!yyextra->scopeStack.empty())
615 int scope = yyextra->scopeStack.top();
616 yyextra->scopeStack.pop();
623 yyextra->insideBody=
false;
627 yyextra->code->codify(yytext);
630 yyextra->currentMemberDef=
nullptr;
631 if (yyextra->currentDefinition)
632 yyextra->currentDefinition=yyextra->currentDefinition->getOuterScope();
bool endsWith(const char *s) const
virtual const DString & name() const =0
635<ClassName,ClassVar>";" {
636 if (yyextra->lang==SrcLangExt::CSharp)
638 yyextra->code->codify(yytext);
639 yyextra->skipCodify =
true;
644 yyextra->code->codify(yytext);
645 yyextra->searchingForBody=
false;
649<ClassName,ClassVar>[*&^%]+ {
650 yyextra->type=yyextra->curClassName;
651 yyextra->name.clear();
652 yyextra->code->codify(yytext);
655<ClassName>"__declspec"{B}*"("{B}*{ID}{B}*")" {
657 yyextra->code->codify(yytext);
660<ClassName>{ID}("."{ID})* |
661<ClassName>{ID}("::"{ID})* {
662 if (yyextra->lang==SrcLangExt::CSharp)
663 yyextra->curClassName=
substitute(yytext,
".",
"::");
665 yyextra->curClassName=yytext;
667 if (yyextra->curClassName==
"alignas")
670 yyextra->code->codify(yytext);
DString substitute(const DString &s, const DString &src, const DString &dst)
substitute all occurrences of src in s by dst
681 yyextra->bracketCount=1;
682 yyextra->code->codify(yytext);
685<AlignAs>\n { yyextra->yyLineNr++;
688<AlignAs>. { yyextra->code->codify(yytext); }
689<AlignAsEnd>"(" { yyextra->code->codify(yytext);
690 yyextra->bracketCount++;
693 yyextra->code->codify(yytext);
694 if (--yyextra->bracketCount<=0)
699<AlignAsEnd>\n { yyextra->yyLineNr++;
702<AlignAsEnd>. { yyextra->code->codify(yytext); }
703<ClassName>{ID}("\\"{ID})* {
704 yyextra->curClassName=
substitute(yytext,
"\\",
"::");
706 pushScope(yyscanner,yyextra->curClassName);
711<ClassName>{ID}{B}*"("{ID}")" {
714 pushScope(yyscanner,yyextra->curClassName);
DString removeRedundantWhiteSpace(const DString &s)
719<PackageName>{ID}("."{ID})* {
720 yyextra->curClassName=
substitute(yytext,
".",
"::");
721 DBG_CTX((stderr,
"found package: %s\n",
qPrint(yyextra->curClassName)));
729<ClassVar>("extends"|"implements") {
733 yyextra->curClassBases.clear();
736<ClassVar>("sealed"|"abstract")/{BN}*(":"|"{") {
737 DBG_CTX((stderr,
"***** C++/CLI modifier %s on yyextra->curClassName=%s\n",yytext,
qPrint(yyextra->curClassName)));
741 BEGIN( CppCliTypeModifierFollowup );
744 yyextra->type = yyextra->curClassName;
745 yyextra->name = yytext;
746 if (yyextra->insideBody)
748 addVariable(yyscanner,yyextra->type,yyextra->name);
752<ClassName,ClassVar,CppCliTypeModifierFollowup>{B}*":"{B}* {
754 yyextra->curClassBases.clear();
757<PackageName>[ \t]*";" |
758<Bases>^{Bopt}/"@"{ID} |
759<Bases,ClassName,ClassVar,CppCliTypeModifierFollowup>{B}*"{"{B}* {
760 yyextra->theVarContext.pushScope();
761 if (!yyextra->skipCodify) yyextra->code->codify(yytext);
762 yyextra->skipCodify =
false;
763 if (YY_START==ClassVar && yyextra->curClassName.empty())
765 yyextra->curClassName = yyextra->name;
767 if (yyextra->searchingForBody)
769 yyextra->searchingForBody=
false;
770 yyextra->insideBody=
true;
772 if (yyextra->insideBody) yyextra->bodyCurlyCount++;
773 if (!yyextra->curClassName.empty())
775 DBG_CTX((stderr,
"** scope stack push CLASSBLOCK\n"));
777 pushScope(yyscanner,yyextra->curClassName);
778 DBG_CTX((stderr,
"***** yyextra->curClassName=%s\n",
qPrint(yyextra->curClassName)));
779 if (yyextra->symbolResolver.resolveClass(yyextra->currentDefinition,yyextra->curClassName,
true)==
nullptr)
781 DBG_CTX((stderr,
"Adding new class %s\n",
qPrint(yyextra->curClassName)));
784 for (
const auto &s : yyextra->curClassBases)
787 auto it = yyextra->codeClassMap.find(s);
788 if (it!=yyextra->codeClassMap.end())
792 if (bcd==
nullptr) bcd=yyextra->symbolResolver.resolveClass(yyextra->currentDefinition,s,
true);
793 if (bcd && bcd->
name()!=yyextra->curClassName)
795 var.localDef()->insertBaseClass(bcd->
name());
798 yyextra->codeClassMap.emplace(yyextra->curClassName.str(),std::move(var));
804 DBG_CTX((stderr,
"** scope stack push INNERBLOCK\n"));
807 yyextra->curClassName.clear();
808 yyextra->curClassBases.clear();
ClassDef * toClassDef(Definition *d)
811<Bases>"virtual"|"public"|"protected"|"private"|"@public"|"@private"|"@protected" {
813 yyextra->code->codify(yytext);
816<Bases>{SEP}?({ID}{SEP})*{ID} {
817 DBG_CTX((stderr,
"%s:addBase(%s)\n",
qPrint(yyextra->curClassName),yytext));
818 yyextra->curClassBases.emplace_back(yytext);
822 yyextra->code->codify(yytext);
823 if (!yyextra->insideObjC)
825 yyextra->sharpCount=1;
830 yyextra->insideProtocolList=
true;
834 yyextra->code->codify(yytext);
835 yyextra->insideProtocolList=
false;
838 yyextra->code->codify(yytext);
839 ++yyextra->sharpCount;
842 yyextra->code->codify(yytext);
843 if (--yyextra->sharpCount<=0)
847 yyextra->code->codify(yytext);
848 yyextra->lastStringContext=YY_START;
852 yyextra->code->codify(yytext);
853 yyextra->lastStringContext=YY_START;
857 yyextra->code->codify(yytext);
858 yyextra->sharpCount=1;
862 yyextra->code->codify(yytext);
863 ++yyextra->sharpCount;
866 yyextra->code->codify(yytext);
867 if (--yyextra->sharpCount<=0)
873 yyextra->code->codify(yytext);
877<Body>{SCOPEPREFIX}?"operator"{B}*"()"{Bopt}/"(" {
880 yyextra->bracketCount=0;
881 yyextra->args.clear();
882 yyextra->name+=yytext;
885<Body>{SCOPEPREFIX}?"operator"/"(" {
888 yyextra->bracketCount=0;
889 yyextra->args.clear();
890 yyextra->name+=yytext;
893<Body>{SCOPEPREFIX}?"operator"[^a-z_A-Z0-9\(\n]+/"(" {
896 yyextra->bracketCount=0;
897 yyextra->args.clear();
898 yyextra->name+=yytext;
901<Body,TemplDecl>("template"|"generic")/([^a-zA-Z0-9]) {
905 yyextra->insideTemplate=
true;
906 yyextra->sharpCount=0;
908<Body>"concept"{BN}+ {
914<Body>"using"{BN}+"namespace"{BN}+ {
926<Body>"module"/{B}*[:;]? {
927 if (yyextra->lang!=SrcLangExt::Cpp) REJECT;
928 if (!yyextra->type.empty() || !yyextra->name.empty()) REJECT;
934<Body>"import"/{B}*[<":]? {
935 if (yyextra->lang!=SrcLangExt::Cpp) REJECT;
941<ConceptName>{ID}("::"{ID})* {
944<ConceptName>"=" {
codifyLines(yyscanner,yytext); BEGIN(Body); }
945<UsingName>{ID}(("::"|"."){ID})* {
950<UsingName>\n {
codifyLines(yyscanner,yytext); BEGIN(Body); }
951<UsingName>. {
codifyLines(yyscanner,yytext); BEGIN(Body); }
952<Body,FuncCall>"$"?"this"("->"|".") { yyextra->code->codify(yytext);
953 yyextra->isPrefixedWithThis =
true;
955<Body>{KEYWORD}/([^a-z_A-Z0-9]) {
956 if (yyextra->lang==SrcLangExt::Java &&
dstrcmp(
"internal",yytext) ==0) REJECT;
964 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)
968<Body>{KEYWORD}/{B}* {
974<Body>{KEYWORD}/{BN}*"(" {
979 yyextra->name.clear();yyextra->type.clear();
981<FuncCall>"in"/{BN}* {
982 if (!yyextra->inForEachExpression) REJECT;
987 yyextra->theVarContext.popScope();
988 addVariable(yyscanner,yyextra->parmType,yyextra->parmName);
989 yyextra->theVarContext.pushScope();
990 yyextra->name.clear();yyextra->type.clear();
992<Body>{FLOWKW}/{BN}*"(" {
996 yyextra->name.clear();yyextra->type.clear();
997 yyextra->inForEachExpression = (
dstrcmp(yytext,
"for each")==0 ||
dstrcmp(yytext,
"foreach")==0);
1000<Body>{FLOWCONDITION}/{BN}*"(" {
1005 yyextra->name.clear();yyextra->type.clear();
1006 yyextra->inForEachExpression = (strcmp(yytext,
"for each")==0 || strcmp(yytext,
"foreach")==0);
1009<Body>{FLOWKW}/([^a-z_A-Z0-9]) {
1013 if (yyextra->inFunctionTryBlock && (
dstrcmp(yytext,
"catch")==0 ||
dstrcmp(yytext,
"finally")==0))
1015 yyextra->inFunctionTryBlock=
false;
1018<Body>{FLOWCONDITION}/([^a-z_A-Z0-9]) {
1023 if (yyextra->inFunctionTryBlock && (strcmp(yytext,
"catch")==0 || strcmp(yytext,
"finally")==0))
1025 yyextra->inFunctionTryBlock=
false;
1028<Body>{FLOWKW}/{B}* {
1033<Body>{FLOWCONDITION}/{B}* {
1040 yyextra->code->codify(yytext);
1041 yyextra->theCallContext.popScope(yyextra->name, yyextra->type, yyextra->bracketCount);
1042 yyextra->bracketCount--;
1043 yyextra->parmType = yyextra->name;
1046<Body>"\\)"|"\\(" {
1047 yyextra->code->codify(yytext);
1049<Body>[\\|\)\+\-\/\%\~\!] {
1050 yyextra->code->codify(yytext);
1051 yyextra->name.clear();yyextra->type.clear();
1054 yyextra->theCallContext.popScope(yyextra->name, yyextra->type, yyextra->bracketCount);
1055 yyextra->bracketCount--;
1056 if (yyextra->bracketCount<=0)
1062<Body,TemplDecl,ObjCMethod>{TYPEKW}/{B}* {
1064 yyextra->code->codify(yytext);
1067 yyextra->name+=yytext;
1069<Body,TemplDecl,ObjCMethod>{TYPEKWSL}/{B}* {
1070 if (yyextra->lang!=SrcLangExt::Slice)
1077 yyextra->code->codify(yytext);
1080 yyextra->name+=yytext;
1083<Body>"generic"/{B}*"<"[^\n\/\-\.\{\">]*">"{B}* {
1085 yyextra->code->codify(yytext);
1087 yyextra->sharpCount=0;
1090<Body>"template"/{B}*"<"[^\n\/\-\.\{\">]*">"{B}* {
1092 yyextra->code->codify(yytext);
1094 yyextra->sharpCount=0;
1097<TemplDecl>"class"|"typename" {
1103 yyextra->code->codify(yytext);
1104 yyextra->sharpCount++;
1107 yyextra->code->codify(yytext);
1108 yyextra->sharpCount--;
1109 if (yyextra->sharpCount<=0)
1118 BEGIN( yyextra->lastTemplCastContext );
1120<TemplCast>{ID}("::"{ID})* {
1123<TemplCast>("const"|"volatile"){B}* {
1131<Body,MemberCall2,FuncCall>{CASTKW}{B}*"<" {
1135 yyextra->lastTemplCastContext = YY_START;
1138<Body>"$this->"{SCOPENAME}/{BN}*[;,)\]] {
1141 yyextra->name+=yytext+7;
1143<Body,TemplCast>{SCOPENAME}{B}*"<"[^\n\/\-\.\{\">\(']*">"{ENDIDopt}/{B}* {
1150 yyextra->name+=yytext;
1152<ModuleName,ModuleImport>{MODULE_ID}({BN}*":"{BN}*{MODULE_ID})? {
1154 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
1171<ModuleName>":"{BN}+"private" {
1173 size_t i=text.
find(
'p');
1179<ModuleName>";" { yyextra->code->codify(yytext); BEGIN(Body); }
1180<ModuleName>. { yyextra->code->codify(yytext); }
1182<ModuleImport>["<] { yyextra->code->codify(yytext); BEGIN(ReadInclude); }
1183<ModuleImport>";" { yyextra->code->codify(yytext); BEGIN(Body); }
1184<ModuleImport>. { yyextra->code->codify(yytext); }
1185<ModuleImport>\n {
codifyLines(yyscanner,yytext); }
1187<Body>{SCOPENAME}/{BN}*[:;,)\]] {
1194 yyextra->name+=yytext;
1196<Body>{ID}("."{ID})+/{BN}+ {
1197 if (yyextra->lang==SrcLangExt::CSharp || yyextra->lang==SrcLangExt::Java)
1201 yyextra->name+=yytext;
1208<Body>"export"/{B}* {
1209 if (yyextra->lang!=SrcLangExt::Cpp) REJECT;
1214<Body>{SCOPENAME}/{B}* {
1221 yyextra->name+=yytext;
1223<Body>"("{B}*("*"{B}*)+{SCOPENAME}+{B}*")"/{B}* {
1224 yyextra->code->codify(yytext);
1225 uint32_t s=0;
while (s<(uint32_t)yyleng && !
isId(yytext[s])) s++;
1226 uint32_t e=(uint32_t)yyleng-1;
while (e>1 && !
isId(yytext[e])) e--;
1229 yyextra->name=std::move(varname);
bool isId(char c)
Returns true if c is a valid character for an identifier.
1231<Body>{SCOPETNAME}{B}*"<"[^\n\/\-\.\{\">]*">"/{BN}*"(" |
1232<Body>{SCOPETNAME}/{BN}*"(" {
1239 yyextra->bracketCount=0;
1240 yyextra->args.clear();
1241 yyextra->name+=yytext;
1244<FuncCall,Body,MemberCall,MemberCall2,SkipInits,InlineInit>{RAWBEGIN} {
1246 size_t i=text.
find(
'R');
1247 yyextra->code->codify(text.
left(i+1));
1249 yyextra->code->codify(yytext+i+1);
1250 yyextra->lastStringContext=YY_START;
1251 yyextra->inForEachExpression =
false;
DString extractBeginRawStringDelimiter(const char *rawStart)
1255<FuncCall,Body,MemberCall,MemberCall2,SkipInits,InlineInit,ClassVar,OldStyleArgs>\" {
1257 yyextra->code->codify(yytext);
1258 yyextra->lastStringContext=YY_START;
1259 yyextra->inForEachExpression =
false;
1260 BEGIN( SkipString );
1262<FuncCall,Body,MemberCall,MemberCall2,SkipInits,InlineInit>{NUMBER} {
1263 if (yyextra->lang!=SrcLangExt::Cpp) REJECT;
1264 yyextra->code->codify(yytext);
1266<FuncCall,Body,MemberCall,MemberCall2,SkipInits,InlineInit>\' {
1268 yyextra->code->codify(yytext);
1269 yyextra->lastStringContext=YY_START;
1270 yyextra->inForEachExpression =
false;
1271 BEGIN( SkipStringS );
1273<SkipString>[^\"\\\r\n]{1,100} {
1274 yyextra->code->codify(yytext);
1276<SkipStringS>[^\'\\\r\n]{1,100} {
1277 yyextra->code->codify(yytext);
1279<SkipString,SkipStringS>{CPPC}|{CCS} {
1280 yyextra->code->codify(yytext);
1283 yyextra->code->codify(yytext);
1284 if (yyextra->lastStringContext!=SkipCPP)
1288 BEGIN( yyextra->lastStringContext );
1291 yyextra->code->codify(yytext);
1293 BEGIN( yyextra->lastStringContext );
1295<SkipString,SkipStringS>\\. {
1296 yyextra->code->codify(yytext);
1298<RawString>{RAWEND} {
1299 yyextra->code->codify(yytext);
1302 BEGIN( yyextra->lastStringContext );
DString extractEndRawStringDelimiter(const char *rawEnd)
1305<RawString>[^)\n]+ { yyextra->code->codify(yytext); }
1306<RawString>. { yyextra->code->codify(yytext); }
1308<SkipVerbString>[^"\n]+ {
1309 yyextra->code->codify(yytext);
1311<SkipVerbString>\"\" {
1312 yyextra->code->codify(yytext);
1315 yyextra->code->codify(yytext);
1317 BEGIN( yyextra->lastVerbStringContext );
1320 yyextra->code->codify(yytext);
1326 yyextra->code->codify(yytext);
1327 yyextra->name.clear();yyextra->type.clear();
1330 if (yyextra->insideTemplate)
1332 yyextra->sharpCount++;
1334 yyextra->code->codify(yytext);
1337 if (yyextra->insideTemplate)
1339 if (--yyextra->sharpCount<=0)
1341 yyextra->insideTemplate=
false;
1344 yyextra->code->codify(yytext);
1346<Body,MemberCall,MemberCall2,FuncCall,OldStyleArgs>"'"((\\0[Xx0-9]+)|(\\.)|(.))"'" {
1348 yyextra->code->codify(yytext);
1356 yyextra->code->codify(yytext);
1357 yyextra->memCallContext = YY_START;
1358 BEGIN( MemberCall );
1360<MemberCall>{SCOPETNAME}/{BN}*"(" {
1362 if (yyextra->theCallContext.getScope().globalDef())
1369 yyextra->name.clear();
1375 yyextra->name.clear();
1377 yyextra->type.clear();
1378 if (yyextra->memCallContext==Body)
1384 BEGIN(yyextra->memCallContext);
1387<MemberCall>{SCOPENAME}/{B}* {
1388 if (yyextra->theCallContext.getScope().globalDef())
1390 DBG_CTX((stderr,
"yyextra->theCallContext.getClass()=%p\n",(
void*)yyextra->theCallContext.getScope().globalDef()));
1396 yyextra->name.clear();
1400 DBG_CTX((stderr,
"no class context!\n"));
1403 yyextra->name.clear();
1405 yyextra->type.clear();
1406 BEGIN(yyextra->memCallContext);
1409 if (yyextra->insideObjC && *yytext==
'[')
1411 DBG_CTX((stderr,
"Found start of ObjC call!\n"));
1413 yyextra->contextMap.clear();
1414 yyextra->nameMap.clear();
1415 yyextra->objectMap.clear();
1416 yyextra->wordMap.clear();
1417 yyextra->commentMap.clear();
1418 yyextra->currentCtxId = 0;
1419 yyextra->currentNameId = 0;
1420 yyextra->currentObjId = 0;
1421 yyextra->currentCtx =
nullptr;
1422 yyextra->braceCount = 0;
1428 if (*yytext!=
'{') yyextra->code->codify(yytext);
1429 yyextra->saveName = yyextra->name;
1430 yyextra->saveType = yyextra->type;
1431 if (*yytext!=
'[' && !yyextra->type.empty())
1438 addVariable(yyscanner,yyextra->type,yyextra->name);
1440 yyextra->name.clear();
1442 if (*yytext==
';' || *yytext==
'=' || *yytext==
'{')
1444 yyextra->type.clear();
1445 yyextra->name.clear();
1447 else if (*yytext==
'[')
1449 yyextra->theCallContext.pushScope(yyextra->name, yyextra->type, yyextra->bracketCount);
1451 yyextra->args.clear();
1452 yyextra->parmType.clear();
1453 yyextra->parmName.clear();
1461<Body,FuncCall,BodyVar>"{" {
1462 yyextra->theVarContext.pushScope();
1463 yyextra->theCallContext.pushScope(yyextra->name, yyextra->type, yyextra->bracketCount);
1464 yyextra->bracketCount = 0;
1469 DBG_CTX((stderr,
"** scope stack push SCOPEBLOCK\n"));
1475 DBG_CTX((stderr,
"** scope stack push INNERBLOCK\n"));
1479 if (yyextra->searchingForBody)
1481 yyextra->searchingForBody=
false;
1482 yyextra->insideBody=
true;
1484 yyextra->code->codify(yytext);
1485 if (yyextra->insideBody)
1487 yyextra->bodyCurlyCount++;
1489 yyextra->type.clear();
1490 yyextra->name.clear();
1493<ObjCCall,ObjCMName>"["|"{" {
1495 yyextra->currentCtx->format+=*yytext;
1499<ObjCCall,ObjCMName>"]"|"}" {
1500 yyextra->currentCtx->format+=*yytext;
1503 if (yyextra->currentCtx==
nullptr)
1507 auto it = yyextra->contextMap.find(0);
1508 if (it!=yyextra->contextMap.end())
1510 ctx = it->second.get();
1517<ObjCCall,ObjCMName>{CPPC}.* {
1518 yyextra->currentCtx->format+=
escapeComment(yyscanner,yytext);
1520<ObjCCall,ObjCMName>{CCS} {
1521 yyextra->lastObjCCallContext = YY_START;
1522 yyextra->currentCtx->comment.str(yytext);
1523 BEGIN(ObjCCallComment);
1525<ObjCCallComment>{CCE} {
1526 yyextra->currentCtx->comment << yytext;
1527 yyextra->currentCtx->format+=
escapeComment(yyscanner,yyextra->currentCtx->comment.str());
1528 BEGIN(yyextra->lastObjCCallContext);
1530<ObjCCallComment>[^*\n]+ { yyextra->currentCtx->comment << yytext; }
1531<ObjCCallComment>{CPPC}|{CCS} { yyextra->currentCtx->comment << yytext; }
1532<ObjCCallComment>\n { yyextra->currentCtx->comment << *yytext; }
1533<ObjCCallComment>. { yyextra->currentCtx->comment << *yytext; }
1534<ObjCCall>{ID}({B}*"."{B}*{ID})* {
1535 yyextra->currentCtx->format+=
escapeObject(yyscanner,yytext);
1536 if (yyextra->braceCount==0)
1538 yyextra->currentCtx->objectTypeOrName=yytext;
1539 DBG_CTX((stderr,
"new type=%s\n",
qPrint(yyextra->currentCtx->objectTypeOrName)));
1543<ObjCMName>{ID}/{BN}*"]" {
1544 if (yyextra->braceCount==0 &&
1545 yyextra->currentCtx->methodName.empty())
1547 yyextra->currentCtx->methodName=yytext;
1548 yyextra->currentCtx->format+=
escapeName(yyscanner,yytext);
1552 yyextra->currentCtx->format+=
escapeWord(yyscanner,yytext);
1555<ObjCMName>{ID}/{BN}*":" {
1556 if (yyextra->braceCount==0)
1558 yyextra->currentCtx->methodName+=yytext;
1559 yyextra->currentCtx->methodName+=
":";
1561 yyextra->currentCtx->format+=
escapeName(yyscanner,yytext);
1563<ObjCSkipStr>[^\n\"$\\]* { yyextra->currentCtx->format+=yytext; }
1564<ObjCSkipStr>\\. { yyextra->currentCtx->format+=yytext; }
1565<ObjCSkipStr>"\"" { yyextra->currentCtx->format+=yytext;
1566 BEGIN(yyextra->lastStringContext);
1568<ObjCCall,ObjCMName>{CHARLIT} { yyextra->currentCtx->format+=yytext; }
1569<ObjCCall,ObjCMName>"@"?"\"" { yyextra->currentCtx->format+=yytext;
1570 yyextra->lastStringContext=YY_START;
1573<ObjCCall,ObjCMName,ObjCSkipStr>"$" { yyextra->currentCtx->format+=
"$$"; }
1574<ObjCCall,ObjCMName>"(" { yyextra->currentCtx->format+=*yytext; yyextra->braceCount++; }
1575<ObjCCall,ObjCMName>")" { yyextra->currentCtx->format+=*yytext; yyextra->braceCount--; }
1576<ObjCSkipStr>"@"/"\"" {
1577 yyextra->currentCtx->format+=yytext;
1579<ObjCCall,ObjCMName,ObjCSkipStr>{ID} { yyextra->currentCtx->format+=
escapeWord(yyscanner,yytext); }
1580<ObjCCall,ObjCMName,ObjCSkipStr>. { yyextra->currentCtx->format+=*yytext; }
1581<ObjCCall,ObjCMName,ObjCSkipStr>\n { yyextra->currentCtx->format+=*yytext; }
1584 yyextra->theCallContext.popScope(yyextra->name, yyextra->type, yyextra->bracketCount);
1585 yyextra->code->codify(yytext);
1587 yyextra->name = yyextra->saveName;
1588 yyextra->type = yyextra->saveType;
1591 yyextra->code->codify(yytext);
1593<Body>[0-9]+[xX][0-9A-Fa-f]+ {
1594 yyextra->code->codify(yytext);
1596<MemberCall2,FuncCall>{KEYWORD}/([^a-z_A-Z0-9]) {
1601 yyextra->code->codify(yytext);
1604<MemberCall2,FuncCall,OldStyleArgs,TemplCast>{TYPEKW}/([^a-z_A-Z0-9]) {
1606 yyextra->parmName=yytext;
1608 yyextra->code->codify(yytext);
1611<MemberCall2,FuncCall,OldStyleArgs,TemplCast>{TYPEKWSL}/([^a-z_A-Z0-9]) {
1612 if (yyextra->lang!=SrcLangExt::Slice)
1619 yyextra->parmName=yytext;
1621 yyextra->code->codify(yytext);
1625<MemberCall2,FuncCall>{FLOWKW}/([^a-z_A-Z0-9]) {
1627 yyextra->parmName=yytext;
1629 yyextra->code->codify(yytext);
1632<MemberCall2,FuncCall>{FLOWCONDITION}/([^a-z_A-Z0-9]) {
1635 yyextra->parmName=yytext;
1637 yyextra->code->codify(yytext);
1640<MemberCall2,FuncCall>("::")?{ID}(({B}*"<"[^\n\[\](){}<>']*">")?({B}*"::"{B}*{ID})?)* {
1646 yyextra->parmName=yytext;
1650 yyextra->code->codify(yytext);
1651 yyextra->inForEachExpression =
false;
1654<MemberCall2,FuncCall>, {
1655 yyextra->code->codify(yytext);
1656 addVariable(yyscanner,yyextra->parmType,yyextra->parmName);
1657 yyextra->parmType.clear();yyextra->parmName.clear();
1659<MemberCall2,FuncCall>"{" {
1660 if (yyextra->bracketCount>0)
1662 yyextra->code->codify(yytext);
1663 yyextra->skipInlineInitContext=YY_START;
1664 yyextra->curlyCount=0;
1672<InlineInit>"{" { yyextra->curlyCount++;
1673 yyextra->code->codify(yytext);
1676 yyextra->code->codify(yytext);
1677 if (--yyextra->curlyCount<=0)
1679 BEGIN(yyextra->skipInlineInitContext);
1686 yyextra->code->codify(yytext);
1688<MemberCall2,FuncCall>"(" {
1689 yyextra->parmType.clear();yyextra->parmName.clear();
1690 yyextra->code->codify(yytext);
1691 yyextra->bracketCount++;
1692 yyextra->theCallContext.pushScope(yyextra->name, yyextra->type, yyextra->bracketCount);
1693 if (YY_START==FuncCall && !yyextra->insideBody)
1695 yyextra->theVarContext.pushScope();
1698<MemberCall2,FuncCall>{OPERATOR} {
1705 yyextra->parmType.clear();yyextra->parmName.clear();
1707 yyextra->code->codify(yytext);
1709<MemberCall,MemberCall2,FuncCall>("*"{B}*)?")" {
1712 DBG_CTX((stderr,
"addVariable(%s,%s)\n",
qPrint(yyextra->parmType),
qPrint(yyextra->parmName)));
1713 if (yyextra->parmType.empty())
1715 yyextra->parmType=yyextra->parmName;
1716 yyextra->parmName.clear();
1718 addVariable(yyscanner,yyextra->parmType,yyextra->parmName);
1722 yyextra->parmType = yyextra->parmName;
1723 yyextra->parmName.clear();
1724 addVariable(yyscanner,yyextra->parmType,yyextra->parmName);
1726 yyextra->theCallContext.popScope(yyextra->name, yyextra->type, yyextra->bracketCount);
1727 yyextra->inForEachExpression =
false;
1729 yyextra->code->codify(yytext);
1730 if (--yyextra->bracketCount<=0)
1732 if (yyextra->name.empty())
1742<MemberCall,MemberCall2,FuncCall>[;:] {
1744 if (yyextra->bracketCount<=0)
1751 yyextra->code->codify(yytext);
1754<CallEnd>[ \t\n]* {
codifyLines(yyscanner,yytext); }
1757 yyextra->bracketCount=0;
1758 if (*yytext==
';') yyextra->searchingForBody=
false;
1759 if (!yyextra->type.empty())
1761 DBG_CTX((stderr,
"add variable yyextra->type=%s yyextra->name=%s)\n",
qPrint(yyextra->type),
qPrint(yyextra->name)));
1762 addVariable(yyscanner,yyextra->type,yyextra->name);
1764 yyextra->parmType.clear();yyextra->parmName.clear();
1766 if (*yytext==
';' || yyextra->insideBody)
1768 if (!yyextra->insideBody)
1770 yyextra->theVarContext.popScope();
1772 yyextra->name.clear();yyextra->type.clear();
1777 yyextra->bracketCount=0;
1782 if (yyextra->lang!=SrcLangExt::CSharp || yyextra->insideBody)
1788 yyextra->code->codify(
"=>");
1792<CallEnd>{ENDQopt}/{BN}*(";"|"="|"throw"{BN}*"(") {
1797<CallEnd,OldStyleArgs>("const"|"volatile"|"sealed"|"override")*({BN}+("const"|"volatile"|"sealed"|"override"))*{BN}*"{" {
1798 if (yyextra->insideBody)
1800 yyextra->theVarContext.pushScope();
1802 addVariable(yyscanner,yyextra->parmType,yyextra->parmName);
1804 yyextra->parmType.clear();yyextra->parmName.clear();
1805 size_t index = yyextra->name.rfind(
"::");
1806 DBG_CTX((stderr,
"yyextra->name=%s\n",
qPrint(yyextra->name)));
1810 if (!yyextra->scopeName.empty()) scope.
prepend((yyextra->scopeName+
"::"));
1816 DBG_CTX((stderr,
"** scope stack push SCOPEBLOCK\n"));
1822 DBG_CTX((stderr,
"** scope stack push INNERBLOCK\n"));
1827 DBG_CTX((stderr,
"** scope stack push INNERBLOCK\n"));
1830 yytext[yyleng-1]=
'\0';
1832 if (!cv.stripWhiteSpace().empty())
1842 yyextra->code->codify(
"{");
1843 if (yyextra->searchingForBody)
1845 yyextra->searchingForBody=
false;
1846 yyextra->insideBody=
true;
1848 if (yyextra->insideBody) yyextra->bodyCurlyCount++;
1849 yyextra->type.clear(); yyextra->name.clear();
DString & prepend(const char *s)
static NamespaceDefMutable * globalScope
1854 yyextra->code->codify(yytext);
1856 yyextra->inFunctionTryBlock=
true;
1858<CallEnd>"requires" {
1860 yyextra->code->codify(yytext);
1864 if (yyextra->insideBody || !yyextra->parmType.empty())
1870 yyextra->parmName=yytext;
1872 BEGIN(OldStyleArgs);
1876 yyextra->parmName=yytext;
1880 yyextra->code->codify(yytext);
1881 addVariable(yyscanner,yyextra->parmType,yyextra->parmName);
1882 if (*yytext==
';') yyextra->parmType.clear();
1883 yyextra->parmName.clear();
1885<CallEnd,OldStyleArgs>"#" {
1887 yyextra->lastSkipCppContext = Body;
1888 yyextra->code->codify(yytext);
1893 if (!yyextra->insideBody)
1895 yyextra->theVarContext.popScope();
1897 yyextra->name.clear();yyextra->args.clear();
1898 yyextra->parmType.clear();yyextra->parmName.clear();
1902 yyextra->code->codify(yytext);
1903 yyextra->type.clear(); yyextra->name.clear();
1907 yyextra->code->codify(yytext);
1908 if (yyextra->searchingForBody)
1910 yyextra->searchingForBody=
false;
1911 yyextra->insideBody=
true;
1913 if (yyextra->insideBody) yyextra->bodyCurlyCount++;
1916 DBG_CTX((stderr,
"** scope stack push SCOPEBLOCK\n"));
1922 DBG_CTX((stderr,
"** scope stack push INNERBLOCK\n"));
1925 yyextra->type.clear(); yyextra->name.clear();
1928<SkipInits>{ID}{B}*"{" {
1930 size_t bracketPos = text.
find(
'{');
1931 size_t spacePos = text.
find(
' ');
1932 size_t len = spacePos==
DString::npos ? bracketPos : spacePos;
1934 yyextra->code->codify(yytext+len);
1942<FuncCall>{ID}/("."|"->") {
1943 yyextra->name=yytext;
1945 BEGIN( MemberCall2 );
1947<FuncCall,MemberCall2>("("{B}*("*"{B}*)+{ID}+{B}*")"{B}*)/("."|"->") {
1948 yyextra->code->codify(yytext);
1949 uint32_t s=0;
while (!
isId(yytext[s])) s++;
1950 uint32_t e=(uint32_t)yyleng-1;
while (e>1 && !
isId(yytext[e])) e--;
1951 yyextra->name=((
DString)yytext).mid(s,e-s+1);
1952 BEGIN( MemberCall2 );
1954<MemberCall2>{ID}/([ \t\n]*"(") {
1955 if (!yyextra->args.empty())
1959 yyextra->args.clear();
1962<MemberCall2>{ID}/([ \t\n]*("."|"->")) {
1964 yyextra->name=yytext;
1966 BEGIN( MemberCall2 );
1968<MemberCall2>"->"|"." {
1973 yyextra->code->codify(yytext);
1974 yyextra->memCallContext = YY_START;
1975 BEGIN( MemberCall );
1977<SkipComment>{CCS}("!"?){CCE} {
1978 yyextra->code->codify(yytext);
1980 BEGIN( yyextra->lastCContext ) ;
1982<SkipComment>{CPPC}|{CCS} {
1983 yyextra->code->codify(yytext);
1985<SkipComment>[^*\/\n]+ {
1986 yyextra->code->codify(yytext);
1988<SkipComment>[ \t]*{CCE} {
1989 yyextra->code->codify(yytext);
1991 if (yyextra->lastCContext==SkipCPP)
1995 BEGIN( yyextra->lastCContext ) ;
1997<SkipCxxComment>[^\r\n]*"\\"[\r]?\n {
2000<SkipCxxComment>[^\r\n]+ {
2001 yyextra->code->codify(yytext);
2007 BEGIN( yyextra->lastCContext ) ;
2010 yyextra->code->codify(yytext);
2012<MemberCall>[^a-z_A-Z0-9(\n] {
2013 yyextra->code->codify(yytext);
2014 yyextra->type.clear();
2015 yyextra->name.clear();
2016 BEGIN(yyextra->memCallContext);
2018<*>\n({B}*{CPPC}[!/][^\n]*\n)+ {
2019 if (YY_START==SkipCPP) REJECT;
2024 if (YY_START==SkipCxxComment)
2026 BEGIN( yyextra->lastCContext ) ;
2031 BEGIN( yyextra->lastSkipCppContext ) ;
2034<*>\n{B}*{CPPC}"@"[{}].*\n {
2039 if (YY_START==SkipCxxComment)
2041 BEGIN( yyextra->lastCContext ) ;
2044<*>\n{B}*{CCS}"@"[{}] {
2046 if (YY_START != SkipComment && YY_START != SkipCxxComment)
2048 yyextra->lastCContext = YY_START ;
2054<*>^{B}*{CPPC}"@"[{}].*\n {
2060<*>^{B}*{CCS}"@"[{}] {
2062 if (YY_START != SkipComment && YY_START != SkipCxxComment)
2064 yyextra->lastCContext = YY_START ;
2067 yyextra->code->codify(yytext);
2070<*>^{B}*{CPPC}[!/][^\n]* {
2075<*>{CPPC}[!/][^\n]* {
2076 if (YY_START==SkipComment || YY_START==SkipString) REJECT;
2081<*>\n{B}*{CCS}[!*]/{NCOMM} {
2083 if (YY_START != SkipComment && YY_START != SkipCxxComment)
2085 yyextra->lastCContext = YY_START ;
2091<*>^{B}*{CCS}"*"[*]+/[^/] {
2093 if (YY_START != SkipComment && YY_START != SkipCxxComment)
2095 yyextra->lastCContext = YY_START ;
2099 yyextra->code->codify(yytext);
#define Config_getBool(name)
2102<*>^{B}*{CCS}[!*]/{NCOMM} {
2104 if (YY_START != SkipComment && YY_START != SkipCxxComment)
2106 yyextra->lastCContext = YY_START ;
2109 yyextra->code->codify(yytext);
2112<*>{CCS}[!*]/{NCOMM} {
2113 if (YY_START==SkipString) REJECT;
2115 if (YY_START != SkipComment && YY_START != SkipCxxComment)
2117 yyextra->lastCContext = YY_START ;
2120 yyextra->code->codify(yytext);
2123<*>{CCS}("!"?){CCE} {
2124 if (YY_START==SkipString) REJECT;
2127 yyextra->code->codify(yytext);
2130<SkipComment>[^\*\n]+ {
2131 yyextra->code->codify(yytext);
2135 yyextra->code->codify(yytext);
2137 if (YY_START != SkipComment && YY_START != SkipCxxComment)
2139 yyextra->lastCContext = YY_START ;
2141 BEGIN( SkipComment ) ;
2145 yyextra->code->codify(yytext);
2146 yyextra->lastVerbStringContext=YY_START;
2147 BEGIN(SkipVerbString);
2151 yyextra->code->codify(yytext);
2152 yyextra->lastCContext = YY_START ;
2153 BEGIN( SkipCxxComment ) ;
2156 if (yytext[0]==
'(') yyextra->bracketCount++;
2157 yyextra->code->codify(yytext);
2158 yyextra->theCallContext.pushScope(yyextra->name, yyextra->type, yyextra->bracketCount);
2161 if (yytext[0]==
')') yyextra->bracketCount--;
2162 yyextra->code->codify(yytext);
2163 yyextra->theCallContext.popScope(yyextra->name, yyextra->type, yyextra->bracketCount);
2169 yyextra->code->codify(yytext);
2172 yyextra->code->codify(yytext);
2189 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
2197 DBG_CTX((stderr,
"** addVariable trying: type='%s' name='%s' currentDefinition=%s\n",
2198 qPrint(ltype),
qPrint(lname),yyextra->currentDefinition?
qPrint(yyextra->currentDefinition->name()):
"<none>"));
2199 auto it = yyextra->codeClassMap.find(ltype.
str());
2200 if (it!=yyextra->codeClassMap.end())
2203 yyextra->theVarContext.addVariable(lname,std::move(it->second));
2207 auto findVariableType = [&yyscanner,&yyg,<ype,&lname,&name](
const Definition *d) ->
const ClassDef *
2209 const ClassDef *varDef = yyextra->symbolResolver.resolveClass(d,ltype,
true);
2222 const ClassDef *varDef = findVariableType(yyextra->currentDefinition);
2223 if (varDef==
nullptr)
2225 for (
const auto &[usingName,namespaceDef] : yyextra->theUsingContext)
2227 varDef = findVariableType(namespaceDef);
2231 if (varDef==
nullptr)
2233 if (!yyextra->theVarContext.atGlobalScope())
2237 DBG_CTX((stderr,
"** addVariable: dummy context for '%s'\n",
qPrint(lname)));
2242 DBG_CTX((stderr,
"** addVariable: not adding variable!\n"));
2253 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
2254 yyextra->scopeNameLengthStack.push_back(
int(yyextra->scopeName.length()));
2255 if (yyextra->scopeName.empty() ||
leftScopeMatch(s,yyextra->scopeName))
2257 yyextra->scopeName = s;
2261 yyextra->scopeName +=
"::";
2262 yyextra->scopeName += s;
2271 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
2272 if (!yyextra->scopeNameLengthStack.empty())
2274 int length = yyextra->scopeNameLengthStack.back();
2275 yyextra->scopeNameLengthStack.pop_back();
2276 yyextra->scopeName.resize(length);
2282 DBG_CTX((stderr,
"popScope() result: '%s'\n",
qPrint(yyextra->scopeName)));
2287 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
2290 if (yyextra->searchCtx)
2311 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
2315 size_t ts=n.
find(
'<');
2316 size_t te=n.
rfind(
'>');
2317 DBG_CTX((stderr,
"ts=%zu te=%zu\n",ts,te));
2323 while (!yyextra->scopeNameLengthStack.empty())
2327 yyextra->scopeName.clear();
2335 DBG_CTX((stderr,
"--->New class scope '%s'\n",
qPrint(yyextra->scopeName)));
2340 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
2341 while (!yyextra->foldStack.empty())
2343 const Definition *dd = yyextra->foldStack.back();
2346 yyextra->code->endFold();
2348 yyextra->foldStack.pop_back();
2363 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
2372 if (endLine!=-1 && startLine!=endLine &&
2380 (yyextra->foldStack.empty() || yyextra->foldStack.back()->getEndBodyLine()!=startLine))
2388 yyextra->code->startFold(yyextra->yyLineNr,
"",
"");
2392 yyextra->code->startFold(yyextra->yyLineNr,
"{",
"}");
2396 yyextra->code->startFold(yyextra->yyLineNr,
"{",
"};");
2401 yyextra->code->startFold(yyextra->yyLineNr,
"{",
"};");
2405 yyextra->code->startFold(yyextra->yyLineNr,
"{",
"}");
2407 yyextra->foldStack.push_back(d);
2419 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
2421 if (yyextra->sourceFileDef && yyextra->lineNumbers)
2427 const Definition *d = yyextra->sourceFileDef->getSourceDefinition(yyextra->yyLineNr);
2429 DBG_CTX((stderr,
"%s:startCodeLine(%d)=%p\n",
qPrint(yyextra->sourceFileDef->name()),yyextra->yyLineNr,(
void*)d));
2430 if (!yyextra->includeCodeFragment && d)
2432 yyextra->currentDefinition = d;
2433 yyextra->currentMemberDef = yyextra->sourceFileDef->getSourceMember(yyextra->yyLineNr);
2434 yyextra->insideBody =
false;
2435 yyextra->searchingForBody =
true;
2437 yyextra->type.
clear();
2438 yyextra->name.clear();
2439 yyextra->args.clear();
2440 yyextra->parmType.clear();
2441 yyextra->parmName.clear();
2442 DBG_CTX((stderr,
"Real scope: '%s'\n",
qPrint(yyextra->realScope)));
2443 yyextra->bodyCurlyCount = 0;
2445 lineAnchor.
sprintf(
"l%05d",yyextra->yyLineNr);
2446 if (yyextra->currentMemberDef)
2449 yyextra->code->writeLineNumber(yyextra->currentMemberDef->getReference(),
2450 yyextra->currentMemberDef->getOutputFileBase(),
2451 yyextra->currentMemberDef->anchor(),
2452 yyextra->yyLineNr,!yyextra->includeCodeFragment);
2460 DString(),yyextra->yyLineNr,!yyextra->includeCodeFragment);
2472 !yyextra->includeCodeFragment);
2475 DBG_CTX((stderr,
"startCodeLine(%d)\n",yyextra->yyLineNr));
2476 yyextra->code->startCodeLine(yyextra->yyLineNr);
2477 yyextra->insideCodeLine =
true;
2478 if (yyextra->currentFontClass)
2480 yyextra->code->startFontClass(yyextra->currentFontClass);
2488 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
2489 DBG_CTX((stderr,
"endCodeLine(%d)\n",yyextra->yyLineNr));
2491 yyextra->code->endCodeLine();
2492 yyextra->insideCodeLine =
false;
2497 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
2498 const char * fc = yyextra->currentFontClass;
2499 if (yyextra->insideCodeLine)
2503 if (yyextra->yyLineNr<yyextra->inputLines)
2505 yyextra->currentFontClass = fc;
2515 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
2516 DBG_CTX((stderr,
"codifyLines(%d,\"%s\")\n",yyextra->yyLineNr,
qPrint(text)));
2517 if (text.
empty())
return;
2518 const char *p=text.
data(),*sp=p;
2524 while ((c=*p++) && c!=
'\n');
2527 yyextra->yyLineNr++;
2528 size_t l =
static_cast<size_t>(p-sp-1);
2529 yyextra->code->codify(
DString(sp,l));
2534 yyextra->code->codify(sp);
2543 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
2544 if (yyextra->currentMemberDef && yyextra->currentMemberDef->isFunction())
2562 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
2564 yyextra->tooltipManager.addTooltip(d);
2569 if (!sourceTooltips)
2574 const char *p=text.
data();
2579 while ((c=*p++) && c!=
'\n') { }
2582 yyextra->yyLineNr++;
2598 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
2599 if (yyextra->name==
"const") { yyextra->name.clear();
return; }
2600 if (!yyextra->type.empty()) yyextra->type +=
' ' ;
2601 yyextra->type += yyextra->name ;
2602 yyextra->name.clear() ;
2603 if (!yyextra->type.empty()) yyextra->type +=
' ' ;
2604 yyextra->type += yyextra->args ;
2605 yyextra->args.clear() ;
2610 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
2611 if (yyextra->parmName==
"const") { yyextra->parmName.clear();
return; }
2612 if (!yyextra->parmType.empty()) yyextra->parmType +=
' ' ;
2613 yyextra->parmType += yyextra->parmName ;
2614 yyextra->parmName.clear() ;
2620 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
2621 if (yyextra->sourceFileDef && !name.
empty())
2626 yyextra->theUsingContext.emplace(name.
str(),nd);
2633 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
2636 yyextra->parmName = a.name;
2637 yyextra->parmType = a.type;
2638 size_t i = yyextra->parmType.find(
'*');
2639 if (i!=
DString::npos) yyextra->parmType = yyextra->parmType.left(i);
2640 i = yyextra->parmType.find(
'&');
2641 if (i!=
DString::npos) yyextra->parmType = yyextra->parmType.left(i);
2642 yyextra->parmType.stripPrefix(
"const ");
2643 yyextra->parmType=yyextra->parmType.stripWhiteSpace();
2644 addVariable(yyscanner,yyextra->parmType,yyextra->parmName);
2650 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
2651 DBG_CTX((stderr,
"stripClassName(scope=%s,type=%s) scopeName=%s\n",
2659 DString clName=className+templSpec;
2661 if (!yyextra->scopeName.empty())
2663 cd=yyextra->symbolResolver.resolveClass(d,yyextra->scopeName+
"::"+clName,
true);
2667 cd=yyextra->symbolResolver.resolveClass(d,clName,
true);
2669 DBG_CTX((stderr,
"stripClass trying '%s' = %p\n",
qPrint(clName),(
void*)cd));
2681 if (name.
empty())
return nullptr;
2682 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
2683 DBG_CTX((stderr,
"setCallContextForVar(%s) yyextra->scopeName=%s\n",
qPrint(name),
qPrint(yyextra->scopeName)));
2685 size_t scopeEnd = name.
rfind(
"::");
2692 if (mcd && !locName.
empty())
2705 if (mnd && !locName.
empty())
2721 DBG_CTX((stderr,
"local variable?\n"));
2725 yyextra->theCallContext.setScope(*mcv);
2730 DBG_CTX((stderr,
"class member? scope=%s\n",
qPrint(yyextra->scopeName)));
2740 if (yyextra->scopeStack.empty() || yyextra->scopeStack.top()!=
CLASSBLOCK)
2757 const std::unique_ptr<MemberDef> &md=mn->
front();
2758 if (!md->isStatic() || md->getBodyDef()==yyextra->sourceFileDef)
2765 else if (mn->
size()>1)
2767 for (
const auto &md : *mn)
2776 if (!md->isStatic() || md->getBodyDef()==yyextra->sourceFileDef)
2779 DBG_CTX((stderr,
"returning member %s in source file %s\n",
qPrint(md->name()),
qPrint(yyextra->sourceFileDef->name())));
2791 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
2792 const Definition *d = yyextra->theCallContext.getScope().globalDef();
2815 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
2816 DBG_CTX((stderr,
"getLinkInScope: trying '%s'::'%s' varOnly=%d\n",
qPrint(c),
qPrint(m),varOnly));
2821 DBG_CTX((stderr,
"scopeNameLengthStack.size()=%zu\n",yyextra->scopeNameLengthStack.size()));
2822 if (!result.
found && !yyextra->scopeNameLengthStack.empty() && c==yyextra->scopeName)
2824 DString localName = yyextra->scopeName.
mid(yyextra->scopeNameLengthStack[0]+2);
2825 auto it = yyextra->codeClassMap.
find(localName.
str());
2826 if (it!=yyextra->codeClassMap.end())
2833 DBG_CTX((stderr,
"trying lookup via base class %s\n",
qPrint(bcName)));
2836 if (result.
found)
break;
2846 if (yyextra->exampleBlock)
2850 anchor.
sprintf(
"a%d",yyextra->anchorCount);
2852 qPrint(yyextra->exampleFile)));
2854 if (mdm && mdm->
addExample(anchor,yyextra->exampleName,yyextra->exampleFile))
2857 yyextra->anchorCount++;
2871 DBG_CTX((stderr,
"yyextra->currentDefinition=%p yyextra->currentMemberDef=%p yyextra->insideBody=%d\n",
2872 (
void*)yyextra->currentDefinition,(
void*)yyextra->currentMemberDef,yyextra->insideBody));
2874 if (yyextra->currentDefinition && yyextra->currentMemberDef &&
2875 yyextra->insideBody && yyextra->collectXRefs)
2897 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
2898 DBG_CTX((stderr,
"getLink(%s,%s) yyextra->curClassName=%s\n",
2904 if (!yyextra->curClassName.empty())
2907 c.
prepend(yyextra->curClassName);
2921 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
2923 if (!scopeName.
empty() && scopeName[0]==
'~')
2925 scopeName=scopeName.
mid(1);
2927 if (scopeName.
empty())
2929 yyextra->code->codify(
"~");
2932 if (yyextra->insideProtocolList)
2936 if (yyextra->lang==SrcLangExt::PHP)
2940 else if (yyextra->lang==SrcLangExt::CSharp || yyextra->lang==SrcLangExt::Java)
2944 if (yyextra->currentDefinition==
nullptr && !yyextra->scopeName.empty())
2946 scopeName = yyextra->scopeName+
"::"+scopeName;
2952 DBG_CTX((stderr,
"generateClassOrGlobalLink(name=%s) yyextra->scopeName=%s scopeName=%s\n",
qPrint(scName),
qPrint(yyextra->scopeName),
qPrint(scopeName)));
2953 if (!yyextra->isPrefixedWithThis || (lcd=yyextra->theVarContext.findVariable(scopeName))==
nullptr)
2958 auto checkForSymbol = [&yyg,&bareName,&scopeName](
const Definition *
parent,
2961 sym_ = yyextra->symbolResolver.resolveSymbol(
parent,scopeName,
DString(),
false,
true);
2962 DBG_CTX((stderr,
"non-local variable name=%s sym=%s!\n",
2963 qPrint(scopeName),sym_?
qPrint(sym_->name()):
"<none>"));
2964 if (sym_==
nullptr && !bareName.
empty())
2967 if (bareName!=scopeName)
2969 sym_ = yyextra->symbolResolver.resolveSymbol(
parent,bareName,
DString(),
false,
true);
2973 const Definition *d = yyextra->currentDefinition;
2974 DBG_CTX((stderr,
"d=%s yyextra->sourceFileDef=%s\n",d?
qPrint(d->
name()):
"<none>",yyextra->sourceFileDef?
qPrint(yyextra->sourceFileDef->name()):
"<none>"));
2975 checkForSymbol(d,sym);
2984 checkForSymbol(nd,sym);
2992 for (
const auto &[usingName,namespaceDef] : yyextra->theUsingContext)
2994 checkForSymbol(namespaceDef,sym);
3016 DBG_CTX((stderr,
"is found as a type sym=%s nd=%s\n",
3021 if (
getLink(yyscanner,yyextra->scopeName,scName,ol,scName,varOnly))
3029 DBG_CTX((stderr,
"local variable!\n"));
3033 yyextra->theCallContext.setScope(*lcd);
3044 DBG_CTX((stderr,
"is a local variable sym=%p!\n",(
void*)sym));
3046 yyextra->isPrefixedWithThis =
false;
3051 if (yyextra->exampleBlock)
3055 anchor.
sprintf(
"_a%d",yyextra->anchorCount);
3056 DBG_CTX((stderr,
"addExampleClass(%s,%s,%s)\n",
qPrint(anchor),
qPrint(yyextra->exampleName),
3057 qPrint(yyextra->exampleFile)));
3061 if (cdm && cdm->
addExample(anchor,yyextra->exampleName,yyextra->exampleFile))
3064 yyextra->anchorCount++;
3070 if (mdm && mdm->
addExample(anchor,yyextra->exampleName,yyextra->exampleFile))
3073 yyextra->anchorCount++;
3086 yyextra->currentMemberDef && yyextra->collectXRefs)
3100 DBG_CTX((stderr,
"class %s not linkable! cd=%p typeOnly=%d\n",
qPrint(scName),(
void*)sym,typeOnly));
3101 if (!isLocal && (md || (!sym && !typeOnly)))
3106 DBG_CTX((stderr,
"setCallContextForVar(%s) md=%p yyextra->currentDefinition=%s\n",
qPrint(scName),(
void*)md,yyextra->currentDefinition ?
qPrint(yyextra->currentDefinition->name()) :
"<none>"));
3107 if (md && yyextra->currentDefinition)
3109 DBG_CTX((stderr,
"%s accessible from %s? %d md->getOuterScope=%s\n",
3110 qPrint(md->name()),
qPrint(yyextra->currentDefinition->name()),
3111 yyextra->symbolResolver.isAccessibleFrom(yyextra->currentDefinition,md),
3112 qPrint(md->getOuterScope()->name())));
3115 if (md && yyextra->currentDefinition &&
3116 yyextra->symbolResolver.isAccessibleFrom(yyextra->currentDefinition,md)==-1)
3123 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()));
3124 if (md->isLinkable())
3128 if (yyextra->currentMemberDef && yyextra->collectXRefs)
3138 DBG_CTX((stderr,
"not found!\n"));
3149 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
3153 DBG_CTX((stderr,
"type='%s' args='%s' class=%s\n",
3157 if (yyextra->exampleBlock)
3161 anchor.
sprintf(
"a%d",yyextra->anchorCount);
3163 qPrint(yyextra->exampleFile)));
3165 if (mdm && mdm->
addExample(anchor,yyextra->exampleName,yyextra->exampleFile))
3168 yyextra->anchorCount++;
3182 DBG_CTX((stderr,
"yyextra->currentDefinition=%p yyextra->currentMemberDef=%p xmd=%p yyextra->insideBody=%d\n",
3183 (
void*)yyextra->currentDefinition,(
void*)yyextra->currentMemberDef,(
void*)xmd,yyextra->insideBody));
3185 if (xmd->templateMaster()) xmd = xmd->templateMaster();
3187 if (xmd->isLinkable())
3190 if (yyextra->currentDefinition && yyextra->currentMemberDef &&
3191 yyextra->insideBody && yyextra->collectXRefs)
3211 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
3216 DBG_CTX((stderr,
"generateClassMemberLink(class=%s,member=%s)=%p\n",
qPrint(def->
name()),
qPrint(memName),(
void*)xmd));
3254 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
3255 DBG_CTX((stderr,
"generateMemberLink(object=%s,mem=%s) classScope=%s\n",
3258 if (varName.
empty())
return;
3266 DBG_CTX((stderr,
"Class found!\n"));
3269 DBG_CTX((stderr,
"Found result!\n"));
3276 if (
getLink(yyscanner,bcName,memName,ol))
3278 DBG_CTX((stderr,
"Found result!\n"));
3287 const ClassDef *vcd = yyextra->symbolResolver.resolveClass(yyextra->currentDefinition,yyextra->scopeName,
true);
3290 DBG_CTX((stderr,
"Found class %s for variable '%s'\n",
qPrint(yyextra->scopeName),
qPrint(varName)));
3303 for (
const auto &vmd : *vmn)
3305 if (vmd->getClassDef()==jcd)
3307 DBG_CTX((stderr,
"Found variable type=%s\n",
qPrint(vmd->typeString())));
3320 DBG_CTX((stderr,
"There is a variable with name '%s'\n",
qPrint(varName)));
3321 for (
const auto &vmd : *vmn)
3323 if (vmd->getClassDef()==vcd)
3325 DBG_CTX((stderr,
"Found variable type=%s\n",
qPrint(vmd->typeString())));
3344 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
3347 DBG_CTX((stderr,
"generatePHPVariableLink(%s) name=%s scope=%s\n",varName,
qPrint(name),
qPrint(yyextra->scopeName)));
3348 if (!
getLink(yyscanner,yyextra->scopeName,name,ol,varName))
3356 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
3358 DString locScope=yyextra->scopeName;
3360 if (yyextra->lang==SrcLangExt::PHP && locFunc.
startsWith(
"self::")) locFunc=locFunc.
mid(4);
3362 DString funcWithScope=locFunc;
3363 DString funcWithFullScope=locFunc;
3367 size_t i=locFunc.
rfind(
"::");
3368 if (yyextra->currentMemberDef && yyextra->currentMemberDef->resolveAlias()->getClassDef() &&
3369 funcName==yyextra->currentMemberDef->localName() &&
3370 yyextra->currentMemberDef->getDefLine()==yyextra->yyLineNr &&
3384 i=locFunc.
rfind(
".");
3389 i=locFunc.
rfind(
"\\");
3394 funcScope=locFunc.
left(i);
3396 size_t ts=locScope.
find(
'<');
3397 size_t te=locScope.
rfind(
'>');
3398 DBG_CTX((stderr,
"ts=%zu te=%zu\n",ts,te));
3402 locScope=locScope.
left(ts)+locScope.
mid(te+1);
3404 ts=funcScope.
find(
'<');
3405 te=funcScope.
rfind(
'>');
3406 DBG_CTX((stderr,
"ts=%zu te=%zu\n",ts,te));
3410 funcScope=funcScope.
left(ts)+funcScope.
mid(te+1);
3412 if (!funcScope.
empty())
3414 funcWithScope = funcScope+
"::"+locFunc;
3415 if (!locScope.
empty())
3417 fullScope=locScope+
"::"+funcScope;
3420 if (!locScope.
empty())
3422 funcWithFullScope = locScope+
"::"+funcWithScope;
3426 if (!fullScope.
empty())
3428 auto it = yyextra->codeClassMap.find(fullScope.
str());
3429 if (it!=yyextra->codeClassMap.end())
3436 if (
getLink(yyscanner,bcName,locFunc,ol,funcName))
3445 if (!locScope.
empty() && fullScope!=locScope)
3447 auto it = yyextra->codeClassMap.find(locScope.
str());
3448 if (it!=yyextra->codeClassMap.end())
3455 if (
getLink(yyscanner,bcName,funcWithScope,ol,funcName))
3463 if (!
getLink(yyscanner,locScope,funcWithScope,ol,funcName))
3474 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
3475 const char *p=yyextra->inputString;
3481 if (c==
'\n') count++;
3483 if (p>yyextra->inputString && *(p-1)!=
'\n')
3492 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
3493 if (yyextra->currentFontClass)
3495 yyextra->code->endFontClass();
3496 yyextra->currentFontClass=
nullptr;
3498 if (specialComment && yyextra->insideSpecialComment)
3500 yyextra->code->endSpecialComment();
3501 yyextra->insideSpecialComment =
false;
3507 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
3511 yyextra->code->startSpecialComment();
3512 yyextra->insideSpecialComment =
true;
3514 yyextra->code->startFontClass(s);
3515 yyextra->currentFontClass=s;
3523 if (ctx==
nullptr)
return;
3524 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
3528 DBG_CTX((stderr,
"writeObjCMethodCall(%s) obj=%s method=%s\n",
3537 DBG_CTX((stderr,
" object is local variable\n"));
3545 DBG_CTX((stderr,
" class=%p method=%p\n",(
void*)cd,(
void*)ctx->
method));
3556 char skipChar =
' ';
3581 yyextra->code->codify(
"$");
3589 while (nc!=0 && isdigit(nc)) { refIdStr+=nc; nc=*p++; }
3591 int refId=refIdStr.
toInt();
3592 auto it = yyextra->nameMap.find(refId);
3593 if (it!=yyextra->nameMap.end())
3599 if (yyextra->currentMemberDef && yyextra->collectXRefs)
3611 DBG_CTX((stderr,
"Invalid name: id=%d\n",refId));
3618 while (nc!=0 && isdigit(nc)) { refIdStr+=nc; nc=*p++; }
3620 int refId=refIdStr.
toInt();
3621 auto it = yyextra->objectMap.find(refId);
3622 if (it!=yyextra->objectMap.end())
3627 if (yyextra->currentDefinition &&
3644 else if (
object==
"super")
3646 if (yyextra->currentDefinition &&
3673 if (yyextra->currentMemberDef && yyextra->collectXRefs)
3686 size_t dotPos =
object.find(
'.',pp);
3687 size_t len =
object.length();
3689 const Definition *scope = yyextra->currentDefinition;
3696 if (fragmentStripped==
"self")
3709 const Definition *symbol = yyextra->symbolResolver.resolveSymbol(scope,fragmentStripped,
DString(),
false,
true);
3715 ctx->
method = yyextra->symbolResolver.getTypedef();
3739 dotPos=
object.find(
'.',pp);
3749 else if (ctx->
method==
nullptr)
3752 DBG_CTX((stderr,
"yyextra->currentDefinition=%p\n",(
void*)yyextra->currentDefinition));
3753 if (yyextra->currentDefinition &&
3774 DBG_CTX((stderr,
"Invalid object: id=%d\n",refId));
3781 while (nc!=0 && isdigit(nc)) { refIdStr+=nc; nc=*p++; }
3783 int refId=refIdStr.
toInt();
3784 auto it = yyextra->contextMap.find(refId);
3785 if (it!=yyextra->contextMap.end())
3800 if (mn && mn->
size()==1)
3818 DBG_CTX((stderr,
"Invalid context: id=%d\n",refId));
3825 while (nc!=0 && isdigit(nc)) { refIdStr+=nc; nc=*p++; }
3827 int refId=refIdStr.
toInt();
3828 auto it = yyextra->wordMap.find(refId);
3829 if (it!=yyextra->wordMap.end())
3832 bool isKeyword = word==
"self";
3848 while (nc!=0 && isdigit(nc)) { refIdStr+=nc; nc=*p++; }
3850 int refId=refIdStr.
toInt();
3851 auto it = yyextra->commentMap.find(refId);
3852 if (it!=yyextra->commentMap.end())
3866 else if (c==
'\'' || c ==
'"')
3883 DBG_CTX((stderr,
"}=(type='%s',name='%s')",
3893 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
3895 result.
sprintf(
"$n%d",yyextra->currentNameId);
3896 yyextra->nameMap.emplace(yyextra->currentNameId,s);
3897 yyextra->currentNameId++;
3903 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
3905 result.
sprintf(
"$o%d",yyextra->currentObjId);
3906 yyextra->objectMap.emplace(yyextra->currentObjId,s);
3907 yyextra->currentObjId++;
3913 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
3915 result.
sprintf(
"$w%d",yyextra->currentWordId);
3916 yyextra->wordMap.emplace(yyextra->currentWordId,s);
3917 yyextra->currentWordId++;
3923 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
3925 result.
sprintf(
"$d%d",yyextra->currentCommentId);
3926 yyextra->commentMap.emplace(yyextra->currentCommentId,s);
3927 yyextra->currentCommentId++;
3933 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
3934 static const std::unordered_set<std::string> non_cpp_keywords = {
3935 "__assume",
"__super",
"abstract",
"function",
3936 "gcnew",
"gcroot",
"generic",
"get",
3937 "internal",
"null",
"pin_ptr",
"raise",
3938 "remove",
"self",
"set",
"transient",
3941 static const std::unordered_set<std::string> non_java_keywords = {
3942 "alignas",
"alignof",
"and",
"and_eq",
"asm",
3943 "atomic_cancel",
"atomic_commit",
"atomic_noexcept",
"auto",
"bitand",
3944 "bitor",
"bool",
"char8_t",
"char16_t",
"char32_t",
3945 "compl",
"concept",
"consteval",
"constexpr",
"constinit",
3946 "const_cast",
"co_await",
"co_return",
"co_yield",
"decltype",
3947 "delete",
"dynamic_cast",
"explicit",
"export",
"extern",
3948 "friend",
"inline",
"mutable",
"namespace",
"noexcept",
3949 "not",
"not_eq",
"nullptr",
"operator",
"or",
3950 "or_eq",
"reflexpr",
"register",
"reinterpret_cast",
"requires",
3951 "signed",
"sizeof",
"static_assert",
"_Static_assert",
"static_cast",
"struct",
3952 "template",
"thread_local",
"typedef",
"typeid",
"typename",
3953 "union",
"unsigned",
"using",
"virtual",
"wchar_t",
3954 "xor",
"xor_eq",
"override",
"sealed"
3956 bool retval =
false;
3957 switch (yyextra->lang)
3959 case SrcLangExt::Cpp:
3960 retval = (non_cpp_keywords.find(keyword) != non_cpp_keywords.end());
3962 case SrcLangExt::Java:
3963 retval = (non_java_keywords.find(keyword) != non_java_keywords.end());
3975 size_t i=s.
find(
'<');
3978 return kw==
"const_cast" || kw==
"static_cast" || kw==
"dynamic_cast" || kw==
"reinterpret_cast";
3983 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
3984 yy_size_t inputPosition = yyextra->inputPosition;
3985 const char *s = yyextra->inputString + inputPosition;
3987 while( c < max_size && *s )
3992 yyextra->inputPosition += c;
3999 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
4000 if (yyextra->currentCtx)
4002 yyextra->currentCtx->format+=
DString().
sprintf(
"$c%d",yyextra->currentCtxId);
4003 if (yyextra->braceCount==0 && YY_START==ObjCCall)
4005 yyextra->currentCtx->objectTypeOrName=yyextra->currentCtx->format.mid(1);
4006 DBG_CTX((stderr,
"new type=%s\n",
qPrint(yyextra->currentCtx->objectTypeOrName)));
4008 yyextra->contextStack.push(yyextra->currentCtx);
4012 DBG_CTX((stderr,
"Trying to save NULL context!\n"));
4014 auto newCtx = std::make_unique<ObjCCallCtx>();
4015 newCtx->id = yyextra->currentCtxId;
4016 newCtx->lexState = YY_START;
4017 newCtx->braceCount = yyextra->braceCount;
4018 newCtx->objectType =
nullptr;
4019 newCtx->objectVar =
nullptr;
4020 newCtx->method =
nullptr;
4021 DBG_CTX((stderr,
"save state=%d\n",YY_START));
4022 yyextra->currentCtx = newCtx.get();
4023 yyextra->contextMap.emplace(yyextra->currentCtxId,std::move(newCtx));
4024 yyextra->braceCount = 0;
4025 yyextra->currentCtxId++;
4030 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
4031 DBG_CTX((stderr,
"restore state=%d->%d\n",YY_START,yyextra->currentCtx->lexState));
4032 BEGIN(yyextra->currentCtx->lexState);
4033 yyextra->braceCount = yyextra->currentCtx->braceCount;
4034 if (!yyextra->contextStack.empty())
4036 yyextra->currentCtx = yyextra->contextStack.top();
4037 yyextra->contextStack.pop();
4041 yyextra->currentCtx =
nullptr;
4042 DBG_CTX((stderr,
"Trying to pop context while yyextra->contextStack is empty!\n"));
4054 codeYYlex_init_extra(&
p->state,&
p->yyscanner);
4063 codeYYlex_destroy(
p->yyscanner);
4068 struct yyguts_t *yyg = (
struct yyguts_t*)
p->yyscanner;
4069 DBG_CTX((stderr,
"***CodeParser::reset()\n"));
4070 yyextra->theVarContext.clear();
4071 while (!yyextra->scopeNameLengthStack.empty()) yyextra->scopeNameLengthStack.pop_back();
4072 yyextra->codeClassMap.clear();
4073 yyextra->curClassBases.clear();
4074 yyextra->anchorCount = 0;
4075 yyextra->insideCodeLine =
false;
4080 struct yyguts_t *yyg = (
struct yyguts_t*)
p->yyscanner;
4081 yyextra->insideCodeLine = inp;
4086 struct yyguts_t *yyg = (
struct yyguts_t*)
p->yyscanner;
4087 return yyextra->insideCodeLine;
4094 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
4095 DBG_CTX((stderr,
"***parseCode() exBlock=%d exName=%s fd=%p scopeName=%s searchCtx=%s\n",
4099 if (s.
empty())
return;
4105 yyextra->code = &od;
4106 yyextra->inputString = s.
data();
4109 yyextra->inputPosition = 0;
4110 codeYYrestart(
nullptr,yyscanner);
4111 yyextra->currentFontClass =
nullptr;
4112 yyextra->searchCtx = options.
searchCtx();
4114 yyextra->inFunctionTryBlock =
false;
4115 yyextra->symbolResolver.setFileScope(options.
fileDef());
4116 yyextra->foldStack.clear();
4117 yyextra->insideSpecialComment =
false;
4120 yyextra->curlyCount = 0;
4121 yyextra->bodyCurlyCount = 0;
4122 yyextra->bracketCount = 0;
4123 yyextra->sharpCount = 0;
4124 yyextra->insideTemplate =
false;
4125 yyextra->theCallContext.clear();
4126 while (!yyextra->scopeStack.empty()) yyextra->scopeStack.pop();
4127 yyextra->scopeName = scopeName;
4129 yyextra->exampleBlock = options.
isExample();
4131 yyextra->sourceFileDef = options.
fileDef();
4133 if (options.
fileDef()==
nullptr)
4137 yyextra->sourceFileDef = yyextra->exampleFileDef.get();
4139 yyextra->lang = lang;
4140 yyextra->insideObjC = lang==SrcLangExt::ObjC;
4141 if (yyextra->sourceFileDef)
4146 yyextra->currentMemberDef =
nullptr;
4147 yyextra->searchingForBody = options.
isExample();
4148 yyextra->insideBody =
false;
4149 yyextra->bracketCount = 0;
4150 if (!yyextra->exampleName.empty())
4152 yyextra->exampleFile =
convertNameToFile(yyextra->exampleName+
"-example",
false,
true);
4153 DBG_CTX((stderr,
"yyextra->exampleFile=%s\n",
qPrint(yyextra->exampleFile)));
4157 if (!yyextra->insideCodeLine)
4161 yyextra->type.clear();
4162 yyextra->name.clear();
4163 yyextra->args.clear();
4164 yyextra->parmName.clear();
4165 yyextra->parmType.clear();
4168 codeYYlex(yyscanner);
4169 yyextra->lexInit=
true;
4170 if (yyextra->insideCodeLine)
4176 while (!yyextra->foldStack.empty())
4178 yyextra->code->endFold();
4179 yyextra->foldStack.pop_back();
4182 if (yyextra->exampleFileDef)
4185 yyextra->exampleFileDef.reset();
4186 yyextra->sourceFileDef=
nullptr;
4189 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)