Package dk.brics.automaton
Class BasicAutomata
- java.lang.Object
-
- dk.brics.automaton.BasicAutomata
-
public final class BasicAutomata extends java.lang.Object
Construction of basic automata.
-
-
Constructor Summary
Constructors Modifier Constructor Description private
BasicAutomata()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static State
anyOfRightLength(java.lang.String x, int n)
Constructs sub-automaton corresponding to decimal numbers of length x.substring(n).length().private static State
atLeast(java.lang.String x, int n, java.util.Collection<State> initials, boolean zeros)
Constructs sub-automaton corresponding to decimal numbers of value at least x.substring(n) and length x.substring(n).length().private static State
atMost(java.lang.String x, int n)
Constructs sub-automaton corresponding to decimal numbers of value at most x.substring(n) and length x.substring(n).length().private static State
between(java.lang.String x, java.lang.String y, int n, java.util.Collection<State> initials, boolean zeros)
Constructs sub-automaton corresponding to decimal numbers of value between x.substring(n) and y.substring(n) and of length x.substring(n).length() (which must be equal to y.substring(n).length()).static Automaton
makeAnyChar()
Returns a new (deterministic) automaton that accepts any single character.static Automaton
makeAnyString()
Returns a new (deterministic) automaton that accepts all strings.static Automaton
makeChar(char c)
Returns a new (deterministic) automaton that accepts a single character of the given value.static Automaton
makeCharRange(char min, char max)
Returns a new (deterministic) automaton that accepts a single char whose value is in the given interval (including both end points).static Automaton
makeCharSet(java.lang.String set)
Returns a new (deterministic) automaton that accepts a single character in the given set.static Automaton
makeDecimalValue(java.lang.String value)
Constructs automaton that accept strings representing the given decimal number.static Automaton
makeEmpty()
Returns a new (deterministic) automaton with the empty language.static Automaton
makeEmptyString()
Returns a new (deterministic) automaton that accepts only the empty string.static Automaton
makeFractionDigits(int i)
Constructs automaton that accept strings representing decimal numbers that can be written with at most the given number of digits in the fraction part.static Automaton
makeIntegerValue(java.lang.String value)
Constructs automaton that accept strings representing the given integer.static Automaton
makeInterval(int min, int max, int digits)
Returns a new automaton that accepts strings representing decimal non-negative integers in the given interval.static Automaton
makeMaxInteger(java.lang.String n)
Constructs automaton that accept strings representing nonnegative integers that are not larger than the given value.static Automaton
makeMinInteger(java.lang.String n)
Constructs automaton that accept strings representing nonnegative integers that are not less that the given value.static Automaton
makeString(java.lang.String s)
Returns a new (deterministic) automaton that accepts the single given string.static Automaton
makeStringMatcher(java.lang.String s)
Constructs deterministic automaton that matches strings that contain the given substring.static Automaton
makeStringUnion(java.lang.CharSequence... strings)
Returns a new (deterministic and minimal) automaton that accepts the union of the given set of strings.static Automaton
makeTotalDigits(int i)
Constructs automaton that accept strings representing decimal numbers that can be written with at most the given number of digits.private static void
maxInteger(java.lang.String n, int i, java.lang.StringBuilder b)
private static void
minInteger(java.lang.String n, int i, java.lang.StringBuilder b)
-
-
-
Method Detail
-
makeEmpty
public static Automaton makeEmpty()
Returns a new (deterministic) automaton with the empty language.
-
makeEmptyString
public static Automaton makeEmptyString()
Returns a new (deterministic) automaton that accepts only the empty string.
-
makeAnyString
public static Automaton makeAnyString()
Returns a new (deterministic) automaton that accepts all strings.
-
makeAnyChar
public static Automaton makeAnyChar()
Returns a new (deterministic) automaton that accepts any single character.
-
makeChar
public static Automaton makeChar(char c)
Returns a new (deterministic) automaton that accepts a single character of the given value.
-
makeCharRange
public static Automaton makeCharRange(char min, char max)
Returns a new (deterministic) automaton that accepts a single char whose value is in the given interval (including both end points).
-
makeCharSet
public static Automaton makeCharSet(java.lang.String set)
Returns a new (deterministic) automaton that accepts a single character in the given set.
-
anyOfRightLength
private static State anyOfRightLength(java.lang.String x, int n)
Constructs sub-automaton corresponding to decimal numbers of length x.substring(n).length().
-
atLeast
private static State atLeast(java.lang.String x, int n, java.util.Collection<State> initials, boolean zeros)
Constructs sub-automaton corresponding to decimal numbers of value at least x.substring(n) and length x.substring(n).length().
-
atMost
private static State atMost(java.lang.String x, int n)
Constructs sub-automaton corresponding to decimal numbers of value at most x.substring(n) and length x.substring(n).length().
-
between
private static State between(java.lang.String x, java.lang.String y, int n, java.util.Collection<State> initials, boolean zeros)
Constructs sub-automaton corresponding to decimal numbers of value between x.substring(n) and y.substring(n) and of length x.substring(n).length() (which must be equal to y.substring(n).length()).
-
makeInterval
public static Automaton makeInterval(int min, int max, int digits) throws java.lang.IllegalArgumentException
Returns a new automaton that accepts strings representing decimal non-negative integers in the given interval.- Parameters:
min
- minimal value of intervalmax
- maximal value of inverval (both end points are included in the interval)digits
- if >0, use fixed number of digits (strings must be prefixed by 0's to obtain the right length) - otherwise, the number of digits is not fixed- Throws:
java.lang.IllegalArgumentException
- if min>max or if numbers in the interval cannot be expressed with the given fixed number of digits
-
makeString
public static Automaton makeString(java.lang.String s)
Returns a new (deterministic) automaton that accepts the single given string.
-
makeStringUnion
public static Automaton makeStringUnion(java.lang.CharSequence... strings)
Returns a new (deterministic and minimal) automaton that accepts the union of the given set of strings. The input character sequences are internally sorted in-place, so the input array is modified.- See Also:
StringUnionOperations
-
makeMaxInteger
public static Automaton makeMaxInteger(java.lang.String n)
Constructs automaton that accept strings representing nonnegative integers that are not larger than the given value.- Parameters:
n
- string representation of maximum value
-
maxInteger
private static void maxInteger(java.lang.String n, int i, java.lang.StringBuilder b)
-
makeMinInteger
public static Automaton makeMinInteger(java.lang.String n)
Constructs automaton that accept strings representing nonnegative integers that are not less that the given value.- Parameters:
n
- string representation of minimum value
-
minInteger
private static void minInteger(java.lang.String n, int i, java.lang.StringBuilder b)
-
makeTotalDigits
public static Automaton makeTotalDigits(int i)
Constructs automaton that accept strings representing decimal numbers that can be written with at most the given number of digits. Surrounding whitespace is permitted.- Parameters:
i
- max number of necessary digits
-
makeFractionDigits
public static Automaton makeFractionDigits(int i)
Constructs automaton that accept strings representing decimal numbers that can be written with at most the given number of digits in the fraction part. Surrounding whitespace is permitted.- Parameters:
i
- max number of necessary fraction digits
-
makeIntegerValue
public static Automaton makeIntegerValue(java.lang.String value)
Constructs automaton that accept strings representing the given integer. Surrounding whitespace is permitted.- Parameters:
value
- string representation of integer
-
makeDecimalValue
public static Automaton makeDecimalValue(java.lang.String value)
Constructs automaton that accept strings representing the given decimal number. Surrounding whitespace is permitted.- Parameters:
value
- string representation of decimal number
-
makeStringMatcher
public static Automaton makeStringMatcher(java.lang.String s)
Constructs deterministic automaton that matches strings that contain the given substring.
-
-