| | | 1 | | // <auto-generated/> |
| | | 2 | | #nullable enable |
| | | 3 | | #pragma warning disable |
| | | 4 | | |
| | | 5 | | namespace ArturRios.Util.RegularExpressions |
| | | 6 | | { |
| | | 7 | | partial class RegexCollection |
| | | 8 | | { |
| | | 9 | | /// <remarks> |
| | | 10 | | /// Pattern:<br/> |
| | | 11 | | /// <code>^[a-zA-Z0-9!#$%&'*+\\-/=?\\^_`{|}~]+(\\.[a-zA-Z0-9!#$%&'*+\\-/=?\\^_`{|}~]+)*@((([a-zA-Z0-9](( |
| | | 12 | | /// Explanation:<br/> |
| | | 13 | | /// <code> |
| | | 14 | | /// ○ Match if at the beginning of the string.<br/> |
| | | 15 | | /// ○ Match a character in the set [!#-'*+\-/-9=?A-Z^-~] greedily at least once.<br/> |
| | | 16 | | /// ○ Loop greedily any number of times.<br/> |
| | | 17 | | /// ○ 1st capture group.<br/> |
| | | 18 | | /// ○ Match '.'.<br/> |
| | | 19 | | /// ○ Match a character in the set [!#-'*+\-/-9=?A-Z^-~] atomically at least once.<br/> |
| | | 20 | | /// ○ Match '@'.<br/> |
| | | 21 | | /// ○ 2nd capture group.<br/> |
| | | 22 | | /// ○ Match with 2 alternative expressions.<br/> |
| | | 23 | | /// ○ 3rd capture group.<br/> |
| | | 24 | | /// ○ Loop greedily at least once.<br/> |
| | | 25 | | /// ○ 4th capture group.<br/> |
| | | 26 | | /// ○ Match an ASCII letter or digit.<br/> |
| | | 27 | | /// ○ Optional (greedy).<br/> |
| | | 28 | | /// ○ 5th capture group.<br/> |
| | | 29 | | /// ○ 6th capture group.<br/> |
| | | 30 | | /// ○ Match a character in the set [\-0-9A-Za-z] greedily at most 61 times.<br/> |
| | | 31 | | /// ○ Match an ASCII letter or digit.<br/> |
| | | 32 | | /// ○ Match '.'.<br/> |
| | | 33 | | /// ○ Match an ASCII letter atomically at least 2 and at most 63 times.<br/> |
| | | 34 | | /// ○ 7th capture group.<br/> |
| | | 35 | | /// ○ Match '['.<br/> |
| | | 36 | | /// ○ Loop exactly 3 times.<br/> |
| | | 37 | | /// ○ 8th capture group.<br/> |
| | | 38 | | /// ○ 9th capture group.<br/> |
| | | 39 | | /// ○ Match with 3 alternative expressions.<br/> |
| | | 40 | | /// ○ Match a sequence of expressions.<br/> |
| | | 41 | | /// ○ Match '2'.<br/> |
| | | 42 | | /// ○ Match with 2 alternative expressions.<br/> |
| | | 43 | | /// ○ Match a sequence of expressions.<br/> |
| | | 44 | | /// ○ Match '5'.<br/> |
| | | 45 | | /// ○ Match a character in the set [0-5].<br/> |
| | | 46 | | /// ○ Match a sequence of expressions.<br/> |
| | | 47 | | /// ○ Match a character in the set [0-4].<br/> |
| | | 48 | | /// ○ Match a character in the set [0-9].<br/> |
| | | 49 | | /// ○ Match a sequence of expressions.<br/> |
| | | 50 | | /// ○ Match '1'.<br/> |
| | | 51 | | /// ○ Match a character in the set [0-9] exactly 2 times.<br/> |
| | | 52 | | /// ○ Match a sequence of expressions.<br/> |
| | | 53 | | /// ○ Match a character in the set [1-9] greedily, optionally.<br/> |
| | | 54 | | /// ○ Match a character in the set [0-9].<br/> |
| | | 55 | | /// ○ Match '.'.<br/> |
| | | 56 | | /// ○ 10th capture group.<br/> |
| | | 57 | | /// ○ Match with 3 alternative expressions.<br/> |
| | | 58 | | /// ○ Match a sequence of expressions.<br/> |
| | | 59 | | /// ○ Match '2'.<br/> |
| | | 60 | | /// ○ Match with 2 alternative expressions.<br/> |
| | | 61 | | /// ○ Match a sequence of expressions.<br/> |
| | | 62 | | /// ○ Match '5'.<br/> |
| | | 63 | | /// ○ Match a character in the set [0-5].<br/> |
| | | 64 | | /// ○ Match a sequence of expressions.<br/> |
| | | 65 | | /// ○ Match a character in the set [0-4].<br/> |
| | | 66 | | /// ○ Match a character in the set [0-9].<br/> |
| | | 67 | | /// ○ Match a sequence of expressions.<br/> |
| | | 68 | | /// ○ Match '1'.<br/> |
| | | 69 | | /// ○ Match a character in the set [0-9] exactly 2 times.<br/> |
| | | 70 | | /// ○ Match a sequence of expressions.<br/> |
| | | 71 | | /// ○ Match a character in the set [1-9] greedily, optionally.<br/> |
| | | 72 | | /// ○ Match a character in the set [0-9].<br/> |
| | | 73 | | /// ○ Match ']'.<br/> |
| | | 74 | | /// ○ Match if at the end of the string.<br/> |
| | | 75 | | /// </code> |
| | | 76 | | /// </remarks> |
| | | 77 | | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Text.RegularExpressions.Generator", "10.0.14.374 |
| | | 78 | | public static partial global::System.Text.RegularExpressions.Regex Email() => global::System.Text.RegularExpress |
| | | 79 | | } |
| | | 80 | | } |
| | | 81 | | |
| | | 82 | | namespace ArturRios.Util.RegularExpressions |
| | | 83 | | { |
| | | 84 | | partial class RegexCollection |
| | | 85 | | { |
| | | 86 | | /// <remarks> |
| | | 87 | | /// Pattern:<br/> |
| | | 88 | | /// <code>[0-9]+</code><br/> |
| | | 89 | | /// Explanation:<br/> |
| | | 90 | | /// <code> |
| | | 91 | | /// ○ Match a character in the set [0-9] atomically at least once.<br/> |
| | | 92 | | /// </code> |
| | | 93 | | /// </remarks> |
| | | 94 | | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Text.RegularExpressions.Generator", "10.0.14.374 |
| | | 95 | | public static partial global::System.Text.RegularExpressions.Regex HasNumber() => global::System.Text.RegularExp |
| | | 96 | | } |
| | | 97 | | } |
| | | 98 | | |
| | | 99 | | namespace ArturRios.Util.RegularExpressions |
| | | 100 | | { |
| | | 101 | | partial class RegexCollection |
| | | 102 | | { |
| | | 103 | | /// <remarks> |
| | | 104 | | /// Pattern:<br/> |
| | | 105 | | /// <code>[a-z]+</code><br/> |
| | | 106 | | /// Explanation:<br/> |
| | | 107 | | /// <code> |
| | | 108 | | /// ○ Match a character in the set [a-z] atomically at least once.<br/> |
| | | 109 | | /// </code> |
| | | 110 | | /// </remarks> |
| | | 111 | | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Text.RegularExpressions.Generator", "10.0.14.374 |
| | | 112 | | public static partial global::System.Text.RegularExpressions.Regex HasLowerChar() => global::System.Text.Regular |
| | | 113 | | } |
| | | 114 | | } |
| | | 115 | | |
| | | 116 | | namespace ArturRios.Util.RegularExpressions |
| | | 117 | | { |
| | | 118 | | partial class RegexCollection |
| | | 119 | | { |
| | | 120 | | /// <remarks> |
| | | 121 | | /// Pattern:<br/> |
| | | 122 | | /// <code>[A-Z]+</code><br/> |
| | | 123 | | /// Explanation:<br/> |
| | | 124 | | /// <code> |
| | | 125 | | /// ○ Match a character in the set [A-Z] atomically at least once.<br/> |
| | | 126 | | /// </code> |
| | | 127 | | /// </remarks> |
| | | 128 | | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Text.RegularExpressions.Generator", "10.0.14.374 |
| | | 129 | | public static partial global::System.Text.RegularExpressions.Regex HasUpperChar() => global::System.Text.Regular |
| | | 130 | | } |
| | | 131 | | } |
| | | 132 | | |
| | | 133 | | namespace ArturRios.Util.RegularExpressions |
| | | 134 | | { |
| | | 135 | | partial class RegexCollection |
| | | 136 | | { |
| | | 137 | | /// <remarks> |
| | | 138 | | /// Pattern:<br/> |
| | | 139 | | /// <code>^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d).+\\z</code><br/> |
| | | 140 | | /// Explanation:<br/> |
| | | 141 | | /// <code> |
| | | 142 | | /// ○ Match if at the beginning of the string.<br/> |
| | | 143 | | /// ○ Zero-width positive lookahead.<br/> |
| | | 144 | | /// ○ Match a character other than '\n' greedily any number of times.<br/> |
| | | 145 | | /// ○ Match a character in the set [a-z].<br/> |
| | | 146 | | /// ○ Zero-width positive lookahead.<br/> |
| | | 147 | | /// ○ Match a character other than '\n' greedily any number of times.<br/> |
| | | 148 | | /// ○ Match a character in the set [A-Z].<br/> |
| | | 149 | | /// ○ Zero-width positive lookahead.<br/> |
| | | 150 | | /// ○ Match a character other than '\n' greedily any number of times.<br/> |
| | | 151 | | /// ○ Match a Unicode digit.<br/> |
| | | 152 | | /// ○ Match a character other than '\n' atomically at least once.<br/> |
| | | 153 | | /// ○ Match if at the end of the string.<br/> |
| | | 154 | | /// </code> |
| | | 155 | | /// </remarks> |
| | | 156 | | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Text.RegularExpressions.Generator", "10.0.14.374 |
| | | 157 | | public static partial global::System.Text.RegularExpressions.Regex HasNumberLowerAndUpperChar() => global::Syste |
| | | 158 | | } |
| | | 159 | | } |
| | | 160 | | |
| | | 161 | | namespace System.Text.RegularExpressions.Generated |
| | | 162 | | { |
| | | 163 | | using System; |
| | | 164 | | using System.Buffers; |
| | | 165 | | using System.CodeDom.Compiler; |
| | | 166 | | using System.Collections; |
| | | 167 | | using System.ComponentModel; |
| | | 168 | | using System.Globalization; |
| | | 169 | | using System.Runtime.CompilerServices; |
| | | 170 | | using System.Text.RegularExpressions; |
| | | 171 | | using System.Threading; |
| | | 172 | | |
| | | 173 | | /// <summary>Custom <see cref="Regex"/>-derived type for the Email method.</summary> |
| | | 174 | | [GeneratedCodeAttribute("System.Text.RegularExpressions.Generator", "10.0.14.37416")] |
| | | 175 | | file sealed class Email_0 : Regex |
| | | 176 | | { |
| | | 177 | | /// <summary>Cached, thread-safe singleton instance.</summary> |
| | | 178 | | internal static readonly Email_0 Instance = new(); |
| | | 179 | | |
| | | 180 | | /// <summary>Initializes the instance.</summary> |
| | | 181 | | private Email_0() |
| | | 182 | | { |
| | | 183 | | base.pattern = "^[a-zA-Z0-9!#$%&'*+\\-/=?\\^_`{|}~]+(\\.[a-zA-Z0-9!#$%&'*+\\-/=?\\^_`{|}~]+)*@((([a-zA-Z0-9] |
| | | 184 | | base.roptions = RegexOptions.None; |
| | | 185 | | base.internalMatchTimeout = TimeSpan.FromMilliseconds(100); |
| | | 186 | | base.factory = new RunnerFactory(); |
| | | 187 | | base.capsize = 11; |
| | | 188 | | } |
| | | 189 | | |
| | | 190 | | /// <summary>Provides a factory for creating <see cref="RegexRunner"/> instances to be used by methods on <see c |
| | | 191 | | private sealed class RunnerFactory : RegexRunnerFactory |
| | | 192 | | { |
| | | 193 | | /// <summary>Creates an instance of a <see cref="RegexRunner"/> used by methods on <see cref="Regex"/>.</sum |
| | | 194 | | protected override RegexRunner CreateInstance() => new Runner(); |
| | | 195 | | |
| | | 196 | | /// <summary>Provides the runner that contains the custom logic implementing the specified regular expressio |
| | | 197 | | private sealed class Runner : RegexRunner |
| | | 198 | | { |
| | | 199 | | /// <summary>Scan the <paramref name="inputSpan"/> starting from base.runtextstart for the next match.</ |
| | | 200 | | /// <param name="inputSpan">The text being scanned by the regular expression.</param> |
| | | 201 | | protected override void Scan(ReadOnlySpan<char> inputSpan) |
| | | 202 | | { |
| | | 203 | | // The pattern is anchored. Validate the current position and try to match at it only. |
| | | 204 | | if (TryFindNextPossibleStartingPosition(inputSpan) && !TryMatchAtCurrentPosition(inputSpan)) |
| | | 205 | | { |
| | | 206 | | base.runtextpos = inputSpan.Length; |
| | | 207 | | } |
| | | 208 | | } |
| | | 209 | | |
| | | 210 | | /// <summary>Search <paramref name="inputSpan"/> starting from base.runtextpos for the next location a m |
| | | 211 | | /// <param name="inputSpan">The text being scanned by the regular expression.</param> |
| | | 212 | | /// <returns>true if a possible match was found; false if no more matches are possible.</returns> |
| | | 213 | | private bool TryFindNextPossibleStartingPosition(ReadOnlySpan<char> inputSpan) |
| | | 214 | | { |
| | | 215 | | int pos = base.runtextpos; |
| | | 216 | | |
| | | 217 | | // Any possible match is at least 6 characters. |
| | | 218 | | if (pos <= inputSpan.Length - 6) |
| | | 219 | | { |
| | | 220 | | // The pattern leads with a beginning (\A) anchor. |
| | | 221 | | if (pos == 0) |
| | | 222 | | { |
| | | 223 | | return true; |
| | | 224 | | } |
| | | 225 | | } |
| | | 226 | | |
| | | 227 | | // No match found. |
| | | 228 | | base.runtextpos = inputSpan.Length; |
| | | 229 | | return false; |
| | | 230 | | } |
| | | 231 | | |
| | | 232 | | /// <summary>Determine whether <paramref name="inputSpan"/> at base.runtextpos is a match for the regula |
| | | 233 | | /// <param name="inputSpan">The text being scanned by the regular expression.</param> |
| | | 234 | | /// <returns>true if the regular expression matches at the current position; otherwise, false.</returns> |
| | | 235 | | private bool TryMatchAtCurrentPosition(ReadOnlySpan<char> inputSpan) |
| | | 236 | | { |
| | | 237 | | int pos = base.runtextpos; |
| | | 238 | | int matchStart = pos; |
| | | 239 | | char ch; |
| | | 240 | | int alternation_branch = 0; |
| | | 241 | | int alternation_branch1 = 0; |
| | | 242 | | int alternation_starting_capturepos = 0; |
| | | 243 | | int alternation_starting_capturepos2 = 0; |
| | | 244 | | int alternation_starting_pos = 0; |
| | | 245 | | int alternation_starting_pos2 = 0; |
| | | 246 | | int capture_starting_pos1 = 0; |
| | | 247 | | int capture_starting_pos2 = 0; |
| | | 248 | | int capture_starting_pos6 = 0; |
| | | 249 | | int capture_starting_pos9 = 0; |
| | | 250 | | int charloop_capture_pos = 0; |
| | | 251 | | int charloop_capture_pos1 = 0; |
| | | 252 | | int charloop_starting_pos = 0, charloop_ending_pos = 0; |
| | | 253 | | int charloop_starting_pos1 = 0, charloop_ending_pos1 = 0; |
| | | 254 | | int charloop_starting_pos2 = 0, charloop_ending_pos2 = 0; |
| | | 255 | | int charloop_starting_pos3 = 0, charloop_ending_pos3 = 0; |
| | | 256 | | int loop_iteration = 0; |
| | | 257 | | int loop_iteration1 = 0; |
| | | 258 | | int loop_iteration2 = 0; |
| | | 259 | | int loop_iteration3 = 0; |
| | | 260 | | int stackpos = 0; |
| | | 261 | | int startingStackpos = 0; |
| | | 262 | | ReadOnlySpan<char> slice = inputSpan.Slice(pos); |
| | | 263 | | |
| | | 264 | | // Match if at the beginning of the string. |
| | | 265 | | if (pos != 0) |
| | | 266 | | { |
| | | 267 | | UncaptureUntil(0); |
| | | 268 | | return false; // The input didn't match. |
| | | 269 | | } |
| | | 270 | | |
| | | 271 | | // Match a character in the set [!#-'*+\-/-9=?A-Z^-~] greedily at least once. |
| | | 272 | | //{ |
| | | 273 | | charloop_starting_pos = pos; |
| | | 274 | | |
| | | 275 | | int iteration = slice.IndexOfAnyExcept(Utilities.s_ascii_FAACFFA3FEFFFFC7FFFFFF7F); |
| | | 276 | | if (iteration < 0) |
| | | 277 | | { |
| | | 278 | | iteration = slice.Length; |
| | | 279 | | } |
| | | 280 | | |
| | | 281 | | if (iteration == 0) |
| | | 282 | | { |
| | | 283 | | UncaptureUntil(0); |
| | | 284 | | return false; // The input didn't match. |
| | | 285 | | } |
| | | 286 | | |
| | | 287 | | slice = slice.Slice(iteration); |
| | | 288 | | pos += iteration; |
| | | 289 | | |
| | | 290 | | charloop_ending_pos = pos; |
| | | 291 | | charloop_starting_pos++; |
| | | 292 | | goto CharLoopEnd; |
| | | 293 | | |
| | | 294 | | CharLoopBacktrack: |
| | | 295 | | UncaptureUntil(charloop_capture_pos); |
| | | 296 | | |
| | | 297 | | base.CheckTimeout(); |
| | | 298 | | |
| | | 299 | | if (charloop_starting_pos >= charloop_ending_pos) |
| | | 300 | | { |
| | | 301 | | UncaptureUntil(0); |
| | | 302 | | return false; // The input didn't match. |
| | | 303 | | } |
| | | 304 | | pos = --charloop_ending_pos; |
| | | 305 | | slice = inputSpan.Slice(pos); |
| | | 306 | | |
| | | 307 | | CharLoopEnd: |
| | | 308 | | charloop_capture_pos = base.Crawlpos(); |
| | | 309 | | //} |
| | | 310 | | |
| | | 311 | | // Loop greedily any number of times. |
| | | 312 | | //{ |
| | | 313 | | loop_iteration = 0; |
| | | 314 | | |
| | | 315 | | LoopBody: |
| | | 316 | | Utilities.StackPush(ref base.runstack!, ref stackpos, base.Crawlpos(), pos); |
| | | 317 | | |
| | | 318 | | loop_iteration++; |
| | | 319 | | |
| | | 320 | | // 1st capture group. |
| | | 321 | | { |
| | | 322 | | int capture_starting_pos = pos; |
| | | 323 | | |
| | | 324 | | // Match '.'. |
| | | 325 | | if (slice.IsEmpty || slice[0] != '.') |
| | | 326 | | { |
| | | 327 | | goto LoopIterationNoMatch; |
| | | 328 | | } |
| | | 329 | | |
| | | 330 | | // Match a character in the set [!#-'*+\-/-9=?A-Z^-~] atomically at least once. |
| | | 331 | | { |
| | | 332 | | int iteration1 = slice.Slice(1).IndexOfAnyExcept(Utilities.s_ascii_FAACFFA3FEFFFFC7FFFFF |
| | | 333 | | if (iteration1 < 0) |
| | | 334 | | { |
| | | 335 | | iteration1 = slice.Length - 1; |
| | | 336 | | } |
| | | 337 | | |
| | | 338 | | if (iteration1 == 0) |
| | | 339 | | { |
| | | 340 | | goto LoopIterationNoMatch; |
| | | 341 | | } |
| | | 342 | | |
| | | 343 | | slice = slice.Slice(iteration1); |
| | | 344 | | pos += iteration1; |
| | | 345 | | } |
| | | 346 | | |
| | | 347 | | pos++; |
| | | 348 | | slice = inputSpan.Slice(pos); |
| | | 349 | | base.Capture(1, capture_starting_pos, pos); |
| | | 350 | | } |
| | | 351 | | |
| | | 352 | | |
| | | 353 | | // The loop has no upper bound. Continue iterating greedily. |
| | | 354 | | goto LoopBody; |
| | | 355 | | |
| | | 356 | | // The loop iteration failed. Put state back to the way it was before the iteration. |
| | | 357 | | LoopIterationNoMatch: |
| | | 358 | | if (--loop_iteration < 0) |
| | | 359 | | { |
| | | 360 | | // Unable to match the remainder of the expression after exhausting the loop. |
| | | 361 | | goto CharLoopBacktrack; |
| | | 362 | | } |
| | | 363 | | pos = base.runstack![--stackpos]; |
| | | 364 | | UncaptureUntil(base.runstack![--stackpos]); |
| | | 365 | | slice = inputSpan.Slice(pos); |
| | | 366 | | LoopEnd:; |
| | | 367 | | //} |
| | | 368 | | |
| | | 369 | | // Match '@'. |
| | | 370 | | if (slice.IsEmpty || slice[0] != '@') |
| | | 371 | | { |
| | | 372 | | goto LoopIterationNoMatch; |
| | | 373 | | } |
| | | 374 | | |
| | | 375 | | // 2nd capture group. |
| | | 376 | | //{ |
| | | 377 | | pos++; |
| | | 378 | | slice = inputSpan.Slice(pos); |
| | | 379 | | capture_starting_pos1 = pos; |
| | | 380 | | |
| | | 381 | | // Match with 2 alternative expressions. |
| | | 382 | | //{ |
| | | 383 | | alternation_starting_pos = pos; |
| | | 384 | | alternation_starting_capturepos = base.Crawlpos(); |
| | | 385 | | |
| | | 386 | | // Branch 0 |
| | | 387 | | //{ |
| | | 388 | | // 3rd capture group. |
| | | 389 | | //{ |
| | | 390 | | capture_starting_pos2 = pos; |
| | | 391 | | |
| | | 392 | | // Loop greedily at least once. |
| | | 393 | | //{ |
| | | 394 | | loop_iteration1 = 0; |
| | | 395 | | |
| | | 396 | | LoopBody1: |
| | | 397 | | Utilities.StackPush(ref base.runstack!, ref stackpos, base.Crawlpos(), pos); |
| | | 398 | | |
| | | 399 | | loop_iteration1++; |
| | | 400 | | |
| | | 401 | | // 4th capture group. |
| | | 402 | | //{ |
| | | 403 | | int capture_starting_pos3 = pos; |
| | | 404 | | |
| | | 405 | | // Match an ASCII letter or digit. |
| | | 406 | | if (slice.IsEmpty || !char.IsAsciiLetterOrDigit(slice[0])) |
| | | 407 | | { |
| | | 408 | | goto LoopIterationNoMatch1; |
| | | 409 | | } |
| | | 410 | | |
| | | 411 | | // Optional (greedy). |
| | | 412 | | //{ |
| | | 413 | | pos++; |
| | | 414 | | slice = inputSpan.Slice(pos); |
| | | 415 | | loop_iteration2 = 0; |
| | | 416 | | |
| | | 417 | | LoopBody2: |
| | | 418 | | Utilities.StackPush(ref base.runstack!, ref stackpos, base.Crawlpos(), p |
| | | 419 | | |
| | | 420 | | loop_iteration2++; |
| | | 421 | | |
| | | 422 | | // 5th capture group. |
| | | 423 | | //{ |
| | | 424 | | int capture_starting_pos4 = pos; |
| | | 425 | | |
| | | 426 | | // 6th capture group. |
| | | 427 | | //{ |
| | | 428 | | int capture_starting_pos5 = pos; |
| | | 429 | | |
| | | 430 | | // Match a character in the set [\-0-9A-Za-z] greedily at most 6 |
| | | 431 | | //{ |
| | | 432 | | charloop_starting_pos1 = pos; |
| | | 433 | | |
| | | 434 | | int iteration2 = 0; |
| | | 435 | | while (iteration2 < 61 && (uint)iteration2 < (uint)slice.Len |
| | | 436 | | { |
| | | 437 | | iteration2++; |
| | | 438 | | } |
| | | 439 | | |
| | | 440 | | slice = slice.Slice(iteration2); |
| | | 441 | | pos += iteration2; |
| | | 442 | | |
| | | 443 | | charloop_ending_pos1 = pos; |
| | | 444 | | goto CharLoopEnd1; |
| | | 445 | | |
| | | 446 | | CharLoopBacktrack1: |
| | | 447 | | UncaptureUntil(base.runstack![--stackpos]); |
| | | 448 | | Utilities.StackPop(base.runstack!, ref stackpos, out charloo |
| | | 449 | | |
| | | 450 | | base.CheckTimeout(); |
| | | 451 | | |
| | | 452 | | if (charloop_starting_pos1 >= charloop_ending_pos1 || |
| | | 453 | | (charloop_ending_pos1 = inputSpan.Slice(charloop_startin |
| | | 454 | | { |
| | | 455 | | goto LoopIterationNoMatch2; |
| | | 456 | | } |
| | | 457 | | charloop_ending_pos1 += charloop_starting_pos1; |
| | | 458 | | pos = charloop_ending_pos1; |
| | | 459 | | slice = inputSpan.Slice(pos); |
| | | 460 | | |
| | | 461 | | CharLoopEnd1: |
| | | 462 | | Utilities.StackPush(ref base.runstack!, ref stackpos, charlo |
| | | 463 | | //} |
| | | 464 | | |
| | | 465 | | base.Capture(6, capture_starting_pos5, pos); |
| | | 466 | | |
| | | 467 | | Utilities.StackPush(ref base.runstack!, ref stackpos, capture_st |
| | | 468 | | goto CaptureSkipBacktrack; |
| | | 469 | | |
| | | 470 | | CaptureBacktrack: |
| | | 471 | | capture_starting_pos5 = base.runstack![--stackpos]; |
| | | 472 | | goto CharLoopBacktrack1; |
| | | 473 | | |
| | | 474 | | CaptureSkipBacktrack:; |
| | | 475 | | //} |
| | | 476 | | |
| | | 477 | | // Match an ASCII letter or digit. |
| | | 478 | | if (slice.IsEmpty || !char.IsAsciiLetterOrDigit(slice[0])) |
| | | 479 | | { |
| | | 480 | | goto CaptureBacktrack; |
| | | 481 | | } |
| | | 482 | | |
| | | 483 | | pos++; |
| | | 484 | | slice = inputSpan.Slice(pos); |
| | | 485 | | base.Capture(5, capture_starting_pos4, pos); |
| | | 486 | | |
| | | 487 | | Utilities.StackPush(ref base.runstack!, ref stackpos, capture_starti |
| | | 488 | | goto CaptureSkipBacktrack1; |
| | | 489 | | |
| | | 490 | | CaptureBacktrack1: |
| | | 491 | | capture_starting_pos4 = base.runstack![--stackpos]; |
| | | 492 | | goto CaptureBacktrack; |
| | | 493 | | |
| | | 494 | | CaptureSkipBacktrack1:; |
| | | 495 | | //} |
| | | 496 | | |
| | | 497 | | |
| | | 498 | | // The loop has an upper bound of 1. Continue iterating greedily if it h |
| | | 499 | | if (loop_iteration2 == 0) |
| | | 500 | | { |
| | | 501 | | goto LoopBody2; |
| | | 502 | | } |
| | | 503 | | goto LoopEnd2; |
| | | 504 | | |
| | | 505 | | // The loop iteration failed. Put state back to the way it was before th |
| | | 506 | | LoopIterationNoMatch2: |
| | | 507 | | if (--loop_iteration2 < 0) |
| | | 508 | | { |
| | | 509 | | // Unable to match the remainder of the expression after exhausting |
| | | 510 | | goto LoopIterationNoMatch1; |
| | | 511 | | } |
| | | 512 | | pos = base.runstack![--stackpos]; |
| | | 513 | | UncaptureUntil(base.runstack![--stackpos]); |
| | | 514 | | slice = inputSpan.Slice(pos); |
| | | 515 | | goto LoopEnd2; |
| | | 516 | | |
| | | 517 | | LoopBacktrack: |
| | | 518 | | base.CheckTimeout(); |
| | | 519 | | |
| | | 520 | | if (loop_iteration2 == 0) |
| | | 521 | | { |
| | | 522 | | // No iterations of the loop remain to backtrack into. Fail the loop |
| | | 523 | | goto LoopIterationNoMatch1; |
| | | 524 | | } |
| | | 525 | | goto CaptureBacktrack1; |
| | | 526 | | LoopEnd2: |
| | | 527 | | |
| | | 528 | | Utilities.StackPush(ref base.runstack!, ref stackpos, loop_iteration2); |
| | | 529 | | goto LoopSkipBacktrack; |
| | | 530 | | |
| | | 531 | | LoopBacktrack1: |
| | | 532 | | loop_iteration2 = base.runstack![--stackpos]; |
| | | 533 | | base.CheckTimeout(); |
| | | 534 | | |
| | | 535 | | goto LoopBacktrack; |
| | | 536 | | |
| | | 537 | | LoopSkipBacktrack:; |
| | | 538 | | //} |
| | | 539 | | |
| | | 540 | | // Match '.'. |
| | | 541 | | if (slice.IsEmpty || slice[0] != '.') |
| | | 542 | | { |
| | | 543 | | goto LoopBacktrack1; |
| | | 544 | | } |
| | | 545 | | |
| | | 546 | | pos++; |
| | | 547 | | slice = inputSpan.Slice(pos); |
| | | 548 | | base.Capture(4, capture_starting_pos3, pos); |
| | | 549 | | |
| | | 550 | | Utilities.StackPush(ref base.runstack!, ref stackpos, capture_starting_pos3) |
| | | 551 | | goto CaptureSkipBacktrack2; |
| | | 552 | | |
| | | 553 | | CaptureBacktrack2: |
| | | 554 | | capture_starting_pos3 = base.runstack![--stackpos]; |
| | | 555 | | goto LoopBacktrack1; |
| | | 556 | | |
| | | 557 | | CaptureSkipBacktrack2:; |
| | | 558 | | //} |
| | | 559 | | |
| | | 560 | | |
| | | 561 | | // The loop has no upper bound. Continue iterating greedily. |
| | | 562 | | goto LoopBody1; |
| | | 563 | | |
| | | 564 | | // The loop iteration failed. Put state back to the way it was before the iterat |
| | | 565 | | LoopIterationNoMatch1: |
| | | 566 | | if (--loop_iteration1 < 0) |
| | | 567 | | { |
| | | 568 | | // Unable to match the remainder of the expression after exhausting the loop |
| | | 569 | | goto AlternationBranch; |
| | | 570 | | } |
| | | 571 | | pos = base.runstack![--stackpos]; |
| | | 572 | | UncaptureUntil(base.runstack![--stackpos]); |
| | | 573 | | slice = inputSpan.Slice(pos); |
| | | 574 | | if (loop_iteration1 == 0) |
| | | 575 | | { |
| | | 576 | | // No iterations have been matched to backtrack into. Fail the loop. |
| | | 577 | | goto AlternationBranch; |
| | | 578 | | } |
| | | 579 | | |
| | | 580 | | goto LoopEnd1; |
| | | 581 | | |
| | | 582 | | LoopBacktrack2: |
| | | 583 | | base.CheckTimeout(); |
| | | 584 | | |
| | | 585 | | if (loop_iteration1 == 0) |
| | | 586 | | { |
| | | 587 | | // No iterations of the loop remain to backtrack into. Fail the loop. |
| | | 588 | | goto AlternationBranch; |
| | | 589 | | } |
| | | 590 | | goto CaptureBacktrack2; |
| | | 591 | | LoopEnd1:; |
| | | 592 | | //} |
| | | 593 | | |
| | | 594 | | // Match an ASCII letter atomically at least 2 and at most 63 times. |
| | | 595 | | { |
| | | 596 | | int iteration3 = 0; |
| | | 597 | | while (iteration3 < 63 && (uint)iteration3 < (uint)slice.Length && char.IsAsciiL |
| | | 598 | | { |
| | | 599 | | iteration3++; |
| | | 600 | | } |
| | | 601 | | |
| | | 602 | | if (iteration3 < 2) |
| | | 603 | | { |
| | | 604 | | goto LoopBacktrack2; |
| | | 605 | | } |
| | | 606 | | |
| | | 607 | | slice = slice.Slice(iteration3); |
| | | 608 | | pos += iteration3; |
| | | 609 | | } |
| | | 610 | | |
| | | 611 | | base.Capture(3, capture_starting_pos2, pos); |
| | | 612 | | |
| | | 613 | | goto CaptureSkipBacktrack3; |
| | | 614 | | |
| | | 615 | | CaptureBacktrack3: |
| | | 616 | | goto LoopBacktrack2; |
| | | 617 | | |
| | | 618 | | CaptureSkipBacktrack3:; |
| | | 619 | | //} |
| | | 620 | | |
| | | 621 | | alternation_branch = 0; |
| | | 622 | | goto AlternationMatch; |
| | | 623 | | |
| | | 624 | | AlternationBranch: |
| | | 625 | | pos = alternation_starting_pos; |
| | | 626 | | slice = inputSpan.Slice(pos); |
| | | 627 | | UncaptureUntil(alternation_starting_capturepos); |
| | | 628 | | //} |
| | | 629 | | |
| | | 630 | | // Branch 1 |
| | | 631 | | //{ |
| | | 632 | | // 7th capture group. |
| | | 633 | | //{ |
| | | 634 | | capture_starting_pos6 = pos; |
| | | 635 | | |
| | | 636 | | // Match '['. |
| | | 637 | | if (slice.IsEmpty || slice[0] != '[') |
| | | 638 | | { |
| | | 639 | | goto LoopIterationNoMatch; |
| | | 640 | | } |
| | | 641 | | |
| | | 642 | | // Loop exactly 3 times. |
| | | 643 | | //{ |
| | | 644 | | pos++; |
| | | 645 | | slice = inputSpan.Slice(pos); |
| | | 646 | | startingStackpos = stackpos; |
| | | 647 | | loop_iteration3 = 0; |
| | | 648 | | |
| | | 649 | | LoopBody3: |
| | | 650 | | Utilities.StackPush(ref base.runstack!, ref stackpos, base.Crawlpos(), pos); |
| | | 651 | | |
| | | 652 | | loop_iteration3++; |
| | | 653 | | |
| | | 654 | | // 8th capture group. |
| | | 655 | | //{ |
| | | 656 | | int capture_starting_pos7 = pos; |
| | | 657 | | |
| | | 658 | | // 9th capture group. |
| | | 659 | | //{ |
| | | 660 | | int capture_starting_pos8 = pos; |
| | | 661 | | |
| | | 662 | | // Match with 3 alternative expressions. |
| | | 663 | | //{ |
| | | 664 | | int alternation_starting_pos1 = pos; |
| | | 665 | | int alternation_starting_capturepos1 = base.Crawlpos(); |
| | | 666 | | |
| | | 667 | | // Branch 0 |
| | | 668 | | //{ |
| | | 669 | | // Match '2'. |
| | | 670 | | if (slice.IsEmpty || slice[0] != '2') |
| | | 671 | | { |
| | | 672 | | goto AlternationBranch1; |
| | | 673 | | } |
| | | 674 | | |
| | | 675 | | // Match with 2 alternative expressions. |
| | | 676 | | //{ |
| | | 677 | | if ((uint)slice.Length < 2) |
| | | 678 | | { |
| | | 679 | | goto AlternationBranch1; |
| | | 680 | | } |
| | | 681 | | |
| | | 682 | | switch (slice[1]) |
| | | 683 | | { |
| | | 684 | | case '5': |
| | | 685 | | |
| | | 686 | | // Match a character in the set [0-5]. |
| | | 687 | | if ((uint)slice.Length < 3 || !char.IsBetween(slice[ |
| | | 688 | | { |
| | | 689 | | goto AlternationBranch1; |
| | | 690 | | } |
| | | 691 | | |
| | | 692 | | pos += 3; |
| | | 693 | | slice = inputSpan.Slice(pos); |
| | | 694 | | break; |
| | | 695 | | |
| | | 696 | | case '0' or '1' or '2' or '3' or '4': |
| | | 697 | | |
| | | 698 | | // Match a character in the set [0-9]. |
| | | 699 | | if ((uint)slice.Length < 3 || !char.IsAsciiDigit(sli |
| | | 700 | | { |
| | | 701 | | goto AlternationBranch1; |
| | | 702 | | } |
| | | 703 | | |
| | | 704 | | pos += 3; |
| | | 705 | | slice = inputSpan.Slice(pos); |
| | | 706 | | break; |
| | | 707 | | |
| | | 708 | | default: |
| | | 709 | | goto AlternationBranch1; |
| | | 710 | | } |
| | | 711 | | //} |
| | | 712 | | |
| | | 713 | | Utilities.StackPush(ref base.runstack!, ref stackpos, 0, alterna |
| | | 714 | | goto AlternationMatch1; |
| | | 715 | | |
| | | 716 | | AlternationBranch1: |
| | | 717 | | pos = alternation_starting_pos1; |
| | | 718 | | slice = inputSpan.Slice(pos); |
| | | 719 | | UncaptureUntil(alternation_starting_capturepos1); |
| | | 720 | | //} |
| | | 721 | | |
| | | 722 | | // Branch 1 |
| | | 723 | | //{ |
| | | 724 | | if ((uint)slice.Length < 3 || |
| | | 725 | | slice[0] != '1' || // Match '1'. |
| | | 726 | | !char.IsAsciiDigit(slice[1]) || // Match a character in the |
| | | 727 | | !char.IsAsciiDigit(slice[2])) |
| | | 728 | | { |
| | | 729 | | goto AlternationBranch2; |
| | | 730 | | } |
| | | 731 | | |
| | | 732 | | Utilities.StackPush(ref base.runstack!, ref stackpos, 1, alterna |
| | | 733 | | pos += 3; |
| | | 734 | | slice = inputSpan.Slice(pos); |
| | | 735 | | goto AlternationMatch1; |
| | | 736 | | |
| | | 737 | | AlternationBranch2: |
| | | 738 | | pos = alternation_starting_pos1; |
| | | 739 | | slice = inputSpan.Slice(pos); |
| | | 740 | | UncaptureUntil(alternation_starting_capturepos1); |
| | | 741 | | //} |
| | | 742 | | |
| | | 743 | | // Branch 2 |
| | | 744 | | //{ |
| | | 745 | | // Match a character in the set [1-9] greedily, optionally. |
| | | 746 | | //{ |
| | | 747 | | charloop_starting_pos2 = pos; |
| | | 748 | | |
| | | 749 | | if (!slice.IsEmpty && char.IsBetween(slice[0], '1', '9')) |
| | | 750 | | { |
| | | 751 | | slice = slice.Slice(1); |
| | | 752 | | pos++; |
| | | 753 | | } |
| | | 754 | | |
| | | 755 | | charloop_ending_pos2 = pos; |
| | | 756 | | goto CharLoopEnd2; |
| | | 757 | | |
| | | 758 | | CharLoopBacktrack2: |
| | | 759 | | UncaptureUntil(base.runstack![--stackpos]); |
| | | 760 | | Utilities.StackPop(base.runstack!, ref stackpos, out charloo |
| | | 761 | | |
| | | 762 | | base.CheckTimeout(); |
| | | 763 | | |
| | | 764 | | if (charloop_starting_pos2 >= charloop_ending_pos2) |
| | | 765 | | { |
| | | 766 | | goto LoopIterationNoMatch3; |
| | | 767 | | } |
| | | 768 | | pos = --charloop_ending_pos2; |
| | | 769 | | slice = inputSpan.Slice(pos); |
| | | 770 | | |
| | | 771 | | CharLoopEnd2: |
| | | 772 | | Utilities.StackPush(ref base.runstack!, ref stackpos, charlo |
| | | 773 | | //} |
| | | 774 | | |
| | | 775 | | // Match a character in the set [0-9]. |
| | | 776 | | if (slice.IsEmpty || !char.IsAsciiDigit(slice[0])) |
| | | 777 | | { |
| | | 778 | | goto CharLoopBacktrack2; |
| | | 779 | | } |
| | | 780 | | |
| | | 781 | | Utilities.StackPush(ref base.runstack!, ref stackpos, 2, alterna |
| | | 782 | | pos++; |
| | | 783 | | slice = inputSpan.Slice(pos); |
| | | 784 | | goto AlternationMatch1; |
| | | 785 | | //} |
| | | 786 | | |
| | | 787 | | AlternationBacktrack1: |
| | | 788 | | base.CheckTimeout(); |
| | | 789 | | |
| | | 790 | | Utilities.StackPop(base.runstack!, ref stackpos, out alternation_sta |
| | | 791 | | switch (base.runstack![--stackpos]) |
| | | 792 | | { |
| | | 793 | | case 0: |
| | | 794 | | goto AlternationBranch1; |
| | | 795 | | case 1: |
| | | 796 | | goto AlternationBranch2; |
| | | 797 | | case 2: |
| | | 798 | | goto CharLoopBacktrack2; |
| | | 799 | | } |
| | | 800 | | |
| | | 801 | | AlternationMatch1:; |
| | | 802 | | //} |
| | | 803 | | |
| | | 804 | | base.Capture(9, capture_starting_pos8, pos); |
| | | 805 | | |
| | | 806 | | Utilities.StackPush(ref base.runstack!, ref stackpos, capture_starting_p |
| | | 807 | | goto CaptureSkipBacktrack4; |
| | | 808 | | |
| | | 809 | | CaptureBacktrack4: |
| | | 810 | | capture_starting_pos8 = base.runstack![--stackpos]; |
| | | 811 | | goto AlternationBacktrack1; |
| | | 812 | | |
| | | 813 | | CaptureSkipBacktrack4:; |
| | | 814 | | //} |
| | | 815 | | |
| | | 816 | | // Match '.'. |
| | | 817 | | if (slice.IsEmpty || slice[0] != '.') |
| | | 818 | | { |
| | | 819 | | goto CaptureBacktrack4; |
| | | 820 | | } |
| | | 821 | | |
| | | 822 | | pos++; |
| | | 823 | | slice = inputSpan.Slice(pos); |
| | | 824 | | base.Capture(8, capture_starting_pos7, pos); |
| | | 825 | | |
| | | 826 | | Utilities.StackPush(ref base.runstack!, ref stackpos, capture_starting_pos7) |
| | | 827 | | goto CaptureSkipBacktrack5; |
| | | 828 | | |
| | | 829 | | CaptureBacktrack5: |
| | | 830 | | capture_starting_pos7 = base.runstack![--stackpos]; |
| | | 831 | | goto CaptureBacktrack4; |
| | | 832 | | |
| | | 833 | | CaptureSkipBacktrack5:; |
| | | 834 | | //} |
| | | 835 | | |
| | | 836 | | |
| | | 837 | | // The loop has an upper bound of 3. Continue iterating greedily if it hasn't ye |
| | | 838 | | if (loop_iteration3 < 3) |
| | | 839 | | { |
| | | 840 | | goto LoopBody3; |
| | | 841 | | } |
| | | 842 | | goto LoopEnd3; |
| | | 843 | | |
| | | 844 | | // The loop iteration failed. Put state back to the way it was before the iterat |
| | | 845 | | LoopIterationNoMatch3: |
| | | 846 | | if (--loop_iteration3 < 0) |
| | | 847 | | { |
| | | 848 | | // Unable to match the remainder of the expression after exhausting the loop |
| | | 849 | | goto LoopIterationNoMatch; |
| | | 850 | | } |
| | | 851 | | pos = base.runstack![--stackpos]; |
| | | 852 | | UncaptureUntil(base.runstack![--stackpos]); |
| | | 853 | | slice = inputSpan.Slice(pos); |
| | | 854 | | if (loop_iteration3 == 0) |
| | | 855 | | { |
| | | 856 | | // No iterations have been matched to backtrack into. Fail the loop. |
| | | 857 | | goto LoopIterationNoMatch; |
| | | 858 | | } |
| | | 859 | | |
| | | 860 | | if (loop_iteration3 < 3) |
| | | 861 | | { |
| | | 862 | | // All possible iterations have matched, but it's below the required minimum |
| | | 863 | | // Backtrack into the prior iteration. |
| | | 864 | | goto CaptureBacktrack5; |
| | | 865 | | } |
| | | 866 | | |
| | | 867 | | goto LoopEnd3; |
| | | 868 | | |
| | | 869 | | LoopBacktrack3: |
| | | 870 | | base.CheckTimeout(); |
| | | 871 | | |
| | | 872 | | if (loop_iteration3 == 0) |
| | | 873 | | { |
| | | 874 | | // No iterations of the loop remain to backtrack into. Fail the loop. |
| | | 875 | | goto LoopIterationNoMatch; |
| | | 876 | | } |
| | | 877 | | goto CaptureBacktrack5; |
| | | 878 | | LoopEnd3:; |
| | | 879 | | //} |
| | | 880 | | |
| | | 881 | | // 10th capture group. |
| | | 882 | | //{ |
| | | 883 | | capture_starting_pos9 = pos; |
| | | 884 | | |
| | | 885 | | // Match with 3 alternative expressions. |
| | | 886 | | //{ |
| | | 887 | | alternation_starting_pos2 = pos; |
| | | 888 | | alternation_starting_capturepos2 = base.Crawlpos(); |
| | | 889 | | |
| | | 890 | | // Branch 0 |
| | | 891 | | //{ |
| | | 892 | | // Match '2'. |
| | | 893 | | if (slice.IsEmpty || slice[0] != '2') |
| | | 894 | | { |
| | | 895 | | goto AlternationBranch3; |
| | | 896 | | } |
| | | 897 | | |
| | | 898 | | // Match with 2 alternative expressions. |
| | | 899 | | //{ |
| | | 900 | | if ((uint)slice.Length < 2) |
| | | 901 | | { |
| | | 902 | | goto AlternationBranch3; |
| | | 903 | | } |
| | | 904 | | |
| | | 905 | | switch (slice[1]) |
| | | 906 | | { |
| | | 907 | | case '5': |
| | | 908 | | |
| | | 909 | | // Match a character in the set [0-5]. |
| | | 910 | | if ((uint)slice.Length < 3 || !char.IsBetween(slice[2], '0', |
| | | 911 | | { |
| | | 912 | | goto AlternationBranch3; |
| | | 913 | | } |
| | | 914 | | |
| | | 915 | | pos += 3; |
| | | 916 | | slice = inputSpan.Slice(pos); |
| | | 917 | | break; |
| | | 918 | | |
| | | 919 | | case '0' or '1' or '2' or '3' or '4': |
| | | 920 | | |
| | | 921 | | // Match a character in the set [0-9]. |
| | | 922 | | if ((uint)slice.Length < 3 || !char.IsAsciiDigit(slice[2])) |
| | | 923 | | { |
| | | 924 | | goto AlternationBranch3; |
| | | 925 | | } |
| | | 926 | | |
| | | 927 | | pos += 3; |
| | | 928 | | slice = inputSpan.Slice(pos); |
| | | 929 | | break; |
| | | 930 | | |
| | | 931 | | default: |
| | | 932 | | goto AlternationBranch3; |
| | | 933 | | } |
| | | 934 | | //} |
| | | 935 | | |
| | | 936 | | alternation_branch1 = 0; |
| | | 937 | | goto AlternationMatch2; |
| | | 938 | | |
| | | 939 | | AlternationBranch3: |
| | | 940 | | pos = alternation_starting_pos2; |
| | | 941 | | slice = inputSpan.Slice(pos); |
| | | 942 | | UncaptureUntil(alternation_starting_capturepos2); |
| | | 943 | | //} |
| | | 944 | | |
| | | 945 | | // Branch 1 |
| | | 946 | | //{ |
| | | 947 | | if ((uint)slice.Length < 3 || |
| | | 948 | | slice[0] != '1' || // Match '1'. |
| | | 949 | | !char.IsAsciiDigit(slice[1]) || // Match a character in the set [0-9 |
| | | 950 | | !char.IsAsciiDigit(slice[2])) |
| | | 951 | | { |
| | | 952 | | goto AlternationBranch4; |
| | | 953 | | } |
| | | 954 | | |
| | | 955 | | alternation_branch1 = 1; |
| | | 956 | | pos += 3; |
| | | 957 | | slice = inputSpan.Slice(pos); |
| | | 958 | | goto AlternationMatch2; |
| | | 959 | | |
| | | 960 | | AlternationBranch4: |
| | | 961 | | pos = alternation_starting_pos2; |
| | | 962 | | slice = inputSpan.Slice(pos); |
| | | 963 | | UncaptureUntil(alternation_starting_capturepos2); |
| | | 964 | | //} |
| | | 965 | | |
| | | 966 | | // Branch 2 |
| | | 967 | | //{ |
| | | 968 | | // Match a character in the set [1-9] greedily, optionally. |
| | | 969 | | //{ |
| | | 970 | | charloop_starting_pos3 = pos; |
| | | 971 | | |
| | | 972 | | if (!slice.IsEmpty && char.IsBetween(slice[0], '1', '9')) |
| | | 973 | | { |
| | | 974 | | slice = slice.Slice(1); |
| | | 975 | | pos++; |
| | | 976 | | } |
| | | 977 | | |
| | | 978 | | charloop_ending_pos3 = pos; |
| | | 979 | | goto CharLoopEnd3; |
| | | 980 | | |
| | | 981 | | CharLoopBacktrack3: |
| | | 982 | | UncaptureUntil(charloop_capture_pos1); |
| | | 983 | | |
| | | 984 | | base.CheckTimeout(); |
| | | 985 | | |
| | | 986 | | if (charloop_starting_pos3 >= charloop_ending_pos3) |
| | | 987 | | { |
| | | 988 | | goto LoopBacktrack3; |
| | | 989 | | } |
| | | 990 | | pos = --charloop_ending_pos3; |
| | | 991 | | slice = inputSpan.Slice(pos); |
| | | 992 | | |
| | | 993 | | CharLoopEnd3: |
| | | 994 | | charloop_capture_pos1 = base.Crawlpos(); |
| | | 995 | | //} |
| | | 996 | | |
| | | 997 | | // Match a character in the set [0-9]. |
| | | 998 | | if (slice.IsEmpty || !char.IsAsciiDigit(slice[0])) |
| | | 999 | | { |
| | | 1000 | | goto CharLoopBacktrack3; |
| | | 1001 | | } |
| | | 1002 | | |
| | | 1003 | | alternation_branch1 = 2; |
| | | 1004 | | pos++; |
| | | 1005 | | slice = inputSpan.Slice(pos); |
| | | 1006 | | goto AlternationMatch2; |
| | | 1007 | | //} |
| | | 1008 | | |
| | | 1009 | | AlternationBacktrack2: |
| | | 1010 | | base.CheckTimeout(); |
| | | 1011 | | |
| | | 1012 | | switch (alternation_branch1) |
| | | 1013 | | { |
| | | 1014 | | case 0: |
| | | 1015 | | goto AlternationBranch3; |
| | | 1016 | | case 1: |
| | | 1017 | | goto AlternationBranch4; |
| | | 1018 | | case 2: |
| | | 1019 | | goto CharLoopBacktrack3; |
| | | 1020 | | } |
| | | 1021 | | |
| | | 1022 | | AlternationMatch2:; |
| | | 1023 | | //} |
| | | 1024 | | |
| | | 1025 | | base.Capture(10, capture_starting_pos9, pos); |
| | | 1026 | | |
| | | 1027 | | goto CaptureSkipBacktrack6; |
| | | 1028 | | |
| | | 1029 | | CaptureBacktrack6: |
| | | 1030 | | goto AlternationBacktrack2; |
| | | 1031 | | |
| | | 1032 | | CaptureSkipBacktrack6:; |
| | | 1033 | | //} |
| | | 1034 | | |
| | | 1035 | | // Match ']'. |
| | | 1036 | | if (slice.IsEmpty || slice[0] != ']') |
| | | 1037 | | { |
| | | 1038 | | goto CaptureBacktrack6; |
| | | 1039 | | } |
| | | 1040 | | |
| | | 1041 | | pos++; |
| | | 1042 | | slice = inputSpan.Slice(pos); |
| | | 1043 | | base.Capture(7, capture_starting_pos6, pos); |
| | | 1044 | | |
| | | 1045 | | goto CaptureSkipBacktrack7; |
| | | 1046 | | |
| | | 1047 | | CaptureBacktrack7: |
| | | 1048 | | goto CaptureBacktrack6; |
| | | 1049 | | |
| | | 1050 | | CaptureSkipBacktrack7:; |
| | | 1051 | | //} |
| | | 1052 | | |
| | | 1053 | | alternation_branch = 1; |
| | | 1054 | | goto AlternationMatch; |
| | | 1055 | | //} |
| | | 1056 | | |
| | | 1057 | | AlternationBacktrack: |
| | | 1058 | | base.CheckTimeout(); |
| | | 1059 | | |
| | | 1060 | | switch (alternation_branch) |
| | | 1061 | | { |
| | | 1062 | | case 0: |
| | | 1063 | | goto CaptureBacktrack3; |
| | | 1064 | | case 1: |
| | | 1065 | | goto CaptureBacktrack7; |
| | | 1066 | | } |
| | | 1067 | | |
| | | 1068 | | AlternationMatch:; |
| | | 1069 | | //} |
| | | 1070 | | |
| | | 1071 | | base.Capture(2, capture_starting_pos1, pos); |
| | | 1072 | | |
| | | 1073 | | goto CaptureSkipBacktrack8; |
| | | 1074 | | |
| | | 1075 | | CaptureBacktrack8: |
| | | 1076 | | goto AlternationBacktrack; |
| | | 1077 | | |
| | | 1078 | | CaptureSkipBacktrack8:; |
| | | 1079 | | //} |
| | | 1080 | | |
| | | 1081 | | // Match if at the end of the string. |
| | | 1082 | | if ((uint)pos < (uint)inputSpan.Length) |
| | | 1083 | | { |
| | | 1084 | | goto CaptureBacktrack8; |
| | | 1085 | | } |
| | | 1086 | | |
| | | 1087 | | // The input matched. |
| | | 1088 | | base.runtextpos = pos; |
| | | 1089 | | base.Capture(0, matchStart, pos); |
| | | 1090 | | return true; |
| | | 1091 | | |
| | | 1092 | | // <summary>Undo captures until it reaches the specified capture position.</summary> |
| | | 1093 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | | 1094 | | void UncaptureUntil(int capturePosition) |
| | | 1095 | | { |
| | | 1096 | | while (base.Crawlpos() > capturePosition) |
| | | 1097 | | { |
| | | 1098 | | base.Uncapture(); |
| | | 1099 | | } |
| | | 1100 | | } |
| | | 1101 | | } |
| | | 1102 | | } |
| | | 1103 | | } |
| | | 1104 | | |
| | | 1105 | | } |
| | | 1106 | | |
| | | 1107 | | /// <summary>Custom <see cref="Regex"/>-derived type for the HasNumber method.</summary> |
| | | 1108 | | [GeneratedCodeAttribute("System.Text.RegularExpressions.Generator", "10.0.14.37416")] |
| | | 1109 | | file sealed class HasNumber_1 : Regex |
| | | 1110 | | { |
| | | 1111 | | /// <summary>Cached, thread-safe singleton instance.</summary> |
| | | 1112 | | internal static readonly HasNumber_1 Instance = new(); |
| | | 1113 | | |
| | | 1114 | | /// <summary>Initializes the instance.</summary> |
| | | 1115 | | private HasNumber_1() |
| | | 1116 | | { |
| | | 1117 | | base.pattern = "[0-9]+"; |
| | | 1118 | | base.roptions = RegexOptions.None; |
| | | 1119 | | base.internalMatchTimeout = TimeSpan.FromMilliseconds(100); |
| | | 1120 | | base.factory = new RunnerFactory(); |
| | | 1121 | | base.capsize = 1; |
| | | 1122 | | } |
| | | 1123 | | |
| | | 1124 | | /// <summary>Provides a factory for creating <see cref="RegexRunner"/> instances to be used by methods on <see c |
| | | 1125 | | private sealed class RunnerFactory : RegexRunnerFactory |
| | | 1126 | | { |
| | | 1127 | | /// <summary>Creates an instance of a <see cref="RegexRunner"/> used by methods on <see cref="Regex"/>.</sum |
| | | 1128 | | protected override RegexRunner CreateInstance() => new Runner(); |
| | | 1129 | | |
| | | 1130 | | /// <summary>Provides the runner that contains the custom logic implementing the specified regular expressio |
| | | 1131 | | private sealed class Runner : RegexRunner |
| | | 1132 | | { |
| | | 1133 | | /// <summary>Scan the <paramref name="inputSpan"/> starting from base.runtextstart for the next match.</ |
| | | 1134 | | /// <param name="inputSpan">The text being scanned by the regular expression.</param> |
| | | 1135 | | protected override void Scan(ReadOnlySpan<char> inputSpan) |
| | | 1136 | | { |
| | | 1137 | | // Search until we can't find a valid starting position, we find a match, or we reach the end of the |
| | | 1138 | | while (TryFindNextPossibleStartingPosition(inputSpan) && |
| | | 1139 | | !TryMatchAtCurrentPosition(inputSpan) && |
| | | 1140 | | base.runtextpos != inputSpan.Length) |
| | | 1141 | | { |
| | | 1142 | | base.runtextpos++; |
| | | 1143 | | base.CheckTimeout(); |
| | | 1144 | | } |
| | | 1145 | | } |
| | | 1146 | | |
| | | 1147 | | /// <summary>Search <paramref name="inputSpan"/> starting from base.runtextpos for the next location a m |
| | | 1148 | | /// <param name="inputSpan">The text being scanned by the regular expression.</param> |
| | | 1149 | | /// <returns>true if a possible match was found; false if no more matches are possible.</returns> |
| | | 1150 | | private bool TryFindNextPossibleStartingPosition(ReadOnlySpan<char> inputSpan) |
| | | 1151 | | { |
| | | 1152 | | int pos = base.runtextpos; |
| | | 1153 | | |
| | | 1154 | | // Empty matches aren't possible. |
| | | 1155 | | if ((uint)pos < (uint)inputSpan.Length) |
| | | 1156 | | { |
| | | 1157 | | // The pattern begins with a character in the set [0-9]. |
| | | 1158 | | // Find the next occurrence. If it can't be found, there's no match. |
| | | 1159 | | int i = inputSpan.Slice(pos).IndexOfAnyInRange('0', '9'); |
| | | 1160 | | if (i >= 0) |
| | | 1161 | | { |
| | | 1162 | | base.runtextpos = pos + i; |
| | | 1163 | | return true; |
| | | 1164 | | } |
| | | 1165 | | } |
| | | 1166 | | |
| | | 1167 | | // No match found. |
| | | 1168 | | base.runtextpos = inputSpan.Length; |
| | | 1169 | | return false; |
| | | 1170 | | } |
| | | 1171 | | |
| | | 1172 | | /// <summary>Determine whether <paramref name="inputSpan"/> at base.runtextpos is a match for the regula |
| | | 1173 | | /// <param name="inputSpan">The text being scanned by the regular expression.</param> |
| | | 1174 | | /// <returns>true if the regular expression matches at the current position; otherwise, false.</returns> |
| | | 1175 | | private bool TryMatchAtCurrentPosition(ReadOnlySpan<char> inputSpan) |
| | | 1176 | | { |
| | | 1177 | | int pos = base.runtextpos; |
| | | 1178 | | int matchStart = pos; |
| | | 1179 | | ReadOnlySpan<char> slice = inputSpan.Slice(pos); |
| | | 1180 | | |
| | | 1181 | | // Match a character in the set [0-9] atomically at least once. |
| | | 1182 | | { |
| | | 1183 | | int iteration = slice.IndexOfAnyExceptInRange('0', '9'); |
| | | 1184 | | if (iteration < 0) |
| | | 1185 | | { |
| | | 1186 | | iteration = slice.Length; |
| | | 1187 | | } |
| | | 1188 | | |
| | | 1189 | | if (iteration == 0) |
| | | 1190 | | { |
| | | 1191 | | return false; // The input didn't match. |
| | | 1192 | | } |
| | | 1193 | | |
| | | 1194 | | slice = slice.Slice(iteration); |
| | | 1195 | | pos += iteration; |
| | | 1196 | | } |
| | | 1197 | | |
| | | 1198 | | // The input matched. |
| | | 1199 | | base.runtextpos = pos; |
| | | 1200 | | base.Capture(0, matchStart, pos); |
| | | 1201 | | return true; |
| | | 1202 | | } |
| | | 1203 | | } |
| | | 1204 | | } |
| | | 1205 | | |
| | | 1206 | | } |
| | | 1207 | | |
| | | 1208 | | /// <summary>Custom <see cref="Regex"/>-derived type for the HasLowerChar method.</summary> |
| | | 1209 | | [GeneratedCodeAttribute("System.Text.RegularExpressions.Generator", "10.0.14.37416")] |
| | | 1210 | | file sealed class HasLowerChar_2 : Regex |
| | | 1211 | | { |
| | | 1212 | | /// <summary>Cached, thread-safe singleton instance.</summary> |
| | 1 | 1213 | | internal static readonly HasLowerChar_2 Instance = new(); |
| | | 1214 | | |
| | | 1215 | | /// <summary>Initializes the instance.</summary> |
| | 1 | 1216 | | private HasLowerChar_2() |
| | | 1217 | | { |
| | 1 | 1218 | | base.pattern = "[a-z]+"; |
| | 1 | 1219 | | base.roptions = RegexOptions.None; |
| | 1 | 1220 | | base.internalMatchTimeout = TimeSpan.FromMilliseconds(100); |
| | 1 | 1221 | | base.factory = new RunnerFactory(); |
| | 1 | 1222 | | base.capsize = 1; |
| | 1 | 1223 | | } |
| | | 1224 | | |
| | | 1225 | | /// <summary>Provides a factory for creating <see cref="RegexRunner"/> instances to be used by methods on <see c |
| | | 1226 | | private sealed class RunnerFactory : RegexRunnerFactory |
| | | 1227 | | { |
| | | 1228 | | /// <summary>Creates an instance of a <see cref="RegexRunner"/> used by methods on <see cref="Regex"/>.</sum |
| | 1 | 1229 | | protected override RegexRunner CreateInstance() => new Runner(); |
| | | 1230 | | |
| | | 1231 | | /// <summary>Provides the runner that contains the custom logic implementing the specified regular expressio |
| | | 1232 | | private sealed class Runner : RegexRunner |
| | | 1233 | | { |
| | | 1234 | | /// <summary>Scan the <paramref name="inputSpan"/> starting from base.runtextstart for the next match.</ |
| | | 1235 | | /// <param name="inputSpan">The text being scanned by the regular expression.</param> |
| | | 1236 | | protected override void Scan(ReadOnlySpan<char> inputSpan) |
| | | 1237 | | { |
| | | 1238 | | // Search until we can't find a valid starting position, we find a match, or we reach the end of the |
| | 9 | 1239 | | while (TryFindNextPossibleStartingPosition(inputSpan) && |
| | 9 | 1240 | | !TryMatchAtCurrentPosition(inputSpan) && |
| | 9 | 1241 | | base.runtextpos != inputSpan.Length) |
| | | 1242 | | { |
| | 0 | 1243 | | base.runtextpos++; |
| | 0 | 1244 | | base.CheckTimeout(); |
| | | 1245 | | } |
| | 9 | 1246 | | } |
| | | 1247 | | |
| | | 1248 | | /// <summary>Search <paramref name="inputSpan"/> starting from base.runtextpos for the next location a m |
| | | 1249 | | /// <param name="inputSpan">The text being scanned by the regular expression.</param> |
| | | 1250 | | /// <returns>true if a possible match was found; false if no more matches are possible.</returns> |
| | | 1251 | | private bool TryFindNextPossibleStartingPosition(ReadOnlySpan<char> inputSpan) |
| | | 1252 | | { |
| | 9 | 1253 | | int pos = base.runtextpos; |
| | | 1254 | | |
| | | 1255 | | // Empty matches aren't possible. |
| | 9 | 1256 | | if ((uint)pos < (uint)inputSpan.Length) |
| | | 1257 | | { |
| | | 1258 | | // The pattern begins with a character in the set [a-z]. |
| | | 1259 | | // Find the next occurrence. If it can't be found, there's no match. |
| | 8 | 1260 | | int i = inputSpan.Slice(pos).IndexOfAnyInRange('a', 'z'); |
| | 8 | 1261 | | if (i >= 0) |
| | | 1262 | | { |
| | 3 | 1263 | | base.runtextpos = pos + i; |
| | 3 | 1264 | | return true; |
| | | 1265 | | } |
| | | 1266 | | } |
| | | 1267 | | |
| | | 1268 | | // No match found. |
| | 6 | 1269 | | base.runtextpos = inputSpan.Length; |
| | 6 | 1270 | | return false; |
| | | 1271 | | } |
| | | 1272 | | |
| | | 1273 | | /// <summary>Determine whether <paramref name="inputSpan"/> at base.runtextpos is a match for the regula |
| | | 1274 | | /// <param name="inputSpan">The text being scanned by the regular expression.</param> |
| | | 1275 | | /// <returns>true if the regular expression matches at the current position; otherwise, false.</returns> |
| | | 1276 | | private bool TryMatchAtCurrentPosition(ReadOnlySpan<char> inputSpan) |
| | | 1277 | | { |
| | 3 | 1278 | | int pos = base.runtextpos; |
| | 3 | 1279 | | int matchStart = pos; |
| | 3 | 1280 | | ReadOnlySpan<char> slice = inputSpan.Slice(pos); |
| | | 1281 | | |
| | | 1282 | | // Match a character in the set [a-z] atomically at least once. |
| | | 1283 | | { |
| | 3 | 1284 | | int iteration = slice.IndexOfAnyExceptInRange('a', 'z'); |
| | 3 | 1285 | | if (iteration < 0) |
| | | 1286 | | { |
| | 2 | 1287 | | iteration = slice.Length; |
| | | 1288 | | } |
| | | 1289 | | |
| | 3 | 1290 | | if (iteration == 0) |
| | | 1291 | | { |
| | 0 | 1292 | | return false; // The input didn't match. |
| | | 1293 | | } |
| | | 1294 | | |
| | 3 | 1295 | | slice = slice.Slice(iteration); |
| | 3 | 1296 | | pos += iteration; |
| | | 1297 | | } |
| | | 1298 | | |
| | | 1299 | | // The input matched. |
| | 3 | 1300 | | base.runtextpos = pos; |
| | 3 | 1301 | | base.Capture(0, matchStart, pos); |
| | 3 | 1302 | | return true; |
| | | 1303 | | } |
| | | 1304 | | } |
| | | 1305 | | } |
| | | 1306 | | |
| | | 1307 | | } |
| | | 1308 | | |
| | | 1309 | | /// <summary>Custom <see cref="Regex"/>-derived type for the HasUpperChar method.</summary> |
| | | 1310 | | [GeneratedCodeAttribute("System.Text.RegularExpressions.Generator", "10.0.14.37416")] |
| | | 1311 | | file sealed class HasUpperChar_3 : Regex |
| | | 1312 | | { |
| | | 1313 | | /// <summary>Cached, thread-safe singleton instance.</summary> |
| | | 1314 | | internal static readonly HasUpperChar_3 Instance = new(); |
| | | 1315 | | |
| | | 1316 | | /// <summary>Initializes the instance.</summary> |
| | | 1317 | | private HasUpperChar_3() |
| | | 1318 | | { |
| | | 1319 | | base.pattern = "[A-Z]+"; |
| | | 1320 | | base.roptions = RegexOptions.None; |
| | | 1321 | | base.internalMatchTimeout = TimeSpan.FromMilliseconds(100); |
| | | 1322 | | base.factory = new RunnerFactory(); |
| | | 1323 | | base.capsize = 1; |
| | | 1324 | | } |
| | | 1325 | | |
| | | 1326 | | /// <summary>Provides a factory for creating <see cref="RegexRunner"/> instances to be used by methods on <see c |
| | | 1327 | | private sealed class RunnerFactory : RegexRunnerFactory |
| | | 1328 | | { |
| | | 1329 | | /// <summary>Creates an instance of a <see cref="RegexRunner"/> used by methods on <see cref="Regex"/>.</sum |
| | | 1330 | | protected override RegexRunner CreateInstance() => new Runner(); |
| | | 1331 | | |
| | | 1332 | | /// <summary>Provides the runner that contains the custom logic implementing the specified regular expressio |
| | | 1333 | | private sealed class Runner : RegexRunner |
| | | 1334 | | { |
| | | 1335 | | /// <summary>Scan the <paramref name="inputSpan"/> starting from base.runtextstart for the next match.</ |
| | | 1336 | | /// <param name="inputSpan">The text being scanned by the regular expression.</param> |
| | | 1337 | | protected override void Scan(ReadOnlySpan<char> inputSpan) |
| | | 1338 | | { |
| | | 1339 | | // Search until we can't find a valid starting position, we find a match, or we reach the end of the |
| | | 1340 | | while (TryFindNextPossibleStartingPosition(inputSpan) && |
| | | 1341 | | !TryMatchAtCurrentPosition(inputSpan) && |
| | | 1342 | | base.runtextpos != inputSpan.Length) |
| | | 1343 | | { |
| | | 1344 | | base.runtextpos++; |
| | | 1345 | | base.CheckTimeout(); |
| | | 1346 | | } |
| | | 1347 | | } |
| | | 1348 | | |
| | | 1349 | | /// <summary>Search <paramref name="inputSpan"/> starting from base.runtextpos for the next location a m |
| | | 1350 | | /// <param name="inputSpan">The text being scanned by the regular expression.</param> |
| | | 1351 | | /// <returns>true if a possible match was found; false if no more matches are possible.</returns> |
| | | 1352 | | private bool TryFindNextPossibleStartingPosition(ReadOnlySpan<char> inputSpan) |
| | | 1353 | | { |
| | | 1354 | | int pos = base.runtextpos; |
| | | 1355 | | |
| | | 1356 | | // Empty matches aren't possible. |
| | | 1357 | | if ((uint)pos < (uint)inputSpan.Length) |
| | | 1358 | | { |
| | | 1359 | | // The pattern begins with a character in the set [A-Z]. |
| | | 1360 | | // Find the next occurrence. If it can't be found, there's no match. |
| | | 1361 | | int i = inputSpan.Slice(pos).IndexOfAnyInRange('A', 'Z'); |
| | | 1362 | | if (i >= 0) |
| | | 1363 | | { |
| | | 1364 | | base.runtextpos = pos + i; |
| | | 1365 | | return true; |
| | | 1366 | | } |
| | | 1367 | | } |
| | | 1368 | | |
| | | 1369 | | // No match found. |
| | | 1370 | | base.runtextpos = inputSpan.Length; |
| | | 1371 | | return false; |
| | | 1372 | | } |
| | | 1373 | | |
| | | 1374 | | /// <summary>Determine whether <paramref name="inputSpan"/> at base.runtextpos is a match for the regula |
| | | 1375 | | /// <param name="inputSpan">The text being scanned by the regular expression.</param> |
| | | 1376 | | /// <returns>true if the regular expression matches at the current position; otherwise, false.</returns> |
| | | 1377 | | private bool TryMatchAtCurrentPosition(ReadOnlySpan<char> inputSpan) |
| | | 1378 | | { |
| | | 1379 | | int pos = base.runtextpos; |
| | | 1380 | | int matchStart = pos; |
| | | 1381 | | ReadOnlySpan<char> slice = inputSpan.Slice(pos); |
| | | 1382 | | |
| | | 1383 | | // Match a character in the set [A-Z] atomically at least once. |
| | | 1384 | | { |
| | | 1385 | | int iteration = slice.IndexOfAnyExceptInRange('A', 'Z'); |
| | | 1386 | | if (iteration < 0) |
| | | 1387 | | { |
| | | 1388 | | iteration = slice.Length; |
| | | 1389 | | } |
| | | 1390 | | |
| | | 1391 | | if (iteration == 0) |
| | | 1392 | | { |
| | | 1393 | | return false; // The input didn't match. |
| | | 1394 | | } |
| | | 1395 | | |
| | | 1396 | | slice = slice.Slice(iteration); |
| | | 1397 | | pos += iteration; |
| | | 1398 | | } |
| | | 1399 | | |
| | | 1400 | | // The input matched. |
| | | 1401 | | base.runtextpos = pos; |
| | | 1402 | | base.Capture(0, matchStart, pos); |
| | | 1403 | | return true; |
| | | 1404 | | } |
| | | 1405 | | } |
| | | 1406 | | } |
| | | 1407 | | |
| | | 1408 | | } |
| | | 1409 | | |
| | | 1410 | | /// <summary>Custom <see cref="Regex"/>-derived type for the HasNumberLowerAndUpperChar method.</summary> |
| | | 1411 | | [GeneratedCodeAttribute("System.Text.RegularExpressions.Generator", "10.0.14.37416")] |
| | | 1412 | | file sealed class HasNumberLowerAndUpperChar_4 : Regex |
| | | 1413 | | { |
| | | 1414 | | /// <summary>Cached, thread-safe singleton instance.</summary> |
| | | 1415 | | internal static readonly HasNumberLowerAndUpperChar_4 Instance = new(); |
| | | 1416 | | |
| | | 1417 | | /// <summary>Initializes the instance.</summary> |
| | | 1418 | | private HasNumberLowerAndUpperChar_4() |
| | | 1419 | | { |
| | | 1420 | | base.pattern = "^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d).+\\z"; |
| | | 1421 | | base.roptions = RegexOptions.None; |
| | | 1422 | | base.internalMatchTimeout = TimeSpan.FromMilliseconds(100); |
| | | 1423 | | base.factory = new RunnerFactory(); |
| | | 1424 | | base.capsize = 1; |
| | | 1425 | | } |
| | | 1426 | | |
| | | 1427 | | /// <summary>Provides a factory for creating <see cref="RegexRunner"/> instances to be used by methods on <see c |
| | | 1428 | | private sealed class RunnerFactory : RegexRunnerFactory |
| | | 1429 | | { |
| | | 1430 | | /// <summary>Creates an instance of a <see cref="RegexRunner"/> used by methods on <see cref="Regex"/>.</sum |
| | | 1431 | | protected override RegexRunner CreateInstance() => new Runner(); |
| | | 1432 | | |
| | | 1433 | | /// <summary>Provides the runner that contains the custom logic implementing the specified regular expressio |
| | | 1434 | | private sealed class Runner : RegexRunner |
| | | 1435 | | { |
| | | 1436 | | /// <summary>Scan the <paramref name="inputSpan"/> starting from base.runtextstart for the next match.</ |
| | | 1437 | | /// <param name="inputSpan">The text being scanned by the regular expression.</param> |
| | | 1438 | | protected override void Scan(ReadOnlySpan<char> inputSpan) |
| | | 1439 | | { |
| | | 1440 | | // The pattern is anchored. Validate the current position and try to match at it only. |
| | | 1441 | | if (TryFindNextPossibleStartingPosition(inputSpan) && !TryMatchAtCurrentPosition(inputSpan)) |
| | | 1442 | | { |
| | | 1443 | | base.runtextpos = inputSpan.Length; |
| | | 1444 | | } |
| | | 1445 | | } |
| | | 1446 | | |
| | | 1447 | | /// <summary>Search <paramref name="inputSpan"/> starting from base.runtextpos for the next location a m |
| | | 1448 | | /// <param name="inputSpan">The text being scanned by the regular expression.</param> |
| | | 1449 | | /// <returns>true if a possible match was found; false if no more matches are possible.</returns> |
| | | 1450 | | private bool TryFindNextPossibleStartingPosition(ReadOnlySpan<char> inputSpan) |
| | | 1451 | | { |
| | | 1452 | | int pos = base.runtextpos; |
| | | 1453 | | |
| | | 1454 | | // Empty matches aren't possible. |
| | | 1455 | | if ((uint)pos < (uint)inputSpan.Length) |
| | | 1456 | | { |
| | | 1457 | | // The pattern leads with a beginning (\A) anchor. |
| | | 1458 | | if (pos == 0) |
| | | 1459 | | { |
| | | 1460 | | return true; |
| | | 1461 | | } |
| | | 1462 | | } |
| | | 1463 | | |
| | | 1464 | | // No match found. |
| | | 1465 | | base.runtextpos = inputSpan.Length; |
| | | 1466 | | return false; |
| | | 1467 | | } |
| | | 1468 | | |
| | | 1469 | | /// <summary>Determine whether <paramref name="inputSpan"/> at base.runtextpos is a match for the regula |
| | | 1470 | | /// <param name="inputSpan">The text being scanned by the regular expression.</param> |
| | | 1471 | | /// <returns>true if the regular expression matches at the current position; otherwise, false.</returns> |
| | | 1472 | | private bool TryMatchAtCurrentPosition(ReadOnlySpan<char> inputSpan) |
| | | 1473 | | { |
| | | 1474 | | int pos = base.runtextpos; |
| | | 1475 | | int matchStart = pos; |
| | | 1476 | | int charloop_starting_pos = 0, charloop_ending_pos = 0; |
| | | 1477 | | int charloop_starting_pos1 = 0, charloop_ending_pos1 = 0; |
| | | 1478 | | int charloop_starting_pos2 = 0, charloop_ending_pos2 = 0; |
| | | 1479 | | int stackpos = 0; |
| | | 1480 | | ReadOnlySpan<char> slice = inputSpan.Slice(pos); |
| | | 1481 | | |
| | | 1482 | | // Match if at the beginning of the string. |
| | | 1483 | | if (pos != 0) |
| | | 1484 | | { |
| | | 1485 | | return false; // The input didn't match. |
| | | 1486 | | } |
| | | 1487 | | |
| | | 1488 | | // Zero-width positive lookahead. |
| | | 1489 | | { |
| | | 1490 | | int positivelookahead_starting_pos = pos; |
| | | 1491 | | |
| | | 1492 | | base.CheckTimeout(); |
| | | 1493 | | |
| | | 1494 | | int atomic_stackpos = stackpos; |
| | | 1495 | | |
| | | 1496 | | // Match a character other than '\n' greedily any number of times. |
| | | 1497 | | //{ |
| | | 1498 | | charloop_starting_pos = pos; |
| | | 1499 | | |
| | | 1500 | | int iteration = slice.IndexOf('\n'); |
| | | 1501 | | if (iteration < 0) |
| | | 1502 | | { |
| | | 1503 | | iteration = slice.Length; |
| | | 1504 | | } |
| | | 1505 | | |
| | | 1506 | | slice = slice.Slice(iteration); |
| | | 1507 | | pos += iteration; |
| | | 1508 | | |
| | | 1509 | | charloop_ending_pos = pos; |
| | | 1510 | | goto CharLoopEnd; |
| | | 1511 | | |
| | | 1512 | | CharLoopBacktrack: |
| | | 1513 | | |
| | | 1514 | | base.CheckTimeout(); |
| | | 1515 | | |
| | | 1516 | | if (charloop_starting_pos >= charloop_ending_pos || |
| | | 1517 | | (charloop_ending_pos = inputSpan.Slice(charloop_starting_pos, charloop_ending_pos - char |
| | | 1518 | | { |
| | | 1519 | | return false; // The input didn't match. |
| | | 1520 | | } |
| | | 1521 | | charloop_ending_pos += charloop_starting_pos; |
| | | 1522 | | pos = charloop_ending_pos; |
| | | 1523 | | slice = inputSpan.Slice(pos); |
| | | 1524 | | |
| | | 1525 | | CharLoopEnd: |
| | | 1526 | | //} |
| | | 1527 | | |
| | | 1528 | | // Match a character in the set [a-z]. |
| | | 1529 | | if (slice.IsEmpty || !char.IsAsciiLetterLower(slice[0])) |
| | | 1530 | | { |
| | | 1531 | | goto CharLoopBacktrack; |
| | | 1532 | | } |
| | | 1533 | | |
| | | 1534 | | stackpos = atomic_stackpos; |
| | | 1535 | | |
| | | 1536 | | pos = positivelookahead_starting_pos; |
| | | 1537 | | slice = inputSpan.Slice(pos); |
| | | 1538 | | } |
| | | 1539 | | |
| | | 1540 | | // Zero-width positive lookahead. |
| | | 1541 | | { |
| | | 1542 | | int positivelookahead_starting_pos1 = pos; |
| | | 1543 | | |
| | | 1544 | | base.CheckTimeout(); |
| | | 1545 | | |
| | | 1546 | | int atomic_stackpos1 = stackpos; |
| | | 1547 | | |
| | | 1548 | | // Match a character other than '\n' greedily any number of times. |
| | | 1549 | | //{ |
| | | 1550 | | charloop_starting_pos1 = pos; |
| | | 1551 | | |
| | | 1552 | | int iteration1 = slice.IndexOf('\n'); |
| | | 1553 | | if (iteration1 < 0) |
| | | 1554 | | { |
| | | 1555 | | iteration1 = slice.Length; |
| | | 1556 | | } |
| | | 1557 | | |
| | | 1558 | | slice = slice.Slice(iteration1); |
| | | 1559 | | pos += iteration1; |
| | | 1560 | | |
| | | 1561 | | charloop_ending_pos1 = pos; |
| | | 1562 | | goto CharLoopEnd1; |
| | | 1563 | | |
| | | 1564 | | CharLoopBacktrack1: |
| | | 1565 | | |
| | | 1566 | | base.CheckTimeout(); |
| | | 1567 | | |
| | | 1568 | | if (charloop_starting_pos1 >= charloop_ending_pos1 || |
| | | 1569 | | (charloop_ending_pos1 = inputSpan.Slice(charloop_starting_pos1, charloop_ending_pos1 - c |
| | | 1570 | | { |
| | | 1571 | | return false; // The input didn't match. |
| | | 1572 | | } |
| | | 1573 | | charloop_ending_pos1 += charloop_starting_pos1; |
| | | 1574 | | pos = charloop_ending_pos1; |
| | | 1575 | | slice = inputSpan.Slice(pos); |
| | | 1576 | | |
| | | 1577 | | CharLoopEnd1: |
| | | 1578 | | //} |
| | | 1579 | | |
| | | 1580 | | // Match a character in the set [A-Z]. |
| | | 1581 | | if (slice.IsEmpty || !char.IsAsciiLetterUpper(slice[0])) |
| | | 1582 | | { |
| | | 1583 | | goto CharLoopBacktrack1; |
| | | 1584 | | } |
| | | 1585 | | |
| | | 1586 | | stackpos = atomic_stackpos1; |
| | | 1587 | | |
| | | 1588 | | pos = positivelookahead_starting_pos1; |
| | | 1589 | | slice = inputSpan.Slice(pos); |
| | | 1590 | | } |
| | | 1591 | | |
| | | 1592 | | // Zero-width positive lookahead. |
| | | 1593 | | { |
| | | 1594 | | int positivelookahead_starting_pos2 = pos; |
| | | 1595 | | |
| | | 1596 | | base.CheckTimeout(); |
| | | 1597 | | |
| | | 1598 | | int atomic_stackpos2 = stackpos; |
| | | 1599 | | |
| | | 1600 | | // Match a character other than '\n' greedily any number of times. |
| | | 1601 | | //{ |
| | | 1602 | | charloop_starting_pos2 = pos; |
| | | 1603 | | |
| | | 1604 | | int iteration2 = slice.IndexOf('\n'); |
| | | 1605 | | if (iteration2 < 0) |
| | | 1606 | | { |
| | | 1607 | | iteration2 = slice.Length; |
| | | 1608 | | } |
| | | 1609 | | |
| | | 1610 | | slice = slice.Slice(iteration2); |
| | | 1611 | | pos += iteration2; |
| | | 1612 | | |
| | | 1613 | | charloop_ending_pos2 = pos; |
| | | 1614 | | goto CharLoopEnd2; |
| | | 1615 | | |
| | | 1616 | | CharLoopBacktrack2: |
| | | 1617 | | |
| | | 1618 | | base.CheckTimeout(); |
| | | 1619 | | |
| | | 1620 | | if (charloop_starting_pos2 >= charloop_ending_pos2) |
| | | 1621 | | { |
| | | 1622 | | return false; // The input didn't match. |
| | | 1623 | | } |
| | | 1624 | | pos = --charloop_ending_pos2; |
| | | 1625 | | slice = inputSpan.Slice(pos); |
| | | 1626 | | |
| | | 1627 | | CharLoopEnd2: |
| | | 1628 | | //} |
| | | 1629 | | |
| | | 1630 | | // Match a Unicode digit. |
| | | 1631 | | if (slice.IsEmpty || !char.IsDigit(slice[0])) |
| | | 1632 | | { |
| | | 1633 | | goto CharLoopBacktrack2; |
| | | 1634 | | } |
| | | 1635 | | |
| | | 1636 | | stackpos = atomic_stackpos2; |
| | | 1637 | | |
| | | 1638 | | pos = positivelookahead_starting_pos2; |
| | | 1639 | | slice = inputSpan.Slice(pos); |
| | | 1640 | | } |
| | | 1641 | | |
| | | 1642 | | // Match a character other than '\n' atomically at least once. |
| | | 1643 | | { |
| | | 1644 | | int iteration3 = slice.IndexOf('\n'); |
| | | 1645 | | if (iteration3 < 0) |
| | | 1646 | | { |
| | | 1647 | | iteration3 = slice.Length; |
| | | 1648 | | } |
| | | 1649 | | |
| | | 1650 | | if (iteration3 == 0) |
| | | 1651 | | { |
| | | 1652 | | return false; // The input didn't match. |
| | | 1653 | | } |
| | | 1654 | | |
| | | 1655 | | slice = slice.Slice(iteration3); |
| | | 1656 | | pos += iteration3; |
| | | 1657 | | } |
| | | 1658 | | |
| | | 1659 | | // Match if at the end of the string. |
| | | 1660 | | if ((uint)pos < (uint)inputSpan.Length) |
| | | 1661 | | { |
| | | 1662 | | return false; // The input didn't match. |
| | | 1663 | | } |
| | | 1664 | | |
| | | 1665 | | // The input matched. |
| | | 1666 | | base.runtextpos = pos; |
| | | 1667 | | base.Capture(0, matchStart, pos); |
| | | 1668 | | return true; |
| | | 1669 | | } |
| | | 1670 | | } |
| | | 1671 | | } |
| | | 1672 | | |
| | | 1673 | | } |
| | | 1674 | | |
| | | 1675 | | /// <summary>Helper methods used by generated <see cref="Regex"/>-derived implementations.</summary> |
| | | 1676 | | [GeneratedCodeAttribute("System.Text.RegularExpressions.Generator", "10.0.14.37416")] |
| | | 1677 | | file static class Utilities |
| | | 1678 | | { |
| | | 1679 | | /// <summary>Pops 2 values from the backtracking stack.</summary> |
| | | 1680 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | | 1681 | | internal static void StackPop(int[] stack, ref int pos, out int arg0, out int arg1) |
| | | 1682 | | { |
| | | 1683 | | arg0 = stack[--pos]; |
| | | 1684 | | arg1 = stack[--pos]; |
| | | 1685 | | } |
| | | 1686 | | |
| | | 1687 | | /// <summary>Pushes 1 value onto the backtracking stack.</summary> |
| | | 1688 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | | 1689 | | internal static void StackPush(ref int[] stack, ref int pos, int arg0) |
| | | 1690 | | { |
| | | 1691 | | // If there's space available for the value, store it. |
| | | 1692 | | int[] s = stack; |
| | | 1693 | | int p = pos; |
| | | 1694 | | if ((uint)p < (uint)s.Length) |
| | | 1695 | | { |
| | | 1696 | | s[p] = arg0; |
| | | 1697 | | pos++; |
| | | 1698 | | return; |
| | | 1699 | | } |
| | | 1700 | | |
| | | 1701 | | // Otherwise, resize the stack to make room and try again. |
| | | 1702 | | WithResize(ref stack, ref pos, arg0); |
| | | 1703 | | |
| | | 1704 | | // <summary>Resize the backtracking stack array and push 1 value onto the stack.</summary> |
| | | 1705 | | [MethodImpl(MethodImplOptions.NoInlining)] |
| | | 1706 | | static void WithResize(ref int[] stack, ref int pos, int arg0) |
| | | 1707 | | { |
| | | 1708 | | Array.Resize(ref stack, (pos + 0) * 2); |
| | | 1709 | | StackPush(ref stack, ref pos, arg0); |
| | | 1710 | | } |
| | | 1711 | | } |
| | | 1712 | | |
| | | 1713 | | /// <summary>Pushes 2 values onto the backtracking stack.</summary> |
| | | 1714 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | | 1715 | | internal static void StackPush(ref int[] stack, ref int pos, int arg0, int arg1) |
| | | 1716 | | { |
| | | 1717 | | // If there's space available for all 2 values, store them. |
| | | 1718 | | int[] s = stack; |
| | | 1719 | | int p = pos; |
| | | 1720 | | if ((uint)(p + 1) < (uint)s.Length) |
| | | 1721 | | { |
| | | 1722 | | s[p] = arg0; |
| | | 1723 | | s[p + 1] = arg1; |
| | | 1724 | | pos += 2; |
| | | 1725 | | return; |
| | | 1726 | | } |
| | | 1727 | | |
| | | 1728 | | // Otherwise, resize the stack to make room and try again. |
| | | 1729 | | WithResize(ref stack, ref pos, arg0, arg1); |
| | | 1730 | | |
| | | 1731 | | // <summary>Resize the backtracking stack array and push 2 values onto the stack.</summary> |
| | | 1732 | | [MethodImpl(MethodImplOptions.NoInlining)] |
| | | 1733 | | static void WithResize(ref int[] stack, ref int pos, int arg0, int arg1) |
| | | 1734 | | { |
| | | 1735 | | Array.Resize(ref stack, (pos + 1) * 2); |
| | | 1736 | | StackPush(ref stack, ref pos, arg0, arg1); |
| | | 1737 | | } |
| | | 1738 | | } |
| | | 1739 | | |
| | | 1740 | | /// <summary>Pushes 3 values onto the backtracking stack.</summary> |
| | | 1741 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | | 1742 | | internal static void StackPush(ref int[] stack, ref int pos, int arg0, int arg1, int arg2) |
| | | 1743 | | { |
| | | 1744 | | // If there's space available for all 3 values, store them. |
| | | 1745 | | int[] s = stack; |
| | | 1746 | | int p = pos; |
| | | 1747 | | if ((uint)(p + 2) < (uint)s.Length) |
| | | 1748 | | { |
| | | 1749 | | s[p] = arg0; |
| | | 1750 | | s[p + 1] = arg1; |
| | | 1751 | | s[p + 2] = arg2; |
| | | 1752 | | pos += 3; |
| | | 1753 | | return; |
| | | 1754 | | } |
| | | 1755 | | |
| | | 1756 | | // Otherwise, resize the stack to make room and try again. |
| | | 1757 | | WithResize(ref stack, ref pos, arg0, arg1, arg2); |
| | | 1758 | | |
| | | 1759 | | // <summary>Resize the backtracking stack array and push 3 values onto the stack.</summary> |
| | | 1760 | | [MethodImpl(MethodImplOptions.NoInlining)] |
| | | 1761 | | static void WithResize(ref int[] stack, ref int pos, int arg0, int arg1, int arg2) |
| | | 1762 | | { |
| | | 1763 | | Array.Resize(ref stack, (pos + 2) * 2); |
| | | 1764 | | StackPush(ref stack, ref pos, arg0, arg1, arg2); |
| | | 1765 | | } |
| | | 1766 | | } |
| | | 1767 | | |
| | | 1768 | | /// <summary>Supports searching for characters in or not in "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmno |
| | | 1769 | | internal static readonly SearchValues<char> s_asciiLettersAndDigits = SearchValues.Create("0123456789ABCDEFGHIJK |
| | | 1770 | | |
| | | 1771 | | /// <summary>Supports searching for characters in or not in "!#$%&'*+-/0123456789=?ABCDEFGHIJKLMNOPQRSTUVWXY |
| | | 1772 | | internal static readonly SearchValues<char> s_ascii_FAACFFA3FEFFFFC7FFFFFF7F = SearchValues.Create("!#$%&'*+-/01 |
| | | 1773 | | } |
| | | 1774 | | } |