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