Java Code Examples for jdk.nashorn.internal.runtime.regexp.joni.Config#USE_WARNING_REDUNDANT_NESTED_REPEAT_OPERATOR

The following examples show how to use jdk.nashorn.internal.runtime.regexp.joni.Config#USE_WARNING_REDUNDANT_NESTED_REPEAT_OPERATOR . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: QuantifierNode.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
@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;
}
 
Example 2
Source File: QuantifierNode.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
@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;
}
 
Example 3
Source File: QuantifierNode.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
@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;
}
 
Example 4
Source File: QuantifierNode.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
@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;
}
 
Example 5
Source File: QuantifierNode.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@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;
}
 
Example 6
Source File: QuantifierNode.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
@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;
}
 
Example 7
Source File: QuantifierNode.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
@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;
}
 
Example 8
Source File: QuantifierNode.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
@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;
}
 
Example 9
Source File: QuantifierNode.java    From jdk8u_nashorn with GNU General Public License v2.0 4 votes vote down vote up
@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;
}
 
Example 10
Source File: QuantifierNode.java    From nashorn with GNU General Public License v2.0 4 votes vote down vote up
@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;
}