Package dk.brics.automaton
Class SpecialOperations
java.lang.Object
dk.brics.automaton.SpecialOperations
Special automata operations.
-
Method Summary
Modifier and TypeMethodDescriptionstatic Automaton
Returns an automaton that accepts the compressed language of the given automaton.static String
Returns the longest string that is a prefix of all accepted strings and visits each state at most once.Returns the set of accepted strings, assuming this automaton has a finite language.getFiniteStrings
(Automaton a, int limit) Returns the set of accepted strings, assuming that at mostlimit
strings are accepted.getStrings
(Automaton a, int length) Returns the set of accepted strings of the given length.static Automaton
Constructs automaton that accepts the same strings as the given automaton but ignores upper/lower case of A-F.static Automaton
Returns an automaton accepting the homomorphic image of the given automaton using the given function.static boolean
Returns true if the language of this automaton is finite.static Automaton
Returns an automaton that accepts the overlap of strings that in more than one way can be split into a left part being accepted bya1
and a right part being accepted bya2
.static void
Prefix closes the given automaton.static Automaton
projectChars
(Automaton a, Set<Character> chars) Returns an automaton with projected alphabet.static Automaton
Constructs automaton that accepts 0x20, 0x9, 0xa, and 0xd in place of each 0x20 transition in the given automaton.Reverses the language of the given (non-singleton) automaton while returning the set of new initial states.static Automaton
Returns an automaton that accepts the single chars that occur in strings that are accepted by the given automaton.static Automaton
Returns an automaton where all transitions of the given char are replaced by a string.static Automaton
Returns an automaton where all transition labels have been substituted.static Automaton
Returns an automaton that accepts the trimmed language of the given automaton.
-
Method Details
-
reverse
Reverses the language of the given (non-singleton) automaton while returning the set of new initial states. -
overlap
Returns an automaton that accepts the overlap of strings that in more than one way can be split into a left part being accepted bya1
and a right part being accepted bya2
. -
singleChars
Returns an automaton that accepts the single chars that occur in strings that are accepted by the given automaton. Never modifies the input automaton. -
trim
Returns an automaton that accepts the trimmed language of the given automaton. The resulting automaton is constructed as follows: 1) Whenever ac
character is allowed in the original automaton, one or moreset
characters are allowed in the new automaton. 2) The automaton is prefixed and postfixed with any number ofset
characters.- Parameters:
set
- set of characters to be trimmedc
- canonical trim character (assumed to be inset
)
-
compress
Returns an automaton that accepts the compressed language of the given automaton. Whenever ac
character is allowed in the original automaton, one or moreset
characters are allowed in the new automaton.- Parameters:
set
- set of characters to be compressedc
- canonical compress character (assumed to be inset
)
-
subst
Returns an automaton where all transition labels have been substituted.Each transition labeled
c
is changed to a set of transitions, one for each character inmap(c)
. Ifmap(c)
is null, then the transition is unchanged.- Parameters:
map
- map from characters to sets of characters (where characters areCharacter
objects)
-
subst
Returns an automaton where all transitions of the given char are replaced by a string.- Parameters:
c
- chars
- string- Returns:
- new automaton
-
homomorph
Returns an automaton accepting the homomorphic image of the given automaton using the given function.This method maps each transition label to a new value.
source
anddest
are assumed to be arrays of same length, andsource
must be sorted in increasing order and contain no duplicates.source
defines the starting points of char intervals, and the corresponding entries indest
define the starting points of corresponding new intervals. -
projectChars
Returns an automaton with projected alphabet. The new automaton accepts all strings that are projections of strings accepted by the given automaton onto the given characters (represented byCharacter
). Ifnull
is in the set, it abbreviates the intervals u0000-uDFFF and uF900-uFFFF (i.e., the non-private code points). It is assumed that all other characters fromchars
are in the interval uE000-uF8FF. -
isFinite
Returns true if the language of this automaton is finite. -
getStrings
Returns the set of accepted strings of the given length. -
getFiniteStrings
Returns the set of accepted strings, assuming this automaton has a finite language. If the language is not finite, null is returned. -
getFiniteStrings
Returns the set of accepted strings, assuming that at mostlimit
strings are accepted. If more thanlimit
strings are accepted, null is returned. Iflimit
<0, then this methods works likegetFiniteStrings(Automaton)
. -
getCommonPrefix
Returns the longest string that is a prefix of all accepted strings and visits each state at most once.- Returns:
- common prefix
-
prefixClose
Prefix closes the given automaton. -
hexCases
Constructs automaton that accepts the same strings as the given automaton but ignores upper/lower case of A-F.- Parameters:
a
- automaton- Returns:
- automaton
-
replaceWhitespace
Constructs automaton that accepts 0x20, 0x9, 0xa, and 0xd in place of each 0x20 transition in the given automaton.- Parameters:
a
- automaton- Returns:
- automaton
-