1031 references to RegexNodeKind
System.Text.RegularExpressions (1031)
System\Text\RegularExpressions\RegexCompiler.cs (6)
649
case
RegexNodeKind
.Bol:
728
case
RegexNodeKind
.End or
RegexNodeKind
.EndZ when _regexTree.FindOptimizations.MaxPossibleLength is int maxLength:
1249
Debug.Assert(target.LoopNode.Kind is
RegexNodeKind
.Setloop or
RegexNodeKind
.Setlazy or
RegexNodeKind
.Setloopatomic);
System\Text\RegularExpressions\RegexFindOptimizations.cs (23)
27
if (_rightToLeft && LeadingAnchor ==
RegexNodeKind
.Bol)
30
LeadingAnchor =
RegexNodeKind
.Unknown;
32
if (LeadingAnchor is
RegexNodeKind
.Beginning or
RegexNodeKind
.Start or
RegexNodeKind
.EndZ or
RegexNodeKind
.End)
36
(
RegexNodeKind
.Beginning, false) => FindNextStartingPositionMode.LeadingAnchor_LeftToRight_Beginning,
37
(
RegexNodeKind
.Beginning, true) => FindNextStartingPositionMode.LeadingAnchor_RightToLeft_Beginning,
38
(
RegexNodeKind
.Start, false) => FindNextStartingPositionMode.LeadingAnchor_LeftToRight_Start,
39
(
RegexNodeKind
.Start, true) => FindNextStartingPositionMode.LeadingAnchor_RightToLeft_Start,
40
(
RegexNodeKind
.End, false) => FindNextStartingPositionMode.LeadingAnchor_LeftToRight_End,
41
(
RegexNodeKind
.End, true) => FindNextStartingPositionMode.LeadingAnchor_RightToLeft_End,
53
if (TrailingAnchor is
RegexNodeKind
.End or
RegexNodeKind
.EndZ &&
60
FindMode = TrailingAnchor ==
RegexNodeKind
.End ?
250
LeadingAnchor ==
RegexNodeKind
.Bol; // there's a leading BOL anchor we can otherwise search for
256
public
RegexNodeKind
LeadingAnchor { get; }
259
public
RegexNodeKind
TrailingAnchor { get; }
379
Debug.Assert(LeadingAnchor !=
RegexNodeKind
.Bol, "BOL isn't enabled for RTL");
505
if (LeadingAnchor ==
RegexNodeKind
.Bol)
792
Debug.Assert(loopNode.Kind is
RegexNodeKind
.Setloop or
RegexNodeKind
.Setlazy or
RegexNodeKind
.Setloopatomic);
System\Text\RegularExpressions\RegexNode.cs (611)
23
public
RegexNodeKind
Kind { get; private set; }
26
/// <remarks>For a <see cref="
RegexNodeKind
.Multi"/>, this is the string from the expression. For an <see cref="IsSetFamily"/> node, this is the character class string from <see cref="RegexCharClass"/>.</remarks>
51
public RegexNode(
RegexNodeKind
kind, RegexOptions options)
57
public RegexNode(
RegexNodeKind
kind, RegexOptions options, char ch)
64
public RegexNode(
RegexNodeKind
kind, RegexOptions options, string str)
71
public RegexNode(
RegexNodeKind
kind, RegexOptions options, int m)
78
public RegexNode(
RegexNodeKind
kind, RegexOptions options, int m, int n)
89
Debug.Assert(Kind is
RegexNodeKind
.Onelazy or
RegexNodeKind
.Oneloop or
RegexNodeKind
.Oneloopatomic or
90
RegexNodeKind
.Notonelazy or
RegexNodeKind
.Notoneloop or
RegexNodeKind
.Notoneloopatomic or
91
RegexNodeKind
.Setlazy or
RegexNodeKind
.Setloop or
RegexNodeKind
.Setloopatomic);
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);
138
Kind ==
RegexNodeKind
.Concatenate &&
150
private void MakeRep(
RegexNodeKind
kind, int min, int max)
152
Kind += kind -
RegexNodeKind
.One;
161
case
RegexNodeKind
.Oneloop or
RegexNodeKind
.Notoneloop or
RegexNodeKind
.Setloop:
164
Kind +=
RegexNodeKind
.Oneloopatomic -
RegexNodeKind
.Oneloop;
167
case
RegexNodeKind
.Onelazy or
RegexNodeKind
.Notonelazy or
RegexNodeKind
.Setlazy:
171
Kind +=
RegexNodeKind
.Oneloopatomic -
RegexNodeKind
.Onelazy;
177
Kind =
RegexNodeKind
.Empty;
181
else if (Kind ==
RegexNodeKind
.Oneloopatomic && N is >= 2 and <= MultiVsRepeaterLimit)
185
Kind =
RegexNodeKind
.Multi;
203
Debug.Assert(Kind ==
RegexNodeKind
.Capture, "Every generated tree should begin with a capture node");
222
Debug.Assert(Kind !=
RegexNodeKind
.Group, "All Group nodes should have been removed.");
227
case
RegexNodeKind
.Group:
231
case
RegexNodeKind
.Beginning:
232
case
RegexNodeKind
.Bol:
233
case
RegexNodeKind
.Boundary:
234
case
RegexNodeKind
.ECMABoundary:
235
case
RegexNodeKind
.Empty:
236
case
RegexNodeKind
.End:
237
case
RegexNodeKind
.EndZ:
238
case
RegexNodeKind
.Eol:
239
case
RegexNodeKind
.Multi:
240
case
RegexNodeKind
.NonBoundary:
241
case
RegexNodeKind
.NonECMABoundary:
242
case
RegexNodeKind
.Nothing:
243
case
RegexNodeKind
.Notone:
244
case
RegexNodeKind
.Notonelazy:
245
case
RegexNodeKind
.Notoneloop:
246
case
RegexNodeKind
.Notoneloopatomic:
247
case
RegexNodeKind
.One:
248
case
RegexNodeKind
.Onelazy:
249
case
RegexNodeKind
.Oneloop:
250
case
RegexNodeKind
.Oneloopatomic:
251
case
RegexNodeKind
.Backreference:
252
case
RegexNodeKind
.Set:
253
case
RegexNodeKind
.Setlazy:
254
case
RegexNodeKind
.Setloop:
255
case
RegexNodeKind
.Setloopatomic:
256
case
RegexNodeKind
.Start:
257
case
RegexNodeKind
.UpdateBumpalong:
261
case
RegexNodeKind
.Atomic:
262
case
RegexNodeKind
.Capture:
263
case
RegexNodeKind
.Lazyloop:
264
case
RegexNodeKind
.Loop:
265
case
RegexNodeKind
.NegativeLookaround:
266
case
RegexNodeKind
.PositiveLookaround:
270
case
RegexNodeKind
.BackreferenceConditional:
274
case
RegexNodeKind
.ExpressionConditional:
278
case
RegexNodeKind
.Concatenate:
279
case
RegexNodeKind
.Alternate:
291
case
RegexNodeKind
.Multi:
296
case
RegexNodeKind
.Set:
297
case
RegexNodeKind
.Setloop:
298
case
RegexNodeKind
.Setloopatomic:
299
case
RegexNodeKind
.Setlazy:
311
case
RegexNodeKind
.Backreference:
332
Debug.Assert(rootNode.Kind ==
RegexNodeKind
.Capture);
375
case
RegexNodeKind
.Atomic:
379
case
RegexNodeKind
.Concatenate:
384
case
RegexNodeKind
.Oneloop or
RegexNodeKind
.Oneloopatomic or
RegexNodeKind
.Notoneloop or
RegexNodeKind
.Notoneloopatomic or
RegexNodeKind
.Setloop or
RegexNodeKind
.Setloopatomic when node.N == int.MaxValue:
385
case
RegexNodeKind
.Onelazy or
RegexNodeKind
.Notonelazy or
RegexNodeKind
.Setlazy when node.N == int.MaxValue && !atomicByAncestry:
386
if (node.Parent is { Kind:
RegexNodeKind
.Concatenate } parent)
388
parent.InsertChild(1, new RegexNode(
RegexNodeKind
.UpdateBumpalong, node.Options));
431
case
RegexNodeKind
.Oneloop or
RegexNodeKind
.Notoneloop or
RegexNodeKind
.Setloop:
432
case
RegexNodeKind
.Onelazy or
RegexNodeKind
.Notonelazy or
RegexNodeKind
.Setlazy:
438
case
RegexNodeKind
.Atomic:
439
case
RegexNodeKind
.PositiveLookaround:
440
case
RegexNodeKind
.NegativeLookaround:
450
case
RegexNodeKind
.Capture:
451
case
RegexNodeKind
.Concatenate:
453
if ((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
456
var atomic = new RegexNode(
RegexNodeKind
.Atomic, existingChild.Options);
466
case
RegexNodeKind
.Alternate:
467
case
RegexNodeKind
.BackreferenceConditional:
468
case
RegexNodeKind
.ExpressionConditional:
476
if (node.Kind !=
RegexNodeKind
.ExpressionConditional) // ReduceExpressionConditional will have already applied ending backtracking removal
491
case
RegexNodeKind
.Lazyloop:
493
goto case
RegexNodeKind
.Loop;
494
case
RegexNodeKind
.Loop:
532
case
RegexNodeKind
.Backreference:
539
RegexNodeKind
.Alternate => ReduceAlternation(),
540
RegexNodeKind
.Atomic => ReduceAtomic(),
541
RegexNodeKind
.Concatenate => ReduceConcatenation(),
542
RegexNodeKind
.Group => ReduceGroup(),
543
RegexNodeKind
.Loop or
RegexNodeKind
.Lazyloop => ReduceLoops(),
544
RegexNodeKind
.PositiveLookaround or
RegexNodeKind
.NegativeLookaround => ReduceLookaround(),
545
RegexNodeKind
.Set or
RegexNodeKind
.Setloop or
RegexNodeKind
.Setloopatomic or
RegexNodeKind
.Setlazy => ReduceSet(),
546
RegexNodeKind
.ExpressionConditional => ReduceExpressionConditional(),
547
RegexNodeKind
.BackreferenceConditional => ReduceBackreferenceConditional(),
560
Debug.Assert(Kind is
RegexNodeKind
.Alternate or
RegexNodeKind
.Concatenate);
563
0 => new RegexNode(Kind ==
RegexNodeKind
.Alternate ?
RegexNodeKind
.Nothing :
RegexNodeKind
.Empty, Options),
577
Debug.Assert(Kind ==
RegexNodeKind
.Group);
580
while (u.Kind ==
RegexNodeKind
.Group)
605
Debug.Assert(Kind ==
RegexNodeKind
.Atomic);
610
while (child.Kind ==
RegexNodeKind
.Atomic)
620
case
RegexNodeKind
.Empty:
621
case
RegexNodeKind
.Nothing:
625
case
RegexNodeKind
.Oneloopatomic:
626
case
RegexNodeKind
.Notoneloopatomic:
627
case
RegexNodeKind
.Setloopatomic:
632
case
RegexNodeKind
.Oneloop:
633
case
RegexNodeKind
.Notoneloop:
634
case
RegexNodeKind
.Setloop:
635
case
RegexNodeKind
.Onelazy:
636
case
RegexNodeKind
.Notonelazy:
637
case
RegexNodeKind
.Setlazy:
643
case
RegexNodeKind
.Alternate:
652
if (branches[0].Kind ==
RegexNodeKind
.Empty)
654
return new RegexNode(
RegexNodeKind
.Empty, child.Options);
663
if (branches[i].Kind ==
RegexNodeKind
.Empty)
767
Debug.Assert(Kind is
RegexNodeKind
.Loop or
RegexNodeKind
.Lazyloop);
770
RegexNodeKind
kind = Kind;
783
if (kind ==
RegexNodeKind
.Loop)
787
case
RegexNodeKind
.Oneloop:
788
case
RegexNodeKind
.Oneloopatomic:
789
case
RegexNodeKind
.Notoneloop:
790
case
RegexNodeKind
.Notoneloopatomic:
791
case
RegexNodeKind
.Setloop:
792
case
RegexNodeKind
.Setloopatomic:
801
case
RegexNodeKind
.Onelazy:
802
case
RegexNodeKind
.Notonelazy:
803
case
RegexNodeKind
.Setlazy:
837
return new RegexNode(
RegexNodeKind
.Nothing, Options);
849
case
RegexNodeKind
.One:
850
case
RegexNodeKind
.Notone:
851
case
RegexNodeKind
.Set:
852
child.MakeRep(u.Kind ==
RegexNodeKind
.Lazyloop ?
RegexNodeKind
.Onelazy :
RegexNodeKind
.Oneloop, u.M, u.N);
876
Debug.Assert(Kind is
RegexNodeKind
.Set or
RegexNodeKind
.Setloop or
RegexNodeKind
.Setloopatomic or
RegexNodeKind
.Setlazy);
881
Kind =
RegexNodeKind
.Nothing;
889
Kind ==
RegexNodeKind
.Set ?
RegexNodeKind
.One :
890
Kind ==
RegexNodeKind
.Setloop ?
RegexNodeKind
.Oneloop :
891
Kind ==
RegexNodeKind
.Setloopatomic ?
RegexNodeKind
.Oneloopatomic :
892
RegexNodeKind
.Onelazy;
899
Kind ==
RegexNodeKind
.Set ?
RegexNodeKind
.Notone :
900
Kind ==
RegexNodeKind
.Setloop ?
RegexNodeKind
.Notoneloop :
901
Kind ==
RegexNodeKind
.Setloopatomic ?
RegexNodeKind
.Notoneloopatomic :
902
RegexNodeKind
.Notonelazy;
925
Debug.Assert(Kind ==
RegexNodeKind
.Alternate);
930
return new RegexNode(
RegexNodeKind
.Nothing, Options);
938
if (node.Kind ==
RegexNodeKind
.Alternate)
941
if (node.Kind ==
RegexNodeKind
.Alternate)
944
if (node.Kind ==
RegexNodeKind
.Alternate)
979
if (at.Kind ==
RegexNodeKind
.Alternate)
997
else if (at.Kind is
RegexNodeKind
.Set or
RegexNodeKind
.One)
1002
if (at.Kind ==
RegexNodeKind
.Set)
1026
if (prev.Kind ==
RegexNodeKind
.One)
1036
if (at.Kind ==
RegexNodeKind
.One)
1046
prev.Kind =
RegexNodeKind
.Set;
1053
else if (at.Kind ==
RegexNodeKind
.Nothing)
1077
Debug.Assert(alternation.Kind ==
RegexNodeKind
.Alternate);
1090
if (child.Kind !=
RegexNodeKind
.Concatenate || child.ChildCount() < 2)
1107
case
RegexNodeKind
.One or
RegexNodeKind
.Notone or
RegexNodeKind
.Set:
1108
case
RegexNodeKind
.Oneloopatomic or
RegexNodeKind
.Notoneloopatomic or
RegexNodeKind
.Setloopatomic:
1109
case
RegexNodeKind
.Oneloop or
RegexNodeKind
.Notoneloop or
RegexNodeKind
.Setloop or
RegexNodeKind
.Onelazy or
RegexNodeKind
.Notonelazy or
RegexNodeKind
.Setlazy when required.M == required.N:
1139
var newAlternate = new RegexNode(
RegexNodeKind
.Alternate, alternation.Options);
1147
if (alternation.Parent is RegexNode { Kind:
RegexNodeKind
.Atomic })
1149
var atomic = new RegexNode(
RegexNodeKind
.Atomic, alternation.Options);
1156
var newConcat = new RegexNode(
RegexNodeKind
.Concatenate, alternation.Options);
1172
Debug.Assert(node.Kind ==
RegexNodeKind
.Alternate);
1183
case
RegexNodeKind
.Empty when !seenEmpty:
1187
case
RegexNodeKind
.Empty:
1188
case
RegexNodeKind
.Nothing:
1215
Debug.Assert(alternation.Kind ==
RegexNodeKind
.Alternate);
1242
if (startingNode.Kind ==
RegexNodeKind
.One)
1262
if (startingNode.Kind ==
RegexNodeKind
.One)
1276
Debug.Assert(startingNode.Kind ==
RegexNodeKind
.Multi);
1307
new RegexNode(
RegexNodeKind
.One, startingNodeOptions, startingSpan[0]) :
1308
new RegexNode(
RegexNodeKind
.Multi, startingNodeOptions, startingSpan.ToString());
1309
var newAlternate = new RegexNode(
RegexNodeKind
.Alternate, startingNodeOptions);
1313
ProcessOneOrMulti(branch.Kind ==
RegexNodeKind
.Concatenate ? branch.Child(0) : branch, startingSpan);
1321
if (node.Kind ==
RegexNodeKind
.One)
1325
node.Kind =
RegexNodeKind
.Empty;
1330
Debug.Assert(node.Kind ==
RegexNodeKind
.Multi);
1334
node.Kind =
RegexNodeKind
.Empty;
1339
node.Kind =
RegexNodeKind
.One;
1351
if (alternation.Parent is RegexNode parent && parent.Kind ==
RegexNodeKind
.Atomic)
1353
var atomic = new RegexNode(
RegexNodeKind
.Atomic, startingNodeOptions);
1358
var newConcat = new RegexNode(
RegexNodeKind
.Concatenate, startingNodeOptions);
1378
RegexNode branch = Kind ==
RegexNodeKind
.Concatenate ? Child(0) : this;
1379
return branch.Kind is
RegexNodeKind
.One or
RegexNodeKind
.Multi ? branch : null;
1385
Debug.Assert(Kind is
RegexNodeKind
.One or
RegexNodeKind
.Multi || (IsOneFamily && M > 0));
1400
case
RegexNodeKind
.One:
1401
case
RegexNodeKind
.Oneloop or
RegexNodeKind
.Oneloopatomic or
RegexNodeKind
.Onelazy when node.M > 0:
1402
case
RegexNodeKind
.Notone:
1403
case
RegexNodeKind
.Notoneloop or
RegexNodeKind
.Notoneloopatomic or
RegexNodeKind
.Notonelazy when node.M > 0:
1404
case
RegexNodeKind
.Set:
1405
case
RegexNodeKind
.Setloop or
RegexNodeKind
.Setloopatomic or
RegexNodeKind
.Setlazy when node.M > 0:
1406
case
RegexNodeKind
.Multi:
1409
case
RegexNodeKind
.Atomic:
1410
case
RegexNodeKind
.Concatenate:
1411
case
RegexNodeKind
.Capture:
1412
case
RegexNodeKind
.Group:
1413
case
RegexNodeKind
.Loop or
RegexNodeKind
.Lazyloop when node.M > 0:
1414
case
RegexNodeKind
.PositiveLookaround when allowZeroWidth:
1435
case
RegexNodeKind
.One or
RegexNodeKind
.Oneloop or
RegexNodeKind
.Oneloopatomic or
RegexNodeKind
.Onelazy:
1438
case
RegexNodeKind
.Notone or
RegexNodeKind
.Notoneloop or
RegexNodeKind
.Notoneloopatomic or
RegexNodeKind
.Notonelazy:
1441
case
RegexNodeKind
.Set or
RegexNodeKind
.Setloop or
RegexNodeKind
.Setloopatomic or
RegexNodeKind
.Setlazy:
1457
case
RegexNodeKind
.Multi:
1500
Debug.Assert(Kind ==
RegexNodeKind
.Concatenate);
1506
return new RegexNode(
RegexNodeKind
.Empty, Options);
1516
if (child.Kind ==
RegexNodeKind
.Nothing)
1542
Debug.Assert(Kind ==
RegexNodeKind
.Concatenate);
1559
if (at.Kind ==
RegexNodeKind
.Concatenate &&
1578
else if (at.Kind is
RegexNodeKind
.Multi or
RegexNodeKind
.One)
1592
if (prev.Kind ==
RegexNodeKind
.One)
1594
prev.Kind =
RegexNodeKind
.Multi;
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);
1602
else if (at.Kind ==
RegexNodeKind
.Empty)
1625
Debug.Assert(Kind ==
RegexNodeKind
.Concatenate);
1663
case
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:
1664
case
RegexNodeKind
.Setloop or
RegexNodeKind
.Setloopatomic or
RegexNodeKind
.Setlazy when nextNode.Kind == currentNode.Kind && currentNode.Str == nextNode.Str:
1666
currentNode.Kind is
RegexNodeKind
.Oneloopatomic or
RegexNodeKind
.Notoneloopatomic or
RegexNodeKind
.Setloopatomic)
1689
case
RegexNodeKind
.Oneloop or
RegexNodeKind
.Onelazy when nextNode.Kind ==
RegexNodeKind
.One && currentNode.Ch == nextNode.Ch:
1690
case
RegexNodeKind
.Notoneloop or
RegexNodeKind
.Notonelazy when nextNode.Kind ==
RegexNodeKind
.Notone && currentNode.Ch == nextNode.Ch:
1691
case
RegexNodeKind
.Setloop or
RegexNodeKind
.Setlazy when nextNode.Kind ==
RegexNodeKind
.Set && currentNode.Str == nextNode.Str:
1705
case
RegexNodeKind
.Oneloop or
RegexNodeKind
.Onelazy when
1706
nextNode.Kind ==
RegexNodeKind
.Multi &&
1739
nextNode.Kind =
RegexNodeKind
.One;
1757
case
RegexNodeKind
.One when (nextNode.Kind is
RegexNodeKind
.Oneloop or
RegexNodeKind
.Oneloopatomic or
RegexNodeKind
.Onelazy) && currentNode.Ch == nextNode.Ch:
1758
case
RegexNodeKind
.Notone when (nextNode.Kind is
RegexNodeKind
.Notoneloop or
RegexNodeKind
.Notoneloopatomic or
RegexNodeKind
.Notonelazy) && currentNode.Ch == nextNode.Ch:
1759
case
RegexNodeKind
.Set when (nextNode.Kind is
RegexNodeKind
.Setloop or
RegexNodeKind
.Setloopatomic or
RegexNodeKind
.Setlazy) && currentNode.Str == nextNode.Str:
1772
case
RegexNodeKind
.Notone when nextNode.Kind == currentNode.Kind && currentNode.Ch == nextNode.Ch:
1773
case
RegexNodeKind
.Set when nextNode.Kind ==
RegexNodeKind
.Set && currentNode.Str == nextNode.Str:
1774
currentNode.MakeRep(
RegexNodeKind
.Oneloop, 2, 2);
1823
if (Kind is not
RegexNodeKind
.Concatenate)
1848
if (node.Kind is
RegexNodeKind
.Capture or
RegexNodeKind
.Concatenate)
1858
if (node.Kind ==
RegexNodeKind
.Loop)
1875
case
RegexNodeKind
.Oneloop or
RegexNodeKind
.Notoneloop or
RegexNodeKind
.Setloop when CanBeMadeAtomic(node, subsequent, iterateNullableSubsequent: true, allowLazy: false):
1884
case
RegexNodeKind
.Onelazy or
RegexNodeKind
.Notonelazy or
RegexNodeKind
.Setlazy when CanBeMadeAtomic(node, subsequent, iterateNullableSubsequent: false, allowLazy: true):
1900
node.Kind -=
RegexNodeKind
.Onelazy -
RegexNodeKind
.Oneloop; // lazy to greedy
1904
case
RegexNodeKind
.Alternate or
RegexNodeKind
.BackreferenceConditional or
RegexNodeKind
.ExpressionConditional:
1915
for (int b = node.Kind ==
RegexNodeKind
.ExpressionConditional ? 1 : 0; b < alternateBranches; b++)
1935
Debug.Assert(node.Kind is
RegexNodeKind
.Loop or
RegexNodeKind
.Lazyloop);
1941
while (node.Kind ==
RegexNodeKind
.Capture)
1952
if (node.Kind ==
RegexNodeKind
.Concatenate)
1969
Debug.Assert(Kind is
RegexNodeKind
.PositiveLookaround or
RegexNodeKind
.NegativeLookaround);
1985
if (Child(0).Kind ==
RegexNodeKind
.Empty)
1987
Kind = Kind ==
RegexNodeKind
.PositiveLookaround ?
RegexNodeKind
.Empty :
RegexNodeKind
.Nothing;
1997
Debug.Assert(Kind ==
RegexNodeKind
.BackreferenceConditional);
2006
AddChild(new RegexNode(
RegexNodeKind
.Empty, Options));
2015
Debug.Assert(Kind ==
RegexNodeKind
.ExpressionConditional);
2024
AddChild(new RegexNode(
RegexNodeKind
.Empty, Options));
2033
if (condition.Kind ==
RegexNodeKind
.PositiveLookaround && (condition.Options & RegexOptions.RightToLeft) == 0)
2069
Debug.Assert(subsequent.Kind !=
RegexNodeKind
.Group);
2072
case
RegexNodeKind
.Concatenate:
2073
case
RegexNodeKind
.Capture:
2074
case
RegexNodeKind
.Atomic:
2075
case
RegexNodeKind
.PositiveLookaround when (subsequent.Options & RegexOptions.RightToLeft) == 0: // only lookaheads, not lookbehinds (represented as RTL PositiveLookaround nodes)
2076
case
RegexNodeKind
.Loop or
RegexNodeKind
.Lazyloop when subsequent.M > 0:
2099
case
RegexNodeKind
.Alternate:
2100
case
RegexNodeKind
.ExpressionConditional when childCount == 3: // condition, yes, and no branch
2116
case
RegexNodeKind
.Oneloop:
2117
case
RegexNodeKind
.Onelazy when allowLazy:
2120
case
RegexNodeKind
.One when node.Ch != subsequent.Ch:
2121
case
RegexNodeKind
.Notone when node.Ch == subsequent.Ch:
2122
case
RegexNodeKind
.Set when !RegexCharClass.CharInClass(node.Ch, subsequent.Str!):
2123
case
RegexNodeKind
.Onelazy or
RegexNodeKind
.Oneloop or
RegexNodeKind
.Oneloopatomic when subsequent.M > 0 && node.Ch != subsequent.Ch:
2124
case
RegexNodeKind
.Notonelazy or
RegexNodeKind
.Notoneloop or
RegexNodeKind
.Notoneloopatomic when subsequent.M > 0 && node.Ch == subsequent.Ch:
2125
case
RegexNodeKind
.Setlazy or
RegexNodeKind
.Setloop or
RegexNodeKind
.Setloopatomic when subsequent.M > 0 && !RegexCharClass.CharInClass(node.Ch, subsequent.Str!):
2126
case
RegexNodeKind
.Multi when node.Ch != subsequent.Str![0]:
2127
case
RegexNodeKind
.End:
2128
case
RegexNodeKind
.EndZ or
RegexNodeKind
.Eol when node.Ch != '\n':
2131
case
RegexNodeKind
.Onelazy or
RegexNodeKind
.Oneloop or
RegexNodeKind
.Oneloopatomic when subsequent.M == 0 && node.Ch != subsequent.Ch:
2132
case
RegexNodeKind
.Notonelazy or
RegexNodeKind
.Notoneloop or
RegexNodeKind
.Notoneloopatomic when subsequent.M == 0 && node.Ch == subsequent.Ch:
2133
case
RegexNodeKind
.Setlazy or
RegexNodeKind
.Setloop or
RegexNodeKind
.Setloopatomic when subsequent.M == 0 && !RegexCharClass.CharInClass(node.Ch, subsequent.Str!):
2134
case
RegexNodeKind
.Boundary when node.M > 0 && RegexCharClass.IsBoundaryWordChar(node.Ch):
2135
case
RegexNodeKind
.NonBoundary when node.M > 0 && !RegexCharClass.IsBoundaryWordChar(node.Ch):
2136
case
RegexNodeKind
.ECMABoundary when node.M > 0 && RegexCharClass.IsECMAWordChar(node.Ch):
2137
case
RegexNodeKind
.NonECMABoundary when node.M > 0 && !RegexCharClass.IsECMAWordChar(node.Ch):
2146
case
RegexNodeKind
.Notoneloop:
2147
case
RegexNodeKind
.Notonelazy when allowLazy:
2150
case
RegexNodeKind
.One when node.Ch == subsequent.Ch:
2151
case
RegexNodeKind
.Onelazy or
RegexNodeKind
.Oneloop or
RegexNodeKind
.Oneloopatomic when subsequent.M > 0 && node.Ch == subsequent.Ch:
2152
case
RegexNodeKind
.Multi when node.Ch == subsequent.Str![0]:
2153
case
RegexNodeKind
.End:
2156
case
RegexNodeKind
.Onelazy or
RegexNodeKind
.Oneloop or
RegexNodeKind
.Oneloopatomic when subsequent.M == 0 && node.Ch == subsequent.Ch:
2165
case
RegexNodeKind
.Setloop:
2166
case
RegexNodeKind
.Setlazy when allowLazy:
2169
case
RegexNodeKind
.One when !RegexCharClass.CharInClass(subsequent.Ch, node.Str!):
2170
case
RegexNodeKind
.Set when !RegexCharClass.MayOverlap(node.Str!, subsequent.Str!):
2171
case
RegexNodeKind
.Onelazy or
RegexNodeKind
.Oneloop or
RegexNodeKind
.Oneloopatomic when subsequent.M > 0 && !RegexCharClass.CharInClass(subsequent.Ch, node.Str!):
2172
case
RegexNodeKind
.Setlazy or
RegexNodeKind
.Setloop or
RegexNodeKind
.Setloopatomic when subsequent.M > 0 && !RegexCharClass.MayOverlap(node.Str!, subsequent.Str!):
2173
case
RegexNodeKind
.Multi when !RegexCharClass.CharInClass(subsequent.Str![0], node.Str!):
2174
case
RegexNodeKind
.End:
2175
case
RegexNodeKind
.EndZ or
RegexNodeKind
.Eol when !RegexCharClass.CharInClass('\n', node.Str!):
2178
case
RegexNodeKind
.Onelazy or
RegexNodeKind
.Oneloop or
RegexNodeKind
.Oneloopatomic when subsequent.M == 0 && !RegexCharClass.CharInClass(subsequent.Ch, node.Str!):
2179
case
RegexNodeKind
.Setlazy or
RegexNodeKind
.Setloop or
RegexNodeKind
.Setloopatomic when subsequent.M == 0 && !RegexCharClass.MayOverlap(node.Str!, subsequent.Str!):
2180
case
RegexNodeKind
.Boundary when node.M > 0 && node.Str is RegexCharClass.WordClass or RegexCharClass.DigitClass:
2181
case
RegexNodeKind
.NonBoundary when node.M > 0 && node.Str is RegexCharClass.NotWordClass or RegexCharClass.NotDigitClass:
2182
case
RegexNodeKind
.ECMABoundary when node.M > 0 && node.Str is RegexCharClass.ECMAWordClass or RegexCharClass.ECMADigitClass:
2183
case
RegexNodeKind
.NonECMABoundary when node.M > 0 && node.Str is RegexCharClass.NotECMAWordClass or RegexCharClass.NotDigitClass:
2211
case
RegexNodeKind
.Atomic:
2212
case
RegexNodeKind
.Alternate:
2213
case
RegexNodeKind
.Capture:
2217
case
RegexNodeKind
.Concatenate:
2262
case
RegexNodeKind
.One:
2263
case
RegexNodeKind
.Notone:
2264
case
RegexNodeKind
.Set:
2268
case
RegexNodeKind
.Multi:
2272
case
RegexNodeKind
.Notonelazy:
2273
case
RegexNodeKind
.Notoneloop:
2274
case
RegexNodeKind
.Notoneloopatomic:
2275
case
RegexNodeKind
.Onelazy:
2276
case
RegexNodeKind
.Oneloop:
2277
case
RegexNodeKind
.Oneloopatomic:
2278
case
RegexNodeKind
.Setlazy:
2279
case
RegexNodeKind
.Setloop:
2280
case
RegexNodeKind
.Setloopatomic:
2284
case
RegexNodeKind
.Lazyloop:
2285
case
RegexNodeKind
.Loop:
2289
case
RegexNodeKind
.Alternate:
2302
case
RegexNodeKind
.BackreferenceConditional:
2306
case
RegexNodeKind
.ExpressionConditional:
2310
case
RegexNodeKind
.Concatenate:
2322
case
RegexNodeKind
.Atomic:
2323
case
RegexNodeKind
.Capture:
2324
case
RegexNodeKind
.Group:
2329
case
RegexNodeKind
.Empty:
2330
case
RegexNodeKind
.Nothing:
2331
case
RegexNodeKind
.UpdateBumpalong:
2335
case
RegexNodeKind
.Beginning:
2336
case
RegexNodeKind
.Bol:
2337
case
RegexNodeKind
.Boundary:
2338
case
RegexNodeKind
.ECMABoundary:
2339
case
RegexNodeKind
.End:
2340
case
RegexNodeKind
.EndZ:
2341
case
RegexNodeKind
.Eol:
2342
case
RegexNodeKind
.NonBoundary:
2343
case
RegexNodeKind
.NonECMABoundary:
2344
case
RegexNodeKind
.Start:
2345
case
RegexNodeKind
.NegativeLookaround:
2346
case
RegexNodeKind
.PositiveLookaround:
2348
case
RegexNodeKind
.Backreference:
2356
goto case
RegexNodeKind
.Empty;
2375
case
RegexNodeKind
.One:
2376
case
RegexNodeKind
.Notone:
2377
case
RegexNodeKind
.Set:
2381
case
RegexNodeKind
.Multi:
2385
case
RegexNodeKind
.Notonelazy or
RegexNodeKind
.Notoneloop or
RegexNodeKind
.Notoneloopatomic or
2386
RegexNodeKind
.Onelazy or
RegexNodeKind
.Oneloop or
RegexNodeKind
.Oneloopatomic or
2387
RegexNodeKind
.Setlazy or
RegexNodeKind
.Setloop or
RegexNodeKind
.Setloopatomic:
2391
case
RegexNodeKind
.Loop or
RegexNodeKind
.Lazyloop:
2406
case
RegexNodeKind
.Alternate:
2429
case
RegexNodeKind
.BackreferenceConditional:
2430
case
RegexNodeKind
.ExpressionConditional:
2433
int i = Kind ==
RegexNodeKind
.BackreferenceConditional ? 0 : 1;
2439
case
RegexNodeKind
.Concatenate:
2461
case
RegexNodeKind
.Atomic:
2462
case
RegexNodeKind
.Capture:
2467
case
RegexNodeKind
.Empty:
2468
case
RegexNodeKind
.Nothing:
2469
case
RegexNodeKind
.UpdateBumpalong:
2470
case
RegexNodeKind
.Beginning:
2471
case
RegexNodeKind
.Bol:
2472
case
RegexNodeKind
.Boundary:
2473
case
RegexNodeKind
.ECMABoundary:
2474
case
RegexNodeKind
.End:
2475
case
RegexNodeKind
.EndZ:
2476
case
RegexNodeKind
.Eol:
2477
case
RegexNodeKind
.NonBoundary:
2478
case
RegexNodeKind
.NonECMABoundary:
2479
case
RegexNodeKind
.Start:
2480
case
RegexNodeKind
.PositiveLookaround:
2481
case
RegexNodeKind
.NegativeLookaround:
2485
case
RegexNodeKind
.Backreference:
2493
goto case
RegexNodeKind
.Empty;
2516
Debug.Assert(Kind ==
RegexNodeKind
.Concatenate, $"Expected Concatenate, got {Kind}");
2529
if (child.Kind is
RegexNodeKind
.One)
2542
else if (child.Kind is
RegexNodeKind
.Multi)
2554
else if (child.Kind is
RegexNodeKind
.Set ||
2555
(child.Kind is
RegexNodeKind
.Setloop or
RegexNodeKind
.Setlazy or
RegexNodeKind
.Setloopatomic && child.M == child.N))
2564
vsb.Append((char)(twoChars[0] | 0x20), child.Kind is
RegexNodeKind
.Set ? 1 : child.M);
2566
else if (child.Kind is
RegexNodeKind
.Empty)
2573
child.Kind is
RegexNodeKind
.Beginning or
2574
RegexNodeKind
.Bol or
2575
RegexNodeKind
.Start or
2577
RegexNodeKind
.Boundary or
2578
RegexNodeKind
.ECMABoundary or
2579
RegexNodeKind
.NonBoundary or
2580
RegexNodeKind
.NonECMABoundary or
2582
RegexNodeKind
.NegativeLookaround or
2583
RegexNodeKind
.PositiveLookaround or
2585
RegexNodeKind
.UpdateBumpalong)
2632
Debug.Assert(Kind ==
RegexNodeKind
.Concatenate, $"Expected Concatenate, got {Kind}");
2636
RegexNodeKind
.One or
RegexNodeKind
.Notone or
RegexNodeKind
.Set => true,
2637
RegexNodeKind
.Multi => true,
2638
RegexNodeKind
.Oneloop or
RegexNodeKind
.Onelazy or
RegexNodeKind
.Oneloopatomic or
2639
RegexNodeKind
.Notoneloop or
RegexNodeKind
.Notonelazy or
RegexNodeKind
.Notoneloopatomic or
2640
RegexNodeKind
.Setloop or
RegexNodeKind
.Setlazy or
RegexNodeKind
.Setloopatomic
2682
return new RegexNode(
RegexNodeKind
.Empty, Options);
2688
case <= MultiVsRepeaterLimit when Kind ==
RegexNodeKind
.One:
2694
Kind =
RegexNodeKind
.Multi;
2703
case
RegexNodeKind
.One:
2704
case
RegexNodeKind
.Notone:
2705
case
RegexNodeKind
.Set:
2706
MakeRep(lazy ?
RegexNodeKind
.Onelazy :
RegexNodeKind
.Oneloop, min, max);
2710
var result = new RegexNode(lazy ?
RegexNodeKind
.Lazyloop :
RegexNodeKind
.Loop, Options, min, max);
2833
public bool IsSetFamily => Kind is
RegexNodeKind
.Set or
RegexNodeKind
.Setloop or
RegexNodeKind
.Setloopatomic or
RegexNodeKind
.Setlazy;
2836
public bool IsOneFamily => Kind is
RegexNodeKind
.One or
RegexNodeKind
.Oneloop or
RegexNodeKind
.Oneloopatomic or
RegexNodeKind
.Onelazy;
2839
public bool IsNotoneFamily => Kind is
RegexNodeKind
.Notone or
RegexNodeKind
.Notoneloop or
RegexNodeKind
.Notoneloopatomic or
RegexNodeKind
.Notonelazy;
2890
case
RegexNodeKind
.Oneloop:
2891
case
RegexNodeKind
.Oneloopatomic:
2892
case
RegexNodeKind
.Notoneloop:
2893
case
RegexNodeKind
.Notoneloopatomic:
2894
case
RegexNodeKind
.Onelazy:
2895
case
RegexNodeKind
.Notonelazy:
2896
case
RegexNodeKind
.One:
2897
case
RegexNodeKind
.Notone:
2900
case
RegexNodeKind
.Capture:
2907
case
RegexNodeKind
.Backreference:
2908
case
RegexNodeKind
.BackreferenceConditional:
2911
case
RegexNodeKind
.Multi:
2919
case
RegexNodeKind
.Set:
2920
case
RegexNodeKind
.Setloop:
2921
case
RegexNodeKind
.Setloopatomic:
2922
case
RegexNodeKind
.Setlazy:
2929
case
RegexNodeKind
.Oneloop:
2930
case
RegexNodeKind
.Oneloopatomic:
2931
case
RegexNodeKind
.Notoneloop:
2932
case
RegexNodeKind
.Notoneloopatomic:
2933
case
RegexNodeKind
.Onelazy:
2934
case
RegexNodeKind
.Notonelazy:
2935
case
RegexNodeKind
.Setloop:
2936
case
RegexNodeKind
.Setloopatomic:
2937
case
RegexNodeKind
.Setlazy:
2938
case
RegexNodeKind
.Loop:
2939
case
RegexNodeKind
.Lazyloop:
System\Text\RegularExpressions\RegexParser.cs (60)
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);
759
return new RegexNode(
RegexNodeKind
.Group, _options);
763
return new RegexNode(
RegexNodeKind
.Capture, _options, _autocap++, -1);
776
RegexNodeKind
nodeType;
783
nodeType =
RegexNodeKind
.Group;
789
nodeType =
RegexNodeKind
.PositiveLookaround;
795
nodeType =
RegexNodeKind
.NegativeLookaround;
800
nodeType =
RegexNodeKind
.Atomic;
823
nodeType =
RegexNodeKind
.PositiveLookaround;
834
nodeType =
RegexNodeKind
.NegativeLookaround;
937
return new RegexNode(
RegexNodeKind
.Capture, _options, capnum, uncapnum);
959
return new RegexNode(
RegexNodeKind
.BackreferenceConditional, _options, capnum);
973
return new RegexNode(
RegexNodeKind
.BackreferenceConditional, _options, tmpCapnum);
978
nodeType =
RegexNodeKind
.ExpressionConditional;
1002
nodeType =
RegexNodeKind
.Group;
1004
if (_group!.Kind !=
RegexNodeKind
.ExpressionConditional)
1096
new RegexNode(
RegexNodeKind
.Set, (_options & ~RegexOptions.IgnoreCase), (_options & RegexOptions.ECMAScript) != 0 ? RegexCharClass.ECMAWordClass : RegexCharClass.WordClass);
1101
new RegexNode(
RegexNodeKind
.Set, (_options & ~RegexOptions.IgnoreCase), (_options & RegexOptions.ECMAScript) != 0 ? RegexCharClass.NotECMAWordClass : RegexCharClass.NotWordClass);
1106
new RegexNode(
RegexNodeKind
.Set, (_options & ~RegexOptions.IgnoreCase), (_options & RegexOptions.ECMAScript) != 0 ? RegexCharClass.ECMASpaceClass : RegexCharClass.SpaceClass);
1111
new RegexNode(
RegexNodeKind
.Set, (_options & ~RegexOptions.IgnoreCase), (_options & RegexOptions.ECMAScript) != 0 ? RegexCharClass.NotECMASpaceClass : RegexCharClass.NotSpaceClass);
1116
new RegexNode(
RegexNodeKind
.Set, (_options & ~RegexOptions.IgnoreCase), (_options & RegexOptions.ECMAScript) != 0 ? RegexCharClass.ECMADigitClass : RegexCharClass.DigitClass);
1121
new RegexNode(
RegexNodeKind
.Set, (_options & ~RegexOptions.IgnoreCase), (_options & RegexOptions.ECMAScript) != 0 ? RegexCharClass.NotECMADigitClass : RegexCharClass.NotDigitClass);
1138
return new RegexNode(
RegexNodeKind
.Set, (_options & ~RegexOptions.IgnoreCase), cc.ToStringClass());
1142
if (result != null && result.Kind ==
RegexNodeKind
.Backreference && (result.Options & RegexOptions.IgnoreCase) != 0)
1203
IsCaptureSlot(capnum) ? new RegexNode(
RegexNodeKind
.Backreference, _options, capnum) :
1235
return scanOnly ? null : new RegexNode(
RegexNodeKind
.Backreference, _options, capnum);
1249
return new RegexNode(
RegexNodeKind
.Backreference, _options, capnum);
1269
_capnames?[capname] is int tmpCapnum ? new RegexNode(
RegexNodeKind
.Backreference, _options, tmpCapnum) :
1345
return new RegexNode(
RegexNodeKind
.Backreference, _options, capnum);
1355
return new RegexNode(
RegexNodeKind
.Backreference, _options, capnum);
1367
return new RegexNode(
RegexNodeKind
.Backreference, _options, tmpCapnum);
1405
return new RegexNode(
RegexNodeKind
.Backreference, _options, capnum);
1653
private readonly
RegexNodeKind
TypeFromCode(char ch) =>
1656
'b' => (_options & RegexOptions.ECMAScript) != 0 ?
RegexNodeKind
.ECMABoundary :
RegexNodeKind
.Boundary,
1657
'B' => (_options & RegexOptions.ECMAScript) != 0 ?
RegexNodeKind
.NonECMABoundary :
RegexNodeKind
.NonBoundary,
1658
'A' =>
RegexNodeKind
.Beginning,
1659
'G' =>
RegexNodeKind
.Start,
1660
'Z' =>
RegexNodeKind
.EndZ,
1661
'z' =>
RegexNodeKind
.End,
1662
_ =>
RegexNodeKind
.Nothing,
2022
_concatenation!.AddChild(new RegexNode(
RegexNodeKind
.Multi, _options & ~RegexOptions.IgnoreCase, _pattern.Substring(pos, cch)));
2052
if (_group.Kind ==
RegexNodeKind
.ExpressionConditional && _group.ChildCount() == 0)
2068
_alternation = new RegexNode(
RegexNodeKind
.Alternate, _options);
2069
_concatenation = new RegexNode(
RegexNodeKind
.Concatenate, _options);
2077
if (_group!.Kind is
RegexNodeKind
.ExpressionConditional or
RegexNodeKind
.BackreferenceConditional)
2086
_concatenation = new RegexNode(
RegexNodeKind
.Concatenate, _options);
2092
if (_group!.Kind is
RegexNodeKind
.ExpressionConditional or
RegexNodeKind
.BackreferenceConditional)
2096
if (_group.Kind ==
RegexNodeKind
.BackreferenceConditional && _group.ChildCount() > 2 || _group.ChildCount() > 3)
System\Text\RegularExpressions\RegexPrefixAnalyzer.cs (180)
84
case
RegexNodeKind
.Atomic:
85
case
RegexNodeKind
.Capture:
90
case
RegexNodeKind
.Bol:
91
case
RegexNodeKind
.Eol:
92
case
RegexNodeKind
.Boundary:
93
case
RegexNodeKind
.ECMABoundary:
94
case
RegexNodeKind
.NonBoundary:
95
case
RegexNodeKind
.NonECMABoundary:
96
case
RegexNodeKind
.Beginning:
97
case
RegexNodeKind
.Start:
98
case
RegexNodeKind
.EndZ:
99
case
RegexNodeKind
.End:
100
case
RegexNodeKind
.Empty:
101
case
RegexNodeKind
.UpdateBumpalong:
102
case
RegexNodeKind
.PositiveLookaround:
103
case
RegexNodeKind
.NegativeLookaround:
112
case
RegexNodeKind
.One or
RegexNodeKind
.Oneloop or
RegexNodeKind
.Onelazy or
RegexNodeKind
.Oneloopatomic when !ignoreCase || !RegexCharClass.ParticipatesInCaseConversion(node.Ch):
114
int reps = node.Kind is
RegexNodeKind
.One ? 1 : Math.Min(node.M, MaxPrefixLength);
119
return node.Kind is
RegexNodeKind
.One || reps == node.N;
124
case
RegexNodeKind
.Multi:
156
case
RegexNodeKind
.Set or
RegexNodeKind
.Setloop or
RegexNodeKind
.Setlazy or
RegexNodeKind
.Setloopatomic when !RegexCharClass.IsNegated(node.Str!): // negated sets are too complex to analyze
164
int reps = node.Kind is
RegexNodeKind
.Set ? 1 : Math.Min(node.M, MaxPrefixLength);
209
return node.Kind is
RegexNodeKind
.Set || reps == node.N;
212
case
RegexNodeKind
.Concatenate:
226
case
RegexNodeKind
.Loop or
RegexNodeKind
.Lazyloop when node.M > 0:
242
case
RegexNodeKind
.Alternate:
363
case
RegexNodeKind
.Concatenate:
377
case
RegexNodeKind
.Alternate when !rtl: // for RTL we'd need to be matching the suffixes of the alternation cases
422
case
RegexNodeKind
.One:
427
case
RegexNodeKind
.Multi:
432
case
RegexNodeKind
.Oneloop or
RegexNodeKind
.Oneloopatomic or
RegexNodeKind
.Onelazy when node.M > 0:
439
case
RegexNodeKind
.Loop or
RegexNodeKind
.Lazyloop when node.M > 0:
454
case
RegexNodeKind
.Atomic:
455
case
RegexNodeKind
.Capture:
459
case
RegexNodeKind
.Bol:
460
case
RegexNodeKind
.Eol:
461
case
RegexNodeKind
.Boundary:
462
case
RegexNodeKind
.ECMABoundary:
463
case
RegexNodeKind
.NonBoundary:
464
case
RegexNodeKind
.NonECMABoundary:
465
case
RegexNodeKind
.Beginning:
466
case
RegexNodeKind
.Start:
467
case
RegexNodeKind
.EndZ:
468
case
RegexNodeKind
.End:
469
case
RegexNodeKind
.Empty:
470
case
RegexNodeKind
.UpdateBumpalong:
471
case
RegexNodeKind
.PositiveLookaround:
472
case
RegexNodeKind
.NegativeLookaround:
491
case
RegexNodeKind
.Atomic:
492
case
RegexNodeKind
.Capture:
493
case
RegexNodeKind
.Loop or
RegexNodeKind
.Lazyloop when node.M > 0:
497
case
RegexNodeKind
.Concatenate:
600
case
RegexNodeKind
.One:
609
case
RegexNodeKind
.Onelazy or
RegexNodeKind
.Oneloop or
RegexNodeKind
.Oneloopatomic when node.M > 0:
621
case
RegexNodeKind
.Multi:
633
case
RegexNodeKind
.Set:
641
case
RegexNodeKind
.Setlazy or
RegexNodeKind
.Setloop or
RegexNodeKind
.Setloopatomic when node.M > 0:
652
case
RegexNodeKind
.Notone:
658
case
RegexNodeKind
.Notonelazy or
RegexNodeKind
.Notoneloop or
RegexNodeKind
.Notoneloopatomic when node.M == node.N:
662
case
RegexNodeKind
.Beginning:
663
case
RegexNodeKind
.Bol:
664
case
RegexNodeKind
.Boundary:
665
case
RegexNodeKind
.ECMABoundary:
666
case
RegexNodeKind
.Empty:
667
case
RegexNodeKind
.End:
668
case
RegexNodeKind
.EndZ:
669
case
RegexNodeKind
.Eol:
670
case
RegexNodeKind
.NonBoundary:
671
case
RegexNodeKind
.NonECMABoundary:
672
case
RegexNodeKind
.UpdateBumpalong:
673
case
RegexNodeKind
.Start:
674
case
RegexNodeKind
.NegativeLookaround:
675
case
RegexNodeKind
.PositiveLookaround:
681
case
RegexNodeKind
.Atomic:
682
case
RegexNodeKind
.Group:
683
case
RegexNodeKind
.Capture:
686
case
RegexNodeKind
.Lazyloop or
RegexNodeKind
.Loop when node.M > 0:
696
case
RegexNodeKind
.Concatenate:
709
case
RegexNodeKind
.Alternate when thorough:
945
case
RegexNodeKind
.One or
RegexNodeKind
.Oneloop or
RegexNodeKind
.Onelazy or
RegexNodeKind
.Oneloopatomic:
950
return node.Kind is
RegexNodeKind
.One || node.M > 0 ? true : null;
954
case
RegexNodeKind
.Notone or
RegexNodeKind
.Notoneloop or
RegexNodeKind
.Notoneloopatomic or
RegexNodeKind
.Notonelazy:
968
return node.Kind is
RegexNodeKind
.Notone || node.M > 0 ? true : null;
972
case
RegexNodeKind
.Set or
RegexNodeKind
.Setloop or
RegexNodeKind
.Setlazy or
RegexNodeKind
.Setloopatomic:
987
node.Kind is
RegexNodeKind
.Set || node.M > 0 ? true :
991
case
RegexNodeKind
.Multi:
1002
case
RegexNodeKind
.Empty:
1003
case
RegexNodeKind
.Nothing:
1004
case
RegexNodeKind
.Bol:
1005
case
RegexNodeKind
.Eol:
1006
case
RegexNodeKind
.Boundary:
1007
case
RegexNodeKind
.NonBoundary:
1008
case
RegexNodeKind
.ECMABoundary:
1009
case
RegexNodeKind
.NonECMABoundary:
1010
case
RegexNodeKind
.Beginning:
1011
case
RegexNodeKind
.Start:
1012
case
RegexNodeKind
.EndZ:
1013
case
RegexNodeKind
.End:
1014
case
RegexNodeKind
.UpdateBumpalong:
1015
case
RegexNodeKind
.PositiveLookaround:
1016
case
RegexNodeKind
.NegativeLookaround:
1020
case
RegexNodeKind
.Atomic:
1021
case
RegexNodeKind
.Capture:
1027
case
RegexNodeKind
.Loop:
1028
case
RegexNodeKind
.Lazyloop:
1040
case
RegexNodeKind
.Concatenate:
1057
case
RegexNodeKind
.Alternate:
1078
case
RegexNodeKind
.BackreferenceConditional:
1079
case
RegexNodeKind
.ExpressionConditional:
1080
int branchStart = node.Kind is
RegexNodeKind
.BackreferenceConditional ? 0 : 1;
1089
case
RegexNodeKind
.Backreference:
1114
while (node.Kind is
RegexNodeKind
.Atomic or
RegexNodeKind
.Capture)
1118
if (node.Kind !=
RegexNodeKind
.Concatenate)
1131
while (firstChild.Kind is
RegexNodeKind
.Atomic or
RegexNodeKind
.Capture)
1135
if (firstChild.Kind is not (
RegexNodeKind
.Setloop or
RegexNodeKind
.Setloopatomic or
RegexNodeKind
.Setlazy) || firstChild.N != int.MaxValue)
1143
if (nextChild.Kind ==
RegexNodeKind
.UpdateBumpalong)
1200
while ((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))
1232
public static
RegexNodeKind
FindLeadingAnchor(RegexNode node) =>
1236
public static
RegexNodeKind
FindTrailingAnchor(RegexNode node) =>
1240
private static
RegexNodeKind
FindLeadingOrTrailingAnchor(RegexNode node, bool leading)
1246
return
RegexNodeKind
.Unknown;
1253
case
RegexNodeKind
.Bol:
1254
case
RegexNodeKind
.Eol:
1255
case
RegexNodeKind
.Beginning:
1256
case
RegexNodeKind
.Start:
1257
case
RegexNodeKind
.EndZ:
1258
case
RegexNodeKind
.End:
1259
case
RegexNodeKind
.Boundary:
1260
case
RegexNodeKind
.ECMABoundary:
1264
case
RegexNodeKind
.Atomic:
1265
case
RegexNodeKind
.Capture:
1270
case
RegexNodeKind
.Concatenate:
1281
if (node.Child(i).Kind is not (
RegexNodeKind
.Empty or
RegexNodeKind
.PositiveLookaround or
RegexNodeKind
.NegativeLookaround))
1292
if (node.Child(i).Kind is not (
RegexNodeKind
.Empty or
RegexNodeKind
.PositiveLookaround or
RegexNodeKind
.NegativeLookaround))
1309
case
RegexNodeKind
.Alternate:
1313
RegexNodeKind
anchor = FindLeadingOrTrailingAnchor(node.Child(0), leading);
1314
if (anchor ==
RegexNodeKind
.Unknown)
1316
return
RegexNodeKind
.Unknown;
1326
return
RegexNodeKind
.Unknown;
1336
return
RegexNodeKind
.Unknown;
System\Text\RegularExpressions\RegexReplacement.cs (4)
36
Debug.Assert(concat.Kind ==
RegexNodeKind
.Concatenate, $"Expected Concatenate, got {concat.Kind}");
50
case
RegexNodeKind
.Multi:
54
case
RegexNodeKind
.One:
58
case
RegexNodeKind
.Backreference:
System\Text\RegularExpressions\RegexTreeAnalyzer.cs (25)
49
case
RegexNodeKind
.Alternate:
50
case
RegexNodeKind
.Loop or
RegexNodeKind
.Lazyloop when node.M != node.N:
51
case
RegexNodeKind
.Oneloop or
RegexNodeKind
.Notoneloop or
RegexNodeKind
.Setloop or
RegexNodeKind
.Onelazy or
RegexNodeKind
.Notonelazy or
RegexNodeKind
.Setlazy when node.M != node.N:
63
case
RegexNodeKind
.Atomic:
64
case
RegexNodeKind
.NegativeLookaround:
65
case
RegexNodeKind
.PositiveLookaround:
70
case
RegexNodeKind
.Capture:
75
case
RegexNodeKind
.Loop:
76
case
RegexNodeKind
.Lazyloop:
94
RegexNodeKind
.Atomic or
RegexNodeKind
.NegativeLookaround or
RegexNodeKind
.PositiveLookaround => true,
98
RegexNodeKind
.Alternate or
RegexNodeKind
.BackreferenceConditional or
RegexNodeKind
.ExpressionConditional => true,
101
RegexNodeKind
.Capture => true,
105
RegexNodeKind
.Concatenate => i == childCount - 1,
111
RegexNodeKind
.Loop or
RegexNodeKind
.Lazyloop when node.N == 1 => true,
System\Text\RegularExpressions\RegexWriter.cs (56)
14
private const
RegexNodeKind
BeforeChild = (
RegexNodeKind
)64;
15
private const
RegexNodeKind
AfterChild = (
RegexNodeKind
)128;
201
private void EmitFragment(
RegexNodeKind
nodeType, RegexNode node, int curIndex)
215
case
RegexNodeKind
.Concatenate | BeforeChild:
216
case
RegexNodeKind
.Concatenate | AfterChild:
217
case
RegexNodeKind
.Empty:
220
case
RegexNodeKind
.Alternate | BeforeChild:
228
case
RegexNodeKind
.Alternate | AfterChild:
247
case
RegexNodeKind
.BackreferenceConditional | BeforeChild:
260
case
RegexNodeKind
.BackreferenceConditional | AfterChild:
278
case
RegexNodeKind
.ExpressionConditional | BeforeChild:
290
case
RegexNodeKind
.ExpressionConditional | AfterChild:
311
case
RegexNodeKind
.Loop | BeforeChild:
312
case
RegexNodeKind
.Lazyloop | BeforeChild:
327
case
RegexNodeKind
.Loop | AfterChild:
328
case
RegexNodeKind
.Lazyloop | AfterChild:
331
int Lazy = (nodeType - (
RegexNodeKind
.Loop | AfterChild));
343
case
RegexNodeKind
.Capture | BeforeChild:
347
case
RegexNodeKind
.Capture | AfterChild:
351
case
RegexNodeKind
.PositiveLookaround | BeforeChild:
356
case
RegexNodeKind
.PositiveLookaround | AfterChild:
361
case
RegexNodeKind
.NegativeLookaround | BeforeChild:
367
case
RegexNodeKind
.NegativeLookaround | AfterChild:
373
case
RegexNodeKind
.Atomic | BeforeChild:
377
case
RegexNodeKind
.Atomic | AfterChild:
381
case
RegexNodeKind
.One:
382
case
RegexNodeKind
.Notone:
386
case
RegexNodeKind
.Notoneloop:
387
case
RegexNodeKind
.Notoneloopatomic:
388
case
RegexNodeKind
.Notonelazy:
389
case
RegexNodeKind
.Oneloop:
390
case
RegexNodeKind
.Oneloopatomic:
391
case
RegexNodeKind
.Onelazy:
394
Emit(((node.Kind is
RegexNodeKind
.Oneloop or
RegexNodeKind
.Oneloopatomic or
RegexNodeKind
.Onelazy) ?
403
case
RegexNodeKind
.Setloop:
404
case
RegexNodeKind
.Setloopatomic:
405
case
RegexNodeKind
.Setlazy:
419
case
RegexNodeKind
.Multi:
423
case
RegexNodeKind
.Set:
427
case
RegexNodeKind
.Backreference:
431
case
RegexNodeKind
.Nothing:
432
case
RegexNodeKind
.Bol:
433
case
RegexNodeKind
.Eol:
434
case
RegexNodeKind
.Boundary:
435
case
RegexNodeKind
.NonBoundary:
436
case
RegexNodeKind
.ECMABoundary:
437
case
RegexNodeKind
.NonECMABoundary:
438
case
RegexNodeKind
.Beginning:
439
case
RegexNodeKind
.Start:
440
case
RegexNodeKind
.EndZ:
441
case
RegexNodeKind
.End:
442
case
RegexNodeKind
.UpdateBumpalong:
System\Text\RegularExpressions\Symbolic\RegexNodeConverter.cs (49)
57
case
RegexNodeKind
.One:
61
case
RegexNodeKind
.Notone:
65
case
RegexNodeKind
.Set:
69
case
RegexNodeKind
.Multi:
84
case
RegexNodeKind
.Concatenate:
85
case
RegexNodeKind
.Alternate:
86
case
RegexNodeKind
.Loop:
87
case
RegexNodeKind
.Lazyloop:
88
case
RegexNodeKind
.Capture when node.N == -1: // N == -1 because balancing groups (which have N >= 0) aren't supported
106
case
RegexNodeKind
.Oneloop:
107
case
RegexNodeKind
.Onelazy:
108
case
RegexNodeKind
.Notoneloop:
109
case
RegexNodeKind
.Notonelazy:
117
result.AddLast(_builder.CreateLoop(_builder.CreateSingleton(bdd), node.Kind is
RegexNodeKind
.Onelazy or
RegexNodeKind
.Notonelazy, node.M, node.N));
121
case
RegexNodeKind
.Setloop:
122
case
RegexNodeKind
.Setlazy:
128
result.AddLast(_builder.CreateLoop(_builder.CreateSingleton(setBdd), node.Kind ==
RegexNodeKind
.Setlazy, node.M, node.N));
132
case
RegexNodeKind
.Empty:
133
case
RegexNodeKind
.UpdateBumpalong: // UpdateBumpalong is a directive relevant only to backtracking and can be ignored just like Empty
136
case
RegexNodeKind
.Nothing:
142
case
RegexNodeKind
.Beginning:
146
case
RegexNodeKind
.Bol:
151
case
RegexNodeKind
.End: // \z anchor
155
case
RegexNodeKind
.EndZ: // \Z anchor
160
case
RegexNodeKind
.Eol:
165
case
RegexNodeKind
.Boundary:
170
case
RegexNodeKind
.NonBoundary:
180
RegexNodeKind
.Atomic or
RegexNodeKind
.Setloopatomic or
RegexNodeKind
.Oneloopatomic or
RegexNodeKind
.Notoneloopatomic => SR.ExpressionDescription_AtomicSubexpressions,
181
RegexNodeKind
.Backreference => SR.ExpressionDescription_Backreference,
182
RegexNodeKind
.BackreferenceConditional => SR.ExpressionDescription_Conditional,
183
RegexNodeKind
.Capture => SR.ExpressionDescription_BalancingGroup,
184
RegexNodeKind
.ExpressionConditional => SR.ExpressionDescription_IfThenElse,
185
RegexNodeKind
.NegativeLookaround => SR.ExpressionDescription_NegativeLookaround,
186
RegexNodeKind
.PositiveLookaround => SR.ExpressionDescription_PositiveLookaround,
187
RegexNodeKind
.Start => SR.ExpressionDescription_ContiguousMatches,
195
string description = $"Unexpected ({nameof(
RegexNodeKind
)}: {node.Kind})";
211
case
RegexNodeKind
.Concatenate:
221
case
RegexNodeKind
.Alternate:
250
case
RegexNodeKind
.Loop:
251
case
RegexNodeKind
.Lazyloop:
260
result.AddLast(_builder.CreateLoop(body, node.Kind ==
RegexNodeKind
.Lazyloop, node.M, node.N));
267
Debug.Assert(node.Kind ==
RegexNodeKind
.Capture && node.N == -1);
285
Debug.Assert(rootResult.Count == 1 || root.Kind ==
RegexNodeKind
.Concatenate || root.Kind ==
RegexNodeKind
.Capture);
312
Debug.Assert(node.Kind ==
RegexNodeKind
.Set);
System\Text\RegularExpressions\Symbolic\SymbolicRegexKind.cs (16)
9
/// <summary>An empty node that matches a zero-width input (e.g. <see cref="
RegexNodeKind
.Empty"/>).</summary>
11
/// <summary>A node that matches a single character (i.e. <see cref="
RegexNodeKind
.One"/>, <see cref="
RegexNodeKind
.Notone"/>, or <see cref="
RegexNodeKind
.Set"/>).</summary>
13
/// <summary>A node that matches a sequence of nodes (i.e. <see cref="
RegexNodeKind
.Concatenate"/>).</summary>
15
/// <summary>A node that matches a loop (e.g. <see cref="
RegexNodeKind
.Loop"/>, <see cref="
RegexNodeKind
.Lazyloop"/>, <see cref="
RegexNodeKind
.Setloop"/>, etc.).</summary>
17
/// <summary>A node that matches if any of its nodes match and that matches them in a fixed order that mirrors how the backtracking engines operate (e.g. <see cref="
RegexNodeKind
.Alternate"/>).</summary>
20
/// <summary>A node that represents a beginning anchor (i.e. <see cref="
RegexNodeKind
.Beginning"/>).</summary>
22
/// <summary>A node that represents an ending anchor (i.e. <see cref="
RegexNodeKind
.End"/>).</summary>
24
/// <summary>A node that represents an ending \Z anchor (i.e. <see cref="
RegexNodeKind
.EndZ"/>).</summary>
28
/// <summary>A node that represents a beginning-of-line anchor (i.e. <see cref="
RegexNodeKind
.Bol"/>).</summary>
30
/// <summary>A node that represents a end-of-line anchor (i.e. <see cref="
RegexNodeKind
.Eol"/>).</summary>
32
/// <summary>A node that represents a word boundary anchor (i.e. <see cref="
RegexNodeKind
.Boundary"/>).</summary>
34
/// <summary>A node that represents a word non-boundary anchor (i.e. <see cref="
RegexNodeKind
.NonBoundary"/>).</summary>
System\Text\RegularExpressions\Symbolic\SymbolicRegexMatcher.cs (1)
211
findOptimizations.LeadingAnchor is not
RegexNodeKind
.Beginning)