Package org.antlr.runtime

Examples of org.antlr.runtime.MismatchedTokenException


        StringBuilder errorMsg = new StringBuilder();
        String[] names = antlr.getTokenNames();
        if (re.token != null && re.token.getType() == ExpressionParser.EOF) {
            errorMsg.append("unexpected end of expression");
        } else if (re instanceof MismatchedTokenException) {
            MismatchedTokenException mte = (MismatchedTokenException) re;
            String txt;
            String expecting;
            // bleh same exception class has different fields set depending on
            // where it occurred
            if (antlr instanceof Lexer) {
View Full Code Here


      String query = "ship = load 'x';";
      try {
            ParserTestingUtils.generateLogicalPlan( query );
        } catch(Exception ex) {
            Assert.assertTrue( ex instanceof MismatchedTokenException );
            MismatchedTokenException mex = (MismatchedTokenException)ex;
            Assert.assertTrue( mex.token.getText().equals("ship") );
            return;
        }
        Assert.fail( "Query is supposed to be failing." );
    }
View Full Code Here

      String query = "A = load 'y'; all = load 'x';";
      try {
            ParserTestingUtils.generateLogicalPlan( query );
        } catch(Exception ex) {
            Assert.assertTrue( ex instanceof MismatchedTokenException );
            MismatchedTokenException mex = (MismatchedTokenException)ex;
            Assert.assertTrue( mex.token.getText().equals("all") );
            return;
        }
        Assert.fail( "Query is supposed to be failing." );
    }
View Full Code Here

    }

    public boolean mismatch(BaseRecognizer br, IntStream input, int ttype, BitSet follow)
        throws RecognitionException {

        throw new MismatchedTokenException(ttype, input);
    }
View Full Code Here

        throw new MismatchedTokenException(ttype, input);
    }

    public Object recoverFromMismatchedToken(BaseRecognizer br, IntStream input, int ttype,
            BitSet follow) throws RecognitionException {
        throw new MismatchedTokenException(ttype, input);
    }
View Full Code Here

                tokenName = tokenNames[ute.expecting];
            }
            msg = "Unexpected input. Expecting \"" + tokenName + "\", got \"" + ute.getUnexpectedToken().getText()
                    + "\" at " + getTokenLocation(ute);
        } else if (e instanceof MismatchedTokenException) {
            MismatchedTokenException mte = (MismatchedTokenException)e;
            String tokenName;
            if (mte.expecting== Token.EOF) {
                tokenName = "EOF";
            } else {
                tokenName = tokenNames[mte.expecting];
View Full Code Here

                              null,
                              DroolsEditorType.IDENTIFIER );
            if ( state.failed ) return null;
            return StringUtils.unescapeJava( safeStripStringDelimiters( id.getText() ) );
        } else {
            throw new MismatchedTokenException( DRLLexer.ID,
                                                input );
        }
    }
View Full Code Here

        if ( text != null ) {
            e = new DroolsMismatchedTokenException( ttype,
                                                    text,
                                                    input );
        } else {
            e = new MismatchedTokenException( ttype,
                                              input );
        }
        throw e;
    }
View Full Code Here

                              null,
                              DroolsEditorType.IDENTIFIER );
            if ( state.failed ) return null;
            return StringUtils.unescapeJava( safeStripStringDelimiters( id.getText() ) );
        } else {
            throw new MismatchedTokenException( DRL5Lexer.ID,
                                                input );
        }
    }
View Full Code Here

        if ( text != null ) {
            e = new DroolsMismatchedTokenException( ttype,
                                                    text,
                                                    input );
        } else {
            e = new MismatchedTokenException( ttype,
                                              input );
        }
        throw e;
    }
View Full Code Here

TOP

Related Classes of org.antlr.runtime.MismatchedTokenException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.