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

◆ ScanBasicBackslash()

RegexNode System.Text.RegularExpressions.RegexParser.ScanBasicBackslash ( bool scanOnly)
inlineprivate

Definition at line 1026 of file RegexParser.cs.

1027 {
1028 if (CharsRight() == 0)
1029 {
1030 throw MakeException(RegexParseError.UnescapedEndingBackslash, System.SR.UnescapedEndingBackslash);
1031 }
1032 int pos = Textpos();
1033 char c = '\0';
1034 bool flag = false;
1035 char c2 = RightChar();
1036 switch (c2)
1037 {
1038 case 'k':
1039 if (CharsRight() >= 2)
1040 {
1041 MoveRight();
1043 if (c2 == '<' || c2 == '\'')
1044 {
1045 flag = true;
1046 c = ((c2 == '\'') ? '\'' : '>');
1047 }
1048 }
1049 if (!flag || CharsRight() <= 0)
1050 {
1051 throw MakeException(RegexParseError.MalformedNamedReference, System.SR.MalformedNamedReference);
1052 }
1053 c2 = RightChar();
1054 break;
1055 case '\'':
1056 case '<':
1057 if (CharsRight() > 1)
1058 {
1059 flag = true;
1060 c = ((c2 == '\'') ? '\'' : '>');
1061 MoveRight();
1062 c2 = RightChar();
1063 }
1064 break;
1065 }
1066 if (flag && c2 >= '0' && c2 <= '9')
1067 {
1068 int num = ScanDecimal();
1069 if (CharsRight() > 0 && RightCharMoveRight() == c)
1070 {
1071 if (!scanOnly)
1072 {
1073 if (!IsCaptureSlot(num))
1074 {
1075 throw MakeException(RegexParseError.UndefinedNumberedReference, System.SR.Format(System.SR.UndefinedNumberedReference, num.ToString()));
1076 }
1077 return new RegexNode(13, _options, num);
1078 }
1079 return null;
1080 }
1081 }
1082 else if (!flag && c2 >= '1' && c2 <= '9')
1083 {
1084 if (UseOptionE())
1085 {
1086 int num2 = -1;
1087 int num3 = c2 - 48;
1088 int num4 = Textpos() - 1;
1089 while (num3 <= _captop)
1090 {
1091 if (IsCaptureSlot(num3) && (_caps == null || (int)_caps[num3] < num4))
1092 {
1093 num2 = num3;
1094 }
1095 MoveRight();
1096 if (CharsRight() == 0 || (c2 = RightChar()) < '0' || c2 > '9')
1097 {
1098 break;
1099 }
1100 num3 = num3 * 10 + (c2 - 48);
1101 }
1102 if (num2 >= 0)
1103 {
1104 if (!scanOnly)
1105 {
1106 return new RegexNode(13, _options, num2);
1107 }
1108 return null;
1109 }
1110 }
1111 else
1112 {
1113 int num5 = ScanDecimal();
1114 if (scanOnly)
1115 {
1116 return null;
1117 }
1118 if (IsCaptureSlot(num5))
1119 {
1120 return new RegexNode(13, _options, num5);
1121 }
1122 if (num5 <= 9)
1123 {
1124 throw MakeException(RegexParseError.UndefinedNumberedReference, System.SR.Format(System.SR.UndefinedNumberedReference, num5.ToString()));
1125 }
1126 }
1127 }
1128 else if (flag && RegexCharClass.IsWordChar(c2))
1129 {
1130 string text = ScanCapname();
1131 if (CharsRight() > 0 && RightCharMoveRight() == c)
1132 {
1133 if (!scanOnly)
1134 {
1135 if (!IsCaptureName(text))
1136 {
1138 }
1139 return new RegexNode(13, _options, CaptureSlotFromName(text));
1140 }
1141 return null;
1142 }
1143 }
1144 Textto(pos);
1145 c2 = ScanCharEscape();
1146 if (UseOptionI())
1147 {
1148 c2 = _culture.TextInfo.ToLower(c2);
1149 }
1150 if (!scanOnly)
1151 {
1152 return new RegexNode(9, _options, c2);
1153 }
1154 return null;
1155 }
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string MalformedNamedReference
Definition SR.cs:50
static string UndefinedNumberedReference
Definition SR.cs:88
static string UnescapedEndingBackslash
Definition SR.cs:36
static string UndefinedNamedReference
Definition SR.cs:90
Definition SR.cs:7
RegexParseException MakeException(RegexParseError error, string message)

References System.Text.RegularExpressions.RegexParser._caps, System.Text.RegularExpressions.RegexParser._captop, System.Text.RegularExpressions.RegexParser._culture, System.Text.RegularExpressions.RegexParser._options, System.Text.RegularExpressions.RegexParser.CaptureSlotFromName(), System.Text.RegularExpressions.RegexParser.CharsRight(), System.SR.Format(), System.Text.RegularExpressions.RegexParser.IsCaptureName(), System.Text.RegularExpressions.RegexParser.IsCaptureSlot(), System.Text.RegularExpressions.RegexCharClass.IsWordChar(), System.Text.RegularExpressions.RegexParser.MakeException(), System.SR.MalformedNamedReference, System.Text.RegularExpressions.RegexParser.MoveRight(), System.Text.RegularExpressions.RegexParser.RightChar(), System.Text.RegularExpressions.RegexParser.RightCharMoveRight(), System.Text.RegularExpressions.RegexParser.ScanCapname(), System.Text.RegularExpressions.RegexParser.ScanCharEscape(), System.Text.RegularExpressions.RegexParser.ScanDecimal(), System.text, System.Globalization.CultureInfo.TextInfo, System.Text.RegularExpressions.RegexParser.Textpos(), System.Text.RegularExpressions.RegexParser.Textto(), System.SR.UndefinedNamedReference, System.SR.UndefinedNumberedReference, System.SR.UnescapedEndingBackslash, System.Text.RegularExpressions.RegexParser.UseOptionE(), and System.Text.RegularExpressions.RegexParser.UseOptionI().

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