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