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.
8 #include "antlr4-common.h"
12 // An exception hierarchy modelled loosely after java.lang.* exceptions.
13 class ANTLR4CPP_PUBLIC RuntimeException : public std::exception {
17 RuntimeException(const std::string &msg = "");
19 virtual const char* what() const NOEXCEPT override;
22 class ANTLR4CPP_PUBLIC IllegalStateException : public RuntimeException {
24 IllegalStateException(const std::string &msg = "") : RuntimeException(msg) {}
25 IllegalStateException(IllegalStateException const&) = default;
26 ~IllegalStateException();
27 IllegalStateException& operator=(IllegalStateException const&) = default;
30 class ANTLR4CPP_PUBLIC IllegalArgumentException : public RuntimeException {
32 IllegalArgumentException(IllegalArgumentException const&) = default;
33 IllegalArgumentException(const std::string &msg = "") : RuntimeException(msg) {}
34 ~IllegalArgumentException();
35 IllegalArgumentException& operator=(IllegalArgumentException const&) = default;
38 class ANTLR4CPP_PUBLIC NullPointerException : public RuntimeException {
40 NullPointerException(const std::string &msg = "") : RuntimeException(msg) {}
41 NullPointerException(NullPointerException const&) = default;
42 ~NullPointerException();
43 NullPointerException& operator=(NullPointerException const&) = default;
46 class ANTLR4CPP_PUBLIC IndexOutOfBoundsException : public RuntimeException {
48 IndexOutOfBoundsException(const std::string &msg = "") : RuntimeException(msg) {}
49 IndexOutOfBoundsException(IndexOutOfBoundsException const&) = default;
50 ~IndexOutOfBoundsException();
51 IndexOutOfBoundsException& operator=(IndexOutOfBoundsException const&) = default;
54 class ANTLR4CPP_PUBLIC UnsupportedOperationException : public RuntimeException {
56 UnsupportedOperationException(const std::string &msg = "") : RuntimeException(msg) {}
57 UnsupportedOperationException(UnsupportedOperationException const&) = default;
58 ~UnsupportedOperationException();
59 UnsupportedOperationException& operator=(UnsupportedOperationException const&) = default;
63 class ANTLR4CPP_PUBLIC EmptyStackException : public RuntimeException {
65 EmptyStackException(const std::string &msg = "") : RuntimeException(msg) {}
66 EmptyStackException(EmptyStackException const&) = default;
67 ~EmptyStackException();
68 EmptyStackException& operator=(EmptyStackException const&) = default;
71 // IOException is not a runtime exception (in the java hierarchy).
72 // Hence we have to duplicate the RuntimeException implementation.
73 class ANTLR4CPP_PUBLIC IOException : public std::exception {
78 IOException(const std::string &msg = "");
80 virtual const char* what() const NOEXCEPT override;
83 class ANTLR4CPP_PUBLIC CancellationException : public IllegalStateException {
85 CancellationException(const std::string &msg = "") : IllegalStateException(msg) {}
86 CancellationException(CancellationException const&) = default;
87 ~CancellationException();
88 CancellationException& operator=(CancellationException const&) = default;
91 class ANTLR4CPP_PUBLIC ParseCancellationException : public CancellationException {
93 ParseCancellationException(const std::string &msg = "") : CancellationException(msg) {}
94 ParseCancellationException(ParseCancellationException const&) = default;
95 ~ParseCancellationException();
96 ParseCancellationException& operator=(ParseCancellationException const&) = default;