Skip to content

Commit 406d854

Browse files
authored
Clean up NonBacktracking DgmlWriter (#66363)
* Clean up NonBacktracking DgmlWriter * Address PR feedback, clean up some lang=regex usage, fix a test failure
1 parent f63e4d9 commit 406d854

File tree

14 files changed

+381
-607
lines changed

14 files changed

+381
-607
lines changed

src/libraries/System.Text.RegularExpressions/src/System.Text.RegularExpressions.csproj

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
<Compile Include="System\Text\RegularExpressions\Symbolic\CharKind.cs" />
6464
<Compile Include="System\Text\RegularExpressions\Symbolic\CharSetSolver.cs" />
6565
<Compile Include="System\Text\RegularExpressions\Symbolic\DerivativeEffect.cs" />
66+
<Compile Include="System\Text\RegularExpressions\Symbolic\DgmlWriter.cs" />
6667
<Compile Include="System\Text\RegularExpressions\Symbolic\DfaMatchingState.cs" />
6768
<Compile Include="System\Text\RegularExpressions\Symbolic\IBooleanAlgebra.cs" />
6869
<Compile Include="System\Text\RegularExpressions\Symbolic\ICharAlgebra.cs" />
@@ -82,10 +83,6 @@
8283
<Compile Include="System\Text\RegularExpressions\Symbolic\SymbolicRegexSet.cs" />
8384
<Compile Include="System\Text\RegularExpressions\Symbolic\TransitionRegex.cs" />
8485
<Compile Include="System\Text\RegularExpressions\Symbolic\TransitionRegexKind.cs" />
85-
<Compile Include="System\Text\RegularExpressions\Symbolic\Dgml\DgmlWriter.cs" />
86-
<Compile Include="System\Text\RegularExpressions\Symbolic\Dgml\IAutomaton.cs" />
87-
<Compile Include="System\Text\RegularExpressions\Symbolic\Dgml\Move.cs" />
88-
<Compile Include="System\Text\RegularExpressions\Symbolic\Dgml\RegexAutomaton.cs" />
8986
<Compile Include="System\Text\RegularExpressions\Symbolic\Unicode\GeneratorHelper.cs" />
9087
<Compile Include="System\Text\RegularExpressions\Symbolic\Unicode\IgnoreCaseRelation.cs" />
9188
<Compile Include="System\Text\RegularExpressions\Symbolic\Unicode\IgnoreCaseRelationGenerator.cs" />

src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/Regex.Debug.cs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,21 @@ internal static bool EnableDebugTracing
2626
}
2727

2828
/// <summary>Unwind the regex and save the resulting state graph in DGML</summary>
29-
/// <param name="bound">roughly the maximum number of states, 0 means no bound</param>
30-
/// <param name="hideStateInfo">if true then hide state info</param>
31-
/// <param name="addDotStar">if true then pretend that there is a .* at the beginning</param>
32-
/// <param name="inReverse">if true then unwind the regex backwards (addDotStar is then ignored)</param>
33-
/// <param name="onlyDFAinfo">if true then compute and save only general DFA info</param>
34-
/// <param name="writer">dgml output is written here</param>
29+
/// <param name="writer">Writer to which the DGML is written.</param>
30+
/// <param name="nfa">True to create an NFA instead of a DFA.</param>
31+
/// <param name="addDotStar">True to prepend .*? onto the pattern (outside of the implicit root capture).</param>
32+
/// <param name="reverse">If true, then unwind the regex backwards (and <paramref name="addDotStar"/> is ignored).</param>
33+
/// <param name="maxStates">The approximate maximum number of states to include; less than or equal to 0 for no maximum.</param>
3534
/// <param name="maxLabelLength">maximum length of labels in nodes anything over that length is indicated with .. </param>
36-
/// <param name="asNFA">if true creates NFA instead of DFA</param>
3735
[ExcludeFromCodeCoverage(Justification = "Debug only")]
38-
internal void SaveDGML(TextWriter writer, int bound, bool hideStateInfo, bool addDotStar, bool inReverse, bool onlyDFAinfo, int maxLabelLength, bool asNFA)
36+
internal void SaveDGML(TextWriter writer, bool nfa, bool addDotStar, bool reverse, int maxStates, int maxLabelLength)
3937
{
4038
if (factory is not SymbolicRegexRunnerFactory srmFactory)
4139
{
4240
throw new NotSupportedException();
4341
}
4442

45-
srmFactory._matcher.SaveDGML(writer, bound, hideStateInfo, addDotStar, inReverse, onlyDFAinfo, maxLabelLength, asNFA);
43+
srmFactory._matcher.SaveDGML(writer, nfa, addDotStar, reverse, maxStates, maxLabelLength);
4644
}
4745

4846
/// <summary>

src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/Symbolic/Dgml/DgmlWriter.cs

Lines changed: 0 additions & 241 deletions
This file was deleted.

src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/Symbolic/Dgml/IAutomaton.cs

Lines changed: 0 additions & 66 deletions
This file was deleted.

0 commit comments

Comments
 (0)