Java Code Examples for jdk.nashorn.internal.runtime.regexp.joni.constants.TokenType#EOT

The following examples show how to use jdk.nashorn.internal.runtime.regexp.joni.constants.TokenType#EOT . 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 TencentKona-8 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 2
Source File: Parser.java    From jdk8u60 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 3
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 4
Source File: Parser.java    From openjdk-jdk8u 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 5
Source File: Parser.java    From openjdk-jdk8u-backup 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 6
Source File: Parser.java    From jdk8u_nashorn 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 7
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 8
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 9
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 10
Source File: Parser.java    From openjdk-8-source 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 11
Source File: Lexer.java    From nashorn with GNU General Public License v2.0 4 votes vote down vote up
protected final TokenType fetchTokenInCC() {
    if (!left()) {
        token.type = TokenType.EOT;
        return token.type;
    }

    fetch();
    token.type = TokenType.CHAR;
    token.setC(c);
    token.escaped = false;

    if (c == ']') {
        token.type = TokenType.CC_CLOSE;
    } else if (c == '-') {
        token.type = TokenType.CC_RANGE;
    } else if (c == syntax.metaCharTable.esc) {
        if (!syntax.backSlashEscapeInCC()) return token.type;
        if (!left()) {
            throw new SyntaxException(ERR_END_PATTERN_AT_ESCAPE);
        }
        fetch();
        token.escaped = true;
        token.setC(c);

        switch (c) {
        case 'w':
            fetchTokenInCCFor_charType(false, Config.NON_UNICODE_SDW ? CharacterType.W : CharacterType.WORD);
            break;
        case 'W':
            fetchTokenInCCFor_charType(true, Config.NON_UNICODE_SDW ? CharacterType.W : CharacterType.WORD);
            break;
        case 'd':
            fetchTokenInCCFor_charType(false, Config.NON_UNICODE_SDW ? CharacterType.D : CharacterType.DIGIT);
            break;
        case 'D':
            fetchTokenInCCFor_charType(true, Config.NON_UNICODE_SDW ? CharacterType.D : CharacterType.DIGIT);
            break;
        case 's':
            fetchTokenInCCFor_charType(false, Config.NON_UNICODE_SDW ? CharacterType.S : CharacterType.SPACE);
            break;
        case 'S':
            fetchTokenInCCFor_charType(true, Config.NON_UNICODE_SDW ? CharacterType.S : CharacterType.SPACE);
            break;
        case 'h':
            if (syntax.op2EscHXDigit()) fetchTokenInCCFor_charType(false, CharacterType.XDIGIT);
            break;
        case 'H':
            if (syntax.op2EscHXDigit()) fetchTokenInCCFor_charType(true, CharacterType.XDIGIT);
            break;
        case 'x':
            fetchTokenInCCFor_x();
            break;
        case 'u':
            fetchTokenInCCFor_u();
            break;
        case '0':
        case '1':
        case '2':
        case '3':
        case '4':
        case '5':
        case '6':
        case '7':
            fetchTokenInCCFor_digit();
            break;

        default:
            unfetch();
            int num = fetchEscapedValue();
            if (token.getC() != num) {
                token.setCode(num);
                token.type = TokenType.CODE_POINT;
            }
            break;
        } // switch

    } else if (c == '&') {
        fetchTokenInCCFor_and();
    }
    return token.type;
}
 
Example 12
Source File: Lexer.java    From jdk8u_nashorn with GNU General Public License v2.0 4 votes vote down vote up
protected final TokenType fetchTokenInCC() {
    if (!left()) {
        token.type = TokenType.EOT;
        return token.type;
    }

    fetch();
    token.type = TokenType.CHAR;
    token.setC(c);
    token.escaped = false;

    if (c == ']') {
        token.type = TokenType.CC_CLOSE;
    } else if (c == '-') {
        token.type = TokenType.CC_RANGE;
    } else if (c == syntax.metaCharTable.esc) {
        if (!syntax.backSlashEscapeInCC()) {
            return token.type;
        }
        if (!left()) {
            throw new SyntaxException(ERR_END_PATTERN_AT_ESCAPE);
        }
        fetch();
        token.escaped = true;
        token.setC(c);

        switch (c) {
        case 'w':
            fetchTokenInCCFor_charType(false, Config.NON_UNICODE_SDW ? CharacterType.W : CharacterType.WORD);
            break;
        case 'W':
            fetchTokenInCCFor_charType(true, Config.NON_UNICODE_SDW ? CharacterType.W : CharacterType.WORD);
            break;
        case 'd':
            fetchTokenInCCFor_charType(false, Config.NON_UNICODE_SDW ? CharacterType.D : CharacterType.DIGIT);
            break;
        case 'D':
            fetchTokenInCCFor_charType(true, Config.NON_UNICODE_SDW ? CharacterType.D : CharacterType.DIGIT);
            break;
        case 's':
            fetchTokenInCCFor_charType(false, Config.NON_UNICODE_SDW ? CharacterType.S : CharacterType.SPACE);
            break;
        case 'S':
            fetchTokenInCCFor_charType(true, Config.NON_UNICODE_SDW ? CharacterType.S : CharacterType.SPACE);
            break;
        case 'h':
            if (syntax.op2EscHXDigit()) {
                fetchTokenInCCFor_charType(false, CharacterType.XDIGIT);
            }
            break;
        case 'H':
            if (syntax.op2EscHXDigit()) {
                fetchTokenInCCFor_charType(true, CharacterType.XDIGIT);
            }
            break;
        case 'x':
            fetchTokenInCCFor_x();
            break;
        case 'u':
            fetchTokenInCCFor_u();
            break;
        case '0':
        case '1':
        case '2':
        case '3':
        case '4':
        case '5':
        case '6':
        case '7':
            fetchTokenInCCFor_digit();
            break;

        default:
            unfetch();
            final int num = fetchEscapedValue();
            if (token.getC() != num) {
                token.setCode(num);
                token.type = TokenType.CODE_POINT;
            }
            break;
        } // switch

    } else if (c == '&') {
        fetchTokenInCCFor_and();
    }
    return token.type;
}
 
Example 13
Source File: Lexer.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
protected final TokenType fetchTokenInCC() {
    if (!left()) {
        token.type = TokenType.EOT;
        return token.type;
    }

    fetch();
    token.type = TokenType.CHAR;
    token.setC(c);
    token.escaped = false;

    if (c == ']') {
        token.type = TokenType.CC_CLOSE;
    } else if (c == '-') {
        token.type = TokenType.CC_RANGE;
    } else if (c == syntax.metaCharTable.esc) {
        if (!syntax.backSlashEscapeInCC()) return token.type;
        if (!left()) {
            throw new SyntaxException(ERR_END_PATTERN_AT_ESCAPE);
        }
        fetch();
        token.escaped = true;
        token.setC(c);

        switch (c) {
        case 'w':
            fetchTokenInCCFor_charType(false, Config.NON_UNICODE_SDW ? CharacterType.W : CharacterType.WORD);
            break;
        case 'W':
            fetchTokenInCCFor_charType(true, Config.NON_UNICODE_SDW ? CharacterType.W : CharacterType.WORD);
            break;
        case 'd':
            fetchTokenInCCFor_charType(false, Config.NON_UNICODE_SDW ? CharacterType.D : CharacterType.DIGIT);
            break;
        case 'D':
            fetchTokenInCCFor_charType(true, Config.NON_UNICODE_SDW ? CharacterType.D : CharacterType.DIGIT);
            break;
        case 's':
            fetchTokenInCCFor_charType(false, Config.NON_UNICODE_SDW ? CharacterType.S : CharacterType.SPACE);
            break;
        case 'S':
            fetchTokenInCCFor_charType(true, Config.NON_UNICODE_SDW ? CharacterType.S : CharacterType.SPACE);
            break;
        case 'h':
            if (syntax.op2EscHXDigit()) fetchTokenInCCFor_charType(false, CharacterType.XDIGIT);
            break;
        case 'H':
            if (syntax.op2EscHXDigit()) fetchTokenInCCFor_charType(true, CharacterType.XDIGIT);
            break;
        case 'x':
            fetchTokenInCCFor_x();
            break;
        case 'u':
            fetchTokenInCCFor_u();
            break;
        case '0':
        case '1':
        case '2':
        case '3':
        case '4':
        case '5':
        case '6':
        case '7':
            fetchTokenInCCFor_digit();
            break;

        default:
            unfetch();
            int num = fetchEscapedValue();
            if (token.getC() != num) {
                token.setCode(num);
                token.type = TokenType.CODE_POINT;
            }
            break;
        } // switch

    } else if (c == '&') {
        fetchTokenInCCFor_and();
    }
    return token.type;
}
 
Example 14
Source File: Lexer.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
protected final TokenType fetchTokenInCC() {
    if (!left()) {
        token.type = TokenType.EOT;
        return token.type;
    }

    fetch();
    token.type = TokenType.CHAR;
    token.setC(c);
    token.escaped = false;

    if (c == ']') {
        token.type = TokenType.CC_CLOSE;
    } else if (c == '-') {
        token.type = TokenType.CC_RANGE;
    } else if (c == syntax.metaCharTable.esc) {
        if (!syntax.backSlashEscapeInCC()) return token.type;
        if (!left()) {
            throw new SyntaxException(ERR_END_PATTERN_AT_ESCAPE);
        }
        fetch();
        token.escaped = true;
        token.setC(c);

        switch (c) {
        case 'w':
            fetchTokenInCCFor_charType(false, Config.NON_UNICODE_SDW ? CharacterType.W : CharacterType.WORD);
            break;
        case 'W':
            fetchTokenInCCFor_charType(true, Config.NON_UNICODE_SDW ? CharacterType.W : CharacterType.WORD);
            break;
        case 'd':
            fetchTokenInCCFor_charType(false, Config.NON_UNICODE_SDW ? CharacterType.D : CharacterType.DIGIT);
            break;
        case 'D':
            fetchTokenInCCFor_charType(true, Config.NON_UNICODE_SDW ? CharacterType.D : CharacterType.DIGIT);
            break;
        case 's':
            fetchTokenInCCFor_charType(false, Config.NON_UNICODE_SDW ? CharacterType.S : CharacterType.SPACE);
            break;
        case 'S':
            fetchTokenInCCFor_charType(true, Config.NON_UNICODE_SDW ? CharacterType.S : CharacterType.SPACE);
            break;
        case 'h':
            if (syntax.op2EscHXDigit()) fetchTokenInCCFor_charType(false, CharacterType.XDIGIT);
            break;
        case 'H':
            if (syntax.op2EscHXDigit()) fetchTokenInCCFor_charType(true, CharacterType.XDIGIT);
            break;
        case 'x':
            fetchTokenInCCFor_x();
            break;
        case 'u':
            fetchTokenInCCFor_u();
            break;
        case '0':
        case '1':
        case '2':
        case '3':
        case '4':
        case '5':
        case '6':
        case '7':
            fetchTokenInCCFor_digit();
            break;

        default:
            unfetch();
            int num = fetchEscapedValue();
            if (token.getC() != num) {
                token.setCode(num);
                token.type = TokenType.CODE_POINT;
            }
            break;
        } // switch

    } else if (c == '&') {
        fetchTokenInCCFor_and();
    }
    return token.type;
}
 
Example 15
Source File: Lexer.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
protected final TokenType fetchTokenInCC() {
    if (!left()) {
        token.type = TokenType.EOT;
        return token.type;
    }

    fetch();
    token.type = TokenType.CHAR;
    token.setC(c);
    token.escaped = false;

    if (c == ']') {
        token.type = TokenType.CC_CLOSE;
    } else if (c == '-') {
        token.type = TokenType.CC_RANGE;
    } else if (c == syntax.metaCharTable.esc) {
        if (!syntax.backSlashEscapeInCC()) {
            return token.type;
        }
        if (!left()) {
            throw new SyntaxException(ERR_END_PATTERN_AT_ESCAPE);
        }
        fetch();
        token.escaped = true;
        token.setC(c);

        switch (c) {
        case 'w':
            fetchTokenInCCFor_charType(false, Config.NON_UNICODE_SDW ? CharacterType.W : CharacterType.WORD);
            break;
        case 'W':
            fetchTokenInCCFor_charType(true, Config.NON_UNICODE_SDW ? CharacterType.W : CharacterType.WORD);
            break;
        case 'd':
            fetchTokenInCCFor_charType(false, Config.NON_UNICODE_SDW ? CharacterType.D : CharacterType.DIGIT);
            break;
        case 'D':
            fetchTokenInCCFor_charType(true, Config.NON_UNICODE_SDW ? CharacterType.D : CharacterType.DIGIT);
            break;
        case 's':
            fetchTokenInCCFor_charType(false, Config.NON_UNICODE_SDW ? CharacterType.S : CharacterType.SPACE);
            break;
        case 'S':
            fetchTokenInCCFor_charType(true, Config.NON_UNICODE_SDW ? CharacterType.S : CharacterType.SPACE);
            break;
        case 'h':
            if (syntax.op2EscHXDigit()) {
                fetchTokenInCCFor_charType(false, CharacterType.XDIGIT);
            }
            break;
        case 'H':
            if (syntax.op2EscHXDigit()) {
                fetchTokenInCCFor_charType(true, CharacterType.XDIGIT);
            }
            break;
        case 'x':
            fetchTokenInCCFor_x();
            break;
        case 'u':
            fetchTokenInCCFor_u();
            break;
        case '0':
        case '1':
        case '2':
        case '3':
        case '4':
        case '5':
        case '6':
        case '7':
            fetchTokenInCCFor_digit();
            break;

        default:
            unfetch();
            final int num = fetchEscapedValue();
            if (token.getC() != num) {
                token.setCode(num);
                token.type = TokenType.CODE_POINT;
            }
            break;
        } // switch

    } else if (c == '&') {
        fetchTokenInCCFor_and();
    }
    return token.type;
}
 
Example 16
Source File: Lexer.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
protected final TokenType fetchTokenInCC() {
    if (!left()) {
        token.type = TokenType.EOT;
        return token.type;
    }

    fetch();
    token.type = TokenType.CHAR;
    token.setC(c);
    token.escaped = false;

    if (c == ']') {
        token.type = TokenType.CC_CLOSE;
    } else if (c == '-') {
        token.type = TokenType.CC_RANGE;
    } else if (c == syntax.metaCharTable.esc) {
        if (!syntax.backSlashEscapeInCC()) {
            return token.type;
        }
        if (!left()) {
            throw new SyntaxException(ERR_END_PATTERN_AT_ESCAPE);
        }
        fetch();
        token.escaped = true;
        token.setC(c);

        switch (c) {
        case 'w':
            fetchTokenInCCFor_charType(false, Config.NON_UNICODE_SDW ? CharacterType.W : CharacterType.WORD);
            break;
        case 'W':
            fetchTokenInCCFor_charType(true, Config.NON_UNICODE_SDW ? CharacterType.W : CharacterType.WORD);
            break;
        case 'd':
            fetchTokenInCCFor_charType(false, Config.NON_UNICODE_SDW ? CharacterType.D : CharacterType.DIGIT);
            break;
        case 'D':
            fetchTokenInCCFor_charType(true, Config.NON_UNICODE_SDW ? CharacterType.D : CharacterType.DIGIT);
            break;
        case 's':
            fetchTokenInCCFor_charType(false, Config.NON_UNICODE_SDW ? CharacterType.S : CharacterType.SPACE);
            break;
        case 'S':
            fetchTokenInCCFor_charType(true, Config.NON_UNICODE_SDW ? CharacterType.S : CharacterType.SPACE);
            break;
        case 'h':
            if (syntax.op2EscHXDigit()) {
                fetchTokenInCCFor_charType(false, CharacterType.XDIGIT);
            }
            break;
        case 'H':
            if (syntax.op2EscHXDigit()) {
                fetchTokenInCCFor_charType(true, CharacterType.XDIGIT);
            }
            break;
        case 'x':
            fetchTokenInCCFor_x();
            break;
        case 'u':
            fetchTokenInCCFor_u();
            break;
        case '0':
        case '1':
        case '2':
        case '3':
        case '4':
        case '5':
        case '6':
        case '7':
            fetchTokenInCCFor_digit();
            break;

        default:
            unfetch();
            final int num = fetchEscapedValue();
            if (token.getC() != num) {
                token.setCode(num);
                token.type = TokenType.CODE_POINT;
            }
            break;
        } // switch

    } else if (c == '&') {
        fetchTokenInCCFor_and();
    }
    return token.type;
}
 
Example 17
Source File: Lexer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
protected final TokenType fetchTokenInCC() {
    if (!left()) {
        token.type = TokenType.EOT;
        return token.type;
    }

    fetch();
    token.type = TokenType.CHAR;
    token.setC(c);
    token.escaped = false;

    if (c == ']') {
        token.type = TokenType.CC_CLOSE;
    } else if (c == '-') {
        token.type = TokenType.CC_RANGE;
    } else if (c == syntax.metaCharTable.esc) {
        if (!syntax.backSlashEscapeInCC()) {
            return token.type;
        }
        if (!left()) {
            throw new SyntaxException(ERR_END_PATTERN_AT_ESCAPE);
        }
        fetch();
        token.escaped = true;
        token.setC(c);

        switch (c) {
        case 'w':
            fetchTokenInCCFor_charType(false, Config.NON_UNICODE_SDW ? CharacterType.W : CharacterType.WORD);
            break;
        case 'W':
            fetchTokenInCCFor_charType(true, Config.NON_UNICODE_SDW ? CharacterType.W : CharacterType.WORD);
            break;
        case 'd':
            fetchTokenInCCFor_charType(false, Config.NON_UNICODE_SDW ? CharacterType.D : CharacterType.DIGIT);
            break;
        case 'D':
            fetchTokenInCCFor_charType(true, Config.NON_UNICODE_SDW ? CharacterType.D : CharacterType.DIGIT);
            break;
        case 's':
            fetchTokenInCCFor_charType(false, Config.NON_UNICODE_SDW ? CharacterType.S : CharacterType.SPACE);
            break;
        case 'S':
            fetchTokenInCCFor_charType(true, Config.NON_UNICODE_SDW ? CharacterType.S : CharacterType.SPACE);
            break;
        case 'h':
            if (syntax.op2EscHXDigit()) {
                fetchTokenInCCFor_charType(false, CharacterType.XDIGIT);
            }
            break;
        case 'H':
            if (syntax.op2EscHXDigit()) {
                fetchTokenInCCFor_charType(true, CharacterType.XDIGIT);
            }
            break;
        case 'x':
            fetchTokenInCCFor_x();
            break;
        case 'u':
            fetchTokenInCCFor_u();
            break;
        case '0':
        case '1':
        case '2':
        case '3':
        case '4':
        case '5':
        case '6':
        case '7':
            fetchTokenInCCFor_digit();
            break;

        default:
            unfetch();
            final int num = fetchEscapedValue();
            if (token.getC() != num) {
                token.setCode(num);
                token.type = TokenType.CODE_POINT;
            }
            break;
        } // switch

    } else if (c == '&') {
        fetchTokenInCCFor_and();
    }
    return token.type;
}
 
Example 18
Source File: Lexer.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
protected final TokenType fetchTokenInCC() {
    if (!left()) {
        token.type = TokenType.EOT;
        return token.type;
    }

    fetch();
    token.type = TokenType.CHAR;
    token.setC(c);
    token.escaped = false;

    if (c == ']') {
        token.type = TokenType.CC_CLOSE;
    } else if (c == '-') {
        token.type = TokenType.CC_RANGE;
    } else if (c == syntax.metaCharTable.esc) {
        if (!syntax.backSlashEscapeInCC()) {
            return token.type;
        }
        if (!left()) {
            throw new SyntaxException(ERR_END_PATTERN_AT_ESCAPE);
        }
        fetch();
        token.escaped = true;
        token.setC(c);

        switch (c) {
        case 'w':
            fetchTokenInCCFor_charType(false, Config.NON_UNICODE_SDW ? CharacterType.W : CharacterType.WORD);
            break;
        case 'W':
            fetchTokenInCCFor_charType(true, Config.NON_UNICODE_SDW ? CharacterType.W : CharacterType.WORD);
            break;
        case 'd':
            fetchTokenInCCFor_charType(false, Config.NON_UNICODE_SDW ? CharacterType.D : CharacterType.DIGIT);
            break;
        case 'D':
            fetchTokenInCCFor_charType(true, Config.NON_UNICODE_SDW ? CharacterType.D : CharacterType.DIGIT);
            break;
        case 's':
            fetchTokenInCCFor_charType(false, Config.NON_UNICODE_SDW ? CharacterType.S : CharacterType.SPACE);
            break;
        case 'S':
            fetchTokenInCCFor_charType(true, Config.NON_UNICODE_SDW ? CharacterType.S : CharacterType.SPACE);
            break;
        case 'h':
            if (syntax.op2EscHXDigit()) {
                fetchTokenInCCFor_charType(false, CharacterType.XDIGIT);
            }
            break;
        case 'H':
            if (syntax.op2EscHXDigit()) {
                fetchTokenInCCFor_charType(true, CharacterType.XDIGIT);
            }
            break;
        case 'x':
            fetchTokenInCCFor_x();
            break;
        case 'u':
            fetchTokenInCCFor_u();
            break;
        case '0':
        case '1':
        case '2':
        case '3':
        case '4':
        case '5':
        case '6':
        case '7':
            fetchTokenInCCFor_digit();
            break;

        default:
            unfetch();
            final int num = fetchEscapedValue();
            if (token.getC() != num) {
                token.setCode(num);
                token.type = TokenType.CODE_POINT;
            }
            break;
        } // switch

    } else if (c == '&') {
        fetchTokenInCCFor_and();
    }
    return token.type;
}
 
Example 19
Source File: Lexer.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
protected final TokenType fetchTokenInCC() {
    if (!left()) {
        token.type = TokenType.EOT;
        return token.type;
    }

    fetch();
    token.type = TokenType.CHAR;
    token.setC(c);
    token.escaped = false;

    if (c == ']') {
        token.type = TokenType.CC_CLOSE;
    } else if (c == '-') {
        token.type = TokenType.CC_RANGE;
    } else if (c == syntax.metaCharTable.esc) {
        if (!syntax.backSlashEscapeInCC()) {
            return token.type;
        }
        if (!left()) {
            throw new SyntaxException(ERR_END_PATTERN_AT_ESCAPE);
        }
        fetch();
        token.escaped = true;
        token.setC(c);

        switch (c) {
        case 'w':
            fetchTokenInCCFor_charType(false, Config.NON_UNICODE_SDW ? CharacterType.W : CharacterType.WORD);
            break;
        case 'W':
            fetchTokenInCCFor_charType(true, Config.NON_UNICODE_SDW ? CharacterType.W : CharacterType.WORD);
            break;
        case 'd':
            fetchTokenInCCFor_charType(false, Config.NON_UNICODE_SDW ? CharacterType.D : CharacterType.DIGIT);
            break;
        case 'D':
            fetchTokenInCCFor_charType(true, Config.NON_UNICODE_SDW ? CharacterType.D : CharacterType.DIGIT);
            break;
        case 's':
            fetchTokenInCCFor_charType(false, Config.NON_UNICODE_SDW ? CharacterType.S : CharacterType.SPACE);
            break;
        case 'S':
            fetchTokenInCCFor_charType(true, Config.NON_UNICODE_SDW ? CharacterType.S : CharacterType.SPACE);
            break;
        case 'h':
            if (syntax.op2EscHXDigit()) {
                fetchTokenInCCFor_charType(false, CharacterType.XDIGIT);
            }
            break;
        case 'H':
            if (syntax.op2EscHXDigit()) {
                fetchTokenInCCFor_charType(true, CharacterType.XDIGIT);
            }
            break;
        case 'x':
            fetchTokenInCCFor_x();
            break;
        case 'u':
            fetchTokenInCCFor_u();
            break;
        case '0':
        case '1':
        case '2':
        case '3':
        case '4':
        case '5':
        case '6':
        case '7':
            fetchTokenInCCFor_digit();
            break;

        default:
            unfetch();
            final int num = fetchEscapedValue();
            if (token.getC() != num) {
                token.setCode(num);
                token.type = TokenType.CODE_POINT;
            }
            break;
        } // switch

    } else if (c == '&') {
        fetchTokenInCCFor_and();
    }
    return token.type;
}
 
Example 20
Source File: Lexer.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
protected final TokenType fetchTokenInCC() {
    if (!left()) {
        token.type = TokenType.EOT;
        return token.type;
    }

    fetch();
    token.type = TokenType.CHAR;
    token.setC(c);
    token.escaped = false;

    if (c == ']') {
        token.type = TokenType.CC_CLOSE;
    } else if (c == '-') {
        token.type = TokenType.CC_RANGE;
    } else if (c == syntax.metaCharTable.esc) {
        if (!syntax.backSlashEscapeInCC()) {
            return token.type;
        }
        if (!left()) {
            throw new SyntaxException(ERR_END_PATTERN_AT_ESCAPE);
        }
        fetch();
        token.escaped = true;
        token.setC(c);

        switch (c) {
        case 'w':
            fetchTokenInCCFor_charType(false, Config.NON_UNICODE_SDW ? CharacterType.W : CharacterType.WORD);
            break;
        case 'W':
            fetchTokenInCCFor_charType(true, Config.NON_UNICODE_SDW ? CharacterType.W : CharacterType.WORD);
            break;
        case 'd':
            fetchTokenInCCFor_charType(false, Config.NON_UNICODE_SDW ? CharacterType.D : CharacterType.DIGIT);
            break;
        case 'D':
            fetchTokenInCCFor_charType(true, Config.NON_UNICODE_SDW ? CharacterType.D : CharacterType.DIGIT);
            break;
        case 's':
            fetchTokenInCCFor_charType(false, Config.NON_UNICODE_SDW ? CharacterType.S : CharacterType.SPACE);
            break;
        case 'S':
            fetchTokenInCCFor_charType(true, Config.NON_UNICODE_SDW ? CharacterType.S : CharacterType.SPACE);
            break;
        case 'h':
            if (syntax.op2EscHXDigit()) {
                fetchTokenInCCFor_charType(false, CharacterType.XDIGIT);
            }
            break;
        case 'H':
            if (syntax.op2EscHXDigit()) {
                fetchTokenInCCFor_charType(true, CharacterType.XDIGIT);
            }
            break;
        case 'x':
            fetchTokenInCCFor_x();
            break;
        case 'u':
            fetchTokenInCCFor_u();
            break;
        case '0':
        case '1':
        case '2':
        case '3':
        case '4':
        case '5':
        case '6':
        case '7':
            fetchTokenInCCFor_digit();
            break;

        default:
            unfetch();
            final int num = fetchEscapedValue();
            if (token.getC() != num) {
                token.setCode(num);
                token.type = TokenType.CODE_POINT;
            }
            break;
        } // switch

    } else if (c == '&') {
        fetchTokenInCCFor_and();
    }
    return token.type;
}