blob: b7b014307f0b4e40cc5aeda0362aee9d9e60cb44 (
plain)
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
|
#ifndef ERRORS_HH
#define ERRORS_HH
#include "location.hh"
#include <iosfwd>
#include <memory>
#include <string>
#include <string_view>
namespace src {
class Errors {
public:
virtual ~Errors() = default;
Errors(Errors const&) = delete;
Errors& operator=(Errors const&) = delete;
virtual void err(Location loc, std::string_view msg) = 0;
virtual void warn(Location loc, std::string_view msg) = 0;
#ifndef NDEBUG
virtual void dbg(Location loc, std::string_view msg) = 0;
#else
void dbg(Location, std::string_view) {}
#endif
[[nodiscard]]
virtual uint64_t errors() const = 0;
[[nodiscard]]
virtual uint64_t warnings() const = 0;
protected:
Errors() = default;
};
class ErrorsOutput {
public:
virtual ~ErrorsOutput() = default;
ErrorsOutput(ErrorsOutput const&) = delete;
ErrorsOutput& operator=(ErrorsOutput const&) = delete;
virtual void println(std::string_view line) = 0;
protected:
ErrorsOutput() = default;
};
[[nodiscard]]
std::unique_ptr<Errors> file_errors(
std::string filename, std::shared_ptr<ErrorsOutput> output = nullptr);
[[nodiscard]]
std::unique_ptr<Errors> ignore_errors();
[[nodiscard]]
std::unique_ptr<ErrorsOutput> errors_output_ios(std::ostream& out);
} // namespace src
#endif // ERRORS_HH
|