283 {
284
285 ^{B}"def"{BB} {
286 DBG_CTX((stderr,
"Found def at %d\n",yyextra->yyLineNr));
289 BEGIN( FunctionDec );
290 }
291 ^{B}"async"{BB}"def"{BB} {
292 DBG_CTX((stderr,
"Found async def at %d\n",yyextra->yyLineNr));
295 BEGIN( FunctionDec );
296 }
297 "def"{BB} {
299 BEGIN( FunctionDec );
300 }
301 "async"{BB}"def"{BB} {
303 BEGIN( FunctionDec );
304 }
static void searchFoundDef(yyscan_t yyscanner)
305
306 ^{B}"class"{BB} {
307 DBG_CTX((stderr,
"Found class at %d\n",yyextra->yyLineNr));
310 BEGIN( ClassDec ) ;
311 }
312 "class"{BB} {
314 BEGIN( ClassDec ) ;
315 }
316 ^{B}"type"{BB} {
319 BEGIN( TypeAlias );
320 }
321 "type"{BB} {
323 BEGIN( TypeAlias );
324 }
325 ^{B}"from"{BB} |
326 "from"{BB} {
327 yyextra->packageCommentAllowed = false;
328 BEGIN( FromMod );
329 }
static void searchFoundTypeAlias(yyscan_t yyscanner)
static void searchFoundClass(yyscan_t yyscanner)
330
331 ^{B}"import"{BB} |
332 "import"{BB} {
333 yyextra->packageCommentAllowed = false;
334 BEGIN( Import );
335 }
336 ^{B}{IDENTIFIER}/{B}"="{B}"property" {
337 yyextra->current->section = EntryType::makeVariable();
338 yyextra->current->mtype = MethodTypes::Property;
340 yyextra->current->fileName = yyextra->fileName;
341 yyextra->current->startLine = yyextra->yyLineNr;
342 yyextra->current->bodyLine = yyextra->yyLineNr;
343 yyextra->packageCommentAllowed = false;
344 BEGIN(VariableDec);
345 }
346 ^{B}{IDENTIFIER}/{B}"="[^=] {
347 if (yyextra->searchCount>0) REJECT;
349 yyextra->current->section = EntryType::makeVariable();
351 yyextra->current->fileName = yyextra->fileName;
352 yyextra->current->startLine = yyextra->yyLineNr;
353 yyextra->current->bodyLine = yyextra->yyLineNr;
354 yyextra->packageCommentAllowed = false;
355 BEGIN(VariableDec);
356 }
357 ^{B}{IDENTIFIER}/{B}":" {
358 if (yyextra->searchCount>0) REJECT;
360 if (id =="try" || id == "else" || id == "except" || id == "finally") REJECT;
362 yyextra->current->section = EntryType::makeVariable();
363 yyextra->current->name = id;
364 yyextra->current->fileName = yyextra->fileName;
365 yyextra->current->startLine = yyextra->yyLineNr;
366 yyextra->current->bodyLine = yyextra->yyLineNr;
367 yyextra->packageCommentAllowed = false;
368 BEGIN(VariableDec);
369 }
370 {B}{IDENTIFIER}/({B},{B}{IDENTIFIER})*{B}")"*{B}"="[^=] {
371
372
373
374 if (yyextra->searchCount>1) REJECT;
376 yyextra->current->section = EntryType::makeVariable();
378 yyextra->current->fileName = yyextra->fileName;
379 yyextra->current->startLine = yyextra->yyLineNr;
380 yyextra->current->bodyLine = yyextra->yyLineNr;
381 yyextra->packageCommentAllowed = false;
383 }
384 "'" {
385 yyextra->stringContext=YY_START;
386 yyextra->copyString=nullptr;
387 yyextra->packageCommentAllowed = false;
388 BEGIN( SingleQuoteString );
389 }
390 "\"" {
391 yyextra->stringContext=YY_START;
392 yyextra->copyString=nullptr;
393 yyextra->packageCommentAllowed = false;
394 BEGIN( DoubleQuoteString );
395 }
396 "@staticmethod" {
397 yyextra->isStatic=true;
398 }
399 "@"{SCOPE}"(" {
401 yyextra->decoratorRound = 1;
402 yyextra->copyString=nullptr;
403 BEGIN( Decorator );
404 }
405 "@"{SCOPE} {
407 }
408 {SCRIPTCOMMENT} {
409 if (yyextra->yyLineNr != 1) REJECT;
410 }
411 {POUNDCOMMENT} {
412
413
414 }
415 {IDENTIFIER} {
416 yyextra->packageCommentAllowed = false;
417 }
418 ^{BB} {
420 }
DString stripWhiteSpace() const
returns a copy of this string with leading and trailing whitespace removed
#define lineCount(s, len)
static void addVariable(yyscan_t yyscanner)
421
422 {NEWLINE}+ {
424 }
425
426 {TRIDOUBLEQUOTE} {
428 BEGIN(TripleComment);
429 }
static void initTriDoubleQuoteBlock(yyscan_t yyscanner)
430
431 {TRISINGLEQUOTE} {
433 BEGIN(TripleComment);
434 }
static void initTriSingleQuoteBlock(yyscan_t yyscanner)
435
436 {B}{STARTDOCSYMS}/[^#] {
438 yyextra->packageCommentAllowed = false;
440 BEGIN(SpecialComment);
441 }
442 [(] {
443 yyextra->searchCount++;
444 }
445 [)] {
446 if (yyextra->searchCount>0)
447 {
448 yyextra->searchCount--;
449 }
450 }
451 "=" {
452 yyextra->current->doc.clear();
453 yyextra->current->brief.clear();
454 }
455 {IDENTIFIER} {
456 }
457 [^\n] {
458
459
460
461 }
462}
463
464<FromMod>{
465 "." {
466 }
467 {IDENTIFIER}({B}"."{B}{IDENTIFIER})* {
468 yyextra->packageName=yytext;
469 }
470 "import"{B} {
471 BEGIN(FromModItem);
472 }
473 \n {
475 BEGIN(Search);
476 }
477 {B} {
478 }
479 . {
480 unput(*yytext);
481 BEGIN(Search);
482 }
static void incLineNr(yyscan_t yyscanner)
483}
484
485<FromModItem>{
486 "*" {
488 BEGIN(Search);
489 }
490 {IDENTIFIER}/{B}","{B} {
492 }
493 {IDENTIFIER}/{B}")" {
495 }
496 {IDENTIFIER} {
498 if (!yyextra->importTuple)
499 {
500 BEGIN(Search);
501 }
502 }
503 \n {
505 if (!yyextra->importTuple)
506 {
507 BEGIN(Search);
508 }
509 }
510 {B} {
511 }
512 "(" {
513 yyextra->importTuple=true;
514 }
515 ")" {
516 yyextra->importTuple=false;
517 BEGIN(Search);
518 }
519 "," {
520 }
521 "\\"{B}\n {
523 }
524 . {
525 unput(*yytext);
526 BEGIN(Search);
527 }
static void addFrom(yyscan_t yyscanner, bool all)
528}
529
530<Import>{
531 {IDENTIFIER}({B}"."{B}{IDENTIFIER})* {
533 yyextra->current->fileName = yyextra->fileName;
534
535 yyextra->current->section=EntryType::makeUsingDecl();
536 yyextra->current_root->moveToSubEntryAndRefresh(yyextra->current);
538 BEGIN(Search);
539 }
540 \n {
542 BEGIN(Search);
543 }
544 {B} {
545 }
546 . {
547 unput(*yytext);
548 BEGIN(Search);
549 }
550}
551
552<SearchMemVars>{
553 ("cls"|"self")"."{IDENTIFIER}/{B}[,)] {
554 const char *s = strchr(yytext,'.'); s++;
555 DBG_CTX((stderr,
"Found instance method variable %s in %s at %d\n",s,
qPrint(yyextra->current_root->name.data(),yyextra->yyLineNr)));
558 }
559 ("cls"|"self")"."{IDENTIFIER}/{B}"=" {
560 const char *s = strchr(yytext,'.'); s++;
561 DBG_CTX((stderr,
"Found instance method variable %s in %s at %d\n",s,
qPrint(yyextra->current_root->name.data(),yyextra->yyLineNr)));
563 BEGIN( SearchSkipValue );
564 }
565 ("cls"|"self")"."{IDENTIFIER}/{B}":" {
566 const char *s = strchr(yytext,'.'); s++;
567 DBG_CTX((stderr,
"Found instance method variable %s in %s at %d\n",s,
qPrint(yyextra->current_root->name.data(),yyextra->yyLineNr)));
569 BEGIN(TypeHint);
570 }
571 {TRIDOUBLEQUOTE} {
573 BEGIN(TripleComment);
574 }
const char * qPrint(const char *s)
static void docVariable(yyscan_t yyscanner, const char *s)
575
576 {TRISINGLEQUOTE} {
578 BEGIN(TripleComment);
579 }
580
581 {STARTDOCSYMS}/[^#] {
583 BEGIN(SpecialComment);
584 }
585 {POUNDCOMMENT} {
586 }
587 "'" {
588 yyextra->stringContext=YY_START;
589 yyextra->copyString=nullptr;
590 BEGIN( SingleQuoteString );
591 }
592 "\"" {
593 yyextra->stringContext=YY_START;
594 yyextra->copyString=nullptr;
595 BEGIN( DoubleQuoteString );
596 }
598 "=" {
599 yyextra->current->doc.clear();
600 yyextra->current->brief.clear();
601 unput(*yytext);
602 BEGIN( SearchSkipValue );
603 }
604 {IDENTIFIER}
605 [^'"\.#a-z_A-Z=\n]+ // other uninteresting stuff
606 . // anything else
607}
608
609<TypeHint>{
610 ":" {
611 yyextra->braceCount=0;
612 }
613 "("|"["|"{" {
614 yyextra->current->type+=*yytext;
615 yyextra->braceCount++;
616 }
617 ")"|"]"|"}" {
618 yyextra->current->type+=*yytext;
619 yyextra->braceCount--;
620 }
621 "'" {
622 yyextra->stringContext=YY_START;
623 yyextra->copyString=nullptr;
624 BEGIN( SingleQuoteString );
625 }
626 "\"" {
627 yyextra->stringContext=YY_START;
628 yyextra->copyString=nullptr;
629 BEGIN( DoubleQuoteString );
630 }
631 "=" {
632 if (yyextra->braceCount==0)
633 {
634 yyextra->current->type = yyextra->current->type.stripWhiteSpace();
635 unput(*yytext);
636 BEGIN(SearchSkipValue);
637 }
638 else
639 {
640 yyextra->current->type+=*yytext;
641 }
642 }
643 \n {
644 yyextra->current->type = yyextra->current->type.stripWhiteSpace();
647 BEGIN(SearchMemVars);
648 }
649 "\\\n" {
650 yyextra->current->type+=' ';
652 }
653 . {
654 yyextra->current->type+=*yytext;
655 }
656}
657
658<SearchSkipValue,VariableDec,TypeValue>{
659 "=" {
660
661 yyextra->startInit = true;
662 if (YY_START!=TypeValue)
663 {
664 yyextra->current->initializer.str(yytext);
665 yyextra->current->initializer << " ";
666 }
667 }
668 {B} {
669 yyextra->current->initializer << yytext;
670 }
671
672 {INTNUMBER} {
673 if (yyextra->current->type.empty()) yyextra->current->type = "int";
674 yyextra->current->initializer << yytext;
675 }
676 {FLOATNUMBER} {
677 if (yyextra->current->type.empty()) yyextra->current->type = "float";
678 yyextra->current->initializer << yytext;
679 }
680 {BOOL} {
681 if (yyextra->current->type.empty()) yyextra->current->type = "bool";
682 yyextra->current->initializer << yytext;
683 }
684 {STRINGPREFIX}?"'" {
685 if (yyextra->current->type.empty()) yyextra->current->type = "str";
686 yyextra->current->initializer << yytext;
687 yyextra->copyString=&yyextra->current->initializer;
688 yyextra->stringContext=YY_START;
689 BEGIN( SingleQuoteString );
690 }
691 {STRINGPREFIX}?"\"" {
692 if (yyextra->current->type.empty()) yyextra->current->type = "str";
693 yyextra->current->initializer << yytext;
694 yyextra->copyString=&yyextra->current->initializer;
695 yyextra->stringContext=YY_START;
696 BEGIN( DoubleQuoteString );
697 }
698 {TRIDOUBLEQUOTE} {
699 if (yyextra->current->type.empty()) yyextra->current->type = "str";
700 yyextra->current->initializer << yytext;
701 yyextra->doubleQuote=true;
702 yyextra->copyString=&yyextra->current->initializer;
703 yyextra->stringContext=YY_START;
704 BEGIN(TripleString);
705 }
706
707 {TRISINGLEQUOTE} {
708 if (yyextra->current->type.empty()) yyextra->current->type = "str";
709 yyextra->current->initializer << yytext;
710 yyextra->doubleQuote=false;
711 yyextra->copyString=&yyextra->current->initializer;
712 yyextra->stringContext=YY_START;
713 BEGIN(TripleString);
714 }
715 "(" {
716 if (yyextra->current->mtype!=MethodTypes::Property && yyextra->startInit)
717 {
718 yyextra->current->type = "tuple";
719 }
720 yyextra->current->initializer << *yytext;
721 yyextra->atomStart='(';
722 yyextra->atomEnd=')';
723 yyextra->atomCount=1;
724 yyextra->atomContext=YY_START;
725 BEGIN( VariableAtom );
726 }
727 "[" {
728 if (yyextra->startInit) yyextra->current->type = "list";
729 yyextra->current->initializer << *yytext;
730 yyextra->atomStart='[';
731 yyextra->atomEnd=']';
732 yyextra->atomCount=1;
733 yyextra->atomContext=YY_START;
734 BEGIN( VariableAtom );
735 }
736 "{" {
737 if (yyextra->startInit) yyextra->current->type = "dict";
738 yyextra->current->initializer << *yytext;
739 yyextra->atomStart='{';
740 yyextra->atomEnd='}';
741 yyextra->atomCount=1;
742 yyextra->atomContext=YY_START;
743 BEGIN( VariableAtom );
744 }
745 "\\\n" {
746 yyextra->current->initializer << yytext;
748 }
749 {IDENTIFIER} {
750
751 if (yyextra->current->type.empty())
752 {
753 for (const auto &child : yyextra->current_root->children())
754 {
755 if (child->name == yytext)
756 {
757 yyextra->current->type = child->type;
758 break;
759 }
760 }
761 }
762 yyextra->startInit = false;
763 yyextra->current->initializer << yytext;
764 }
765 . {
766 yyextra->startInit = false;
767 yyextra->current->initializer << *yytext;
768 }
769}
770<SearchSkipValue>{
771 {STARTDOCSYMS}/[^#] {
773 BEGIN(SpecialComment);
774 }
775 {POUNDCOMMENT} {
776 }
779 BEGIN(SearchMemVars);
780 }
783 BEGIN(SearchMemVars);
784 }
785}
786
787<FunctionBody>{
791 {
794
795 BEGIN(Search);
796 }
797 else
798 {
800 yyextra->current->program << yytext;
801 }
802 }
803 \n{B}/"##" {
805 {
808
809 BEGIN(Search);
810 }
811 else
812 {
814 yyextra->current->program << yytext;
815 }
816 }
817 <<EOF>> {
820 }
821 ^{BB}/\n {
822 yyextra->current->program << yytext;
823 }
824 ^{BB} {
826 if (yyextra->curIndent<=yyextra->indent)
827
828 {
830 BEGIN(Search);
831 }
832 else
833 {
834 yyextra->current->program << yytext;
835 }
836 }
837 "'" {
838 yyextra->current->program << yytext;
839 yyextra->stringContext=YY_START;
840 yyextra->specialBlock = false;
841 yyextra->copyString=&yyextra->current->program;
842 BEGIN( SingleQuoteString );
843 }
844 "\"" {
845 yyextra->current->program << yytext;
846 yyextra->stringContext=YY_START;
847 yyextra->specialBlock = false;
848 yyextra->copyString=&yyextra->current->program;
849 BEGIN( DoubleQuoteString );
850 }
851 [^ \t\n#'".]+ { // non-special stuff
852 yyextra->current->program << yytext;
853 yyextra->specialBlock = false;
854 }
855 ^{POUNDCOMMENT} { // normal comment
856 yyextra->current->program << yytext;
857 }
858 "#".* { // comment half way
859 yyextra->current->program << yytext;
860 }
861 {NEWLINE} {
862 incLineNr(yyscanner);
863 yyextra->current->program << yytext;
864 }
865 . { // any character
866 yyextra->current->program << *yytext;
867 yyextra->specialBlock = false;
868 }
const int DIGIT
RegularExpression Id.
const int LETTER
RegularExpression Id.
static void endOfDef(yyscan_t yyscanner, int correction=0)
#define unput_string(yytext, yyleng)
869
870 {TRIDOUBLEQUOTE} {
871 yyextra->current->program << yytext;
873 BEGIN(TripleComment);
874 }
875
876 {TRISINGLEQUOTE} {
877 yyextra->current->program << yytext;
879 BEGIN(TripleComment);
880 }
881
882}
883
884<FunctionDec>{
885 {IDENTIFIER} {
886
887 yyextra->current->name = yytext;
888 yyextra->current->name = yyextra->current->name.stripWhiteSpace();
890 }
891 {B}":"{B} {
892 yyextra->specialBlock = true;
893 yyextra->bodyEntry = yyextra->current;
894 yyextra->current->bodyLine = yyextra->yyLineNr;
895 BEGIN(FunctionBody);
896 }
897 "[" {
898 yyextra->genericsContext = YY_START;
899 yyextra->bracketDepth = 1;
900 yyextra->genericsValue = "[";
901 BEGIN(Generics);
902 }
903 "->" {
904 yyextra->defVal.str(std::string());
905 yyextra->braceCount = 0;
906 BEGIN(FunctionTypeAnnotation);
907 }
908 {B}"(" {
909 yyextra->funcParamsEnd = false;
910 yyextra->current->bodyLine = yyextra->yyLineNr;
911 BEGIN(FunctionParams);
912 }
913 ")" {
914 if (yyextra->current->argList.empty())
915 {
916 yyextra->current->argList.setNoParameters(true);
917 }
919 yyextra->funcParamsEnd = true;
920 }
static void newFunction(yyscan_t yyscanner)
DString argListToString(const ArgumentList &al, bool useCanonicalType, bool showDefVals)
921}
922
923<Generics>{
924 {IDENTIFIER} {
925 yyextra->genericsValue+=yytext;
926 }
927 "[" {
928 yyextra->genericsValue+=yytext;
929 yyextra->bracketDepth++;
930 }
931 "]" {
932 yyextra->genericsValue+=yytext;
933 yyextra->bracketDepth--;
934 if (yyextra->bracketDepth==0)
935 {
936 BEGIN(yyextra->genericsContext);
937 }
938 }
939 . {
940 yyextra->genericsValue+=yytext;
941 }
942}
943
944<FunctionParams>{
945 {BB} {
946 }
947
948 "," {
949 if (!yyextra->argType.empty())
950 {
953 a.
type = yyextra->argType;
955 yyextra->argType = "";
956 }
957 }
This class contains the information about the argument of a function or template.
958
959 [\*]+ {
960 yyextra->argType = yytext;
961 }
962 {IDENTIFIER} {
966 a.
type = yyextra->argType;
968 yyextra->argType = "";
969 }
970 "=" {
971
972
973 yyextra->defVal.str(std::string());
974 yyextra->braceCount = 0;
975 BEGIN(FunctionParamDefVal);
976 }
977 ")" {
978 if (!yyextra->argType.empty())
979 {
982 a.
type = yyextra->argType;
984 yyextra->argType = "";
985 }
986 unput(*yytext);
987 BEGIN(FunctionDec);
988 }
989 ":"{B} {
990 yyextra->defVal.str(std::string());
991 yyextra->braceCount = 0;
992 BEGIN(FunctionAnnotation);
993 }
994 {STARTDOCSYMS}"<"/.* {
996 BEGIN(SpecialComment);
997 }
998 {POUNDCOMMENT} {
999 }
1000 {PARAMNONEMPTY} {
1001 }
static void handleParamComment(yyscan_t yyscanner, const DString &doc)
1002
1003}
1004
1005<FunctionTypeAnnotation>{
1006 "{" |
1007 "[" |
1008 "(" {
1009 ++yyextra->braceCount;
1010 yyextra->defVal << *yytext;
1011 }
1012 "}" |
1013 "]" |
1014 ")" {
1015 --yyextra->braceCount;
1016 yyextra->defVal << *yytext;
1017 }
1018 ":" {
1019 if (yyextra->braceCount == 0)
1020 {
1021 yyextra->current->type = yyextra->defVal.str();
1022 unput(*yytext);
1023 BEGIN(FunctionDec);
1024 }
1025 else
1026 yyextra->defVal << *yytext;
1027 }
1028 "'" {
1029 yyextra->defVal << *yytext;
1030 yyextra->copyString=&yyextra->defVal;
1031 yyextra->stringContext=FunctionTypeAnnotation;
1032 BEGIN(SingleQuoteString);
1033 }
1034 "\"" {
1035 yyextra->defVal << *yytext;
1036 yyextra->copyString=&yyextra->defVal;
1037 yyextra->stringContext=FunctionTypeAnnotation;
1038 BEGIN(DoubleQuoteString);
1039 }
1040 \n {
1041 yyextra->defVal << *yytext;
1043 }
1044 . {
1045 yyextra->defVal << *yytext;
1046 }
1047}
1048
1049<FunctionAnnotation>{
1050 "{" |
1051 "[" |
1052 "(" {
1053 ++yyextra->braceCount;
1054 yyextra->defVal << *yytext;
1055 }
1056 "}" |
1057 "]" {
1058 --yyextra->braceCount;
1059 yyextra->defVal << *yytext;
1060 }
1061 ")" |
1062 "=" |
1063 "," {
1064 if (yyextra->braceCount == 0)
1065 {
1066 if (!yyextra->current->argList.empty())
1067 yyextra->current->argList.back().type += yyextra->defVal.str();
1068 if (*yytext != ',')
1069 unput(*yytext);
1070 BEGIN(FunctionParams);
1071 }
1072 else
1073 {
1074 if (*yytext == ')')
1075 --yyextra->braceCount;
1076 yyextra->defVal << *yytext;
1077 }
1078 }
1079 "'" {
1080 yyextra->defVal << *yytext;
1081 yyextra->copyString=&yyextra->defVal;
1082 yyextra->stringContext=FunctionAnnotation;
1083 BEGIN(SingleQuoteString);
1084 }
1085 "\"" {
1086 yyextra->defVal << *yytext;
1087 yyextra->copyString=&yyextra->defVal;
1088 yyextra->stringContext=FunctionAnnotation;
1089 BEGIN(DoubleQuoteString);
1090 }
1091 \n {
1092 yyextra->defVal << *yytext;
1094 }
1095 {STARTDOCSYMS}"<"/.* {
1097 BEGIN(SpecialComment);
1098 }
1099 {POUNDCOMMENT} {
1100 }
1101 . {
1102 yyextra->defVal << *yytext;
1103 }
1104}
1105
1106<FunctionParamDefVal>{
1107 "{" |
1108 "[" |
1109 "(" {
1110 ++yyextra->braceCount;
1111 yyextra->defVal << *yytext;
1112 }
1113 "}" |
1114 "]" {
1115 --yyextra->braceCount;
1116 yyextra->defVal << *yytext;
1117 }
1118 ")" |
1119 "," {
1120 if (yyextra->braceCount == 0)
1121 {
1122 if (!yyextra->current->argList.empty())
1124 if (*yytext == ')')
1125 unput(*yytext);
1126 BEGIN(FunctionParams);
1127 }
1128 else
1129 {
1130 if (*yytext == ')')
1131 --yyextra->braceCount;
1132 yyextra->defVal << *yytext;
1133 }
1134 }
1135
1136 "'" {
1137 yyextra->defVal << *yytext;
1138 yyextra->copyString=&yyextra->defVal;
1139 yyextra->stringContext=FunctionParamDefVal;
1140 BEGIN( SingleQuoteString );
1141 }
1142 "\"" {
1143 yyextra->defVal << *yytext;
1144 yyextra->copyString=&yyextra->defVal;
1145 yyextra->stringContext=FunctionParamDefVal;
1146 BEGIN( DoubleQuoteString );
1147 }
1148 {STARTDOCSYMS}"<"/.* {
1150 BEGIN(SpecialComment);
1151 }
1152 {POUNDCOMMENT} {
1153 }
1154 \n {
1155 yyextra->defVal << *yytext;
1157 }
1158 . {
1159 yyextra->defVal << *yytext;
1160 }
1161}
1162
1163
1164<ClassBody>{
1165 \n/{IDENTIFIER}{BB} {
1167 {
1168 int i;
1169 for (i=(int)yyleng-1;i>=0;i--)
1170 {
1171 unput(yytext[i]);
1172 }
1174
1175 BEGIN(Search);
1176 }
1177 else
1178 {
1180 yyextra->current->program << yytext;
1181 }
1182 }
1183 \n/"##"[^#] {
1185 {
1186 int i;
1187 for (i=(int)yyleng-1;i>=0;i--)
1188 {
1189 unput(yytext[i]);
1190 }
1192
1193 BEGIN(Search);
1194 }
1195 else
1196 {
1198 yyextra->current->program << yytext;
1199 }
1200 }
1201 ^{BB}/\n {
1202 yyextra->current->program << yytext;
1203 }
1204 <<EOF>> {
1207 }
1208 ^{BB} {
1210 DBG_CTX((stderr,
"yyextra->curIndent=%d yyextra->indent=%d\n",yyextra->curIndent,yyextra->indent));
1211 if (yyextra->curIndent<=yyextra->indent)
1212
1213 {
1215 yyextra->indent=yyextra->curIndent;
1216
1217
1218
1219 BEGIN(Search);
1220 }
1221 else
1222 {
1223 yyextra->current->program << yytext;
1224 }
1225 }
1226 "'" {
1227 yyextra->current->program << *yytext;
1228 yyextra->stringContext=YY_START;
1229 yyextra->specialBlock = false;
1230 yyextra->copyString=&yyextra->current->program;
1231 BEGIN( SingleQuoteString );
1232 }
1233 "\"" {
1234 yyextra->current->program << *yytext;
1235 yyextra->stringContext=YY_START;
1236 yyextra->specialBlock = false;
1237 yyextra->copyString=&yyextra->current->program;
1238 BEGIN( DoubleQuoteString );
1239 }
1240 [^ \t\n#'"]+ { // non-special stuff
1241 yyextra->current->program << yytext;
1242 yyextra->specialBlock = false;
1243 //yyextra->hideClassDocs = false;
1244 }
1245 {NEWLINE} {
1246 yyextra->current->program << *yytext;
1247 incLineNr(yyscanner);
1248 }
1249 {POUNDCOMMENT} { // normal comment
1250 yyextra->current->program << yytext;
1251 }
1252 . { // any character
1253 yyextra->specialBlock = false;
1254 yyextra->current->program << *yytext;
1255 }
1256 {TRIDOUBLEQUOTE} { // start of a comment block
1257 //if (!yyextra->hideClassDocs)
1258 yyextra->current->program << yytext;
1259 initTriDoubleQuoteBlock(yyscanner);
1260 BEGIN(TripleComment);
1261 }
1262
1263 {TRISINGLEQUOTE} {
1264
1265 yyextra->current->program << yytext;
1267 BEGIN(TripleComment);
1268 }
1269}
1270
1271<TypeAlias>{
1272 {IDENTIFIER} {
1273 yyextra->current->name = yytext;
1274 }
1275 "[" {
1276 yyextra->bracketDepth=1;
1277 yyextra->genericsContext = YY_START;
1278 yyextra->genericsValue = "[";
1279 BEGIN(Generics);
1280 }
1281 "=" {
1282 yyextra->current->args = yyextra->genericsValue;
1283 BEGIN(TypeValue);
1284 }
1285}
1286<TypeValue>{
1287 \n {
1290 {
1292 }
1293 BEGIN(Search);
1294 }
1295 . {
1296 unput(*yytext);
1298 BEGIN(Search);
1299 }
1301 }
static void newTypeAlias(yyscan_t yyscanner)
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...
1302}
1303
1304<ClassDec>{IDENTIFIER} {
1305 if (yyextra->current->type.empty())
1306 {
1307 yyextra->current->type = "class";
1308 }
1309
1310 yyextra->current->section = EntryType::makeClass();
1311 yyextra->current->name = yytext;
1312
1314
1315
1316 if (yyextra->current_root->section.isScope())
1317 {
1318
1319 yyextra->current->name.prepend(yyextra->current_root->name+"::");
1320 }
1321
1322 yyextra->current->name = yyextra->current->name.stripWhiteSpace();
1323 yyextra->current->fileName = yyextra->fileName;
1324 yyextra->docBlockContext = YY_START;
1325 yyextra->docBlockInBody = false;
1326 yyextra->docBlockJavaStyle = false;
1327 yyextra->docBlock.clear();
1328 yyextra->bracketDepth = 0;
1329
1330 BEGIN(ClassInheritance);
1331 }
1332
1333<ClassInheritance>{
1334 ({BB}|[\(,\)]) {
1335 }
1336 "[" {
1337 yyextra->bracketDepth=1;
1338 yyextra->genericsContext = YY_START;
1339 yyextra->genericsValue = "[";
1340 BEGIN(Generics);
1341 }
1342 ":" {
1343 yyextra->specialBlock = true;
1344 yyextra->current->bodyLine = yyextra->yyLineNr;
1345 yyextra->current->program.str(std::string());
1346 BEGIN(ClassCaptureIndent);
1347 }
1348
1349 {SCOPE} {
1350 yyextra->current->extends.emplace_back(
1351 substitute(yytext,
".",
"::"),Protection::Public,Specifier::Normal
1352 );
1353 }
1354 "'" {
1355 yyextra->stringContext=YY_START;
1356 BEGIN( SingleQuoteStringIgnore );
1357 }
1358 "\"" {
1359 yyextra->stringContext=YY_START;
1360 BEGIN( DoubleQuoteStringIgnore );
1361 }
1362}
1363
1364<SingleQuoteStringIgnore>{
1365 "'" {
1366 BEGIN(yyextra->stringContext);
1367 }
1368 . { }
1369}
1370<DoubleQuoteStringIgnore>{
1371 "\"" {
1372 BEGIN(yyextra->stringContext);
1373 }
1374 . { }
1375}
1376
1377<ClassCaptureIndent>{
1378 "\n"|({BB}"\n") {
1379
1381 yyextra->current->program << yytext;
1382 }
1383
1384 {TRIDOUBLEQUOTE} {
1386 yyextra->current->program << yytext;
1387 BEGIN(TripleComment);
1388 }
1389 {TRISINGLEQUOTE} {
1391 yyextra->current->program << yytext;
1392 BEGIN(TripleComment);
1393 }
1394 {STARTDOCSYMS}[#]* {
1396 BEGIN(SpecialComment);
1397 }
1398 {POUNDCOMMENT} {
1399 }
1400 ^{BB} {
1401 yyextra->current->program << yytext;
1402
1404 yyextra->bodyEntry = yyextra->current;
1405 DBG_CTX((stderr,
"setting indent %d\n",yyextra->curIndent));
1406
1407
1408 BEGIN(ClassBody);
1409 }
1410
1411 ""/({NONEMPTY}|{EXPCHAR}) {
1412
1413
1415 yyextra->current->program << yytext;
1416
1417
1418 BEGIN( Search );
1419 }
1420}
1421
1422
1423<VariableDec>{
1424 ":"{B}{IDENTIFIER} {
1425 yyextra->startInit = false;
1426 yyextra->current->type =
substitute(yytext,
":",
"");
1427 }
1428 {STARTDOCSYMS}"<"/.* {
1430 yyextra->packageCommentAllowed = false;
1432 yyextra->docBlockContext = VariableEnd;
1433 BEGIN(SpecialComment);
1434 }
1435 "#".* {
1436 BEGIN( VariableEnd );
1437 }
1438 \n {
1439 unput('\n');
1440 BEGIN( VariableEnd );
1441 }
1442}
1443
1444<VariableAtom>{
1445 [\(\[\{] {
1446 yyextra->current->initializer << *yytext;
1447 if (yyextra->atomStart==*yytext)
1448 {
1449 yyextra->atomCount++;
1450 }
1451 }
1452 [\)\]\}] {
1453 yyextra->current->initializer << *yytext;
1454 if (yyextra->atomEnd==*yytext)
1455 {
1456 yyextra->atomCount--;
1457 }
1458 if (yyextra->atomCount==0)
1459 {
1460 yyextra->startInit = false;
1461 BEGIN(yyextra->atomContext);
1462 }
1463 }
1464 {TRIDOUBLEQUOTE} {
1465 yyextra->specialBlock = false;
1466 yyextra->current->program << yytext;
1468 BEGIN(TripleComment);
1469 }
1470
1471 {TRISINGLEQUOTE} {
1472 yyextra->specialBlock = false;
1473 yyextra->current->program << yytext;
1475 BEGIN(TripleComment);
1476 }
1477 "'" {
1478 yyextra->stringContext=YY_START;
1479 yyextra->current->initializer << "'";
1480 yyextra->copyString=&yyextra->current->initializer;
1481 BEGIN( SingleQuoteString );
1482 }
1483 "\"" {
1484 yyextra->stringContext=YY_START;
1485 yyextra->current->initializer << "\"";
1486 yyextra->copyString=&yyextra->current->initializer;
1487 BEGIN( DoubleQuoteString );
1488 }
1489 {IDENTIFIER} {
1490 yyextra->current->initializer << yytext;
1491 }
1492 {POUNDCOMMENT} {
1493 yyextra->current->initializer << yytext;
1494 }
1495 . {
1496 yyextra->current->initializer << *yytext;
1497 }
1498 \n {
1499 yyextra->current->initializer << *yytext;
1501 }
1502
1503}
1504
1505<VariableEnd>{
1506 \n {
1509 {
1511 }
1512 BEGIN(Search);
1513 }
1514 . {
1515 unput(*yytext);
1517 BEGIN(Search);
1518 }
1520 }
static void newVariable(yyscan_t yyscanner)
1521}
1522
1523<TripleComment>{
1524 {ENDTRIDOUBLEQUOTE} |
1525 {ENDTRISINGLEQUOTE} {
1526
1527 if (yyextra->doubleQuote==(yytext[0]=='"'))
1528 {
1529 if (yyextra->specialBlock)
1530 {
1531 DString actualDoc=yyextra->docBlock;
1532 if (!yyextra->docBlockSpecial)
1533 {
1534 if (!actualDoc.
empty())
1535 {
1537 actualDoc.
prepend(
"@iverbatim\n");
1538 actualDoc.
append(
"@endiverbatim ");
1539 }
1540 }
1541
1543 }
1544 else if (yyextra->packageCommentAllowed)
1545 {
1546 DString actualDoc=yyextra->docBlock;
1547 if (!yyextra->docBlockSpecial)
1548 {
1549 if (!actualDoc.
empty())
1550 {
1552 actualDoc.
prepend(
"@iverbatim\n");
1553 actualDoc.
append(
"@endiverbatim ");
1554 }
1555 }
1556 if (yyextra->moduleScope.startsWith("__") && yyextra->moduleScope.endsWith("__"))
1557 {
1558 actualDoc.
prepend(
"\\namespace \\"+yyextra->moduleScope+
" ");
1559 }
1560 else
1561 {
1562 actualDoc.
prepend(
"\\namespace "+yyextra->moduleScope+
" ");
1563 }
1565 }
1566 if ((yyextra->docBlockContext==ClassBody ) ||
1567 yyextra->docBlockContext==FunctionBody)
1568 {
1569 yyextra->current->program << yyextra->docBlock;
1570 yyextra->current->program << yytext;
1571 }
1572
1573
1574
1575
1576
1577 BEGIN(yyextra->docBlockContext);
1578 }
1579 else
1580 {
1581 yyextra->docBlock += yytext;
1582 }
1583 yyextra->packageCommentAllowed = false;
1584 }
DString & prepend(const char *s)
static void handleCommentBlock(yyscan_t yyscanner, const DString &doc, bool brief)
void stripIndentationVerbatim(DString &doc, size_t indentationLevel, bool skipFirstLine)
1585
1586
1587 ^{BB} {
1588 if (yyextra->firstPass && yyextra->docBlockSpecial && yyleng >= yyextra->curIndent)
1589 yyextra->docBlock += yytext + yyextra->curIndent;
1590 else
1591 yyextra->docBlock += yytext;
1592 }
1593 [^"'\n \t\\@]+ {
1594 yyextra->docBlock += yytext;
1595 }
1596 \n {
1597 incLineNr(yyscanner);
1598 yyextra->docBlock += yytext;
1599 }
1600 {CMD}"ifile"{B}+"\""[^\n\"]+"\"" {
1601 yyextra->fileName = &yytext[6];
1602 yyextra->fileName = yyextra->fileName.stripWhiteSpace();
1603 yyextra->fileName = yyextra->fileName.mid(1,yyextra->fileName.length()-2);
1604 yyextra->docBlock+=yytext;
1605 }
1606 {CMD}"ifile"{B}+{FILEMASK} {
1607 yyextra->fileName = &yytext[6];
1608 yyextra->fileName = yyextra->fileName.stripWhiteSpace();
1609 yyextra->docBlock+=yytext;
1610 }
1611 {CMD}"iline"{LINENR}/[\n\.] |
1612 {CMD}"iline"{LINENR}{B} {
1613 bool ok = false;
1615 if (!ok)
1616 {
1617 warn(yyextra->fileName,yyextra->yyLineNr,
"Invalid line number '{}' for iline command",yytext);
1618 }
1619 else
1620 {
1621 yyextra->yyLineNr = nr;
1622 }
1623 yyextra->docBlock+=yytext;
1624 }
1625 ({CMD}{CMD}){ID}/[^a-z_A-Z0-9] {
1626 yyextra->docBlock+=yytext;
1627 }
1628 \\. {
1629 yyextra->docBlock += yytext;
1630 }
1631 . {
1632 yyextra->docBlock += yytext;
1633 }
int toInt(bool *ok=nullptr, int base=10) const
1634}
1635
1636<SpecialComment>{
1637 ^{B}"#"("#")* {
1638 }
1639 \n/{B}"#" {
1640 yyextra->docBlock+='\n';
1641 yyextra->docBrief = false;
1643 }
1644 {CMD}"ifile"{B}+"\""[^\n\"]+"\"" {
1645 yyextra->fileName = &yytext[6];
1646 yyextra->fileName = yyextra->fileName.stripWhiteSpace();
1647 yyextra->fileName = yyextra->fileName.mid(1,yyextra->fileName.length()-2);
1648 yyextra->docBlock+=yytext;
1649 }
1650 {CMD}"ifile"{B}+{FILEMASK} {
1651 yyextra->fileName = &yytext[6];
1652 yyextra->fileName = yyextra->fileName.stripWhiteSpace();
1653 yyextra->docBlock+=yytext;
1654 }
1655 {CMD}"iline"{LINENR}/[\n\.] |
1656 {CMD}"iline"{LINENR}{B} {
1657 bool ok = false;
1659 if (!ok)
1660 {
1661 warn(yyextra->fileName,yyextra->yyLineNr,
"Invalid line number '{}' for iline command",yytext);
1662 }
1663 else
1664 {
1665 yyextra->yyLineNr = nr;
1666 }
1667 yyextra->docBlock+=yytext;
1668 }
1669 ({CMD}{CMD}){ID}/[^a-z_A-Z0-9] {
1670 yyextra->docBlock+=yytext;
1671 }
1672 "\\ilinebr "{B}* {
1674 int extraSpaces = std::max(0,static_cast<int>(yyleng-9-yyextra->curIndent-2));
1675 indent.
fill(
' ',extraSpaces);
1676
1677 yyextra->docBlock += "\\ilinebr ";
1678 yyextra->docBlock += indent;
1679 }
1680 [^#\\@\n]+ {
1681 yyextra->docBlock+=yytext;
1682 }
1683 \n {
1685 if (yyextra->docBlockContext == VariableEnd)
1686 {
1687 unput(*yytext);
1688 }
1689 else
1690 {
1692 }
1693 BEGIN(yyextra->docBlockContext);
1694 }
1695 . {
1696 yyextra->docBlock+=*yytext;
1697 }
DString fill(char c, size_t len)
Fills a string with a predefined character.
1698}
1699
1700<SingleQuoteString>{
1701 \\{B}\n {
1704 }
1705 \\. {
1707 }
1708 "\"\"\"" {
1710 }
1711 "'" {
1713 BEGIN(yyextra->stringContext);
1714 }
1715 [^"'\n\\]+ { // normal chars
1716 addToString(yyscanner,yytext);
1717 }
1718 . { // normal char
1719 addToString(yyscanner,yytext);
1720 }
static void addToString(yyscan_t yyscanner, const char *s)
1721}
1722
1723<DoubleQuoteString>{
1724 \\{B}\n {
1727 }
1728 \\. {
1730 }
1731 "'''" {
1733 }
1734 "\"" {
1736 BEGIN(yyextra->stringContext);
1737 }
1738 [^"'\n\\]+ { // normal chars
1739 addToString(yyscanner,yytext);
1740 }
1741 . { // normal char
1742 addToString(yyscanner,yytext);
1743 }
1744}
1745
1746<TripleString>{
1747 {ENDTRIDOUBLEQUOTE} |
1748 {ENDTRISINGLEQUOTE} {
1749 *yyextra->copyString << yytext;
1750 if (yyextra->doubleQuote==(yytext[0]=='"'))
1751 {
1752 BEGIN(yyextra->stringContext);
1753 }
1754 }
1755
1756
1757 ({LONGSTRINGBLOCK}) {
1759 *yyextra->copyString << yytext;
1760 }
1761 \n {
1763 *yyextra->copyString << yytext;
1764 }
1765 . {
1766 *yyextra->copyString << *yytext;
1767 }
1768}
1769
1770<Decorator>{
1771 {TRIDOUBLEQUOTE} {
1772 yyextra->doubleQuote=true;
1773 yyextra->decoratorCommentStr.str(std::string());
1774 yyextra->copyString=&yyextra->decoratorCommentStr;
1775 yyextra->stringContext=YY_START;
1776 BEGIN(TripleString);
1777 }
1778
1779 {TRISINGLEQUOTE} {
1780 yyextra->doubleQuote=false;
1781 yyextra->decoratorCommentStr.str(std::string());
1782 yyextra->copyString=&yyextra->decoratorCommentStr;
1783 yyextra->stringContext=YY_START;
1784 BEGIN(TripleString);
1785 }
1786 "'" {
1787 yyextra->stringContext=YY_START;
1788 yyextra->decoratorCommentStr.str(std::string());
1789 yyextra->copyString=&yyextra->decoratorCommentStr;
1790 BEGIN( SingleQuoteString );
1791 }
1792 "\"" {
1793 yyextra->stringContext=YY_START;
1794 yyextra->decoratorCommentStr.str(std::string());
1795 yyextra->copyString=&yyextra->decoratorCommentStr;
1796 BEGIN( DoubleQuoteString );
1797 }
1798 "(" {
1799 yyextra->decoratorRound++;
1800 }
1801 ")" {
1802 yyextra->decoratorRound--;
1803 if (!yyextra->decoratorRound) BEGIN( Search );
1804 }
1805 \n {
1807 }
1808 . { }
1809}
1810
1811
1812
1813
1814<*>({NONEMPTY}|{EXPCHAR}|{BB}) { // This should go one character at a time.
1815
1816
1817
1818 }
1819 */
1820
1821<*>{NEWLINE} {
1822
1823
1824
1826 }
1827
1828<*>"'" {
1829
1830 }
1831
1832<*>. {
1833
1834
1835
1836 }
1837
1838
1839%%