8 instantiations of RegexCharClass
System.Text.RegularExpressions (8)
System\Text\RegularExpressions\RegexCharClass.cs (1)
1506return new RegexCharClass(IsNegated(charClass, start), ranges, categoriesBuilder, sub);
System\Text\RegularExpressions\RegexNode.cs (1)
1028prevCharClass = new RegexCharClass();
System\Text\RegularExpressions\RegexParser.cs (2)
555RegexCharClass? charClass = scanOnly ? null : new RegexCharClass(); 1131var cc = new RegexCharClass();
System\Text\RegularExpressions\RegexPrefixAnalyzer.cs (3)
948cc ??= new RegexCharClass(); 957cc ??= new RegexCharClass(); 994cc ??= new RegexCharClass();
System\Text\RegularExpressions\Symbolic\CharSetSolver.cs (1)
147var rcc = new RegexCharClass();
166 references to RegexCharClass
System.Text.RegularExpressions (166)
System\Text\RegularExpressions\RegexCharClass.cs (8)
316private RegexCharClass? _subtractor; 349private RegexCharClass(bool negate, List<(char First, char Last)>? ranges, StringBuilder? categories, RegexCharClass? subtraction) 369public void AddCharClass(RegexCharClass cc) 387public bool TryAddCharClass(RegexCharClass cc) 425public void AddSubtraction(RegexCharClass sub) 1481public static RegexCharClass Parse(string charClass) => ParseRecursive(charClass, 0); 1483private static RegexCharClass ParseRecursive(string charClass, int start) 1494RegexCharClass? sub = null;
System\Text\RegularExpressions\RegexCompiler.cs (4)
867primarySet.Set != RegexCharClass.NotNewLineClass && 868primarySet.Set != RegexCharClass.AnyClass; 965else if (RegexCharClass.IsUnicodeCategoryOfSmallCharCount(primarySet.Set, out char[]? setChars, out bool negated, out _)) 983if (!RegexCharClass.CharInClass((char)i, primarySet.Set))
System\Text\RegularExpressions\RegexFindOptimizations.cs (10)
101if (!RegexCharClass.IsNegated(charClass) && 102(scratchCount = RegexCharClass.GetSetChars(charClass, scratch)) > 0) 112Debug.Assert(!RegexCharClass.IsNegated(charClass)); 119Debug.Assert(!RegexCharClass.IsNegated(charClass) || chars is null); 468if (RegexCharClass.CharInClass(span[i], set, ref startingAsciiLookup)) 647if (RegexCharClass.CharInClass(span[i], primarySet.Set, ref startingAsciiLookup)) 741if (!RegexCharClass.CharInClass(c, nextSet.Set, ref _asciiLookups![i])) 760if (!RegexCharClass.CharInClass(c, primarySet.Set, ref startingAsciiLookup)) 769if (!RegexCharClass.CharInClass(c, nextSet.Set, ref _asciiLookups![i])) 811while ((uint)--prev < (uint)slice.Length && RegexCharClass.CharInClass(slice[prev], loopNode.Str!, ref _asciiLookups![0])) ;
System\Text\RegularExpressions\RegexInterpreterCode.cs (2)
165sb.Append(Indent()).Append('\'').Append(RegexCharClass.DescribeChar((char)Codes[opcodeOffset + 1])).Append('\''); 173sb.Append(Indent()).Append(RegexCharClass.DescribeSet(Strings[Codes[opcodeOffset + 1]]));
System\Text\RegularExpressions\RegexNode.cs (54)
26/// <remarks>For a <see cref="RegexNodeKind.Multi"/>, this is the string from the expression. For an <see cref="IsSetFamily"/> node, this is the character class string from <see cref="RegexCharClass"/>.</remarks> 126string stringSet = RegexCharClass.CharsToStringClass(equivalences); 879if (RegexCharClass.IsEmpty(Str)) 884else if (RegexCharClass.IsSingleton(Str)) 886Ch = RegexCharClass.SingletonChar(Str); 894else if (RegexCharClass.IsSingletonInverse(Str)) 896Ch = RegexCharClass.SingletonChar(Str); 909case RegexCharClass.WordNotWordClass: 910case RegexCharClass.NotWordWordClass: 911case RegexCharClass.DigitNotDigitClass: 912case RegexCharClass.NotDigitDigitClass: 913case RegexCharClass.SpaceNotSpaceClass: 914case RegexCharClass.NotSpaceSpaceClass: 915Str = RegexCharClass.AnyClass; 1004if (!wasLastSet || optionsLast != optionsAt || lastNodeCannotMerge || !RegexCharClass.IsMergeable(at.Str!)) 1007lastNodeCannotMerge = !RegexCharClass.IsMergeable(at.Str!); 1025RegexCharClass prevCharClass; 1033prevCharClass = RegexCharClass.Parse(prev.Str!); 1042RegexCharClass atCharClass = RegexCharClass.Parse(at.Str!); 1442if (RegexCharClass.TryGetSingleRange(node.Str!, out char lowInclusive, out char highInclusive) && 1446return new StartingLiteralData(range: (lowInclusive, highInclusive), negated: RegexCharClass.IsNegated(node.Str!)); 1451if ((numChars = RegexCharClass.GetSetChars(node.Str!, setChars)) != 0) 1453return new StartingLiteralData(setChars: setChars.Slice(0, numChars).ToString(), negated: RegexCharClass.IsNegated(node.Str!)); 2122case RegexNodeKind.Set when !RegexCharClass.CharInClass(node.Ch, subsequent.Str!): 2125case RegexNodeKind.Setlazy or RegexNodeKind.Setloop or RegexNodeKind.Setloopatomic when subsequent.M > 0 && !RegexCharClass.CharInClass(node.Ch, subsequent.Str!): 2133case RegexNodeKind.Setlazy or RegexNodeKind.Setloop or RegexNodeKind.Setloopatomic when subsequent.M == 0 && !RegexCharClass.CharInClass(node.Ch, subsequent.Str!): 2134case RegexNodeKind.Boundary when node.M > 0 && RegexCharClass.IsBoundaryWordChar(node.Ch): 2135case RegexNodeKind.NonBoundary when node.M > 0 && !RegexCharClass.IsBoundaryWordChar(node.Ch): 2136case RegexNodeKind.ECMABoundary when node.M > 0 && RegexCharClass.IsECMAWordChar(node.Ch): 2137case RegexNodeKind.NonECMABoundary when node.M > 0 && !RegexCharClass.IsECMAWordChar(node.Ch): 2169case RegexNodeKind.One when !RegexCharClass.CharInClass(subsequent.Ch, node.Str!): 2170case RegexNodeKind.Set when !RegexCharClass.MayOverlap(node.Str!, subsequent.Str!): 2171case RegexNodeKind.Onelazy or RegexNodeKind.Oneloop or RegexNodeKind.Oneloopatomic when subsequent.M > 0 && !RegexCharClass.CharInClass(subsequent.Ch, node.Str!): 2172case RegexNodeKind.Setlazy or RegexNodeKind.Setloop or RegexNodeKind.Setloopatomic when subsequent.M > 0 && !RegexCharClass.MayOverlap(node.Str!, subsequent.Str!): 2173case RegexNodeKind.Multi when !RegexCharClass.CharInClass(subsequent.Str![0], node.Str!): 2175case RegexNodeKind.EndZ or RegexNodeKind.Eol when !RegexCharClass.CharInClass('\n', node.Str!): 2178case RegexNodeKind.Onelazy or RegexNodeKind.Oneloop or RegexNodeKind.Oneloopatomic when subsequent.M == 0 && !RegexCharClass.CharInClass(subsequent.Ch, node.Str!): 2179case RegexNodeKind.Setlazy or RegexNodeKind.Setloop or RegexNodeKind.Setloopatomic when subsequent.M == 0 && !RegexCharClass.MayOverlap(node.Str!, subsequent.Str!): 2180case RegexNodeKind.Boundary when node.M > 0 && node.Str is RegexCharClass.WordClass or RegexCharClass.DigitClass: 2181case RegexNodeKind.NonBoundary when node.M > 0 && node.Str is RegexCharClass.NotWordClass or RegexCharClass.NotDigitClass: 2182case RegexNodeKind.ECMABoundary when node.M > 0 && node.Str is RegexCharClass.ECMAWordClass or RegexCharClass.ECMADigitClass: 2183case RegexNodeKind.NonECMABoundary when node.M > 0 && node.Str is RegexCharClass.NotECMAWordClass or RegexCharClass.NotDigitClass: 2535RegexCharClass.ParticipatesInCaseConversion(child.Ch)) 2546if (!RegexCharClass.IsAscii(child.Str.AsSpan()) || 2547RegexCharClass.ParticipatesInCaseConversion(child.Str.AsSpan())) 2559if (!RegexCharClass.SetContainsAsciiOrdinalIgnoreCaseCharacter(child.Str!, twoChars)) 2898sb.Append(" '").Append(RegexCharClass.DescribeChar(Ch)).Append('\''); 2915sb.Append(RegexCharClass.DescribeChar(c)); 2923sb.Append(' ').Append(RegexCharClass.DescribeSet(Str!));
System\Text\RegularExpressions\RegexNodeKind.cs (4)
22/// <remarks>The <see cref="RegexCharClass"/> set string is specified in <see cref="RegexNode.Str"/>.</remarks> 40/// <remarks>The <see cref="RegexCharClass"/> set string is specified in <see cref="RegexNode.Str"/>, the minimum number of iterations in <see cref="RegexNode.M"/>, and the maximum number of iterations in <see cref="RegexNode.N"/>.</remarks> 53/// <remarks>The <see cref="RegexCharClass"/> set string is specified in <see cref="RegexNode.Str"/>, the minimum number of iterations in <see cref="RegexNode.M"/>, and the maximum number of iterations in <see cref="RegexNode.N"/>.</remarks> 71/// The <see cref="RegexCharClass"/> set string is specified in <see cref="RegexNode.Str"/>, the minimum number of iterations in <see cref="RegexNode.M"/>, and the maximum number of iterations in <see cref="RegexNode.N"/>.
System\Text\RegularExpressions\RegexParser.cs (27)
403new RegexNode(RegexNodeKind.Set, _options & ~RegexOptions.IgnoreCase, RegexCharClass.AnyClass) : 547private RegexCharClass? ScanCharClass(bool caseInsensitive, bool scanOnly) 555RegexCharClass? charClass = scanOnly ? null : new RegexCharClass(); 710RegexCharClass? rcc = ScanCharClass(caseInsensitive, scanOnly); 865else if (RegexCharClass.IsBoundaryWordChar(ch)) 912else if (RegexCharClass.IsBoundaryWordChar(ch)) 967else if (RegexCharClass.IsBoundaryWordChar(ch)) 1096new RegexNode(RegexNodeKind.Set, (_options & ~RegexOptions.IgnoreCase), (_options & RegexOptions.ECMAScript) != 0 ? RegexCharClass.ECMAWordClass : RegexCharClass.WordClass); 1101new RegexNode(RegexNodeKind.Set, (_options & ~RegexOptions.IgnoreCase), (_options & RegexOptions.ECMAScript) != 0 ? RegexCharClass.NotECMAWordClass : RegexCharClass.NotWordClass); 1106new RegexNode(RegexNodeKind.Set, (_options & ~RegexOptions.IgnoreCase), (_options & RegexOptions.ECMAScript) != 0 ? RegexCharClass.ECMASpaceClass : RegexCharClass.SpaceClass); 1111new RegexNode(RegexNodeKind.Set, (_options & ~RegexOptions.IgnoreCase), (_options & RegexOptions.ECMAScript) != 0 ? RegexCharClass.NotECMASpaceClass : RegexCharClass.NotSpaceClass); 1116new RegexNode(RegexNodeKind.Set, (_options & ~RegexOptions.IgnoreCase), (_options & RegexOptions.ECMAScript) != 0 ? RegexCharClass.ECMADigitClass : RegexCharClass.DigitClass); 1121new RegexNode(RegexNodeKind.Set, (_options & ~RegexOptions.IgnoreCase), (_options & RegexOptions.ECMAScript) != 0 ? RegexCharClass.NotECMADigitClass : RegexCharClass.NotDigitClass); 1131var cc = new RegexCharClass(); 1261else if (angled && RegexCharClass.IsBoundaryWordChar(ch)) 1360else if (angled && RegexCharClass.IsBoundaryWordChar(ch)) 1422if (!RegexCharClass.IsBoundaryWordChar(_pattern[_pos++])) 1609if ((_options & RegexOptions.ECMAScript) == 0 && RegexCharClass.IsBoundaryWordChar(ch)) 1635if (!(RegexCharClass.IsBoundaryWordChar(ch) || ch == '-')) 1728if (ch != '0' && RegexCharClass.IsBoundaryWordChar(ch)) 2021case > 1 when (_options & RegexOptions.IgnoreCase) == 0 || isReplacement || !RegexCharClass.ParticipatesInCaseConversion(_pattern.AsSpan(pos, cch)):
System\Text\RegularExpressions\RegexPrefixAnalyzer.cs (34)
112case RegexNodeKind.One or RegexNodeKind.Oneloop or RegexNodeKind.Onelazy or RegexNodeKind.Oneloopatomic when !ignoreCase || !RegexCharClass.ParticipatesInCaseConversion(node.Ch): 138if (RegexCharClass.ParticipatesInCaseConversion(c)) 156case RegexNodeKind.Set or RegexNodeKind.Setloop or RegexNodeKind.Setlazy or RegexNodeKind.Setloopatomic when !RegexCharClass.IsNegated(node.Str!): // negated sets are too complex to analyze 158int charCount = RegexCharClass.GetSetChars(node.Str!, setChars); 197if (!RegexCharClass.SetContainsAsciiOrdinalIgnoreCaseCharacter(node.Str!, setChars)) 530if (results[i].Set == RegexCharClass.AnyClass) 532results.RemoveAll(s => s.Set == RegexCharClass.AnyClass); 543charClass == RegexCharClass.AnyClass) // weed out match-all, same as above 557result.Negated = RegexCharClass.IsNegated(result.Set); 559if (RegexCharClass.TryGetSingleRange(result.Set, out char lowInclusive, out char highInclusive) && 566int count = RegexCharClass.GetSetChars(result.Set, scratch); 603string setString = RegexCharClass.OneToStringClass(node.Ch); 611string setString = RegexCharClass.OneToStringClass(node.Ch); 627string setString = RegexCharClass.OneToStringClass(s[i]); 714var combined = new Dictionary<int, (RegexCharClass Set, int Count)>(); 742if (combined.TryGetValue(fixedSet.Distance, out (RegexCharClass Set, int Count) value)) 744if (value.Set.TryAddCharClass(RegexCharClass.Parse(fixedSet.Set))) 752combined[fixedSet.Distance] = (RegexCharClass.Parse(fixedSet.Set), 1); 757foreach (KeyValuePair<int, (RegexCharClass Set, int Count)> pair in combined) 829if (!RegexCharClass.IsAscii(s1Chars) && !RegexCharClass.IsAscii(s2Chars)) 915RegexCharClass? cc = null; 933static bool? TryFindFirstCharClass(RegexNode node, ref RegexCharClass? cc) 977cc = RegexCharClass.Parse(node.Str!); 980else if (cc.CanMerge && RegexCharClass.Parse(node.Str!) is { CanMerge: true } setCc) 1160RegexCharClass.CharInClass(prefix[0], firstChild.Str!) ? null : 1176!RegexCharClass.ParticipatesInCaseConversion(ordinalCaseInsensitivePrefix[0]) || 1179if (RegexCharClass.ParticipatesInCaseConversion(ordinalCaseInsensitivePrefix[0])) 1181if (RegexCharClass.CharInClass((char)(ordinalCaseInsensitivePrefix[0] | 0x20), firstChild.Str!) || 1182RegexCharClass.CharInClass((char)(ordinalCaseInsensitivePrefix[0] & ~0x20), firstChild.Str!)) 1187else if (RegexCharClass.CharInClass(ordinalCaseInsensitivePrefix[0], firstChild.Str!)) 1208!RegexCharClass.IsNegated(nextChild.Str!) && 1212chars = chars.Slice(0, RegexCharClass.GetSetChars(nextChild.Str!, chars)); 1217if (RegexCharClass.CharInClass(c, firstChild.Str!))
System\Text\RegularExpressions\RegexRunner.cs (12)
410return (index > startpos && RegexCharClass.IsBoundaryWordChar(runtext![index - 1])) != 411(index < endpos && RegexCharClass.IsBoundaryWordChar(runtext![index])); 417return ((uint)indexM1 < (uint)inputSpan.Length && RegexCharClass.IsBoundaryWordChar(inputSpan[indexM1])) != 418((uint)index < (uint)inputSpan.Length && RegexCharClass.IsBoundaryWordChar(inputSpan[index])); 422internal static bool IsWordChar(char ch) => RegexCharClass.IsWordChar(ch); 426return (index > startpos && RegexCharClass.IsECMAWordChar(runtext![index - 1])) != 427(index < endpos && RegexCharClass.IsECMAWordChar(runtext![index])); 433return ((uint)indexM1 < (uint)inputSpan.Length && RegexCharClass.IsECMAWordChar(inputSpan[indexM1])) != 434((uint)index < (uint)inputSpan.Length && RegexCharClass.IsECMAWordChar(inputSpan[index])); 440string charClass = RegexCharClass.ConvertOldStringsToClass(set, category); 441return RegexCharClass.CharInClass(ch, charClass); 446return RegexCharClass.CharInClass(ch, charClass);
System\Text\RegularExpressions\Symbolic\CharSetSolver.cs (2)
147var rcc = new RegexCharClass(); 152return RegexCharClass.DescribeSet(rcc.ToStringClass());
System\Text\RegularExpressions\Symbolic\RegexNodeConverter.cs (9)
22/// <summary>Cache of BDDs created to represent <see cref="RegexCharClass"/> set strings.</summary> 323/// <summary>Creates a BDD from the <see cref="RegexCharClass"/> set string to determine whether a char is in the set.</summary> 355bool negate = RegexCharClass.IsNegated(set); 361List<(char First, char Last)>? ranges = RegexCharClass.ComputeRanges(set); 381int setLength = set[RegexCharClass.SetLengthIndex]; 382int catLength = set[RegexCharClass.CategoryLengthIndex]; 383int catStart = setLength + RegexCharClass.SetStartIndex; 523Debug.Assert(Enum.IsDefined(code) || code == (UnicodeCategory)(RegexCharClass.SpaceConst - 1), $"Unknown category: {code}"); 524return code == (UnicodeCategory)(RegexCharClass.SpaceConst - 1) ?