63 instantiations of RegexNode
System.Text.RegularExpressions.Generator (63)
RegexGenerator.Emitter.cs (3)
1932
new
RegexNode
(RegexNodeKind.Empty, child.Options)); // single, so removing it yields empty
1978
new
(RegexNodeKind.One, multi.Options, multi.Str[1]) :
1979
new
(RegexNodeKind.Multi, multi.Options, multi.Str.Substring(1));
src\libraries\System.Text.RegularExpressions\src\System\Text\RegularExpressions\RegexNode.cs (27)
95
new
RegexNode
(Kind, Options, Str!) :
96
new
RegexNode
(Kind, Options, Ch);
121
return new
RegexNode
(RegexNodeKind.One, options & ~RegexOptions.IgnoreCase, ch);
127
return new
RegexNode
(RegexNodeKind.Set, options & ~RegexOptions.IgnoreCase, stringSet);
131
return new
RegexNode
(RegexNodeKind.One, options, ch);
207
RegexNode loopAsChild =
new
(RegexNodeKind.Loop, Options, M, N);
428
parent.InsertChild(1, new
RegexNode
(RegexNodeKind.UpdateBumpalong, node.Options));
501
var atomic = new
RegexNode
(RegexNodeKind.Atomic, existingChild.Options);
615
0 => new
RegexNode
(Kind == RegexNodeKind.Alternate ? RegexNodeKind.Nothing : RegexNodeKind.Empty, Options),
706
return new
RegexNode
(RegexNodeKind.Empty, child.Options);
896
return new
RegexNode
(RegexNodeKind.Nothing, Options);
935
u = u.M == 0 ? new
RegexNode
(RegexNodeKind.Empty, Options) : child;
1023
return new
RegexNode
(RegexNodeKind.Nothing, Options);
1245
var newAlternate = new
RegexNode
(RegexNodeKind.Alternate, alternation.Options);
1256
newAlternate.AddChild(new
RegexNode
(RegexNodeKind.Empty, children[i].Options));
1263
var atomic = new
RegexNode
(RegexNodeKind.Atomic, alternation.Options);
1270
var newConcat = new
RegexNode
(RegexNodeKind.Concatenate, alternation.Options);
1421
new
RegexNode
(RegexNodeKind.One, startingNodeOptions, startingSpan[0]) :
1422
new
RegexNode
(RegexNodeKind.Multi, startingNodeOptions, startingSpan.ToString());
1423
var newAlternate = new
RegexNode
(RegexNodeKind.Alternate, startingNodeOptions);
1467
var atomic = new
RegexNode
(RegexNodeKind.Atomic, startingNodeOptions);
1472
var newConcat = new
RegexNode
(RegexNodeKind.Concatenate, startingNodeOptions);
1690
return new
RegexNode
(RegexNodeKind.Empty, Options);
2292
AddChild(new
RegexNode
(RegexNodeKind.Empty, Options));
2310
AddChild(new
RegexNode
(RegexNodeKind.Empty, Options));
3111
return new
RegexNode
(RegexNodeKind.Empty, Options);
3139
var result = new
RegexNode
(lazy ? RegexNodeKind.Lazyloop : RegexNodeKind.Loop, Options, min, max);
src\libraries\System.Text.RegularExpressions\src\System\Text\RegularExpressions\RegexParser.cs (33)
277
StartGroup(new
RegexNode
(RegexNodeKind.Capture, (_options & ~RegexOptions.IgnoreCase), 0, -1));
347
_unit = new
RegexNode
(RegexNodeKind.Set, _options & ~RegexOptions.IgnoreCase, setString);
394
_unit = new
RegexNode
((_options & RegexOptions.Multiline) != 0 ? RegexNodeKind.Bol : RegexNodeKind.Beginning, _options);
398
_unit = new
RegexNode
((_options & RegexOptions.Multiline) != 0 ? RegexNodeKind.Eol : RegexNodeKind.EndZ, _options);
403
new
RegexNode
(RegexNodeKind.Set, _options & ~RegexOptions.IgnoreCase, RegexCharClass.AnyClass) :
404
new
RegexNode
(RegexNodeKind.Notone, _options & ~RegexOptions.IgnoreCase, '\n');
521
_concatenation = new
RegexNode
(RegexNodeKind.Concatenate, _options);
806
return new
RegexNode
(RegexNodeKind.Group, _options);
810
return new
RegexNode
(RegexNodeKind.Capture, _options, _autocap++, -1);
984
return new
RegexNode
(RegexNodeKind.Capture, _options, capnum, uncapnum);
1006
return new
RegexNode
(RegexNodeKind.BackreferenceConditional, _options, capnum);
1020
return new
RegexNode
(RegexNodeKind.BackreferenceConditional, _options, tmpCapnum);
1073
return new
RegexNode
(nodeType, _options);
1138
new
RegexNode
(TypeFromCode(ch), _options);
1143
new
RegexNode
(RegexNodeKind.Set, (_options & ~RegexOptions.IgnoreCase), (_options & RegexOptions.ECMAScript) != 0 ? RegexCharClass.ECMAWordClass : RegexCharClass.WordClass);
1148
new
RegexNode
(RegexNodeKind.Set, (_options & ~RegexOptions.IgnoreCase), (_options & RegexOptions.ECMAScript) != 0 ? RegexCharClass.NotECMAWordClass : RegexCharClass.NotWordClass);
1153
new
RegexNode
(RegexNodeKind.Set, (_options & ~RegexOptions.IgnoreCase), (_options & RegexOptions.ECMAScript) != 0 ? RegexCharClass.ECMASpaceClass : RegexCharClass.SpaceClass);
1158
new
RegexNode
(RegexNodeKind.Set, (_options & ~RegexOptions.IgnoreCase), (_options & RegexOptions.ECMAScript) != 0 ? RegexCharClass.NotECMASpaceClass : RegexCharClass.NotSpaceClass);
1163
new
RegexNode
(RegexNodeKind.Set, (_options & ~RegexOptions.IgnoreCase), (_options & RegexOptions.ECMAScript) != 0 ? RegexCharClass.ECMADigitClass : RegexCharClass.DigitClass);
1168
new
RegexNode
(RegexNodeKind.Set, (_options & ~RegexOptions.IgnoreCase), (_options & RegexOptions.ECMAScript) != 0 ? RegexCharClass.NotECMADigitClass : RegexCharClass.NotDigitClass);
1185
return new
RegexNode
(RegexNodeKind.Set, (_options & ~RegexOptions.IgnoreCase), cc.ToStringClass());
1250
IsCaptureSlot(capnum) ? new
RegexNode
(RegexNodeKind.Backreference, _options, capnum) :
1282
return scanOnly ? null : new
RegexNode
(RegexNodeKind.Backreference, _options, capnum);
1296
return new
RegexNode
(RegexNodeKind.Backreference, _options, capnum);
1316
_capnames?[capname] is int tmpCapnum ? new
RegexNode
(RegexNodeKind.Backreference, _options, tmpCapnum) :
1392
return new
RegexNode
(RegexNodeKind.Backreference, _options, capnum);
1402
return new
RegexNode
(RegexNodeKind.Backreference, _options, capnum);
1414
return new
RegexNode
(RegexNodeKind.Backreference, _options, tmpCapnum);
1452
return new
RegexNode
(RegexNodeKind.Backreference, _options, capnum);
2051
_concatenation!.AddChild(new
RegexNode
(RegexNodeKind.Multi, _options & ~RegexOptions.IgnoreCase, _pattern.Substring(pos, cch)));
2097
_alternation = new
RegexNode
(RegexNodeKind.Alternate, _options);
2098
_concatenation = new
RegexNode
(RegexNodeKind.Concatenate, _options);
2115
_concatenation = new
RegexNode
(RegexNodeKind.Concatenate, _options);
313 references to RegexNode
System.Text.RegularExpressions.Generator (313)
RegexGenerator.cs (2)
347
RegexNode
node = method.Tree.Root;
371
static bool HasCaseInsensitiveBackReferences(
RegexNode
node)
RegexGenerator.Emitter.cs (59)
755
RegexNode
root = rm.Tree.Root.Child(0);
1500
(
RegexNode
LoopNode, (char Char, string? String, StringComparison StringComparison, char[]? Chars) Literal) target = regexTree.FindOptimizations.LiteralAfterLoop.Value;
1622
RegexNode
node = regexTree.Root;
1803
void EmitAlternation(
RegexNode
node)
1887
RegexNode
child = node.Child(i);
1888
RegexNode
? startingLiteralNode = child.FindStartingLiteralNode(allowZeroWidth: false);
1928
RegexNode
originalFirst = child.Child(0);
1974
static
RegexNode
SliceOffMultiFirstChar(
RegexNode
multi)
2201
void EmitBackreference(
RegexNode
node)
2270
void EmitBackreferenceConditional(
RegexNode
node)
2284
RegexNode
yesBranch = node.Child(0);
2285
RegexNode
? noBranch = node.Child(1) is { Kind: not RegexNodeKind.Empty } childNo ? childNo : null;
2443
void EmitExpressionConditional(
RegexNode
node)
2456
RegexNode
condition = node.Child(0);
2460
RegexNode
yesBranch = node.Child(1);
2461
RegexNode
? noBranch = node.Child(2) is { Kind: not RegexNodeKind.Empty } childNo ? childNo : null;
2623
void EmitCapture(
RegexNode
node,
RegexNode
? subsequent = null)
2647
RegexNode
child = node.Child(0);
2716
void EmitPositiveLookaroundAssertion(
RegexNode
node)
2757
void EmitNegativeLookaroundAssertion(
RegexNode
node)
2788
RegexNode
child = node.Child(0);
2855
void EmitNode(
RegexNode
node,
RegexNode
? subsequent = null, bool emitLengthChecksIfRequired = true)
3026
void EmitAtomic(
RegexNode
node,
RegexNode
? subsequent)
3056
void EmitUpdateBumpalong(
RegexNode
node)
3068
void EmitConcatenation(
RegexNode
node,
RegexNode
? subsequent, bool emitLengthChecksIfRequired)
3106
RegexNode
child = node.Child(i);
3181
static
RegexNode
? GetSubsequentOrDefault(int index,
RegexNode
node,
RegexNode
? defaultNode)
3186
RegexNode
next = node.Child(i);
3198
void EmitSingleChar(
RegexNode
node, bool emitLengthCheck = true, string? offset = null, bool clauseOnly = false)
3242
void EmitBoundary(
RegexNode
node)
3282
void EmitAnchors(
RegexNode
node)
3348
void EmitMultiChar(
RegexNode
node, bool emitLengthCheck)
3397
void EmitSingleCharLoop(
RegexNode
node,
RegexNode
? subsequent = null, bool emitLengthChecksIfRequired = true)
3482
subsequent?.FindStartingLiteralNode() is
RegexNode
literalNode &&
3535
void EmitSingleCharLazy(
RegexNode
node,
RegexNode
? subsequent = null, bool emitLengthChecksIfRequired = true)
3639
subsequent?.FindStartingLiteral() is
RegexNode
.StartingLiteralData literal &&
3707
subsequent?.FindStartingLiteralNode() is
RegexNode
literal2 &&
3782
void EmitLazy(
RegexNode
node)
3789
RegexNode
child = node.Child(0);
4082
void EmitSingleCharRepeater(
RegexNode
node, bool emitLengthCheck = true)
4100
case <=
RegexNode
.MultiVsRepeaterLimit when node.IsOneFamily:
4202
void EmitSingleCharAtomicLoop(
RegexNode
node, bool emitLengthChecksIfRequired = true)
4334
void EmitAtomicSingleCharZeroOrOne(
RegexNode
node)
4372
void EmitNonBacktrackingRepeater(
RegexNode
node)
4392
void EmitLoop(
RegexNode
node)
4398
RegexNode
child = node.Child(0);
5010
RegexNode
node,
5535
private static string DescribeNode(
RegexNode
node, RegexMethod rm)
5709
private static void DescribeExpressionAsXmlComment(TextWriter writer,
RegexNode
node, RegexMethod rm, int depth = 0)
5779
private static string DescribeLoop(
RegexNode
node, RegexMethod rm)
src\libraries\System.Text.RegularExpressions\src\System\Text\RegularExpressions\RegexFindOptimizations.cs (5)
18
public static RegexFindOptimizations Create(
RegexNode
root, RegexOptions options)
24
RegexPrefixAnalyzer.FindLeadingPositiveLookahead(root) is
RegexNode
positiveLookahead)
46
private RegexFindOptimizations(
RegexNode
root, RegexOptions options, bool isLeadingPartial)
202
(
RegexNode
LoopNode, (char Char, string? String, StringComparison StringComparison, char[]? Chars) Literal)? literalAfterLoop = RegexPrefixAnalyzer.FindLiteralFollowingLeadingLoop(root);
336
public (
RegexNode
LoopNode, (char Char, string? String, StringComparison StringComparison, char[]? Chars) Literal)? LiteralAfterLoop { get; }
src\libraries\System.Text.RegularExpressions\src\System\Text\RegularExpressions\RegexNode.cs (137)
19
/// <remarks>null if no children, a <see cref="
RegexNode
"/> if one child, or a <see cref="List{RegexNode}"/> if multiple children.</remarks>
49
public
RegexNode
? Parent;
87
public
RegexNode
CloneCharLoopWithOneLessIteration()
94
RegexNode
newNode = IsSetFamily ?
110
public static
RegexNode
CreateOneWithCaseConversion(char ch, RegexOptions options, CultureInfo? culture, ref RegexCaseBehavior caseBehavior)
135
public
RegexNode
ReverseConcatenationIfRightToLeft()
141
((List<
RegexNode
>)Children!).Reverse();
207
RegexNode
loopAsChild = new(RegexNodeKind.Loop, Options, M, N);
245
var toExamine = new Stack<
RegexNode
>();
249
RegexNode
node = toExamine.Pop();
255
RegexNode
child = node.Child(i);
369
internal
RegexNode
FinalOptimize()
371
RegexNode
rootNode = this;
409
RegexNode
node = rootNode.Child(0); // skip implicit root capture node
462
RegexNode
node = this;
497
RegexNode
existingChild = node.Child(node.ChildCount() - 1);
501
var
atomic = new RegexNode(RegexNodeKind.Atomic, existingChild.Options);
574
internal
RegexNode
Reduce()
610
private
RegexNode
ReplaceNodeIfUnnecessary()
627
private
RegexNode
ReduceGroup()
631
RegexNode
u = this;
648
private
RegexNode
ReduceAtomic()
660
RegexNode
atomic = this;
661
RegexNode
child = Child(0);
698
List<
RegexNode
>? branches = child.Children as List<
RegexNode
>;
739
RegexNode
startNode = branches[start];
775
RegexNode
nextChild = branches[next];
824
private
RegexNode
ReduceLoops()
828
RegexNode
u = this;
836
RegexNode
child = u.Child(0);
904
RegexNode
child = u.Child(0);
955
private
RegexNode
ReduceSet()
1016
private
RegexNode
ReduceAlternation()
1030
RegexNode
node = ReplaceNodeIfUnnecessary();
1075
RegexNode
at;
1076
RegexNode
prev;
1078
List<
RegexNode
> children = (List<
RegexNode
>)Children!;
1090
if (at.Children is List<
RegexNode
> atChildren)
1100
RegexNode
atChild = (
RegexNode
)at.Children!;
1184
static
RegexNode
ExtractCommonPrefixNode(
RegexNode
alternation)
1187
Debug.Assert(alternation.Children is List<
RegexNode
> { Count: >= 2 });
1188
var children = (List<
RegexNode
>)alternation.Children;
1204
RegexNode
startingNode = children[startingIndex];
1205
RegexNode
required = startingNode.Kind == RegexNodeKind.Concatenate ? startingNode.Child(0) : startingNode;
1225
RegexNode
endingNode = children[endingIndex];
1226
RegexNode
other = endingNode.Kind == RegexNodeKind.Concatenate ? endingNode.Child(0) : endingNode;
1245
var
newAlternate = new RegexNode(RegexNodeKind.Alternate, alternation.Options);
1250
((List<
RegexNode
>)children[i].Children!).RemoveAt(0);
1261
if (alternation.Parent is
RegexNode
{ Kind: RegexNodeKind.Atomic })
1263
var
atomic = new RegexNode(RegexNodeKind.Atomic, alternation.Options);
1270
var
newConcat = new RegexNode(RegexNodeKind.Concatenate, alternation.Options);
1284
static
RegexNode
RemoveRedundantEmptiesAndNothings(
RegexNode
node)
1288
var children = (List<
RegexNode
>)node.Children!;
1294
RegexNode
child = children[i];
1327
static
RegexNode
ExtractCommonPrefixText(
RegexNode
alternation)
1330
Debug.Assert(alternation.Children is List<
RegexNode
> { Count: >= 2 });
1331
var children = (List<
RegexNode
>)alternation.Children;
1348
RegexNode
? startingNode = children[startingIndex].FindBranchOneOrMultiStart();
1420
var
prefix = startingSpan.Length == 1 ?
1423
var
newAlternate = new RegexNode(RegexNodeKind.Alternate, startingNodeOptions);
1426
RegexNode
branch = children[i];
1433
static void ProcessOneOrMulti(
RegexNode
node, ReadOnlySpan<char> startingSpan)
1465
if (alternation.Parent is
RegexNode
parent && parent.Kind == RegexNodeKind.Atomic)
1467
var
atomic = new RegexNode(RegexNodeKind.Atomic, startingNodeOptions);
1472
var
newConcat = new RegexNode(RegexNodeKind.Concatenate, startingNodeOptions);
1490
public
RegexNode
? FindBranchOneOrMultiStart()
1492
RegexNode
branch = Kind == RegexNodeKind.Concatenate ? Child(0) : this;
1529
if (Child(i).FindStartingLiteralNode(allowZeroWidth: false) is not
RegexNode
startingLiteralNode ||
1575
public
RegexNode
? FindStartingLiteralNode(bool allowZeroWidth = true)
1577
RegexNode
? node = this;
1615
if (FindStartingLiteralNode() is
RegexNode
node)
1682
private
RegexNode
ReduceConcatenation()
1699
RegexNode
child = Child(i);
1727
Debug.Assert(Children is List<
RegexNode
>);
1733
List<
RegexNode
> children = (List<
RegexNode
>)Children!;
1736
RegexNode
at = children[i];
1746
if (at.Children is List<
RegexNode
> atChildren)
1756
RegexNode
atChild = (
RegexNode
)at.Children!;
1774
RegexNode
prev = children[--j];
1810
Debug.Assert(Children is List<
RegexNode
>);
1812
var children = (List<
RegexNode
>)Children!;
1817
RegexNode
currentNode = children[current];
1818
RegexNode
nextNode = children[next];
2018
Debug.Assert(Children is List<
RegexNode
>);
2019
var children = (List<
RegexNode
>)Children;
2024
static void ProcessNode(
RegexNode
node,
RegexNode
subsequent)
2086
RegexNode
loopChild = node.Child(0);
2120
RegexNode
child = node.Child(0);
2130
RegexNode
child = node.Child(0);
2161
private
RegexNode
ReduceLookaround()
2180
static bool RemoveCaptures(
RegexNode
parent, int nodeIndex)
2182
RegexNode
node = parent.Child(nodeIndex);
2212
RegexNode
child = Child(0);
2251
private static bool? ContainsKind(
RegexNode
node, ReadOnlySpan<RegexNodeKind> kinds)
2281
private
RegexNode
ReduceBackreferenceConditional()
2299
private
RegexNode
ReduceExpressionConditional()
2318
RegexNode
condition = Child(0);
2337
private static bool CanBeMadeAtomic(
RegexNode
node,
RegexNode
subsequent, bool iterateNullableSubsequent, bool allowLazy)
2502
RegexNode
loopChild = node.Child(0);
2557
RegexNode
? parent = subsequent.Parent;
2567
var peers = (List<
RegexNode
>)parent.Children!;
2614
private static bool MayContainBacktracking(
RegexNode
node)
2650
RegexNode
node = this;
2657
node.Parent is not
RegexNode
parent)
2671
var peers = (List<
RegexNode
>)parent.Children!;
2971
RegexNode
child = Child(i);
3063
static bool CanJoinLengthCheck(
RegexNode
node) => node.Kind switch
3074
RegexNode
child = Child(childIndex);
3102
public
RegexNode
MakeQuantifier(bool lazy, int min, int max)
3139
var
result = new RegexNode(lazy ? RegexNodeKind.Lazyloop : RegexNodeKind.Loop, Options, min, max);
3145
public void AddChild(
RegexNode
newChild)
3155
else if (Children is
RegexNode
currentChild)
3157
Children = new List<
RegexNode
>() { currentChild, newChild };
3161
((List<
RegexNode
>)Children).Add(newChild);
3165
public void InsertChild(int index,
RegexNode
newChild)
3167
Debug.Assert(Children is List<
RegexNode
>);
3173
((List<
RegexNode
>)Children).Insert(index, newChild);
3176
public void ReplaceChild(int index,
RegexNode
newChild)
3185
if (Children is
RegexNode
)
3191
((List<
RegexNode
>)Children)[index] = newChild;
3195
public
RegexNode
Child(int i) => Children is
RegexNode
child ? child : ((List<
RegexNode
>)Children!)[i];
3204
if (Children is List<
RegexNode
> children)
3209
Debug.Assert(Children is
RegexNode
);
3240
static bool ExceedsMaxDepthAllowedDepth(
RegexNode
node, int allowedDepth)
3274
RegexNode
? curNode = this;
src\libraries\System.Text.RegularExpressions\src\System\Text\RegularExpressions\RegexNodeKind.cs (42)
6
/// <summary>Specifies the kind of a <see cref="
RegexNode
"/>.</summary>
16
/// <remarks>The character is specified in <see cref="
RegexNode
.Ch"/>.</remarks>
19
/// <remarks>The character is specified in <see cref="
RegexNode
.Ch"/>.</remarks>
22
/// <remarks>The <see cref="RegexCharClass"/> set string is specified in <see cref="
RegexNode
.Str"/>.</remarks>
26
/// <remarks>The characters are specified in <see cref="
RegexNode
.Str"/>. This is purely a representational optimization, equivalent to multiple <see cref="One"/> nodes concatenated together.</remarks>
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>
126
/// <summary>A loop around an arbitrary <see cref="
RegexNode
"/>, e.g. `(ab|cd)*`.</summary>
128
/// One and only one child, the expression in the loop. The minimum number of iterations is in <see cref="
RegexNode
.M"/>,
129
/// and the maximum number of iterations is in <see cref="
RegexNode
.N"/>.
132
/// <summary>A lazy loop around an arbitrary <see cref="
RegexNode
"/>, e.g. `(ab|cd)*?`.</summary>
134
/// One and only one child, the expression in the loop. The minimum number of iterations is in <see cref="
RegexNode
.M"/>,
135
/// and the maximum number of iterations is in <see cref="
RegexNode
.N"/>.
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
142
/// group, <see cref="
RegexNode
.N"/> is the uncapture.
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\RegexParser.cs (23)
24
private
RegexNode
? _stack;
25
private
RegexNode
? _group;
26
private
RegexNode
? _alternation;
27
private
RegexNode
? _concatenation;
28
private
RegexNode
? _unit;
109
RegexNode
root = parser.ScanRegex();
144
RegexNode
root = parser.ScanReplacement();
270
private
RegexNode
ScanRegex()
332
_unit =
RegexNode
.CreateOneWithCaseConversion(_pattern[endpos - 1], _options, _culture, ref _caseBehavior);
353
if (ScanGroupOpen() is
RegexNode
grouper)
519
private
RegexNode
ScanReplacement()
795
private
RegexNode
? ScanGroupOpen()
1123
private
RegexNode
? ScanBackslash(bool scanOnly)
1188
RegexNode
? result = ScanBasicBackslash(scanOnly);
1198
private
RegexNode
? ScanBasicBackslash(bool scanOnly)
1327
RegexNode
.CreateOneWithCaseConversion(ch, _options, _culture, ref _caseBehavior) :
1332
private
RegexNode
ScanDollar()
1336
return
RegexNode
.CreateOneWithCaseConversion('$', _options, _culture, ref _caseBehavior);
1426
return
RegexNode
.CreateOneWithCaseConversion('$', _options, _culture, ref _caseBehavior);
1459
return
RegexNode
.CreateOneWithCaseConversion('$', _options, _culture, ref _caseBehavior);
2047
_concatenation!.AddChild(
RegexNode
.CreateOneWithCaseConversion(_pattern[pos], isReplacement ? _options & ~RegexOptions.IgnoreCase : _options, _culture, ref _caseBehavior));
2057
_concatenation!.AddChild(
RegexNode
.CreateOneWithCaseConversion(c, _options, _culture, ref _caseBehavior));
2094
private void StartGroup(
RegexNode
openGroup)
src\libraries\System.Text.RegularExpressions\src\System\Text\RegularExpressions\RegexPrefixAnalyzer.cs (25)
21
public static string[]? FindPrefixes(
RegexNode
node, bool ignoreCase)
57
static bool FindPrefixesCore(
RegexNode
node, List<StringBuilder> results, bool ignoreCase)
340
public static string FindPrefix(
RegexNode
node)
348
static bool Process(
RegexNode
node, ref ValueStringBuilder vsb)
483
public static string? FindPrefixOrdinalCaseInsensitive(
RegexNode
node)
511
public static List<RegexFindOptimizations.FixedDistanceSet>? FindFixedDistanceSets(
RegexNode
root, bool thorough)
586
static bool TryFindRawFixedSets(
RegexNode
node, List<RegexFindOptimizations.FixedDistanceSet> results, ref int distance, bool thorough)
906
public static string? FindFirstCharClass(
RegexNode
root) => FindFirstOrLastCharClass(root, findFirst: true);
911
public static string? FindLastCharClass(
RegexNode
root) => FindFirstOrLastCharClass(root, findFirst: false);
913
public static string? FindFirstOrLastCharClass(
RegexNode
root, bool findFirst)
942
static bool? TryFindFirstOrLastCharClass(
RegexNode
node, bool findFirst, ref RegexCharClass? cc)
1127
public static (
RegexNode
LoopNode, (char Char, string? String, StringComparison StringComparison, char[]? Chars) Literal)? FindLiteralFollowingLeadingLoop(
RegexNode
node)
1154
RegexNode
firstChild = node.Child(0);
1166
RegexNode
nextChild = node.Child(1);
1256
public static
RegexNode
? FindLeadingPositiveLookahead(
RegexNode
node)
1258
RegexNode
? positiveLookahead = null;
1263
static bool FindLeadingPositiveLookahead(
RegexNode
node, ref
RegexNode
? positiveLookahead)
1330
public static RegexNodeKind FindLeadingAnchor(
RegexNode
node) =>
1334
public static RegexNodeKind FindTrailingAnchor(
RegexNode
node) =>
1338
private static RegexNodeKind FindLeadingOrTrailingAnchor(
RegexNode
node, bool leading)
1379
RegexNode
? child = null;
1385
RegexNode
tmpChild = node.Child(i);
src\libraries\System.Text.RegularExpressions\src\System\Text\RegularExpressions\RegexTree.cs (4)
11
/// Provides the core data describing a parsed <see cref="
RegexNode
"/> tree, along with necessary
18
/// <summary>The root node of the parsed <see cref="
RegexNode
"/> tree.</summary>
19
public readonly
RegexNode
Root;
43
internal RegexTree(
RegexNode
root, int captureCount, string[]? captureNames, Hashtable? captureNameToNumberMapping, Hashtable? captureNumberSparseMapping, RegexOptions options, CultureInfo? culture)
src\libraries\System.Text.RegularExpressions\src\System\Text\RegularExpressions\RegexTreeAnalyzer.cs (14)
9
/// <summary>Analyzes a <see cref="RegexTree"/> of <see cref="
RegexNode
"/>s to produce data on the tree structure, in particular in support of code generation.</summary>
19
static bool TryAnalyze(
RegexNode
node, AnalysisResults results, bool isAtomicByAncestor, bool isInLoop)
33
(results._inLoops ??= new HashSet<
RegexNode
>()).Add(node);
49
(results._mayBacktrack ??= new HashSet<
RegexNode
>()).Add(node);
81
RegexNode
child = node.Child(i);
131
(results._mayBacktrack ??= new HashSet<
RegexNode
>()).Add(node);
154
internal readonly HashSet<
RegexNode
> _isAtomicByAncestor = new(); // since the root is implicitly atomic, every tree will contain atomic-by-ancestor nodes
156
internal readonly HashSet<
RegexNode
> _containsCapture = new(); // the root is a capture, so this will always contain at least the root node
158
internal HashSet<
RegexNode
>? _mayBacktrack;
160
internal HashSet<
RegexNode
>? _inLoops;
179
public bool IsAtomicByAncestor(
RegexNode
node) => _isAtomicByAncestor.Contains(node);
187
public bool MayContainCapture(
RegexNode
node) => !_complete || _containsCapture.Contains(node);
200
public bool MayBacktrack(
RegexNode
node) => !_complete || (_mayBacktrack?.Contains(node) ?? false);
220
public bool IsInLoop(
RegexNode
node) => !_complete || (_inLoops?.Contains(node) ?? false);
Stubs.cs (1)
108
public RegexReplacement(string rep,
RegexNode
concat, Hashtable caps) { }