Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ ScanGroupOpen()

RegexNode System.Text.RegularExpressions.RegexParser.ScanGroupOpen ( )
inlineprivate

Definition at line 663 of file RegexParser.cs.

664 {
665 if (CharsRight() == 0 || RightChar() != '?' || (RightChar() == '?' && CharsRight() > 1 && RightChar(1) == ')'))
666 {
668 {
669 _ignoreNextParen = false;
670 return new RegexNode(29, _options);
671 }
672 return new RegexNode(28, _options, _autocap++, -1);
673 }
674 MoveRight();
675 if (CharsRight() != 0)
676 {
677 char c = '>';
678 int type;
679 switch (RightCharMoveRight())
680 {
681 case ':':
682 type = 29;
683 goto IL_0501;
684 case '=':
685 _options &= ~RegexOptions.RightToLeft;
686 type = 30;
687 goto IL_0501;
688 case '!':
689 _options &= ~RegexOptions.RightToLeft;
690 type = 31;
691 goto IL_0501;
692 case '>':
693 type = 32;
694 goto IL_0501;
695 case '\'':
696 c = '\'';
697 goto case '<';
698 case '<':
699 {
700 if (CharsRight() == 0)
701 {
702 break;
703 }
704 char c2;
705 char c3 = (c2 = RightCharMoveRight());
706 if (c3 != '!')
707 {
708 if (c3 != '=')
709 {
710 MoveLeft();
711 int num = -1;
712 int num2 = -1;
713 bool flag = false;
714 if ((uint)(c2 - 48) <= 9u)
715 {
716 num = ScanDecimal();
717 if (!IsCaptureSlot(num))
718 {
719 num = -1;
720 }
721 if (CharsRight() > 0 && RightChar() != c && RightChar() != '-')
722 {
723 throw MakeException(RegexParseError.CaptureGroupNameInvalid, System.SR.CaptureGroupNameInvalid);
724 }
725 if (num == 0)
726 {
727 throw MakeException(RegexParseError.CaptureGroupOfZero, System.SR.CaptureGroupOfZero);
728 }
729 }
730 else if (RegexCharClass.IsWordChar(c2))
731 {
732 string capname = ScanCapname();
734 {
736 }
737 if (CharsRight() > 0 && RightChar() != c && RightChar() != '-')
738 {
739 throw MakeException(RegexParseError.CaptureGroupNameInvalid, System.SR.CaptureGroupNameInvalid);
740 }
741 }
742 else
743 {
744 if (c2 != '-')
745 {
746 throw MakeException(RegexParseError.CaptureGroupNameInvalid, System.SR.CaptureGroupNameInvalid);
747 }
748 flag = true;
749 }
750 if ((num != -1 || flag) && CharsRight() > 1 && RightChar() == '-')
751 {
752 MoveRight();
753 c2 = RightChar();
754 if ((uint)(c2 - 48) <= 9u)
755 {
756 num2 = ScanDecimal();
757 if (!IsCaptureSlot(num2))
758 {
760 }
761 if (CharsRight() > 0 && RightChar() != c)
762 {
763 throw MakeException(RegexParseError.CaptureGroupNameInvalid, System.SR.CaptureGroupNameInvalid);
764 }
765 }
766 else
767 {
768 if (!RegexCharClass.IsWordChar(c2))
769 {
770 throw MakeException(RegexParseError.CaptureGroupNameInvalid, System.SR.CaptureGroupNameInvalid);
771 }
772 string text = ScanCapname();
773 if (!IsCaptureName(text))
774 {
776 }
778 if (CharsRight() > 0 && RightChar() != c)
779 {
780 throw MakeException(RegexParseError.CaptureGroupNameInvalid, System.SR.CaptureGroupNameInvalid);
781 }
782 }
783 }
784 if ((num != -1 || num2 != -1) && CharsRight() > 0 && RightCharMoveRight() == c)
785 {
786 return new RegexNode(28, _options, num, num2);
787 }
788 break;
789 }
790 if (c == '\'')
791 {
792 break;
793 }
794 _options |= RegexOptions.RightToLeft;
795 type = 30;
796 }
797 else
798 {
799 if (c == '\'')
800 {
801 break;
802 }
803 _options |= RegexOptions.RightToLeft;
804 type = 31;
805 }
806 goto IL_0501;
807 }
808 case '(':
809 {
810 int num3 = Textpos();
811 if (CharsRight() > 0)
812 {
813 char c2 = RightChar();
814 if (c2 >= '0' && c2 <= '9')
815 {
816 int num4 = ScanDecimal();
817 if (CharsRight() > 0 && RightCharMoveRight() == ')')
818 {
819 if (IsCaptureSlot(num4))
820 {
821 return new RegexNode(33, _options, num4);
822 }
823 throw MakeException(RegexParseError.AlternationHasUndefinedReference, System.SR.Format(System.SR.AlternationHasUndefinedReference, num4.ToString()));
824 }
825 throw MakeException(RegexParseError.AlternationHasMalformedReference, System.SR.Format(System.SR.AlternationHasMalformedReference, num4.ToString()));
826 }
827 if (RegexCharClass.IsWordChar(c2))
828 {
829 string capname2 = ScanCapname();
830 if (IsCaptureName(capname2) && CharsRight() > 0 && RightCharMoveRight() == ')')
831 {
832 return new RegexNode(33, _options, CaptureSlotFromName(capname2));
833 }
834 }
835 }
836 type = 34;
837 Textto(num3 - 1);
838 _ignoreNextParen = true;
839 int num5 = CharsRight();
840 if (num5 >= 3 && RightChar(1) == '?')
841 {
842 char c4 = RightChar(2);
843 switch (c4)
844 {
845 case '#':
846 throw MakeException(RegexParseError.AlternationHasComment, System.SR.AlternationHasComment);
847 case '\'':
848 throw MakeException(RegexParseError.AlternationHasNamedCapture, System.SR.AlternationHasNamedCapture);
849 }
850 if (num5 >= 4 && c4 == '<' && RightChar(3) != '!' && RightChar(3) != '=')
851 {
852 throw MakeException(RegexParseError.AlternationHasNamedCapture, System.SR.AlternationHasNamedCapture);
853 }
854 }
855 goto IL_0501;
856 }
857 default:
858 {
859 MoveLeft();
860 type = 29;
861 if (_group.Type != 34)
862 {
863 ScanOptions();
864 }
865 if (CharsRight() == 0)
866 {
867 break;
868 }
869 char c2;
870 if ((c2 = RightCharMoveRight()) == ')')
871 {
872 return null;
873 }
874 if (c2 != ':')
875 {
876 break;
877 }
878 goto IL_0501;
879 }
880 IL_0501:
881 return new RegexNode(type, _options);
882 }
883 }
884 throw MakeException(RegexParseError.InvalidGroupingConstruct, System.SR.InvalidGroupingConstruct);
885 }
static string AlternationHasMalformedReference
Definition SR.cs:52
static string AlternationHasUndefinedReference
Definition SR.cs:92
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string UndefinedNumberedReference
Definition SR.cs:88
static string CaptureGroupOfZero
Definition SR.cs:26
static string AlternationHasComment
Definition SR.cs:16
static string CaptureGroupNameInvalid
Definition SR.cs:44
static string AlternationHasNamedCapture
Definition SR.cs:14
static string InvalidGroupingConstruct
Definition SR.cs:102
static string UndefinedNamedReference
Definition SR.cs:90
Definition SR.cs:7
RegexParseException MakeException(RegexParseError error, string message)

References System.Text.RegularExpressions.RegexParser._autocap, System.Text.RegularExpressions.RegexParser._group, System.Text.RegularExpressions.RegexParser._ignoreNextParen, System.Text.RegularExpressions.RegexParser._options, System.SR.AlternationHasComment, System.SR.AlternationHasMalformedReference, System.SR.AlternationHasNamedCapture, System.SR.AlternationHasUndefinedReference, System.SR.CaptureGroupNameInvalid, System.SR.CaptureGroupOfZero, System.Text.RegularExpressions.RegexParser.CaptureSlotFromName(), System.Text.RegularExpressions.RegexParser.CharsRight(), System.SR.Format(), System.SR.InvalidGroupingConstruct, System.Text.RegularExpressions.RegexParser.IsCaptureName(), System.Text.RegularExpressions.RegexParser.IsCaptureSlot(), System.Text.RegularExpressions.RegexCharClass.IsWordChar(), System.Text.RegularExpressions.RegexParser.MakeException(), System.Text.RegularExpressions.RegexParser.MoveLeft(), System.Text.RegularExpressions.RegexParser.MoveRight(), System.Text.RegularExpressions.RegexParser.RightChar(), System.Text.RegularExpressions.RegexParser.RightCharMoveRight(), System.Text.RegularExpressions.RegexParser.ScanCapname(), System.Text.RegularExpressions.RegexParser.ScanDecimal(), System.Text.RegularExpressions.RegexParser.ScanOptions(), System.text, System.Text.RegularExpressions.RegexParser.Textpos(), System.Text.RegularExpressions.RegexParser.Textto(), System.type, System.Text.RegularExpressions.RegexNode.Type, System.SR.UndefinedNamedReference, System.SR.UndefinedNumberedReference, and System.Text.RegularExpressions.RegexParser.UseOptionN().

Referenced by System.Text.RegularExpressions.RegexParser.ScanRegex().