Class DAutomaton<V>
- Type Parameters:
V
- the label value type
- All Implemented Interfaces:
FormatClient
,Traceable<List<V>>
Automaton states are labeled with lists of values. This is a generalization of accepting automata: Roughly, an accepting state corresponds to a state labeled with a non-empty list of values.
This class has no public constructor. Instances can be obtained from factory methods, and by conversion from other types of automata.
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionclass
Iterator-like mutable API for tracking the consumption of an input sequence of code points by an automaton.Nested classes/interfaces inherited from class eu.bandm.tools.lexic.Automaton
Automaton.State, Automaton.Transformer<B,
R> -
Field Summary
-
Constructor Summary
ConstructorDescriptionDAutomaton
(Automaton.State initial, Map<Automaton.State, Behavior<List<V>, Automaton.State>> table) Creates a new instance. -
Method Summary
Modifier and TypeMethodDescriptionReturns an automaton that differs from this automaton by retaining only live states.complement
(V negValue) Returns an automaton that differs from this automaton by switching accepted and rejected inputs.deflate()
Returns a zero-overhead automaton equivalent to this automaton.Returns the set of distinguishing code points of this automaton.<F> F
format
(FormatServer<F> server) Returns a pretty-printable representation of this automaton.<F> F
format
(FormatServer<F> server, Function<? super V, ? extends F> onValue) Returns a pretty-printable representation of this automaton.Returns the set of live states of this automaton.intersection
(DAutomaton<V> other, BinaryOperator<V> combo) Returns an automaton that behaves like performing transitions of this and the other given automaton simultaneously.<W> DAutomaton<W>
Returns an automaton that differs from this automaton by having a function applied to the list of values associated with each reachable state.minimize()
Returns an automaton that is equivalent to this automaton but uses the least possible number of states.Returns a nondeterministic automaton that is equivalent to this automaton.toString()
Returns a human-readable representation of this automaton.totalize()
Returns an automaton that differs from this automaton by having successful transitions for all inputs.trace()
Returns a fresh trace.
-
Constructor Details
-
DAutomaton
DAutomaton(Automaton.State initial, Map<Automaton.State, Behavior<List<V>, Automaton.State>> table) Creates a new instance.- Parameters:
initial
- the initial state of the automatontable
- the behavioral table of the automaton- See Also:
-
-
Method Details
-
toString
Returns a human-readable representation of this automaton. -
deflate
Returns a zero-overhead automaton equivalent to this automaton.- Returns:
- a zero-overhead automaton equivalent to this automaton
-
totalize
Returns an automaton that differs from this automaton by having successful transitions for all inputs. Inputs rejected by this automaton lead to dead states in the new automaton, i.e., they are labeled with the empty list of values.- Returns:
- an automaton that differs from this automaton by having successful transitions for all inputs
- See Also:
-
getLiveStates
Returns the set of live states of this automaton. A state is live, if itself or any reachable state is labeled with a non-empty list; otherwise it is dead.- Returns:
- a set containing the live states of this automaton
-
abbreviate
Returns an automaton that differs from this automaton by retaining only live states. For inputs that are eventually rejected, the resulting automaton fails to make a transition at the earliest certain position.- Returns:
- an automaton that differs from this automaton by retaining only live states
-
complement
Returns an automaton that differs from this automaton by switching accepted and rejected inputs.- Parameters:
negValue
- the value to associated with each previously rejecting state- Returns:
- an automaton that rejects inputs accepted by this automaton, and vice versa
-
intersection
Returns an automaton that behaves like performing transitions of this and the other given automaton simultaneously.The resulting automaton accepts only input that is accepted by both given automata, and combines the result values.
In the worst case, the number of states of the resulting automaton is the product of the numbers of states of the given automata.
- Parameters:
other
- the other automatoncombo
- the operation for combining the values for an accepted input- Returns:
- an automaton that behaves like performing transitions of the two automata simultaneously
-
nondeterminate
Returns a nondeterministic automaton that is equivalent to this automaton.- Returns:
- a nondeterministic automaton that is equivalent to this automaton
- See Also:
-
mapList
Returns an automaton that differs from this automaton by having a function applied to the list of values associated with each reachable state.- Type Parameters:
W
- the target value type- Parameters:
fun
- the function to apply to each list of values- Returns:
- an automaton that differs from this automaton by having the given function applied to the list of values associated with each reachable state
-
distinguishingCodePoints
Returns the set of distinguishing code points of this automaton.This set contains all code points that occur explicitly in the behavior associated with any state. It is used for Hopcroft's minimization algorithm.
- Returns:
- the set of distinguishing code points of this automaton
- See Also:
-
minimize
Returns an automaton that is equivalent to this automaton but uses the least possible number of states.- Returns:
- an automaton that is equivalent to this automaton but uses the least possible number of states
-
format
Returns a pretty-printable representation of this automaton.- Specified by:
format
in interfaceFormatClient
- Type Parameters:
F
- the type of format objects to produce- Parameters:
server
- a factory object that can produce format objects- Returns:
- a format object produced by the server
-
format
Returns a pretty-printable representation of this automaton.- Type Parameters:
F
- the type of format objects to produce- Parameters:
server
- a factory object that can produce format objectsonValue
- the operation to compute a representation of a value- Returns:
- a pretty-printable representation of this automaton
-
trace
Returns a fresh trace.Objects obtained as return values from multiple calls to this method do not share mutable state with each other, and can be used safely in concurrency.
-