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

◆ ComputeMultipleCharClasses()

static string bool CaseInsensitive[] System.Text.RegularExpressions.RegexPrefixAnalyzer.ComputeMultipleCharClasses ( RegexTree tree,
int maxChars )
inlinestatic

Definition at line 101 of file RegexPrefixAnalyzer.cs.

102 {
103 if ((tree.Options & RegexOptions.RightToLeft) != 0)
104 {
105 return null;
106 }
107 maxChars = Math.Min(tree.MinRequiredLength, maxChars);
108 if (maxChars <= 1)
109 {
110 return null;
111 }
112 RegexNode regexNode = tree.Root;
113 while (regexNode.Type != 24)
114 {
115 int type = regexNode.Type;
116 if (type == 25 || type == 28 || type == 32)
117 {
118 regexNode = regexNode.Child(0);
119 continue;
120 }
121 return null;
122 }
123 RegexCharClass[] array = new RegexCharClass[maxChars];
124 bool flag = false;
125 int num = regexNode.ChildCount();
126 for (int i = 0; i < num; i++)
127 {
128 RegexNode regexNode2 = regexNode.Child(i);
129 flag |= (regexNode2.Options & RegexOptions.IgnoreCase) != 0;
130 switch (regexNode2.Type)
131 {
132 case 12:
133 {
134 maxChars = Math.Min(maxChars, regexNode2.Str.Length);
135 for (int l = 0; l < maxChars; l++)
136 {
137 ref RegexCharClass reference = ref array[l];
138 (reference ?? (reference = new RegexCharClass())).AddChar(regexNode2.Str[l]);
139 }
140 break;
141 }
142 case 25:
143 {
144 int num2 = 0;
145 int num3 = regexNode2.ChildCount();
146 for (int j = 0; j < num3; j++)
147 {
148 if (num2 >= array.Length)
149 {
150 break;
151 }
152 RegexNode regexNode3 = regexNode2.Child(j);
153 flag |= (regexNode3.Options & RegexOptions.IgnoreCase) != 0;
154 switch (regexNode3.Type)
155 {
156 case 9:
157 {
158 ref RegexCharClass reference = ref array[num2++];
159 (reference ?? (reference = new RegexCharClass())).AddChar(regexNode3.Ch);
160 break;
161 }
162 case 11:
163 {
164 ref RegexCharClass reference = ref array[num2++];
165 if (!(reference ?? (reference = new RegexCharClass())).TryAddCharClass(RegexCharClass.Parse(regexNode3.Str)))
166 {
167 return null;
168 }
169 break;
170 }
171 case 12:
172 {
173 for (int k = 0; k < regexNode3.Str.Length; k++)
174 {
175 if (num2 >= array.Length)
176 {
177 break;
178 }
179 ref RegexCharClass reference = ref array[num2++];
180 (reference ?? (reference = new RegexCharClass())).AddChar(regexNode3.Str[k]);
181 }
182 break;
183 }
184 default:
185 j = num3;
186 break;
187 }
188 }
189 maxChars = Math.Min(maxChars, num2);
190 break;
191 }
192 default:
193 return null;
194 }
195 }
196 for (int m = 0; m < maxChars; m++)
197 {
198 if (array[m] == null)
199 {
200 maxChars = m;
201 break;
202 }
203 }
204 if (maxChars == 0)
205 {
206 return null;
207 }
208 (string, bool)[] array2 = new(string, bool)[maxChars];
209 CultureInfo culture = null;
210 if (flag)
211 {
212 culture = (((tree.Options & RegexOptions.CultureInvariant) != 0) ? CultureInfo.InvariantCulture : CultureInfo.CurrentCulture);
213 }
214 for (int n = 0; n < array2.Length; n++)
215 {
216 if (flag)
217 {
218 array[n].AddLowercase(culture);
219 }
220 array2[n] = (array[n].ToStringClass(), flag);
221 }
222 return array2;
223 }
static CultureInfo CurrentCulture

References System.Text.RegularExpressions.array, System.culture, System.Globalization.CultureInfo.CurrentCulture, System.Text.RegularExpressions.i, System.Math.Min(), System.Text.RegularExpressions.RegexCharClass.Parse(), and System.type.

Referenced by System.Text.RegularExpressions.RegexWriter.RegexCodeFromRegexTree().