23 writes to Kind
System.Text.RegularExpressions (23)
System\Text\RegularExpressions\RegexNode.cs (23)
53Kind = kind; 59Kind = kind; 66Kind = kind; 73Kind = kind; 80Kind = kind; 152Kind += kind - RegexNodeKind.One; 164Kind += RegexNodeKind.Oneloopatomic - RegexNodeKind.Oneloop; 171Kind += RegexNodeKind.Oneloopatomic - RegexNodeKind.Onelazy; 177Kind = RegexNodeKind.Empty; 185Kind = RegexNodeKind.Multi; 881Kind = RegexNodeKind.Nothing; 888Kind = 898Kind = 1046prev.Kind = RegexNodeKind.Set; 1329node.Kind = RegexNodeKind.Empty; 1338node.Kind = RegexNodeKind.Empty; 1343node.Kind = RegexNodeKind.One; 1598prev.Kind = RegexNodeKind.Multi; 1743nextNode.Kind = RegexNodeKind.One; 1766currentNode.Kind = nextNode.Kind; 1904node.Kind -= RegexNodeKind.Onelazy - RegexNodeKind.Oneloop; // lazy to greedy 1991Kind = Kind == RegexNodeKind.PositiveLookaround ? RegexNodeKind.Empty : RegexNodeKind.Nothing; 2698Kind = RegexNodeKind.Multi;
222 references to Kind
System.Text.RegularExpressions (222)
System\Text\RegularExpressions\RegexCompiler.cs (1)
1249Debug.Assert(target.LoopNode.Kind is RegexNodeKind.Setloop or RegexNodeKind.Setlazy or RegexNodeKind.Setloopatomic);
System\Text\RegularExpressions\RegexFindOptimizations.cs (1)
822Debug.Assert(loopNode.Kind is RegexNodeKind.Setloop or RegexNodeKind.Setlazy or RegexNodeKind.Setloopatomic);
System\Text\RegularExpressions\RegexNode.cs (158)
89Debug.Assert(Kind is RegexNodeKind.Onelazy or RegexNodeKind.Oneloop or RegexNodeKind.Oneloopatomic or 95new RegexNode(Kind, Options, Str!) : 96new RegexNode(Kind, Options, Ch); 138Kind == RegexNodeKind.Concatenate && 159switch (Kind) 181else if (Kind == RegexNodeKind.Oneloopatomic && N is >= 2 and <= MultiVsRepeaterLimit) 193Debug.Fail($"Unexpected type: {Kind}"); 203Debug.Assert(Kind == RegexNodeKind.Capture, "Every generated tree should begin with a capture node"); 222Debug.Assert(Kind != RegexNodeKind.Group, "All Group nodes should have been removed."); 225switch (node.Kind) 258Debug.Assert(childCount == 0, $"Expected zero children for {node.Kind}, got {childCount}."); 267Debug.Assert(childCount == 1, $"Expected one and only one child for {node.Kind}, got {childCount}."); 271Debug.Assert(childCount == 2, $"Expected two children for {node.Kind}, got {childCount}"); 275Debug.Assert(childCount == 3, $"Expected three children for {node.Kind}, got {childCount}"); 280Debug.Assert(childCount >= 2, $"Expected at least two children for {node.Kind}, got {childCount}."); 284Debug.Fail($"Unexpected node type: {node.Kind}"); 289switch (node.Kind) 300Debug.Assert(!string.IsNullOrEmpty(node.Str), $"Expected non-null, non-empty string for {node.Kind}."); 304Debug.Assert(node.Str is null, $"Expected null string for {node.Kind}, got \"{node.Str}\"."); 309switch (node.Kind) 315Debug.Assert((node.Options & RegexOptions.IgnoreCase) == 0, $"{node.Kind} node should not have RegexOptions.IgnoreCase"); 332Debug.Assert(rootNode.Kind == RegexNodeKind.Capture); 373switch (node.Kind) 386if (node.Parent is { Kind: RegexNodeKind.Concatenate } parent) 426switch (node.Kind) 453if ((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 476if (node.Kind != RegexNodeKind.ExpressionConditional) // ReduceExpressionConditional will have already applied ending backtracking removal 525switch (Kind) 537return Kind switch 560Debug.Assert(Kind is RegexNodeKind.Alternate or RegexNodeKind.Concatenate); 5630 => new RegexNode(Kind == RegexNodeKind.Alternate ? RegexNodeKind.Nothing : RegexNodeKind.Empty, Options), 577Debug.Assert(Kind == RegexNodeKind.Group); 580while (u.Kind == RegexNodeKind.Group) 605Debug.Assert(Kind == RegexNodeKind.Atomic); 610while (child.Kind == RegexNodeKind.Atomic) 616switch (child.Kind) 652if (branches[0].Kind == RegexNodeKind.Empty) 663if (branches[i].Kind == RegexNodeKind.Empty) 767Debug.Assert(Kind is RegexNodeKind.Loop or RegexNodeKind.Lazyloop); 770RegexNodeKind kind = Kind; 780if (child.Kind != kind) 785switch (child.Kind) 799switch (child.Kind) 847switch (child.Kind) 852child.MakeRep(u.Kind == RegexNodeKind.Lazyloop ? RegexNodeKind.Onelazy : RegexNodeKind.Oneloop, u.M, u.N); 876Debug.Assert(Kind is RegexNodeKind.Set or RegexNodeKind.Setloop or RegexNodeKind.Setloopatomic or RegexNodeKind.Setlazy); 889Kind == RegexNodeKind.Set ? RegexNodeKind.One : 890Kind == RegexNodeKind.Setloop ? RegexNodeKind.Oneloop : 891Kind == RegexNodeKind.Setloopatomic ? RegexNodeKind.Oneloopatomic : 899Kind == RegexNodeKind.Set ? RegexNodeKind.Notone : 900Kind == RegexNodeKind.Setloop ? RegexNodeKind.Notoneloop : 901Kind == RegexNodeKind.Setloopatomic ? RegexNodeKind.Notoneloopatomic : 925Debug.Assert(Kind == RegexNodeKind.Alternate); 938if (node.Kind == RegexNodeKind.Alternate) 941if (node.Kind == RegexNodeKind.Alternate) 944if (node.Kind == RegexNodeKind.Alternate) 979if (at.Kind == RegexNodeKind.Alternate) 997else if (at.Kind is RegexNodeKind.Set or RegexNodeKind.One) 1002if (at.Kind == RegexNodeKind.Set) 1026if (prev.Kind == RegexNodeKind.One) 1036if (at.Kind == RegexNodeKind.One) 1053else if (at.Kind == RegexNodeKind.Nothing) 1077Debug.Assert(alternation.Kind == RegexNodeKind.Alternate); 1090if (child.Kind != RegexNodeKind.Concatenate || child.ChildCount() < 2) 1105switch (required.Kind) 1125if (required.Kind != other.Kind || 1151if (alternation.Parent is RegexNode { Kind: RegexNodeKind.Atomic }) 1176Debug.Assert(node.Kind == RegexNodeKind.Alternate); 1185switch (child.Kind) 1219Debug.Assert(alternation.Kind == RegexNodeKind.Alternate); 1246if (startingNode.Kind == RegexNodeKind.One) 1266if (startingNode.Kind == RegexNodeKind.One) 1280Debug.Assert(startingNode.Kind == RegexNodeKind.Multi); 1317ProcessOneOrMulti(branch.Kind == RegexNodeKind.Concatenate ? branch.Child(0) : branch, startingSpan); 1325if (node.Kind == RegexNodeKind.One) 1334Debug.Assert(node.Kind == RegexNodeKind.Multi); 1355if (alternation.Parent is RegexNode parent && parent.Kind == RegexNodeKind.Atomic) 1382RegexNode branch = Kind == RegexNodeKind.Concatenate ? Child(0) : this; 1383return branch.Kind is RegexNodeKind.One or RegexNodeKind.Multi ? branch : null; 1389Debug.Assert(Kind is RegexNodeKind.One or RegexNodeKind.Multi || (IsOneFamily && M > 0)); 1402switch (node.Kind) 1437switch (node.Kind) 1504Debug.Assert(Kind == RegexNodeKind.Concatenate); 1520if (child.Kind == RegexNodeKind.Nothing) 1546Debug.Assert(Kind == RegexNodeKind.Concatenate); 1563if (at.Kind == RegexNodeKind.Concatenate && 1582else if (at.Kind is RegexNodeKind.Multi or RegexNodeKind.One) 1596if (prev.Kind == RegexNodeKind.One) 1603((at.Kind == RegexNodeKind.One) ? $"{prev.Str}{at.Ch}" : prev.Str + at.Str) : 1604((at.Kind == RegexNodeKind.One) ? $"{at.Ch}{prev.Str}" : at.Str + prev.Str); 1606else if (at.Kind == RegexNodeKind.Empty) 1629Debug.Assert(Kind == RegexNodeKind.Concatenate); 1664switch (currentNode.Kind) 1667case 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: 1668case RegexNodeKind.Setloop or RegexNodeKind.Setloopatomic or RegexNodeKind.Setlazy when nextNode.Kind == currentNode.Kind && currentNode.Str == nextNode.Str: 1670currentNode.Kind is RegexNodeKind.Oneloopatomic or RegexNodeKind.Notoneloopatomic or RegexNodeKind.Setloopatomic) 1693case RegexNodeKind.Oneloop or RegexNodeKind.Onelazy when nextNode.Kind == RegexNodeKind.One && currentNode.Ch == nextNode.Ch: 1694case RegexNodeKind.Notoneloop or RegexNodeKind.Notonelazy when nextNode.Kind == RegexNodeKind.Notone && currentNode.Ch == nextNode.Ch: 1695case RegexNodeKind.Setloop or RegexNodeKind.Setlazy when nextNode.Kind == RegexNodeKind.Set && currentNode.Str == nextNode.Str: 1710nextNode.Kind == RegexNodeKind.Multi && 1761case RegexNodeKind.One when (nextNode.Kind is RegexNodeKind.Oneloop or RegexNodeKind.Oneloopatomic or RegexNodeKind.Onelazy) && currentNode.Ch == nextNode.Ch: 1762case RegexNodeKind.Notone when (nextNode.Kind is RegexNodeKind.Notoneloop or RegexNodeKind.Notoneloopatomic or RegexNodeKind.Notonelazy) && currentNode.Ch == nextNode.Ch: 1763case RegexNodeKind.Set when (nextNode.Kind is RegexNodeKind.Setloop or RegexNodeKind.Setloopatomic or RegexNodeKind.Setlazy) && currentNode.Str == nextNode.Str: 1766currentNode.Kind = nextNode.Kind; 1776case RegexNodeKind.Notone when nextNode.Kind == currentNode.Kind && currentNode.Ch == nextNode.Ch: 1777case RegexNodeKind.Set when nextNode.Kind == RegexNodeKind.Set && currentNode.Str == nextNode.Str: 1827if (Kind is not RegexNodeKind.Concatenate) 1852if (node.Kind is RegexNodeKind.Capture or RegexNodeKind.Concatenate) 1862if (node.Kind == RegexNodeKind.Loop) 1877switch (node.Kind) 1919for (int b = node.Kind == RegexNodeKind.ExpressionConditional ? 1 : 0; b < alternateBranches; b++) 1939Debug.Assert(node.Kind is RegexNodeKind.Loop or RegexNodeKind.Lazyloop); 1945while (node.Kind == RegexNodeKind.Capture) 1956if (node.Kind == RegexNodeKind.Concatenate) 1973Debug.Assert(Kind is RegexNodeKind.PositiveLookaround or RegexNodeKind.NegativeLookaround); 1989if (Child(0).Kind == RegexNodeKind.Empty) 1991Kind = Kind == RegexNodeKind.PositiveLookaround ? RegexNodeKind.Empty : RegexNodeKind.Nothing; 2001Debug.Assert(Kind == RegexNodeKind.BackreferenceConditional); 2019Debug.Assert(Kind == RegexNodeKind.ExpressionConditional); 2037if (condition.Kind == RegexNodeKind.PositiveLookaround && (condition.Options & RegexOptions.RightToLeft) == 0) 2073Debug.Assert(subsequent.Kind != RegexNodeKind.Group); 2074switch (subsequent.Kind) 2101switch (subsequent.Kind) 2118switch (node.Kind) 2122switch (subsequent.Kind) 2152switch (subsequent.Kind) 2171switch (subsequent.Kind) 2213switch (parent?.Kind) 2264switch (Kind) 2359Debug.Fail($"Unknown node: {Kind}"); 2377switch (Kind) 2437int i = Kind == RegexNodeKind.BackreferenceConditional ? 0 : 1; 2496Debug.Fail($"Unknown node: {Kind}"); 2520Debug.Assert(Kind == RegexNodeKind.Concatenate, $"Expected Concatenate, got {Kind}"); 2533if (child.Kind is RegexNodeKind.One) 2546else if (child.Kind is RegexNodeKind.Multi) 2558else if (child.Kind is RegexNodeKind.Set || 2559(child.Kind is RegexNodeKind.Setloop or RegexNodeKind.Setlazy or RegexNodeKind.Setloopatomic && child.M == child.N)) 2568vsb.Append((char)(twoChars[0] | 0x20), child.Kind is RegexNodeKind.Set ? 1 : child.M); 2570else if (child.Kind is RegexNodeKind.Empty) 2577child.Kind is RegexNodeKind.Beginning or 2636Debug.Assert(Kind == RegexNodeKind.Concatenate, $"Expected Concatenate, got {Kind}"); 2638static bool CanJoinLengthCheck(RegexNode node) => node.Kind switch 2692case <= MultiVsRepeaterLimit when Kind == RegexNodeKind.One: 2705switch (Kind) 2837public bool IsSetFamily => Kind is RegexNodeKind.Set or RegexNodeKind.Setloop or RegexNodeKind.Setloopatomic or RegexNodeKind.Setlazy; 2840public bool IsOneFamily => Kind is RegexNodeKind.One or RegexNodeKind.Oneloop or RegexNodeKind.Oneloopatomic or RegexNodeKind.Onelazy; 2843public bool IsNotoneFamily => Kind is RegexNodeKind.Notone or RegexNodeKind.Notoneloop or RegexNodeKind.Notoneloopatomic or RegexNodeKind.Notonelazy; 2882var sb = new StringBuilder(Kind.ToString()); 2892switch (Kind) 2931switch (Kind)
System\Text\RegularExpressions\RegexParser.cs (6)
1004if (_group!.Kind != RegexNodeKind.ExpressionConditional) 1142if (result != null && result.Kind == RegexNodeKind.Backreference && (result.Options & RegexOptions.IgnoreCase) != 0) 2052if (_group.Kind == RegexNodeKind.ExpressionConditional && _group.ChildCount() == 0) 2077if (_group!.Kind is RegexNodeKind.ExpressionConditional or RegexNodeKind.BackreferenceConditional) 2092if (_group!.Kind is RegexNodeKind.ExpressionConditional or RegexNodeKind.BackreferenceConditional) 2096if (_group.Kind == RegexNodeKind.BackreferenceConditional && _group.ChildCount() > 2 || _group.ChildCount() > 3)
System\Text\RegularExpressions\RegexPrefixAnalyzer.cs (27)
80switch (node.Kind) 114int reps = node.Kind is RegexNodeKind.One ? 1 : Math.Min(node.M, MaxPrefixLength); 119return node.Kind is RegexNodeKind.One || reps == node.N; 164int reps = node.Kind is RegexNodeKind.Set ? 1 : Math.Min(node.M, MaxPrefixLength); 209return node.Kind is RegexNodeKind.Set || reps == node.N; 360switch (node.Kind) 489switch (node.Kind) 598switch (node.Kind) 941switch (node.Kind) 950return node.Kind is RegexNodeKind.One || node.M > 0 ? true : null; 968return node.Kind is RegexNodeKind.Notone || node.M > 0 ? true : null; 987node.Kind is RegexNodeKind.Set || node.M > 0 ? true : 1080int branchStart = node.Kind is RegexNodeKind.BackreferenceConditional ? 0 : 1; 1094Debug.Fail($"Unexpected node {node.Kind}"); 1114while (node.Kind is RegexNodeKind.Atomic or RegexNodeKind.Capture) 1118if (node.Kind != RegexNodeKind.Concatenate) 1131while (firstChild.Kind is RegexNodeKind.Atomic or RegexNodeKind.Capture) 1135if (firstChild.Kind is not (RegexNodeKind.Setloop or RegexNodeKind.Setloopatomic or RegexNodeKind.Setlazy) || firstChild.N != int.MaxValue) 1143if (nextChild.Kind == RegexNodeKind.UpdateBumpalong) 1200while ((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)) 1253switch (node.Kind) 1325switch (node.Kind) 1336return node.Kind; 1364switch (tmpChild.Kind) 1393if (node.Child(i).Kind is not (RegexNodeKind.Empty or RegexNodeKind.PositiveLookaround or RegexNodeKind.NegativeLookaround))
System\Text\RegularExpressions\RegexReplacement.cs (4)
36Debug.Assert(concat.Kind == RegexNodeKind.Concatenate, $"Expected Concatenate, got {concat.Kind}"); 48switch (child.Kind) 77Debug.Fail($"Unexpected child kind {child.Kind}");
System\Text\RegularExpressions\RegexTreeAnalyzer.cs (3)
47switch (node.Kind) 59switch (node.Kind) 90bool treatChildAsAtomic = (isAtomicByAncestor | isAtomicBySelf) && node.Kind switch
System\Text\RegularExpressions\RegexWriter.cs (11)
85EmitFragment(curNode.Kind, curNode, 0); 89EmitFragment(curNode.Kind | BeforeChild, curNode, curChild); 105EmitFragment(curNode.Kind | AfterChild, curNode, curChild); 383Emit((RegexOpcode)node.Kind | bits, node.Ch); 394Emit(((node.Kind is RegexNodeKind.Oneloop or RegexNodeKind.Oneloopatomic or RegexNodeKind.Onelazy) ? 399Emit((RegexOpcode)node.Kind | bits, node.Ch, node.N == int.MaxValue ? int.MaxValue : node.N - node.M); 414Emit((RegexOpcode)node.Kind | bits, stringCode, (node.N == int.MaxValue) ? int.MaxValue : node.N - node.M); 420Emit((RegexOpcode)node.Kind | bits, StringCode(node.Str!)); 424Emit((RegexOpcode)node.Kind | bits, StringCode(node.Str!)); 428Emit((RegexOpcode)node.Kind | bits, RegexParser.MapCaptureNumber(node.M, _tree.CaptureNumberSparseMapping)); 443Emit((RegexOpcode)node.Kind);
System\Text\RegularExpressions\Symbolic\RegexNodeConverter.cs (11)
53switch (node.Kind) 117result.AddLast(_builder.CreateLoop(_builder.CreateSingleton(bdd), node.Kind is RegexNodeKind.Onelazy or RegexNodeKind.Notonelazy, node.M, node.N)); 128result.AddLast(_builder.CreateLoop(_builder.CreateSingleton(setBdd), node.Kind == RegexNodeKind.Setlazy, node.M, node.N)); 178throw new NotSupportedException(SR.Format(SR.NotSupported_NonBacktrackingConflictingExpression, node.Kind switch 195string description = $"Unexpected ({nameof(RegexNodeKind)}: {node.Kind})"; 209switch (node.Kind) 260result.AddLast(_builder.CreateLoop(body, node.Kind == RegexNodeKind.Lazyloop, node.M, node.N)); 267Debug.Assert(node.Kind == RegexNodeKind.Capture && node.N == -1); 285Debug.Assert(rootResult.Count == 1 || root.Kind == RegexNodeKind.Concatenate || root.Kind == RegexNodeKind.Capture); 312Debug.Assert(node.Kind == RegexNodeKind.Set);