Search in sources :

Example 1 with NoViableAltForCharException

use of antlr.NoViableAltForCharException in project sonarqube by SonarSource.

the class ValidWhenLexer method mDECIMAL_LITERAL.

public final void mDECIMAL_LITERAL(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
    int _ttype;
    Token _token = null;
    int _begin = text.length();
    _ttype = DECIMAL_LITERAL;
    int _saveIndex;
    {
        switch(LA(1)) {
            case '-':
                {
                    match('-');
                    break;
                }
            case '1':
            case '2':
            case '3':
            case '4':
            case '5':
            case '6':
            case '7':
            case '8':
            case '9':
                {
                    break;
                }
            default:
                {
                    throw new NoViableAltForCharException((char) LA(1), getFilename(), getLine(), getColumn());
                }
        }
    }
    {
        matchRange('1', '9');
    }
    {
        _loop20: do {
            if (((LA(1) >= '0' && LA(1) <= '9'))) {
                matchRange('0', '9');
            } else {
                break _loop20;
            }
        } while (true);
    }
    if (_createToken && _token == null && _ttype != Token.SKIP) {
        _token = makeToken(_ttype);
        _token.setText(new String(text.getBuffer(), _begin, text.length() - _begin));
    }
    _returnToken = _token;
}
Also used : NoViableAltForCharException(antlr.NoViableAltForCharException) Token(antlr.Token) CommonToken(antlr.CommonToken) ANTLRHashString(antlr.ANTLRHashString)

Example 2 with NoViableAltForCharException

use of antlr.NoViableAltForCharException in project sonarqube by SonarSource.

the class ValidWhenLexer 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 '\t':
                    case '\n':
                    case '\r':
                    case ' ':
                        {
                            mWS(true);
                            theRetToken = _returnToken;
                            break;
                        }
                    case '-':
                    case '1':
                    case '2':
                    case '3':
                    case '4':
                    case '5':
                    case '6':
                    case '7':
                    case '8':
                    case '9':
                        {
                            mDECIMAL_LITERAL(true);
                            theRetToken = _returnToken;
                            break;
                        }
                    case '"':
                    case '\'':
                        {
                            mSTRING_LITERAL(true);
                            theRetToken = _returnToken;
                            break;
                        }
                    case '[':
                        {
                            mLBRACKET(true);
                            theRetToken = _returnToken;
                            break;
                        }
                    case ']':
                        {
                            mRBRACKET(true);
                            theRetToken = _returnToken;
                            break;
                        }
                    case '(':
                        {
                            mLPAREN(true);
                            theRetToken = _returnToken;
                            break;
                        }
                    case ')':
                        {
                            mRPAREN(true);
                            theRetToken = _returnToken;
                            break;
                        }
                    case '*':
                        {
                            mTHIS(true);
                            theRetToken = _returnToken;
                            break;
                        }
                    case '.':
                    case '_':
                    case 'a':
                    case 'b':
                    case 'c':
                    case 'd':
                    case 'e':
                    case 'f':
                    case 'g':
                    case 'h':
                    case 'i':
                    case 'j':
                    case 'k':
                    case 'l':
                    case 'm':
                    case 'n':
                    case 'o':
                    case 'p':
                    case 'q':
                    case 'r':
                    case 's':
                    case 't':
                    case 'u':
                    case 'v':
                    case 'w':
                    case 'x':
                    case 'y':
                    case 'z':
                        {
                            mIDENTIFIER(true);
                            theRetToken = _returnToken;
                            break;
                        }
                    case '=':
                        {
                            mEQUALSIGN(true);
                            theRetToken = _returnToken;
                            break;
                        }
                    case '!':
                        {
                            mNOTEQUALSIGN(true);
                            theRetToken = _returnToken;
                            break;
                        }
                    default:
                        if ((LA(1) == '0') && (LA(2) == 'x')) {
                            mHEX_LITERAL(true);
                            theRetToken = _returnToken;
                        } else if ((LA(1) == '<') && (LA(2) == '=')) {
                            mLESSEQUALSIGN(true);
                            theRetToken = _returnToken;
                        } else if ((LA(1) == '>') && (LA(2) == '=')) {
                            mGREATEREQUALSIGN(true);
                            theRetToken = _returnToken;
                        } else if ((LA(1) == '0') && (true)) {
                            mOCTAL_LITERAL(true);
                            theRetToken = _returnToken;
                        } else if ((LA(1) == '<') && (true)) {
                            mLESSTHANSIGN(true);
                            theRetToken = _returnToken;
                        } else if ((LA(1) == '>') && (true)) {
                            mGREATERTHANSIGN(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();
                _ttype = testLiteralsTable(_ttype);
                _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) CommonToken(antlr.CommonToken) TokenStreamIOException(antlr.TokenStreamIOException) TokenStreamRecognitionException(antlr.TokenStreamRecognitionException) RecognitionException(antlr.RecognitionException)

Example 3 with NoViableAltForCharException

use of antlr.NoViableAltForCharException in project sonarqube by SonarSource.

the class ValidWhenLexer method mIDENTIFIER.

public final void mIDENTIFIER(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
    int _ttype;
    Token _token = null;
    int _begin = text.length();
    _ttype = IDENTIFIER;
    int _saveIndex;
    {
        switch(LA(1)) {
            case 'a':
            case 'b':
            case 'c':
            case 'd':
            case 'e':
            case 'f':
            case 'g':
            case 'h':
            case 'i':
            case 'j':
            case 'k':
            case 'l':
            case 'm':
            case 'n':
            case 'o':
            case 'p':
            case 'q':
            case 'r':
            case 's':
            case 't':
            case 'u':
            case 'v':
            case 'w':
            case 'x':
            case 'y':
            case 'z':
                {
                    matchRange('a', 'z');
                    break;
                }
            case '.':
                {
                    match('.');
                    break;
                }
            case '_':
                {
                    match('_');
                    break;
                }
            default:
                {
                    throw new NoViableAltForCharException((char) LA(1), getFilename(), getLine(), getColumn());
                }
        }
    }
    {
        int _cnt42 = 0;
        _loop42: do {
            switch(LA(1)) {
                case 'a':
                case 'b':
                case 'c':
                case 'd':
                case 'e':
                case 'f':
                case 'g':
                case 'h':
                case 'i':
                case 'j':
                case 'k':
                case 'l':
                case 'm':
                case 'n':
                case 'o':
                case 'p':
                case 'q':
                case 'r':
                case 's':
                case 't':
                case 'u':
                case 'v':
                case 'w':
                case 'x':
                case 'y':
                case 'z':
                    {
                        matchRange('a', 'z');
                        break;
                    }
                case '0':
                case '1':
                case '2':
                case '3':
                case '4':
                case '5':
                case '6':
                case '7':
                case '8':
                case '9':
                    {
                        matchRange('0', '9');
                        break;
                    }
                case '.':
                    {
                        match('.');
                        break;
                    }
                case '_':
                    {
                        match('_');
                        break;
                    }
                default:
                    {
                        if (_cnt42 >= 1) {
                            break _loop42;
                        } else {
                            throw new NoViableAltForCharException((char) LA(1), getFilename(), getLine(), getColumn());
                        }
                    }
            }
            _cnt42++;
        } while (true);
    }
    if (_createToken && _token == null && _ttype != Token.SKIP) {
        _token = makeToken(_ttype);
        _token.setText(new String(text.getBuffer(), _begin, text.length() - _begin));
    }
    _returnToken = _token;
}
Also used : NoViableAltForCharException(antlr.NoViableAltForCharException) Token(antlr.Token) CommonToken(antlr.CommonToken) ANTLRHashString(antlr.ANTLRHashString)

Example 4 with NoViableAltForCharException

use of antlr.NoViableAltForCharException in project cxf by apache.

the class IDLLexer method mESC.

protected final void mESC(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
    int _ttype;
    Token _token = null;
    int _begin = text.length();
    _ttype = ESC;
    int _saveIndex;
    _saveIndex = text.length();
    match('\\');
    text.setLength(_saveIndex);
    {
        switch(LA(1)) {
            case 'n':
                {
                    match('n');
                    text.setLength(_begin);
                    text.append("\n");
                    break;
                }
            case 't':
                {
                    match('t');
                    text.setLength(_begin);
                    text.append("\t");
                    break;
                }
            case 'v':
                {
                    match('v');
                    text.setLength(_begin);
                    text.append("\013");
                    break;
                }
            case 'b':
                {
                    match('b');
                    text.setLength(_begin);
                    text.append("\b");
                    break;
                }
            case 'r':
                {
                    match('r');
                    text.setLength(_begin);
                    text.append("\r");
                    break;
                }
            case 'f':
                {
                    match('f');
                    text.setLength(_begin);
                    text.append("\r");
                    break;
                }
            case 'a':
                {
                    match('a');
                    text.setLength(_begin);
                    text.append("\007");
                    break;
                }
            case '\\':
                {
                    match('\\');
                    text.setLength(_begin);
                    text.append("\\");
                    break;
                }
            case '?':
                {
                    match('?');
                    text.setLength(_begin);
                    text.append("?");
                    break;
                }
            case '\'':
                {
                    match('\'');
                    text.setLength(_begin);
                    text.append("'");
                    break;
                }
            case '"':
                {
                    match('"');
                    text.setLength(_begin);
                    text.append("\"");
                    break;
                }
            case '0':
            case '1':
            case '2':
            case '3':
            case '4':
            case '5':
            case '6':
            case '7':
                {
                    mOCTDIGIT(false);
                    {
                        if (((LA(1) >= '0' && LA(1) <= '7')) && ((LA(2) >= '\u0000' && LA(2) <= '\ufffe')) && (true) && (true)) {
                            mOCTDIGIT(false);
                            {
                                if (((LA(1) >= '0' && LA(1) <= '7')) && ((LA(2) >= '\u0000' && LA(2) <= '\ufffe')) && (true) && (true)) {
                                    mOCTDIGIT(false);
                                } else if (((LA(1) >= '\u0000' && LA(1) <= '\ufffe')) && (true) && (true) && (true)) {
                                } else {
                                    throw new NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());
                                }
                            }
                        } else if (((LA(1) >= '\u0000' && LA(1) <= '\ufffe')) && (true) && (true) && (true)) {
                        } else {
                            throw new NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());
                        }
                    }
                    char realc = (char) Integer.valueOf(new String(text.getBuffer(), _begin, text.length() - _begin), 8).intValue();
                    text.setLength(_begin);
                    text.append(realc);
                    break;
                }
            case 'x':
                {
                    _saveIndex = text.length();
                    match('x');
                    text.setLength(_saveIndex);
                    mHEXDIGIT(false);
                    {
                        if ((_tokenSet_6.member(LA(1))) && ((LA(2) >= '\u0000' && LA(2) <= '\ufffe')) && (true) && (true)) {
                            mHEXDIGIT(false);
                        } else if (((LA(1) >= '\u0000' && LA(1) <= '\ufffe')) && (true) && (true) && (true)) {
                        } else {
                            throw new NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());
                        }
                    }
                    char realc = (char) Integer.valueOf(new String(text.getBuffer(), _begin, text.length() - _begin), 16).intValue();
                    text.setLength(_begin);
                    text.append(realc);
                    break;
                }
            case 'u':
                {
                    _saveIndex = text.length();
                    match('u');
                    text.setLength(_saveIndex);
                    mHEXDIGIT(false);
                    {
                        if ((_tokenSet_6.member(LA(1))) && ((LA(2) >= '\u0000' && LA(2) <= '\ufffe')) && (true) && (true)) {
                            mHEXDIGIT(false);
                            {
                                if ((_tokenSet_6.member(LA(1))) && ((LA(2) >= '\u0000' && LA(2) <= '\ufffe')) && (true) && (true)) {
                                    mHEXDIGIT(false);
                                    {
                                        if ((_tokenSet_6.member(LA(1))) && ((LA(2) >= '\u0000' && LA(2) <= '\ufffe')) && (true) && (true)) {
                                            mHEXDIGIT(false);
                                        } else if (((LA(1) >= '\u0000' && LA(1) <= '\ufffe')) && (true) && (true) && (true)) {
                                        } else {
                                            throw new NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());
                                        }
                                    }
                                } else if (((LA(1) >= '\u0000' && LA(1) <= '\ufffe')) && (true) && (true) && (true)) {
                                } else {
                                    throw new NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());
                                }
                            }
                        } else if (((LA(1) >= '\u0000' && LA(1) <= '\ufffe')) && (true) && (true) && (true)) {
                        } else {
                            throw new NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());
                        }
                    }
                    char realc = (char) Integer.valueOf(new String(text.getBuffer(), _begin, text.length() - _begin), 16).intValue();
                    text.setLength(_begin);
                    text.append(realc);
                    break;
                }
            default:
                {
                    throw new NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());
                }
        }
    }
    if (_createToken && _token == null && _ttype != Token.SKIP) {
        _token = makeToken(_ttype);
        _token.setText(new String(text.getBuffer(), _begin, text.length() - _begin));
    }
    _returnToken = _token;
}
Also used : NoViableAltForCharException(antlr.NoViableAltForCharException) Token(antlr.Token) CommonToken(antlr.CommonToken) ANTLRHashString(antlr.ANTLRHashString)

Example 5 with NoViableAltForCharException

use of antlr.NoViableAltForCharException in project cxf by apache.

the class IDLLexer method mFLOAT.

public final void mFLOAT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
    int _ttype;
    Token _token = null;
    int _begin = text.length();
    _ttype = FLOAT;
    int _saveIndex;
    match('.');
    {
        int _cnt387 = 0;
        _loop387: do {
            if (((LA(1) >= '0' && LA(1) <= '9'))) {
                mDIGIT(false);
            } else {
                if (_cnt387 >= 1) {
                    break _loop387;
                }
                throw new NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());
            }
            _cnt387++;
        } while (true);
    }
    {
        switch(LA(1)) {
            case 'E':
            case 'e':
                {
                    {
                        switch(LA(1)) {
                            case 'e':
                                {
                                    match('e');
                                    break;
                                }
                            case 'E':
                                {
                                    match('E');
                                    break;
                                }
                            default:
                                {
                                    throw new NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());
                                }
                        }
                    }
                    {
                        switch(LA(1)) {
                            case '+':
                                {
                                    match('+');
                                    break;
                                }
                            case '-':
                                {
                                    match('-');
                                    break;
                                }
                            case '0':
                            case '1':
                            case '2':
                            case '3':
                            case '4':
                            case '5':
                            case '6':
                            case '7':
                            case '8':
                            case '9':
                                {
                                    break;
                                }
                            default:
                                {
                                    throw new NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());
                                }
                        }
                    }
                    {
                        int _cnt392 = 0;
                        _loop392: do {
                            if (((LA(1) >= '0' && LA(1) <= '9'))) {
                                mDIGIT(false);
                            } else {
                                if (_cnt392 >= 1) {
                                    break _loop392;
                                }
                                throw new NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());
                            }
                            _cnt392++;
                        } while (true);
                    }
                    break;
                }
            case 'D':
            case 'd':
                {
                    {
                        switch(LA(1)) {
                            case 'd':
                                {
                                    match('d');
                                    break;
                                }
                            case 'D':
                                {
                                    match('D');
                                    break;
                                }
                            default:
                                {
                                    throw new NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());
                                }
                        }
                    }
                    _ttype = FIXED;
                    break;
                }
            default:
                {
                }
        }
    }
    if (_createToken && _token == null && _ttype != Token.SKIP) {
        _token = makeToken(_ttype);
        _token.setText(new String(text.getBuffer(), _begin, text.length() - _begin));
    }
    _returnToken = _token;
}
Also used : NoViableAltForCharException(antlr.NoViableAltForCharException) Token(antlr.Token) CommonToken(antlr.CommonToken) ANTLRHashString(antlr.ANTLRHashString)

Aggregations

NoViableAltForCharException (antlr.NoViableAltForCharException)55 Token (antlr.Token)53 ANTLRHashString (antlr.ANTLRHashString)47 CommonToken (antlr.CommonToken)44 RecognitionException (antlr.RecognitionException)7 TokenStreamRecognitionException (antlr.TokenStreamRecognitionException)7 CharStreamException (antlr.CharStreamException)6 CharStreamIOException (antlr.CharStreamIOException)6 TokenStreamException (antlr.TokenStreamException)6 TokenStreamIOException (antlr.TokenStreamIOException)6 MismatchedCharException (antlr.MismatchedCharException)2 MismatchedTokenException (antlr.MismatchedTokenException)2 NoViableAltException (antlr.NoViableAltException)2 Message (org.codehaus.groovy.control.messages.Message)2 SimpleMessage (org.codehaus.groovy.control.messages.SimpleMessage)2 SyntaxErrorMessage (org.codehaus.groovy.control.messages.SyntaxErrorMessage)2