Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static final class Ques extends Node {
- Node atom;
- int type;
- Ques(Node node, int type) {
- this.atom = node;
- this.type = type;
- }
- boolean match(Matcher matcher, int i, CharSequence seq) {
- switch (type) {
- case GREEDY:
- return (atom.match(matcher, i, seq) && next.match(matcher, matcher.last, seq))
- || next.match(matcher, i, seq);
- case LAZY:
- return next.match(matcher, i, seq)
- || (atom.match(matcher, i, seq) && next.match(matcher, matcher.last, seq));
- case POSSESSIVE:
- if (atom.match(matcher, i, seq)) i = matcher.last;
- return next.match(matcher, i, seq);
- default:
- return atom.match(matcher, i, seq) && next.match(matcher, matcher.last, seq);
- }
- }
- boolean study(TreeInfo info) {
- if (type != INDEPENDENT) {
- int minL = info.minLength;
- atom.study(info);
- info.minLength = minL;
- info.deterministic = false;
- return next.study(info);
- } else {
- atom.study(info);
- return next.study(info);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment