10 writes to M
System.Text.RegularExpressions.Generator (10)
src\libraries\System.Text.RegularExpressions\src\System\Text\RegularExpressions\RegexNode.cs (10)
75M = m; 82M = m; 98newNode.M = M - 1; 153M = min; 188M = N = 0; 826u.M = min = ((int.MaxValue - 1) / u.M < min) ? int.MaxValue : u.M * min; 1684currentNode.M += nextNode.M; 1698currentNode.M++; 1725currentNode.M += matchingCharsInMulti; 1767currentNode.M = nextNode.M + 1;
161 references to M
System.Text.RegularExpressions.Generator (161)
RegexGenerator.Emitter.cs (55)
1377if (target.LoopNode.M > 0) 1402if (target.LoopNode.M > 0) 1423if (target.LoopNode.M > 0) 1427using (EmitBlock(writer, $"if ((i - prev - 1) < {target.LoopNode.M})")) 2118int capnum = RegexParser.MapCaptureNumber(node.M, rm.Tree.CaptureNumberSparseMapping); 2130writer.WriteLine($"// If the {DescribeCapture(node.M, rm)} hasn't matched, the backreference matches with RegexOptions.ECMAScript rules."); 2138writer.WriteLine($"// If the {DescribeCapture(node.M, rm)} hasn't matched, the backreference doesn't match."); 2193int capnum = RegexParser.MapCaptureNumber(node.M, rm.Tree.CaptureNumberSparseMapping); 2208writer.WriteLine($"// The {DescribeCapture(node.M, rm)} captured a value. Match the first branch."); 2548int capnum = RegexParser.MapCaptureNumber(node.M, rm.Tree.CaptureNumberSparseMapping); 3058child.M == child.N && 3059child.M <= MaxUnrollSize) 3061int repeatCount = child.Kind is RegexNodeKind.One or RegexNodeKind.Notone or RegexNodeKind.Set ? 1 : child.M; 3328if (node.M == node.N) 3338Debug.Assert(node.M < node.N); 3363EmitAdd(writer, startingPos, !rtl ? node.M : -node.M); 3461if (node.M > 0) 3468if (node.M == node.N || rm.Analysis.IsAtomicByAncestor(node)) 3473if (node.M > 0) 3479Debug.Assert(node.M < node.N); 3492maxIterations = $"{node.N - node.M}"; 3704Debug.Assert(node.M < int.MaxValue, $"Unexpected M={node.M}"); 3705Debug.Assert(node.N >= node.M, $"Unexpected M={node.M}, N={node.N}"); 3709int minIterations = node.M; 4015int iterations = node.M; 4130if (node.M == node.N) 4137if (node.M == 0 && node.N == 1) 4143Debug.Assert(node.N > node.M); 4144int minIterations = node.M; 4260Debug.Assert(node.M == 0 && node.N == 1); 4298Debug.Assert(node.M < int.MaxValue, $"Unexpected M={node.M}"); 4299Debug.Assert(node.M == node.N, $"Unexpected M={node.M} == N={node.N}"); 4308using (EmitBlock(writer, $"for (int {i} = 0; {i} < {node.M}; {i}++)")) 4318Debug.Assert(node.M < int.MaxValue, $"Unexpected M={node.M}"); 4319Debug.Assert(node.N >= node.M, $"Unexpected M={node.M}, N={node.N}"); 4323int minIterations = node.M; 5469RegexNodeKind.Capture when node.M == -1 && node.N != -1 => $"Non-capturing balancing group. Uncaptures the {DescribeCapture(node.N, rm)}.", 5470RegexNodeKind.Capture when node.N != -1 => $"Balancing group. Captures the {DescribeCapture(node.M, rm)} and uncaptures the {DescribeCapture(node.N, rm)}.", 5471RegexNodeKind.Capture when node.N == -1 => $"{DescribeCapture(node.M, rm)}.", 5478RegexNodeKind.Loop or RegexNodeKind.Lazyloop => node.M == 0 && node.N == 1 ? $"Optional ({(node.Kind is RegexNodeKind.Loop ? "greedy" : "lazy")})." : $"Loop {DescribeLoop(node, rm)}{direction}.", 5488RegexNodeKind.Backreference => $"Match the same text as matched by the {DescribeCapture(node.M, rm)}{direction}.", 5494RegexNodeKind.BackreferenceConditional => $"Conditionally match one of two expressions depending on whether the {DescribeCapture(node.M, rm)} matched.", 5625_ when node.M == node.N => "exactly", 5634node.M == node.N ? $" {node.M} times" : 5635(node.M, node.N) switch 5640(_, int.MaxValue) => $" at least {node.M} times", 5643_ => $" at least {node.M} and at most {node.N} times"
src\libraries\System.Text.RegularExpressions\src\System\Text\RegularExpressions\RegexNode.cs (63)
92Debug.Assert(M > 0); 98newNode.M = M - 1; 172N = M; 492node.N = node.M; 772int min = M; 817if (u.M == 0 && child.M > 1 || child.N < child.M * 2) 824if (u.M > 0) 826u.M = min = ((int.MaxValue - 1) / u.M < min) ? int.MaxValue : u.M * min; 852child.MakeRep(u.Kind == RegexNodeKind.Lazyloop ? RegexNodeKind.Onelazy : RegexNodeKind.Oneloop, u.M, u.N); 1109case RegexNodeKind.Oneloop or RegexNodeKind.Notoneloop or RegexNodeKind.Setloop or RegexNodeKind.Onelazy or RegexNodeKind.Notonelazy or RegexNodeKind.Setlazy when required.M == required.N: 1127required.M != other.M || 1389Debug.Assert(Kind is RegexNodeKind.One or RegexNodeKind.Multi || (IsOneFamily && M > 0)); 1405case RegexNodeKind.Oneloop or RegexNodeKind.Oneloopatomic or RegexNodeKind.Onelazy when node.M > 0: 1407case RegexNodeKind.Notoneloop or RegexNodeKind.Notoneloopatomic or RegexNodeKind.Notonelazy when node.M > 0: 1409case RegexNodeKind.Setloop or RegexNodeKind.Setloopatomic or RegexNodeKind.Setlazy when node.M > 0: 1417case RegexNodeKind.Loop or RegexNodeKind.Lazyloop when node.M > 0: 1669if (nextNode.M > 0 && 1679if (!CanCombineCounts(currentNode.M, currentNode.N, nextNode.M, nextNode.N)) 1684currentNode.M += nextNode.M; 1696if (CanCombineCounts(currentNode.M, currentNode.N, 1, 1)) 1722if (CanCombineCounts(currentNode.M, currentNode.N, matchingCharsInMulti, matchingCharsInMulti)) 1764if (CanCombineCounts(1, 1, nextNode.M, nextNode.N)) 1767currentNode.M = nextNode.M + 1; 2080case RegexNodeKind.Loop or RegexNodeKind.Lazyloop when subsequent.M > 0: 2127case RegexNodeKind.Onelazy or RegexNodeKind.Oneloop or RegexNodeKind.Oneloopatomic when subsequent.M > 0 && node.Ch != subsequent.Ch: 2128case RegexNodeKind.Notonelazy or RegexNodeKind.Notoneloop or RegexNodeKind.Notoneloopatomic when subsequent.M > 0 && node.Ch == subsequent.Ch: 2129case RegexNodeKind.Setlazy or RegexNodeKind.Setloop or RegexNodeKind.Setloopatomic when subsequent.M > 0 && !RegexCharClass.CharInClass(node.Ch, subsequent.Str!): 2135case RegexNodeKind.Onelazy or RegexNodeKind.Oneloop or RegexNodeKind.Oneloopatomic when subsequent.M == 0 && node.Ch != subsequent.Ch: 2136case RegexNodeKind.Notonelazy or RegexNodeKind.Notoneloop or RegexNodeKind.Notoneloopatomic when subsequent.M == 0 && node.Ch == subsequent.Ch: 2137case RegexNodeKind.Setlazy or RegexNodeKind.Setloop or RegexNodeKind.Setloopatomic when subsequent.M == 0 && !RegexCharClass.CharInClass(node.Ch, subsequent.Str!): 2138case RegexNodeKind.Boundary when node.M > 0 && RegexCharClass.IsBoundaryWordChar(node.Ch): 2139case RegexNodeKind.NonBoundary when node.M > 0 && !RegexCharClass.IsBoundaryWordChar(node.Ch): 2140case RegexNodeKind.ECMABoundary when node.M > 0 && RegexCharClass.IsECMAWordChar(node.Ch): 2141case RegexNodeKind.NonECMABoundary when node.M > 0 && !RegexCharClass.IsECMAWordChar(node.Ch): 2155case RegexNodeKind.Onelazy or RegexNodeKind.Oneloop or RegexNodeKind.Oneloopatomic when subsequent.M > 0 && node.Ch == subsequent.Ch: 2160case RegexNodeKind.Onelazy or RegexNodeKind.Oneloop or RegexNodeKind.Oneloopatomic when subsequent.M == 0 && node.Ch == subsequent.Ch: 2175case RegexNodeKind.Onelazy or RegexNodeKind.Oneloop or RegexNodeKind.Oneloopatomic when subsequent.M > 0 && !RegexCharClass.CharInClass(subsequent.Ch, node.Str!): 2176case RegexNodeKind.Setlazy or RegexNodeKind.Setloop or RegexNodeKind.Setloopatomic when subsequent.M > 0 && !RegexCharClass.MayOverlap(node.Str!, subsequent.Str!): 2182case RegexNodeKind.Onelazy or RegexNodeKind.Oneloop or RegexNodeKind.Oneloopatomic when subsequent.M == 0 && !RegexCharClass.CharInClass(subsequent.Ch, node.Str!): 2183case RegexNodeKind.Setlazy or RegexNodeKind.Setloop or RegexNodeKind.Setloopatomic when subsequent.M == 0 && !RegexCharClass.MayOverlap(node.Str!, subsequent.Str!): 2184case RegexNodeKind.Boundary when node.M > 0 && node.Str is RegexCharClass.WordClass or RegexCharClass.DigitClass: 2185case RegexNodeKind.NonBoundary when node.M > 0 && node.Str is RegexCharClass.NotWordClass or RegexCharClass.NotDigitClass: 2186case RegexNodeKind.ECMABoundary when node.M > 0 && node.Str is RegexCharClass.ECMAWordClass or RegexCharClass.ECMADigitClass: 2187case RegexNodeKind.NonECMABoundary when node.M > 0 && node.Str is RegexCharClass.NotECMAWordClass or RegexCharClass.NotDigitClass: 2286return M; 2291return (int)Math.Min(int.MaxValue - 1, (long)M * Child(0).ComputeMinLength()); 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); 2645when node.M == node.N => true, 2905sb.Append(' ').Append($"index = {M}"); 2913sb.Append(' ').Append($"index = {M}"); 2945(M == 0 && N == int.MaxValue) ? "*" : 2946(M == 0 && N == 1) ? "?" : 2947(M == 1 && N == int.MaxValue) ? "+" : 2948(N == int.MaxValue) ? $"{{{M}, *}}" : 2949(N == M) ? $"{{{M}}}" : 2950$"{{{M}, {N}}}");
src\libraries\System.Text.RegularExpressions\src\System\Text\RegularExpressions\RegexNodeKind.cs (14)
31/// The character is specified in <see cref="RegexNode.Ch"/>, the minimum number of iterations in <see cref="RegexNode.M"/>, and the maximum number of iterations in <see cref="RegexNode.N"/>. 36/// <remarks>The character is specified in <see cref="RegexNode.Ch"/>, the minimum number of iterations in <see cref="RegexNode.M"/>, and the maximum number of iterations in <see cref="RegexNode.N"/>.</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> 45/// <remarks>The character is specified in <see cref="RegexNode.Ch"/>, the minimum number of iterations in <see cref="RegexNode.M"/>, and the maximum number of iterations in <see cref="RegexNode.N"/>.</remarks> 49/// <remarks>The character is specified in <see cref="RegexNode.Ch"/>, 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> 59/// The character is specified in <see cref="RegexNode.Ch"/>, the minimum number of iterations in <see cref="RegexNode.M"/>, and the maximum number of iterations in <see cref="RegexNode.N"/>. 65/// The character is specified in <see cref="RegexNode.Ch"/>, the minimum number of iterations in <see cref="RegexNode.M"/>, and the maximum number of iterations in <see cref="RegexNode.N"/>. 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"/>. 77/// <remarks>The capture group number referenced is stored in <see cref="RegexNode.M"/>.</remarks> 128/// One and only one child, the expression in the loop. The minimum number of iterations is in <see cref="RegexNode.M"/>, 134/// One and only one child, the expression in the loop. The minimum number of iterations is in <see cref="RegexNode.M"/>, 141/// One and only one child, the expression in the capture. <see cref="RegexNode.M"/> is the number of the capture, and if a balancing 169/// The referenced capture group number is stored in <see cref="RegexNode.M"/>.
src\libraries\System.Text.RegularExpressions\src\System\Text\RegularExpressions\RegexOpcode.cs (1)
151/// For quantified constructs with a minimum of zero (<see cref="RegexNode.M"/> == 0), this opcode pushes a counter
src\libraries\System.Text.RegularExpressions\src\System\Text\RegularExpressions\RegexPrefixAnalyzer.cs (26)
114int reps = node.Kind is RegexNodeKind.One ? 1 : Math.Min(node.M, MaxPrefixLength); 164int reps = node.Kind is RegexNodeKind.Set ? 1 : Math.Min(node.M, MaxPrefixLength); 226case RegexNodeKind.Loop or RegexNodeKind.Lazyloop when node.M > 0: 228int limit = Math.Min(node.M, MaxPrefixLength); // MaxPrefixLength here is somewhat arbitrary, as a single loop iteration could yield multiple chars 432case RegexNodeKind.Oneloop or RegexNodeKind.Oneloopatomic or RegexNodeKind.Onelazy when node.M > 0: 434int count = Math.Min(node.M, SingleCharIterationLimit); 439case RegexNodeKind.Loop or RegexNodeKind.Lazyloop when node.M > 0: 442int limit = Math.Min(node.M, NodeIterationLimit); 493case RegexNodeKind.Loop or RegexNodeKind.Lazyloop when node.M > 0: 609case RegexNodeKind.Onelazy or RegexNodeKind.Oneloop or RegexNodeKind.Oneloopatomic when node.M > 0: 612int minIterations = Math.Min(node.M, MaxLoopExpansion); 618return i == node.M && i == node.N; 641case RegexNodeKind.Setlazy or RegexNodeKind.Setloop or RegexNodeKind.Setloopatomic when node.M > 0: 643int minIterations = Math.Min(node.M, MaxLoopExpansion); 649return i == node.M && i == node.N; 658case RegexNodeKind.Notonelazy or RegexNodeKind.Notoneloop or RegexNodeKind.Notoneloopatomic when node.M == node.N: 659distance += node.M; 686case RegexNodeKind.Lazyloop or RegexNodeKind.Loop when node.M > 0: 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 : 1033_ => node.M == 0 ? null : true, 1201(nextChild.Kind is RegexNodeKind.Loop or RegexNodeKind.Lazyloop && nextChild.M >= 1)) 1209(nextChild.Kind is RegexNodeKind.Set || nextChild.M >= 1)) 1279case RegexNodeKind.Loop or RegexNodeKind.Lazyloop when node.M >= 1: 1340case RegexNodeKind.Loop or RegexNodeKind.Lazyloop when leading && node.M >= 1:
src\libraries\System.Text.RegularExpressions\src\System\Text\RegularExpressions\RegexTreeAnalyzer.cs (2)
50case RegexNodeKind.Loop or RegexNodeKind.Lazyloop when node.M != node.N: 51case RegexNodeKind.Oneloop or RegexNodeKind.Notoneloop or RegexNodeKind.Setloop or RegexNodeKind.Onelazy or RegexNodeKind.Notonelazy or RegexNodeKind.Setlazy when node.M != node.N: