public interface TokenMatcher
TokenPattern that will match the sequence the
pattern describes. Matchers keep track of their matching state and are
designed for easy use together with Handler:
new DefaultHandler() {
TokenMatcher matcher = pattern.matcher();
public void token(Token token) {
if(matcher.add(token)) {
// This will be true if the pattern is matched
}
}
public void sentenceStart(Location location) {
// Reset matching when a new sentence is found
matcher.reset();
}
}
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(Token token)
Add a token to this matcher returning whether a match has now been found.
|
boolean |
end()
Indicate that this is the end of the current match sequence.
|
boolean |
isMatch()
Get if the matcher is currently matching.
|
void |
reset()
Reset the matching, for when tokens are no longer logically connected,
such as when new sentence has been started.
|
boolean add(Token token)
token - boolean end()
$ if used. In many
cases this would be called at the end of a sentence by a Handler.void reset()
boolean isMatch()
Copyright © 2018. All rights reserved.