ApplicationParser implements IParser { @Override public ParseContext parse(String cql) throws ParseException { LOG.info("start to parse cql : {}", cql); CQLErrorListener errorListener = new CQLErrorListener(); CQLLexer lexer = new CQLLexer(new ANTLRIgnoreCaseStringStream(cql)); lexer.removeErrorListeners(); lexer.addErrorListener(errorListener); CommonTokenStream tokens = new CommonTokenStream(lexer); CQLParser parser = new CQLParser(tokens); CQLErrorStrategy errorHandler = new CQLErrorStrategy(); parser.setErrorHandler(errorHandler); parser.removeErrorListeners(); parser.addErrorListener(errorListener); CQLParser.StatementContext tree = parser.statement(); if (errorListener.getRecException() != null) { errorListener.getRecException().setCql(cql); throw errorListener.getRecException(); } LOG.info("Parse Completed"); ApplicationVisitor visitor = new ApplicationVisitor(); return visitor.visit(tree); }  @Override ParseContext parse(String cql);  }
@Test public void testParse() { String cql = "select from S"; IParser parser = new ApplicationParser(); try { parser.parse(cql); } catch (ParseException e) { System.out.println(e.getCql()); System.out.println(e.getCqlSummary()); System.out.println(e.getErrorCode()); System.out.println(e.getErrorCode().getFormattedMessage()); System.out.println(e.getErrorCode().getErrorCode()); System.out.println(e.getErrorCode().getSqlState()); assertTrue(true); return; } fail("test failed!"); }