382 {BS}[&]*{BS}!.*\n {
383 yyextra->lineCountPrepass ++;
384 }
385<Prepass>^{BS}\n { /* skip empty lines */
386 yyextra->lineCountPrepass ++;
387 }
388<*>^.*\n { // prepass: look for line continuations
389 yyextra->functionLine = false;
390
391 DBG_CTX((stderr,
"---%s", yytext));
392
395 if (indexEnd>=0 && yytext[indexEnd]!='&')
396 {
397 indexEnd=-1;
398 }
static int getAmpersandAtTheStart(const char *buf, int length)
399
400 if (indexEnd<0)
401 {
402 if (YY_START == Prepass)
403 {
404
405
406 yyextra->inputStringPrepass+=(const char*)(yytext+(indexStart+1));
407
408
409 pushBuffer(yyscanner,yyextra->inputStringPrepass);
410 yyextra->colNr = 0;
412 }
413 else
414 {
415 yyextra->colNr = 0;
416 REJECT;
417 }
418 }
419 else
420 {
421 if (YY_START != Prepass)
422 {
423 yyextra->comments.clear();
424 yyextra->inputStringPrepass=
DString();
425 yy_push_state(Prepass,yyscanner);
426 }
static void pushBuffer(yyscan_t yyscanner, const DString &buffer)
static void pop_state(yyscan_t yyscanner)
427
428 size_t length = yyextra->inputStringPrepass.length();
429
430
431 yyextra->inputStringPrepass+=(const char*)(yytext+(indexStart+1));
432 yyextra->lineCountPrepass ++;
433
434
435 truncatePrepass(yyscanner,
static_cast<int>(length) + indexEnd - indexStart - 1);
436 }
437 }
static void truncatePrepass(yyscan_t yyscanner, int index)
438
439
440
441<String>\"|\' { // string ends with next quote without previous backspace
442 if (yytext[0]!=yyextra->stringStartSymbol)
443 {
444 yyextra->colNr -= (int)yyleng;
445 REJECT;
446 }
447 if (yy_top_state(yyscanner) == Initialization ||
448 yy_top_state(yyscanner) == ArrayInitializer)
449 {
450 yyextra->initializer+=yytext;
451 }
453 }
454<String>[\x80-\xFF]* |
455<String>. { if (yy_top_state(yyscanner) == Initialization ||
456 yy_top_state(yyscanner) == ArrayInitializer)
457 {
458 yyextra->initializer+=yytext;
459 }
460 }
461<*>\"|\' { /* string starts */
462 if (YY_START == StrIgnore)
463 { yyextra->colNr -= (int)yyleng;
464 REJECT;
465 };
466 yy_push_state(YY_START,yyscanner);
467 if (yy_top_state(yyscanner) == Initialization ||
468 yy_top_state(yyscanner) == ArrayInitializer)
469 {
470 yyextra->initializer+=yytext;
471 }
472 yyextra->stringStartSymbol=yytext[0];
473 BEGIN(String);
474 }
475
476
477
478<*>"!"/([^<>\n]|"<ff>"|"<FF>") { if (YY_START == String || YY_START == DocCopyBlock)
479 { yyextra->colNr -= (int)yyleng;
480 REJECT;
481 }
482
483
484 if ((YY_START != StrIgnore) && (YY_START != String))
485 {
486 yy_push_state(YY_START,yyscanner);
487 BEGIN(StrIgnore);
488 yyextra->debugStr="*!";
489 DBG_CTX((stderr,
"start comment %d\n",yyextra->lineNr));
490 }
491 }
492<StrIgnore>.?/\n { pop_state(yyscanner); // comment ends with endline character
493 DBG_CTX((stderr,
"end comment %d %s\n",yyextra->lineNr,
qPrint(yyextra->debugStr)));
494 }
495<StrIgnore>[\x80-\xFF]* |
496<StrIgnore>. { yyextra->debugStr+=yytext; }
497
498
499
500
501<Start,ModuleBody,SubprogBody>"use"{BS_} {
502 if (YY_START == Start)
503 {
506 yy_push_state(ModuleBody,yyscanner);
507 }
508 yy_push_state(Use,yyscanner);
509 }
510<Use>{ID} {
511 DBG_CTX((stderr,
"using dir %s\n",yytext));
512 yyextra->current->name=yytext;
513 yyextra->current->name=yyextra->current->name.lower();
514 yyextra->current->fileName = yyextra->fileName;
515 yyextra->current->section=EntryType::makeUsingDir();
516 yyextra->current_root->moveToSubEntryAndRefresh(yyextra->current);
517 yyextra->current->lang = SrcLangExt::Fortran;
519 }
520<Use>{ID}/, {
521 yyextra->useModuleName=yytext;
522 yyextra->useModuleName=yyextra->useModuleName.lower();
523 }
524<Use>,{BS}"ONLY" { BEGIN(UseOnly);
525 }
526<UseOnly>{BS},{BS} {}
527<UseOnly>{ID} {
528 yyextra->current->name= yyextra->useModuleName+"::"+yytext;
529 yyextra->current->name=yyextra->current->name.lower();
530 yyextra->current->fileName = yyextra->fileName;
531 yyextra->current->section=EntryType::makeUsingDecl();
532 yyextra->current_root->moveToSubEntryAndRefresh(yyextra->current);
533 yyextra->current->lang = SrcLangExt::Fortran;
534 }
535<Use,UseOnly>"\n" {
536 yyextra->colNr -= 1;
537 unput(*yytext);
539 }
540
541
542<Start,ModuleBody,SubprogBody>{
543^{BS}interface{IDSYM}+ { /* variable with interface prefix */ }
544^{BS}interface { yyextra->ifType = IF_SPECIFIC;
545 yy_push_state(InterfaceBody,yyscanner);
546
547
548 }
549
550^{BS}abstract{BS_}interface { yyextra->ifType = IF_ABSTRACT;
551 yy_push_state(InterfaceBody,yyscanner);
552
553
554 }
555
556^{BS}interface{BS_}{ID}{ARGS}? { yyextra->ifType = IF_GENERIC;
557 yyextra->current->bodyLine = yyextra->lineNr + yyextra->lineCountPrepass + 1;
558 yy_push_state(InterfaceBody,yyscanner);
559
560
562 name =
name.mid(9).stripWhiteSpace().lower();
564 startScope(yyscanner,yyextra->last_entry.get());
565 }
static void addInterface(yyscan_t yyscanner, DString name, InterfaceType type)
566}
567
568<InterfaceBody>^{BS}end{BS}interface({BS_}{ID})? {
569
571 {
572 yyextra->last_entry->parent()->endBodyLine = yyextra->lineNr - 1;
573 }
575 {
577 }
580 }
581<InterfaceBody>module{BS}procedure { yy_push_state(YY_START,yyscanner);
582 BEGIN(ModuleProcedure);
583 }
584<ModuleProcedure>{ID} { DString name = DString(yytext).lower();
586 {
588 startScope(yyscanner,yyextra->last_entry.get());
589 }
590
591 yyextra->current->section = EntryType::makeFunction();
592 yyextra->current->name =
name;
593 yyextra->moduleProcedures.push_back(yyextra->current);
595 }
596<ModuleProcedure>"\n" { yyextra->colNr -= 1;
597 unput(*yytext);
599 }
600<InterfaceBody>. {}
601
602
603<Start>^{BS}{CONTAINS}/({BS}|\n|!|;) {
604 if (YY_START == Start)
605 {
607 yy_push_state(ModuleBodyContains,yyscanner);
608 }
609 }
610<ModuleBody>^{BS}{CONTAINS}/({BS}|\n|!|;) { BEGIN(ModuleBodyContains); }
611<SubprogBody>^{BS}{CONTAINS}/({BS}|\n|!|;) { BEGIN(SubprogBodyContains); }
612<TypedefBody>^{BS}{CONTAINS}/({BS}|\n|!|;) { BEGIN(TypedefBodyContains); }
613
614
615<Start>block{BS}data{BS}{ID_} { //
617 yy_push_state(BlockData,yyscanner);
618 yyextra->defaultProtection = Protection::Public;
619 }
620<Start>module|program{BS_} { //
622 if (yytext[0]=='m' || yytext[0]=='M')
623 {
624 yy_push_state(Module,yyscanner);
625 }
626 else
627 {
628 yy_push_state(Program,yyscanner);
629 }
630 yyextra->defaultProtection = Protection::Public;
631 }
632<BlockData>^{BS}"end"({BS}(block{BS}data)({BS_}{ID})?)?{BS}/(\n|!|;) { // end block data
633
634
635 yyextra->defaultProtection = Protection::Public;
637 }
638<Start,ModuleBody,ModuleBodyContains>"end"({BS}(module|program)({BS_}{ID})?)?{BS}/(\n|!|;) { // end module
640 if (!
endScope(yyscanner,yyextra->current_root))
641 {
643 }
644 yyextra->defaultProtection = Protection::Public;
645 if (yyextra->global_scope)
646 {
648 {
649 yy_push_state(Start,yyscanner);
650 }
651 else
652 {
654 }
655 }
656 else
657 {
658 yy_push_state(Start,yyscanner);
660 }
662 }
static void resolveModuleProcedures(yyscan_t yyscanner, Entry *current_root)
fill empty interface module procedures with info from corresponding module subprogs
static void popBlockState(yyscan_t yyscanner)
663<Module>{ID} {
666 BEGIN(ModuleBody);
667 }
668<Program>{ID} {
671 BEGIN(ModuleBody);
672 }
673
674
675
676<ModuleBody,TypedefBody,TypedefBodyContains>private/{BS}(\n|"!") {
677 yyextra->defaultProtection = Protection::Private;
678 yyextra->current->protection = yyextra->defaultProtection ;
679 }
680<ModuleBody,TypedefBody,TypedefBodyContains>public/{BS}(\n|"!") {
681 yyextra->defaultProtection = Protection::Public;
682 yyextra->current->protection = yyextra->defaultProtection ;
683 }
684
685
686
687<ModuleBody>^{BS}type{BS}"=" {}
688<Start,ModuleBody>^{BS}type/[^a-z0-9_] {
689 if (YY_START == Start)
690 {
693 yy_push_state(ModuleBody,yyscanner);
694 }
695
696 yy_push_state(Typedef,yyscanner);
697 yyextra->current->protection = Protection::Package;
698 yyextra->typeProtection = Protection::Public;
699 yyextra->typeMode = true;
700 }
701<Typedef>{
702{COMMA} {}
703
704{BS}"::"{BS} {}
705
706abstract {
707 yyextra->current->spec.setAbstractClass(true);
708 }
709extends{ARGS} {
711 yyextra->current->extends.emplace_back(basename, Protection::Public, Specifier::Normal);
712 }
713public {
714 yyextra->current->protection = Protection::Public;
715 }
716private {
717 yyextra->current->protection = Protection::Private;
718 }
719{LANGUAGE_BIND_SPEC} {
720
721 }
722{ID} { /* type name found */
723 yyextra->current->section = EntryType::makeClass();
724 yyextra->current->spec.setStruct(true);
725 yyextra->current->name = yytext;
726 yyextra->current->fileName = yyextra->fileName;
727 yyextra->current->bodyLine = yyextra->lineNr;
728 yyextra->current->startLine = yyextra->lineNr;
729
730
731 if (yyextra->current_root &&
732 (yyextra->current_root->section.isClass() ||
733 yyextra->current_root->section.isNamespace()))
734 {
735 yyextra->current->name = yyextra->current_root->name + "::" + yyextra->current->name;
736 }
737
738
739 if( yyextra->current->protection == Protection::Package )
740 {
741 yyextra->current->protection = yyextra->defaultProtection;
742 }
743 else if( yyextra->current->protection == Protection::Public )
744 {
745 yyextra->modifiers[yyextra->current_root][yyextra->current->name.lower().str()] |=
DString(
"public");
746 }
747 else if( yyextra->current->protection == Protection::Private )
748 {
749 yyextra->modifiers[yyextra->current_root][yyextra->current->name.lower().str()] |=
DString(
"private");
750 }
751
753 startScope(yyscanner,yyextra->last_entry.get());
754 BEGIN(TypedefBody);
755 }
756}
757
758<TypedefBodyContains>{ /* Type Bound Procedures */
759^{BS}PROCEDURE{ARGS}? {
761 }
DString simplifyWhiteSpace() const
return a copy of this string with leading and trailing whitespace removed and multiple internal white...
762^{BS}final {
763 yyextra->current->spec.setFinal(true);
765 }
766^{BS}generic {
768 }
769{COMMA} {
770 }
771{ATTR_SPEC} {
773 }
774{BS}"::"{BS} {
775 }
776{ID} {
778 yyextra->modifiers[yyextra->current_root][
name.lower().str()] |= yyextra->currentModifiers;
779 yyextra->current->section = EntryType::makeFunction();
780 yyextra->current->name =
name;
781
783 {
785 }
786 else
787 {
788 yyextra->current->args =
name.lower();
789 }
790 yyextra->current->fileName = yyextra->fileName;
791 yyextra->current->bodyLine = yyextra->lineNr;
792 yyextra->current->startLine = yyextra->lineNr;
794 }
795{BS}"=>"[^(\n|\!)]* { /* Specific bindings come after the ID. */
797 size_t i = tmp.
find(
"=>");
799 {
801 }
803 if (yyextra->last_entry->type == "generic")
804 {
805
806
807
810 {
811 copyEntry(yyextra->current, yyextra->last_entry);
812 yyextra->current->name = yyextra->last_entry->name;
813 yyextra->current->section = EntryType::makeFunction();
815
819 }
820 }
821
822 yyextra->last_entry->args = tmp;
823 }
DString left(size_t len) const
824"\n" {
827 yyextra->docBlock.clear();
828 }
static void newLine(yyscan_t yyscanner)
Holds yyextra->modifiers (ie attributes) for one symbol (variable, function, etc).
829}
830
831
832<TypedefBody,TypedefBodyContains>{
833^{BS}"end"{BS}"type"({BS_}{ID})?{BS}/(\n|!|;) { /* end type definition */
834 yyextra->last_entry->parent()->endBodyLine = yyextra->lineNr;
835 if (!
endScope(yyscanner,yyextra->current_root))
836 {
838 }
839 yyextra->typeMode = false;
841 }
842^{BS}"end"{BS}/(\n|!|;) { /* incorrect end type definition */
843 warn(yyextra->fileName,yyextra->lineNr,
"Found 'END' instead of 'END TYPE'");
844 yyextra->last_entry->parent()->endBodyLine = yyextra->lineNr;
845 if (!
endScope(yyscanner,yyextra->current_root))
846 {
848 }
849 yyextra->typeMode = false;
851 }
852}
853
854
855
856<SubprogBody,SubprogBodyContains>^{BS}[0-9]*{BS}"end"({BS}{SUBPROG}({BS_}{ID})?)?{BS}/(\n|!|;) {
857
858
859
860
861
863 {
864 endScope(yyscanner,yyextra->current_root);
865 yyextra->last_entry->endBodyLine = yyextra->lineNr - 1;
866 }
867 yyextra->current_root->endBodyLine = yyextra->lineNr - 1;
868
869 if (!
endScope(yyscanner,yyextra->current_root))
870 {
872 }
873 yyextra->subrCurrent.pop_back();
877 }
878<BlockData>{
879{ID} {
880 }
881}
882<Start,ModuleBody,TypedefBody,SubprogBody,FEnum>{
883^{BS}{TYPE_SPEC}/{SEPARATE} {
884 yyextra->last_enum.reset();
885 if (YY_START == FEnum)
886 {
887 yyextra->argType = "@";
888 }
889 else
890 {
892 }
893 yyextra->current->bodyLine = yyextra->lineNr + 1;
894 yyextra->current->endBodyLine = yyextra->lineNr + yyextra->lineCountPrepass;
895
896 if (YY_START == Start)
897 {
900 yy_push_state(ModuleBody,yyscanner);
901 }
902 yy_push_state(AttributeList,yyscanner);
903 }
904{EXTERNAL_STMT}/({BS}"::"|{BS_}{ID}) {
905
906 if (YY_START == Start)
907 {
910 yy_push_state(ModuleBody,yyscanner);
911 }
915 yy_push_state(AttributeList,yyscanner);
916 }
917{ATTR_STMT}/{BS_}{ID} |
918{ATTR_STMT}/{BS}"::" {
919
920 DBG_CTX((stderr,
"5=========> Attribute statement: %s\n", yytext));
921 if (YY_START == Start)
922 {
925 yy_push_state(ModuleBody,yyscanner);
926 }
929 yyextra->argType="";
930 yy_push_state(YY_START,yyscanner);
931 BEGIN( AttributeList ) ;
932 }
933"common" {
934 if (YY_START == Start)
935 {
938 yy_push_state(ModuleBody,yyscanner);
939 }
940 }
941{ID} {
943 {
946 yy_push_state(ModuleBody,yyscanner);
947 }
948 }
std::string_view stripWhiteSpace(std::string_view s)
Given a string view s, returns a new, narrower view on that string, skipping over any leading or trai...
949^{BS}"type"{BS_}"is"/{BT_} {}
950^{BS}"type"{BS}"=" {}
951^{BS}"class"{BS_}"is"/{BT_} {}
952^{BS}"class"{BS_}"default" {}
953}
954<AttributeList>{
955{COMMA} {}
956{BS} {}
957{LANGUAGE_BIND_SPEC} {
958 yyextra->currentModifiers |= yytext;
959 }
960{ATTR_SPEC}. { /* update yyextra->current yyextra->modifiers when it is an ATTR_SPEC and not a variable name */
961
962 char chr = yytext[(int)yyleng-1];
964 {
965 yyextra->colNr -= (int)yyleng;
966 REJECT;
967 }
968 else
969 {
972 yyextra->colNr -= 1;
973 unput(yytext[(int)yyleng-1]);
974 yyextra->currentModifiers |= (tmp);
975 }
976 }
bool isId(char c)
Returns true if c is a valid character for an identifier.
977"::" { /* end attribute list */
978 BEGIN( FVariable );
979 }
980. { /* unknown attribute, consider variable name */
981
982 yyextra->colNr -= 1;
983 unput(*yytext);
984 BEGIN( FVariable );
985 }
986}
987
988<FVariable>{BS} {}
989<FVariable>{OPERATOR_ID} { /* parse operator access statements "public :: operator(==)" */
991
992
993 int currentState = YY_START;
995 int outerState = YY_START;
996 yy_push_state(currentState,yyscanner);
997 if( outerState == Start || outerState == ModuleBody )
998 {
999 if ((yyextra->current_root) &&
1000 (yyextra->current_root->section.isClass() ||
1001 yyextra->current_root->section.isNamespace()))
1002 {
1003 name = yyextra->current_root->name +
"::" +
name;
1004 }
1005 }
1006
1007 yyextra->modifiers[yyextra->current_root][
name.str()] |= yyextra->currentModifiers;
1008 }
1009<FVariable>{ID} { /* parse variable declaration */
1010
1011
1014
1015 if ((yyextra->current_root) && yyextra->current_root->section.isNamespace())
1016 {
1017 name = yyextra->current_root->name +
"::" +
name;
1018 }
1019
1020 yyextra->modifiers[yyextra->current_root][
name.lower().str()] |= yyextra->currentModifiers;
1021 yyextra->argName=
name;
1022
1024 if (!yyextra->argType.empty() && !yyextra->current_root->section.isFunction())
1025 {
1027 yyextra->current->section = EntryType::makeVariable();
1028 yyextra->current->name = yyextra->argName;
1029 yyextra->current->type = yyextra->argType;
1030 yyextra->current->fileName = yyextra->fileName;
1031 yyextra->current->bodyLine = yyextra->lineNr;
1032 yyextra->current->startLine = yyextra->lineNr;
1033 if (yyextra->argType == "@")
1034 {
1035 yyextra->current_root->copyToSubEntry(yyextra->current);
1036
1037 yyextra->last_enum = yyextra->current;
1038 yyextra->current_root->parent()->moveToSubEntryAndRefresh(yyextra->current);
1040 }
1041 else
1042 {
1044 }
1045 }
1046 else if (!yyextra->argType.empty())
1047 {
1049 if (parameter)
1050 {
1053 if (!yyextra->docBlock.empty())
1054 {
1056 }
1057 }
1058
1059 if (parameter)
1060 {
1061 yyextra->modifiers[yyextra->current_root][
name.lower().str()].type = yyextra->argType;
1062 }
1063 else
1064 {
1065 if ((yyextra->current_root->name.lower() == yyextra->argName.lower()) ||
1066 (yyextra->modifiers[yyextra->current_root->parent()][yyextra->current_root->name.lower().str()].returnName.lower() == yyextra->argName.lower()))
1067 {
1068 size_t strt = yyextra->current_root->type.find("function");
1072 {
1074 lft = "";
1075 rght = "";
1077 if ((yyextra->current_root->type.length() - strt - strlen("function"))!= 0)
1078 {
1079 rght = yyextra->current_root->type.
right(yyextra->current_root->type.length() - strt - (
int)strlen(
"function")).
stripWhiteSpace();
1080 }
1081 yyextra->current_root->type = lft;
1083 {
1084 if (yyextra->current_root->type.length() > 0) yyextra->current_root->type += " ";
1085 yyextra->current_root->type += rght;
1086 }
1087 if (yyextra->argType.stripWhiteSpace().length() > 0)
1088 {
1089 if (yyextra->current_root->type.length() > 0) yyextra->current_root->type += " ";
1090 yyextra->current_root->type += yyextra->argType.stripWhiteSpace();
1091 }
1092 if (yyextra->current_root->type.length() > 0) yyextra->current_root->type += " ";
1093 yyextra->current_root->type += "function";
1094 if (!yyextra->docBlock.empty())
1095 {
1097 }
1098 }
1099 else
1100 {
1101 yyextra->current_root->type += " " + yyextra->argType.stripWhiteSpace();
1102 }
1103 yyextra->current_root->type = yyextra->current_root->type.
stripWhiteSpace();
1104 yyextra->modifiers[yyextra->current_root][
name.lower().str()].type = yyextra->current_root->type;
1105 }
1106 else
1107 {
1108 yyextra->modifiers[yyextra->current_root][
name.lower().str()].type = yyextra->argType;
1109 }
1110 }
1111
1112
1113
1114 yyextra->current->doc.clear();
1115 yyextra->current->brief.clear();
1116 }
1117 }
DString right(size_t len) const
static void subrHandleCommentBlockResult(yyscan_t yyscanner, const DString &doc, bool brief)
Handle result description as defined after the declaration of the parameter.
static void subrHandleCommentBlock(yyscan_t yyscanner, const DString &doc, bool brief)
Handle parameter description as defined after the declaration of the parameter.
1118<FVariable>{ARGS} { /* dimension of the previous entry. */
1121 attr += yytext;
1122 yyextra->modifiers[yyextra->current_root][
name.lower().str()] |= attr;
1123 }
1124<FVariable>{COMMA} { //printf("COMMA: %d<=..<=%d\n", yyextra->colNr-(int)yyleng, yyextra->colNr);
1125
1127 }
static void updateVariablePrepassComment(yyscan_t yyscanner, int from, int to)
1128<FVariable>{BS}"=" {
1129 yy_push_state(YY_START,yyscanner);
1130 yyextra->initializer="=";
1131 yyextra->initializerScope = yyextra->initializerArrayScope = 0;
1132 BEGIN(Initialization);
1133 }
1134<FVariable>"\n" { yyextra->currentModifiers = SymbolModifiers();
1137 yyextra->docBlock.clear();
1138 }
1139<FVariable>";".*"\n" { yyextra->currentModifiers = SymbolModifiers();
1141 yyextra->docBlock.clear();
1142 yyextra->inputStringSemi =
" \n"+
DString(yytext+1);
1143 yyextra->lineNr--;
1144 pushBuffer(yyscanner,yyextra->inputStringSemi);
1145 }
1146<*>";".*"\n" {
1147 if (YY_START == FVariable) REJECT;
1148 if (YY_START == String) REJECT;
1149 if (YY_START == StrIgnore) REJECT;
1150 if (YY_START == DocBlock) REJECT;
1151 yyextra->inputStringSemi =
" \n"+
DString(yytext+1);
1152 yyextra->lineNr--;
1153 pushBuffer(yyscanner,yyextra->inputStringSemi);
1154 }
1155
1156<Initialization,ArrayInitializer>"[" |
1157<Initialization,ArrayInitializer>"(/" { yyextra->initializer+=yytext;
1158 yyextra->initializerArrayScope++;
1159 BEGIN(ArrayInitializer);
1160 }
1161<ArrayInitializer>"]" |
1162<ArrayInitializer>"/)" { yyextra->initializer+=yytext;
1163 yyextra->initializerArrayScope--;
1164 if (yyextra->initializerArrayScope<=0)
1165 {
1166 yyextra->initializerArrayScope = 0;
1167 BEGIN(Initialization);
1168 }
1169 }
1170<ArrayInitializer>. { yyextra->initializer+=yytext; }
1171<Initialization>"(" { yyextra->initializerScope++;
1172 yyextra->initializer+=yytext;
1173 }
1174<Initialization>")" { yyextra->initializerScope--;
1175 yyextra->initializer+=yytext;
1176 }
1177<Initialization>{COMMA} { if (yyextra->initializerScope == 0)
1178 {
1181 if (yyextra->last_enum)
1182 {
1183 yyextra->last_enum->initializer.str(yyextra->initializer.str());
1184 }
1185 else
1186 {
1187 if (yyextra->vtype ==
V_VARIABLE) yyextra->last_entry->initializer.str(yyextra->initializer.str());
1188 }
1189 }
1190 else
1191 {
1192 yyextra->initializer+=", ";
1193 }
1194 }
1195<Initialization>"\n"|"!" { //|
1197 if (yyextra->last_enum)
1198 {
1199 yyextra->last_enum->initializer.str(yyextra->initializer.str());
1200 }
1201 else
1202 {
1203 if (yyextra->vtype ==
V_VARIABLE) yyextra->last_entry->initializer.str(yyextra->initializer.str());
1204 }
1205 yyextra->colNr -= 1;
1206 unput(*yytext);
1207 }
1208<Initialization>. { yyextra->initializer+=yytext; }
1209
1210<*>{BS}"enum"{BS}","{BS}"bind"{BS}"("{BS}"c"{BS}")"{BS} {
1211 if (YY_START == Start)
1212 {
1215 yy_push_state(ModuleBody,yyscanner);
1216 }
1217
1218 yy_push_state(FEnum,yyscanner);
1219 yyextra->current->protection = yyextra->defaultProtection;
1220 yyextra->typeProtection = yyextra->defaultProtection;
1221 yyextra->typeMode = true;
1222
1223 yyextra->current->spec.setStruct(true);
1224 yyextra->current->name.clear();
1225 yyextra->current->args.clear();
1226 yyextra->current->name.sprintf("@%d",yyextra->anonCount++);
1227
1228 yyextra->current->section = EntryType::makeEnum();
1229 yyextra->current->fileName = yyextra->fileName;
1230 yyextra->current->startLine = yyextra->lineNr;
1231 yyextra->current->bodyLine = yyextra->lineNr;
1232 if ((yyextra->current_root) &&
1233 (yyextra->current_root->section.isClass() ||
1234 yyextra->current_root->section.isNamespace()))
1235 {
1236 yyextra->current->name = yyextra->current_root->name + "::" + yyextra->current->name;
1237 }
1238
1240 startScope(yyscanner,yyextra->last_entry.get());
1241 BEGIN( FEnum ) ;
1242 }
1243<FEnum>"end"{BS}"enum" {
1244 yyextra->last_entry->parent()->endBodyLine = yyextra->lineNr;
1245 if (!
endScope(yyscanner,yyextra->current_root))
1246 {
1248 }
1249 yyextra->typeMode = false;
1251 }
1252
1253
1254
1255<Start,ModuleBody,SubprogBody,InterfaceBody,ModuleBodyContains,SubprogBodyContains>^{BS}({PREFIX}{BS_})?{TYPE_SPEC}{BS}({PREFIX}{BS_})?/{SUBPROG}{BS_} {
1257 {
1258 addInterface(yyscanner,
"$interface$", yyextra->ifType);
1259 startScope(yyscanner,yyextra->last_entry.get());
1260 }
1261
1262
1264 yy_push_state(SubprogPrefix,yyscanner);
1265 }
1266
1267<SubprogPrefix>{BS}{SUBPROG}{BS_} {
1268
1273 BEGIN(Subprog);
1274 yyextra->current->bodyLine = yyextra->lineNr + yyextra->lineCountPrepass + 1;
1275 yyextra->current->startLine = yyextra->lineNr;
1276 }
static void addSubprogram(yyscan_t yyscanner, const DString &text)
1277
1278<Start,ModuleBody,SubprogBody,InterfaceBody,ModuleBodyContains,SubprogBodyContains>^{BS}({PREFIX}{BS_})?{SUBPROG}{BS_} {
1279
1282 {
1283 addInterface(yyscanner,
"$interface$", yyextra->ifType);
1284 startScope(yyscanner,yyextra->last_entry.get());
1285 }
1286
1289 yy_push_state(Subprog,yyscanner);
1290 yyextra->current->bodyLine = yyextra->lineNr + yyextra->lineCountPrepass + 1;
1291 yyextra->current->startLine = yyextra->lineNr;
1292 }
1293
1294<Subprog>{BS} { /* ignore white space */ }
1295<Subprog>{ID} { yyextra->current->name = yytext;
1296
1298
1299 if ((yyextra->current_root) &&
1300 (yyextra->current_root->section.isClass() ||
1301 yyextra->current_root->section.isNamespace()))
1302 {
1303 yyextra->current->name= yyextra->current_root->name + "::" + yyextra->current->name;
1304 }
1305 yyextra->modifiers[yyextra->current_root][yyextra->current->name.lower().str()].returnName = std::move(returnName);
1306
1308 {
1310 yyextra->current_root->name,
"$interface$",
DString(yytext).lower());
1311 }
1312
1313 BEGIN(Parameterlist);
1314 }
1315<Parameterlist>"(" { yyextra->current->args = "("; }
1316<Parameterlist>")" {
1317 yyextra->current->args += ")";
1320 startScope(yyscanner,yyextra->last_entry.get());
1321 BEGIN(SubprogBody);
1322 }
DString removeRedundantWhiteSpace(const DString &s)
1323<Parameterlist>{COMMA}|{BS} { yyextra->current->args += yytext;
1325 if (c)
1326 {
1327 if (!yyextra->current->argList.empty())
1328 {
1329 yyextra->current->argList.back().docs = c->
str;
1330 }
1331 }
1332 }
1333<Parameterlist>{ID} {
1334
1336
1337 yyextra->current->args += param;
1341 yyextra->current->argList.
push_back(arg);
1342 }
1343<Parameterlist>{NOARGS} {
1345
1347 startScope(yyscanner,yyextra->last_entry.get());
1348 BEGIN(SubprogBody);
1349 }
1350<SubprogBody>result{BS}\({BS}{ID} {
1351 if (yyextra->functionLine)
1352 {
1354 result= result.
mid(result.
find(
'(')+1);
1356 yyextra->modifiers[yyextra->current_root->parent()][yyextra->current_root->name.lower().str()].returnName = result;
1357 }
1358
1359 }
1360
1361
1362
1363<FVariable,SubprogBody,ModuleBody,TypedefBody,TypedefBodyContains>"!<" { /* backward docu comment */
1365 {
1366 yyextra->current->docLine = yyextra->lineNr;
1367 yyextra->docBlockJavaStyle = false;
1368 yyextra->docBlock.clear();
1371 yy_push_state(DocBackLine,yyscanner);
1372 }
1373 else
1374 {
1375
1376 if (YY_START == String)
1377 {
1378 yyextra->colNr -= (int)yyleng;
1379 REJECT;
1380 }
1381
1382
1383 if ((YY_START != StrIgnore) && (YY_START != String))
1384 {
1385 yy_push_state(YY_START,yyscanner);
1386 BEGIN(StrIgnore);
1387 yyextra->debugStr="*!";
1388 }
1389 }
1390 }
static void startCommentBlock(yyscan_t yyscanner, bool)
1391<DocBackLine>.* { // contents of yyextra->current comment line
1392 yyextra->docBlock+=yytext;
1393 }
1394<DocBackLine>"\n"{BS}"!"("<"|"!"+) { // comment block (next line is also comment line)
1395 yyextra->docBlock+="\n";
1397 }
1398<DocBackLine>"\n" { // comment block ends at the end of this line
1399
1400 yyextra->colNr -= 1;
1401 unput(*yytext);
1403 {
1404 std::shared_ptr<Entry> tmp_entry = yyextra->current;
1405
1406 if (yyextra->last_enum)
1407 {
1408 yyextra->current = yyextra->last_enum;
1409 }
1410 else
1411 {
1412 yyextra->current = yyextra->last_entry;
1413 }
1415
1416 yyextra->current = std::move(tmp_entry);
1417 }
1419 {
1421 }
1422 else if (yyextra->vtype ==
V_RESULT)
1423 {
1425 }
1427 yyextra->docBlock.clear();
1428 }
1429
1430<Start,SubprogBody,ModuleBody,TypedefBody,InterfaceBody,ModuleBodyContains,SubprogBodyContains,TypedefBodyContains,FEnum>^{BS} {
1432 }
static int computeIndent(const char *s)
1433<Start,SubprogBody,ModuleBody,TypedefBody,InterfaceBody,ModuleBodyContains,SubprogBodyContains,TypedefBodyContains,FEnum>"!>" {
1434 yy_push_state(YY_START,yyscanner);
1435 yyextra->current->docLine = yyextra->lineNr;
1436 yyextra->docBlockJavaStyle = false;
1437 if (YY_START==SubprogBody) yyextra->docBlockInBody = true;
1438 yyextra->docBlock.clear();
1441 BEGIN(DocBlock);
1442
1443 }
1444
1445
1446<DocBlock>({CMD}{CMD}){ID}/[^a-z_A-Z0-9] { // escaped command
1447 yyextra->docBlock += yytext;
1448 }
1449<DocBlock>{CMD}("f$"|"f["|"f{"|"f(") {
1450 yyextra->docBlock += yytext;
1451 yyextra->docBlockName=&yytext[1];
1452 if (yyextra->docBlockName.at(1)=='[')
1453 {
1454 yyextra->docBlockName.at(1)=']';
1455 }
1456 if (yyextra->docBlockName.at(1)=='{')
1457 {
1458 yyextra->docBlockName.at(1)='}';
1459 }
1460 if (yyextra->docBlockName.at(1)=='(')
1461 {
1462 yyextra->docBlockName.at(1)=')';
1463 }
1464 yyextra->fencedSize=0;
1466 BEGIN(DocCopyBlock);
1467 }
1468<DocBlock>{CMD}"ifile"{B}+"\""[^\n\"]+"\"" {
1469 yyextra->fileName = &yytext[6];
1470 yyextra->fileName = yyextra->fileName.stripWhiteSpace();
1471 yyextra->fileName = yyextra->fileName.mid(1,yyextra->fileName.length()-2);
1472 yyextra->docBlock += yytext;
1473 }
1474<DocBlock>{CMD}"ifile"{B}+{FILEMASK} {
1475 yyextra->fileName = &yytext[6];
1476 yyextra->fileName = yyextra->fileName.stripWhiteSpace();
1477 yyextra->docBlock += yytext;
1478 }
1479<DocBlock>{CMD}"iline"{LINENR}/[\n\.] |
1480<DocBlock>{CMD}"iline"{LINENR}{B} {
1481 bool ok = false;
1483 if (!ok)
1484 {
1485 warn(yyextra->fileName,yyextra->lineNr,
"Invalid line number '{}' for iline command",yytext);
1486 }
1487 else
1488 {
1489 yyextra->lineNr = nr;
1490 }
1491 yyextra->docBlock += yytext;
1492 }
int toInt(bool *ok=nullptr, int base=10) const
1493<DocBlock>{B}*"<"{PRE}">" {
1494 yyextra->docBlock += yytext;
1495 yyextra->docBlockName="<pre>";
1496 yyextra->fencedSize=0;
1498 BEGIN(DocCopyBlock);
1499 }
1500<DocBlock>{B}*"<"<CODE>">" {
1501 yyextra->docBlock += yytext;
1502 yyextra->docBlockName="<code>";
1503 yyextra->fencedSize=0;
1505 BEGIN(DocCopyBlock);
1506 }
1507<DocBlock>{CMD}"startuml"/[^a-z_A-Z0-9\-] { // verbatim command
1508 yyextra->docBlock += yytext;
1509 yyextra->docBlockName="uml";
1510 yyextra->fencedSize=0;
1512 BEGIN(DocCopyBlock);
1513 }
1514<DocBlock>{CMD}("verbatim"|"iliteral"|"latexonly"|"htmlonly"|"xmlonly"|"manonly"|"rtfonly"|"docbookonly"|"dot"|"msc"|"mermaid"|"code")/[^a-z_A-Z0-9\-] { // verbatim command
1515 yyextra->docBlock += yytext;
1516 yyextra->docBlockName=&yytext[1];
1517 yyextra->fencedSize=0;
1519 BEGIN(DocCopyBlock);
1520 }
1521<DocBlock>"~~~"[~]* {
1523 yyextra->docBlock += pat;
1524 yyextra->docBlockName="~~~";
1525 yyextra->fencedSize=pat.
length();
1527 BEGIN(DocCopyBlock);
1528 }
1529<DocBlock>"```"[`]*/(".")?[a-zA-Z0-9#_-]+ |
1530<DocBlock>"```"[`]*/"{"[^}]+"}" |
1531<DocBlock>"```"[`]* {
1533 yyextra->docBlock += pat;
1534 yyextra->docBlockName="```";
1535 yyextra->fencedSize=pat.
length();
1537 BEGIN(DocCopyBlock);
1538 }
1539<DocBlock>"\\ilinebr "{BS} {
1541 int extraSpaces = std::max(0,static_cast<int>(yyleng-9-yyextra->curIndent-2));
1542 indent.
fill(
' ',extraSpaces);
1543
1544 yyextra->docBlock += "\\ilinebr ";
1545 yyextra->docBlock += indent;
1546 }
DString fill(char c, size_t len)
Fills a string with a predefined character.
1547
1548<DocBlock>[^@*`~\/\\\n]+ { // any character that isn't special
1549 yyextra->docBlock += yytext;
1550 }
1551<DocBlock>"\n"{BS}"!"(">"|"!"+) { // comment block (next line is also comment line)
1552 yyextra->docBlock+="\n";
1554 }
1555<DocBlock>"\n" { // comment block ends at the end of this line
1556
1557 yyextra->colNr -= 1;
1558 unput(*yytext);
1561 }
1562<DocBlock>. { // command block
1563 yyextra->docBlock += *yytext;
1564 }
1565
1566
1567
1568<DocCopyBlock>"</"{PRE}">" { // end of a <pre> block
1569 yyextra->docBlock += yytext;
1570 if (yyextra->docBlockName=="<pre>")
1571 {
1572 yyextra->docBlockName="";
1574 BEGIN(DocBlock);
1575 }
1576 }
1577<DocCopyBlock>"</"{CODE}">" { // end of a <code> block
1578 yyextra->docBlock += yytext;
1579 if (yyextra->docBlockName=="<code>")
1580 {
1581 yyextra->docBlockName="";
1583 BEGIN(DocBlock);
1584 }
1585 }
1586<DocCopyBlock>{CMD}("f$"|"f]"|"f}"|"f)") {
1587 yyextra->docBlock += yytext;
1588 if (yyextra->docBlockName==&yytext[1])
1589 {
1590 yyextra->docBlockName="";
1592 BEGIN(DocBlock);
1593 }
1594 }
1595<DocCopyBlock>{CMD}("endverbatim"|"endiliteral"|"endlatexonly"|"endhtmlonly"|"endxmlonly"|"enddocbookonly"|"endmanonly"|"endrtfonly"|"enddot"|"endmsc"|"endmermaid"|"enduml"|"endcode")/[^a-z_A-Z0-9] { // end of verbatim block
1596 yyextra->docBlock += yytext;
1597 if (&yytext[4]==yyextra->docBlockName)
1598 {
1599 yyextra->docBlockName="";
1601 BEGIN(DocBlock);
1602 }
1603 }
1604
1605<DocCopyBlock>^{B}*{COMM} { // start of a comment line, just ignore the comment indicator and leading whitespace
1606 }
1607<DocCopyBlock>"~~~"[~]* {
1609 yyextra->docBlock += pat;
1610 if (yyextra->docBlockName ==
"~~~" && yyextra->fencedSize==pat.
length())
1611 {
1613 BEGIN(DocBlock);
1614 }
1615 }
1616<DocCopyBlock>"```"[`]* {
1618 yyextra->docBlock += pat;
1619 if (yyextra->docBlockName ==
"```" && yyextra->fencedSize==pat.
length())
1620 {
1622 BEGIN(DocBlock);
1623 }
1624 }
1625
1626<DocCopyBlock>[^<@/\*\]!`~"\$\\\n]+ { // any character that is not special
1627 yyextra->docBlock += yytext;
1628 }
1629<DocCopyBlock>\n { // newline
1630 yyextra->docBlock += *yytext;
1632 }
1633<DocCopyBlock>. { // any other character
1634 yyextra->docBlock += *yytext;
1635 }
1636
1637
1638<Prototype>{BS}{SUBPROG}{BS_} {
1639 BEGIN(PrototypeSubprog);
1640 }
1641<Prototype,PrototypeSubprog>{BS}{SCOPENAME}?{BS}{ID} {
1644 BEGIN(PrototypeArgs);
1645 }
1646<PrototypeArgs>{
1647"("|")"|","|{BS_} { yyextra->current->args += yytext; }
1648{ID} { yyextra->current->args += yytext;
1652 }
1653}
1654
1655
1656
1657<*>"\n" {
1659
1660 yyextra->debugStr="";
1661 }
1662
1663
1664
1665
1666<*><<EOF>> {
1667 if (yyextra->parsingPrototype)
1668 {
1670 }
1671 else if ( yyextra->includeStackPtr <= 0 )
1672 {
1673 if (YY_START!=INITIAL && YY_START!=Start)
1674 {
1675 DBG_CTX((stderr,
"==== Error: EOF reached in wrong state (end missing)"));
1677 }
1679 }
1680 else
1681 {
1683 }
1684 }
static void popBuffer(yyscan_t yyscanner)
1685<*>{LOG_OPER} { // Fortran logical comparison keywords
1686 }
1687<*>. {
1688
1689
1690 }
1691
1692
1693
1694
1695%%