]> gitweb.ps.run Git - toc/blob - antlr4-cpp-runtime-4.9.2-source/runtime/src/ProxyErrorListener.cpp
add antlr source code and ReadMe
[toc] / antlr4-cpp-runtime-4.9.2-source / runtime / src / ProxyErrorListener.cpp
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 #include "ProxyErrorListener.h"
7
8 using namespace antlr4;
9
10 void ProxyErrorListener::addErrorListener(ANTLRErrorListener *listener) {
11   if (listener == nullptr) {
12     throw "listener cannot be null.";
13   }
14
15   _delegates.insert(listener);
16 }
17
18 void ProxyErrorListener::removeErrorListener(ANTLRErrorListener *listener) {
19   _delegates.erase(listener);
20 }
21
22 void ProxyErrorListener::removeErrorListeners() {
23   _delegates.clear();
24 }
25
26 void ProxyErrorListener::syntaxError(Recognizer *recognizer, Token *offendingSymbol, size_t line,
27   size_t charPositionInLine, const std::string &msg, std::exception_ptr e) {
28
29   for (auto *listener : _delegates) {
30     listener->syntaxError(recognizer, offendingSymbol, line, charPositionInLine, msg, e);
31   }
32 }
33
34 void ProxyErrorListener::reportAmbiguity(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex,
35   bool exact, const antlrcpp::BitSet &ambigAlts, atn::ATNConfigSet *configs) {
36   for (auto *listener : _delegates) {
37     listener->reportAmbiguity(recognizer, dfa, startIndex, stopIndex, exact, ambigAlts, configs);
38   }
39 }
40
41 void ProxyErrorListener::reportAttemptingFullContext(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex,
42   size_t stopIndex, const antlrcpp::BitSet &conflictingAlts, atn::ATNConfigSet *configs) {
43   for (auto *listener : _delegates) {
44     listener->reportAttemptingFullContext(recognizer, dfa, startIndex, stopIndex, conflictingAlts, configs);
45   }
46 }
47
48 void ProxyErrorListener::reportContextSensitivity(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex,
49   size_t prediction, atn::ATNConfigSet *configs) {
50   for (auto *listener : _delegates) {
51     listener->reportContextSensitivity(recognizer, dfa, startIndex, stopIndex, prediction, configs);
52   }
53 }