Skip to content

Commit

Permalink
Clean up NonBacktracking DgmlWriter (#66363)
Browse files Browse the repository at this point in the history
* Clean up NonBacktracking DgmlWriter

* Address PR feedback, clean up some lang=regex usage, fix a test failure
  • Loading branch information
stephentoub authored Mar 10, 2022
1 parent f63e4d9 commit 406d854
Show file tree
Hide file tree
Showing 14 changed files with 381 additions and 607 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
<Compile Include="System\Text\RegularExpressions\Symbolic\CharKind.cs" />
<Compile Include="System\Text\RegularExpressions\Symbolic\CharSetSolver.cs" />
<Compile Include="System\Text\RegularExpressions\Symbolic\DerivativeEffect.cs" />
<Compile Include="System\Text\RegularExpressions\Symbolic\DgmlWriter.cs" />
<Compile Include="System\Text\RegularExpressions\Symbolic\DfaMatchingState.cs" />
<Compile Include="System\Text\RegularExpressions\Symbolic\IBooleanAlgebra.cs" />
<Compile Include="System\Text\RegularExpressions\Symbolic\ICharAlgebra.cs" />
Expand All @@ -82,10 +83,6 @@
<Compile Include="System\Text\RegularExpressions\Symbolic\SymbolicRegexSet.cs" />
<Compile Include="System\Text\RegularExpressions\Symbolic\TransitionRegex.cs" />
<Compile Include="System\Text\RegularExpressions\Symbolic\TransitionRegexKind.cs" />
<Compile Include="System\Text\RegularExpressions\Symbolic\Dgml\DgmlWriter.cs" />
<Compile Include="System\Text\RegularExpressions\Symbolic\Dgml\IAutomaton.cs" />
<Compile Include="System\Text\RegularExpressions\Symbolic\Dgml\Move.cs" />
<Compile Include="System\Text\RegularExpressions\Symbolic\Dgml\RegexAutomaton.cs" />
<Compile Include="System\Text\RegularExpressions\Symbolic\Unicode\GeneratorHelper.cs" />
<Compile Include="System\Text\RegularExpressions\Symbolic\Unicode\IgnoreCaseRelation.cs" />
<Compile Include="System\Text\RegularExpressions\Symbolic\Unicode\IgnoreCaseRelationGenerator.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,21 @@ internal static bool EnableDebugTracing
}

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

srmFactory._matcher.SaveDGML(writer, bound, hideStateInfo, addDotStar, inReverse, onlyDFAinfo, maxLabelLength, asNFA);
srmFactory._matcher.SaveDGML(writer, nfa, addDotStar, reverse, maxStates, maxLabelLength);
}

/// <summary>
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit 406d854

Please sign in to comment.