11 writes to M
System.Text.RegularExpressions.Generator (11)
src\libraries\System.Text.RegularExpressions\src\System\Text\RegularExpressions\RegexNode.cs (11)
75
M
= m;
82
M
= m;
98
newNode.
M
= M - 1;
153
M
= min;
200
M
= N = 0;
209
M
= N = 0;
885
u.
M
= min = ((int.MaxValue - 1) / u.M < min) ? int.MaxValue : u.M * min;
1864
currentNode.
M
+= nextNode.M;
1878
currentNode.
M
++;
1905
currentNode.
M
+= matchingCharsInMulti;
1947
currentNode.
M
= nextNode.M + 1;
171 references to M
System.Text.RegularExpressions.Generator (171)
RegexGenerator.Emitter.cs (55)
1516
if (target.LoopNode.
M
> 0)
1541
if (target.LoopNode.
M
> 0)
1562
if (target.LoopNode.
M
> 0)
1566
using (EmitBlock(writer, $"if ((i - prev - 1) < {target.LoopNode.
M
})"))
2205
int capnum = RegexParser.MapCaptureNumber(node.
M
, rm.Tree.CaptureNumberSparseMapping);
2217
writer.WriteLine($"// If the {DescribeCapture(node.
M
, rm)} hasn't matched, the backreference matches with RegexOptions.ECMAScript rules.");
2225
writer.WriteLine($"// If the {DescribeCapture(node.
M
, rm)} hasn't matched, the backreference doesn't match.");
2280
int capnum = RegexParser.MapCaptureNumber(node.
M
, rm.Tree.CaptureNumberSparseMapping);
2295
writer.WriteLine($"// The {DescribeCapture(node.
M
, rm)} captured a value. Match the first branch.");
2628
int capnum = RegexParser.MapCaptureNumber(node.
M
, rm.Tree.CaptureNumberSparseMapping);
3126
child.
M
== child.N &&
3127
child.
M
<= MaxUnrollSize)
3129
int repeatCount = child.Kind is RegexNodeKind.One or RegexNodeKind.Notone or RegexNodeKind.Set ? 1 : child.
M
;
3409
if (node.
M
== node.N)
3419
Debug.Assert(node.
M
< node.N);
3444
EmitAdd(writer, startingPos, !rtl ? node.
M
: -node.
M
);
3542
if (node.
M
> 0)
3549
if (node.
M
== node.N || rm.Analysis.IsAtomicByAncestor(node))
3554
if (node.
M
> 0)
3560
Debug.Assert(node.
M
< node.N);
3573
maxIterations = $"{node.N - node.
M
}";
3785
Debug.Assert(node.
M
< int.MaxValue, $"Unexpected M={node.
M
}");
3786
Debug.Assert(node.N >= node.
M
, $"Unexpected M={node.
M
}, N={node.N}");
3790
int minIterations = node.
M
;
4086
int iterations = node.
M
;
4207
if (node.
M
== node.N)
4214
if (node.
M
== 0 && node.N == 1)
4220
Debug.Assert(node.N > node.
M
);
4221
int minIterations = node.
M
;
4337
Debug.Assert(node.
M
== 0 && node.N == 1);
4375
Debug.Assert(node.
M
< int.MaxValue, $"Unexpected M={node.
M
}");
4376
Debug.Assert(node.
M
== node.N, $"Unexpected M={node.
M
} == N={node.N}");
4385
using (EmitBlock(writer, $"for (int {i} = 0; {i} < {node.
M
}; {i}++)"))
4395
Debug.Assert(node.
M
< int.MaxValue, $"Unexpected M={node.
M
}");
4396
Debug.Assert(node.N >= node.
M
, $"Unexpected M={node.
M
}, N={node.N}");
4400
int minIterations = node.
M
;
5546
RegexNodeKind.Capture when node.
M
== -1 && node.N != -1 => $"Non-capturing balancing group. Uncaptures the {DescribeCapture(node.N, rm)}.",
5547
RegexNodeKind.Capture when node.N != -1 => $"Balancing group. Captures the {DescribeCapture(node.
M
, rm)} and uncaptures the {DescribeCapture(node.N, rm)}.",
5548
RegexNodeKind.Capture when node.N == -1 => $"{DescribeCapture(node.
M
, rm)}.",
5555
RegexNodeKind.Loop or RegexNodeKind.Lazyloop => node.
M
== 0 && node.N == 1 ? $"Optional ({(node.Kind is RegexNodeKind.Loop ? "greedy" : "lazy")})." : $"Loop {DescribeLoop(node, rm)}{direction}.",
5565
RegexNodeKind.Backreference => $"Match the same text as matched by the {DescribeCapture(node.
M
, rm)}{direction}.",
5571
RegexNodeKind.BackreferenceConditional => $"Conditionally match one of two expressions depending on whether the {DescribeCapture(node.
M
, rm)} matched.",
5783
_ when node.
M
== node.N => "exactly",
5791
node.
M
== node.N ? $" {node.
M
} times" :
5792
(node.
M
, node.N) switch
5797
(_, int.MaxValue) => $" at least {node.
M
} times",
5800
_ => $" at least {node.
M
} and at most {node.N} times"
src\libraries\System.Text.RegularExpressions\src\System\Text\RegularExpressions\RegexNode.cs (75)
92
Debug.Assert(
M
> 0);
98
newNode.M =
M
- 1;
182
N =
M
;
207
RegexNode loopAsChild = new(RegexNodeKind.Loop, Options,
M
, N);
218
N =
M
;
831
int min =
M
;
876
if (u.
M
== 0 && child.
M
> 1 || child.N < child.
M
* 2)
883
if (u.
M
> 0)
885
u.M = min = ((int.MaxValue - 1) / u.
M
< min) ? int.MaxValue : u.
M
* min;
910
child.MakeRep(u.Kind == RegexNodeKind.Lazyloop ? RegexNodeKind.Onelazy : RegexNodeKind.Oneloop, u.
M
, u.N);
935
u = u.
M
== 0 ? new RegexNode(RegexNodeKind.Empty, Options) : child;
1210
case RegexNodeKind.Oneloop or RegexNodeKind.Notoneloop or RegexNodeKind.Setloop or RegexNodeKind.Onelazy or RegexNodeKind.Notonelazy or RegexNodeKind.Setlazy when required.
M
== required.N:
1229
required.
M
!= other.
M
||
1499
Debug.Assert(Kind is RegexNodeKind.One or RegexNodeKind.Multi || (IsOneFamily &&
M
> 0));
1585
case RegexNodeKind.Oneloop or RegexNodeKind.Oneloopatomic or RegexNodeKind.Onelazy when node.
M
> 0:
1587
case RegexNodeKind.Notoneloop or RegexNodeKind.Notoneloopatomic or RegexNodeKind.Notonelazy when node.
M
> 0:
1589
case RegexNodeKind.Setloop or RegexNodeKind.Setloopatomic or RegexNodeKind.Setlazy when node.
M
> 0:
1597
case RegexNodeKind.Loop or RegexNodeKind.Lazyloop when node.
M
> 0:
1849
if (nextNode.
M
> 0 &&
1859
if (!CanCombineCounts(currentNode.
M
, currentNode.N, nextNode.
M
, nextNode.N))
1864
currentNode.M += nextNode.
M
;
1876
if (CanCombineCounts(currentNode.
M
, currentNode.N, 1, 1))
1902
if (CanCombineCounts(currentNode.
M
, currentNode.N, matchingCharsInMulti, matchingCharsInMulti))
1944
if (CanCombineCounts(1, 1, nextNode.
M
, nextNode.N))
1947
currentNode.M = nextNode.
M
+ 1;
2370
case RegexNodeKind.Loop or RegexNodeKind.Lazyloop when subsequent.
M
> 0:
2425
case RegexNodeKind.Onelazy or RegexNodeKind.Oneloop or RegexNodeKind.Oneloopatomic when subsequent.
M
> 0 && node.Ch != subsequent.Ch:
2426
case RegexNodeKind.Notonelazy or RegexNodeKind.Notoneloop or RegexNodeKind.Notoneloopatomic when subsequent.
M
> 0 && node.Ch == subsequent.Ch:
2427
case RegexNodeKind.Setlazy or RegexNodeKind.Setloop or RegexNodeKind.Setloopatomic when subsequent.
M
> 0 && !RegexCharClass.CharInClass(node.Ch, subsequent.Str!):
2431
case RegexNodeKind.Boundary when node.
M
> 0 && RegexCharClass.IsBoundaryWordChar(node.Ch):
2432
case RegexNodeKind.NonBoundary when node.
M
> 0 && !RegexCharClass.IsBoundaryWordChar(node.Ch):
2433
case RegexNodeKind.ECMABoundary when node.
M
> 0 && RegexCharClass.IsECMAWordChar(node.Ch):
2434
case RegexNodeKind.NonECMABoundary when node.
M
> 0 && !RegexCharClass.IsECMAWordChar(node.Ch):
2437
case RegexNodeKind.Onelazy or RegexNodeKind.Oneloop or RegexNodeKind.Oneloopatomic when subsequent.
M
== 0 && node.Ch != subsequent.Ch:
2438
case RegexNodeKind.Notonelazy or RegexNodeKind.Notoneloop or RegexNodeKind.Notoneloopatomic when subsequent.
M
== 0 && node.Ch == subsequent.Ch:
2439
case RegexNodeKind.Setlazy or RegexNodeKind.Setloop or RegexNodeKind.Setloopatomic when subsequent.
M
== 0 && !RegexCharClass.CharInClass(node.Ch, subsequent.Str!):
2453
case RegexNodeKind.Onelazy or RegexNodeKind.Oneloop or RegexNodeKind.Oneloopatomic when subsequent.
M
> 0 && node.Ch == subsequent.Ch:
2458
case RegexNodeKind.Onelazy or RegexNodeKind.Oneloop or RegexNodeKind.Oneloopatomic when subsequent.
M
== 0 && node.Ch == subsequent.Ch:
2473
case RegexNodeKind.Onelazy or RegexNodeKind.Oneloop or RegexNodeKind.Oneloopatomic when subsequent.
M
> 0 && !RegexCharClass.CharInClass(subsequent.Ch, node.Str!):
2474
case RegexNodeKind.Setlazy or RegexNodeKind.Setloop or RegexNodeKind.Setloopatomic when subsequent.
M
> 0 && !RegexCharClass.MayOverlap(node.Str!, subsequent.Str!):
2478
case RegexNodeKind.Boundary when node.
M
> 0 && RegexCharClass.IsKnownWordClassSubset(node.Str!):
2479
case RegexNodeKind.NonBoundary when node.
M
> 0 && node.Str is RegexCharClass.NotWordClass or RegexCharClass.NotDigitClass:
2480
case RegexNodeKind.ECMABoundary when node.
M
> 0 && node.Str is RegexCharClass.ECMAWordClass or RegexCharClass.ECMADigitClass:
2481
case RegexNodeKind.NonECMABoundary when node.
M
> 0 && node.Str is RegexCharClass.NotECMAWordClass or RegexCharClass.NotDigitClass:
2484
case RegexNodeKind.Onelazy or RegexNodeKind.Oneloop or RegexNodeKind.Oneloopatomic when subsequent.
M
== 0 && !RegexCharClass.CharInClass(subsequent.Ch, node.Str!):
2485
case RegexNodeKind.Setlazy or RegexNodeKind.Setloop or RegexNodeKind.Setloopatomic when subsequent.
M
== 0 && !RegexCharClass.MayOverlap(node.Str!, subsequent.Str!):
2520
case RegexNodeKind.Onelazy or RegexNodeKind.Oneloop or RegexNodeKind.Oneloopatomic when subsequent.
M
> 0 && !CharInStartingOrEndingSet(subsequent.Ch):
2521
case RegexNodeKind.Setlazy or RegexNodeKind.Setloop or RegexNodeKind.Setloopatomic when subsequent.
M
> 0 && !MayOverlapStartingOrEndingSet(subsequent.Str!):
2525
case RegexNodeKind.Boundary when node.
M
> 0 && RegexCharClass.IsKnownWordClassSubset(loopStartingSet) && RegexCharClass.IsKnownWordClassSubset(loopEndingSet):
2526
case RegexNodeKind.NonBoundary when node.
M
> 0 && (loopStartingSet is RegexCharClass.NotWordClass or RegexCharClass.NotDigitClass) && (loopEndingSet is RegexCharClass.NotWordClass or RegexCharClass.NotDigitClass):
2527
case RegexNodeKind.ECMABoundary when node.
M
> 0 && (loopStartingSet is RegexCharClass.ECMAWordClass or RegexCharClass.ECMADigitClass) && (loopEndingSet is RegexCharClass.ECMAWordClass or RegexCharClass.ECMADigitClass):
2528
case RegexNodeKind.NonECMABoundary when node.
M
> 0 && (loopStartingSet is RegexCharClass.NotECMAWordClass or RegexCharClass.NotDigitClass) && (loopEndingSet is RegexCharClass.NotECMAWordClass or RegexCharClass.NotDigitClass):
2531
case RegexNodeKind.Onelazy or RegexNodeKind.Oneloop or RegexNodeKind.Oneloopatomic when subsequent.
M
== 0 && !CharInStartingOrEndingSet(subsequent.Ch):
2532
case RegexNodeKind.Setlazy or RegexNodeKind.Setloop or RegexNodeKind.Setloopatomic when subsequent.
M
== 0 && !MayOverlapStartingOrEndingSet(subsequent.Str!):
2604
RegexNodeKind.Loop or RegexNodeKind.Lazyloop when
M
!= N => true,
2607
RegexNodeKind.Setloop or RegexNodeKind.Setlazy when
M
!= N => true,
2726
return
M
;
2731
return (int)Math.Min(int.MaxValue - 1, (long)
M
* Child(0).ComputeMinLength());
2999
(child.Kind is RegexNodeKind.Setloop or RegexNodeKind.Setlazy or RegexNodeKind.Setloopatomic && child.
M
== child.N))
3008
vsb.Append((char)(twoChars[0] | 0x20), child.Kind is RegexNodeKind.Set ? 1 : child.
M
);
3070
when node.
M
== node.N => true,
3330
sb.Append(' ').Append($"index = {
M
}");
3338
sb.Append(' ').Append($"index = {
M
}");
3370
(
M
== 0 && N == int.MaxValue) ? "*" :
3371
(
M
== 0 && N == 1) ? "?" :
3372
(
M
== 1 && N == int.MaxValue) ? "+" :
3373
(N == int.MaxValue) ? $"{{{
M
}, *}}" :
3374
(N ==
M
) ? $"{{{
M
}}}" :
3375
$"{{{
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)
114
int reps = node.Kind is RegexNodeKind.One ? 1 : Math.Min(node.
M
, MaxPrefixLength);
164
int reps = node.Kind is RegexNodeKind.Set ? 1 : Math.Min(node.
M
, MaxPrefixLength);
226
case RegexNodeKind.Loop or RegexNodeKind.Lazyloop when node.
M
> 0:
228
int limit = Math.Min(node.
M
, MaxPrefixLength); // MaxPrefixLength here is somewhat arbitrary, as a single loop iteration could yield multiple chars
432
case RegexNodeKind.Oneloop or RegexNodeKind.Oneloopatomic or RegexNodeKind.Onelazy when node.
M
> 0:
434
int count = Math.Min(node.
M
, SingleCharIterationLimit);
439
case RegexNodeKind.Loop or RegexNodeKind.Lazyloop when node.
M
> 0:
442
int limit = Math.Min(node.
M
, NodeIterationLimit);
493
case RegexNodeKind.Loop or RegexNodeKind.Lazyloop when node.
M
> 0:
609
case RegexNodeKind.Onelazy or RegexNodeKind.Oneloop or RegexNodeKind.Oneloopatomic when node.
M
> 0:
612
int minIterations = Math.Min(node.
M
, MaxLoopExpansion);
618
return i == node.
M
&& i == node.N;
641
case RegexNodeKind.Setlazy or RegexNodeKind.Setloop or RegexNodeKind.Setloopatomic when node.
M
> 0:
643
int minIterations = Math.Min(node.
M
, MaxLoopExpansion);
649
return i == node.
M
&& i == node.N;
658
case RegexNodeKind.Notonelazy or RegexNodeKind.Notoneloop or RegexNodeKind.Notoneloopatomic when node.
M
== node.N:
659
distance += node.
M
;
686
case RegexNodeKind.Lazyloop or RegexNodeKind.Loop when node.
M
> 0:
959
return node.Kind is RegexNodeKind.One || node.
M
> 0 ? true : null;
977
return node.Kind is RegexNodeKind.Notone || node.
M
> 0 ? true : null;
996
node.Kind is RegexNodeKind.Set || node.
M
> 0 ? true :
1043
_ => node.
M
== 0 ? null : true,
1225
(nextChild.Kind is RegexNodeKind.Loop or RegexNodeKind.Lazyloop && nextChild.
M
>= 1))
1233
(nextChild.Kind is RegexNodeKind.Set || nextChild.
M
>= 1))
1303
case RegexNodeKind.Loop or RegexNodeKind.Lazyloop when node.
M
>= 1:
1362
case RegexNodeKind.Loop or RegexNodeKind.Lazyloop when leading && node.
M
>= 1: