378 {
380 yyextra->code->codify(yytext);
381 BEGIN( ReadInclude );
382 }
383<Body>("@interface"|"@implementation"|"@protocol")[ \t\n]+ {
384 yyextra->insideObjC=true;
388 if (!yyextra->insideTemplate)
389 BEGIN( ClassName );
390 }
391<Body>(("public"|"private"){B}+)?("ref"|"value"|"interface"|"enum"){B}+("class"|"struct") {
392 if (yyextra->insideTemplate) REJECT;
396 BEGIN( ClassName );
397 }
398<Body>"property"|"event"/{BN}* {
399 if (yyextra->insideTemplate) REJECT;
403 }
404<Body>("partial"{B}+)?("class"|"struct"|"union"|"namespace"|"interface"){B}+ {
408 if (!yyextra->insideTemplate)
409 BEGIN( ClassName );
410 }
411<Body>("package")[ \t\n]+ {
415 BEGIN( PackageName );
416 }
417<ClassVar>\n {
418 if (!yyextra->insideObjC) REJECT;
420 BEGIN(Body);
421 }
422<Body,ClassVar,Bases>"-"|"+" {
423 if (!yyextra->insideObjC || yyextra->insideBody)
424 {
425 yyextra->code->codify(yytext);
426 }
427 else
428 {
429 DBG_CTX((stderr,
"Start of Objective-C method!\n"));
430 yyextra->code->codify(yytext);
431 BEGIN(ObjCMethod);
432 }
433 }
434<ObjCMethod>":" {
435 yyextra->code->codify(yytext);
436 BEGIN(ObjCParams);
437 }
438<ObjCParams>"(" {
439 yyextra->code->codify(yytext);
440 BEGIN(ObjCParamType);
441 }
442<ObjCParams,ObjCMethod>";"|"{" {
443 yyextra->code->codify(yytext);
444 if (*yytext=='{')
445 {
446 if (yyextra->searchingForBody)
447 {
448 yyextra->searchingForBody=false;
449 yyextra->insideBody=true;
450 }
451 if (yyextra->insideBody) yyextra->bodyCurlyCount++;
452 if (!yyextra->curClassName.empty())
453 {
454 pushScope(yyscanner,yyextra->curClassName);
455 DBG_CTX((stderr,
"** scope stack push SCOPEBLOCK\n"));
457 }
458 }
459 yyextra->type.clear();
460 yyextra->name.clear();
461 BEGIN(Body);
462 }
463<ObjCParams>{ID}{B}*":" {
464 yyextra->code->codify(yytext);
465 }
466<ObjCParamType>{TYPEKW} {
468 yyextra->code->codify(yytext);
470 yyextra->parmType=yytext;
471 }
472<ObjCParamType>{ID} {
474 yyextra->parmType=yytext;
475 }
476<ObjCParamType>")" {
477 yyextra->code->codify(yytext);
478 BEGIN(ObjCParams);
479 }
480<ObjCParams>{ID} {
481 yyextra->code->codify(yytext);
482 yyextra->parmName=yytext;
483 addVariable(yyscanner,yyextra->parmType,yyextra->parmName);
484 yyextra->parmType.clear();yyextra->parmName.clear();
485 }
486<ObjCMethod,ObjCParams,ObjCParamType>{ID} {
488 }
489<ObjCMethod,ObjCParams,ObjCParamType>. {
490 yyextra->code->codify(yytext);
491 }
492<ObjCMethod,ObjCParams,ObjCParamType>\n {
494 }
495<ReadInclude>[^\n\">]+/(">"|"\"") {
496
497 bool found = false;
498 bool ambig = false;
501
503 {
504 if (ambig)
505 {
506 DBG_CTX((stderr,
"===== yes %s is ambiguous\n",yytext));
508 if (!name.empty() && yyextra->sourceFileDef)
509 {
511 if (fn)
512 {
513
514 auto it = std::find_if(fn->begin(),
515 fn->end(),
516 [&sfd=yyextra->sourceFileDef]
517 (const auto &lfd)
518 { return sfd->isIncluded(lfd->absFilePath()); });
519 found = it!=fn->end();
520 }
521 }
522 }
523 else
524 {
525 found = true;
526 }
527 }
529 if (found)
530 {
532 }
533 else
534 {
535 yyextra->code->codify(yytext);
536 }
537 char c=(char)yyinput(yyscanner);
539 text+=c;
540 yyextra->code->codify(text);
542 BEGIN( Body );
543 }
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.
DString determineAbsoluteIncludeName(const DString &curFile, const DString &incFileName)
544<Body,Bases>^[ \t]*"#" {
546 yyextra->lastSkipCppContext = YY_START;
547 yyextra->code->codify(yytext);
548 BEGIN( SkipCPP ) ;
549 }
550<SkipCPP>\" {
551 yyextra->code->codify(yytext);
552 yyextra->lastStringContext=YY_START;
553 BEGIN( SkipString ) ;
554 }
555<SkipCPP>. {
556 yyextra->code->codify(yytext);
557 }
558<SkipCPP>[^\n\/\\\"]+ {
559 yyextra->code->codify(yytext);
560 }
561<SkipCPP>\\[\r]?\n {
563 }
564<SkipCPP>{CPPC}/[^/!] {
565 REJECT;
566 }
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();
572
573 if (!yyextra->scopeStack.empty())
574 {
575 int scope = yyextra->scopeStack.top();
576 yyextra->scopeStack.pop();
579 {
581 }
582 }
583
584 yyextra->code->codify(yytext);
585
586 DBG_CTX((stderr,
"yyextra->bodyCurlyCount=%d\n",yyextra->bodyCurlyCount));
587 if (--yyextra->bodyCurlyCount<=0)
588 {
589 yyextra->insideBody=false;
590 yyextra->currentMemberDef=nullptr;
591 if (yyextra->currentDefinition)
592 yyextra->currentDefinition=yyextra->currentDefinition->getOuterScope();
593 }
594 BEGIN(Body);
595 }
596<Body,ClassVar>"@end" {
597 DBG_CTX((stderr,
"End of objc scope fd=%s\n",
qPrint(yyextra->sourceFileDef->name())));
598 if (yyextra->sourceFileDef)
599 {
600 const FileDef *fd=yyextra->sourceFileDef;
603 DBG_CTX((stderr,
"insideObjC=%d\n",yyextra->insideObjC));
604 }
605 else
606 {
607 yyextra->insideObjC = false;
608 }
609 if (yyextra->insideBody)
610 {
611 yyextra->theVarContext.popScope();
bool endsWith(const char *s) const
612
613 if (!yyextra->scopeStack.empty())
614 {
615 int scope = yyextra->scopeStack.top();
616 yyextra->scopeStack.pop();
619 {
621 }
622 }
623 yyextra->insideBody=false;
624 }
625
627 yyextra->code->codify(yytext);
629
630 yyextra->currentMemberDef=nullptr;
631 if (yyextra->currentDefinition)
632 yyextra->currentDefinition=yyextra->currentDefinition->getOuterScope();
633 BEGIN(Body);
634 }
635<ClassName,ClassVar>";" {
636 if (yyextra->lang==SrcLangExt::CSharp)
637 {
638 yyextra->code->codify(yytext);
639 yyextra->skipCodify = true;
640 unput('{');
641 }
642 else
643 {
644 yyextra->code->codify(yytext);
645 yyextra->searchingForBody=false;
646 BEGIN( Body );
647 }
648 }
649<ClassName,ClassVar>[*&^%]+ {
650 yyextra->type=yyextra->curClassName;
651 yyextra->name.clear();
652 yyextra->code->codify(yytext);
653 BEGIN( Body );
654 }
655<ClassName>"__declspec"{B}*"("{B}*{ID}{B}*")" {
657 yyextra->code->codify(yytext);
659 }
660<ClassName>{ID}("."{ID})* |
661<ClassName>{ID}("::"{ID})* {
662 if (yyextra->lang==SrcLangExt::CSharp)
663 yyextra->curClassName=
substitute(yytext,
".",
"::");
664 else
665 yyextra->curClassName=yytext;
667 if (yyextra->curClassName=="alignas")
668 {
670 yyextra->code->codify(yytext);
672 BEGIN( AlignAs );
673 }
674 else
675 {
677 BEGIN( ClassVar );
678 }
679 }
static void addType(yyscan_t yyscanner)
680<AlignAs>"(" {
681 yyextra->bracketCount=1;
682 yyextra->code->codify(yytext);
683 BEGIN( AlignAsEnd );
684 }
685<AlignAs>\n { yyextra->yyLineNr++;
687 }
688<AlignAs>. { yyextra->code->codify(yytext); }
689<AlignAsEnd>"(" { yyextra->code->codify(yytext);
690 yyextra->bracketCount++;
691 }
692<AlignAsEnd>")" {
693 yyextra->code->codify(yytext);
694 if (--yyextra->bracketCount<=0)
695 {
696 BEGIN(ClassName);
697 }
698 }
699<AlignAsEnd>\n { yyextra->yyLineNr++;
701 }
702<AlignAsEnd>. { yyextra->code->codify(yytext); }
703<ClassName>{ID}("\\"{ID})* { // PHP namespace
704 yyextra->curClassName=
substitute(yytext,
"\\",
"::");
706 pushScope(yyscanner,yyextra->curClassName);
709 BEGIN( ClassVar );
710 }
711<ClassName>{ID}{B}*"("{ID}")" { // Obj-C category
714 pushScope(yyscanner,yyextra->curClassName);
717 BEGIN( ClassVar );
718 }
719<PackageName>{ID}("."{ID})* {
720 yyextra->curClassName=
substitute(yytext,
".",
"::");
721 DBG_CTX((stderr,
"found package: %s\n",
qPrint(yyextra->curClassName)));
724 }
725<ClassVar>"=" {
726 unput(*yytext);
727 BEGIN( Body );
728 }
729<ClassVar>("extends"|"implements") { // Java, Slice
733 yyextra->curClassBases.clear();
734 BEGIN( Bases );
735 }
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 );
742 }
743<ClassVar>{ID} {
744 yyextra->type = yyextra->curClassName;
745 yyextra->name = yytext;
746 if (yyextra->insideBody)
747 {
748 addVariable(yyscanner,yyextra->type,yyextra->name);
749 }
751 }
752<ClassName,ClassVar,CppCliTypeModifierFollowup>{B}*":"{B}* {
754 yyextra->curClassBases.clear();
755 BEGIN( Bases );
756 }
757<PackageName>[ \t]*";" |
758<Bases>^{Bopt}/"@"{ID} | // Objective-C interface
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())
764 {
765 yyextra->curClassName = yyextra->name;
766 }
767 if (yyextra->searchingForBody)
768 {
769 yyextra->searchingForBody=false;
770 yyextra->insideBody=true;
771 }
772 if (yyextra->insideBody) yyextra->bodyCurlyCount++;
773 if (!yyextra->curClassName.empty())
774 {
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)
780 {
781 DBG_CTX((stderr,
"Adding new class %s\n",
qPrint(yyextra->curClassName)));
783
784 for (const auto &s : yyextra->curClassBases)
785 {
787 auto it = yyextra->codeClassMap.find(s);
788 if (it!=yyextra->codeClassMap.end())
789 {
791 }
792 if (bcd==nullptr) bcd=yyextra->symbolResolver.resolveClass(yyextra->currentDefinition,s,true);
793 if (bcd && bcd->
name()!=yyextra->curClassName)
794 {
795 var.localDef()->insertBaseClass(bcd->
name());
796 }
797 }
798 yyextra->codeClassMap.emplace(yyextra->curClassName.str(),std::move(var));
799 }
800
801 }
802 else
803 {
804 DBG_CTX((stderr,
"** scope stack push INNERBLOCK\n"));
806 }
807 yyextra->curClassName.clear();
808 yyextra->curClassBases.clear();
809 BEGIN( Body );
810 }
811<Bases>"virtual"|"public"|"protected"|"private"|"@public"|"@private"|"@protected" {
813 yyextra->code->codify(yytext);
815 }
816<Bases>{SEP}?({ID}{SEP})*{ID} {
817 DBG_CTX((stderr,
"%s:addBase(%s)\n",
qPrint(yyextra->curClassName),yytext));
818 yyextra->curClassBases.emplace_back(yytext);
820 }
821<Bases>"<" {
822 yyextra->code->codify(yytext);
823 if (!yyextra->insideObjC)
824 {
825 yyextra->sharpCount=1;
826 BEGIN ( SkipSharp );
827 }
828 else
829 {
830 yyextra->insideProtocolList=true;
831 }
832 }
833<Bases>">" {
834 yyextra->code->codify(yytext);
835 yyextra->insideProtocolList=false;
836 }
837<SkipSharp>"<" {
838 yyextra->code->codify(yytext);
839 ++yyextra->sharpCount;
840 }
841<SkipSharp>">" {
842 yyextra->code->codify(yytext);
843 if (--yyextra->sharpCount<=0)
844 BEGIN ( Bases );
845 }
846<SkipSharp>"\"" {
847 yyextra->code->codify(yytext);
848 yyextra->lastStringContext=YY_START;
849 BEGIN(SkipString);
850 }
851<SkipSharp>"\'" {
852 yyextra->code->codify(yytext);
853 yyextra->lastStringContext=YY_START;
854 BEGIN(SkipStringS);
855 }
856<Bases>"(" {
857 yyextra->code->codify(yytext);
858 yyextra->sharpCount=1;
859 BEGIN ( SkipSharp );
860 }
861<SkipSharp>"(" {
862 yyextra->code->codify(yytext);
863 ++yyextra->sharpCount;
864 }
865<SkipSharp>")" {
866 yyextra->code->codify(yytext);
867 if (--yyextra->sharpCount<=0)
868 BEGIN ( Bases );
869 }
870
871
872<Bases>"," {
873 yyextra->code->codify(yytext);
874 }
875
876
877<Body>{SCOPEPREFIX}?"operator"{B}*"()"{Bopt}/"(" {
880 yyextra->bracketCount=0;
881 yyextra->args.clear();
882 yyextra->name+=yytext;
883 BEGIN( FuncCall );
884 }
static void generateFunctionLink(yyscan_t yyscanner, OutputCodeList &ol, const DString &funcName)
885<Body>{SCOPEPREFIX}?"operator"/"(" {
888 yyextra->bracketCount=0;
889 yyextra->args.clear();
890 yyextra->name+=yytext;
891 BEGIN( FuncCall );
892 }
893<Body>{SCOPEPREFIX}?"operator"[^a-z_A-Z0-9\(\n]+/"(" {
896 yyextra->bracketCount=0;
897 yyextra->args.clear();
898 yyextra->name+=yytext;
899 BEGIN( FuncCall );
900 }
901<Body,TemplDecl>("template"|"generic")/([^a-zA-Z0-9]) {
905 yyextra->insideTemplate=true;
906 yyextra->sharpCount=0;
907 }
908<Body>"concept"{BN}+ {
912 BEGIN(ConceptName);
913 }
914<Body>"using"{BN}+"namespace"{BN}+ {
918 BEGIN(UsingName);
919 }
920<Body>"using"{BN}+ {
924 BEGIN(UsingName);
925 }
926<Body>"module"/{B}*[:;]? { // 'module X' or 'module : private' or 'module;'
927 if (yyextra->lang!=SrcLangExt::Cpp) REJECT;
928 if (!yyextra->type.empty() || !yyextra->name.empty()) REJECT;
932 BEGIN(ModuleName);
933 }
934<Body>"import"/{B}*[<":]? {
935 if (yyextra->lang!=SrcLangExt::Cpp) REJECT;
939 BEGIN(ModuleImport);
940 }
941<ConceptName>{ID}("::"{ID})* {
943 }
944<ConceptName>"=" { codifyLines(yyscanner,yytext); BEGIN(Body); }
945<UsingName>{ID}(("::"|"."){ID})* {
948 BEGIN(Body);
949 }
static void addUsingDirective(yyscan_t yyscanner, const DString &name)
950<UsingName>\n { codifyLines(yyscanner,yytext); BEGIN(Body); }
951<UsingName>. { codifyLines(yyscanner,yytext); BEGIN(Body); }
952<Body,FuncCall>"$"?"this"("->"|".") { yyextra->code->codify(yytext); // this-> for C++, this. for C#
953 yyextra->isPrefixedWithThis = true;
954 }
955<Body>{KEYWORD}/([^a-z_A-Z0-9]) {
956 if (yyextra->lang==SrcLangExt::Java &&
dstrcmp(
"internal",yytext) ==0) REJECT;
962 {
964 yyextra->name+=yytext;
965 }
967 }
static bool skipLanguageSpecificKeyword(yyscan_t yyscanner, const char *kw)
int dstrcmp(const char *str1, const char *str2)
968<Body>{KEYWORD}/{B}* {
973 }
974<Body>{KEYWORD}/{BN}*"(" {
979 yyextra->name.clear();yyextra->type.clear();
980 }
981<FuncCall>"in"/{BN}* {
982 if (!yyextra->inForEachExpression) REJECT;
986
987 yyextra->theVarContext.popScope();
988 addVariable(yyscanner,yyextra->parmType,yyextra->parmName);
989 yyextra->theVarContext.pushScope();
990 yyextra->name.clear();yyextra->type.clear();
991 }
992<Body>{FLOWKW}/{BN}*"(" {
996 yyextra->name.clear();yyextra->type.clear();
997 yyextra->inForEachExpression = (
dstrcmp(yytext,
"for each")==0 ||
dstrcmp(yytext,
"foreach")==0);
998 BEGIN(FuncCall);
999 }
1000<Body>{FLOWCONDITION}/{BN}*"(" {
1005 yyextra->name.clear();yyextra->type.clear();
1006 yyextra->inForEachExpression = (strcmp(yytext,"for each")==0 || strcmp(yytext, "foreach")==0);
1007 BEGIN(FuncCall);
1008 }
static void incrementFlowKeyWordCount(yyscan_t yyscanner)
1009<Body>{FLOWKW}/([^a-z_A-Z0-9]) {
1013 if (yyextra->inFunctionTryBlock && (
dstrcmp(yytext,
"catch")==0 ||
dstrcmp(yytext,
"finally")==0))
1014 {
1015 yyextra->inFunctionTryBlock=false;
1016 }
1017 }
1018<Body>{FLOWCONDITION}/([^a-z_A-Z0-9]) {
1023 if (yyextra->inFunctionTryBlock && (strcmp(yytext,"catch")==0 || strcmp(yytext,"finally")==0))
1024 {
1025 yyextra->inFunctionTryBlock=false;
1026 }
1027 }
1028<Body>{FLOWKW}/{B}* {
1032 }
1033<Body>{FLOWCONDITION}/{B}* {
1038 }
1039<Body>"*"{B}*")" { // end of cast?
1040 yyextra->code->codify(yytext);
1041 yyextra->theCallContext.popScope(yyextra->name, yyextra->type, yyextra->bracketCount);
1042 yyextra->bracketCount--;
1043 yyextra->parmType = yyextra->name;
1044 BEGIN(FuncCall);
1045 }
1046<Body>"\\)"|"\\(" {
1047 yyextra->code->codify(yytext);
1048 }
1049<Body>[\\|\)\+\-\/\%\~\!] {
1050 yyextra->code->codify(yytext);
1051 yyextra->name.clear();yyextra->type.clear();
1052 if (*yytext==')')
1053 {
1054 yyextra->theCallContext.popScope(yyextra->name, yyextra->type, yyextra->bracketCount);
1055 yyextra->bracketCount--;
1056 if (yyextra->bracketCount<=0)
1057 {
1058 BEGIN(FuncCall);
1059 }
1060 }
1061 }
1062<Body,TemplDecl,ObjCMethod>{TYPEKW}/{B}* {
1064 yyextra->code->codify(yytext);
1067 yyextra->name+=yytext;
1068 }
1069<Body,TemplDecl,ObjCMethod>{TYPEKWSL}/{B}* {
1070 if (yyextra->lang!=SrcLangExt::Slice)
1071 {
1072 REJECT;
1073 }
1074 else
1075 {
1077 yyextra->code->codify(yytext);
1080 yyextra->name+=yytext;
1081 }
1082 }
1083<Body>"generic"/{B}*"<"[^\n\/\-\.\{\">]*">"{B}* {
1085 yyextra->code->codify(yytext);
1087 yyextra->sharpCount=0;
1088 BEGIN(TemplDecl);
1089 }
1090<Body>"template"/{B}*"<"[^\n\/\-\.\{\">]*">"{B}* { // template<...>
1092 yyextra->code->codify(yytext);
1094 yyextra->sharpCount=0;
1095 BEGIN(TemplDecl);
1096 }
1097<TemplDecl>"class"|"typename" {
1101 }
1102<TemplDecl>"<" {
1103 yyextra->code->codify(yytext);
1104 yyextra->sharpCount++;
1105 }
1106<TemplDecl>">" {
1107 yyextra->code->codify(yytext);
1108 yyextra->sharpCount--;
1109 if (yyextra->sharpCount<=0)
1110 {
1111 BEGIN(Body);
1112 }
1113 }
1114<TemplCast>">" {
1118 BEGIN( yyextra->lastTemplCastContext );
1119 }
1120<TemplCast>{ID}("::"{ID})* {
1122 }
1123<TemplCast>("const"|"volatile"){B}* {
1127 }
1128<TemplCast>[*^]* {
1130 }
1131<Body,MemberCall2,FuncCall>{CASTKW}{B}*"<" { // static_cast<T>(
1135 yyextra->lastTemplCastContext = YY_START;
1136 BEGIN(TemplCast);
1137 }
1138<Body>"$this->"{SCOPENAME}/{BN}*[;,)\]] { // PHP member variable
1141 yyextra->name+=yytext+7;
1142 }
static void generatePHPVariableLink(yyscan_t yyscanner, OutputCodeList &ol, const char *varName)
1143<Body,TemplCast>{SCOPENAME}{B}*"<"[^\n\/\-\.\{\">\(']*">"{ENDIDopt}/{B}* { // A<T> *pt;
1145 {
1146 REJECT;
1147 }
1150 yyextra->name+=yytext;
1151 }
static bool isCastKeyword(const char *s)
1152<ModuleName,ModuleImport>{MODULE_ID}({BN}*":"{BN}*{MODULE_ID})? {
1154 size_t i = name.
find(
':');
1157 {
1160 }
1162 if (mod)
1163 {
1165 }
1166 else
1167 {
1169 }
1170 }
static ModuleManager & instance()
ModuleDef * getPrimaryInterface(const DString &moduleName) const
1171<ModuleName>":"{BN}+"private" {
1173 size_t i=text.
find(
'p');
1178 }
1179<ModuleName>";" { yyextra->code->codify(yytext); BEGIN(Body); }
1180<ModuleName>. { yyextra->code->codify(yytext); }
1181<ModuleName>\n { codifyLines(yyscanner,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); }
1186
1187<Body>{SCOPENAME}/{BN}*[:;,)\]] { // "int var;" or "var, var2" or "debug(f) macro" , or int var : 5;
1189 {
1190 REJECT;
1191 }
1194 yyextra->name+=yytext;
1195 }
static bool startsWithKeyword(const DString &str, const DString &kw)
1196<Body>{ID}("."{ID})+/{BN}+ { // CSharp/Java scope
1197 if (yyextra->lang==SrcLangExt::CSharp || yyextra->lang==SrcLangExt::Java)
1198 {
1201 yyextra->name+=yytext;
1202 }
1203 else
1204 {
1205 REJECT;
1206 }
1207 }
1208<Body>"export"/{B}* {
1209 if (yyextra->lang!=SrcLangExt::Cpp) REJECT;
1213 }
1214<Body>{SCOPENAME}/{B}* { // p->func()
1216 {
1217 REJECT;
1218 }
1221 yyextra->name+=yytext;
1222 }
1223<Body>"("{B}*("*"{B}*)+{SCOPENAME}+{B}*")"/{B}* { // (*p)->func() but not "if (p) ..."
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);
1230 }
1231<Body>{SCOPETNAME}{B}*"<"[^\n\/\-\.\{\">]*">"/{BN}*"(" |
1232<Body>{SCOPETNAME}/{BN}*"(" { // a() or c::a() or t<A,B>::a() or A\B\foo()
1234 {
1235 REJECT;
1236 }
1239 yyextra->bracketCount=0;
1240 yyextra->args.clear();
1241 yyextra->name+=yytext;
1242 BEGIN( FuncCall );
1243 }
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;
1253 BEGIN( RawString );
1254 }
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 );
1261 }
1262<FuncCall,Body,MemberCall,MemberCall2,SkipInits,InlineInit>{NUMBER} { //Note similar code in commentcnv.l
1263 if (yyextra->lang!=SrcLangExt::Cpp) REJECT;
1264 yyextra->code->codify(yytext);
1265 }
1266<FuncCall,Body,MemberCall,MemberCall2,SkipInits,InlineInit>\' {
1268 yyextra->code->codify(yytext);
1269 yyextra->lastStringContext=YY_START;
1270 yyextra->inForEachExpression = false;
1271 BEGIN( SkipStringS );
1272 }
1273<SkipString>[^\"\\\r\n]{1,100} {
1274 yyextra->code->codify(yytext);
1275 }
1276<SkipStringS>[^\'\\\r\n]{1,100} {
1277 yyextra->code->codify(yytext);
1278 }
1279<SkipString,SkipStringS>{CPPC}|{CCS} {
1280 yyextra->code->codify(yytext);
1281 }
1282<SkipString>@?\" {
1283 yyextra->code->codify(yytext);
1284 if (yyextra->lastStringContext!=SkipCPP)
1285 {
1287 }
1288 BEGIN( yyextra->lastStringContext );
1289 }
1290<SkipStringS>\' {
1291 yyextra->code->codify(yytext);
1293 BEGIN( yyextra->lastStringContext );
1294 }
1295<SkipString,SkipStringS>\\. {
1296 yyextra->code->codify(yytext);
1297 }
1298<RawString>{RAWEND} {
1299 yyextra->code->codify(yytext);
1301 {
1302 BEGIN( yyextra->lastStringContext );
1303 }
1304 }
DString extractEndRawStringDelimiter(const char *rawEnd)
1305<RawString>[^)\n]+ { yyextra->code->codify(yytext); }
1306<RawString>. { yyextra->code->codify(yytext); }
1307<RawString>\n { codifyLines(yyscanner,yytext); }
1308<SkipVerbString>[^"\n]+ {
1309 yyextra->code->codify(yytext);
1310 }
1311<SkipVerbString>\"\" { // escaped quote
1312 yyextra->code->codify(yytext);
1313 }
1314<SkipVerbString>\" { // end of string
1315 yyextra->code->codify(yytext);
1317 BEGIN( yyextra->lastVerbStringContext );
1318 }
1319<SkipVerbString>. {
1320 yyextra->code->codify(yytext);
1321 }
1322<SkipVerbString>\n {
1324 }
1325<Body>":" {
1326 yyextra->code->codify(yytext);
1327 yyextra->name.clear();yyextra->type.clear();
1328 }
1329<Body>"<" {
1330 if (yyextra->insideTemplate)
1331 {
1332 yyextra->sharpCount++;
1333 }
1334 yyextra->code->codify(yytext);
1335 }
1336<Body>">" {
1337 if (yyextra->insideTemplate)
1338 {
1339 if (--yyextra->sharpCount<=0)
1340 {
1341 yyextra->insideTemplate=false;
1342 }
1343 }
1344 yyextra->code->codify(yytext);
1345 }
1346<Body,MemberCall,MemberCall2,FuncCall,OldStyleArgs>"'"((\\0[Xx0-9]+)|(\\.)|(.))"'" {
1348 yyextra->code->codify(yytext);
1350 }
1351<Body>"."|"->" {
1352 if (yytext[0]=='-')
1353 {
1355 }
1356 yyextra->code->codify(yytext);
1357 yyextra->memCallContext = YY_START;
1358 BEGIN( MemberCall );
1359 }
static void updateCallContextForSmartPointer(yyscan_t yyscanner)
1360<MemberCall>{SCOPETNAME}/{BN}*"(" {
1362 if (yyextra->theCallContext.getScope().globalDef())
1363 {
1365 {
1368 }
1369 yyextra->name.clear();
1370 }
1371 else
1372 {
1375 yyextra->name.clear();
1376 }
1377 yyextra->type.clear();
1378 if (yyextra->memCallContext==Body)
1379 {
1380 BEGIN(FuncCall);
1381 }
1382 else
1383 {
1384 BEGIN(yyextra->memCallContext);
1385 }
1386 }
1387<MemberCall>{SCOPENAME}/{B}* {
1388 if (yyextra->theCallContext.getScope().globalDef())
1389 {
1390 DBG_CTX((stderr,
"yyextra->theCallContext.getClass()=%p\n",(
void*)yyextra->theCallContext.getScope().globalDef()));
1392 {
1395 }
1396 yyextra->name.clear();
1397 }
1398 else
1399 {
1400 DBG_CTX((stderr,
"no class context!\n"));
1403 yyextra->name.clear();
1404 }
1405 yyextra->type.clear();
1406 BEGIN(yyextra->memCallContext);
1407 }
1408<Body>[,=;\[{] {
1409 if (yyextra->insideObjC && *yytext=='[')
1410 {
1411 DBG_CTX((stderr,
"Found start of ObjC call!\n"));
1412
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;
1423 unput('[');
1424 BEGIN(ObjCCall);
1425 }
1426 else
1427 {
1428 if (*yytext!='{') yyextra->code->codify(yytext);
1429 yyextra->saveName = yyextra->name;
1430 yyextra->saveType = yyextra->type;
1431 if (*yytext!='[' && !yyextra->type.empty())
1432 {
1433
1434
1435 {
1436
1437
1438 addVariable(yyscanner,yyextra->type,yyextra->name);
1439 }
1440 yyextra->name.clear();
1441 }
1442 if (*yytext==';' || *yytext=='=' || *yytext=='{')
1443 {
1444 yyextra->type.clear();
1445 yyextra->name.clear();
1446 }
1447 else if (*yytext=='[')
1448 {
1449 yyextra->theCallContext.pushScope(yyextra->name, yyextra->type, yyextra->bracketCount);
1450 }
1451 yyextra->args.clear();
1452 yyextra->parmType.clear();
1453 yyextra->parmName.clear();
1454 if (*yytext=='{')
1455 {
1456 BEGIN( BodyVar );
1457 unput('{');
1458 }
1459 }
1460 }
1461<Body,FuncCall,BodyVar>"{" {
1462 yyextra->theVarContext.pushScope();
1463 yyextra->theCallContext.pushScope(yyextra->name, yyextra->type, yyextra->bracketCount);
1464 yyextra->bracketCount = 0;
1465
1468 {
1469 DBG_CTX((stderr,
"** scope stack push SCOPEBLOCK\n"));
1472 }
1473 else
1474 {
1475 DBG_CTX((stderr,
"** scope stack push INNERBLOCK\n"));
1477 }
1478
1479 if (yyextra->searchingForBody)
1480 {
1481 yyextra->searchingForBody=false;
1482 yyextra->insideBody=true;
1483 }
1484 yyextra->code->codify(yytext);
1485 if (yyextra->insideBody)
1486 {
1487 yyextra->bodyCurlyCount++;
1488 }
1489 yyextra->type.clear();
1490 yyextra->name.clear();
1491 BEGIN( Body );
1492 }
1493<ObjCCall,ObjCMName>"["|"{" {
1495 yyextra->currentCtx->format+=*yytext;
1496 BEGIN(ObjCCall);
1498 }
static void saveObjCContext(yyscan_t yyscanner)
1499<ObjCCall,ObjCMName>"]"|"}" {
1500 yyextra->currentCtx->format+=*yytext;
1502 BEGIN(ObjCMName);
1503 if (yyextra->currentCtx==nullptr)
1504 {
1505
1507 auto it = yyextra->contextMap.find(0);
1508 if (it!=yyextra->contextMap.end())
1509 {
1510 ctx = it->second.get();
1511 }
1513 BEGIN(Body);
1514 }
1516 }
static void restoreObjCContext(yyscan_t yyscanner)
1517<ObjCCall,ObjCMName>{CPPC}.* {
1518 yyextra->currentCtx->format+=
escapeComment(yyscanner,yytext);
1519 }
static DString escapeComment(yyscan_t yyscanner, const DString &s)
1520<ObjCCall,ObjCMName>{CCS} {
1521 yyextra->lastObjCCallContext = YY_START;
1522 yyextra->currentCtx->comment.str(yytext);
1523 BEGIN(ObjCCallComment);
1524 }
1525<ObjCCallComment>{CCE} {
1526 yyextra->currentCtx->comment << yytext;
1527 yyextra->currentCtx->format+=
escapeComment(yyscanner,yyextra->currentCtx->comment.str());
1528 BEGIN(yyextra->lastObjCCallContext);
1529 }
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)
1537 {
1538 yyextra->currentCtx->objectTypeOrName=yytext;
1539 DBG_CTX((stderr,
"new type=%s\n",
qPrint(yyextra->currentCtx->objectTypeOrName)));
1540 BEGIN(ObjCMName);
1541 }
1542 }
static DString escapeObject(yyscan_t yyscanner, const DString &s)
1543<ObjCMName>{ID}/{BN}*"]" {
1544 if (yyextra->braceCount==0 &&
1545 yyextra->currentCtx->methodName.empty())
1546 {
1547 yyextra->currentCtx->methodName=yytext;
1548 yyextra->currentCtx->format+=
escapeName(yyscanner,yytext);
1549 }
1550 else
1551 {
1552 yyextra->currentCtx->format+=
escapeWord(yyscanner,yytext);
1553 }
1554 }
static DString escapeName(yyscan_t yyscanner, const DString &s)
static DString escapeWord(yyscan_t yyscanner, const DString &s)
1555<ObjCMName>{ID}/{BN}*":" {
1556 if (yyextra->braceCount==0)
1557 {
1558 yyextra->currentCtx->methodName+=yytext;
1559 yyextra->currentCtx->methodName+=":";
1560 }
1561 yyextra->currentCtx->format+=
escapeName(yyscanner,yytext);
1562 }
1563<ObjCSkipStr>[^\n\"$\\]* { yyextra->currentCtx->format+=yytext; }
1564<ObjCSkipStr>\\. { yyextra->currentCtx->format+=yytext; }
1565<ObjCSkipStr>"\"" { yyextra->currentCtx->format+=yytext;
1566 BEGIN(yyextra->lastStringContext);
1567 }
1568<ObjCCall,ObjCMName>{CHARLIT} { yyextra->currentCtx->format+=yytext; }
1569<ObjCCall,ObjCMName>"@"?"\"" { yyextra->currentCtx->format+=yytext;
1570 yyextra->lastStringContext=YY_START;
1571 BEGIN(ObjCSkipStr);
1572 }
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>"@"/"\"" { // needed to prevent matching the global rule (for C#)
1577 yyextra->currentCtx->format+=yytext;
1578 }
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; }
1582
1583<Body>"]" {
1584 yyextra->theCallContext.popScope(yyextra->name, yyextra->type, yyextra->bracketCount);
1585 yyextra->code->codify(yytext);
1586
1587 yyextra->name = yyextra->saveName;
1588 yyextra->type = yyextra->saveType;
1589 }
1590<Body>[0-9]+ {
1591 yyextra->code->codify(yytext);
1592 }
1593<Body>[0-9]+[xX][0-9A-Fa-f]+ {
1594 yyextra->code->codify(yytext);
1595 }
1596<MemberCall2,FuncCall>{KEYWORD}/([^a-z_A-Z0-9]) {
1597
1598
1601 yyextra->code->codify(yytext);
1603 }
1604<MemberCall2,FuncCall,OldStyleArgs,TemplCast>{TYPEKW}/([^a-z_A-Z0-9]) {
1606 yyextra->parmName=yytext;
1608 yyextra->code->codify(yytext);
1610 }
static void addParmType(yyscan_t yyscanner)
1611<MemberCall2,FuncCall,OldStyleArgs,TemplCast>{TYPEKWSL}/([^a-z_A-Z0-9]) {
1612 if (yyextra->lang!=SrcLangExt::Slice)
1613 {
1614 REJECT;
1615 }
1616 else
1617 {
1619 yyextra->parmName=yytext;
1621 yyextra->code->codify(yytext);
1623 }
1624 }
1625<MemberCall2,FuncCall>{FLOWKW}/([^a-z_A-Z0-9]) {
1627 yyextra->parmName=yytext;
1629 yyextra->code->codify(yytext);
1631 }
1632<MemberCall2,FuncCall>{FLOWCONDITION}/([^a-z_A-Z0-9]) {
1635 yyextra->parmName=yytext;
1637 yyextra->code->codify(yytext);
1639 }
1640<MemberCall2,FuncCall>("::")?{ID}(({B}*"<"[^\n\[\](){}<>']*">")?({B}*"::"{B}*{ID})?)* {
1642 {
1643 REJECT;
1644 }
1646 yyextra->parmName=yytext;
1648 }
1649<FuncCall>";" { // probably a cast, not a function call
1650 yyextra->code->codify(yytext);
1651 yyextra->inForEachExpression = false;
1652 BEGIN( Body );
1653 }
1654<MemberCall2,FuncCall>, {
1655 yyextra->code->codify(yytext);
1656 addVariable(yyscanner,yyextra->parmType,yyextra->parmName);
1657 yyextra->parmType.clear();yyextra->parmName.clear();
1658 }
1659<MemberCall2,FuncCall>"{" {
1660 if (yyextra->bracketCount>0)
1661 {
1662 yyextra->code->codify(yytext);
1663 yyextra->skipInlineInitContext=YY_START;
1664 yyextra->curlyCount=0;
1665 BEGIN(InlineInit);
1666 }
1667 else
1668 {
1669 REJECT;
1670 }
1671 }
1672<InlineInit>"{" { yyextra->curlyCount++;
1673 yyextra->code->codify(yytext);
1674 }
1675<InlineInit>"}" {
1676 yyextra->code->codify(yytext);
1677 if (--yyextra->curlyCount<=0)
1678 {
1679 BEGIN(yyextra->skipInlineInitContext);
1680 }
1681 }
1682<InlineInit>\n {
1684 }
1685<InlineInit>. {
1686 yyextra->code->codify(yytext);
1687 }
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)
1694 {
1695 yyextra->theVarContext.pushScope();
1696 }
1697 }
1698<MemberCall2,FuncCall>{OPERATOR} { // operator
1703 {
1704
1705 yyextra->parmType.clear();yyextra->parmName.clear();
1706 }
1707 yyextra->code->codify(yytext);
1708 }
1709<MemberCall,MemberCall2,FuncCall>("*"{B}*)?")" {
1710 if (yytext[0]==')')
1711 {
1712 DBG_CTX((stderr,
"addVariable(%s,%s)\n",
qPrint(yyextra->parmType),
qPrint(yyextra->parmName)));
1713 if (yyextra->parmType.empty())
1714 {
1715 yyextra->parmType=yyextra->parmName;
1716 yyextra->parmName.clear();
1717 }
1718 addVariable(yyscanner,yyextra->parmType,yyextra->parmName);
1719 }
1720 else
1721 {
1722 yyextra->parmType = yyextra->parmName;
1723 yyextra->parmName.clear();
1724 addVariable(yyscanner,yyextra->parmType,yyextra->parmName);
1725 }
1726 yyextra->theCallContext.popScope(yyextra->name, yyextra->type, yyextra->bracketCount);
1727 yyextra->inForEachExpression = false;
1728
1729 yyextra->code->codify(yytext);
1730 if (--yyextra->bracketCount<=0)
1731 {
1732 if (yyextra->name.empty())
1733 {
1734 BEGIN( Body );
1735 }
1736 else
1737 {
1738 BEGIN( CallEnd );
1739 }
1740 }
1741 }
1742<MemberCall,MemberCall2,FuncCall>[;:] { // recover from unexpected end of call
1743
1744 if (yyextra->bracketCount<=0)
1745 {
1746 unput(*yytext);
1747 BEGIN(CallEnd);
1748 }
1749 else
1750 {
1751 yyextra->code->codify(yytext);
1752 }
1753 }
1754<CallEnd>[ \t\n]* { codifyLines(yyscanner,yytext); }
1755<CallEnd>[;:] {
1757 yyextra->bracketCount=0;
1758 if (*yytext==';') yyextra->searchingForBody=false;
1759 if (!yyextra->type.empty())
1760 {
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);
1763 }
1764 yyextra->parmType.clear();yyextra->parmName.clear();
1766 if (*yytext==';' || yyextra->insideBody)
1767 {
1768 if (!yyextra->insideBody)
1769 {
1770 yyextra->theVarContext.popScope();
1771 }
1772 yyextra->name.clear();yyextra->type.clear();
1773 BEGIN( Body );
1774 }
1775 else
1776 {
1777 yyextra->bracketCount=0;
1778 BEGIN( SkipInits );
1779 }
1780 }
1781<CallEnd>"=>" { // C# Expression Body
1782 if (yyextra->lang!=SrcLangExt::CSharp || yyextra->insideBody)
1783 {
1784 REJECT;
1785 }
1786 else
1787 {
1788 yyextra->code->codify("=>");
1789 BEGIN( Body );
1790 }
1791 }
1792<CallEnd>{ENDQopt}/{BN}*(";"|"="|"throw"{BN}*"(") {
1796 }
1797<CallEnd,OldStyleArgs>("const"|"volatile"|"sealed"|"override")*({BN}+("const"|"volatile"|"sealed"|"override"))*{BN}*"{" {
1798 if (yyextra->insideBody)
1799 {
1800 yyextra->theVarContext.pushScope();
1801 }
1802 addVariable(yyscanner,yyextra->parmType,yyextra->parmName);
1803
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)));
1808 {
1810 if (!yyextra->scopeName.empty()) scope.
prepend((yyextra->scopeName+
"::"));
1812 if (cd)
1813 {
1816 DBG_CTX((stderr,
"** scope stack push SCOPEBLOCK\n"));
1817 }
1818 else
1819 {
1820
1822 DBG_CTX((stderr,
"** scope stack push INNERBLOCK\n"));
1823 }
1824 }
1825 else
1826 {
1827 DBG_CTX((stderr,
"** scope stack push INNERBLOCK\n"));
1829 }
1830 yytext[yyleng-1]='\0';
1832 if (!cv.stripWhiteSpace().empty())
1833 {
1837 }
1838 else
1839 {
1841 }
1842 yyextra->code->codify("{");
1843 if (yyextra->searchingForBody)
1844 {
1845 yyextra->searchingForBody=false;
1846 yyextra->insideBody=true;
1847 }
1848 if (yyextra->insideBody) yyextra->bodyCurlyCount++;
1849 yyextra->type.clear(); yyextra->name.clear();
1850 BEGIN( Body );
1851 }
static void setClassScope(yyscan_t yyscanner, const DString &name)
1852<CallEnd>"try" { // function-try-block
1854 yyextra->code->codify(yytext);
1856 yyextra->inFunctionTryBlock=true;
1857 }
1858<CallEnd>"requires" { // function-try-block
1860 yyextra->code->codify(yytext);
1862 }
1863<CallEnd>{ID} {
1864 if (yyextra->insideBody || !yyextra->parmType.empty())
1865 {
1866 REJECT;
1867 }
1868
1870 yyextra->parmName=yytext;
1872 BEGIN(OldStyleArgs);
1873 }
1874<OldStyleArgs>{ID} {
1876 yyextra->parmName=yytext;
1878 }
1879<OldStyleArgs>[,;] {
1880 yyextra->code->codify(yytext);
1881 addVariable(yyscanner,yyextra->parmType,yyextra->parmName);
1882 if (*yytext==';') yyextra->parmType.clear();
1883 yyextra->parmName.clear();
1884 }
1885<CallEnd,OldStyleArgs>"#" {
1887 yyextra->lastSkipCppContext = Body;
1888 yyextra->code->codify(yytext);
1889 BEGIN( SkipCPP );
1890 }
1891<CallEnd>. {
1892 unput(*yytext);
1893 if (!yyextra->insideBody)
1894 {
1895 yyextra->theVarContext.popScope();
1896 }
1897 yyextra->name.clear();yyextra->args.clear();
1898 yyextra->parmType.clear();yyextra->parmName.clear();
1899 BEGIN( Body );
1900 }
1901<SkipInits>";" {
1902 yyextra->code->codify(yytext);
1903 yyextra->type.clear(); yyextra->name.clear();
1904 BEGIN( Body );
1905 }
1906<SkipInits>"{" {
1907 yyextra->code->codify(yytext);
1908 if (yyextra->searchingForBody)
1909 {
1910 yyextra->searchingForBody=false;
1911 yyextra->insideBody=true;
1912 }
1913 if (yyextra->insideBody) yyextra->bodyCurlyCount++;
1915 {
1916 DBG_CTX((stderr,
"** scope stack push SCOPEBLOCK\n"));
1919 }
1920 else
1921 {
1922 DBG_CTX((stderr,
"** scope stack push INNERBLOCK\n"));
1924 }
1925 yyextra->type.clear(); yyextra->name.clear();
1926 BEGIN( Body );
1927 }
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);
1935 }
1936<SkipInits>{ID} {
1938 }
1939<FuncCall>{ID}/"(" {
1941 }
1942<FuncCall>{ID}/("."|"->") {
1943 yyextra->name=yytext;
1945 BEGIN( MemberCall2 );
1946 }
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 );
1953 }
1954<MemberCall2>{ID}/([ \t\n]*"(") {
1955 if (!yyextra->args.empty())
1957 else
1959 yyextra->args.clear();
1960 BEGIN( FuncCall );
1961 }
static void generateMemberLink(yyscan_t yyscanner, OutputCodeList &ol, const DString &varName, const DString &memName)
1962<MemberCall2>{ID}/([ \t\n]*("."|"->")) {
1963
1964 yyextra->name=yytext;
1966 BEGIN( MemberCall2 );
1967 }
1968<MemberCall2>"->"|"." {
1969 if (yytext[0]=='-')
1970 {
1972 }
1973 yyextra->code->codify(yytext);
1974 yyextra->memCallContext = YY_START;
1975 BEGIN( MemberCall );
1976 }
1977<SkipComment>{CCS}("!"?){CCE} {
1978 yyextra->code->codify(yytext);
1980 BEGIN( yyextra->lastCContext ) ;
1981 }
1982<SkipComment>{CPPC}|{CCS} {
1983 yyextra->code->codify(yytext);
1984 }
1985<SkipComment>[^*\/\n]+ {
1986 yyextra->code->codify(yytext);
1987 }
1988<SkipComment>[ \t]*{CCE} {
1989 yyextra->code->codify(yytext);
1991 if (yyextra->lastCContext==SkipCPP)
1992 {
1994 }
1995 BEGIN( yyextra->lastCContext ) ;
1996 }
1997<SkipCxxComment>[^\r\n]*"\\"[\r]?\n { // line continuation
1999 }
2000<SkipCxxComment>[^\r\n]+ {
2001 yyextra->code->codify(yytext);
2002 }
2003<SkipCxxComment>\r
2004<SkipCxxComment>\n {
2005 unput('\n');
2007 BEGIN( yyextra->lastCContext ) ;
2008 }
2009<SkipCxxComment>. {
2010 yyextra->code->codify(yytext);
2011 }
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);
2017 }
2018<*>\n({B}*{CPPC}[!/][^\n]*\n)+ { // remove special one-line comment
2019 if (YY_START==SkipCPP) REJECT;
2024 if (YY_START==SkipCxxComment)
2025 {
2026 BEGIN( yyextra->lastCContext ) ;
2027 }
2028 }
2029<SkipCPP>\n/(.|\n) {
2031 BEGIN( yyextra->lastSkipCppContext ) ;
2032 unput('\n');
2033 }
2034<*>\n{B}*{CPPC}"@"[{}].*\n { // remove one-line group marker
2039 if (YY_START==SkipCxxComment)
2040 {
2041 BEGIN( yyextra->lastCContext ) ;
2042 }
2043 }
2044<*>\n{B}*{CCS}"@"[{}] { // remove one-line group marker
2045
2046 if (YY_START != SkipComment && YY_START != SkipCxxComment)
2047 {
2048 yyextra->lastCContext = YY_START ;
2049 }
2052 BEGIN(SkipComment);
2053 }
2054<*>^{B}*{CPPC}"@"[{}].*\n { // remove one-line group marker
2059 }
2060<*>^{B}*{CCS}"@"[{}] { // remove multi-line group marker
2061
2062 if (YY_START != SkipComment && YY_START != SkipCxxComment)
2063 {
2064 yyextra->lastCContext = YY_START ;
2065 }
2067 yyextra->code->codify(yytext);
2068 BEGIN(SkipComment);
2069 }
2070<*>^{B}*{CPPC}[!/][^\n]* { // remove special one-line comment
2074 }
2075<*>{CPPC}[!/][^\n]* { // strip special one-line comment
2076 if (YY_START==SkipComment || YY_START==SkipString) REJECT;
2080 }
2081<*>\n{B}*{CCS}[!*]/{NCOMM} {
2082
2083 if (YY_START != SkipComment && YY_START != SkipCxxComment)
2084 {
2085 yyextra->lastCContext = YY_START ;
2086 }
2089 BEGIN(SkipComment);
2090 }
2091<*>^{B}*{CCS}"*"[*]+/[^/] {
2092
2093 if (YY_START != SkipComment && YY_START != SkipCxxComment)
2094 {
2095 yyextra->lastCContext = YY_START ;
2096 }
2097
2099 yyextra->code->codify(yytext);
2100 BEGIN(SkipComment);
2101 }
2102<*>^{B}*{CCS}[!*]/{NCOMM} { // special C comment block at a new line
2103
2104 if (YY_START != SkipComment && YY_START != SkipCxxComment)
2105 {
2106 yyextra->lastCContext = YY_START ;
2107 }
2109 yyextra->code->codify(yytext);
2110 BEGIN(SkipComment);
2111 }
2112<*>{CCS}[!*]/{NCOMM} { // special C comment block half way a line
2113 if (YY_START==SkipString) REJECT;
2114
2115 if (YY_START != SkipComment && YY_START != SkipCxxComment)
2116 {
2117 yyextra->lastCContext = YY_START ;
2118 }
2120 yyextra->code->codify(yytext);
2121 BEGIN(SkipComment);
2122 }
2123<*>{CCS}("!"?){CCE} {
2124 if (YY_START==SkipString) REJECT;
2127 yyextra->code->codify(yytext);
2129 }
2130<SkipComment>[^\*\n]+ {
2131 yyextra->code->codify(yytext);
2132 }
2133<*>{CCS} {
2135 yyextra->code->codify(yytext);
2136
2137 if (YY_START != SkipComment && YY_START != SkipCxxComment)
2138 {
2139 yyextra->lastCContext = YY_START ;
2140 }
2141 BEGIN( SkipComment ) ;
2142 }
2143<*>[$]?@\" { // C# (interpolated) verbatim string
2145 yyextra->code->codify(yytext);
2146 yyextra->lastVerbStringContext=YY_START;
2147 BEGIN(SkipVerbString);
2148 }
2149<*>{CPPC} {
2151 yyextra->code->codify(yytext);
2152 yyextra->lastCContext = YY_START ;
2153 BEGIN( SkipCxxComment ) ;
2154 }
2155<*>"("|"[" {
2156 if (yytext[0]=='(') yyextra->bracketCount++;
2157 yyextra->code->codify(yytext);
2158 yyextra->theCallContext.pushScope(yyextra->name, yyextra->type, yyextra->bracketCount);
2159 }
2160<*>")"|"]" {
2161 if (yytext[0]==')') yyextra->bracketCount--;
2162 yyextra->code->codify(yytext);
2163 yyextra->theCallContext.popScope(yyextra->name, yyextra->type, yyextra->bracketCount);
2164 }
2165<*>\n {
2167 }
2168<*>[\x80-\xFF]* { // keep utf8 characters together...
2169 yyextra->code->codify(yytext);
2170 }
2171<*>. {
2172 yyextra->code->codify(yytext);
2173 }
2174
2175%%