Package | Description |
---|---|
jfun.parsec |
Provides classes and interfaces for parser combinator logic and basic parsers.
|
jfun.parsec.pattern |
Provides classes and interfaces for pattern combinator logic and basic patterns.
|
Modifier and Type | Method and Description |
---|---|
static Parser<_> |
Scanners.isBlockComment(java.lang.String open,
java.lang.String close,
Pattern commented)
Scans a non-nestable block comment.
|
static Parser<_> |
Scanners.isPattern(Pattern pp,
java.lang.String err)
Scans the input for an occurrence of a string pattern.
|
static Parser<_> |
Scanners.isPattern(java.lang.String name,
Pattern pp,
java.lang.String err)
Scans the input for an occurrence of a string pattern.
|
static Parser<_> |
Scanners.many(Pattern pp)
Scans greedily for 0 or more occurrences of the given pattern.
|
static Parser<_> |
Scanners.many(java.lang.String name,
Pattern pp)
Scans greedily for 0 or more occurrences of the given pattern.
|
static Parser<_> |
Scanners.many1(Pattern pp)
Scans greedily for 1 or more occurrences of the given pattern.
|
static Parser<_> |
Scanners.many1(java.lang.String name,
Pattern pp)
Scans greedily for 1 or more occurrences of the given pattern.
|
Modifier and Type | Method and Description |
---|---|
static Pattern |
Patterns.always()
A Pattern object that always matches with 0 length.
|
static Pattern |
Patterns.among(char[] cs)
Succeed with match length 1
if the current character in the input is among the given characters.
|
static Pattern |
Patterns.and(Pattern... pps)
Find the match length that matches
all of the patterns in the given Pattern object array.
|
static Pattern |
Patterns.chars_eq(int l)
Deprecated.
Use
Patterns.hasExact(int) instead. |
static Pattern |
Patterns.chars_ge(int l)
Deprecated.
Use
Patterns.hasAtLeast(int) instead. |
static Pattern |
Patterns.eof()
Ensures the input has no character left.
|
static Pattern |
Patterns.hasAtLeast(int l)
Ensures the input has at least l characters left.
|
static Pattern |
Patterns.hasExact(int l)
Ensures the input has exactly l characters left.
|
Pattern |
Pattern.ifelse(Pattern yes,
Pattern no)
If this pattern matches,
match the remaining input against Pattern object yes.
|
static Pattern |
Patterns.ifelse(Pattern cond,
Pattern yes,
Pattern no)
If the condiction Pattern object cond matches,
match the remaining input against Pattern object yes.
|
static Pattern |
Patterns.isChar(char c)
Succeed with match length 1
if the current character in the input is same as character c.
|
static Pattern |
Patterns.isChar(CharPredicate cp)
Succeed with match length 1
if the current character in the input satisfies the given predicate.
|
static Pattern |
Patterns.isDecimal()
Recognizes a decimal number that can start with a decimal point.
|
static Pattern |
Patterns.isDecimalL()
a decimal number that has at least one number before the decimal point.
|
static Pattern |
Patterns.isDecimalR()
Recognizes a decimal point and 1 or more digits after it.
|
static Pattern |
Patterns.isDecInteger()
pattern for a decimal integer.
|
static Pattern |
Patterns.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 |
Patterns.isExponential()
Recognizes a the exponent part of a scientific number notation.
|
static Pattern |
Patterns.isHexInteger()
pattern for a hex integer.
|
static Pattern |
Patterns.isInteger()
pattern for an integer.
|
static Pattern |
Patterns.isLineComment(java.lang.String open)
Matches a line comment that starts with a string
and end with EOF or Line Feed character.
|
static Pattern |
Patterns.isOctInteger()
pattern for a octal integer that starts with a 0 and followed by 0 or more [0-7] characters.
|
static Pattern |
Patterns.isString(java.lang.String str)
Matches a string.
|
static Pattern |
Patterns.isStringCI(java.lang.String str)
Matches a string case insensitively.
|
static Pattern |
Patterns.isWord()
a pattern for a standard english word.
|
static Pattern |
Patterns.longer(Pattern p1,
Pattern p2)
Try two pattern objects, pick the one with the longer match length.
|
static Pattern |
Patterns.longest(Pattern... pps)
Try an array of pattern objects, pick the one with the longest match length.
|
Pattern |
Pattern.many()
Matches this pattern for 0 or more times.
|
static Pattern |
Patterns.many(CharPredicate cp)
Matches 0 or more characters that all satisfy the given predicate.
|
Pattern |
Pattern.many(int min)
Matches this pattern for at least min times.
|
static Pattern |
Patterns.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 |
Patterns.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 |
Patterns.many(Pattern pp)
Matches 0 or more occurrences of
patterns recognized by Pattern object pp.
|
Pattern |
Pattern.many1()
Matches this pattern for 1 or more times.
|
static Pattern |
Patterns.many1(CharPredicate cp)
Matches characters that satisfies the given predicate
for 1 or more times.
|
static Pattern |
Patterns.never()
A Pattern object that always returns MISMATCH.
|
Pattern |
Pattern.not()
If this pattern matches, return mismatch.
|
static Pattern |
Patterns.not(Pattern pp)
Matches with match length 0 if the Pattern object pp mismatch.
|
static Pattern |
Patterns.notAmong(char[] cs)
Succeed with match length 1
if the current character in the input is not among the given characters.
|
static Pattern |
Patterns.notChar(char c)
Succeed with match length 1
if the current character in the input is not the same as character c.
|
static Pattern |
Patterns.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 |
Patterns.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 |
Patterns.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.
|
Pattern |
Pattern.optional()
Match with 0 length even if this pattern mismatches.
|
static Pattern |
Patterns.optional(Pattern pp)
Match with 0 length even if Pattern object pp mismatches.
|
static Pattern |
Patterns.or(Pattern... pps)
try an array of Pattern objects subsequently until one matches.
|
static Pattern |
Patterns.or(Pattern pp1,
Pattern pp2)
if the first Pattern object pp1 mismatches, try the second Pattern object pp2.
|
Pattern |
Pattern.peek()
Matches with match length 0 if this Pattern object matches.
|
static Pattern |
Patterns.peek(Pattern pp)
Matches with match length 0 if the Pattern object pp matches.
|
static Pattern |
Patterns.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 |
Patterns.regex_modifiers()
Get the pattern that matches regular expression modifiers.
|
static Pattern |
Patterns.regex_pattern()
Get the Pattern object that matches any regular expression pattern
string in the form of /some pattern here/.
|
static Pattern |
Patterns.regex(java.util.regex.Pattern p)
Adapt a regular expression pattern to a jfun.parsec.pattern.Pattern;
|
static Pattern |
Patterns.regex(java.lang.String s)
Adapt a regular expression pattern string to a jfun.parsec.pattern.Pattern;
|
Pattern |
Pattern.repeat(int n)
Matches the input against this pattern for n times.
|
static Pattern |
Patterns.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 |
Patterns.repeat(int n,
Pattern pp)
Matches if the input n occurrences of Pattern pp.
|
static Pattern |
Patterns.seq(Pattern... pps)
Runs an array of Pattern objects subsequently until one mismatches.
|
Pattern |
Pattern.seq(Pattern p2)
First matches this pattern.
|
static Pattern |
Patterns.seq(Pattern pp1,
Pattern pp2)
First matches Pattern object pp1.
|
static Pattern |
Patterns.shorter(Pattern p1,
Pattern p2)
Try two pattern objects, pick the one with the shorter match length.
|
static Pattern |
Patterns.shortest(Pattern... pps)
Try an array of pattern objects, pick the one with the shortest match length.
|
Pattern |
Pattern.some(int max)
Matches this pattern for up to max times.
|
static Pattern |
Patterns.some(int max,
CharPredicate cp)
Matches at most max number of characters
that satisfies the given predicate.
|
Pattern |
Pattern.some(int min,
int max)
Matches this pattern for at least min times
and at most max times.
|
static Pattern |
Patterns.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 |
Patterns.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 |
Patterns.some(int max,
Pattern pp)
Matches at most max number of occurrences
of pattern recognized by Pattern object pp.
|
Modifier and Type | Method and Description |
---|---|
static Pattern |
Patterns.and(Pattern... pps)
Find the match length that matches
all of the patterns in the given Pattern object array.
|
Pattern |
Pattern.ifelse(Pattern yes,
Pattern no)
If this pattern matches,
match the remaining input against Pattern object yes.
|
static Pattern |
Patterns.ifelse(Pattern cond,
Pattern yes,
Pattern no)
If the condiction Pattern object cond matches,
match the remaining input against Pattern object yes.
|
static Pattern |
Patterns.longer(Pattern p1,
Pattern p2)
Try two pattern objects, pick the one with the longer match length.
|
static Pattern |
Patterns.longest(Pattern... pps)
Try an array of pattern objects, pick the one with the longest match length.
|
static Pattern |
Patterns.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 |
Patterns.many(Pattern pp)
Matches 0 or more occurrences of
patterns recognized by Pattern object pp.
|
static Pattern |
Patterns.not(Pattern pp)
Matches with match length 0 if the Pattern object pp mismatch.
|
static Pattern |
Patterns.optional(Pattern pp)
Match with 0 length even if Pattern object pp mismatches.
|
static Pattern |
Patterns.or(Pattern... pps)
try an array of Pattern objects subsequently until one matches.
|
static Pattern |
Patterns.or(Pattern pp1,
Pattern pp2)
if the first Pattern object pp1 mismatches, try the second Pattern object pp2.
|
static Pattern |
Patterns.peek(Pattern pp)
Matches with match length 0 if the Pattern object pp matches.
|
static Pattern |
Patterns.repeat(int n,
Pattern pp)
Matches if the input n occurrences of Pattern pp.
|
static Pattern |
Patterns.seq(Pattern... pps)
Runs an array of Pattern objects subsequently until one mismatches.
|
Pattern |
Pattern.seq(Pattern p2)
First matches this pattern.
|
static Pattern |
Patterns.seq(Pattern pp1,
Pattern pp2)
First matches Pattern object pp1.
|
static Pattern |
Patterns.shorter(Pattern p1,
Pattern p2)
Try two pattern objects, pick the one with the shorter match length.
|
static Pattern |
Patterns.shortest(Pattern... pps)
Try an array of pattern objects, pick the one with the shortest match length.
|
static Pattern |
Patterns.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 |
Patterns.some(int max,
Pattern pp)
Matches at most max number of occurrences
of pattern recognized by Pattern object pp.
|