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


Java Config.USE_WARNING_REDUNDANT_NESTED_REPEAT_OPERATOR属性代码示例

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


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

示例1: setQuantifier

@SuppressWarnings("fallthrough")
public int setQuantifier(final Node tgt, final boolean group, final ScanEnvironment env, final char[] chars, final int p, final int end) {
    if (lower == 1 && upper == 1) {
        return 1;
    }

    switch(tgt.getType()) {

    case STR:
        if (!group) {
            final StringNode sn = (StringNode)tgt;
            if (sn.canBeSplit()) {
                final StringNode n = sn.splitLastChar();
                if (n != null) {
                    setTarget(n);
                    return 2;
                }
            }
        }
        break;

    case QTFR:
        /* check redundant double repeat. */
        /* verbose warn (?:.?)? etc... but not warn (.?)? etc... */
        final QuantifierNode qnt = (QuantifierNode)tgt;
        final int nestQNum = popularNum();
        final int targetQNum = qnt.popularNum();

        if (Config.USE_WARNING_REDUNDANT_NESTED_REPEAT_OPERATOR) {
            if (!isByNumber() && !qnt.isByNumber() && env.syntax.warnReduntantNestedRepeat()) {
                switch(REDUCE_TABLE[targetQNum][nestQNum]) {
                case ASIS:
                    break;

                case DEL:
                    env.reg.getWarnings().warn(new String(chars, p, end) +
                            " redundant nested repeat operator");
                    break;

                default:
                    env.reg.getWarnings().warn(new String(chars, p, end) +
                            " nested repeat operator " + PopularQStr[targetQNum] +
                            " and " + PopularQStr[nestQNum] + " was replaced with '" +
                            ReduceQStr[REDUCE_TABLE[targetQNum][nestQNum].ordinal()] + "'");
                }
            }
        } // USE_WARNING_REDUNDANT_NESTED_REPEAT_OPERATOR

        if (targetQNum >= 0) {
            if (nestQNum >= 0) {
                reduceNestedQuantifier(qnt);
                return 0;
            } else if (targetQNum == 1 || targetQNum == 2) { /* * or + */
                /* (?:a*){n,m}, (?:a+){n,m} => (?:a*){n,n}, (?:a+){n,n} */
                if (!isRepeatInfinite(upper) && upper > 1 && greedy) {
                    upper = lower == 0 ? 1 : lower;
                }
            }
        }

    default:
        break;
    }

    setTarget(tgt);
    return 0;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:67,代码来源:QuantifierNode.java

示例2: setQuantifier

@SuppressWarnings("fallthrough")
public int setQuantifier(Node tgt, boolean group, ScanEnvironment env, char[] chars, int p, int end) {
    if (lower == 1 && upper == 1) return 1;

    switch(tgt.getType()) {

    case STR:
        if (!group) {
            StringNode sn = (StringNode)tgt;
            if (sn.canBeSplit()) {
                StringNode n = sn.splitLastChar();
                if (n != null) {
                    setTarget(n);
                    return 2;
                }
            }
        }
        break;

    case QTFR:
        /* check redundant double repeat. */
        /* verbose warn (?:.?)? etc... but not warn (.?)? etc... */
        QuantifierNode qnt = (QuantifierNode)tgt;
        int nestQNum = popularNum();
        int targetQNum = qnt.popularNum();

        if (Config.USE_WARNING_REDUNDANT_NESTED_REPEAT_OPERATOR) {
            if (!isByNumber() && !qnt.isByNumber() && env.syntax.warnReduntantNestedRepeat()) {
                switch(REDUCE_TABLE[targetQNum][nestQNum]) {
                case ASIS:
                    break;

                case DEL:
                    env.reg.getWarnings().warn(new String(chars, p, end) +
                            " redundant nested repeat operator");
                    break;

                default:
                    env.reg.getWarnings().warn(new String(chars, p, end) +
                            " nested repeat operator " + PopularQStr[targetQNum] +
                            " and " + PopularQStr[nestQNum] + " was replaced with '" +
                            ReduceQStr[REDUCE_TABLE[targetQNum][nestQNum].ordinal()] + "'");
                }
            }
        } // USE_WARNING_REDUNDANT_NESTED_REPEAT_OPERATOR

        if (targetQNum >= 0) {
            if (nestQNum >= 0) {
                reduceNestedQuantifier(qnt);
                return 0;
            } else if (targetQNum == 1 || targetQNum == 2) { /* * or + */
                /* (?:a*){n,m}, (?:a+){n,m} => (?:a*){n,n}, (?:a+){n,n} */
                if (!isRepeatInfinite(upper) && upper > 1 && greedy) {
                    upper = lower == 0 ? 1 : lower;
                }
            }
        }

    default:
        break;
    }

    setTarget(tgt);
    return 0;
}
 
开发者ID:RedlineResearch,项目名称:OLD-OpenJDK8,代码行数:65,代码来源:QuantifierNode.java


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