Search in sources :

Example 86 with RecognitionException

use of antlr.RecognitionException in project cxf by apache.

the class IDLParser method attr_dcl.

public final void attr_dcl() throws RecognitionException, TokenStreamException {
    returnAST = null;
    ASTPair currentAST = new ASTPair();
    AST attr_dcl_AST = null;
    try {
        // for error handling
        switch(LA(1)) {
            case LITERAL_readonly:
                {
                    readonly_attr_spec();
                    astFactory.addASTChild(currentAST, returnAST);
                    attr_dcl_AST = (AST) currentAST.root;
                    break;
                }
            case LITERAL_attribute:
                {
                    attr_spec();
                    astFactory.addASTChild(currentAST, returnAST);
                    attr_dcl_AST = (AST) currentAST.root;
                    break;
                }
            default:
                {
                    throw new NoViableAltException(LT(1), getFilename());
                }
        }
    } catch (RecognitionException ex) {
        if (inputState.guessing == 0) {
            reportError(ex);
            consume();
            consumeUntil(_tokenSet_10);
        } else {
            throw ex;
        }
    }
    returnAST = attr_dcl_AST;
}
Also used : ASTPair(antlr.ASTPair) AST(antlr.collections.AST) NoViableAltException(antlr.NoViableAltException) RecognitionException(antlr.RecognitionException)

Example 87 with RecognitionException

use of antlr.RecognitionException in project cxf by apache.

the class IDLParser method parameter_dcls.

public final void parameter_dcls() throws RecognitionException, TokenStreamException {
    returnAST = null;
    ASTPair currentAST = new ASTPair();
    AST parameter_dcls_AST = null;
    try {
        // for error handling
        match(LPAREN);
        {
            switch(LA(1)) {
                case LITERAL_in:
                case LITERAL_out:
                case LITERAL_inout:
                    {
                        param_dcl_list();
                        astFactory.addASTChild(currentAST, returnAST);
                        break;
                    }
                case RPAREN:
                    {
                        break;
                    }
                default:
                    {
                        throw new NoViableAltException(LT(1), getFilename());
                    }
            }
        }
        match(RPAREN);
        parameter_dcls_AST = (AST) currentAST.root;
    } catch (RecognitionException ex) {
        if (inputState.guessing == 0) {
            reportError(ex);
            consume();
            consumeUntil(_tokenSet_57);
        } else {
            throw ex;
        }
    }
    returnAST = parameter_dcls_AST;
}
Also used : ASTPair(antlr.ASTPair) AST(antlr.collections.AST) NoViableAltException(antlr.NoViableAltException) RecognitionException(antlr.RecognitionException)

Example 88 with RecognitionException

use of antlr.RecognitionException in project cxf by apache.

the class IDLParser method case_stmt_list.

public final void case_stmt_list() throws RecognitionException, TokenStreamException {
    returnAST = null;
    ASTPair currentAST = new ASTPair();
    AST case_stmt_list_AST = null;
    try {
        // for error handling
        {
            int _cnt157 = 0;
            _loop157: do {
                if ((LA(1) == LITERAL_case || LA(1) == LITERAL_default)) {
                    case_stmt();
                    astFactory.addASTChild(currentAST, returnAST);
                } else {
                    if (_cnt157 >= 1) {
                        break _loop157;
                    } else {
                        throw new NoViableAltException(LT(1), getFilename());
                    }
                }
                _cnt157++;
            } while (true);
        }
        case_stmt_list_AST = (AST) currentAST.root;
    } catch (RecognitionException ex) {
        if (inputState.guessing == 0) {
            reportError(ex);
            consume();
            consumeUntil(_tokenSet_15);
        } else {
            throw ex;
        }
    }
    returnAST = case_stmt_list_AST;
}
Also used : ASTPair(antlr.ASTPair) AST(antlr.collections.AST) NoViableAltException(antlr.NoViableAltException) RecognitionException(antlr.RecognitionException)

Example 89 with RecognitionException

use of antlr.RecognitionException in project cxf by apache.

the class IDLParser method unsigned_short_int.

public final void unsigned_short_int() throws RecognitionException, TokenStreamException {
    returnAST = null;
    ASTPair currentAST = new ASTPair();
    AST unsigned_short_int_AST = null;
    try {
        // for error handling
        AST tmp146_AST = null;
        tmp146_AST = astFactory.create(LT(1));
        astFactory.addASTChild(currentAST, tmp146_AST);
        match(LITERAL_unsigned);
        AST tmp147_AST = null;
        tmp147_AST = astFactory.create(LT(1));
        astFactory.addASTChild(currentAST, tmp147_AST);
        match(LITERAL_short);
        unsigned_short_int_AST = (AST) currentAST.root;
    } catch (RecognitionException ex) {
        if (inputState.guessing == 0) {
            reportError(ex);
            consume();
            consumeUntil(_tokenSet_35);
        } else {
            throw ex;
        }
    }
    returnAST = unsigned_short_int_AST;
}
Also used : ASTPair(antlr.ASTPair) AST(antlr.collections.AST) RecognitionException(antlr.RecognitionException)

Example 90 with RecognitionException

use of antlr.RecognitionException in project cxf by apache.

the class IDLLexer 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 ';':
                        {
                            mSEMI(true);
                            theRetToken = _returnToken;
                            break;
                        }
                    case '?':
                        {
                            mQUESTION(true);
                            theRetToken = _returnToken;
                            break;
                        }
                    case '(':
                        {
                            mLPAREN(true);
                            theRetToken = _returnToken;
                            break;
                        }
                    case ')':
                        {
                            mRPAREN(true);
                            theRetToken = _returnToken;
                            break;
                        }
                    case '[':
                        {
                            mLBRACK(true);
                            theRetToken = _returnToken;
                            break;
                        }
                    case ']':
                        {
                            mRBRACK(true);
                            theRetToken = _returnToken;
                            break;
                        }
                    case '{':
                        {
                            mLCURLY(true);
                            theRetToken = _returnToken;
                            break;
                        }
                    case '}':
                        {
                            mRCURLY(true);
                            theRetToken = _returnToken;
                            break;
                        }
                    case '|':
                        {
                            mOR(true);
                            theRetToken = _returnToken;
                            break;
                        }
                    case '^':
                        {
                            mXOR(true);
                            theRetToken = _returnToken;
                            break;
                        }
                    case '&':
                        {
                            mAND(true);
                            theRetToken = _returnToken;
                            break;
                        }
                    case ',':
                        {
                            mCOMMA(true);
                            theRetToken = _returnToken;
                            break;
                        }
                    case '=':
                        {
                            mASSIGN(true);
                            theRetToken = _returnToken;
                            break;
                        }
                    case '!':
                        {
                            mNOT(true);
                            theRetToken = _returnToken;
                            break;
                        }
                    case '+':
                        {
                            mPLUS(true);
                            theRetToken = _returnToken;
                            break;
                        }
                    case '-':
                        {
                            mMINUS(true);
                            theRetToken = _returnToken;
                            break;
                        }
                    case '~':
                        {
                            mTILDE(true);
                            theRetToken = _returnToken;
                            break;
                        }
                    case '*':
                        {
                            mSTAR(true);
                            theRetToken = _returnToken;
                            break;
                        }
                    case '%':
                        {
                            mMOD(true);
                            theRetToken = _returnToken;
                            break;
                        }
                    case '\t':
                    case '\n':
                    case '\r':
                    case ' ':
                        {
                            mWS(true);
                            theRetToken = _returnToken;
                            break;
                        }
                    case '#':
                        {
                            mPREPROC_DIRECTIVE(true);
                            theRetToken = _returnToken;
                            break;
                        }
                    case '\'':
                        {
                            mCHAR_LITERAL(true);
                            theRetToken = _returnToken;
                            break;
                        }
                    case '"':
                        {
                            mSTRING_LITERAL(true);
                            theRetToken = _returnToken;
                            break;
                        }
                    case '1':
                    case '2':
                    case '3':
                    case '4':
                    case '5':
                    case '6':
                    case '7':
                    case '8':
                    case '9':
                        {
                            mINT(true);
                            theRetToken = _returnToken;
                            break;
                        }
                    case '_':
                        {
                            mESCAPED_IDENT(true);
                            theRetToken = _returnToken;
                            break;
                        }
                    default:
                        if ((LA(1) == '<') && (LA(2) == '<')) {
                            mLSHIFT(true);
                            theRetToken = _returnToken;
                        } else if ((LA(1) == '>') && (LA(2) == '>')) {
                            mRSHIFT(true);
                            theRetToken = _returnToken;
                        } else if ((LA(1) == ':') && (LA(2) == ':')) {
                            mSCOPEOP(true);
                            theRetToken = _returnToken;
                        } else if ((LA(1) == '/') && (LA(2) == '/')) {
                            mSL_COMMENT(true);
                            theRetToken = _returnToken;
                        } else if ((LA(1) == '/') && (LA(2) == '*')) {
                            mML_COMMENT(true);
                            theRetToken = _returnToken;
                        } else if ((LA(1) == 'L') && (LA(2) == '\'')) {
                            mWIDE_CHAR_LITERAL(true);
                            theRetToken = _returnToken;
                        } else if ((LA(1) == 'L') && (LA(2) == '"')) {
                            mWIDE_STRING_LITERAL(true);
                            theRetToken = _returnToken;
                        } else if ((LA(1) == '0') && (LA(2) == 'X' || LA(2) == 'x')) {
                            mHEX(true);
                            theRetToken = _returnToken;
                        } else if ((LA(1) == '.') && ((LA(2) >= '0' && LA(2) <= '9'))) {
                            mFLOAT(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)) {
                            mLT(true);
                            theRetToken = _returnToken;
                        } else if ((LA(1) == '>') && (true)) {
                            mGT(true);
                            theRetToken = _returnToken;
                        } else if ((LA(1) == '/') && (true)) {
                            mDIV(true);
                            theRetToken = _returnToken;
                        } else if ((LA(1) == '0') && (true)) {
                            mOCTAL(true);
                            theRetToken = _returnToken;
                        } else if ((_tokenSet_0.member(LA(1))) && (true)) {
                            mIDENT(true);
                            theRetToken = _returnToken;
                        } else {
                            if (LA(1) == EOF_CHAR) {
                                uponEOF();
                                _returnToken = makeToken(Token.EOF_TYPE);
                            } else {
                                throw new NoViableAltForCharException(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);
            }
            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)

Aggregations

RecognitionException (antlr.RecognitionException)170 AST (antlr.collections.AST)155 ASTPair (antlr.ASTPair)154 NoViableAltException (antlr.NoViableAltException)68 TokenStreamException (antlr.TokenStreamException)10 GroovyRecognizer (org.codehaus.groovy.antlr.parser.GroovyRecognizer)6 TokenStreamRecognitionException (antlr.TokenStreamRecognitionException)5 StringReader (java.io.StringReader)4 GroovyLexer (org.codehaus.groovy.antlr.parser.GroovyLexer)4 Token (antlr.Token)3 CharStreamException (antlr.CharStreamException)2 CharStreamIOException (antlr.CharStreamIOException)2 CommonToken (antlr.CommonToken)2 NoViableAltForCharException (antlr.NoViableAltForCharException)2 TokenStreamIOException (antlr.TokenStreamIOException)2 CheckstyleException (com.puppycrawl.tools.checkstyle.api.CheckstyleException)2 DetailAST (com.puppycrawl.tools.checkstyle.api.DetailAST)2 FileContents (com.puppycrawl.tools.checkstyle.api.FileContents)2 IncorrectTypeHintException (groovy.transform.stc.IncorrectTypeHintException)2 BufferedReader (java.io.BufferedReader)2