dk.brics.automaton
public class Automaton extends Object implements Serializable, Cloneable
Class invariants:
If the states or transitions are manipulated manually, the restoreInvariant and Automaton methods should be used afterwards to restore representation invariants that are assumed by the built-in automata operations.
Field Summary | |
---|---|
static int | MINIMIZE_BRZOZOWSKI
Minimize using Brzozowski's O(2n) algorithm.
|
static int | MINIMIZE_HOPCROFT
Minimize using Hopcroft's O(n log n) algorithm.
|
static int | MINIMIZE_HUFFMAN
Minimize using Huffman's O(n2) algorithm.
|
Constructor Summary | |
---|---|
Automaton()
Constructs a new automaton that accepts the empty language.
|
Method Summary | |
---|---|
void | addEpsilons(Collection<StatePair> pairs)
See BasicOperations. |
Automaton | complement()
See complement. |
Automaton | compress(String set, char c)
See SpecialOperations. |
Automaton | concatenate(Automaton a)
See BasicOperations. |
static Automaton | concatenate(List<Automaton> l)
See concatenate. |
void | determinize()
See determinize. |
void | expandSingleton()
Expands singleton representation to normal representation.
|
Set<State> | getAcceptStates()
Returns the set of reachable accept states. |
String | getCommonPrefix()
See getCommonPrefix. |
Set<String> | getFiniteStrings()
See getFiniteStrings. |
Set<String> | getFiniteStrings(int limit)
See SpecialOperations. |
Object | getInfo()
Returns extra information associated with this automaton. |
State | getInitialState()
Gets initial state. |
Set<State> | getLiveStates()
Returns the set of live states. |
int | getNumberOfStates()
Returns the number of states in this automaton. |
int | getNumberOfTransitions()
Returns the number of transitions in this automaton. |
String | getShortestExample(boolean accepted)
See BasicOperations. |
String | getSingleton()
Returns the singleton string for this automaton.
|
Set<State> | getStates()
Returns the set of states that are reachable from the initial state. |
Set<String> | getStrings(int length)
See SpecialOperations. |
static Automaton | hexCases(Automaton a)
See hexCases. |
Automaton | homomorph(char[] source, char[] dest) |
Automaton | intersection(Automaton a)
See BasicOperations. |
boolean | isDeterministic()
Returns deterministic flag for this automaton. |
boolean | isEmpty()
See isEmpty. |
boolean | isEmptyString()
See isEmptyString. |
boolean | isFinite()
See isFinite. |
boolean | isTotal()
See isTotal. |
static Automaton | load(URL url)
Retrieves a serialized Automaton located by a URL. |
static Automaton | load(InputStream stream)
Retrieves a serialized Automaton from a stream. |
static Automaton | makeAnyChar()
See makeAnyChar. |
static Automaton | makeAnyString()
See makeAnyString. |
static Automaton | makeChar(char c)
See BasicAutomata. |
static Automaton | makeCharRange(char min, char max)
See BasicAutomata. |
static Automaton | makeCharSet(String set)
See makeCharSet. |
static Automaton | makeDecimalValue(String value)
See makeDecimalValue. |
static Automaton | makeEmpty()
See makeEmpty. |
static Automaton | makeEmptyString()
See makeEmptyString. |
static Automaton | makeFractionDigits(int i)
See BasicAutomata. |
static Automaton | makeIntegerValue(String value)
See makeIntegerValue. |
static Automaton | makeInterval(int min, int max, int digits)
See BasicAutomata. |
static Automaton | makeMaxInteger(String n)
See makeMaxInteger. |
static Automaton | makeMinInteger(String n)
See makeMinInteger. |
static Automaton | makeString(String s)
See makeString. |
static Automaton | makeStringMatcher(String s)
See makeStringMatcher. |
static Automaton | makeTotalDigits(int i)
See BasicAutomata. |
void | minimize()
See minimize. |
static Automaton | minimize(Automaton a)
See minimize.
|
Automaton | minus(Automaton a)
See BasicOperations. |
Automaton | optional()
See optional. |
Automaton | overlap(Automaton a)
See SpecialOperations. |
void | prefixClose()
See prefixClose. |
Automaton | projectChars(Set<Character> chars)
See SpecialOperations. |
void | reduce()
Reduces this automaton.
|
void | removeDeadTransitions()
Removes transitions to dead states and calls reduce and clearHashCode.
|
Automaton | repeat()
See repeat. |
Automaton | repeat(int min)
See BasicOperations. |
Automaton | repeat(int min, int max)
See BasicOperations. |
static Automaton | replaceWhitespace(Automaton a)
See replaceWhitespace. |
void | restoreInvariant()
Restores representation invariant.
|
boolean | run(String s)
See BasicOperations. |
static boolean | setAllowMutate(boolean flag)
Sets or resets allow mutate flag.
|
void | setDeterministic(boolean deterministic)
Sets deterministic flag for this automaton.
|
void | setInfo(Object info)
Associates extra information with this automaton. |
void | setInitialState(State s)
Sets initial state. |
static void | setMinimization(int algorithm)
Selects minimization algorithm (default: MINIMIZE_HOPCROFT ). |
static void | setMinimizeAlways(boolean flag)
Sets or resets minimize always flag.
|
Automaton | shuffle(Automaton a)
See ShuffleOperations. |
static String | shuffleSubsetOf(Collection<Automaton> ca, Automaton a, Character suspend_shuffle, Character resume_shuffle)
See ShuffleOperations. |
Automaton | singleChars()
See singleChars. |
void | store(OutputStream stream)
Writes this Automaton to the given stream. |
boolean | subsetOf(Automaton a)
See BasicOperations. |
Automaton | subst(Map<Character,Set<Character>> map)
See SpecialOperations. |
Automaton | subst(char c, String s)
See SpecialOperations. |
String | toDot()
Returns Graphviz Dot
representation of this automaton. |
Automaton | trim(String set, char c)
See SpecialOperations. |
Automaton | union(Automaton a)
See BasicOperations. |
static Automaton | union(Collection<Automaton> l)
See union. |
See Also: Automaton
See Also: Automaton
See Also: Automaton
See Also: setInitialState State Transition
Returns: set of State objects
Returns: extra information
See Also: setInfo
Returns: state
Returns: set of State objects
Returns: string, null if this automaton is not in singleton mode.
Returns: set of State objects
Returns: true if the automaton is definitely deterministic, false if the automaton may be nondeterministic
Automaton
located by a URL.Parameters: url URL of serialized automaton
Throws: IOException if input/output related exception occurs OptionalDataException if the data is not a serialized object InvalidClassException if the class serial number does not match ClassCastException if the data is not a serialized Automaton
ClassNotFoundException if the class of the serialized object cannot be found
Automaton
from a stream.Parameters: stream input stream with serialized automaton
Throws: IOException if input/output related exception occurs OptionalDataException if the data is not a serialized object InvalidClassException if the class serial number does not match ClassCastException if the data is not a serialized Automaton
ClassNotFoundException if the class of the serialized object cannot be found
See Also: Automaton
Parameters: flag if true, the flag is set
Returns: previous value of the flag
Parameters: deterministic true if the automaton is definitely deterministic, false if the automaton may be nondeterministic
Parameters: info extra information
Parameters: s state
MINIMIZE_HOPCROFT
).Parameters: algorithm minimization algorithm
Parameters: flag if true, the flag is set
Automaton
to the given stream.Parameters: stream output stream for serialized automaton
Throws: IOException if input/output related exception occurs