本文整理汇总了Java中jdk.nashorn.internal.runtime.regexp.joni.ast.Node类的典型用法代码示例。如果您正苦于以下问题:Java Node类的具体用法?Java Node怎么用?Java Node使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Node类属于jdk.nashorn.internal.runtime.regexp.joni.ast包,在下文中一共展示了Node类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: compileLengthStringNode
import jdk.nashorn.internal.runtime.regexp.joni.ast.Node; //导入依赖的package包/类
private static int compileLengthStringNode(final Node node) {
final StringNode sn = (StringNode)node;
if (sn.length() <= 0) {
return 0;
}
final boolean ambig = sn.isAmbig();
int p, prev;
p = prev = sn.p;
final int end = sn.end;
final char[] chars = sn.chars;
p++;
int slen = 1;
int rlen = 0;
while (p < end) {
slen++;
p++;
}
final int r = addCompileStringlength(chars, prev, slen, ambig);
rlen += r;
return rlen;
}
示例2: parseExpTkByte
import jdk.nashorn.internal.runtime.regexp.joni.ast.Node; //导入依赖的package包/类
private Node parseExpTkByte(final boolean group) {
final StringNode node = new StringNode(chars, token.backP, p); // tk_byte:
while (true) {
fetchToken();
if (token.type != TokenType.STRING) {
break;
}
if (token.backP == node.end) {
node.end = p; // non escaped character, remain shared, just increase shared range
} else {
node.cat(chars, token.backP, p); // non continuous string stream, need to COW
}
}
// targetp = node;
return parseExpRepeat(node, group); // string_end:, goto repeat
}
示例3: parseBranch
import jdk.nashorn.internal.runtime.regexp.joni.ast.Node; //导入依赖的package包/类
private Node parseBranch(final TokenType term) {
Node node = parseExp(term);
if (token.type == TokenType.EOT || token.type == term || token.type == TokenType.ALT) {
return node;
}
final ConsAltNode top = ConsAltNode.newListNode(node, null);
ConsAltNode t = top;
while (token.type != TokenType.EOT && token.type != term && token.type != TokenType.ALT) {
node = parseExp(term);
if (node.getType() == NodeType.LIST) {
t.setCdr((ConsAltNode)node);
while (((ConsAltNode)node).cdr != null ) {
node = ((ConsAltNode)node).cdr;
}
t = ((ConsAltNode)node);
} else {
t.setCdr(ConsAltNode.newListNode(node, null));
t = t.cdr;
}
}
return top;
}
示例4: parseSubExp
import jdk.nashorn.internal.runtime.regexp.joni.ast.Node; //导入依赖的package包/类
private Node parseSubExp(final TokenType term) {
Node node = parseBranch(term);
if (token.type == term) {
return node;
} else if (token.type == TokenType.ALT) {
final ConsAltNode top = ConsAltNode.newAltNode(node, null);
ConsAltNode t = top;
while (token.type == TokenType.ALT) {
fetchToken();
node = parseBranch(term);
t.setCdr(ConsAltNode.newAltNode(node, null));
t = t.cdr;
}
if (token.type != term) {
parseSubExpError(term);
}
return top;
} else {
parseSubExpError(term);
return null; //not reached
}
}
示例5: setupLookBehind
import jdk.nashorn.internal.runtime.regexp.joni.ast.Node; //导入依赖的package包/类
private Node setupLookBehind(final Node node) {
final AnchorNode an = (AnchorNode)node;
final int len = getCharLengthTree(an.target);
switch (returnCode) {
case 0:
an.charLength = len;
break;
case GET_CHAR_LEN_VARLEN:
throw new SyntaxException(ERR_INVALID_LOOK_BEHIND_PATTERN);
case GET_CHAR_LEN_TOP_ALT_VARLEN:
if (syntax.differentLengthAltLookBehind()) {
return divideLookBehindAlternatives(node);
}
throw new SyntaxException(ERR_INVALID_LOOK_BEHIND_PATTERN);
default:
break;
}
return node;
}
示例6: compileTreeEmptyCheck
import jdk.nashorn.internal.runtime.regexp.joni.ast.Node; //导入依赖的package包/类
private void compileTreeEmptyCheck(final Node node, final int emptyInfo) {
final int savedNumNullCheck = regex.numNullCheck;
if (emptyInfo != 0) {
addOpcode(OPCode.NULL_CHECK_START);
addMemNum(regex.numNullCheck); /* NULL CHECK ID */
regex.numNullCheck++;
}
compileTree(node);
if (emptyInfo != 0) {
switch (emptyInfo) {
case TargetInfo.IS_EMPTY:
addOpcode(OPCode.NULL_CHECK_END);
break;
case TargetInfo.IS_EMPTY_MEM:
addOpcode(OPCode.NULL_CHECK_END_MEMST);
break;
default:
break;
} // switch
addMemNum(savedNumNullCheck); /* NULL CHECK ID */
}
}
示例7: addMemEntry
import jdk.nashorn.internal.runtime.regexp.joni.ast.Node; //导入依赖的package包/类
public int addMemEntry() {
if (numMem++ == 0) {
memNodes = new Node[SCANENV_MEMNODES_SIZE];
} else if (numMem >= memNodes.length) {
final Node[]tmp = new Node[memNodes.length << 1];
System.arraycopy(memNodes, 0, tmp, 0, memNodes.length);
memNodes = tmp;
}
return numMem;
}
示例8: setMemNode
import jdk.nashorn.internal.runtime.regexp.joni.ast.Node; //导入依赖的package包/类
public void setMemNode(final int num, final Node node) {
if (numMem >= num) {
memNodes[num] = node;
} else {
throw new InternalException(ErrorMessages.ERR_PARSER_BUG);
}
}
示例9: compileTreeEmptyCheck
import jdk.nashorn.internal.runtime.regexp.joni.ast.Node; //导入依赖的package包/类
private void compileTreeEmptyCheck(final Node node, final int emptyInfo) {
final int savedNumNullCheck = regex.numNullCheck;
if (emptyInfo != 0) {
addOpcode(OPCode.NULL_CHECK_START);
addMemNum(regex.numNullCheck); /* NULL CHECK ID */
regex.numNullCheck++;
}
compileTree(node);
if (emptyInfo != 0) {
switch (emptyInfo) {
case TargetInfo.IS_EMPTY:
addOpcode(OPCode.NULL_CHECK_END);
break;
case TargetInfo.IS_EMPTY_MEM:
addOpcode(OPCode.NULL_CHECK_END_MEMST);
break;
case TargetInfo.IS_EMPTY_REC:
addOpcode(OPCode.NULL_CHECK_END_MEMST_PUSH);
break;
default:
break;
} // switch
addMemNum(savedNumNullCheck); /* NULL CHECK ID */
}
}
示例10: parseExpTkRawByte
import jdk.nashorn.internal.runtime.regexp.joni.ast.Node; //导入依赖的package包/类
private Node parseExpTkRawByte(final boolean group) {
// tk_raw_byte:
// important: we don't use 0xff mask here neither in the compiler
// (in the template string) so we won't have to mask target
// strings when comparing against them in the matcher
final StringNode node = new StringNode((char)token.getC());
node.setRaw();
fetchToken();
node.clearRaw();
// !goto string_end;!
return parseExpRepeat(node, group);
}
示例11: parseExpRepeat
import jdk.nashorn.internal.runtime.regexp.joni.ast.Node; //导入依赖的package包/类
private Node parseExpRepeat(final Node targetp, final boolean group) {
Node target = targetp;
while (token.type == TokenType.OP_REPEAT || token.type == TokenType.INTERVAL) { // repeat:
if (target.isInvalidQuantifier()) {
throw new SyntaxException(ERR_TARGET_OF_REPEAT_OPERATOR_INVALID);
}
final QuantifierNode qtfr = new QuantifierNode(token.getRepeatLower(),
token.getRepeatUpper(),
token.type == TokenType.INTERVAL);
qtfr.greedy = token.getRepeatGreedy();
final int ret = qtfr.setQuantifier(target, group, env, chars, getBegin(), getEnd());
Node qn = qtfr;
if (token.getRepeatPossessive()) {
final EncloseNode en = new EncloseNode(EncloseType.STOP_BACKTRACK); // node_new_enclose
en.setTarget(qn);
qn = en;
}
if (ret == 0) {
target = qn;
} else if (ret == 2) { /* split case: /abc+/ */
target = ConsAltNode.newListNode(target, null);
final ConsAltNode tmp = ((ConsAltNode)target).setCdr(ConsAltNode.newListNode(qn, null));
fetchToken();
return parseExpRepeatForCar(target, tmp, group);
}
fetchToken(); // goto re_entry
}
return target;
}
示例12: parseExpRepeatForCar
import jdk.nashorn.internal.runtime.regexp.joni.ast.Node; //导入依赖的package包/类
private Node parseExpRepeatForCar(final Node top, final ConsAltNode target, final boolean group) {
while (token.type == TokenType.OP_REPEAT || token.type == TokenType.INTERVAL) { // repeat:
if (target.car.isInvalidQuantifier()) {
throw new SyntaxException(ERR_TARGET_OF_REPEAT_OPERATOR_INVALID);
}
final QuantifierNode qtfr = new QuantifierNode(token.getRepeatLower(),
token.getRepeatUpper(),
token.type == TokenType.INTERVAL);
qtfr.greedy = token.getRepeatGreedy();
final int ret = qtfr.setQuantifier(target.car, group, env, chars, getBegin(), getEnd());
Node qn = qtfr;
if (token.getRepeatPossessive()) {
final EncloseNode en = new EncloseNode(EncloseType.STOP_BACKTRACK); // node_new_enclose
en.setTarget(qn);
qn = en;
}
if (ret == 0) {
target.setCar(qn);
} else if (ret == 2) { /* split case: /abc+/ */
assert false;
}
fetchToken(); // goto re_entry
}
return top;
}