private CommonTree parse(String preparedSql) {
CommonTree result = null;
ANTLRNoCaseStringStream inputStream = new ANTLRNoCaseStringStream(preparedSql);
MySQL51Lexer lexer = new MySQL51Lexer(inputStream);
CommonTokenStream tokens = new CommonTokenStream(lexer);
lexer.setErrorListener(new QueuingErrorListener(lexer));
tokens.getTokens();
if (lexer.getErrorListener().hasErrors()) {
logger.warn(local.message("ERR_Lexing_SQ",preparedSql));
return result;
}
PlaceholderNode.resetId();
MySQL51Parser parser = new MySQL51Parser(tokens);
parser.setTreeAdaptor(mySQLTreeAdaptor);
parser.setErrorListener(new QueuingErrorListener(parser));
try {
CommonTree stmtTree = (CommonTree) parser.statement().getTree();
result = stmtTree;
} catch (RecognitionException e) {
logger.warn(local.message("ERR_Parsing_SQL", preparedSql));