case NodeType.CTYPE: {
int min;
int max = enc.maxLengthDistance();
if (max == 1) {
min = 1;
CTypeNode cn = (CTypeNode)node;
switch (cn.ctype) {
case CharacterType.WORD:
if (cn.not) {
for (int i=0; i<BitSet.SINGLE_BYTE_SIZE; i++) {
if (!enc.isWord(i)) {
opt.map.addChar((byte)i, enc);
}
}
} else {
for (int i=0; i<BitSet.SINGLE_BYTE_SIZE; i++) {
if (enc.isWord(i)) {
opt.map.addChar((byte)i, enc);
}
}
}
break;
} // inner switch
} else {
min = enc.minLength();
}
opt.length.set(min, max);
break;
}
case NodeType.CANY: {
opt.length.set(enc.minLength(), enc.maxLengthDistance());
break;
}
case NodeType.ANCHOR: {
AnchorNode an = (AnchorNode)node;
switch (an.type) {
case AnchorType.BEGIN_BUF:
case AnchorType.BEGIN_POSITION:
case AnchorType.BEGIN_LINE:
case AnchorType.END_BUF:
case AnchorType.SEMI_END_BUF:
case AnchorType.END_LINE:
opt.anchor.add(an.type);
break;
case AnchorType.PREC_READ:
NodeOptInfo nopt = new NodeOptInfo();
optimizeNodeLeft(an.target, nopt, oenv);
if (nopt.exb.length > 0) {
opt.expr.copy(nopt.exb);
} else if (nopt.exm.length > 0) {
opt.expr.copy(nopt.exm);
}
opt.expr.reachEnd = false;
if (nopt.map.value > 0) opt.map.copy(nopt.map);
break;
case AnchorType.PREC_READ_NOT:
case AnchorType.LOOK_BEHIND: /* Sorry, I can't make use of it. */
case AnchorType.LOOK_BEHIND_NOT:
break;
} // inner switch
break;
}
case NodeType.BREF: {
BackRefNode br = (BackRefNode)node;
if (br.isRecursion()) {
opt.length.set(0, MinMaxLen.INFINITE_DISTANCE);
break;
}
Node[]nodes = oenv.scanEnv.memNodes;
int min = 0;
int max = 0;
if (nodes != null && nodes[br.back[0]] != null) {
min = getMinMatchLength(nodes[br.back[0]]);
max = getMaxMatchLength(nodes[br.back[0]]);
}
for (int i=1; i<br.backNum; i++) {
if (nodes[br.back[i]] != null) {
int tmin = getMinMatchLength(nodes[br.back[i]]);
int tmax = getMaxMatchLength(nodes[br.back[i]]);
if (min > tmin) min = tmin;
if (max < tmax) max = tmax;
}
}
opt.length.set(min, max);
break;
}
case NodeType.CALL: {
if (Config.USE_SUBEXP_CALL) {
CallNode cn = (CallNode)node;
if (cn.isRecursion()) {
opt.length.set(0, MinMaxLen.INFINITE_DISTANCE);
} else {
int safe = oenv.options;
oenv.options = ((EncloseNode)cn.target).option;
optimizeNodeLeft(cn.target, opt, oenv);