当前位置: 首页>>代码示例>>Java>>正文


Java NodeType.CANY属性代码示例

本文整理汇总了Java中jdk.nashorn.internal.runtime.regexp.joni.constants.NodeType.CANY属性的典型用法代码示例。如果您正苦于以下问题:Java NodeType.CANY属性的具体用法?Java NodeType.CANY怎么用?Java NodeType.CANY使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在jdk.nashorn.internal.runtime.regexp.joni.constants.NodeType的用法示例。


在下文中一共展示了NodeType.CANY属性的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: compileNonCECLengthQuantifierNode

private int compileNonCECLengthQuantifierNode(final QuantifierNode qn) {
    final boolean infinite = isRepeatInfinite(qn.upper);
    final int emptyInfo = qn.targetEmptyInfo;

    final int tlen = compileLengthTree(qn.target);

    /* anychar repeat */
    if (qn.target.getType() == NodeType.CANY) {
        if (qn.greedy && infinite) {
            if (qn.nextHeadExact != null) {
                return OPSize.ANYCHAR_STAR_PEEK_NEXT + tlen * qn.lower;
            }
            return OPSize.ANYCHAR_STAR + tlen * qn.lower;
        }
    }

    int modTLen = 0;
    if (emptyInfo != 0) {
        modTLen = tlen + (OPSize.NULL_CHECK_START + OPSize.NULL_CHECK_END);
    } else {
        modTLen = tlen;
    }

    int len;
    if (infinite && (qn.lower <= 1 || tlen * qn.lower <= QUANTIFIER_EXPAND_LIMIT_SIZE)) {
        if (qn.lower == 1 && tlen > QUANTIFIER_EXPAND_LIMIT_SIZE) {
            len = OPSize.JUMP;
        } else {
            len = tlen * qn.lower;
        }

        if (qn.greedy) {
            if (qn.headExact != null) {
                len += OPSize.PUSH_OR_JUMP_EXACT1 + modTLen + OPSize.JUMP;
            } else if (qn.nextHeadExact != null) {
                len += OPSize.PUSH_IF_PEEK_NEXT + modTLen + OPSize.JUMP;
            } else {
                len += OPSize.PUSH + modTLen + OPSize.JUMP;
            }
        } else {
            len += OPSize.JUMP + modTLen + OPSize.PUSH;
        }

    } else if (qn.upper == 0 && qn.isRefered) { /* /(?<n>..){0}/ */
        len = OPSize.JUMP + tlen;
    } else if (!infinite && qn.greedy &&
              (qn.upper == 1 || (tlen + OPSize.PUSH) * qn.upper <= QUANTIFIER_EXPAND_LIMIT_SIZE )) {
        len = tlen * qn.lower;
        len += (OPSize.PUSH + tlen) * (qn.upper - qn.lower);
    } else if (!qn.greedy && qn.upper == 1 && qn.lower == 0) { /* '??' */
        len = OPSize.PUSH + OPSize.JUMP + tlen;
    } else {
        len = OPSize.REPEAT_INC + modTLen + OPSize.OPCODE + OPSize.RELADDR + OPSize.MEMNUM;
    }
    return len;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:56,代码来源:ArrayCompiler.java

示例2: compileLengthTree

private int compileLengthTree(final Node node) {
    int len = 0;

    switch (node.getType()) {
    case NodeType.LIST:
        ConsAltNode lin = (ConsAltNode)node;
        do {
            len += compileLengthTree(lin.car);
        } while ((lin = lin.cdr) != null);
        break;

    case NodeType.ALT:
        ConsAltNode aln = (ConsAltNode)node;
        int n = 0;
        do {
            len += compileLengthTree(aln.car);
            n++;
        } while ((aln = aln.cdr) != null);
        len += (OPSize.PUSH + OPSize.JUMP) * (n - 1);
        break;

    case NodeType.STR:
        final StringNode sn = (StringNode)node;
        if (sn.isRaw()) {
            len = compileLengthStringRawNode(sn);
        } else {
            len = compileLengthStringNode(sn);
        }
        break;

    case NodeType.CCLASS:
        len = compileLengthCClassNode((CClassNode)node);
        break;

    case NodeType.CTYPE:
    case NodeType.CANY:
        len = OPSize.OPCODE;
        break;

    case NodeType.BREF:
        final BackRefNode br = (BackRefNode)node;

        len = ((!isIgnoreCase(regex.options) && br.backRef <= 2)
                ? OPSize.OPCODE : (OPSize.OPCODE + OPSize.MEMNUM));
        break;

    case NodeType.QTFR:
        len = compileNonCECLengthQuantifierNode((QuantifierNode)node);
        break;

    case NodeType.ENCLOSE:
        len = compileLengthEncloseNode((EncloseNode)node);
        break;

    case NodeType.ANCHOR:
        len = compileLengthAnchorNode((AnchorNode)node);
        break;

    default:
        newInternalException(ERR_PARSER_BUG);

    } //switch
    return len;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:64,代码来源:ArrayCompiler.java

示例3: compileTree

protected final void compileTree(final Node node) {
    switch (node.getType()) {
    case NodeType.LIST:
        ConsAltNode lin = (ConsAltNode)node;
        do {
            compileTree(lin.car);
        } while ((lin = lin.cdr) != null);
        break;

    case NodeType.ALT:
        compileAltNode((ConsAltNode)node);
        break;

    case NodeType.STR:
        final StringNode sn = (StringNode)node;
        if (sn.isRaw()) {
            compileStringRawNode(sn);
        } else {
            compileStringNode(sn);
        }
        break;

    case NodeType.CCLASS:
        compileCClassNode((CClassNode)node);
        break;

    case NodeType.CANY:
        compileAnyCharNode();
        break;

    case NodeType.BREF:
        compileBackrefNode((BackRefNode)node);
        break;

    case NodeType.QTFR:
        compileNonCECQuantifierNode((QuantifierNode)node);
        break;

    case NodeType.ENCLOSE:
        final EncloseNode enode = (EncloseNode)node;
        if (enode.isOption()) {
            compileOptionNode(enode);
        } else {
            compileEncloseNode(enode);
        }
        break;

    case NodeType.ANCHOR:
        compileAnchorNode((AnchorNode)node);
        break;

    default:
        // undefined node type
        newInternalException(ERR_PARSER_BUG);
    } // switch
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:56,代码来源:Compiler.java

示例4: quantifiersMemoryInfo

private int quantifiersMemoryInfo(final Node node) {
    int info = 0;

    switch(node.getType()) {
    case NodeType.LIST:
    case NodeType.ALT:
        ConsAltNode can = (ConsAltNode)node;
        do {
            final int v = quantifiersMemoryInfo(can.car);
            if (v > info) {
                info = v;
            }
        } while ((can = can.cdr) != null);
        break;

    case NodeType.QTFR:
        final QuantifierNode qn = (QuantifierNode)node;
        if (qn.upper != 0) {
            info = quantifiersMemoryInfo(qn.target);
        }
        break;

    case NodeType.ENCLOSE:
        final EncloseNode en = (EncloseNode)node;
        switch (en.type) {
        case EncloseType.MEMORY:
            return TargetInfo.IS_EMPTY_MEM;

        case EncloseType.OPTION:
        case EncloseNode.STOP_BACKTRACK:
            info = quantifiersMemoryInfo(en.target);
            break;

        default:
            break;
        } // inner switch
        break;

    case NodeType.BREF:
    case NodeType.STR:
    case NodeType.CTYPE:
    case NodeType.CCLASS:
    case NodeType.CANY:
    case NodeType.ANCHOR:
    default:
        break;
    } // switch

    return info;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:50,代码来源:Analyser.java

示例5: compileNonCECLengthQuantifierNode

private int compileNonCECLengthQuantifierNode(QuantifierNode qn) {
    boolean infinite = isRepeatInfinite(qn.upper);
    int emptyInfo = qn.targetEmptyInfo;

    int tlen = compileLengthTree(qn.target);

    /* anychar repeat */
    if (qn.target.getType() == NodeType.CANY) {
        if (qn.greedy && infinite) {
            if (qn.nextHeadExact != null) {
                return OPSize.ANYCHAR_STAR_PEEK_NEXT + tlen * qn.lower;
            } else {
                return OPSize.ANYCHAR_STAR + tlen * qn.lower;
            }
        }
    }

    int modTLen = 0;
    if (emptyInfo != 0) {
        modTLen = tlen + (OPSize.NULL_CHECK_START + OPSize.NULL_CHECK_END);
    } else {
        modTLen = tlen;
    }

    int len;
    if (infinite && (qn.lower <= 1 || tlen * qn.lower <= QUANTIFIER_EXPAND_LIMIT_SIZE)) {
        if (qn.lower == 1 && tlen > QUANTIFIER_EXPAND_LIMIT_SIZE) {
            len = OPSize.JUMP;
        } else {
            len = tlen * qn.lower;
        }

        if (qn.greedy) {
            if (qn.headExact != null) {
                len += OPSize.PUSH_OR_JUMP_EXACT1 + modTLen + OPSize.JUMP;
            } else if (qn.nextHeadExact != null) {
                len += OPSize.PUSH_IF_PEEK_NEXT + modTLen + OPSize.JUMP;
            } else {
                len += OPSize.PUSH + modTLen + OPSize.JUMP;
            }
        } else {
            len += OPSize.JUMP + modTLen + OPSize.PUSH;
        }

    } else if (qn.upper == 0 && qn.isRefered) { /* /(?<n>..){0}/ */
        len = OPSize.JUMP + tlen;
    } else if (!infinite && qn.greedy &&
              (qn.upper == 1 || (tlen + OPSize.PUSH) * qn.upper <= QUANTIFIER_EXPAND_LIMIT_SIZE )) {
        len = tlen * qn.lower;
        len += (OPSize.PUSH + tlen) * (qn.upper - qn.lower);
    } else if (!qn.greedy && qn.upper == 1 && qn.lower == 0) { /* '??' */
        len = OPSize.PUSH + OPSize.JUMP + tlen;
    } else {
        len = OPSize.REPEAT_INC + modTLen + OPSize.OPCODE + OPSize.RELADDR + OPSize.MEMNUM;
    }
    return len;
}
 
开发者ID:RedlineResearch,项目名称:OLD-OpenJDK8,代码行数:57,代码来源:ArrayCompiler.java

示例6: compileLengthTree

private int compileLengthTree(Node node) {
    int len = 0;

    switch (node.getType()) {
    case NodeType.LIST:
        ConsAltNode lin = (ConsAltNode)node;
        do {
            len += compileLengthTree(lin.car);
        } while ((lin = lin.cdr) != null);
        break;

    case NodeType.ALT:
        ConsAltNode aln = (ConsAltNode)node;
        int n = 0;
        do {
            len += compileLengthTree(aln.car);
            n++;
        } while ((aln = aln.cdr) != null);
        len += (OPSize.PUSH + OPSize.JUMP) * (n - 1);
        break;

    case NodeType.STR:
        StringNode sn = (StringNode)node;
        if (sn.isRaw()) {
            len = compileLengthStringRawNode(sn);
        } else {
            len = compileLengthStringNode(sn);
        }
        break;

    case NodeType.CCLASS:
        len = compileLengthCClassNode((CClassNode)node);
        break;

    case NodeType.CTYPE:
    case NodeType.CANY:
        len = OPSize.OPCODE;
        break;

    case NodeType.BREF:
        BackRefNode br = (BackRefNode)node;

        len = ((!isIgnoreCase(regex.options) && br.backRef <= 2)
                ? OPSize.OPCODE : (OPSize.OPCODE + OPSize.MEMNUM));
        break;

    case NodeType.QTFR:
        len = compileNonCECLengthQuantifierNode((QuantifierNode)node);
        break;

    case NodeType.ENCLOSE:
        len = compileLengthEncloseNode((EncloseNode)node);
        break;

    case NodeType.ANCHOR:
        len = compileLengthAnchorNode((AnchorNode)node);
        break;

    default:
        newInternalException(ERR_PARSER_BUG);

    } //switch
    return len;
}
 
开发者ID:RedlineResearch,项目名称:OLD-OpenJDK8,代码行数:64,代码来源:ArrayCompiler.java

示例7: compileTree

protected final void compileTree(Node node) {
    switch (node.getType()) {
    case NodeType.LIST:
        ConsAltNode lin = (ConsAltNode)node;
        do {
            compileTree(lin.car);
        } while ((lin = lin.cdr) != null);
        break;

    case NodeType.ALT:
        compileAltNode((ConsAltNode)node);
        break;

    case NodeType.STR:
        StringNode sn = (StringNode)node;
        if (sn.isRaw()) {
            compileStringRawNode(sn);
        } else {
            compileStringNode(sn);
        }
        break;

    case NodeType.CCLASS:
        compileCClassNode((CClassNode)node);
        break;

    case NodeType.CANY:
        compileAnyCharNode();
        break;

    case NodeType.BREF:
        compileBackrefNode((BackRefNode)node);
        break;

    case NodeType.QTFR:
        compileNonCECQuantifierNode((QuantifierNode)node);
        break;

    case NodeType.ENCLOSE:
        EncloseNode enode = (EncloseNode)node;
        if (enode.isOption()) {
            compileOptionNode(enode);
        } else {
            compileEncloseNode(enode);
        }
        break;

    case NodeType.ANCHOR:
        compileAnchorNode((AnchorNode)node);
        break;

    default:
        // undefined node type
        newInternalException(ERR_PARSER_BUG);
    } // switch
}
 
开发者ID:RedlineResearch,项目名称:OLD-OpenJDK8,代码行数:56,代码来源:Compiler.java

示例8: quantifiersMemoryInfo

private int quantifiersMemoryInfo(Node node) {
    int info = 0;

    switch(node.getType()) {
    case NodeType.LIST:
    case NodeType.ALT:
        ConsAltNode can = (ConsAltNode)node;
        do {
            int v = quantifiersMemoryInfo(can.car);
            if (v > info) info = v;
        } while ((can = can.cdr) != null);
        break;

    case NodeType.QTFR:
        QuantifierNode qn = (QuantifierNode)node;
        if (qn.upper != 0) {
            info = quantifiersMemoryInfo(qn.target);
        }
        break;

    case NodeType.ENCLOSE:
        EncloseNode en = (EncloseNode)node;
        switch (en.type) {
        case EncloseType.MEMORY:
            return TargetInfo.IS_EMPTY_MEM;

        case EncloseType.OPTION:
        case EncloseNode.STOP_BACKTRACK:
            info = quantifiersMemoryInfo(en.target);
            break;

        default:
            break;
        } // inner switch
        break;

    case NodeType.BREF:
    case NodeType.STR:
    case NodeType.CTYPE:
    case NodeType.CCLASS:
    case NodeType.CANY:
    case NodeType.ANCHOR:
    default:
        break;
    } // switch

    return info;
}
 
开发者ID:RedlineResearch,项目名称:OLD-OpenJDK8,代码行数:48,代码来源:Analyser.java


注:本文中的jdk.nashorn.internal.runtime.regexp.joni.constants.NodeType.CANY属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。