|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjfun.parsec.pattern.Patterns
public final class Patterns
This class provides all the basic Pattern implementations and all Pattern combinators.
Constructor Summary | |
---|---|
Patterns()
|
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)
Deprecated. Use hasExact(int) instead. |
static Pattern |
chars_ge(int l)
Deprecated. Use hasAtLeast(int) instead. |
static Pattern |
eof()
Ensures the input has no character left. |
static Pattern |
hasAtLeast(int l)
Ensures the input has at least l characters left. |
static Pattern |
hasExact(int l)
Ensures the input has exactly l characters left. |
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. |
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(java.lang.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(java.lang.String str)
Matches a string. |
static Pattern |
isStringCI(java.lang.String str)
Matches a string case insensitively. |
static Pattern |
isWord()
a pattern for a standard english word. |
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(CharPredicate cp)
Matches 0 or more characters that all satisfy the given predicate. |
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(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(java.lang.String str)
Matches a character if the input has at least 1 character and does not match the given string. |
static Pattern |
notStringCI(java.lang.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... pps)
try an array of Pattern objects subsequently until one matches. |
static Pattern |
or(Pattern pp1,
Pattern pp2)
if the first Pattern object pp1 mismatches, try the second Pattern object pp2. |
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_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 |
regex(java.util.regex.Pattern p)
Adapt a regular expression pattern to a jfun.parsec.pattern.Pattern; |
static Pattern |
regex(java.lang.String s)
Adapt a regular expression pattern string to a jfun.parsec.pattern.Pattern; |
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... pps)
Runs an array of Pattern objects subsequently until one mismatches. |
static Pattern |
seq(Pattern pp1,
Pattern pp2)
First matches Pattern object pp1. |
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 max,
CharPredicate cp)
Matches at most max number of characters that satisfies the given predicate. |
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 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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Patterns()
Method Detail |
---|
public static Pattern chars_ge(int l)
hasAtLeast(int)
instead.
public static Pattern chars_eq(int l)
hasExact(int)
instead.
public static Pattern hasAtLeast(int l)
l
- the number of characters.
public static Pattern hasExact(int l)
l
- the number of characters.
public static Pattern eof()
public static Pattern isChar(char c)
c
- the character to compare with.
public static Pattern range(char c1, char c2)
c1
- the first character.c2
- the second character.
public static Pattern notRange(char c1, char c2)
c1
- the first character.c2
- the second character.
public static Pattern among(char[] cs)
cs
- the characters to compare with.
public static Pattern notAmong(char[] cs)
cs
- the characters to compare with.
public static Pattern notChar(char c)
c
- the character to compare with.
public static Pattern isChar(CharPredicate cp)
cp
- the predicate object.
public static Pattern isEscaped()
public static Pattern isLineComment(java.lang.String open)
open
- the line comment starting string.
public static Pattern isString(java.lang.String str)
public static Pattern isStringCI(java.lang.String str)
public static Pattern notString(java.lang.String str)
public static Pattern notStringCI(java.lang.String str)
public static Pattern not(Pattern pp)
pp
- the Pattern object.
public static Pattern peek(Pattern pp)
pp
- the Pattern object.
public static Pattern or(Pattern pp1, Pattern pp2)
pp1
- the 1st Pattern object.pp2
- the 2nd Pattern object.
public static Pattern and(Pattern... pps)
pps
- the Pattern array.
public static Pattern seq(Pattern pp1, Pattern pp2)
pp1
- the 1st Pattern object to match.pp2
- the 2nd Pattern object to match.
public static Pattern or(Pattern... pps)
pps
- the Pattern object array.
public static Pattern seq(Pattern... pps)
pps
- the Pattern object array.
public static Pattern repeat(int n, CharPredicate cp)
n
- the number of characters to test.cp
- the predicate object.
public static Pattern repeat(int n, Pattern pp)
n
- the number of occurrences.pp
- the Pattern object.
public static Pattern many(int min, CharPredicate cp)
min
- the minimal number of characters to match.cp
- the predicate.
public static Pattern many(CharPredicate cp)
cp
- the predicate.
public static Pattern many(int min, Pattern pp)
min
- the minimal number of occurrences to match.pp
- the Pattern object.
public static Pattern many(Pattern pp)
pp
- the Pattern object.
public static Pattern some(int min, int max, CharPredicate cp)
min
- the minimal number of characters.max
- the maximal number of characters.cp
- the predicate.
public static Pattern some(int max, CharPredicate cp)
max
- the maximal number of characters.cp
- the predicate.
public static Pattern some(int min, int max, Pattern pp)
min
- the minimal number of occurrences of pattern.max
- the maximal number of occurrences of pattern.pp
- the Pattern object.
public static Pattern some(int max, Pattern pp)
max
- the maximal number of occurrences of pattern.pp
- the Pattern object.
public static Pattern longer(Pattern p1, Pattern p2)
p1
- the 1st pattern object.p2
- the 2nd pattern object.
public static Pattern longest(Pattern... pps)
pps
- the array of Pattern objects.
public static Pattern shorter(Pattern p1, Pattern p2)
p1
- the 1st pattern object.p2
- the 2nd pattern object.
public static Pattern shortest(Pattern... pps)
pps
- the array of Pattern objects.
public static Pattern ifelse(Pattern cond, Pattern yes, Pattern no)
cond
- the condition Pattern.yes
- the true Pattern.no
- the false Pattern.
public static Pattern many1(CharPredicate cp)
public static Pattern optional(Pattern pp)
public static Pattern never()
public static Pattern always()
public static Pattern isDecimalL()
public static Pattern isDecimalR()
public static Pattern isDecimal()
public static Pattern isWord()
public static Pattern isInteger()
public static Pattern isOctInteger()
public static Pattern isDecInteger()
public static Pattern isHexInteger()
public static Pattern isExponential()
public static Pattern regex(java.util.regex.Pattern p)
p
- the regular expression pattern.
public static Pattern regex(java.lang.String s)
s
- the regular expression pattern string.
public static Pattern regex_pattern()
public static Pattern regex_modifiers()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |