⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xpathlexer.java

📁 XML的解析、编译、查询等技术的JAVA源代码。
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
                               currentPosition()+3 );                consume();            consume();            consume();        }            return token;    }        private Token or()    {        Token token = null;            if ( ( LA(1) == 'o' )             &&             ( LA(2) == 'r' )           )        {            token = new Token( TokenTypes.OR,                               getXPath(),                               currentPosition(),                               currentPosition()+2 );                consume();            consume();        }            return token;    }        private Token number()    {        int     start         = currentPosition();        boolean periodAllowed = true;          loop:        while( true )        {            switch ( LA(1) )            {                case '.':                    if ( periodAllowed )                    {                        periodAllowed = false;                        consume();                    }                    else                    {                        break loop;                    }                    break;                case '0':                case '1':                case '2':                case '3':                case '4':                case '5':                case '6':                case '7':                case '8':                case '9':                    consume();                    break;                default:                    break loop;            }        }            return new Token( TokenTypes.DOUBLE,                               getXPath(),                               start,                               currentPosition() );    }        private Token whitespace()    {        consume();                  loop:        while( hasMoreChars() )        {            switch ( LA(1) )            {                case ' ':                case '\t':                case '\n':                case '\r':                {                    consume();                    break;                }                                    default:                {                    break loop;                }            }        }            return new Token( TokenTypes.SKIP,                          getXPath(),                          0,                          0 );    }        private Token comma()    {        Token token = new Token( TokenTypes.COMMA,                                 getXPath(),                                 currentPosition(),                                 currentPosition()+1 );            consume();            return token;    }        private Token equals()    {        Token token = new Token( TokenTypes.EQUALS,                                 getXPath(),                                 currentPosition(),                                 currentPosition()+1 );            consume();            return token;    }        private Token minus()    {        Token token = new Token( TokenTypes.MINUS,                                 getXPath(),                                 currentPosition(),                                 currentPosition()+1 );        consume();                    return token;    }        private Token plus()    {        Token token = new Token( TokenTypes.PLUS,                                 getXPath(),                                 currentPosition(),                                 currentPosition()+1 );        consume();            return token;    }        private Token dollar()    {        Token token = new Token( TokenTypes.DOLLAR,                                 getXPath(),                                 currentPosition(),                                 currentPosition()+1 );        consume();            return token;    }        private Token pipe()    {        Token token = new Token( TokenTypes.PIPE,                                 getXPath(),                                 currentPosition(),                                 currentPosition()+1 );            consume();            return token;    }        private Token at()    {        Token token = new Token( TokenTypes.AT,                                 getXPath(),                                 currentPosition(),                                 currentPosition()+1 );            consume();            return token;    }        private Token colon()    {        Token token = new Token( TokenTypes.COLON,                                 getXPath(),                                 currentPosition(),                                 currentPosition()+1 );        consume();            return token;    }        private Token doubleColon()    {        Token token = new Token( TokenTypes.DOUBLE_COLON,                                 getXPath(),                                 currentPosition(),                                 currentPosition()+2 );            consume();        consume();            return token;    }        private Token notEquals()    {        Token token = new Token( TokenTypes.NOT_EQUALS,                                 getXPath(),                                 currentPosition(),                                 currentPosition() + 2 );            consume();        consume();            return token;    }        private Token relationalOperator()    {        Token token = null;            switch ( LA(1) )        {            case '<':            {                if ( LA(2) == '=' )                {                    token = new Token( TokenTypes.LESS_THAN_OR_EQUALS_SIGN,                                       getXPath(),                                       currentPosition(),                                       currentPosition() + 2 );                    consume();                }                else                {                    token = new Token( TokenTypes.LESS_THAN_SIGN,                                       getXPath(),                                       currentPosition(),                                       currentPosition() + 1);                }                    consume();                break;            }            case '>':            {                if ( LA(2) == '=' )                {                    token = new Token( TokenTypes.GREATER_THAN_OR_EQUALS_SIGN,                                       getXPath(),                                       currentPosition(),                                       currentPosition() + 2 );                    consume();                }                else                {                    token = new Token( TokenTypes.GREATER_THAN_SIGN,                                       getXPath(),                                       currentPosition(),                                       currentPosition() + 1 );                }                    consume();                break;            }        }            return token;                    }        private Token star()    {        Token token = new Token( TokenTypes.STAR,                                 getXPath(),                                 currentPosition(),                                 currentPosition()+1 );            consume();                    return token;    }        private Token literal()    {        Token token = null;            char match  = LA(1);            consume();            int start = currentPosition();                    while ( ( token == null )                &&                hasMoreChars() )        {            if ( LA(1) == match )            {                token = new Token( TokenTypes.LITERAL,                                   getXPath(),                                   start,                                   currentPosition() );            }            consume();        }            return token;    }        private Token dots()    {        Token token = null;            switch ( LA(2) )        {            case '.':            {                token = new Token( TokenTypes.DOT_DOT,                                   getXPath(),                                   currentPosition(),                                   currentPosition()+2 ) ;                consume();                consume();                break;            }            default:            {                token = new Token( TokenTypes.DOT,                                   getXPath(),                                   currentPosition(),                                   currentPosition()+1 );                consume();                break;            }        }            return token;    }        private Token leftBracket()    {        Token token = new Token( TokenTypes.LEFT_BRACKET,                                 getXPath(),                                 currentPosition(),                                 currentPosition()+1 );            consume();            return token;    }        private Token rightBracket()    {        Token token = new Token( TokenTypes.RIGHT_BRACKET,                                 getXPath(),                                 currentPosition(),                                 currentPosition()+1 );            consume();            return token;    }        private Token leftParen()    {        Token token = new Token( TokenTypes.LEFT_PAREN,                                 getXPath(),                                 currentPosition(),                                 currentPosition()+1 );            consume();            return token;    }        private Token rightParen()    {        Token token = new Token( TokenTypes.RIGHT_PAREN,                                 getXPath(),                                 currentPosition(),                                 currentPosition()+1 );            consume();            return token;    }        private Token slashes()    {        Token token = null;            switch ( LA(2) )        {            case '/':            {                token = new Token( TokenTypes.DOUBLE_SLASH,                                   getXPath(),                                   currentPosition(),                                   currentPosition()+2 );                consume();                consume();                break;            }            default:            {                token = new Token( TokenTypes.SLASH,                                   getXPath(),                                   currentPosition(),                                   currentPosition()+1 );                consume();            }        }            return token;    }        private char LA(int i)     {        if ( currentPosition + ( i - 1 ) >= endPosition() )        {            return (char) -1;        }            return getXPath().charAt( currentPosition() + (i - 1) );    }        private void consume()    {        ++this.currentPosition;    }        private int currentPosition()    {        return this.currentPosition;    }        private int endPosition()    {        return this.endPosition;    }        private void setPreviousToken(Token previousToken)    {        this.previousToken = previousToken;    }        private boolean hasMoreChars()    {        return currentPosition() < endPosition();    }        private boolean isIdentifierChar(char c)    {        return Verifier.isXMLNCNameCharacter( c );    }        private boolean isIdentifierStartChar(char c)    {        return Verifier.isXMLNCNameStartCharacter( c );    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -