]> review.fuel-infra Code Review - packages/trusty/mysql-wsrep-5.6.git/blob
b249fcdfefd3c097295b36c1e86cbfa694d711f4
[packages/trusty/mysql-wsrep-5.6.git] /
1 /*
2  *  Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
3  *
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.
7  *
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.
12  *
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
16  */
17
18 package com.mysql.clusterj.jdbc.antlr;
19
20 import org.antlr.runtime.RecognitionException;
21 import org.antlr.runtime.BaseRecognizer;
22
23 import java.util.List;
24
25 /**
26  * Generic ErrorListener for RecognitionExceptions.
27  * Enables client code to flexibly override error handling/presentation.
28  * Author: kroepke
29  */
30 public interface ErrorListener {
31
32     /**
33      * Called by reportError to display a recognition error.
34      * Normally it is sufficient to implement this method.
35      *
36      * @param tokenNames
37      * @param e
38      */
39     void displayRecognitionError(String[] tokenNames, RecognitionException e);
40
41     /**
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
45      * 
46      * @param e A runtime exception containing information about the error.
47      */
48     public void reportError(RecognitionException e);
49
50     /**
51      * Generates a header line for error messages, normally containing source file and the position
52      * in the file where the error occured.
53      *
54      * @param e
55      * @return String to print as a location information for the error
56      */
57     public String getErrorHeader(RecognitionException e);
58
59     /**
60      * Generates the message string for the actual error occured, must distinguish between
61      * the different RecognitionException subclasses.
62      *
63      * @param e
64      * @param tokenNames
65      * @return String to print as an explanation of the error
66      */
67     public String getErrorMessage(RecognitionException e, String[] tokenNames);
68
69     /**
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
73      */
74     public void emitErrorMessage(String msg);
75
76     /**
77      * Check whether errors have occurred during recognition. 
78      * @return true if errors have occurred
79      */
80     public boolean hasErrors();
81
82     /**
83      * Retrieve the list of errors occurred.
84      *
85      * @return Might be null for ErrorListeners that don't queue up errors.
86      */
87     public List<RecognitionException> getErrors();
88 }