Search in sources :

Example 51 with NoViableAltForCharException

use of antlr.NoViableAltForCharException in project jasn1 by openmuc.

the class ASNLexer 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 '|':
                        {
                            mBAR(true);
                            theRetToken = _returnToken;
                            break;
                        }
                    case ',':
                        {
                            mCOMMA(true);
                            theRetToken = _returnToken;
                            break;
                        }
                    case '&':
                        {
                            mAMPERSAND(true);
                            theRetToken = _returnToken;
                            break;
                        }
                    case '!':
                        {
                            mEXCLAMATION(true);
                            theRetToken = _returnToken;
                            break;
                        }
                    case '^':
                        {
                            mINTERSECTION(true);
                            theRetToken = _returnToken;
                            break;
                        }
                    case '<':
                        {
                            mLESS(true);
                            theRetToken = _returnToken;
                            break;
                        }
                    case '{':
                        {
                            mL_BRACE(true);
                            theRetToken = _returnToken;
                            break;
                        }
                    case '[':
                        {
                            mL_BRACKET(true);
                            theRetToken = _returnToken;
                            break;
                        }
                    case '(':
                        {
                            mL_PAREN(true);
                            theRetToken = _returnToken;
                            break;
                        }
                    case '+':
                        {
                            mPLUS(true);
                            theRetToken = _returnToken;
                            break;
                        }
                    case '}':
                        {
                            mR_BRACE(true);
                            theRetToken = _returnToken;
                            break;
                        }
                    case ']':
                        {
                            mR_BRACKET(true);
                            theRetToken = _returnToken;
                            break;
                        }
                    case ')':
                        {
                            mR_PAREN(true);
                            theRetToken = _returnToken;
                            break;
                        }
                    case ';':
                        {
                            mSEMI(true);
                            theRetToken = _returnToken;
                            break;
                        }
                    case '@':
                        {
                            mAT_SIGN(true);
                            theRetToken = _returnToken;
                            break;
                        }
                    case '\t':
                    case '\n':
                    case '\u000c':
                    case '\r':
                    case ' ':
                        {
                            mWS(true);
                            theRetToken = _returnToken;
                            break;
                        }
                    case '/':
                        {
                            mML_COMMENT(true);
                            theRetToken = _returnToken;
                            break;
                        }
                    case '0':
                    case '1':
                    case '2':
                    case '3':
                    case '4':
                    case '5':
                    case '6':
                    case '7':
                    case '8':
                    case '9':
                        {
                            mNUMBER(true);
                            theRetToken = _returnToken;
                            break;
                        }
                    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':
                        {
                            mUPPER(true);
                            theRetToken = _returnToken;
                            break;
                        }
                    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':
                        {
                            mLOWER(true);
                            theRetToken = _returnToken;
                            break;
                        }
                    case '"':
                        {
                            mC_STRING(true);
                            theRetToken = _returnToken;
                            break;
                        }
                    default:
                        if ((LA(1) == '.') && (LA(2) == '.') && (LA(3) == '.')) {
                            mELLIPSIS(true);
                            theRetToken = _returnToken;
                        } else if ((LA(1) == '-') && (LA(2) == '-') && ((LA(3) >= '\u0003' && LA(3) <= '\u00ff'))) {
                            mSL_COMMENT(true);
                            theRetToken = _returnToken;
                        } else if ((LA(1) == '\'') && (_tokenSet_0.member(LA(2))) && (_tokenSet_1.member(LA(3)))) {
                            mB_OR_H_STRING(true);
                            theRetToken = _returnToken;
                        } else if ((LA(1) == ':') && (LA(2) == ':')) {
                            mASSIGN_OP(true);
                            theRetToken = _returnToken;
                        } else if ((LA(1) == '-') && (LA(2) == '-') && (true)) {
                            mCOMMENT(true);
                            theRetToken = _returnToken;
                        } else if ((LA(1) == '.') && (LA(2) == '.') && (true)) {
                            mDOTDOT(true);
                            theRetToken = _returnToken;
                        } else if ((LA(1) == '\'') && (LA(2) == 'B') && (true)) {
                            mCHARB(true);
                            theRetToken = _returnToken;
                        } else if ((LA(1) == '\'') && (LA(2) == 'H')) {
                            mCHARH(true);
                            theRetToken = _returnToken;
                        } else if ((LA(1) == ':') && (true)) {
                            mCOLON(true);
                            theRetToken = _returnToken;
                        } else if ((LA(1) == '.') && (true)) {
                            mDOT(true);
                            theRetToken = _returnToken;
                        } else if ((LA(1) == '-') && (true)) {
                            mMINUS(true);
                            theRetToken = _returnToken;
                        } else if ((LA(1) == '\'') && (true)) {
                            mSINGLE_QUOTE(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 52 with NoViableAltForCharException

use of antlr.NoViableAltForCharException in project jasn1 by openmuc.

the class ASNLexer method mNUMBER.

public final void mNUMBER(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
    int _ttype;
    Token _token = null;
    int _begin = text.length();
    _ttype = NUMBER;
    int _saveIndex;
    {
        int _cnt46 = 0;
        _loop46: do {
            if (((LA(1) >= '0' && LA(1) <= '9'))) {
                matchRange('0', '9');
            } else {
                if (_cnt46 >= 1) {
                    break _loop46;
                } else {
                    throw new NoViableAltForCharException((char) LA(1), getFilename(), getLine(), getColumn());
                }
            }
            _cnt46++;
        } 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 53 with NoViableAltForCharException

use of antlr.NoViableAltForCharException in project jasn1 by openmuc.

the class ASNLexer method mML_COMMENT.

public final void mML_COMMENT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
    int _ttype;
    Token _token = null;
    int _begin = text.length();
    _ttype = ML_COMMENT;
    int _saveIndex;
    match("/*");
    {
        _loop43: do {
            if ((LA(1) == '*') && (_tokenSet_3.member(LA(2)))) {
                {
                    match('*');
                    matchNot('/');
                }
            } else if ((LA(1) == '\n' || LA(1) == '\r')) {
                {
                    {
                        switch(LA(1)) {
                            case '\r':
                                {
                                    match('\r');
                                    break;
                                }
                            case '\n':
                                {
                                    break;
                                }
                            default:
                                {
                                    throw new NoViableAltForCharException((char) LA(1), getFilename(), getLine(), getColumn());
                                }
                        }
                    }
                    match('\n');
                }
                if (inputState.guessing == 0) {
                    newline();
                }
            } else if ((_tokenSet_4.member(LA(1)))) {
                matchNot('*');
            } else {
                break _loop43;
            }
        } while (true);
    }
    match("*/");
    if (inputState.guessing == 0) {
        _ttype = Token.SKIP;
    }
    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 54 with NoViableAltForCharException

use of antlr.NoViableAltForCharException in project jasn1 by openmuc.

the class ASNLexer method mB_OR_H_STRING.

public final void mB_OR_H_STRING(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
    int _ttype;
    Token _token = null;
    int _begin = text.length();
    _ttype = B_OR_H_STRING;
    int _saveIndex;
    {
        boolean synPredMatched67 = false;
        if (((LA(1) == '\'') && (LA(2) == '0' || LA(2) == '1') && (_tokenSet_6.member(LA(3))) && (_tokenSet_7.member(LA(4))) && (true) && (true) && (true) && (true) && (true) && (true) && (true))) {
            int _m67 = mark();
            synPredMatched67 = true;
            inputState.guessing++;
            try {
                {
                    mB_STRING(false);
                }
            } catch (RecognitionException pe) {
                synPredMatched67 = false;
            }
            rewind(_m67);
            inputState.guessing--;
        }
        if (synPredMatched67) {
            mB_STRING(false);
            if (inputState.guessing == 0) {
                _ttype = B_STRING;
            }
        } else if ((LA(1) == '\'') && (_tokenSet_0.member(LA(2))) && (_tokenSet_1.member(LA(3))) && (_tokenSet_8.member(LA(4))) && (true) && (true) && (true) && (true) && (true) && (true) && (true)) {
            mH_STRING(false);
            if (inputState.guessing == 0) {
                _ttype = H_STRING;
            }
        } else {
            throw new NoViableAltForCharException((char) 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) TokenStreamRecognitionException(antlr.TokenStreamRecognitionException) RecognitionException(antlr.RecognitionException)

Example 55 with NoViableAltForCharException

use of antlr.NoViableAltForCharException in project groovy-core by groovy.

the class SourceUnit method failedWithUnexpectedEOF.

/**
 * Convenience routine, primarily for use by the InteractiveShell,
 * that returns true if parse() failed with an unexpected EOF.
 */
public boolean failedWithUnexpectedEOF() {
    // If you find another way, please add it.
    if (getErrorCollector().hasErrors()) {
        Message last = (Message) getErrorCollector().getLastError();
        Throwable cause = null;
        if (last instanceof SyntaxErrorMessage) {
            cause = ((SyntaxErrorMessage) last).getCause().getCause();
        }
        if (cause != null) {
            if (cause instanceof NoViableAltException) {
                return isEofToken(((NoViableAltException) cause).token);
            } else if (cause instanceof NoViableAltForCharException) {
                char badChar = ((NoViableAltForCharException) cause).foundChar;
                return badChar == CharScanner.EOF_CHAR;
            } else if (cause instanceof MismatchedCharException) {
                char badChar = (char) ((MismatchedCharException) cause).foundChar;
                return badChar == CharScanner.EOF_CHAR;
            } else if (cause instanceof MismatchedTokenException) {
                return isEofToken(((MismatchedTokenException) cause).token);
            }
        }
    }
    return false;
}
Also used : SimpleMessage(org.codehaus.groovy.control.messages.SimpleMessage) Message(org.codehaus.groovy.control.messages.Message) SyntaxErrorMessage(org.codehaus.groovy.control.messages.SyntaxErrorMessage) SyntaxErrorMessage(org.codehaus.groovy.control.messages.SyntaxErrorMessage) NoViableAltForCharException(antlr.NoViableAltForCharException) NoViableAltException(antlr.NoViableAltException) MismatchedTokenException(antlr.MismatchedTokenException) MismatchedCharException(antlr.MismatchedCharException)

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