aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/antlr4_cpp_runtime/src/Exceptions.h
blob: 35d72b52ee27e40cfbe9a7ce4586790647eff951 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
 * Use of this file is governed by the BSD 3-clause license that
 * can be found in the LICENSE.txt file in the project root.
 */

#pragma once

#include "antlr4-common.h"

namespace antlr4 {

  // An exception hierarchy modelled loosely after java.lang.* exceptions.
  class ANTLR4CPP_PUBLIC RuntimeException : public std::exception {
  private:
    std::string _message;
  public:
    RuntimeException(const std::string &msg = "");

    virtual const char* what() const noexcept override;
  };

  class ANTLR4CPP_PUBLIC IllegalStateException : public RuntimeException {
  public:
    IllegalStateException(const std::string &msg = "") : RuntimeException(msg) {}
    IllegalStateException(IllegalStateException const&) = default;
    ~IllegalStateException();
    IllegalStateException& operator=(IllegalStateException const&) = default;
  };

  class ANTLR4CPP_PUBLIC IllegalArgumentException : public RuntimeException {
  public:
    IllegalArgumentException(IllegalArgumentException const&) = default;
    IllegalArgumentException(const std::string &msg = "") : RuntimeException(msg) {}
    ~IllegalArgumentException();
    IllegalArgumentException& operator=(IllegalArgumentException const&) = default;
  };

  class ANTLR4CPP_PUBLIC NullPointerException : public RuntimeException {
  public:
    NullPointerException(const std::string &msg = "") : RuntimeException(msg) {}
    NullPointerException(NullPointerException const&) = default;
    ~NullPointerException();
    NullPointerException& operator=(NullPointerException const&) = default;
  };

  class ANTLR4CPP_PUBLIC IndexOutOfBoundsException : public RuntimeException {
  public:
    IndexOutOfBoundsException(const std::string &msg = "") : RuntimeException(msg) {}
    IndexOutOfBoundsException(IndexOutOfBoundsException const&) = default;
    ~IndexOutOfBoundsException();
    IndexOutOfBoundsException& operator=(IndexOutOfBoundsException const&) = default;
  };

  class ANTLR4CPP_PUBLIC UnsupportedOperationException : public RuntimeException {
  public:
    UnsupportedOperationException(const std::string &msg = "") : RuntimeException(msg) {}
    UnsupportedOperationException(UnsupportedOperationException const&) = default;
    ~UnsupportedOperationException();
    UnsupportedOperationException& operator=(UnsupportedOperationException const&) = default;

  };

  class ANTLR4CPP_PUBLIC EmptyStackException : public RuntimeException {
  public:
    EmptyStackException(const std::string &msg = "") : RuntimeException(msg) {}
    EmptyStackException(EmptyStackException const&) = default;
    ~EmptyStackException();
    EmptyStackException& operator=(EmptyStackException const&) = default;
  };

  // IOException is not a runtime exception (in the java hierarchy).
  // Hence we have to duplicate the RuntimeException implementation.
  class ANTLR4CPP_PUBLIC IOException : public std::exception {
  private:
    std::string _message;

  public:
    IOException(const std::string &msg = "");

    virtual const char* what() const noexcept override;
  };

  class ANTLR4CPP_PUBLIC CancellationException : public IllegalStateException {
  public:
    CancellationException(const std::string &msg = "") : IllegalStateException(msg) {}
    CancellationException(CancellationException const&) = default;
    ~CancellationException();
    CancellationException& operator=(CancellationException const&) = default;
  };

  class ANTLR4CPP_PUBLIC ParseCancellationException : public CancellationException {
  public:
    ParseCancellationException(const std::string &msg = "") : CancellationException(msg) {}
    ParseCancellationException(ParseCancellationException const&) = default;
    ~ParseCancellationException();
    ParseCancellationException& operator=(ParseCancellationException const&) = default;
  };

} // namespace antlr4