jdk.nashorn.internal.runtime.regexp.joni.constants.TokenType Java Examples

The following examples show how to use jdk.nashorn.internal.runtime.regexp.joni.constants.TokenType. 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: Parser.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
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
    }
}
 
Example #2
Source File: Parser.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
private Node parseBranch(TokenType term) {
    Node node = parseExp(term);

    if (token.type == TokenType.EOT || token.type == term || token.type == TokenType.ALT) {
        return node;
    } else {
        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;
    }
}
 
Example #3
Source File: Lexer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
private void fetchTokenFor_uHex() {
    if (!left()) {
        return;
    }
    final int last = p;

    if (syntax.op2EscUHex4()) {
        int num = scanUnsignedHexadecimalNumber(4);
        if (num < 0) {
            throw new ValueException(ERR_TOO_BIG_NUMBER);
        }
        if (p == last) { /* can't read nothing. */
            num = 0; /* but, it's not error */
        }
        token.type = TokenType.CODE_POINT;
        token.setCode(num);
    }
}
 
Example #4
Source File: Lexer.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private void fetchTokenFor_digit() {
    unfetch();
    final int last = p;
    final int num = scanUnsignedNumber();
    if (num < 0 || num > Config.MAX_BACKREF_NUM) { // goto skip_backref
    } else if (syntax.opDecimalBackref() && (num <= env.numMem || num <= 9)) { /* This spec. from GNU regex */
        if (syntax.strictCheckBackref()) {
            if (num > env.numMem || env.memNodes == null || env.memNodes[num] == null) {
                throw new ValueException(ERR_INVALID_BACKREF);
            }
        }
        token.type = TokenType.BACKREF;
        token.setBackrefRef(num);
        return;
    }

    if (c == '8' || c == '9') { /* normal char */ // skip_backref:
        p = last;
        inc();
        return;
    }
    p = last;

    fetchTokenFor_zero(); /* fall through */
}
 
Example #5
Source File: Lexer.java    From jdk8u_nashorn with GNU General Public License v2.0 6 votes vote down vote up
private void fetchTokenFor_digit() {
    unfetch();
    final int last = p;
    final int num = scanUnsignedNumber();
    if (num < 0 || num > Config.MAX_BACKREF_NUM) { // goto skip_backref
    } else if (syntax.opDecimalBackref() && (num <= env.numMem || num <= 9)) { /* This spec. from GNU regex */
        if (syntax.strictCheckBackref()) {
            if (num > env.numMem || env.memNodes == null || env.memNodes[num] == null) {
                throw new ValueException(ERR_INVALID_BACKREF);
            }
        }
        token.type = TokenType.BACKREF;
        token.setBackrefRef(num);
        return;
    }

    if (c == '8' || c == '9') { /* normal char */ // skip_backref:
        p = last;
        inc();
        return;
    }
    p = last;

    fetchTokenFor_zero(); /* fall through */
}
 
Example #6
Source File: Lexer.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private void fetchTokenFor_zero() {
    if (syntax.opEscOctal3()) {
        final int last = p;
        int num = scanUnsignedOctalNumber(c == '0' ? 2 : 3);
        if (num < 0) {
            throw new ValueException(ERR_TOO_BIG_NUMBER);
        }
        if (p == last) { /* can't read nothing. */
            num = 0; /* but, it's not error */
        }
        token.type = TokenType.RAW_BYTE;
        token.setC(num);
    } else if (c != '0') {
        inc();
    }
}
 
Example #7
Source File: Lexer.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
private void fetchTokenInCCFor_u() {
    if (!left()) {
        return;
    }
    final int last = p;

    if (syntax.op2EscUHex4()) {
        int num = scanUnsignedHexadecimalNumber(4);
        if (num < 0) {
            throw new ValueException(ERR_TOO_BIG_NUMBER);
        }
        if (p == last) {  /* can't read nothing. */
            num = 0; /* but, it's not error */
        }
        token.type = TokenType.CODE_POINT;
        token.setCode(num);
    }
}
 
Example #8
Source File: Parser.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
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
}
 
Example #9
Source File: Lexer.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
private void fetchTokenFor_zero() {
    if (syntax.opEscOctal3()) {
        int last = p;
        int num = scanUnsignedOctalNumber(c == '0' ? 2 : 3);
        if (num < 0) {
            throw new ValueException(ERR_TOO_BIG_NUMBER);
        }
        if (p == last) { /* can't read nothing. */
            num = 0; /* but, it's not error */
        }
        token.type = TokenType.RAW_BYTE;
        token.setC(num);
    } else if (c != '0') {
        inc();
    }
}
 
Example #10
Source File: Lexer.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
private void fetchTokenFor_uHex() {
    if (!left()) return;
    int last = p;

    if (syntax.op2EscUHex4()) {
        int num = scanUnsignedHexadecimalNumber(4);
        if (num < 0) {
            throw new ValueException(ERR_TOO_BIG_NUMBER);
        }
        if (p == last) { /* can't read nothing. */
            num = 0; /* but, it's not error */
        }
        token.type = TokenType.CODE_POINT;
        token.setCode(num);
    }
}
 
Example #11
Source File: Parser.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example #12
Source File: Lexer.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
private void fetchTokenFor_digit() {
    unfetch();
    final int last = p;
    final int num = scanUnsignedNumber();
    if (num < 0 || num > Config.MAX_BACKREF_NUM) { // goto skip_backref
    } else if (syntax.opDecimalBackref() && (num <= env.numMem || num <= 9)) { /* This spec. from GNU regex */
        if (syntax.strictCheckBackref()) {
            if (num > env.numMem || env.memNodes == null || env.memNodes[num] == null) {
                throw new ValueException(ERR_INVALID_BACKREF);
            }
        }
        token.type = TokenType.BACKREF;
        token.setBackrefRef(num);
        return;
    }

    if (c == '8' || c == '9') { /* normal char */ // skip_backref:
        p = last;
        inc();
        return;
    }
    p = last;

    fetchTokenFor_zero(); /* fall through */
}
 
Example #13
Source File: Lexer.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private void fetchTokenFor_uHex() {
    if (!left()) {
        return;
    }
    final int last = p;

    if (syntax.op2EscUHex4()) {
        int num = scanUnsignedHexadecimalNumber(4);
        if (num < 0) {
            throw new ValueException(ERR_TOO_BIG_NUMBER);
        }
        if (p == last) { /* can't read nothing. */
            num = 0; /* but, it's not error */
        }
        token.type = TokenType.CODE_POINT;
        token.setCode(num);
    }
}
 
Example #14
Source File: Lexer.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private void fetchTokenFor_digit() {
    unfetch();
    final int last = p;
    final int num = scanUnsignedNumber();
    if (num < 0 || num > Config.MAX_BACKREF_NUM) { // goto skip_backref
    } else if (syntax.opDecimalBackref() && (num <= env.numMem || num <= 9)) { /* This spec. from GNU regex */
        if (syntax.strictCheckBackref()) {
            if (num > env.numMem || env.memNodes == null || env.memNodes[num] == null) {
                throw new ValueException(ERR_INVALID_BACKREF);
            }
        }
        token.type = TokenType.BACKREF;
        token.setBackrefRef(num);
        return;
    }

    if (c == '8' || c == '9') { /* normal char */ // skip_backref:
        p = last;
        inc();
        return;
    }
    p = last;

    fetchTokenFor_zero(); /* fall through */
}
 
Example #15
Source File: Parser.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
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
    }
}
 
Example #16
Source File: Lexer.java    From jdk8u_nashorn with GNU General Public License v2.0 6 votes vote down vote up
private void fetchTokenInCCFor_u() {
    if (!left()) {
        return;
    }
    final int last = p;

    if (syntax.op2EscUHex4()) {
        int num = scanUnsignedHexadecimalNumber(4);
        if (num < 0) {
            throw new ValueException(ERR_TOO_BIG_NUMBER);
        }
        if (p == last) {  /* can't read nothing. */
            num = 0; /* but, it's not error */
        }
        token.type = TokenType.CODE_POINT;
        token.setCode(num);
    }
}
 
Example #17
Source File: Lexer.java    From nashorn with GNU General Public License v2.0 6 votes vote down vote up
private void fetchTokenInCCFor_u() {
    if (!left()) return;
    int last = p;

    if (syntax.op2EscUHex4()) {
        int num = scanUnsignedHexadecimalNumber(4);
        if (num < 0) {
            throw new ValueException(ERR_TOO_BIG_NUMBER);
        }
        if (p == last) {  /* can't read nothing. */
            num = 0; /* but, it's not error */
        }
        token.type = TokenType.CODE_POINT;
        token.setCode(num);
    }
}
 
Example #18
Source File: Lexer.java    From nashorn with GNU General Public License v2.0 6 votes vote down vote up
private void fetchTokenFor_uHex() {
    if (!left()) return;
    int last = p;

    if (syntax.op2EscUHex4()) {
        int num = scanUnsignedHexadecimalNumber(4);
        if (num < 0) {
            throw new ValueException(ERR_TOO_BIG_NUMBER);
        }
        if (p == last) { /* can't read nothing. */
            num = 0; /* but, it's not error */
        }
        token.type = TokenType.CODE_POINT;
        token.setCode(num);
    }
}
 
Example #19
Source File: Lexer.java    From jdk8u_nashorn with GNU General Public License v2.0 6 votes vote down vote up
private void fetchTokenFor_uHex() {
    if (!left()) {
        return;
    }
    final int last = p;

    if (syntax.op2EscUHex4()) {
        int num = scanUnsignedHexadecimalNumber(4);
        if (num < 0) {
            throw new ValueException(ERR_TOO_BIG_NUMBER);
        }
        if (p == last) { /* can't read nothing. */
            num = 0; /* but, it's not error */
        }
        token.type = TokenType.CODE_POINT;
        token.setCode(num);
    }
}
 
Example #20
Source File: Parser.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
private Node parseSubExp(TokenType term) {
    Node node = parseBranch(term);

    if (token.type == term) {
        return node;
    } else if (token.type == TokenType.ALT) {
        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
    }
}
 
Example #21
Source File: Lexer.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private void fetchTokenInCCFor_u() {
    if (!left()) {
        return;
    }
    final int last = p;

    if (syntax.op2EscUHex4()) {
        int num = scanUnsignedHexadecimalNumber(4);
        if (num < 0) {
            throw new ValueException(ERR_TOO_BIG_NUMBER);
        }
        if (p == last) {  /* can't read nothing. */
            num = 0; /* but, it's not error */
        }
        token.type = TokenType.CODE_POINT;
        token.setCode(num);
    }
}
 
Example #22
Source File: Parser.java    From nashorn with GNU General Public License v2.0 6 votes vote down vote up
private Node parseBranch(TokenType term) {
    Node node = parseExp(term);

    if (token.type == TokenType.EOT || token.type == term || token.type == TokenType.ALT) {
        return node;
    } else {
        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;
    }
}
 
Example #23
Source File: Parser.java    From jdk8u_nashorn with GNU General Public License v2.0 6 votes vote down vote up
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
}
 
Example #24
Source File: Lexer.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private void fetchTokenFor_uHex() {
    if (!left()) {
        return;
    }
    final int last = p;

    if (syntax.op2EscUHex4()) {
        int num = scanUnsignedHexadecimalNumber(4);
        if (num < 0) {
            throw new ValueException(ERR_TOO_BIG_NUMBER);
        }
        if (p == last) { /* can't read nothing. */
            num = 0; /* but, it's not error */
        }
        token.type = TokenType.CODE_POINT;
        token.setCode(num);
    }
}
 
Example #25
Source File: Lexer.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
private void fetchTokenFor_digit() {
    unfetch();
    final int last = p;
    final int num = scanUnsignedNumber();
    if (num < 0 || num > Config.MAX_BACKREF_NUM) { // goto skip_backref
    } else if (syntax.opDecimalBackref() && (num <= env.numMem || num <= 9)) { /* This spec. from GNU regex */
        if (syntax.strictCheckBackref()) {
            if (num > env.numMem || env.memNodes == null || env.memNodes[num] == null) {
                throw new ValueException(ERR_INVALID_BACKREF);
            }
        }
        token.type = TokenType.BACKREF;
        token.setBackrefRef(num);
        return;
    }

    if (c == '8' || c == '9') { /* normal char */ // skip_backref:
        p = last;
        inc();
        return;
    }
    p = last;

    fetchTokenFor_zero(); /* fall through */
}
 
Example #26
Source File: Lexer.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
private void fetchTokenFor_zero() {
    if (syntax.opEscOctal3()) {
        final int last = p;
        int num = scanUnsignedOctalNumber(c == '0' ? 2 : 3);
        if (num < 0) {
            throw new ValueException(ERR_TOO_BIG_NUMBER);
        }
        if (p == last) { /* can't read nothing. */
            num = 0; /* but, it's not error */
        }
        token.type = TokenType.RAW_BYTE;
        token.setC(num);
    } else if (c != '0') {
        inc();
    }
}
 
Example #27
Source File: Lexer.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
private void fetchTokenFor_uHex() {
    if (!left()) return;
    int last = p;

    if (syntax.op2EscUHex4()) {
        int num = scanUnsignedHexadecimalNumber(4);
        if (num < 0) {
            throw new ValueException(ERR_TOO_BIG_NUMBER);
        }
        if (p == last) { /* can't read nothing. */
            num = 0; /* but, it's not error */
        }
        token.type = TokenType.CODE_POINT;
        token.setCode(num);
    }
}
 
Example #28
Source File: Parser.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example #29
Source File: Lexer.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
private void fetchTokenFor_zero() {
    if (syntax.opEscOctal3()) {
        final int last = p;
        int num = scanUnsignedOctalNumber(c == '0' ? 2 : 3);
        if (num < 0) {
            throw new ValueException(ERR_TOO_BIG_NUMBER);
        }
        if (p == last) { /* can't read nothing. */
            num = 0; /* but, it's not error */
        }
        token.type = TokenType.RAW_BYTE;
        token.setC(num);
    } else if (c != '0') {
        inc();
    }
}
 
Example #30
Source File: Parser.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
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
    }
}