18 package com.mysql.clusterj.jdbc.antlr;
20 import org.antlr.runtime.IntStream;
21 import org.antlr.runtime.NoViableAltException;
22 import org.antlr.runtime.Parser;
23 import org.antlr.runtime.RecognizerSharedState;
24 import org.antlr.runtime.RecognitionException;
25 import org.antlr.runtime.Token;
26 import org.antlr.runtime.TokenStream;
28 import java.util.List;
29 import java.util.logging.Level;
30 import java.util.logging.Logger;
37 private static final Logger log = Logger.getLogger(
MySQLParser.class.getName());
41 public String getTokenErrorDisplay(Token t) {
50 public MySQLParser(TokenStream input, RecognizerSharedState state) {
56 this.errorListener = listener;
68 public String getErrorHeader(RecognitionException e) {
72 public void emitErrorMessage(
String msg) {
77 @SuppressWarnings(
"unchecked")
78 public
String getErrorMessage(RecognitionException re,
String[] tokenNames) {
79 if (log.isLoggable(Level.FINEST)) {
80 List stack = getRuleInvocationStack(re, this.getClass().getName());
82 if (re instanceof NoViableAltException) {
83 NoViableAltException nvae = (NoViableAltException)re;
84 msg =
" no viable alternative for token="+ re.token +
"\n" +
85 " at decision="+nvae.decisionNumber +
" state=" + nvae.stateNumber;
86 if (nvae.grammarDecisionDescription != null && nvae.grammarDecisionDescription.length() > 0)
87 msg = msg +
"\n decision grammar=<< "+ nvae.grammarDecisionDescription +
" >>";
89 msg = super.getErrorMessage(re, tokenNames);
91 return stack +
"\n" + msg;
98 public void reportError(RecognitionException e) {
102 protected Object getCurrentInputSymbol(IntStream input) {
103 return super.getCurrentInputSymbol(input);
107 public void originalDisplayError(
String[] tokenNames, RecognitionException e) {
108 super.displayRecognitionError(tokenNames, e);
111 public void originalReportError(RecognitionException e) {
112 super.reportError(e);
115 public String originalGetErrorHeader(RecognitionException e) {
116 return super.getErrorHeader(e);
119 public String originalGetErrorMessage(RecognitionException e,
String[] tokenNames) {
120 return super.getErrorMessage(e, tokenNames);
123 public void originalEmitErrorMessage(
String msg) {