Class StateTransitionCanonicalizer<SI extends StateIndex<? super S>,S extends AbstractState<S,T>,T extends AbstractTransition<S,T>,TB extends TransitionBuilder<SI,S,T>>
java.lang.Object
com.oracle.truffle.regex.tregex.automaton.StateTransitionCanonicalizer<SI,S,T,TB>
- Type Parameters:
TB- represents a DFA transition fragment. This type is used for both intermediate and final results.
- Direct Known Subclasses:
ASTTransitionCanonicalizer,DFATransitionCanonicalizer
public abstract class StateTransitionCanonicalizer<SI extends StateIndex<? super S>,S extends AbstractState<S,T>,T extends AbstractTransition<S,T>,TB extends TransitionBuilder<SI,S,T>>
extends Object
This class provides an algorithm for converting a list of NFA transitions into a set of DFA
transitions.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionStateTransitionCanonicalizer(SI stateIndex, boolean forward, boolean prioritySensitive) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddArgument(T transition, CodePointSet charSet) Submits an argument to be processed byrun(CompilationBuffer).protected abstract booleanReturnstrueif two DFA transitions are allowed to be merged into one.protected abstract TB[]createResultArray(int size) Returns an array suitable for holding the result ofrun(CompilationBuffer).protected abstract T[]createTransitionArray(int size) protected abstract TBcreateTransitionBuilder(T[] transitions, StateSet<SI, S> targetStateSet, CodePointSet matcherBuilder) protected booleanIf priority-sensitive mode, transition sets are pruned after transitions to final states.TB[]run(CompilationBuffer compilationBuffer) Runs the NFA to DFA transition conversion algorithm on the NFA transitions given by previous calls toaddArgument(AbstractTransition, CodePointSet).
-
Constructor Details
-
StateTransitionCanonicalizer
-
-
Method Details
-
isPrioritySensitive
protected boolean isPrioritySensitive()If priority-sensitive mode, transition sets are pruned after transitions to final states. Also, target state sets are considered equal iff their order is equal as well. -
addArgument
Submits an argument to be processed byrun(CompilationBuffer). -
run
Runs the NFA to DFA transition conversion algorithm on the NFA transitions given by previous calls toaddArgument(AbstractTransition, CodePointSet). This algorithm has two phases:- Merge NFA transitions according to their expected character sets. The result of this
phase is a list of
TransitionBuilders whoseCodePointSets have no more intersections. - Merge
TransitionBuilders generated by the first phase if their target state is equal andcanMerge(TransitionBuilder, TransitionBuilder)returnstrue.
- Returns:
- a set of transition builders representing the DFA transitions generated from the given NFA transitions.
- Merge NFA transitions according to their expected character sets. The result of this
phase is a list of
-
createTransitionBuilder
-
canMerge
-
createTransitionArray
-
createResultArray
Returns an array suitable for holding the result ofrun(CompilationBuffer).
-