Search in sources :

Example 6 with CharStreamIOException

use of antlr.CharStreamIOException in project jbosstools-hibernate by jbosstools.

the class HQLBaseLexer method nextToken.

public Token nextToken() throws TokenStreamException {
    Token theRetToken = null;
    tryAgain: for (; ; ) {
        Token _token = null;
        int _ttype = Token.INVALID_TYPE;
        resetText();
        try {
            // for char stream error handling
            try {
                // for lexical error handling
                switch(LA(1)) {
                    case '=':
                        {
                            mEQ(true);
                            theRetToken = _returnToken;
                            break;
                        }
                    case '!':
                    case '^':
                        {
                            mNE(true);
                            theRetToken = _returnToken;
                            break;
                        }
                    case ',':
                        {
                            mCOMMA(true);
                            theRetToken = _returnToken;
                            break;
                        }
                    case '(':
                        {
                            mOPEN(true);
                            theRetToken = _returnToken;
                            break;
                        }
                    case ')':
                        {
                            mCLOSE(true);
                            theRetToken = _returnToken;
                            break;
                        }
                    case '[':
                        {
                            mOPEN_BRACKET(true);
                            theRetToken = _returnToken;
                            break;
                        }
                    case ']':
                        {
                            mCLOSE_BRACKET(true);
                            theRetToken = _returnToken;
                            break;
                        }
                    case '|':
                        {
                            mCONCAT(true);
                            theRetToken = _returnToken;
                            break;
                        }
                    case '+':
                        {
                            mPLUS(true);
                            theRetToken = _returnToken;
                            break;
                        }
                    case '-':
                        {
                            mMINUS(true);
                            theRetToken = _returnToken;
                            break;
                        }
                    case '*':
                        {
                            mSTAR(true);
                            theRetToken = _returnToken;
                            break;
                        }
                    case '/':
                        {
                            mDIV(true);
                            theRetToken = _returnToken;
                            break;
                        }
                    case '%':
                        {
                            mMOD(true);
                            theRetToken = _returnToken;
                            break;
                        }
                    case ':':
                        {
                            mCOLON(true);
                            theRetToken = _returnToken;
                            break;
                        }
                    case '?':
                        {
                            mPARAM(true);
                            theRetToken = _returnToken;
                            break;
                        }
                    case '\'':
                        {
                            mQUOTED_STRING(true);
                            theRetToken = _returnToken;
                            break;
                        }
                    case '\t':
                    case '\n':
                    case '\r':
                    case ' ':
                        {
                            mWS(true);
                            theRetToken = _returnToken;
                            break;
                        }
                    case '.':
                    case '0':
                    case '1':
                    case '2':
                    case '3':
                    case '4':
                    case '5':
                    case '6':
                    case '7':
                    case '8':
                    case '9':
                        {
                            mNUM_INT(true);
                            theRetToken = _returnToken;
                            break;
                        }
                    default:
                        if ((LA(1) == '<') && (LA(2) == '>')) {
                            mSQL_NE(true);
                            theRetToken = _returnToken;
                        } else if ((LA(1) == '<') && (LA(2) == '=')) {
                            mLE(true);
                            theRetToken = _returnToken;
                        } else if ((LA(1) == '>') && (LA(2) == '=')) {
                            mGE(true);
                            theRetToken = _returnToken;
                        } else if ((LA(1) == '<') && (true)) {
                            mLT(true);
                            theRetToken = _returnToken;
                        } else if ((LA(1) == '>') && (true)) {
                            mGT(true);
                            theRetToken = _returnToken;
                        } else if ((_tokenSet_0.member(LA(1)))) {
                            mIDENT(true);
                            theRetToken = _returnToken;
                        } else {
                            if (LA(1) == EOF_CHAR) {
                                uponEOF();
                                _returnToken = makeToken(Token.EOF_TYPE);
                            } else {
                                throw new NoViableAltForCharException((char) LA(1), getFilename(), getLine(), getColumn());
                            }
                        }
                }
                // found SKIP token
                if (_returnToken == null)
                    continue tryAgain;
                _ttype = _returnToken.getType();
                _returnToken.setType(_ttype);
                return _returnToken;
            } catch (RecognitionException e) {
                throw new TokenStreamRecognitionException(e);
            }
        } catch (CharStreamException cse) {
            if (cse instanceof CharStreamIOException) {
                throw new TokenStreamIOException(((CharStreamIOException) cse).io);
            } else {
                throw new TokenStreamException(cse.getMessage());
            }
        }
    }
}
Also used : TokenStreamException(antlr.TokenStreamException) TokenStreamRecognitionException(antlr.TokenStreamRecognitionException) NoViableAltForCharException(antlr.NoViableAltForCharException) CharStreamException(antlr.CharStreamException) CharStreamIOException(antlr.CharStreamIOException) Token(antlr.Token) TokenStreamIOException(antlr.TokenStreamIOException) TokenStreamRecognitionException(antlr.TokenStreamRecognitionException) RecognitionException(antlr.RecognitionException)

Aggregations

CharStreamException (antlr.CharStreamException)6 CharStreamIOException (antlr.CharStreamIOException)6 NoViableAltForCharException (antlr.NoViableAltForCharException)6 RecognitionException (antlr.RecognitionException)6 Token (antlr.Token)6 TokenStreamException (antlr.TokenStreamException)6 TokenStreamIOException (antlr.TokenStreamIOException)6 TokenStreamRecognitionException (antlr.TokenStreamRecognitionException)6 CommonToken (antlr.CommonToken)5