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; 1325node.Kind = RegexNodeKind.Empty; 1334node.Kind = RegexNodeKind.Empty; 1339node.Kind = RegexNodeKind.One; 1594prev.Kind = RegexNodeKind.Multi; 1736nextNode.Kind = RegexNodeKind.One; 1759currentNode.Kind = nextNode.Kind; 1897node.Kind -= RegexNodeKind.Onelazy - RegexNodeKind.Oneloop; // lazy to greedy 1984Kind = Kind == RegexNodeKind.PositiveLookaround ? RegexNodeKind.Empty : RegexNodeKind.Nothing; 2691Kind = RegexNodeKind.Multi;
221 references to Kind
System.Text.RegularExpressions (221)
System\Text\RegularExpressions\RegexCompiler.cs (1)
1246Debug.Assert(target.LoopNode.Kind is RegexNodeKind.Setloop or RegexNodeKind.Setlazy or RegexNodeKind.Setloopatomic);
System\Text\RegularExpressions\RegexFindOptimizations.cs (1)
763Debug.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) 1121if (required.Kind != other.Kind || 1147if (alternation.Parent is RegexNode { Kind: RegexNodeKind.Atomic }) 1172Debug.Assert(node.Kind == RegexNodeKind.Alternate); 1181switch (child.Kind) 1215Debug.Assert(alternation.Kind == RegexNodeKind.Alternate); 1242if (startingNode.Kind == RegexNodeKind.One) 1262if (startingNode.Kind == RegexNodeKind.One) 1276Debug.Assert(startingNode.Kind == RegexNodeKind.Multi); 1313ProcessOneOrMulti(branch.Kind == RegexNodeKind.Concatenate ? branch.Child(0) : branch, startingSpan); 1321if (node.Kind == RegexNodeKind.One) 1330Debug.Assert(node.Kind == RegexNodeKind.Multi); 1351if (alternation.Parent is RegexNode parent && parent.Kind == RegexNodeKind.Atomic) 1378RegexNode branch = Kind == RegexNodeKind.Concatenate ? Child(0) : this; 1379return branch.Kind is RegexNodeKind.One or RegexNodeKind.Multi ? branch : null; 1385Debug.Assert(Kind is RegexNodeKind.One or RegexNodeKind.Multi || (IsOneFamily && M > 0)); 1398switch (node.Kind) 1433switch (node.Kind) 1500Debug.Assert(Kind == RegexNodeKind.Concatenate); 1516if (child.Kind == RegexNodeKind.Nothing) 1542Debug.Assert(Kind == RegexNodeKind.Concatenate); 1559if (at.Kind == RegexNodeKind.Concatenate && 1578else if (at.Kind is RegexNodeKind.Multi or RegexNodeKind.One) 1592if (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); 1602else if (at.Kind == RegexNodeKind.Empty) 1625Debug.Assert(Kind == RegexNodeKind.Concatenate); 1660switch (currentNode.Kind) 1663case 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: 1664case RegexNodeKind.Setloop or RegexNodeKind.Setloopatomic or RegexNodeKind.Setlazy when nextNode.Kind == currentNode.Kind && currentNode.Str == nextNode.Str: 1666currentNode.Kind is RegexNodeKind.Oneloopatomic or RegexNodeKind.Notoneloopatomic or RegexNodeKind.Setloopatomic) 1689case RegexNodeKind.Oneloop or RegexNodeKind.Onelazy when nextNode.Kind == RegexNodeKind.One && currentNode.Ch == nextNode.Ch: 1690case RegexNodeKind.Notoneloop or RegexNodeKind.Notonelazy when nextNode.Kind == RegexNodeKind.Notone && currentNode.Ch == nextNode.Ch: 1691case RegexNodeKind.Setloop or RegexNodeKind.Setlazy when nextNode.Kind == RegexNodeKind.Set && currentNode.Str == nextNode.Str: 1705case RegexNodeKind.Oneloop or RegexNodeKind.Onelazy when nextNode.Kind == RegexNodeKind.Multi && currentNode.Ch == nextNode.Str![0]: 1754case RegexNodeKind.One when (nextNode.Kind is RegexNodeKind.Oneloop or RegexNodeKind.Oneloopatomic or RegexNodeKind.Onelazy) && currentNode.Ch == nextNode.Ch: 1755case RegexNodeKind.Notone when (nextNode.Kind is RegexNodeKind.Notoneloop or RegexNodeKind.Notoneloopatomic or RegexNodeKind.Notonelazy) && currentNode.Ch == nextNode.Ch: 1756case RegexNodeKind.Set when (nextNode.Kind is RegexNodeKind.Setloop or RegexNodeKind.Setloopatomic or RegexNodeKind.Setlazy) && currentNode.Str == nextNode.Str: 1759currentNode.Kind = nextNode.Kind; 1769case RegexNodeKind.Notone when nextNode.Kind == currentNode.Kind && currentNode.Ch == nextNode.Ch: 1770case RegexNodeKind.Set when nextNode.Kind == RegexNodeKind.Set && currentNode.Str == nextNode.Str: 1820if (Kind is not RegexNodeKind.Concatenate) 1845if (node.Kind is RegexNodeKind.Capture or RegexNodeKind.Concatenate) 1855if (node.Kind == RegexNodeKind.Loop) 1870switch (node.Kind) 1912for (int b = node.Kind == RegexNodeKind.ExpressionConditional ? 1 : 0; b < alternateBranches; b++) 1932Debug.Assert(node.Kind is RegexNodeKind.Loop or RegexNodeKind.Lazyloop); 1938while (node.Kind == RegexNodeKind.Capture) 1949if (node.Kind == RegexNodeKind.Concatenate) 1966Debug.Assert(Kind is RegexNodeKind.PositiveLookaround or RegexNodeKind.NegativeLookaround); 1982if (Child(0).Kind == RegexNodeKind.Empty) 1984Kind = Kind == RegexNodeKind.PositiveLookaround ? RegexNodeKind.Empty : RegexNodeKind.Nothing; 1994Debug.Assert(Kind == RegexNodeKind.BackreferenceConditional); 2012Debug.Assert(Kind == RegexNodeKind.ExpressionConditional); 2030if (condition.Kind == RegexNodeKind.PositiveLookaround && (condition.Options & RegexOptions.RightToLeft) == 0) 2066Debug.Assert(subsequent.Kind != RegexNodeKind.Group); 2067switch (subsequent.Kind) 2094switch (subsequent.Kind) 2111switch (node.Kind) 2115switch (subsequent.Kind) 2145switch (subsequent.Kind) 2164switch (subsequent.Kind) 2206switch (parent?.Kind) 2257switch (Kind) 2352Debug.Fail($"Unknown node: {Kind}"); 2370switch (Kind) 2430int i = Kind == RegexNodeKind.BackreferenceConditional ? 0 : 1; 2489Debug.Fail($"Unknown node: {Kind}"); 2513Debug.Assert(Kind == RegexNodeKind.Concatenate, $"Expected Concatenate, got {Kind}"); 2526if (child.Kind is RegexNodeKind.One) 2539else if (child.Kind is RegexNodeKind.Multi) 2551else if (child.Kind is RegexNodeKind.Set || 2552(child.Kind is RegexNodeKind.Setloop or RegexNodeKind.Setlazy or RegexNodeKind.Setloopatomic && child.M == child.N)) 2561vsb.Append((char)(twoChars[0] | 0x20), child.Kind is RegexNodeKind.Set ? 1 : child.M); 2563else if (child.Kind is RegexNodeKind.Empty) 2570child.Kind is RegexNodeKind.Beginning or 2629Debug.Assert(Kind == RegexNodeKind.Concatenate, $"Expected Concatenate, got {Kind}"); 2631static bool CanJoinLengthCheck(RegexNode node) => node.Kind switch 2685case <= MultiVsRepeaterLimit when Kind == RegexNodeKind.One: 2698switch (Kind) 2830public bool IsSetFamily => Kind is RegexNodeKind.Set or RegexNodeKind.Setloop or RegexNodeKind.Setloopatomic or RegexNodeKind.Setlazy; 2833public bool IsOneFamily => Kind is RegexNodeKind.One or RegexNodeKind.Oneloop or RegexNodeKind.Oneloopatomic or RegexNodeKind.Onelazy; 2836public bool IsNotoneFamily => Kind is RegexNodeKind.Notone or RegexNodeKind.Notoneloop or RegexNodeKind.Notoneloopatomic or RegexNodeKind.Notonelazy; 2875var sb = new StringBuilder(Kind.ToString()); 2885switch (Kind) 2924switch (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 (26)
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)) 1251switch (node.Kind) 1262return node.Kind; 1281if (node.Child(i).Kind is not (RegexNodeKind.Empty or RegexNodeKind.PositiveLookaround or RegexNodeKind.NegativeLookaround)) 1292if (node.Child(i).Kind is not (RegexNodeKind.Empty or RegexNodeKind.PositiveLookaround or RegexNodeKind.NegativeLookaround))
System\Text\RegularExpressions\RegexReplacement.cs (4)
39Debug.Assert(concat.Kind == RegexNodeKind.Concatenate, $"Expected Concatenate, got {concat.Kind}"); 51switch (child.Kind) 80Debug.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);