From 1e9e51dae1c01bab7562911b958c47528b8011c8 Mon Sep 17 00:00:00 2001 From: Joel Klinghed Date: Sun, 28 Sep 2025 22:53:30 +0200 Subject: java: Add tokens Only parses Java 8 tokens for now. --- src/errors.hh | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 src/errors.hh (limited to 'src/errors.hh') diff --git a/src/errors.hh b/src/errors.hh new file mode 100644 index 0000000..d8b3d60 --- /dev/null +++ b/src/errors.hh @@ -0,0 +1,64 @@ +#ifndef ERRORS_HH +#define ERRORS_HH + +#include "location.hh" + +#include +#include +#include +#include + +namespace src { + +class Errors { + public: + virtual ~Errors() = default; + + virtual void err(Location loc, std::string_view msg) = 0; + + virtual void warn(Location loc, std::string_view msg) = 0; + +#if !defined(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; + + Errors(Errors const&) = delete; + Errors& operator=(Errors const&) = delete; +}; + +class ErrorsOutput { + public: + virtual ~ErrorsOutput() = default; + + virtual void println(std::string_view line) = 0; + + protected: + ErrorsOutput() = default; + + ErrorsOutput(ErrorsOutput const&) = delete; + ErrorsOutput& operator=(ErrorsOutput const&) = delete; +}; + +[[nodiscard]] +std::unique_ptr file_errors( + std::string filename, std::shared_ptr output = nullptr); + +[[nodiscard]] +std::unique_ptr ignore_errors(); + +[[nodiscard]] +std::unique_ptr errors_output_ios(std::ostream& out); + +} // namespace src + +#endif // ERRORS_HH -- cgit v1.3