jdk.nashorn.internal.runtime.regexp.joni.exception.SyntaxException Java Examples

The following examples show how to use jdk.nashorn.internal.runtime.regexp.joni.exception.SyntaxException. 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: Analyser.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example #2
Source File: Analyser.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example #3
Source File: Analyser.java    From jdk8u_nashorn with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example #4
Source File: Analyser.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
private Node setupLookBehind(Node node) {
    AnchorNode an = (AnchorNode)node;
    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);
        } else {
            throw new SyntaxException(ERR_INVALID_LOOK_BEHIND_PATTERN);
        }
    }
    return node;
}
 
Example #5
Source File: Analyser.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example #6
Source File: Analyser.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example #7
Source File: Analyser.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
private Node setupLookBehind(Node node) {
    AnchorNode an = (AnchorNode)node;
    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);
        } else {
            throw new SyntaxException(ERR_INVALID_LOOK_BEHIND_PATTERN);
        }
    }
    return node;
}
 
Example #8
Source File: Analyser.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example #9
Source File: Lexer.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private int invalidRangeQuantifier(final boolean synAllow) {
    if (synAllow) {
        restore();
        return 1;
    }
    throw new SyntaxException(ERR_INVALID_REPEAT_RANGE_PATTERN);
}
 
Example #10
Source File: CClassNode.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public void nextStateClass(final CCStateArg arg, final ScanEnvironment env) {
    if (arg.state == CCSTATE.RANGE) {
        throw new SyntaxException(ErrorMessages.ERR_CHAR_CLASS_VALUE_AT_END_OF_RANGE);
    }

    if (arg.state == CCSTATE.VALUE && arg.type != CCVALTYPE.CLASS) {
        if (arg.type == CCVALTYPE.SB) {
            bs.set(arg.vs);
        } else if (arg.type == CCVALTYPE.CODE_POINT) {
            addCodeRange(env, arg.vs, arg.vs);
        }
    }
    arg.state = CCSTATE.VALUE;
    arg.type = CCVALTYPE.CLASS;
}
 
Example #11
Source File: Lexer.java    From jdk8u_nashorn with GNU General Public License v2.0 5 votes vote down vote up
private int invalidRangeQuantifier(final boolean synAllow) {
    if (synAllow) {
        restore();
        return 1;
    }
    throw new SyntaxException(ERR_INVALID_REPEAT_RANGE_PATTERN);
}
 
Example #12
Source File: Lexer.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private int invalidRangeQuantifier(boolean synAllow) {
    if (synAllow) {
        restore();
        return 1;
    } else {
        throw new SyntaxException(ERR_INVALID_REPEAT_RANGE_PATTERN);
    }
}
 
Example #13
Source File: Lexer.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private int invalidRangeQuantifier(final boolean synAllow) {
    if (synAllow) {
        restore();
        return 1;
    }
    throw new SyntaxException(ERR_INVALID_REPEAT_RANGE_PATTERN);
}
 
Example #14
Source File: Lexer.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private void fetchEscapedValueControl() {
    if (!left()) {
        throw new SyntaxException(ERR_END_PATTERN_AT_CONTROL);
    }
    fetch();
    if (c == '?') {
        c = 0177;
    } else {
        if (c == syntax.metaCharTable.esc) {
            c = fetchEscapedValue();
        }
        c &= 0x9f;
    }
}
 
Example #15
Source File: CClassNode.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public void nextStateClass(final CCStateArg arg, final ScanEnvironment env) {
    if (arg.state == CCSTATE.RANGE) {
        throw new SyntaxException(ErrorMessages.ERR_CHAR_CLASS_VALUE_AT_END_OF_RANGE);
    }

    if (arg.state == CCSTATE.VALUE && arg.type != CCVALTYPE.CLASS) {
        if (arg.type == CCVALTYPE.SB) {
            bs.set(arg.vs);
        } else if (arg.type == CCVALTYPE.CODE_POINT) {
            addCodeRange(env, arg.vs, arg.vs);
        }
    }
    arg.state = CCSTATE.VALUE;
    arg.type = CCVALTYPE.CLASS;
}
 
Example #16
Source File: Lexer.java    From jdk8u_nashorn with GNU General Public License v2.0 5 votes vote down vote up
private void fetchEscapedValueControl() {
    if (!left()) {
        throw new SyntaxException(ERR_END_PATTERN_AT_CONTROL);
    }
    fetch();
    if (c == '?') {
        c = 0177;
    } else {
        if (c == syntax.metaCharTable.esc) {
            c = fetchEscapedValue();
        }
        c &= 0x9f;
    }
}
 
Example #17
Source File: Lexer.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private int invalidRangeQuantifier(boolean synAllow) {
    if (synAllow) {
        restore();
        return 1;
    } else {
        throw new SyntaxException(ERR_INVALID_REPEAT_RANGE_PATTERN);
    }
}
 
Example #18
Source File: Lexer.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private int invalidRangeQuantifier(final boolean synAllow) {
    if (synAllow) {
        restore();
        return 1;
    }
    throw new SyntaxException(ERR_INVALID_REPEAT_RANGE_PATTERN);
}
 
Example #19
Source File: CClassNode.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public void nextStateClass(final CCStateArg arg, final ScanEnvironment env) {
    if (arg.state == CCSTATE.RANGE) {
        throw new SyntaxException(ErrorMessages.ERR_CHAR_CLASS_VALUE_AT_END_OF_RANGE);
    }

    if (arg.state == CCSTATE.VALUE && arg.type != CCVALTYPE.CLASS) {
        if (arg.type == CCVALTYPE.SB) {
            bs.set(arg.vs);
        } else if (arg.type == CCVALTYPE.CODE_POINT) {
            addCodeRange(env, arg.vs, arg.vs);
        }
    }
    arg.state = CCSTATE.VALUE;
    arg.type = CCVALTYPE.CLASS;
}
 
Example #20
Source File: Lexer.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private void fetchEscapedValueControl() {
    if (!left()) {
        throw new SyntaxException(ERR_END_PATTERN_AT_CONTROL);
    }
    fetch();
    if (c == '?') {
        c = 0177;
    } else {
        if (c == syntax.metaCharTable.esc) {
            c = fetchEscapedValue();
        }
        c &= 0x9f;
    }
}
 
Example #21
Source File: Parser.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example #22
Source File: Parser.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private void parseSubExpError(TokenType term) {
    if (term == TokenType.SUBEXP_CLOSE) {
        throw new SyntaxException(ERR_END_PATTERN_WITH_UNMATCHED_PARENTHESIS);
    } else {
        throw new InternalException(ERR_PARSER_BUG);
    }
}
 
Example #23
Source File: CClassNode.java    From jdk8u_nashorn with GNU General Public License v2.0 5 votes vote down vote up
public void nextStateClass(final CCStateArg arg, final ScanEnvironment env) {
    if (arg.state == CCSTATE.RANGE) {
        throw new SyntaxException(ErrorMessages.ERR_CHAR_CLASS_VALUE_AT_END_OF_RANGE);
    }

    if (arg.state == CCSTATE.VALUE && arg.type != CCVALTYPE.CLASS) {
        if (arg.type == CCVALTYPE.SB) {
            bs.set(arg.vs);
        } else if (arg.type == CCVALTYPE.CODE_POINT) {
            addCodeRange(env, arg.vs, arg.vs);
        }
    }
    arg.state = CCSTATE.VALUE;
    arg.type = CCVALTYPE.CLASS;
}
 
Example #24
Source File: Parser.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private Node parseExpRepeat(Node target, boolean group) {
    while (token.type == TokenType.OP_REPEAT || token.type == TokenType.INTERVAL) { // repeat:
        if (target.isInvalidQuantifier()) {
            throw new SyntaxException(ERR_TARGET_OF_REPEAT_OPERATOR_INVALID);
        }

        QuantifierNode qtfr = new QuantifierNode(token.getRepeatLower(),
                                                 token.getRepeatUpper(),
                                                 token.type == TokenType.INTERVAL);

        qtfr.greedy = token.getRepeatGreedy();
        int ret = qtfr.setQuantifier(target, group, env, chars, getBegin(), getEnd());
        Node qn = qtfr;

        if (token.getRepeatPossessive()) {
            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);
            ConsAltNode tmp = ((ConsAltNode)target).setCdr(ConsAltNode.newListNode(qn, null));

            fetchToken();
            return parseExpRepeatForCar(target, tmp, group);
        }
        fetchToken(); // goto re_entry
    }
    return target;
}
 
Example #25
Source File: Lexer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private void fetchEscapedValueControl() {
    if (!left()) {
        throw new SyntaxException(ERR_END_PATTERN_AT_CONTROL);
    }
    fetch();
    if (c == '?') {
        c = 0177;
    } else {
        if (c == syntax.metaCharTable.esc) {
            c = fetchEscapedValue();
        }
        c &= 0x9f;
    }
}
 
Example #26
Source File: CClassNode.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public void nextStateClass(final CCStateArg arg, final ScanEnvironment env) {
    if (arg.state == CCSTATE.RANGE) {
        throw new SyntaxException(ErrorMessages.ERR_CHAR_CLASS_VALUE_AT_END_OF_RANGE);
    }

    if (arg.state == CCSTATE.VALUE && arg.type != CCVALTYPE.CLASS) {
        if (arg.type == CCVALTYPE.SB) {
            bs.set(arg.vs);
        } else if (arg.type == CCVALTYPE.CODE_POINT) {
            addCodeRange(env, arg.vs, arg.vs);
        }
    }
    arg.state = CCSTATE.VALUE;
    arg.type = CCVALTYPE.CLASS;
}
 
Example #27
Source File: CClassNode.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public void nextStateClass(CCStateArg arg, ScanEnvironment env) {
    if (arg.state == CCSTATE.RANGE) throw new SyntaxException(ErrorMessages.ERR_CHAR_CLASS_VALUE_AT_END_OF_RANGE);

    if (arg.state == CCSTATE.VALUE && arg.type != CCVALTYPE.CLASS) {
        if (arg.type == CCVALTYPE.SB) {
            bs.set(arg.vs);
        } else if (arg.type == CCVALTYPE.CODE_POINT) {
            addCodeRange(env, arg.vs, arg.vs);
        }
    }
    arg.state = CCSTATE.VALUE;
    arg.type = CCVALTYPE.CLASS;
}
 
Example #28
Source File: Parser.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example #29
Source File: Lexer.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private int invalidRangeQuantifier(final boolean synAllow) {
    if (synAllow) {
        restore();
        return 1;
    }
    throw new SyntaxException(ERR_INVALID_REPEAT_RANGE_PATTERN);
}
 
Example #30
Source File: Lexer.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private void fetchEscapedValueControl() {
    if (!left()) {
        throw new SyntaxException(ERR_END_PATTERN_AT_CONTROL);
    }
    fetch();
    if (c == '?') {
        c = 0177;
    } else {
        if (c == syntax.metaCharTable.esc) {
            c = fetchEscapedValue();
        }
        c &= 0x9f;
    }
}