/* * This is the one of the only two functions that should be called from outside. * It takes a RegexTree and computes the set of chars that can start it. */ internal static RegexPrefix FirstChars(RegexTree t) { RegexFCD s = new RegexFCD(); RegexFC fc = s.RegexFCFromRegexTree(t); if (fc == null || fc._nullable) { return(null); } CultureInfo culture = ((t._options & RegexOptions.CultureInvariant) != 0) ? CultureInfo.InvariantCulture : CultureInfo.CurrentCulture; return(new RegexPrefix(fc.GetFirstChars(culture), fc.IsCaseInsensitive())); }
/// <summary> /// This is the one of the only two functions that should be called from outside. /// It takes a RegexTree and computes the set of chars that can start it. /// </summary> public static RegexPrefix?FirstChars(RegexTree t) { // Create/rent buffers Span <int> intSpan = stackalloc int[StackBufferSize]; RegexFCD s = new RegexFCD(intSpan); RegexFC fc = s.RegexFCFromRegexTree(t); s.Dispose(); if (fc == null || fc._nullable) { return(null); } CultureInfo culture = ((t.Options & RegexOptions.CultureInvariant) != 0) ? CultureInfo.InvariantCulture : CultureInfo.CurrentCulture; return(new RegexPrefix(fc.GetFirstChars(culture), fc.CaseInsensitive)); }