Package org.antlr.runtime

Examples of org.antlr.runtime.MismatchedTokenException


        msg = "cannot recognize input near "
                + getTokenErrorDisplay(e.token)
                + (input.LT(2) != null ? " " + getTokenErrorDisplay(input.LT(2)) : "")
                + (input.LT(3) != null ? " " + getTokenErrorDisplay(input.LT(3)) : "");
      } else if (e instanceof MismatchedTokenException) {
        MismatchedTokenException mte = (MismatchedTokenException) e;
        msg = super.getErrorMessage(e, xlateNames) + (input.LT(-1) == null ? "":" near '" + input.LT(-1).getText()) + "'";
      } else if (e instanceof FailedPredicateException) {
        FailedPredicateException fpe = (FailedPredicateException) e;
        msg = "Failed to recognize predicate '" + fpe.token.getText() + "'. Failed rule: '" + fpe.ruleName + "'";
      } else {
View Full Code Here


    public void testNegative2() throws Exception {
        String query = "ship = load 'x';";
        try {
            ParserTestingUtils.generateLogicalPlan( query );
        } catch(Exception ex) {
            MismatchedTokenException mex = (MismatchedTokenException)ex;
            assertTrue( mex.token.getText().equals("ship") );
            throw ex;
        }
    }
View Full Code Here

    public void testNegative3() throws Exception {
      String query = "A = load 'y'; all = load 'x';";
      try {
            ParserTestingUtils.generateLogicalPlan( query );
        } catch(Exception ex) {
            MismatchedTokenException mex = (MismatchedTokenException)ex;
            assertTrue( mex.token.getText().equals("all") );
            throw ex;
        }
    }
View Full Code Here

    @Override
    protected void mismatch(IntStream input, int ttype, BitSet follow)
        throws RecognitionException {

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

        msg = "cannot recognize input near "
                + getTokenErrorDisplay(e.token)
                + (input.LT(2) != null ? " " + getTokenErrorDisplay(input.LT(2)) : "")
                + (input.LT(3) != null ? " " + getTokenErrorDisplay(input.LT(3)) : "");
      } else if (e instanceof MismatchedTokenException) {
        MismatchedTokenException mte = (MismatchedTokenException) e;
        msg = super.getErrorMessage(e, xlateNames) + (input.LT(-1) == null ? "":" near '" + input.LT(-1).getText()) + "'";
      } else if (e instanceof FailedPredicateException) {
        FailedPredicateException fpe = (FailedPredicateException) e;
        msg = "Failed to recognize predicate '" + fpe.token.getText() + "'. Failed rule: '" + fpe.ruleName + "'";
      } else {
View Full Code Here

      msg = "Unexpected token "+tokenName(parser, ex.getUnexpectedType());
      if (statement != null) {
        msg += " in "+ActionScriptFactory.str(statement);
      }
    } else if (e instanceof MismatchedTokenException) {
      MismatchedTokenException ex = (MismatchedTokenException)e;
      msg = "Unexpected token "+tokenName(parser, ex.getUnexpectedType())+" (expecting "+tokenName(parser, ex.expecting)+")";
      if (statement != null) {
        msg += " in "+ActionScriptFactory.str(statement);
      }
    } else {
      if (statement == null) {
View Full Code Here

   */
  private List<String> createErrorMessage(RecognitionException e) {
    List<String> codeAndMessage = new ArrayList<String>(2);
    String message = "";
    if (e instanceof MismatchedTokenException) {
      MismatchedTokenException mte = (MismatchedTokenException) e;
      if (tokenNames != null && mte.expecting >= 0 && mte.expecting < tokenNames.length) {
        message = String
            .format(
                DroolsParserExceptionFactory.MISMATCHED_TOKEN_MESSAGE_COMPLETE,
                e.line, e.charPositionInLine,
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

      return "Lexer error at token '" + c + "' at line " + nvae.line + " char "
          + nvae.charPositionInLine;
    }

    if (re instanceof MismatchedTokenException) {
      MismatchedTokenException mte = (MismatchedTokenException) re;
      String token = (mte.token == null) ? "\"\"" : mte.token.getText();

      return "Parser error: unexpected '" + token + "' at position "
          + mte.charPositionInLine + " line " + mte.line + ": '" + mte.input
          + "'";
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.