15%option never-interactive
16%option prefix="codeYY"
18%option extra-type="struct codeYY_state *"
22#define YY_TYPEDEF_YY_SCANNER_T
23#define yyguts_t codeYYguts_t
41#include <unordered_map>
42#include <unordered_set>
71#define DBG_CTX(x) do { } while(0)
73#define YY_NO_UNISTD_H 1
177 std::unordered_map< int,std::unique_ptr<ObjCCallCtx> >
contextMap;
236 bool typeOnly=
false,
bool varOnly=
false);
258#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 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 const MemberDef * setCallContextForVar(yyscan_t yyscanner, const DString &name)
static void generateFunctionLink(yyscan_t yyscanner, OutputCodeList &ol, const DString &funcName)
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 const ClassDef * stripClassName(yyscan_t yyscanner, const DString &s, const Definition *d)
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.
269ID [$a-z_A-Z\x80-\xFF][$a-z_A-Z0-9\x80-\xFF]*
271SCOPENAME ("::"{BN}*)?({ID}{BN}*{SEP}{BN}*)*("~"{BN}*)?{ID}
272TEMPLIST "<"[^\"\}\{\(\)\/\n>]*">"
273SCOPETNAME (((({ID}{TEMPLIST}?){BN}*)?{SEP}{BN}*)*)((~{BN}*)?{ID})
274SCOPEPREFIX ({ID}{TEMPLIST}?{BN}*{SEP}{BN}*)+
275KEYWORD_OBJC ("@public"|"@private"|"@protected"|"@class"|"@implementation"|"@interface"|"@end"|"@selector"|"@protocol"|"@optional"|"@required"|"@throw"|"@synthesize"|"@property")
277KEYWORD ("asm"|"__assume"|"auto"|"class"|"const"|"delete"|"enum"|"explicit"|"extern"|"false"|"friend"|"gcnew"|"gcroot"|"set"|"get"|"inline"|"internal"|"mutable"|"namespace"|"new"|"null"|"nullptr"|"override"|"operator"|"pin_ptr"|"private"|"protected"|"public"|"raise"|"record"|"register"|"remove"|"self"|"sizeof"|"static"|"struct"|"__super"|"function"|"template"|"generic"|"this"|"true"|"typedef"|"typeid"|"typename"|"union"|"using"|"virtual"|"volatile"|"abstract"|"sealed"|"final"|"import"|"synchronized"|"transient"|"alignas"|"alignof"|"concept"|"requires"|"decltype"|{KEYWORD_OBJC}|"constexpr"|"consteval"|"constinit"|"co_await"|"co_return"|"co_yield"|"static_assert"|"_Static_assert"|"noexcept"|"thread_local"|"enum"{B}+("class"|"struct"))
278FLOWKW ("break"|"catch"|"continue"|"default"|"do"|"else"|"finally"|"return"|"switch"|"throw"|"throws"|"@catch"|"@finally")
279FLOWCONDITION ("case"|"for"|"foreach"|"for each"|"goto"|"if"|"try"|"while"|"@try")
280TYPEKW ("bool"|"byte"|"char"|"char8_t"|"char16_t"|"char32_t"|"double"|"float"|"int"|"long"|"object"|"short"|"signed"|"unsigned"|"void"|"wchar_t"|"size_t"|"boolean"|"id"|"SEL"|"string"|"nullptr")
281TYPEKWSL ("LocalObject"|"Object"|"Value")
282CASTKW ("const_cast"|"dynamic_cast"|"reinterpret_cast"|"static_cast")
283CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^' \\\n]{1,4}"'"))
284ARITHOP "+"|"-"|"/"|"*"|"%"|"--"|"++"
285ASSIGNOP "="|"*="|"/="|"%="|"+="|"-="|"<<="|">>="|"&="|"^="|"|="
286LOGICOP "=="|"!="|">"|"<"|">="|"<="|"&&"|"||"|"!"|"<=>"
287BITOP "&"|"|"|"^"|"<<"|">>"|"~"
288OPERATOR {ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}
289RAWBEGIN (u|U|L|u8)?R\"[^ \t\(\)\\]{0,16}"("
290RAWEND ")"[^ \t\(\)\\]{0,16}\"
291MODULE_ID ({ID}".")*{ID}
297DECIMAL_INTEGER [1-9][0-9']*[0-9]?[uU]?[lL]?[lL]?
298HEXADECIMAL_INTEGER "0"[xX][0-9a-zA-Z']+[0-9a-zA-Z]?
299OCTAL_INTEGER "0"[0-7][0-7']+[0-7]?
300BINARY_INTEGER "0"[bB][01][01']*[01]?
301INTEGER_NUMBER {DECIMAL_INTEGER}|{HEXADECIMAL_INTEGER}|{OCTAL_INTEGER}|{BINARY_INTEGER}
305DIGIT_SEQ [0-9][0-9']*[0-9]?
306FRAC_CONST {DIGIT_SEQ}"."|{DIGIT_SEQ}?"."{DIGIT_SEQ}
307FP_EXP [eE][+-]?{DIGIT_SEQ}
308DEC_FP1 {FRAC_CONST}{FP_EXP}?{FP_SUF}?
309DEC_FP2 {DIGIT_SEQ}{FP_EXP}{FP_SUF}
311HEX_DIGIT_SEQ [0-9a-fA-F][0-9a-fA-F']*[0-9a-fA-F]?
312HEX_FRAC_CONST {HEX_DIGIT_SEQ}"."|{HEX_DIGIT_SEQ}?"."{HEX_DIGIT_SEQ}
313BIN_EXP [pP][+-]?{DIGIT_SEQ}
314HEX_FP1 "0"[xX]{HEX_FRAC_CONST}{BIN_EXP}{FP_SUF}?
315HEX_FP2 "0"[xX]{HEX_DIGIT_SEQ}{BIN_EXP}{FP_SUF}?
317FLOAT_DECIMAL {DEC_FP1}|{DEC_FP2}
318FLOAT_HEXADECIMAL {HEX_FP1}|{HEX_FP2}
319FLOAT_NUMBER {FLOAT_DECIMAL}|{FLOAT_HEXADECIMAL}
320NUMBER {INTEGER_NUMBER}|{FLOAT_NUMBER}
333ENDQopt ("const"|"volatile"|"sealed"|"override")({BN}+("const"|"volatile"|"sealed"|"override"))*
354%x CppCliTypeModifierFollowup
379<Body>^([ \t]*"#"[ \t]*("include"|"import")[ \t]*)("<"|"\"") {
381 yyextra->code->codify(yytext);
382 BEGIN( ReadInclude );
384<Body>("@interface"|"@implementation"|"@protocol")[ \t\n]+ {
385 yyextra->insideObjC=
true;
389 if (!yyextra->insideTemplate)
392<Body>(("public"|"private"){B}+)?("ref"|"value"|"interface"|"enum"){B}+("class"|"struct") {
393 if (yyextra->insideTemplate) REJECT;
399<Body>"property"|"event"/{BN}* {
400 if (yyextra->insideTemplate) REJECT;
405<Body>("partial"{B}+)?("class"|"struct"|"union"|"record"|"namespace"|"interface"){B}+ {
409 if (!yyextra->insideTemplate)
412<Body>("package")[ \t\n]+ {
416 BEGIN( PackageName );
419 if (!yyextra->insideObjC) REJECT;
423<Body,ClassVar,Bases>"-"|"+" {
424 if (!yyextra->insideObjC || yyextra->insideBody)
426 yyextra->code->codify(yytext);
430 DBG_CTX((stderr,
"Start of Objective-C method!\n"));
431 yyextra->code->codify(yytext);
436 yyextra->code->codify(yytext);
440 yyextra->code->codify(yytext);
441 BEGIN(ObjCParamType);
443<ObjCParams,ObjCMethod>";"|"{" {
444 yyextra->code->codify(yytext);
447 if (yyextra->searchingForBody)
449 yyextra->searchingForBody=
false;
450 yyextra->insideBody=
true;
452 if (yyextra->insideBody) yyextra->bodyCurlyCount++;
453 if (!yyextra->curClassName.empty())
455 pushScope(yyscanner,yyextra->curClassName);
456 DBG_CTX((stderr,
"** scope stack push SCOPEBLOCK\n"));
460 yyextra->type.clear();
461 yyextra->name.clear();
464<ObjCParams>{ID}{B}*":" {
465 yyextra->code->codify(yytext);
467<ObjCParamType>{TYPEKW} {
469 yyextra->code->codify(yytext);
471 yyextra->parmType=yytext;
475 yyextra->parmType=yytext;
478 yyextra->code->codify(yytext);
482 yyextra->code->codify(yytext);
483 yyextra->parmName=yytext;
484 addVariable(yyscanner,yyextra->parmType,yyextra->parmName);
485 yyextra->parmType.clear();yyextra->parmName.clear();
487<ObjCMethod,ObjCParams,ObjCParamType>{ID} {
490<ObjCMethod,ObjCParams,ObjCParamType>. {
491 yyextra->code->codify(yytext);
493<ObjCMethod,ObjCParams,ObjCParamType>\n {
496<ReadInclude>[^\n\">]+/(">"|"\"") {
507 DBG_CTX((stderr,
"===== yes %s is ambiguous\n",yytext));
509 if (!
name.empty() && yyextra->sourceFileDef)
515 auto it = std::find_if(fn->begin(),
517 [&sfd=yyextra->sourceFileDef]
519 { return sfd->isIncluded(lfd->absFilePath()); });
520 found = it!=fn->end();
536 yyextra->code->codify(yytext);
538 char c=(char)yyinput(yyscanner);
541 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)
const char * name(int level)
DString determineAbsoluteIncludeName(const DString &curFile, const DString &incFileName)
545<Body,Bases>^[ \t]*"#" {
547 yyextra->lastSkipCppContext = YY_START;
548 yyextra->code->codify(yytext);
552 yyextra->code->codify(yytext);
553 yyextra->lastStringContext=YY_START;
554 BEGIN( SkipString ) ;
557 yyextra->code->codify(yytext);
559<SkipCPP>[^\n\/\\\"]+ {
560 yyextra->code->codify(yytext);
565<SkipCPP>{CPPC}/[^/!] {
568<Body,FuncCall,MemberCall,MemberCall2>"}" {
569 yyextra->theVarContext.popScope();
570 yyextra->theCallContext.popScope(yyextra->name, yyextra->type, yyextra->bracketCount);
571 yyextra->type.clear();
572 yyextra->name.clear();
574 if (!yyextra->scopeStack.empty())
576 int scope = yyextra->scopeStack.top();
577 yyextra->scopeStack.pop();
585 yyextra->code->codify(yytext);
587 DBG_CTX((stderr,
"yyextra->bodyCurlyCount=%d\n",yyextra->bodyCurlyCount));
588 if (--yyextra->bodyCurlyCount<=0)
590 yyextra->insideBody=
false;
591 yyextra->currentMemberDef=
nullptr;
592 if (yyextra->currentDefinition)
593 yyextra->currentDefinition=yyextra->currentDefinition->getOuterScope();
597<Body,ClassVar>"@end" {
598 DBG_CTX((stderr,
"End of objc scope fd=%s\n",
qPrint(yyextra->sourceFileDef->name())));
599 if (yyextra->sourceFileDef)
601 const FileDef *fd=yyextra->sourceFileDef;
604 DBG_CTX((stderr,
"insideObjC=%d\n",yyextra->insideObjC));
608 yyextra->insideObjC =
false;
610 if (yyextra->insideBody)
612 yyextra->theVarContext.popScope();
614 if (!yyextra->scopeStack.empty())
616 int scope = yyextra->scopeStack.top();
617 yyextra->scopeStack.pop();
624 yyextra->insideBody=
false;
628 yyextra->code->codify(yytext);
631 yyextra->currentMemberDef=
nullptr;
632 if (yyextra->currentDefinition)
633 yyextra->currentDefinition=yyextra->currentDefinition->getOuterScope();
bool endsWith(const char *s) const
virtual const DString & name() const =0
636<ClassName,ClassVar>";" {
637 if (yyextra->lang==SrcLangExt::CSharp)
639 yyextra->code->codify(yytext);
640 yyextra->skipCodify =
true;
645 yyextra->code->codify(yytext);
646 yyextra->searchingForBody=
false;
650<ClassName,ClassVar>[*&^%]+ {
651 yyextra->type=yyextra->curClassName;
652 yyextra->name.clear();
653 yyextra->code->codify(yytext);
656<ClassName>"__declspec"{B}*"("{B}*{ID}{B}*")" {
658 yyextra->code->codify(yytext);
661<ClassName>{ID}("."{ID})* |
662<ClassName>{ID}("::"{ID})* {
663 if (yyextra->lang==SrcLangExt::CSharp)
664 yyextra->curClassName=
substitute(yytext,
".",
"::");
666 yyextra->curClassName=yytext;
668 if (yyextra->curClassName==
"alignas")
671 yyextra->code->codify(yytext);
DString substitute(const DString &s, const DString &src, const DString &dst)
substitute all occurrences of src in s by dst
682 yyextra->bracketCount=1;
683 yyextra->code->codify(yytext);
686<AlignAs>\n { yyextra->yyLineNr++;
689<AlignAs>. { yyextra->code->codify(yytext); }
690<AlignAsEnd>"(" { yyextra->code->codify(yytext);
691 yyextra->bracketCount++;
694 yyextra->code->codify(yytext);
695 if (--yyextra->bracketCount<=0)
700<AlignAsEnd>\n { yyextra->yyLineNr++;
703<AlignAsEnd>. { yyextra->code->codify(yytext); }
704<ClassName>{ID}("\\"{ID})* {
705 yyextra->curClassName=
substitute(yytext,
"\\",
"::");
707 pushScope(yyscanner,yyextra->curClassName);
712<ClassName>{ID}{B}*"("{ID}")" {
715 pushScope(yyscanner,yyextra->curClassName);
DString removeRedundantWhiteSpace(const DString &s)
720<PackageName>{ID}("."{ID})* {
721 yyextra->curClassName=
substitute(yytext,
".",
"::");
722 DBG_CTX((stderr,
"found package: %s\n",
qPrint(yyextra->curClassName)));
730<ClassVar>("extends"|"implements") {
734 yyextra->curClassBases.clear();
737<ClassVar>("sealed"|"abstract")/{BN}*(":"|"{") {
738 DBG_CTX((stderr,
"***** C++/CLI modifier %s on yyextra->curClassName=%s\n",yytext,
qPrint(yyextra->curClassName)));
742 BEGIN( CppCliTypeModifierFollowup );
745 yyextra->type = yyextra->curClassName;
746 yyextra->name = yytext;
747 if (yyextra->insideBody)
749 addVariable(yyscanner,yyextra->type,yyextra->name);
753<ClassName,ClassVar,CppCliTypeModifierFollowup>{B}*":"{B}* {
755 yyextra->curClassBases.clear();
758<PackageName>[ \t]*";" |
759<Bases>^{Bopt}/"@"{ID} |
760<Bases,ClassName,ClassVar,CppCliTypeModifierFollowup>{B}*"{"{B}* {
761 yyextra->theVarContext.pushScope();
762 if (!yyextra->skipCodify) yyextra->code->codify(yytext);
763 yyextra->skipCodify =
false;
764 if (YY_START==ClassVar && yyextra->curClassName.empty())
766 yyextra->curClassName = yyextra->name;
768 if (yyextra->searchingForBody)
770 yyextra->searchingForBody=
false;
771 yyextra->insideBody=
true;
773 if (yyextra->insideBody) yyextra->bodyCurlyCount++;
774 if (!yyextra->curClassName.empty())
776 DBG_CTX((stderr,
"** scope stack push CLASSBLOCK\n"));
778 pushScope(yyscanner,yyextra->curClassName);
779 DBG_CTX((stderr,
"***** yyextra->curClassName=%s\n",
qPrint(yyextra->curClassName)));
780 if (yyextra->symbolResolver.resolveClass(yyextra->currentDefinition,yyextra->curClassName,
true)==
nullptr)
782 DBG_CTX((stderr,
"Adding new class %s\n",
qPrint(yyextra->curClassName)));
785 for (
const auto &s : yyextra->curClassBases)
788 auto it = yyextra->codeClassMap.find(s);
789 if (it!=yyextra->codeClassMap.end())
793 if (bcd==
nullptr) bcd=yyextra->symbolResolver.resolveClass(yyextra->currentDefinition,s,
true);
794 if (bcd && bcd->
name()!=yyextra->curClassName)
796 var.localDef()->insertBaseClass(bcd->
name());
799 yyextra->codeClassMap.emplace(yyextra->curClassName.str(),std::move(var));
805 DBG_CTX((stderr,
"** scope stack push INNERBLOCK\n"));
808 yyextra->curClassName.clear();
809 yyextra->curClassBases.clear();
ClassDef * toClassDef(Definition *d)
812<Bases>"virtual"|"public"|"protected"|"private"|"@public"|"@private"|"@protected" {
814 yyextra->code->codify(yytext);
817<Bases>{SEP}?({ID}{SEP})*{ID} {
818 DBG_CTX((stderr,
"%s:addBase(%s)\n",
qPrint(yyextra->curClassName),yytext));
819 yyextra->curClassBases.emplace_back(yytext);
823 yyextra->code->codify(yytext);
824 if (!yyextra->insideObjC)
826 yyextra->sharpCount=1;
831 yyextra->insideProtocolList=
true;
835 yyextra->code->codify(yytext);
836 yyextra->insideProtocolList=
false;
839 yyextra->code->codify(yytext);
840 ++yyextra->sharpCount;
843 yyextra->code->codify(yytext);
844 if (--yyextra->sharpCount<=0)
848 yyextra->code->codify(yytext);
849 yyextra->lastStringContext=YY_START;
853 yyextra->code->codify(yytext);
854 yyextra->lastStringContext=YY_START;
858 yyextra->code->codify(yytext);
859 yyextra->sharpCount=1;
863 yyextra->code->codify(yytext);
864 ++yyextra->sharpCount;
867 yyextra->code->codify(yytext);
868 if (--yyextra->sharpCount<=0)
874 yyextra->code->codify(yytext);
878<Body>{SCOPEPREFIX}?"operator"{B}*"()"{Bopt}/"(" {
881 yyextra->bracketCount=0;
882 yyextra->args.clear();
883 yyextra->name+=yytext;
886<Body>{SCOPEPREFIX}?"operator"/"(" {
889 yyextra->bracketCount=0;
890 yyextra->args.clear();
891 yyextra->name+=yytext;
894<Body>{SCOPEPREFIX}?"operator"[^a-z_A-Z0-9\(\n]+/"(" {
897 yyextra->bracketCount=0;
898 yyextra->args.clear();
899 yyextra->name+=yytext;
902<Body,TemplDecl>("template"|"generic")/([^a-zA-Z0-9]) {
906 yyextra->insideTemplate=
true;
907 yyextra->sharpCount=0;
909<Body>"concept"{BN}+ {
915<Body>"using"{BN}+"namespace"{BN}+ {
927<Body>"module"/{B}*[:;]? {
928 if (yyextra->lang!=SrcLangExt::Cpp) REJECT;
929 if (!yyextra->type.empty() || !yyextra->name.empty()) REJECT;
935<Body>"import"/{B}*[<":]? {
936 if (yyextra->lang!=SrcLangExt::Cpp) REJECT;
942<ConceptName>{ID}("::"{ID})* {
945<ConceptName>"=" {
codifyLines(yyscanner,yytext); BEGIN(Body); }
946<UsingName>{ID}(("::"|"."){ID})* {
951<UsingName>\n {
codifyLines(yyscanner,yytext); BEGIN(Body); }
952<UsingName>. {
codifyLines(yyscanner,yytext); BEGIN(Body); }
953<Body,FuncCall>"$"?"this"("->"|".") { yyextra->code->codify(yytext);
954 yyextra->isPrefixedWithThis =
true;
956<Body>{KEYWORD}/([^a-z_A-Z0-9]) {
957 if (yyextra->lang==SrcLangExt::Java &&
dstrcmp(
"internal",yytext) ==0) REJECT;
965 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)
969<Body>{KEYWORD}/{B}* {
975<Body>{KEYWORD}/{BN}*"(" {
980 yyextra->name.clear();yyextra->type.clear();
982<FuncCall>"in"/{BN}* {
983 if (!yyextra->inForEachExpression) REJECT;
988 yyextra->theVarContext.popScope();
989 addVariable(yyscanner,yyextra->parmType,yyextra->parmName);
990 yyextra->theVarContext.pushScope();
991 yyextra->name.clear();yyextra->type.clear();
993<Body>{FLOWKW}/{BN}*"(" {
997 yyextra->name.clear();yyextra->type.clear();
998 yyextra->inForEachExpression = (
dstrcmp(yytext,
"for each")==0 ||
dstrcmp(yytext,
"foreach")==0);
1001<Body>{FLOWCONDITION}/{BN}*"(" {
1006 yyextra->name.clear();yyextra->type.clear();
1007 yyextra->inForEachExpression = (strcmp(yytext,
"for each")==0 || strcmp(yytext,
"foreach")==0);
1010<Body>{FLOWKW}/([^a-z_A-Z0-9]) {
1014 if (yyextra->inFunctionTryBlock && (
dstrcmp(yytext,
"catch")==0 ||
dstrcmp(yytext,
"finally")==0))
1016 yyextra->inFunctionTryBlock=
false;
1019<Body>{FLOWCONDITION}/([^a-z_A-Z0-9]) {
1024 if (yyextra->inFunctionTryBlock && (strcmp(yytext,
"catch")==0 || strcmp(yytext,
"finally")==0))
1026 yyextra->inFunctionTryBlock=
false;
1029<Body>{FLOWKW}/{B}* {
1034<Body>{FLOWCONDITION}/{B}* {
1041 yyextra->code->codify(yytext);
1042 yyextra->theCallContext.popScope(yyextra->name, yyextra->type, yyextra->bracketCount);
1043 yyextra->bracketCount--;
1044 yyextra->parmType = yyextra->name;
1047<Body>"\\)"|"\\(" {
1048 yyextra->code->codify(yytext);
1050<Body>[\\|\)\+\-\/\%\~\!] {
1051 yyextra->code->codify(yytext);
1052 yyextra->name.clear();yyextra->type.clear();
1055 yyextra->theCallContext.popScope(yyextra->name, yyextra->type, yyextra->bracketCount);
1056 yyextra->bracketCount--;
1057 if (yyextra->bracketCount<=0)
1063<Body,TemplDecl,ObjCMethod>{TYPEKW}/{B}* {
1065 yyextra->code->codify(yytext);
1068 yyextra->name+=yytext;
1070<Body,TemplDecl,ObjCMethod>{TYPEKWSL}/{B}* {
1071 if (yyextra->lang!=SrcLangExt::Slice)
1078 yyextra->code->codify(yytext);
1081 yyextra->name+=yytext;
1084<Body>"generic"/{B}*"<"[^\n\/\-\.\{\">]*">"{B}* {
1086 yyextra->code->codify(yytext);
1088 yyextra->sharpCount=0;
1091<Body>"template"/{B}*"<"[^\n\/\-\.\{\">]*">"{B}* {
1093 yyextra->code->codify(yytext);
1095 yyextra->sharpCount=0;
1098<TemplDecl>"class"|"typename" {
1104 yyextra->code->codify(yytext);
1105 yyextra->sharpCount++;
1108 yyextra->code->codify(yytext);
1109 yyextra->sharpCount--;
1110 if (yyextra->sharpCount<=0)
1119 BEGIN( yyextra->lastTemplCastContext );
1121<TemplCast>{ID}("::"{ID})* {
1124<TemplCast>("const"|"volatile"){B}* {
1132<Body,MemberCall2,FuncCall>{CASTKW}{B}*"<" {
1136 yyextra->lastTemplCastContext = YY_START;
1139<Body>"$this->"{SCOPENAME}/{BN}*[;,)\]] {
1142 yyextra->name+=yytext+7;
1144<Body,TemplCast>{SCOPENAME}{B}*"<"[^\n\/\-\.\{\">\(']*">"{ENDIDopt}/{B}* {
1151 yyextra->name+=yytext;
1153<ModuleName,ModuleImport>{MODULE_ID}({BN}*":"{BN}*{MODULE_ID})? {
1155 size_t i =
name.find(
':');
1159 partition =
name.mid(i+1).stripWhiteSpace();
1160 name =
name.left(i).stripWhiteSpace();
static ModuleManager & instance()
ModuleDef * getPrimaryInterface(const DString &moduleName) const
1172<ModuleName>":"{BN}+"private" {
1174 size_t i=text.
find(
'p');
DString mid(size_t index, size_t len=npos) const
DString left(size_t len) const
1180<ModuleName>";" { yyextra->code->codify(yytext); BEGIN(Body); }
1181<ModuleName>. { yyextra->code->codify(yytext); }
1183<ModuleImport>["<] { yyextra->code->codify(yytext); BEGIN(ReadInclude); }
1184<ModuleImport>";" { yyextra->code->codify(yytext); BEGIN(Body); }
1185<ModuleImport>. { yyextra->code->codify(yytext); }
1186<ModuleImport>\n {
codifyLines(yyscanner,yytext); }
1188<Body>{SCOPENAME}/{BN}*[:;,)\]] {
1195 yyextra->name+=yytext;
1197<Body>{ID}("."{ID})+/{BN}+ {
1198 if (yyextra->lang==SrcLangExt::CSharp || yyextra->lang==SrcLangExt::Java)
1202 yyextra->name+=yytext;
1209<Body>"export"/{B}* {
1210 if (yyextra->lang!=SrcLangExt::Cpp) REJECT;
1215<Body>{SCOPENAME}/{B}* {
1222 yyextra->name+=yytext;
1224<Body>"("{B}*("*"{B}*)+{SCOPENAME}+{B}*")"/{B}* {
1225 yyextra->code->codify(yytext);
1226 uint32_t s=0;
while (s<(uint32_t)yyleng && !
isId(yytext[s])) s++;
1227 uint32_t e=(uint32_t)yyleng-1;
while (e>1 && !
isId(yytext[e])) e--;
1230 yyextra->name=std::move(varname);
bool isId(char c)
Returns true if c is a valid character for an identifier.
1232<Body>{SCOPETNAME}{B}*"<"[^\n\/\-\.\{\">]*">"/{BN}*"(" |
1233<Body>{SCOPETNAME}/{BN}*"(" {
1240 yyextra->bracketCount=0;
1241 yyextra->args.clear();
1242 yyextra->name+=yytext;
1245<FuncCall,Body,MemberCall,MemberCall2,SkipInits,InlineInit>{RAWBEGIN} {
1247 size_t i=text.
find(
'R');
1248 yyextra->code->codify(text.
left(i+1));
1250 yyextra->code->codify(yytext+i+1);
1251 yyextra->lastStringContext=YY_START;
1252 yyextra->inForEachExpression =
false;
DString extractBeginRawStringDelimiter(const char *rawStart)
1256<FuncCall,Body,MemberCall,MemberCall2,SkipInits,InlineInit,ClassVar,OldStyleArgs>\" {
1258 yyextra->code->codify(yytext);
1259 yyextra->lastStringContext=YY_START;
1260 yyextra->inForEachExpression =
false;
1261 BEGIN( SkipString );
1263<FuncCall,Body,MemberCall,MemberCall2,SkipInits,InlineInit>{NUMBER} {
1264 if (yyextra->lang!=SrcLangExt::Cpp) REJECT;
1265 yyextra->code->codify(yytext);
1267<FuncCall,Body,MemberCall,MemberCall2,SkipInits,InlineInit>\' {
1269 yyextra->code->codify(yytext);
1270 yyextra->lastStringContext=YY_START;
1271 yyextra->inForEachExpression =
false;
1272 BEGIN( SkipStringS );
1274<SkipString>[^\"\\\r\n]{1,100} {
1275 yyextra->code->codify(yytext);
1277<SkipStringS>[^\'\\\r\n]{1,100} {
1278 yyextra->code->codify(yytext);
1280<SkipString,SkipStringS>{CPPC}|{CCS} {
1281 yyextra->code->codify(yytext);
1284 yyextra->code->codify(yytext);
1285 if (yyextra->lastStringContext!=SkipCPP)
1289 BEGIN( yyextra->lastStringContext );
1292 yyextra->code->codify(yytext);
1294 BEGIN( yyextra->lastStringContext );
1296<SkipString,SkipStringS>\\. {
1297 yyextra->code->codify(yytext);
1299<RawString>{RAWEND} {
1300 yyextra->code->codify(yytext);
1303 BEGIN( yyextra->lastStringContext );
DString extractEndRawStringDelimiter(const char *rawEnd)
1306<RawString>[^)\n]+ { yyextra->code->codify(yytext); }
1307<RawString>. { yyextra->code->codify(yytext); }
1309<SkipVerbString>[^"\n]+ {
1310 yyextra->code->codify(yytext);
1312<SkipVerbString>\"\" {
1313 yyextra->code->codify(yytext);
1316 yyextra->code->codify(yytext);
1318 BEGIN( yyextra->lastVerbStringContext );
1321 yyextra->code->codify(yytext);
1327 yyextra->code->codify(yytext);
1328 yyextra->name.clear();yyextra->type.clear();
1331 if (yyextra->insideTemplate)
1333 yyextra->sharpCount++;
1335 yyextra->code->codify(yytext);
1338 if (yyextra->insideTemplate)
1340 if (--yyextra->sharpCount<=0)
1342 yyextra->insideTemplate=
false;
1345 yyextra->code->codify(yytext);
1347<Body,MemberCall,MemberCall2,FuncCall,OldStyleArgs>"'"((\\0[Xx0-9]+)|(\\.)|(.))"'" {
1349 yyextra->code->codify(yytext);
1357 yyextra->code->codify(yytext);
1358 yyextra->memCallContext = YY_START;
1359 BEGIN( MemberCall );
1361<MemberCall>{SCOPETNAME}/{BN}*"(" {
1363 if (yyextra->theCallContext.getScope().globalDef())
1370 yyextra->name.clear();
1376 yyextra->name.clear();
1378 yyextra->type.clear();
1379 if (yyextra->memCallContext==Body)
1385 BEGIN(yyextra->memCallContext);
1388<MemberCall>{SCOPENAME}/{B}* {
1389 if (yyextra->theCallContext.getScope().globalDef())
1391 DBG_CTX((stderr,
"yyextra->theCallContext.getClass()=%p\n",(
void*)yyextra->theCallContext.getScope().globalDef()));
1397 yyextra->name.clear();
1401 DBG_CTX((stderr,
"no class context!\n"));
1404 yyextra->name.clear();
1406 yyextra->type.clear();
1407 BEGIN(yyextra->memCallContext);
1410 if (yyextra->insideObjC && *yytext==
'[')
1412 DBG_CTX((stderr,
"Found start of ObjC call!\n"));
1414 yyextra->contextMap.clear();
1415 yyextra->nameMap.clear();
1416 yyextra->objectMap.clear();
1417 yyextra->wordMap.clear();
1418 yyextra->commentMap.clear();
1419 yyextra->currentCtxId = 0;
1420 yyextra->currentNameId = 0;
1421 yyextra->currentObjId = 0;
1422 yyextra->currentCtx =
nullptr;
1423 yyextra->braceCount = 0;
1429 if (*yytext!=
'{') yyextra->code->codify(yytext);
1430 yyextra->saveName = yyextra->name;
1431 yyextra->saveType = yyextra->type;
1432 if (*yytext!=
'[' && !yyextra->type.empty())
1439 addVariable(yyscanner,yyextra->type,yyextra->name);
1441 yyextra->name.clear();
1443 if (*yytext==
';' || *yytext==
'=' || *yytext==
'{')
1445 yyextra->type.clear();
1446 yyextra->name.clear();
1448 else if (*yytext==
'[')
1450 yyextra->theCallContext.pushScope(yyextra->name, yyextra->type, yyextra->bracketCount);
1452 yyextra->args.clear();
1453 yyextra->parmType.clear();
1454 yyextra->parmName.clear();
1462<Body,FuncCall,BodyVar>"{" {
1463 yyextra->theVarContext.pushScope();
1464 yyextra->theCallContext.pushScope(yyextra->name, yyextra->type, yyextra->bracketCount);
1465 yyextra->bracketCount = 0;
1470 DBG_CTX((stderr,
"** scope stack push SCOPEBLOCK\n"));
1476 DBG_CTX((stderr,
"** scope stack push INNERBLOCK\n"));
1480 if (yyextra->searchingForBody)
1482 yyextra->searchingForBody=
false;
1483 yyextra->insideBody=
true;
1485 yyextra->code->codify(yytext);
1486 if (yyextra->insideBody)
1488 yyextra->bodyCurlyCount++;
1490 yyextra->type.clear();
1491 yyextra->name.clear();
1494<ObjCCall,ObjCMName>"["|"{" {
1496 yyextra->currentCtx->format+=*yytext;
1500<ObjCCall,ObjCMName>"]"|"}" {
1501 yyextra->currentCtx->format+=*yytext;
1504 if (yyextra->currentCtx==
nullptr)
1508 auto it = yyextra->contextMap.find(0);
1509 if (it!=yyextra->contextMap.end())
1511 ctx = it->second.get();
1518<ObjCCall,ObjCMName>{CPPC}.* {
1519 yyextra->currentCtx->format+=
escapeComment(yyscanner,yytext);
1521<ObjCCall,ObjCMName>{CCS} {
1522 yyextra->lastObjCCallContext = YY_START;
1523 yyextra->currentCtx->comment.str(yytext);
1524 BEGIN(ObjCCallComment);
1526<ObjCCallComment>{CCE} {
1527 yyextra->currentCtx->comment << yytext;
1528 yyextra->currentCtx->format+=
escapeComment(yyscanner,yyextra->currentCtx->comment.str());
1529 BEGIN(yyextra->lastObjCCallContext);
1531<ObjCCallComment>[^*\n]+ { yyextra->currentCtx->comment << yytext; }
1532<ObjCCallComment>{CPPC}|{CCS} { yyextra->currentCtx->comment << yytext; }
1533<ObjCCallComment>\n { yyextra->currentCtx->comment << *yytext; }
1534<ObjCCallComment>. { yyextra->currentCtx->comment << *yytext; }
1535<ObjCCall>{ID}({B}*"."{B}*{ID})* {
1536 yyextra->currentCtx->format+=
escapeObject(yyscanner,yytext);
1537 if (yyextra->braceCount==0)
1539 yyextra->currentCtx->objectTypeOrName=yytext;
1540 DBG_CTX((stderr,
"new type=%s\n",
qPrint(yyextra->currentCtx->objectTypeOrName)));
1544<ObjCMName>{ID}/{BN}*"]" {
1545 if (yyextra->braceCount==0 &&
1546 yyextra->currentCtx->methodName.empty())
1548 yyextra->currentCtx->methodName=yytext;
1549 yyextra->currentCtx->format+=
escapeName(yyscanner,yytext);
1553 yyextra->currentCtx->format+=
escapeWord(yyscanner,yytext);
1556<ObjCMName>{ID}/{BN}*":" {
1557 if (yyextra->braceCount==0)
1559 yyextra->currentCtx->methodName+=yytext;
1560 yyextra->currentCtx->methodName+=
":";
1562 yyextra->currentCtx->format+=
escapeName(yyscanner,yytext);
1564<ObjCSkipStr>[^\n\"$\\]* { yyextra->currentCtx->format+=yytext; }
1565<ObjCSkipStr>\\. { yyextra->currentCtx->format+=yytext; }
1566<ObjCSkipStr>"\"" { yyextra->currentCtx->format+=yytext;
1567 BEGIN(yyextra->lastStringContext);
1569<ObjCCall,ObjCMName>{CHARLIT} { yyextra->currentCtx->format+=yytext; }
1570<ObjCCall,ObjCMName>"@"?"\"" { yyextra->currentCtx->format+=yytext;
1571 yyextra->lastStringContext=YY_START;
1574<ObjCCall,ObjCMName,ObjCSkipStr>"$" { yyextra->currentCtx->format+=
"$$"; }
1575<ObjCCall,ObjCMName>"(" { yyextra->currentCtx->format+=*yytext; yyextra->braceCount++; }
1576<ObjCCall,ObjCMName>")" { yyextra->currentCtx->format+=*yytext; yyextra->braceCount--; }
1577<ObjCSkipStr>"@"/"\"" {
1578 yyextra->currentCtx->format+=yytext;
1580<ObjCCall,ObjCMName,ObjCSkipStr>{ID} { yyextra->currentCtx->format+=
escapeWord(yyscanner,yytext); }
1581<ObjCCall,ObjCMName,ObjCSkipStr>. { yyextra->currentCtx->format+=*yytext; }
1582<ObjCCall,ObjCMName,ObjCSkipStr>\n { yyextra->currentCtx->format+=*yytext; }
1585 yyextra->theCallContext.popScope(yyextra->name, yyextra->type, yyextra->bracketCount);
1586 yyextra->code->codify(yytext);
1588 yyextra->name = yyextra->saveName;
1589 yyextra->type = yyextra->saveType;
1592 yyextra->code->codify(yytext);
1594<Body>[0-9]+[xX][0-9A-Fa-f]+ {
1595 yyextra->code->codify(yytext);
1597<MemberCall2,FuncCall>{KEYWORD}/([^a-z_A-Z0-9]) {
1602 yyextra->code->codify(yytext);
1605<MemberCall2,FuncCall,OldStyleArgs,TemplCast>{TYPEKW}/([^a-z_A-Z0-9]) {
1607 yyextra->parmName=yytext;
1609 yyextra->code->codify(yytext);
1612<MemberCall2,FuncCall,OldStyleArgs,TemplCast>{TYPEKWSL}/([^a-z_A-Z0-9]) {
1613 if (yyextra->lang!=SrcLangExt::Slice)
1620 yyextra->parmName=yytext;
1622 yyextra->code->codify(yytext);
1626<MemberCall2,FuncCall>{FLOWKW}/([^a-z_A-Z0-9]) {
1628 yyextra->parmName=yytext;
1630 yyextra->code->codify(yytext);
1633<MemberCall2,FuncCall>{FLOWCONDITION}/([^a-z_A-Z0-9]) {
1636 yyextra->parmName=yytext;
1638 yyextra->code->codify(yytext);
1641<MemberCall2,FuncCall>("::")?{ID}(({B}*"<"[^\n\[\](){}<>']*">")?({B}*"::"{B}*{ID})?)* {
1647 yyextra->parmName=yytext;
1651 yyextra->code->codify(yytext);
1652 yyextra->inForEachExpression =
false;
1655<MemberCall2,FuncCall>, {
1656 yyextra->code->codify(yytext);
1657 addVariable(yyscanner,yyextra->parmType,yyextra->parmName);
1658 yyextra->parmType.clear();yyextra->parmName.clear();
1660<MemberCall2,FuncCall>"{" {
1661 if (yyextra->bracketCount>0)
1663 yyextra->code->codify(yytext);
1664 yyextra->skipInlineInitContext=YY_START;
1665 yyextra->curlyCount=0;
1673<InlineInit>"{" { yyextra->curlyCount++;
1674 yyextra->code->codify(yytext);
1677 yyextra->code->codify(yytext);
1678 if (--yyextra->curlyCount<=0)
1680 BEGIN(yyextra->skipInlineInitContext);
1687 yyextra->code->codify(yytext);
1689<MemberCall2,FuncCall>"(" {
1690 yyextra->parmType.clear();yyextra->parmName.clear();
1691 yyextra->code->codify(yytext);
1692 yyextra->bracketCount++;
1693 yyextra->theCallContext.pushScope(yyextra->name, yyextra->type, yyextra->bracketCount);
1694 if (YY_START==FuncCall && !yyextra->insideBody)
1696 yyextra->theVarContext.pushScope();
1699<MemberCall2,FuncCall>{OPERATOR} {
1706 yyextra->parmType.clear();yyextra->parmName.clear();
1708 yyextra->code->codify(yytext);
1710<MemberCall,MemberCall2,FuncCall>("*"{B}*)?")" {
1713 DBG_CTX((stderr,
"addVariable(%s,%s)\n",
qPrint(yyextra->parmType),
qPrint(yyextra->parmName)));
1714 if (yyextra->parmType.empty())
1716 yyextra->parmType=yyextra->parmName;
1717 yyextra->parmName.clear();
1719 addVariable(yyscanner,yyextra->parmType,yyextra->parmName);
1723 yyextra->parmType = yyextra->parmName;
1724 yyextra->parmName.clear();
1725 addVariable(yyscanner,yyextra->parmType,yyextra->parmName);
1727 yyextra->theCallContext.popScope(yyextra->name, yyextra->type, yyextra->bracketCount);
1728 yyextra->inForEachExpression =
false;
1730 yyextra->code->codify(yytext);
1731 if (--yyextra->bracketCount<=0)
1733 if (yyextra->name.empty())
1743<MemberCall,MemberCall2,FuncCall>[;:] {
1745 if (yyextra->bracketCount<=0)
1752 yyextra->code->codify(yytext);
1755<CallEnd>[ \t\n]* {
codifyLines(yyscanner,yytext); }
1758 yyextra->bracketCount=0;
1759 if (*yytext==
';') yyextra->searchingForBody=
false;
1760 if (!yyextra->type.empty())
1762 DBG_CTX((stderr,
"add variable yyextra->type=%s yyextra->name=%s)\n",
qPrint(yyextra->type),
qPrint(yyextra->name)));
1763 addVariable(yyscanner,yyextra->type,yyextra->name);
1765 yyextra->parmType.clear();yyextra->parmName.clear();
1767 if (*yytext==
';' || yyextra->insideBody)
1769 if (!yyextra->insideBody)
1771 yyextra->theVarContext.popScope();
1773 yyextra->name.clear();yyextra->type.clear();
1778 yyextra->bracketCount=0;
1783 if (yyextra->lang!=SrcLangExt::CSharp || yyextra->insideBody)
1789 yyextra->code->codify(
"=>");
1793<CallEnd>{ENDQopt}/{BN}*(";"|"="|"throw"{BN}*"(") {
1798<CallEnd,OldStyleArgs>("const"|"volatile"|"sealed"|"override")*({BN}+("const"|"volatile"|"sealed"|"override"))*{BN}*"{" {
1799 if (yyextra->insideBody)
1801 yyextra->theVarContext.pushScope();
1803 addVariable(yyscanner,yyextra->parmType,yyextra->parmName);
1805 yyextra->parmType.clear();yyextra->parmName.clear();
1806 size_t index = yyextra->name.rfind(
"::");
1807 DBG_CTX((stderr,
"yyextra->name=%s\n",
qPrint(yyextra->name)));
1811 if (!yyextra->scopeName.empty()) scope.
prepend((yyextra->scopeName+
"::"));
1817 DBG_CTX((stderr,
"** scope stack push SCOPEBLOCK\n"));
1823 DBG_CTX((stderr,
"** scope stack push INNERBLOCK\n"));
1828 DBG_CTX((stderr,
"** scope stack push INNERBLOCK\n"));
1831 yytext[yyleng-1]=
'\0';
1833 if (!cv.stripWhiteSpace().empty())
1843 yyextra->code->codify(
"{");
1844 if (yyextra->searchingForBody)
1846 yyextra->searchingForBody=
false;
1847 yyextra->insideBody=
true;
1849 if (yyextra->insideBody) yyextra->bodyCurlyCount++;
1850 yyextra->type.clear(); yyextra->name.clear();
DString & prepend(const char *s)
static NamespaceDefMutable * globalScope
1855 yyextra->code->codify(yytext);
1857 yyextra->inFunctionTryBlock=
true;
1859<CallEnd>"requires" {
1861 yyextra->code->codify(yytext);
1865 if (yyextra->insideBody || !yyextra->parmType.empty())
1871 yyextra->parmName=yytext;
1873 BEGIN(OldStyleArgs);
1877 yyextra->parmName=yytext;
1881 yyextra->code->codify(yytext);
1882 addVariable(yyscanner,yyextra->parmType,yyextra->parmName);
1883 if (*yytext==
';') yyextra->parmType.clear();
1884 yyextra->parmName.clear();
1886<CallEnd,OldStyleArgs>"#" {
1888 yyextra->lastSkipCppContext = Body;
1889 yyextra->code->codify(yytext);
1894 if (!yyextra->insideBody)
1896 yyextra->theVarContext.popScope();
1898 yyextra->name.clear();yyextra->args.clear();
1899 yyextra->parmType.clear();yyextra->parmName.clear();
1903 yyextra->code->codify(yytext);
1904 yyextra->type.clear(); yyextra->name.clear();
1908 yyextra->code->codify(yytext);
1909 if (yyextra->searchingForBody)
1911 yyextra->searchingForBody=
false;
1912 yyextra->insideBody=
true;
1914 if (yyextra->insideBody) yyextra->bodyCurlyCount++;
1917 DBG_CTX((stderr,
"** scope stack push SCOPEBLOCK\n"));
1923 DBG_CTX((stderr,
"** scope stack push INNERBLOCK\n"));
1926 yyextra->type.clear(); yyextra->name.clear();
1929<SkipInits>{ID}{B}*"{" {
1931 size_t bracketPos = text.
find(
'{');
1932 size_t spacePos = text.
find(
' ');
1933 size_t len = spacePos==
DString::npos ? bracketPos : spacePos;
1935 yyextra->code->codify(yytext+len);
1943<FuncCall>{ID}/("."|"->") {
1944 yyextra->name=yytext;
1946 BEGIN( MemberCall2 );
1948<FuncCall,MemberCall2>("("{B}*("*"{B}*)+{ID}+{B}*")"{B}*)/("."|"->") {
1949 yyextra->code->codify(yytext);
1950 uint32_t s=0;
while (!
isId(yytext[s])) s++;
1951 uint32_t e=(uint32_t)yyleng-1;
while (e>1 && !
isId(yytext[e])) e--;
1952 yyextra->name=((
DString)yytext).mid(s,e-s+1);
1953 BEGIN( MemberCall2 );
1955<MemberCall2>{ID}/([ \t\n]*"(") {
1956 if (!yyextra->args.empty())
1960 yyextra->args.clear();
1963<MemberCall2>{ID}/([ \t\n]*("."|"->")) {
1965 yyextra->name=yytext;
1967 BEGIN( MemberCall2 );
1969<MemberCall2>"->"|"." {
1974 yyextra->code->codify(yytext);
1975 yyextra->memCallContext = YY_START;
1976 BEGIN( MemberCall );
1978<SkipComment>{CCS}("!"?){CCE} {
1979 yyextra->code->codify(yytext);
1981 BEGIN( yyextra->lastCContext ) ;
1983<SkipComment>{CPPC}|{CCS} {
1984 yyextra->code->codify(yytext);
1986<SkipComment>[^*\/\n]+ {
1987 yyextra->code->codify(yytext);
1989<SkipComment>[ \t]*{CCE} {
1990 yyextra->code->codify(yytext);
1992 if (yyextra->lastCContext==SkipCPP)
1996 BEGIN( yyextra->lastCContext ) ;
1998<SkipCxxComment>[^\r\n]*"\\"[\r]?\n {
2001<SkipCxxComment>[^\r\n]+ {
2002 yyextra->code->codify(yytext);
2008 BEGIN( yyextra->lastCContext ) ;
2011 yyextra->code->codify(yytext);
2013<MemberCall>[^a-z_A-Z0-9(\n] {
2014 yyextra->code->codify(yytext);
2015 yyextra->type.clear();
2016 yyextra->name.clear();
2017 BEGIN(yyextra->memCallContext);
2019<*>\n({B}*{CPPC}[!/][^\n]*\n)+ {
2020 if (YY_START==SkipCPP) REJECT;
2025 if (YY_START==SkipCxxComment)
2027 BEGIN( yyextra->lastCContext ) ;
2032 BEGIN( yyextra->lastSkipCppContext ) ;
2035<*>\n{B}*{CPPC}"@"[{}].*\n {
2040 if (YY_START==SkipCxxComment)
2042 BEGIN( yyextra->lastCContext ) ;
2045<*>\n{B}*{CCS}"@"[{}] {
2047 if (YY_START != SkipComment && YY_START != SkipCxxComment)
2049 yyextra->lastCContext = YY_START ;
2055<*>^{B}*{CPPC}"@"[{}].*\n {
2061<*>^{B}*{CCS}"@"[{}] {
2063 if (YY_START != SkipComment && YY_START != SkipCxxComment)
2065 yyextra->lastCContext = YY_START ;
2068 yyextra->code->codify(yytext);
2071<*>^{B}*{CPPC}[!/][^\n]* {
2076<*>{CPPC}[!/][^\n]* {
2077 if (YY_START==SkipComment || YY_START==SkipString) REJECT;
2082<*>\n{B}*{CCS}[!*]/{NCOMM} {
2084 if (YY_START != SkipComment && YY_START != SkipCxxComment)
2086 yyextra->lastCContext = YY_START ;
2092<*>^{B}*{CCS}"*"[*]+/[^/] {
2094 if (YY_START != SkipComment && YY_START != SkipCxxComment)
2096 yyextra->lastCContext = YY_START ;
2100 yyextra->code->codify(yytext);
#define Config_getBool(name)
2103<*>^{B}*{CCS}[!*]/{NCOMM} {
2105 if (YY_START != SkipComment && YY_START != SkipCxxComment)
2107 yyextra->lastCContext = YY_START ;
2110 yyextra->code->codify(yytext);
2113<*>{CCS}[!*]/{NCOMM} {
2114 if (YY_START==SkipString) REJECT;
2116 if (YY_START != SkipComment && YY_START != SkipCxxComment)
2118 yyextra->lastCContext = YY_START ;
2121 yyextra->code->codify(yytext);
2124<*>{CCS}("!"?){CCE} {
2125 if (YY_START==SkipString) REJECT;
2128 yyextra->code->codify(yytext);
2131<SkipComment>[^\*\n]+ {
2132 yyextra->code->codify(yytext);
2136 yyextra->code->codify(yytext);
2138 if (YY_START != SkipComment && YY_START != SkipCxxComment)
2140 yyextra->lastCContext = YY_START ;
2142 BEGIN( SkipComment ) ;
2146 yyextra->code->codify(yytext);
2147 yyextra->lastVerbStringContext=YY_START;
2148 BEGIN(SkipVerbString);
2152 yyextra->code->codify(yytext);
2153 yyextra->lastCContext = YY_START ;
2154 BEGIN( SkipCxxComment ) ;
2157 if (yytext[0]==
'(') yyextra->bracketCount++;
2158 yyextra->code->codify(yytext);
2159 yyextra->theCallContext.pushScope(yyextra->name, yyextra->type, yyextra->bracketCount);
2162 if (yytext[0]==
')') yyextra->bracketCount--;
2163 yyextra->code->codify(yytext);
2164 yyextra->theCallContext.popScope(yyextra->name, yyextra->type, yyextra->bracketCount);
2170 yyextra->code->codify(yytext);
2173 yyextra->code->codify(yytext);
2193 DString lname = name.simplifyWhiteSpace();
2199 DBG_CTX((stderr,
"** addVariable trying: type='%s' name='%s' currentDefinition=%s\n",
2200 qPrint(ltype),
qPrint(lname),yyextra->currentDefinition?
qPrint(yyextra->currentDefinition->name()):
"<none>"));
2201 auto it = yyextra->codeClassMap.find(ltype.
str());
2202 if (it!=yyextra->codeClassMap.end())
2205 yyextra->theVarContext.addVariable(lname,std::move(it->second));
2209 auto findVariableType = [&yyscanner,&yyg,<ype,&lname,&name](
const Definition *d) ->
const ClassDef *
2211 const ClassDef *varDef = yyextra->symbolResolver.resolveClass(d,ltype,
true);
2224 const ClassDef *varDef = findVariableType(yyextra->currentDefinition);
2225 if (varDef==
nullptr)
2227 for (
const auto &[usingName,namespaceDef] : yyextra->theUsingContext)
2229 varDef = findVariableType(namespaceDef);
2233 if (varDef==
nullptr)
2235 if (!yyextra->theVarContext.atGlobalScope())
2239 DBG_CTX((stderr,
"** addVariable: dummy context for '%s'\n",
qPrint(lname)));
2244 DBG_CTX((stderr,
"** addVariable: not adding variable!\n"));
2256 yyextra->scopeNameLengthStack.push_back(
int(yyextra->scopeName.length()));
2257 if (yyextra->scopeName.empty() ||
leftScopeMatch(s,yyextra->scopeName))
2259 yyextra->scopeName = s;
2263 yyextra->scopeName +=
"::";
2264 yyextra->scopeName += s;
2274 if (!yyextra->scopeNameLengthStack.empty())
2276 int length = yyextra->scopeNameLengthStack.back();
2277 yyextra->scopeNameLengthStack.pop_back();
2278 yyextra->scopeName.resize(length);
2284 DBG_CTX((stderr,
"popScope() result: '%s'\n",
qPrint(yyextra->scopeName)));
2292 if (yyextra->searchCtx)
2317 size_t ts=n.
find(
'<');
2318 size_t te=n.
rfind(
'>');
2319 DBG_CTX((stderr,
"ts=%zu te=%zu\n",ts,te));
2325 while (!yyextra->scopeNameLengthStack.empty())
2329 yyextra->scopeName.clear();
2337 DBG_CTX((stderr,
"--->New class scope '%s'\n",
qPrint(yyextra->scopeName)));
2343 while (!yyextra->foldStack.empty())
2345 const Definition *dd = yyextra->foldStack.back();
2348 yyextra->code->endFold();
2350 yyextra->foldStack.pop_back();
2374 if (endLine!=-1 && startLine!=endLine &&
2382 (yyextra->foldStack.empty() || yyextra->foldStack.back()->getEndBodyLine()!=startLine))
2390 yyextra->code->startFold(yyextra->yyLineNr,
"",
"");
2394 yyextra->code->startFold(yyextra->yyLineNr,
"{",
"}");
2398 yyextra->code->startFold(yyextra->yyLineNr,
"{",
"};");
2403 yyextra->code->startFold(yyextra->yyLineNr,
"{",
"};");
2407 yyextra->code->startFold(yyextra->yyLineNr,
"{",
"}");
2409 yyextra->foldStack.push_back(d);
2423 if (yyextra->sourceFileDef && yyextra->lineNumbers)
2429 const Definition *d = yyextra->sourceFileDef->getSourceDefinition(yyextra->yyLineNr);
2431 DBG_CTX((stderr,
"%s:startCodeLine(%d)=%p\n",
qPrint(yyextra->sourceFileDef->name()),yyextra->yyLineNr,(
void*)d));
2432 if (!yyextra->includeCodeFragment && d)
2434 yyextra->currentDefinition = d;
2435 yyextra->currentMemberDef = yyextra->sourceFileDef->getSourceMember(yyextra->yyLineNr);
2436 yyextra->insideBody =
false;
2437 yyextra->searchingForBody =
true;
2439 yyextra->type.
clear();
2440 yyextra->name.clear();
2441 yyextra->args.clear();
2442 yyextra->parmType.clear();
2443 yyextra->parmName.clear();
2444 DBG_CTX((stderr,
"Real scope: '%s'\n",
qPrint(yyextra->realScope)));
2445 yyextra->bodyCurlyCount = 0;
2447 lineAnchor.
sprintf(
"l%05d",yyextra->yyLineNr);
2448 if (yyextra->currentMemberDef)
2451 yyextra->code->writeLineNumber(yyextra->currentMemberDef->getReference(),
2452 yyextra->currentMemberDef->getOutputFileBase(),
2453 yyextra->currentMemberDef->anchor(),
2454 yyextra->yyLineNr,!yyextra->includeCodeFragment);
2462 DString(),yyextra->yyLineNr,!yyextra->includeCodeFragment);
2474 !yyextra->includeCodeFragment);
2477 DBG_CTX((stderr,
"startCodeLine(%d)\n",yyextra->yyLineNr));
2478 yyextra->code->startCodeLine(yyextra->yyLineNr);
2479 yyextra->insideCodeLine =
true;
2480 if (yyextra->currentFontClass)
2482 yyextra->code->startFontClass(yyextra->currentFontClass);
2491 DBG_CTX((stderr,
"endCodeLine(%d)\n",yyextra->yyLineNr));
2493 yyextra->code->endCodeLine();
2494 yyextra->insideCodeLine =
false;
2500 const char * fc = yyextra->currentFontClass;
2501 if (yyextra->insideCodeLine)
2505 if (yyextra->yyLineNr<yyextra->inputLines)
2507 yyextra->currentFontClass = fc;
2518 DBG_CTX((stderr,
"codifyLines(%d,\"%s\")\n",yyextra->yyLineNr,
qPrint(text)));
2519 if (text.
empty())
return;
2520 const char *p=text.
data(),*sp=p;
2526 while ((c=*p++) && c!=
'\n');
2529 yyextra->yyLineNr++;
2530 size_t l =
static_cast<size_t>(p-sp-1);
2531 yyextra->code->codify(
DString(sp,l));
2536 yyextra->code->codify(sp);
2546 if (yyextra->currentMemberDef && yyextra->currentMemberDef->isFunction())
2566 yyextra->tooltipManager.addTooltip(d);
2571 if (!sourceTooltips)
2576 const char *p=text.
data();
2581 while ((c=*p++) && c!=
'\n') { }
2584 yyextra->yyLineNr++;
2601 if (yyextra->name==
"const") { yyextra->name.clear();
return; }
2602 if (!yyextra->type.empty()) yyextra->type +=
' ' ;
2603 yyextra->type += yyextra->name ;
2604 yyextra->name.clear() ;
2605 if (!yyextra->type.empty()) yyextra->type +=
' ' ;
2606 yyextra->type += yyextra->args ;
2607 yyextra->args.clear() ;
2613 if (yyextra->parmName==
"const") { yyextra->parmName.clear();
return; }
2614 if (!yyextra->parmType.empty()) yyextra->parmType +=
' ' ;
2615 yyextra->parmType += yyextra->parmName ;
2616 yyextra->parmName.clear() ;
2623 if (yyextra->sourceFileDef && !name.empty())
2628 yyextra->theUsingContext.emplace(name.str(),nd);
2638 yyextra->parmName = a.name;
2639 yyextra->parmType = a.type;
2640 size_t i = yyextra->parmType.find(
'*');
2641 if (i!=
DString::npos) yyextra->parmType = yyextra->parmType.left(i);
2642 i = yyextra->parmType.find(
'&');
2643 if (i!=
DString::npos) yyextra->parmType = yyextra->parmType.left(i);
2644 yyextra->parmType.stripPrefix(
"const ");
2645 yyextra->parmType=yyextra->parmType.stripWhiteSpace();
2646 addVariable(yyscanner,yyextra->parmType,yyextra->parmName);
2653 DBG_CTX((stderr,
"stripClassName(scope=%s,type=%s) scopeName=%s\n",
2661 DString clName=className+templSpec;
2663 if (!yyextra->scopeName.empty())
2665 cd=yyextra->symbolResolver.resolveClass(d,yyextra->scopeName+
"::"+clName,
true);
2669 cd=yyextra->symbolResolver.resolveClass(d,clName,
true);
2671 DBG_CTX((stderr,
"stripClass trying '%s' = %p\n",
qPrint(clName),(
void*)cd));
2683 if (name.empty())
return nullptr;
2685 DBG_CTX((stderr,
"setCallContextForVar(%s) yyextra->scopeName=%s\n",
qPrint(name),
qPrint(yyextra->scopeName)));
2687 size_t scopeEnd = name.rfind(
"::");
2690 DString scope = name.left(scopeEnd);
2691 DString locName = name.mid(scopeEnd+2);
2694 if (mcd && !locName.
empty())
2707 if (mnd && !locName.
empty())
2723 DBG_CTX((stderr,
"local variable?\n"));
2727 yyextra->theCallContext.setScope(*mcv);
2732 DBG_CTX((stderr,
"class member? scope=%s\n",
qPrint(yyextra->scopeName)));
2742 if (yyextra->scopeStack.empty() || yyextra->scopeStack.top()!=
CLASSBLOCK)
2759 const std::unique_ptr<MemberDef> &md=mn->
front();
2760 if (!md->isStatic() || md->getBodyDef()==yyextra->sourceFileDef)
2767 else if (mn->
size()>1)
2769 for (
const auto &md : *mn)
2778 if (!md->isStatic() || md->getBodyDef()==yyextra->sourceFileDef)
2781 DBG_CTX((stderr,
"returning member %s in source file %s\n",
qPrint(md->name()),
qPrint(yyextra->sourceFileDef->name())));
2794 const Definition *d = yyextra->theCallContext.getScope().globalDef();
2818 DBG_CTX((stderr,
"getLinkInScope: trying '%s'::'%s' varOnly=%d\n",
qPrint(c),
qPrint(m),varOnly));
2823 DBG_CTX((stderr,
"scopeNameLengthStack.size()=%zu\n",yyextra->scopeNameLengthStack.size()));
2824 if (!result.
found && !yyextra->scopeNameLengthStack.empty() && c==yyextra->scopeName)
2826 DString localName = yyextra->scopeName.
mid(yyextra->scopeNameLengthStack[0]+2);
2827 auto it = yyextra->codeClassMap.
find(localName.
str());
2828 if (it!=yyextra->codeClassMap.end())
2835 DBG_CTX((stderr,
"trying lookup via base class %s\n",
qPrint(bcName)));
2838 if (result.
found)
break;
2848 if (yyextra->exampleBlock)
2852 anchor.
sprintf(
"a%d",yyextra->anchorCount);
2854 qPrint(yyextra->exampleFile)));
2856 if (mdm && mdm->
addExample(anchor,yyextra->exampleName,yyextra->exampleFile))
2859 yyextra->anchorCount++;
2873 DBG_CTX((stderr,
"yyextra->currentDefinition=%p yyextra->currentMemberDef=%p yyextra->insideBody=%d\n",
2874 (
void*)yyextra->currentDefinition,(
void*)yyextra->currentMemberDef,yyextra->insideBody));
2876 if (yyextra->currentDefinition && yyextra->currentMemberDef &&
2877 yyextra->insideBody && yyextra->collectXRefs)
2900 DBG_CTX((stderr,
"getLink(%s,%s) yyextra->curClassName=%s\n",
2906 if (!yyextra->curClassName.empty())
2909 c.
prepend(yyextra->curClassName);
2925 if (!scopeName.
empty() && scopeName[0]==
'~')
2927 scopeName=scopeName.
mid(1);
2929 if (scopeName.
empty())
2931 yyextra->code->codify(
"~");
2934 if (yyextra->insideProtocolList)
2938 if (yyextra->lang==SrcLangExt::PHP)
2942 else if (yyextra->lang==SrcLangExt::CSharp || yyextra->lang==SrcLangExt::Java)
2946 if (yyextra->currentDefinition==
nullptr && !yyextra->scopeName.empty())
2948 scopeName = yyextra->scopeName+
"::"+scopeName;
2954 DBG_CTX((stderr,
"generateClassOrGlobalLink(name=%s) yyextra->scopeName=%s scopeName=%s\n",
qPrint(scName),
qPrint(yyextra->scopeName),
qPrint(scopeName)));
2955 if (!yyextra->isPrefixedWithThis || (lcd=yyextra->theVarContext.findVariable(scopeName))==
nullptr)
2960 auto checkForSymbol = [&yyg,&bareName,&scopeName](
const Definition *
parent,
2963 sym_ = yyextra->symbolResolver.resolveSymbol(
parent,scopeName,
DString(),
false,
true);
2964 DBG_CTX((stderr,
"non-local variable name=%s sym=%s!\n",
2965 qPrint(scopeName),sym_?
qPrint(sym_->name()):
"<none>"));
2966 if (sym_==
nullptr && !bareName.
empty())
2969 if (bareName!=scopeName)
2971 sym_ = yyextra->symbolResolver.resolveSymbol(
parent,bareName,
DString(),
false,
true);
2975 const Definition *d = yyextra->currentDefinition;
2976 DBG_CTX((stderr,
"d=%s yyextra->sourceFileDef=%s\n",d?
qPrint(d->
name()):
"<none>",yyextra->sourceFileDef?
qPrint(yyextra->sourceFileDef->name()):
"<none>"));
2977 checkForSymbol(d,sym);
2986 checkForSymbol(nd,sym);
2994 for (
const auto &[usingName,namespaceDef] : yyextra->theUsingContext)
2996 checkForSymbol(namespaceDef,sym);
3018 DBG_CTX((stderr,
"is found as a type sym=%s nd=%s\n",
3023 if (
getLink(yyscanner,yyextra->scopeName,scName,ol,scName,varOnly))
3031 DBG_CTX((stderr,
"local variable!\n"));
3035 yyextra->theCallContext.setScope(*lcd);
3046 DBG_CTX((stderr,
"is a local variable sym=%p!\n",(
void*)sym));
3048 yyextra->isPrefixedWithThis =
false;
3053 if (yyextra->exampleBlock)
3057 anchor.
sprintf(
"_a%d",yyextra->anchorCount);
3058 DBG_CTX((stderr,
"addExampleClass(%s,%s,%s)\n",
qPrint(anchor),
qPrint(yyextra->exampleName),
3059 qPrint(yyextra->exampleFile)));
3063 if (cdm && cdm->
addExample(anchor,yyextra->exampleName,yyextra->exampleFile))
3066 yyextra->anchorCount++;
3072 if (mdm && mdm->
addExample(anchor,yyextra->exampleName,yyextra->exampleFile))
3075 yyextra->anchorCount++;
3088 yyextra->currentMemberDef && yyextra->collectXRefs)
3102 DBG_CTX((stderr,
"class %s not linkable! cd=%p typeOnly=%d\n",
qPrint(scName),(
void*)sym,typeOnly));
3103 if (!isLocal && (md || (!sym && !typeOnly)))
3108 DBG_CTX((stderr,
"setCallContextForVar(%s) md=%p yyextra->currentDefinition=%s\n",
qPrint(scName),(
void*)md,yyextra->currentDefinition ?
qPrint(yyextra->currentDefinition->name()) :
"<none>"));
3109 if (md && yyextra->currentDefinition)
3111 DBG_CTX((stderr,
"%s accessible from %s? %d md->getOuterScope=%s\n",
3112 qPrint(md->name()),
qPrint(yyextra->currentDefinition->name()),
3113 yyextra->symbolResolver.isAccessibleFrom(yyextra->currentDefinition,md),
3114 qPrint(md->getOuterScope()->name())));
3117 if (md && yyextra->currentDefinition &&
3118 yyextra->symbolResolver.isAccessibleFrom(yyextra->currentDefinition,md)==-1)
3125 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()));
3126 if (md->isLinkable())
3130 if (yyextra->currentMemberDef && yyextra->collectXRefs)
3140 DBG_CTX((stderr,
"not found!\n"));
3155 DBG_CTX((stderr,
"type='%s' args='%s' class=%s\n",
3159 if (yyextra->exampleBlock)
3163 anchor.
sprintf(
"a%d",yyextra->anchorCount);
3165 qPrint(yyextra->exampleFile)));
3167 if (mdm && mdm->
addExample(anchor,yyextra->exampleName,yyextra->exampleFile))
3170 yyextra->anchorCount++;
3184 DBG_CTX((stderr,
"yyextra->currentDefinition=%p yyextra->currentMemberDef=%p xmd=%p yyextra->insideBody=%d\n",
3185 (
void*)yyextra->currentDefinition,(
void*)yyextra->currentMemberDef,(
void*)xmd,yyextra->insideBody));
3187 if (xmd->templateMaster()) xmd = xmd->templateMaster();
3189 if (xmd->isLinkable())
3192 if (yyextra->currentDefinition && yyextra->currentMemberDef &&
3193 yyextra->insideBody && yyextra->collectXRefs)
3218 DBG_CTX((stderr,
"generateClassMemberLink(class=%s,member=%s)=%p\n",
qPrint(def->
name()),
qPrint(memName),(
void*)xmd));
3257 DBG_CTX((stderr,
"generateMemberLink(object=%s,mem=%s) classScope=%s\n",
3260 if (varName.
empty())
return;
3268 DBG_CTX((stderr,
"Class found!\n"));
3271 DBG_CTX((stderr,
"Found result!\n"));
3278 if (
getLink(yyscanner,bcName,memName,ol))
3280 DBG_CTX((stderr,
"Found result!\n"));
3289 const ClassDef *vcd = yyextra->symbolResolver.resolveClass(yyextra->currentDefinition,yyextra->scopeName,
true);
3292 DBG_CTX((stderr,
"Found class %s for variable '%s'\n",
qPrint(yyextra->scopeName),
qPrint(varName)));
3305 for (
const auto &vmd : *vmn)
3307 if (vmd->getClassDef()==jcd)
3309 DBG_CTX((stderr,
"Found variable type=%s\n",
qPrint(vmd->typeString())));
3322 DBG_CTX((stderr,
"There is a variable with name '%s'\n",
qPrint(varName)));
3323 for (
const auto &vmd : *vmn)
3325 if (vmd->getClassDef()==vcd)
3327 DBG_CTX((stderr,
"Found variable type=%s\n",
qPrint(vmd->typeString())));
3349 DBG_CTX((stderr,
"generatePHPVariableLink(%s) name=%s scope=%s\n",varName,
qPrint(name),
qPrint(yyextra->scopeName)));
3350 if (!
getLink(yyscanner,yyextra->scopeName,name,ol,varName))
3360 DString locScope=yyextra->scopeName;
3362 if (yyextra->lang==SrcLangExt::PHP && locFunc.
startsWith(
"self::")) locFunc=locFunc.
mid(4);
3364 DString funcWithScope=locFunc;
3365 DString funcWithFullScope=locFunc;
3369 size_t i=locFunc.
rfind(
"::");
3370 if (yyextra->currentMemberDef && yyextra->currentMemberDef->resolveAlias()->getClassDef() &&
3371 funcName==yyextra->currentMemberDef->localName() &&
3372 yyextra->currentMemberDef->getDefLine()==yyextra->yyLineNr &&
3386 i=locFunc.
rfind(
".");
3391 i=locFunc.
rfind(
"\\");
3396 funcScope=locFunc.
left(i);
3398 size_t ts=locScope.
find(
'<');
3399 size_t te=locScope.
rfind(
'>');
3400 DBG_CTX((stderr,
"ts=%zu te=%zu\n",ts,te));
3404 locScope=locScope.
left(ts)+locScope.
mid(te+1);
3406 ts=funcScope.
find(
'<');
3407 te=funcScope.
rfind(
'>');
3408 DBG_CTX((stderr,
"ts=%zu te=%zu\n",ts,te));
3412 funcScope=funcScope.
left(ts)+funcScope.
mid(te+1);
3414 if (!funcScope.
empty())
3416 funcWithScope = funcScope+
"::"+locFunc;
3417 if (!locScope.
empty())
3419 fullScope=locScope+
"::"+funcScope;
3422 if (!locScope.
empty())
3424 funcWithFullScope = locScope+
"::"+funcWithScope;
3428 if (!fullScope.
empty())
3430 auto it = yyextra->codeClassMap.find(fullScope.
str());
3431 if (it!=yyextra->codeClassMap.end())
3438 if (
getLink(yyscanner,bcName,locFunc,ol,funcName))
3447 if (!locScope.
empty() && fullScope!=locScope)
3449 auto it = yyextra->codeClassMap.find(locScope.
str());
3450 if (it!=yyextra->codeClassMap.end())
3457 if (
getLink(yyscanner,bcName,funcWithScope,ol,funcName))
3465 if (!
getLink(yyscanner,locScope,funcWithScope,ol,funcName))
3477 const char *p=yyextra->inputString;
3483 if (c==
'\n') count++;
3485 if (p>yyextra->inputString && *(p-1)!=
'\n')
3495 if (yyextra->currentFontClass)
3497 yyextra->code->endFontClass();
3498 yyextra->currentFontClass=
nullptr;
3500 if (specialComment && yyextra->insideSpecialComment)
3502 yyextra->code->endSpecialComment();
3503 yyextra->insideSpecialComment =
false;
3513 yyextra->code->startSpecialComment();
3514 yyextra->insideSpecialComment =
true;
3516 yyextra->code->startFontClass(s);
3517 yyextra->currentFontClass=s;
3525 if (ctx==
nullptr)
return;
3530 DBG_CTX((stderr,
"writeObjCMethodCall(%s) obj=%s method=%s\n",
3539 DBG_CTX((stderr,
" object is local variable\n"));
3547 DBG_CTX((stderr,
" class=%p method=%p\n",(
void*)cd,(
void*)ctx->
method));
3558 char skipChar =
' ';
3583 yyextra->code->codify(
"$");
3591 while (nc!=0 && isdigit(nc)) { refIdStr+=nc; nc=*p++; }
3593 int refId=refIdStr.
toInt();
3594 auto it = yyextra->nameMap.find(refId);
3595 if (it!=yyextra->nameMap.end())
3601 if (yyextra->currentMemberDef && yyextra->collectXRefs)
3613 DBG_CTX((stderr,
"Invalid name: id=%d\n",refId));
3620 while (nc!=0 && isdigit(nc)) { refIdStr+=nc; nc=*p++; }
3622 int refId=refIdStr.
toInt();
3623 auto it = yyextra->objectMap.find(refId);
3624 if (it!=yyextra->objectMap.end())
3629 if (yyextra->currentDefinition &&
3646 else if (
object==
"super")
3648 if (yyextra->currentDefinition &&
3675 if (yyextra->currentMemberDef && yyextra->collectXRefs)
3688 size_t dotPos =
object.find(
'.',pp);
3689 size_t len =
object.length();
3691 const Definition *scope = yyextra->currentDefinition;
3698 if (fragmentStripped==
"self")
3711 const Definition *symbol = yyextra->symbolResolver.resolveSymbol(scope,fragmentStripped,
DString(),
false,
true);
3717 ctx->
method = yyextra->symbolResolver.getTypedef();
3741 dotPos=
object.find(
'.',pp);
3751 else if (ctx->
method==
nullptr)
3754 DBG_CTX((stderr,
"yyextra->currentDefinition=%p\n",(
void*)yyextra->currentDefinition));
3755 if (yyextra->currentDefinition &&
3776 DBG_CTX((stderr,
"Invalid object: id=%d\n",refId));
3783 while (nc!=0 && isdigit(nc)) { refIdStr+=nc; nc=*p++; }
3785 int refId=refIdStr.
toInt();
3786 auto it = yyextra->contextMap.find(refId);
3787 if (it!=yyextra->contextMap.end())
3802 if (mn && mn->
size()==1)
3820 DBG_CTX((stderr,
"Invalid context: id=%d\n",refId));
3827 while (nc!=0 && isdigit(nc)) { refIdStr+=nc; nc=*p++; }
3829 int refId=refIdStr.
toInt();
3830 auto it = yyextra->wordMap.find(refId);
3831 if (it!=yyextra->wordMap.end())
3834 bool isKeyword = word==
"self";
3850 while (nc!=0 && isdigit(nc)) { refIdStr+=nc; nc=*p++; }
3852 int refId=refIdStr.
toInt();
3853 auto it = yyextra->commentMap.find(refId);
3854 if (it!=yyextra->commentMap.end())
3868 else if (c==
'\'' || c ==
'"')
3885 DBG_CTX((stderr,
"}=(type='%s',name='%s')",
3897 result.
sprintf(
"$n%d",yyextra->currentNameId);
3898 yyextra->nameMap.emplace(yyextra->currentNameId,s);
3899 yyextra->currentNameId++;
3907 result.
sprintf(
"$o%d",yyextra->currentObjId);
3908 yyextra->objectMap.emplace(yyextra->currentObjId,s);
3909 yyextra->currentObjId++;
3917 result.
sprintf(
"$w%d",yyextra->currentWordId);
3918 yyextra->wordMap.emplace(yyextra->currentWordId,s);
3919 yyextra->currentWordId++;
3927 result.
sprintf(
"$d%d",yyextra->currentCommentId);
3928 yyextra->commentMap.emplace(yyextra->currentCommentId,s);
3929 yyextra->currentCommentId++;
3936 static const std::unordered_set<std::string> non_cpp_keywords = {
3937 "__assume",
"__super",
"abstract",
"function",
3938 "gcnew",
"gcroot",
"generic",
"get",
3939 "internal",
"null",
"pin_ptr",
"raise",
3940 "remove",
"self",
"set",
"transient",
3943 static const std::unordered_set<std::string> non_java_keywords = {
3944 "alignas",
"alignof",
"and",
"and_eq",
"asm",
3945 "atomic_cancel",
"atomic_commit",
"atomic_noexcept",
"auto",
"bitand",
3946 "bitor",
"bool",
"char8_t",
"char16_t",
"char32_t",
3947 "compl",
"concept",
"consteval",
"constexpr",
"constinit",
3948 "const_cast",
"co_await",
"co_return",
"co_yield",
"decltype",
3949 "delete",
"dynamic_cast",
"explicit",
"export",
"extern",
3950 "friend",
"inline",
"mutable",
"namespace",
"noexcept",
3951 "not",
"not_eq",
"nullptr",
"operator",
"or",
3952 "or_eq",
"reflexpr",
"register",
"reinterpret_cast",
"requires",
3953 "signed",
"sizeof",
"static_assert",
"_Static_assert",
"static_cast",
"struct",
3954 "template",
"thread_local",
"typedef",
"typeid",
"typename",
3955 "union",
"unsigned",
"using",
"virtual",
"wchar_t",
3956 "xor",
"xor_eq",
"override",
"sealed"
3958 bool retval =
false;
3959 switch (yyextra->lang)
3961 case SrcLangExt::Cpp:
3962 retval = (non_cpp_keywords.find(keyword) != non_cpp_keywords.end());
3964 case SrcLangExt::Java:
3965 retval = (non_java_keywords.find(keyword) != non_java_keywords.end());
3977 size_t i=s.
find(
'<');
3980 return kw==
"const_cast" || kw==
"static_cast" || kw==
"dynamic_cast" || kw==
"reinterpret_cast";
3986 yy_size_t inputPosition = yyextra->inputPosition;
3987 const char *s = yyextra->inputString + inputPosition;
3989 while( c < max_size && *s )
3994 yyextra->inputPosition += c;
4002 if (yyextra->currentCtx)
4004 yyextra->currentCtx->format+=
DString().
sprintf(
"$c%d",yyextra->currentCtxId);
4005 if (yyextra->braceCount==0 && YY_START==ObjCCall)
4007 yyextra->currentCtx->objectTypeOrName=yyextra->currentCtx->format.mid(1);
4008 DBG_CTX((stderr,
"new type=%s\n",
qPrint(yyextra->currentCtx->objectTypeOrName)));
4010 yyextra->contextStack.push(yyextra->currentCtx);
4014 DBG_CTX((stderr,
"Trying to save NULL context!\n"));
4016 auto newCtx = std::make_unique<ObjCCallCtx>();
4017 newCtx->id = yyextra->currentCtxId;
4018 newCtx->lexState = YY_START;
4019 newCtx->braceCount = yyextra->braceCount;
4020 newCtx->objectType =
nullptr;
4021 newCtx->objectVar =
nullptr;
4022 newCtx->method =
nullptr;
4023 DBG_CTX((stderr,
"save state=%d\n",YY_START));
4024 yyextra->currentCtx = newCtx.get();
4025 yyextra->contextMap.emplace(yyextra->currentCtxId,std::move(newCtx));
4026 yyextra->braceCount = 0;
4027 yyextra->currentCtxId++;
4033 DBG_CTX((stderr,
"restore state=%d->%d\n",YY_START,yyextra->currentCtx->lexState));
4034 BEGIN(yyextra->currentCtx->lexState);
4035 yyextra->braceCount = yyextra->currentCtx->braceCount;
4036 if (!yyextra->contextStack.empty())
4038 yyextra->currentCtx = yyextra->contextStack.top();
4039 yyextra->contextStack.pop();
4043 yyextra->currentCtx =
nullptr;
4044 DBG_CTX((stderr,
"Trying to pop context while yyextra->contextStack is empty!\n"));
4056 codeYYlex_init_extra(&
p->state,&
p->yyscanner);
4065 codeYYlex_destroy(
p->yyscanner);
4071 DBG_CTX((stderr,
"***CodeParser::reset()\n"));
4072 yyextra->theVarContext.clear();
4073 while (!yyextra->scopeNameLengthStack.empty()) yyextra->scopeNameLengthStack.pop_back();
4074 yyextra->codeClassMap.clear();
4075 yyextra->curClassBases.clear();
4076 yyextra->anchorCount = 0;
4077 yyextra->insideCodeLine =
false;
4083 yyextra->insideCodeLine = inp;
4089 return yyextra->insideCodeLine;
4097 DBG_CTX((stderr,
"***parseCode() exBlock=%d exName=%s fd=%p scopeName=%s searchCtx=%s\n",
4101 if (s.
empty())
return;
4107 yyextra->code = &od;
4108 yyextra->inputString = s.
data();
4111 yyextra->inputPosition = 0;
4112 codeYYrestart(
nullptr,yyscanner);
4113 yyextra->currentFontClass =
nullptr;
4114 yyextra->searchCtx = options.
searchCtx();
4116 yyextra->inFunctionTryBlock =
false;
4117 yyextra->symbolResolver.setFileScope(options.
fileDef());
4118 yyextra->foldStack.clear();
4119 yyextra->insideSpecialComment =
false;
4122 yyextra->curlyCount = 0;
4123 yyextra->bodyCurlyCount = 0;
4124 yyextra->bracketCount = 0;
4125 yyextra->sharpCount = 0;
4126 yyextra->insideTemplate =
false;
4127 yyextra->theCallContext.clear();
4128 while (!yyextra->scopeStack.empty()) yyextra->scopeStack.pop();
4129 yyextra->scopeName = scopeName;
4131 yyextra->exampleBlock = options.
isExample();
4133 yyextra->sourceFileDef = options.
fileDef();
4135 if (options.
fileDef()==
nullptr)
4139 yyextra->sourceFileDef = yyextra->exampleFileDef.get();
4141 yyextra->lang = lang;
4142 yyextra->insideObjC = lang==SrcLangExt::ObjC;
4143 if (yyextra->sourceFileDef)
4148 yyextra->currentMemberDef =
nullptr;
4149 yyextra->searchingForBody = options.
isExample();
4150 yyextra->insideBody =
false;
4151 yyextra->bracketCount = 0;
4152 if (!yyextra->exampleName.empty())
4154 yyextra->exampleFile =
convertNameToFile(yyextra->exampleName+
"-example",
false,
true);
4155 DBG_CTX((stderr,
"yyextra->exampleFile=%s\n",
qPrint(yyextra->exampleFile)));
4159 if (!yyextra->insideCodeLine)
4163 yyextra->type.clear();
4164 yyextra->name.clear();
4165 yyextra->args.clear();
4166 yyextra->parmName.clear();
4167 yyextra->parmType.clear();
4170 codeYYlex(yyscanner);
4171 yyextra->lexInit=
true;
4172 if (yyextra->insideCodeLine)
4178 while (!yyextra->foldStack.empty())
4180 yyextra->code->endFold();
4181 yyextra->foldStack.pop_back();
4184 if (yyextra->exampleFileDef)
4187 yyextra->exampleFileDef.reset();
4188 yyextra->sourceFileDef=
nullptr;
4191 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
DString stripWhiteSpace() const
returns a copy of this string with leading and trailing whitespace removed
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)