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