2 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 package com.mysql.clusterj.jdbc.antlr;
20 import org.antlr.runtime.RecognitionException;
21 import org.antlr.runtime.BaseRecognizer;
23 import java.util.List;
26 * Generic ErrorListener for RecognitionExceptions.
27 * Enables client code to flexibly override error handling/presentation.
30 public interface ErrorListener {
33 * Called by reportError to display a recognition error.
34 * Normally it is sufficient to implement this method.
39 void displayRecognitionError(String[] tokenNames, RecognitionException e);
42 * The main entry point for reporting recognition errors.
43 * Override only if you want to show "spurious" errors during recovery, too.
44 * @see org.antlr.runtime.BaseRecognizer.reportError
46 * @param e A runtime exception containing information about the error.
48 public void reportError(RecognitionException e);
51 * Generates a header line for error messages, normally containing source file and the position
52 * in the file where the error occured.
55 * @return String to print as a location information for the error
57 public String getErrorHeader(RecognitionException e);
60 * Generates the message string for the actual error occured, must distinguish between
61 * the different RecognitionException subclasses.
65 * @return String to print as an explanation of the error
67 public String getErrorMessage(RecognitionException e, String[] tokenNames);
70 * Redirects an error message to the appropriate place, relying on the other methods
71 * to actually produce a message
72 * @param msg Preformatted error message
74 public void emitErrorMessage(String msg);
77 * Check whether errors have occurred during recognition.
78 * @return true if errors have occurred
80 public boolean hasErrors();
83 * Retrieve the list of errors occurred.
85 * @return Might be null for ErrorListeners that don't queue up errors.
87 public List<RecognitionException> getErrors();