Skip to content

Use static abstract interface methods in SymbolicRegexMatcher #61631

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,10 @@ private DfaMatchingState<TSetType> DeltaPlus<TTransition>(string pattern, DfaMat
/// <summary>Interface for transitions used by the <see cref="Delta"/> method.</summary>
private interface ITransition
{
#pragma warning disable CA2252 // This API requires opting into preview features
/// <summary>Find the next state given the current state and next character.</summary>
DfaMatchingState<TSetType> TakeTransition(SymbolicRegexMatcher<TSetType> matcher, DfaMatchingState<TSetType> currentState, int mintermId, TSetType minterm);
static abstract DfaMatchingState<TSetType> TakeTransition(SymbolicRegexMatcher<TSetType> matcher, DfaMatchingState<TSetType> currentState, int mintermId, TSetType minterm);
#pragma warning restore CA2252
}

/// <summary>Compute the target state for the source state and input[i] character.</summary>
Expand All @@ -345,14 +347,14 @@ private DfaMatchingState<TSetType> Delta<TTransition>(string input, int i, DfaMa
minterms[mintermId] :
_builder._solver.False; // minterm=False represents \Z

return default(TTransition).TakeTransition(this, sourceState, mintermId, minterm);
return TTransition.TakeTransition(this, sourceState, mintermId, minterm);
}

/// <summary>Transition for Brzozowski-style derivatives (i.e. a DFA).</summary>
private readonly struct BrzozowskiTransition : ITransition
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public DfaMatchingState<TSetType> TakeTransition(
public static DfaMatchingState<TSetType> TakeTransition(
SymbolicRegexMatcher<TSetType> matcher, DfaMatchingState<TSetType> currentState, int mintermId, TSetType minterm)
{
SymbolicRegexBuilder<TSetType> builder = matcher._builder;
Expand All @@ -367,13 +369,13 @@ public DfaMatchingState<TSetType> TakeTransition(
private readonly struct AntimirovTransition : ITransition
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public DfaMatchingState<TSetType> TakeTransition(
public static DfaMatchingState<TSetType> TakeTransition(
SymbolicRegexMatcher<TSetType> matcher, DfaMatchingState<TSetType> currentStates, int mintermId, TSetType minterm)
{
if (currentStates.Node.Kind != SymbolicRegexKind.Or)
{
// Fall back to Brzozowski when the state is not a disjunction.
return default(BrzozowskiTransition).TakeTransition(matcher, currentStates, mintermId, minterm);
return BrzozowskiTransition.TakeTransition(matcher, currentStates, mintermId, minterm);
}

SymbolicRegexBuilder<TSetType> builder = matcher._builder;
Expand Down