1 /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
2  * Use of this file is governed by the BSD 3-clause license that
3  * can be found in the LICENSE.txt file in the project root.
4  */
5 
6 #pragma once
7 
8 #include "ANTLRErrorListener.h"
9 #include "Exceptions.h"
10 
11 namespace antlr4 {
12 
13   /// This implementation of ANTLRErrorListener dispatches all calls to a
14   /// collection of delegate listeners. This reduces the effort required to support multiple
15   /// listeners.
16   class ANTLR4CPP_PUBLIC ProxyErrorListener : public ANTLRErrorListener {
17   private:
18     std::set<ANTLRErrorListener *> _delegates; // Not owned.
19 
20   public:
21     void addErrorListener(ANTLRErrorListener *listener);
22     void removeErrorListener(ANTLRErrorListener *listener);
23     void removeErrorListeners();
24 
25     void syntaxError(Recognizer *recognizer, Token *offendingSymbol, size_t line, size_t charPositionInLine,
26                      const std::string &msg, std::exception_ptr e) override;
27 
28     virtual void reportAmbiguity(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex, bool exact,
29                                  const antlrcpp::BitSet &ambigAlts, atn::ATNConfigSet *configs) override;
30 
31     virtual void reportAttemptingFullContext(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex,
32       const antlrcpp::BitSet &conflictingAlts, atn::ATNConfigSet *configs) override;
33 
34     virtual void reportContextSensitivity(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex,
35                                           size_t prediction, atn::ATNConfigSet *configs) override;
36   };
37 
38 } // namespace antlr4
39