23 writes to Kind
System.Text.RegularExpressions (23)
System\Text\RegularExpressions\RegexNode.cs (23)
53
Kind
= kind;
59
Kind
= kind;
66
Kind
= kind;
73
Kind
= kind;
80
Kind
= kind;
152
Kind
+= kind - RegexNodeKind.One;
164
Kind
+= RegexNodeKind.Oneloopatomic - RegexNodeKind.Oneloop;
171
Kind
+= RegexNodeKind.Oneloopatomic - RegexNodeKind.Onelazy;
177
Kind
= RegexNodeKind.Empty;
185
Kind
= RegexNodeKind.Multi;
881
Kind
= RegexNodeKind.Nothing;
888
Kind
=
898
Kind
=
1046
prev.
Kind
= RegexNodeKind.Set;
1325
node.
Kind
= RegexNodeKind.Empty;
1334
node.
Kind
= RegexNodeKind.Empty;
1339
node.
Kind
= RegexNodeKind.One;
1594
prev.
Kind
= RegexNodeKind.Multi;
1739
nextNode.
Kind
= RegexNodeKind.One;
1762
currentNode.
Kind
= nextNode.Kind;
1900
node.
Kind
-= RegexNodeKind.Onelazy - RegexNodeKind.Oneloop; // lazy to greedy
1987
Kind
= Kind == RegexNodeKind.PositiveLookaround ? RegexNodeKind.Empty : RegexNodeKind.Nothing;
2694
Kind
= RegexNodeKind.Multi;
221 references to Kind
System.Text.RegularExpressions (221)
System\Text\RegularExpressions\RegexCompiler.cs (1)
1249
Debug.Assert(target.LoopNode.
Kind
is RegexNodeKind.Setloop or RegexNodeKind.Setlazy or RegexNodeKind.Setloopatomic);
System\Text\RegularExpressions\RegexFindOptimizations.cs (1)
792
Debug.Assert(loopNode.
Kind
is RegexNodeKind.Setloop or RegexNodeKind.Setlazy or RegexNodeKind.Setloopatomic);
System\Text\RegularExpressions\RegexNode.cs (158)
89
Debug.Assert(
Kind
is RegexNodeKind.Onelazy or RegexNodeKind.Oneloop or RegexNodeKind.Oneloopatomic or
95
new RegexNode(
Kind
, Options, Str!) :
96
new RegexNode(
Kind
, Options, Ch);
138
Kind
== RegexNodeKind.Concatenate &&
159
switch (
Kind
)
181
else if (
Kind
== RegexNodeKind.Oneloopatomic && N is >= 2 and <= MultiVsRepeaterLimit)
193
Debug.Fail($"Unexpected type: {
Kind
}");
203
Debug.Assert(
Kind
== RegexNodeKind.Capture, "Every generated tree should begin with a capture node");
222
Debug.Assert(
Kind
!= RegexNodeKind.Group, "All Group nodes should have been removed.");
225
switch (node.
Kind
)
258
Debug.Assert(childCount == 0, $"Expected zero children for {node.
Kind
}, got {childCount}.");
267
Debug.Assert(childCount == 1, $"Expected one and only one child for {node.
Kind
}, got {childCount}.");
271
Debug.Assert(childCount == 2, $"Expected two children for {node.
Kind
}, got {childCount}");
275
Debug.Assert(childCount == 3, $"Expected three children for {node.
Kind
}, got {childCount}");
280
Debug.Assert(childCount >= 2, $"Expected at least two children for {node.
Kind
}, got {childCount}.");
284
Debug.Fail($"Unexpected node type: {node.
Kind
}");
289
switch (node.
Kind
)
300
Debug.Assert(!string.IsNullOrEmpty(node.Str), $"Expected non-null, non-empty string for {node.
Kind
}.");
304
Debug.Assert(node.Str is null, $"Expected null string for {node.
Kind
}, got \"{node.Str}\".");
309
switch (node.
Kind
)
315
Debug.Assert((node.Options & RegexOptions.IgnoreCase) == 0, $"{node.
Kind
} node should not have RegexOptions.IgnoreCase");
332
Debug.Assert(rootNode.
Kind
== RegexNodeKind.Capture);
373
switch (node.
Kind
)
386
if (node.Parent is {
Kind
: RegexNodeKind.Concatenate } parent)
426
switch (node.
Kind
)
453
if ((existingChild.
Kind
is RegexNodeKind.Alternate or RegexNodeKind.BackreferenceConditional or RegexNodeKind.ExpressionConditional or RegexNodeKind.Loop or RegexNodeKind.Lazyloop) &&
454
(node.Parent is null || node.Parent.
Kind
!= RegexNodeKind.Atomic)) // validate grandparent isn't atomic
476
if (node.
Kind
!= RegexNodeKind.ExpressionConditional) // ReduceExpressionConditional will have already applied ending backtracking removal
525
switch (
Kind
)
537
return
Kind
switch
560
Debug.Assert(
Kind
is RegexNodeKind.Alternate or RegexNodeKind.Concatenate);
563
0 => new RegexNode(
Kind
== RegexNodeKind.Alternate ? RegexNodeKind.Nothing : RegexNodeKind.Empty, Options),
577
Debug.Assert(
Kind
== RegexNodeKind.Group);
580
while (u.
Kind
== RegexNodeKind.Group)
605
Debug.Assert(
Kind
== RegexNodeKind.Atomic);
610
while (child.
Kind
== RegexNodeKind.Atomic)
616
switch (child.
Kind
)
652
if (branches[0].
Kind
== RegexNodeKind.Empty)
663
if (branches[i].
Kind
== RegexNodeKind.Empty)
767
Debug.Assert(
Kind
is RegexNodeKind.Loop or RegexNodeKind.Lazyloop);
770
RegexNodeKind kind =
Kind
;
780
if (child.
Kind
!= kind)
785
switch (child.
Kind
)
799
switch (child.
Kind
)
847
switch (child.
Kind
)
852
child.MakeRep(u.
Kind
== RegexNodeKind.Lazyloop ? RegexNodeKind.Onelazy : RegexNodeKind.Oneloop, u.M, u.N);
876
Debug.Assert(
Kind
is RegexNodeKind.Set or RegexNodeKind.Setloop or RegexNodeKind.Setloopatomic or RegexNodeKind.Setlazy);
889
Kind
== RegexNodeKind.Set ? RegexNodeKind.One :
890
Kind
== RegexNodeKind.Setloop ? RegexNodeKind.Oneloop :
891
Kind
== RegexNodeKind.Setloopatomic ? RegexNodeKind.Oneloopatomic :
899
Kind
== RegexNodeKind.Set ? RegexNodeKind.Notone :
900
Kind
== RegexNodeKind.Setloop ? RegexNodeKind.Notoneloop :
901
Kind
== RegexNodeKind.Setloopatomic ? RegexNodeKind.Notoneloopatomic :
925
Debug.Assert(
Kind
== RegexNodeKind.Alternate);
938
if (node.
Kind
== RegexNodeKind.Alternate)
941
if (node.
Kind
== RegexNodeKind.Alternate)
944
if (node.
Kind
== RegexNodeKind.Alternate)
979
if (at.
Kind
== RegexNodeKind.Alternate)
997
else if (at.
Kind
is RegexNodeKind.Set or RegexNodeKind.One)
1002
if (at.
Kind
== RegexNodeKind.Set)
1026
if (prev.
Kind
== RegexNodeKind.One)
1036
if (at.
Kind
== RegexNodeKind.One)
1053
else if (at.
Kind
== RegexNodeKind.Nothing)
1077
Debug.Assert(alternation.
Kind
== RegexNodeKind.Alternate);
1090
if (child.
Kind
!= RegexNodeKind.Concatenate || child.ChildCount() < 2)
1105
switch (required.
Kind
)
1121
if (required.
Kind
!= other.
Kind
||
1147
if (alternation.Parent is RegexNode {
Kind
: RegexNodeKind.Atomic })
1172
Debug.Assert(node.
Kind
== RegexNodeKind.Alternate);
1181
switch (child.
Kind
)
1215
Debug.Assert(alternation.
Kind
== RegexNodeKind.Alternate);
1242
if (startingNode.
Kind
== RegexNodeKind.One)
1262
if (startingNode.
Kind
== RegexNodeKind.One)
1276
Debug.Assert(startingNode.
Kind
== RegexNodeKind.Multi);
1313
ProcessOneOrMulti(branch.
Kind
== RegexNodeKind.Concatenate ? branch.Child(0) : branch, startingSpan);
1321
if (node.
Kind
== RegexNodeKind.One)
1330
Debug.Assert(node.
Kind
== RegexNodeKind.Multi);
1351
if (alternation.Parent is RegexNode parent && parent.
Kind
== RegexNodeKind.Atomic)
1378
RegexNode branch =
Kind
== RegexNodeKind.Concatenate ? Child(0) : this;
1379
return branch.
Kind
is RegexNodeKind.One or RegexNodeKind.Multi ? branch : null;
1385
Debug.Assert(
Kind
is RegexNodeKind.One or RegexNodeKind.Multi || (IsOneFamily && M > 0));
1398
switch (node.
Kind
)
1433
switch (node.
Kind
)
1500
Debug.Assert(
Kind
== RegexNodeKind.Concatenate);
1516
if (child.
Kind
== RegexNodeKind.Nothing)
1542
Debug.Assert(
Kind
== RegexNodeKind.Concatenate);
1559
if (at.
Kind
== RegexNodeKind.Concatenate &&
1578
else if (at.
Kind
is RegexNodeKind.Multi or RegexNodeKind.One)
1592
if (prev.
Kind
== RegexNodeKind.One)
1599
((at.
Kind
== RegexNodeKind.One) ? $"{prev.Str}{at.Ch}" : prev.Str + at.Str) :
1600
((at.
Kind
== RegexNodeKind.One) ? $"{at.Ch}{prev.Str}" : at.Str + prev.Str);
1602
else if (at.
Kind
== RegexNodeKind.Empty)
1625
Debug.Assert(
Kind
== RegexNodeKind.Concatenate);
1660
switch (currentNode.
Kind
)
1663
case RegexNodeKind.Oneloop or RegexNodeKind.Oneloopatomic or RegexNodeKind.Onelazy or RegexNodeKind.Notoneloop or RegexNodeKind.Notoneloopatomic or RegexNodeKind.Notonelazy when nextNode.
Kind
== currentNode.
Kind
&& currentNode.Ch == nextNode.Ch:
1664
case RegexNodeKind.Setloop or RegexNodeKind.Setloopatomic or RegexNodeKind.Setlazy when nextNode.
Kind
== currentNode.
Kind
&& currentNode.Str == nextNode.Str:
1666
currentNode.
Kind
is RegexNodeKind.Oneloopatomic or RegexNodeKind.Notoneloopatomic or RegexNodeKind.Setloopatomic)
1689
case RegexNodeKind.Oneloop or RegexNodeKind.Onelazy when nextNode.
Kind
== RegexNodeKind.One && currentNode.Ch == nextNode.Ch:
1690
case RegexNodeKind.Notoneloop or RegexNodeKind.Notonelazy when nextNode.
Kind
== RegexNodeKind.Notone && currentNode.Ch == nextNode.Ch:
1691
case RegexNodeKind.Setloop or RegexNodeKind.Setlazy when nextNode.
Kind
== RegexNodeKind.Set && currentNode.Str == nextNode.Str:
1706
nextNode.
Kind
== RegexNodeKind.Multi &&
1757
case RegexNodeKind.One when (nextNode.
Kind
is RegexNodeKind.Oneloop or RegexNodeKind.Oneloopatomic or RegexNodeKind.Onelazy) && currentNode.Ch == nextNode.Ch:
1758
case RegexNodeKind.Notone when (nextNode.
Kind
is RegexNodeKind.Notoneloop or RegexNodeKind.Notoneloopatomic or RegexNodeKind.Notonelazy) && currentNode.Ch == nextNode.Ch:
1759
case RegexNodeKind.Set when (nextNode.
Kind
is RegexNodeKind.Setloop or RegexNodeKind.Setloopatomic or RegexNodeKind.Setlazy) && currentNode.Str == nextNode.Str:
1762
currentNode.Kind = nextNode.
Kind
;
1772
case RegexNodeKind.Notone when nextNode.
Kind
== currentNode.
Kind
&& currentNode.Ch == nextNode.Ch:
1773
case RegexNodeKind.Set when nextNode.
Kind
== RegexNodeKind.Set && currentNode.Str == nextNode.Str:
1823
if (
Kind
is not RegexNodeKind.Concatenate)
1848
if (node.
Kind
is RegexNodeKind.Capture or RegexNodeKind.Concatenate)
1858
if (node.
Kind
== RegexNodeKind.Loop)
1873
switch (node.
Kind
)
1915
for (int b = node.
Kind
== RegexNodeKind.ExpressionConditional ? 1 : 0; b < alternateBranches; b++)
1935
Debug.Assert(node.
Kind
is RegexNodeKind.Loop or RegexNodeKind.Lazyloop);
1941
while (node.
Kind
== RegexNodeKind.Capture)
1952
if (node.
Kind
== RegexNodeKind.Concatenate)
1969
Debug.Assert(
Kind
is RegexNodeKind.PositiveLookaround or RegexNodeKind.NegativeLookaround);
1985
if (Child(0).
Kind
== RegexNodeKind.Empty)
1987
Kind =
Kind
== RegexNodeKind.PositiveLookaround ? RegexNodeKind.Empty : RegexNodeKind.Nothing;
1997
Debug.Assert(
Kind
== RegexNodeKind.BackreferenceConditional);
2015
Debug.Assert(
Kind
== RegexNodeKind.ExpressionConditional);
2033
if (condition.
Kind
== RegexNodeKind.PositiveLookaround && (condition.Options & RegexOptions.RightToLeft) == 0)
2069
Debug.Assert(subsequent.
Kind
!= RegexNodeKind.Group);
2070
switch (subsequent.
Kind
)
2097
switch (subsequent.
Kind
)
2114
switch (node.
Kind
)
2118
switch (subsequent.
Kind
)
2148
switch (subsequent.
Kind
)
2167
switch (subsequent.
Kind
)
2209
switch (parent?.
Kind
)
2260
switch (
Kind
)
2355
Debug.Fail($"Unknown node: {
Kind
}");
2373
switch (
Kind
)
2433
int i =
Kind
== RegexNodeKind.BackreferenceConditional ? 0 : 1;
2492
Debug.Fail($"Unknown node: {
Kind
}");
2516
Debug.Assert(
Kind
== RegexNodeKind.Concatenate, $"Expected Concatenate, got {
Kind
}");
2529
if (child.
Kind
is RegexNodeKind.One)
2542
else if (child.
Kind
is RegexNodeKind.Multi)
2554
else if (child.
Kind
is RegexNodeKind.Set ||
2555
(child.
Kind
is RegexNodeKind.Setloop or RegexNodeKind.Setlazy or RegexNodeKind.Setloopatomic && child.M == child.N))
2564
vsb.Append((char)(twoChars[0] | 0x20), child.
Kind
is RegexNodeKind.Set ? 1 : child.M);
2566
else if (child.
Kind
is RegexNodeKind.Empty)
2573
child.
Kind
is RegexNodeKind.Beginning or
2632
Debug.Assert(
Kind
== RegexNodeKind.Concatenate, $"Expected Concatenate, got {
Kind
}");
2634
static bool CanJoinLengthCheck(RegexNode node) => node.
Kind
switch
2688
case <= MultiVsRepeaterLimit when
Kind
== RegexNodeKind.One:
2701
switch (
Kind
)
2833
public bool IsSetFamily =>
Kind
is RegexNodeKind.Set or RegexNodeKind.Setloop or RegexNodeKind.Setloopatomic or RegexNodeKind.Setlazy;
2836
public bool IsOneFamily =>
Kind
is RegexNodeKind.One or RegexNodeKind.Oneloop or RegexNodeKind.Oneloopatomic or RegexNodeKind.Onelazy;
2839
public bool IsNotoneFamily =>
Kind
is RegexNodeKind.Notone or RegexNodeKind.Notoneloop or RegexNodeKind.Notoneloopatomic or RegexNodeKind.Notonelazy;
2878
var sb = new StringBuilder(
Kind
.ToString());
2888
switch (
Kind
)
2927
switch (
Kind
)
System\Text\RegularExpressions\RegexParser.cs (6)
1004
if (_group!.
Kind
!= RegexNodeKind.ExpressionConditional)
1142
if (result != null && result.
Kind
== RegexNodeKind.Backreference && (result.Options & RegexOptions.IgnoreCase) != 0)
2052
if (_group.
Kind
== RegexNodeKind.ExpressionConditional && _group.ChildCount() == 0)
2077
if (_group!.
Kind
is RegexNodeKind.ExpressionConditional or RegexNodeKind.BackreferenceConditional)
2092
if (_group!.
Kind
is RegexNodeKind.ExpressionConditional or RegexNodeKind.BackreferenceConditional)
2096
if (_group.
Kind
== RegexNodeKind.BackreferenceConditional && _group.ChildCount() > 2 || _group.ChildCount() > 3)
System\Text\RegularExpressions\RegexPrefixAnalyzer.cs (26)
80
switch (node.
Kind
)
114
int reps = node.
Kind
is RegexNodeKind.One ? 1 : Math.Min(node.M, MaxPrefixLength);
119
return node.
Kind
is RegexNodeKind.One || reps == node.N;
164
int reps = node.
Kind
is RegexNodeKind.Set ? 1 : Math.Min(node.M, MaxPrefixLength);
209
return node.
Kind
is RegexNodeKind.Set || reps == node.N;
360
switch (node.
Kind
)
489
switch (node.
Kind
)
598
switch (node.
Kind
)
941
switch (node.
Kind
)
950
return node.
Kind
is RegexNodeKind.One || node.M > 0 ? true : null;
968
return node.
Kind
is RegexNodeKind.Notone || node.M > 0 ? true : null;
987
node.
Kind
is RegexNodeKind.Set || node.M > 0 ? true :
1080
int branchStart = node.
Kind
is RegexNodeKind.BackreferenceConditional ? 0 : 1;
1094
Debug.Fail($"Unexpected node {node.
Kind
}");
1114
while (node.
Kind
is RegexNodeKind.Atomic or RegexNodeKind.Capture)
1118
if (node.
Kind
!= RegexNodeKind.Concatenate)
1131
while (firstChild.
Kind
is RegexNodeKind.Atomic or RegexNodeKind.Capture)
1135
if (firstChild.
Kind
is not (RegexNodeKind.Setloop or RegexNodeKind.Setloopatomic or RegexNodeKind.Setlazy) || firstChild.N != int.MaxValue)
1143
if (nextChild.
Kind
== RegexNodeKind.UpdateBumpalong)
1200
while ((nextChild.
Kind
is RegexNodeKind.Atomic or RegexNodeKind.Capture or RegexNodeKind.Concatenate) ||
1201
(nextChild.
Kind
is RegexNodeKind.Loop or RegexNodeKind.Lazyloop && nextChild.M >= 1))
1209
(nextChild.
Kind
is RegexNodeKind.Set || nextChild.M >= 1))
1251
switch (node.
Kind
)
1262
return node.
Kind
;
1281
if (node.Child(i).
Kind
is not (RegexNodeKind.Empty or RegexNodeKind.PositiveLookaround or RegexNodeKind.NegativeLookaround))
1292
if (node.Child(i).
Kind
is not (RegexNodeKind.Empty or RegexNodeKind.PositiveLookaround or RegexNodeKind.NegativeLookaround))
System\Text\RegularExpressions\RegexReplacement.cs (4)
36
Debug.Assert(concat.
Kind
== RegexNodeKind.Concatenate, $"Expected Concatenate, got {concat.
Kind
}");
48
switch (child.
Kind
)
77
Debug.Fail($"Unexpected child kind {child.
Kind
}");
System\Text\RegularExpressions\RegexTreeAnalyzer.cs (3)
47
switch (node.
Kind
)
59
switch (node.
Kind
)
90
bool treatChildAsAtomic = (isAtomicByAncestor | isAtomicBySelf) && node.
Kind
switch
System\Text\RegularExpressions\RegexWriter.cs (11)
85
EmitFragment(curNode.
Kind
, curNode, 0);
89
EmitFragment(curNode.
Kind
| BeforeChild, curNode, curChild);
105
EmitFragment(curNode.
Kind
| AfterChild, curNode, curChild);
383
Emit((RegexOpcode)node.
Kind
| bits, node.Ch);
394
Emit(((node.
Kind
is RegexNodeKind.Oneloop or RegexNodeKind.Oneloopatomic or RegexNodeKind.Onelazy) ?
399
Emit((RegexOpcode)node.
Kind
| bits, node.Ch, node.N == int.MaxValue ? int.MaxValue : node.N - node.M);
414
Emit((RegexOpcode)node.
Kind
| bits, stringCode, (node.N == int.MaxValue) ? int.MaxValue : node.N - node.M);
420
Emit((RegexOpcode)node.
Kind
| bits, StringCode(node.Str!));
424
Emit((RegexOpcode)node.
Kind
| bits, StringCode(node.Str!));
428
Emit((RegexOpcode)node.
Kind
| bits, RegexParser.MapCaptureNumber(node.M, _tree.CaptureNumberSparseMapping));
443
Emit((RegexOpcode)node.
Kind
);
System\Text\RegularExpressions\Symbolic\RegexNodeConverter.cs (11)
53
switch (node.
Kind
)
117
result.AddLast(_builder.CreateLoop(_builder.CreateSingleton(bdd), node.
Kind
is RegexNodeKind.Onelazy or RegexNodeKind.Notonelazy, node.M, node.N));
128
result.AddLast(_builder.CreateLoop(_builder.CreateSingleton(setBdd), node.
Kind
== RegexNodeKind.Setlazy, node.M, node.N));
178
throw new NotSupportedException(SR.Format(SR.NotSupported_NonBacktrackingConflictingExpression, node.
Kind
switch
195
string description = $"Unexpected ({nameof(RegexNodeKind)}: {node.
Kind
})";
209
switch (node.
Kind
)
260
result.AddLast(_builder.CreateLoop(body, node.
Kind
== RegexNodeKind.Lazyloop, node.M, node.N));
267
Debug.Assert(node.
Kind
== RegexNodeKind.Capture && node.N == -1);
285
Debug.Assert(rootResult.Count == 1 || root.
Kind
== RegexNodeKind.Concatenate || root.
Kind
== RegexNodeKind.Capture);
312
Debug.Assert(node.
Kind
== RegexNodeKind.Set);