jfun.parsec.pattern
public final class Patterns extends Object
Method Summary | |
---|---|
static Pattern | always()
A Pattern object that always matches with 0 length. |
static Pattern | among(char[] cs)
Succeed with match length 1
if the current character in the input is among the given characters. |
static Pattern | and(Pattern... pps)
Find the match length that matches
all of the patterns in the given Pattern object array.
|
static Pattern | chars_eq(int l) |
static Pattern | chars_ge(int l) |
static Pattern | eof()
Ensures the input has no character left.
match length is 0 if succeed. |
static Pattern | hasAtLeast(int l)
Ensures the input has at least l characters left.
match length is l if succeed. |
static Pattern | hasExact(int l)
Ensures the input has exactly l characters left.
match length is l if succeed. |
static Pattern | ifelse(Pattern cond, Pattern yes, Pattern no)
If the condiction Pattern object cond matches,
match the remaining input against Pattern object yes.
|
static Pattern | isChar(char c)
Succeed with match length 1
if the current character in the input is same as character c.
|
static Pattern | isChar(CharPredicate cp)
Succeed with match length 1
if the current character in the input satisfies the given predicate.
|
static Pattern | isDecimal()
Recognizes a decimal number that can start with a decimal point. |
static Pattern | isDecimalL()
a decimal number that has at least one number before the decimal point.
the decimal point and the numbers to the right are optional.
|
static Pattern | isDecimalR()
Recognizes a decimal point and 1 or more digits after it. |
static Pattern | isDecInteger()
pattern for a decimal integer.
|
static Pattern | isEscaped()
Succeed with match length 2
if there are at least 2 characters in the input and the first character is '\'
Mismatch otherwise. |
static Pattern | isExponential()
Recognizes a the exponent part of a scientific number notation.
|
static Pattern | isHexInteger()
pattern for a hex integer.
|
static Pattern | isInteger()
pattern for an integer. |
static Pattern | isLineComment(String open)
Matches a line comment that starts with a string
and end with EOF or Line Feed character. |
static Pattern | isOctInteger()
pattern for a octal integer that starts with a 0 and followed by 0 or more [0-7] characters. |
static Pattern | isString(String str)
Matches a string. |
static Pattern | isStringCI(String str)
Matches a string case insensitively. |
static Pattern | isWord()
a pattern for a standard english word.
it starts with an underscore or an alphametic character, followed by 0 or more alphanumeric characters. |
static Pattern | longer(Pattern p1, Pattern p2)
Try two pattern objects, pick the one with the longer match length.
|
static Pattern | longest(Pattern... pps)
Try an array of pattern objects, pick the one with the longest match length.
|
static Pattern | many(int min, CharPredicate cp)
Matches if the input starts with min or more characters
that all satisfy the given predicate,
mismatch otherwise. |
static Pattern | many(CharPredicate cp)
Matches 0 or more characters that all satisfy the given predicate. |
static Pattern | many(int min, Pattern pp)
Matches if the input starts with min or more occurrences of
patterns recognized by Pattern object pp,
mismatch otherwise. |
static Pattern | many(Pattern pp)
Matches 0 or more occurrences of
patterns recognized by Pattern object pp. |
static Pattern | many1(CharPredicate cp)
Matches characters that satisfies the given predicate
for 1 or more times.
|
static Pattern | never()
A Pattern object that always returns MISMATCH. |
static Pattern | not(Pattern pp)
Matches with match length 0 if the Pattern object pp mismatch.
|
static Pattern | notAmong(char[] cs)
Succeed with match length 1
if the current character in the input is not among the given characters. |
static Pattern | notChar(char c)
Succeed with match length 1
if the current character in the input is not the same as character c.
|
static Pattern | notRange(char c1, char c2)
Succeed with match length 1
if the current character in the input is not between character c1 and c2. |
static Pattern | notString(String str)
Matches a character if the input has at least 1 character
and does not match the given string. |
static Pattern | notStringCI(String str)
Matches a character if the input has at least 1 character
and does not match the given string case insensitively. |
static Pattern | optional(Pattern pp)
Match with 0 length even if Pattern object pp mismatches. |
static Pattern | or(Pattern pp1, Pattern pp2)
if the first Pattern object pp1 mismatches, try the second Pattern object pp2. |
static Pattern | or(Pattern... pps)
try an array of Pattern objects subsequently until one matches.
|
static Pattern | peek(Pattern pp)
Matches with match length 0 if the Pattern object pp matches.
|
static Pattern | range(char c1, char c2)
Succeed with match length 1
if the current character in the input is between character c1 and c2. |
static Pattern | regex(Pattern p)
Adapt a regular expression pattern to a jfun.parsec.pattern.Pattern; |
static Pattern | regex(String s)
Adapt a regular expression pattern string to a jfun.parsec.pattern.Pattern; |
static Pattern | regex_modifiers()
Get the pattern that matches regular expression modifiers.
|
static Pattern | regex_pattern()
Get the Pattern object that matches any regular expression pattern
string in the form of /some pattern here/.
|
static Pattern | repeat(int n, CharPredicate cp)
Matches if the input has at least n characters
and the first n characters all satisfy the given predicate. |
static Pattern | repeat(int n, Pattern pp)
Matches if the input n occurrences of Pattern pp. |
static Pattern | seq(Pattern pp1, Pattern pp2)
First matches Pattern object pp1.
|
static Pattern | seq(Pattern... pps)
Runs an array of Pattern objects subsequently until one mismatches.
|
static Pattern | shorter(Pattern p1, Pattern p2)
Try two pattern objects, pick the one with the shorter match length.
|
static Pattern | shortest(Pattern... pps)
Try an array of pattern objects, pick the one with the shortest match length.
|
static Pattern | some(int min, int max, CharPredicate cp)
Matches at least min and at most max number of characters
that satisfies the given predicate,
mismatch otherwise. |
static Pattern | some(int max, CharPredicate cp)
Matches at most max number of characters
that satisfies the given predicate. |
static Pattern | some(int min, int max, Pattern pp)
Matches at least min and at most max number of occurrences
of pattern recognized by Pattern object pp,
mismatch otherwise. |
static Pattern | some(int max, Pattern pp)
Matches at most max number of occurrences
of pattern recognized by Pattern object pp. |
Returns: the Pattern object.
Parameters: cs the characters to compare with.
Returns: the Pattern object.
Parameters: pps the Pattern array.
Returns: the new Pattern object.
Deprecated: Use Patterns instead.
Deprecated: Use Patterns instead.
Returns: the Pattern object.
Parameters: l the number of characters.
Returns: the Pattern object.
Parameters: l the number of characters.
Returns: the Pattern object.
Parameters: cond the condition Pattern. yes the true Pattern. no the false Pattern.
Returns: the new Pattern object.
Parameters: c the character to compare with.
Returns: the Pattern object.
Parameters: cp the predicate object.
Returns: the Pattern object.
Returns: the Pattern object.
Returns: the Pattern object.
Returns: the Pattern object.
Returns: the Pattern object.
Returns: the Pattern object.
Returns: the Pattern object.
Returns: the Pattern object.
Returns: the Pattern object.
Parameters: open the line comment starting string.
Returns: the Pattern object.
Returns: the Pattern object.
Returns: the Pattern object.
Returns: the Pattern object.
Returns: the Pattern object.
Parameters: p1 the 1st pattern object. p2 the 2nd pattern object.
Returns: the new Pattern object.
Parameters: pps the array of Pattern objects.
Returns: the new Pattern object.
Parameters: min the minimal number of characters to match. cp the predicate.
Returns: the Pattern object.
Parameters: cp the predicate.
Returns: the Pattern object.
Parameters: min the minimal number of occurrences to match. pp the Pattern object.
Returns: the new Pattern object.
Parameters: pp the Pattern object.
Returns: the new Pattern object.
Returns: the new Pattern object.
Returns: the Pattern object.
Parameters: pp the Pattern object.
Returns: the new Pattern object.
Parameters: cs the characters to compare with.
Returns: the Pattern object.
Parameters: c the character to compare with.
Returns: the Pattern object.
Parameters: c1 the first character. c2 the second character.
Returns: the Pattern object.
Returns: the Pattern object.
Returns: the Pattern object.
Returns: the new Pattern object.
Parameters: pp1 the 1st Pattern object. pp2 the 2nd Pattern object.
Returns: the new Pattern object.
Parameters: pps the Pattern object array.
Returns: the new Pattern object.
Parameters: pp the Pattern object.
Returns: the new Pattern object.
Parameters: c1 the first character. c2 the second character.
Returns: the Pattern object.
Parameters: p the regular expression pattern.
Returns: the jfun.parsec.pattern.Pattern object.
Parameters: s the regular expression pattern string.
Returns: the jfun.parsec.pattern.Pattern object.
Parameters: n the number of characters to test. cp the predicate object.
Returns: the Pattern object.
Parameters: n the number of occurrences. pp the Pattern object.
Returns: the new Pattern object.
Parameters: pp1 the 1st Pattern object to match. pp2 the 2nd Pattern object to match.
Returns: the new Pattern object.
Parameters: pps the Pattern object array.
Returns: the new Pattern object.
Parameters: p1 the 1st pattern object. p2 the 2nd pattern object.
Returns: the new Pattern object.
Parameters: pps the array of Pattern objects.
Returns: the new Pattern object.
Parameters: min the minimal number of characters. max the maximal number of characters. cp the predicate.
Returns: the Pattern object.
Parameters: max the maximal number of characters. cp the predicate.
Returns: the Pattern object.
Parameters: min the minimal number of occurrences of pattern. max the maximal number of occurrences of pattern. pp the Pattern object.
Returns: the new Pattern object.
Parameters: max the maximal number of occurrences of pattern. pp the Pattern object.
Returns: the new Pattern object.