T - public class Difference<T> extends Parser<T>
Difference parser matches the prefix of the parse buffer if
the left parser matches and the right parser does
not.
The following is a complicated way of constructing a parser which matches a
digit:
Parser p = Parser.difference(Chset.ALNUM, Chset.ALPHA);
p.parse("0") -> matches "0"
p.parse("a") -> no matchParser| Constructor and Description |
|---|
Difference(Parser<? super T> left,
Parser<? super T> right)
Class constructor.
|
| Modifier and Type | Method and Description |
|---|---|
int |
parse(char[] buf,
int start,
int end,
T data)
Matches the prefix of the buffer (
buf[start,end)) being
parsed if, and only if, the left sub-parser matches the
incoming state of the buffer and the right sub-parser does
not match the incoming state of the parse buffer. |
public int parse(char[] buf,
int start,
int end,
T data)
buf[start,end)) being
parsed if, and only if, the left sub-parser matches the
incoming state of the buffer and the right sub-parser does
not match the incoming state of the parse buffer. It does not make much
sense to specify a right sub-parser that matches the empty
string as doing so will cause this function to always return
NO_MATCH.parse in class Parser<T>buf - The character array to match against.start - The start offset of data within the character array to match
against.end - The end offset of data within the character array to match
against.data - User defined object that is passed to
Callback.handle when an Action fires.Parser.parse(char[], int, int, T)