Package org.antlr.runtime

Examples of org.antlr.runtime.MismatchedTokenException


                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


      m = errorPrefix + tokenText + nvae.grammarDecisionDescription;
      reportProblem(line, m, st, et);
    } else if (re instanceof MismatchedTokenException) {

      errorPrefix = "Mismatched Input: ";
      MismatchedTokenException mte = (MismatchedTokenException) re;
      int expecting = mte.expecting;
      String expectedToken = "";
      if (expecting > 0) {
        expectedToken = parser.getTokenNames()[expecting];
        errorPrefix = errorPrefix + "Expecting \"" + expectedToken;
View Full Code Here

        reporter.reportProblem(defaultProblem);
        problems.add(defaultProblem);
        System.out.println(messages[0] + " ### line " + ec.token.getLine());
      }
    } else if (re instanceof MismatchedTokenException) {
      MismatchedTokenException ec = (MismatchedTokenException) re;
      if (message == null || ec.token.getText() == null) {
        m = ec.toString();
      } else {
        m = "mismatched input: " + message + " : " + ec.token.getText();
      }
      // if (message == null) {
      // message = "mismatched input "
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 String getErrorMessageLexer(RecognitionException e, String[] tokenNames) {
    String msg = null;
    if ( e instanceof MismatchedTokenException ) {
      MismatchedTokenException mte = (MismatchedTokenException)e;
      msg = "mismatched character "+lexer.getCharErrorDisplay(e.c)+" expecting "+lexer.getCharErrorDisplay(mte.expecting);
    }
    else if ( e instanceof NoViableAltException ) {
//      NoViableAltException nvae = (NoViableAltException)e;
      // for development, can add "decision=<<"+nvae.grammarDecisionDescription+">>"
View Full Code Here

        tokenName = tokenNames[mte.expecting];
      }
      msg = "missing "+tokenName+" at "+parser.getTokenErrorDisplay(e.token);
    }
    else if ( e instanceof MismatchedTokenException ) {
      MismatchedTokenException mte = (MismatchedTokenException)e;
      String tokenName="<unknown>";
      if ( mte.expecting== Token.EOF ) {
        tokenName = "EOF";
      }
      else {
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

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

      throw new MismatchedTokenException(ttype, 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.