diff options
| author | Joel Klinghed <the_jk@spawned.biz> | 2025-09-28 22:53:30 +0200 |
|---|---|---|
| committer | Joel Klinghed <the_jk@spawned.biz> | 2025-09-29 09:39:17 +0200 |
| commit | 1e9e51dae1c01bab7562911b958c47528b8011c8 (patch) | |
| tree | 73e0c97545d1cf833a4205c8ced41c822b4bb348 /src/errors.hh | |
| parent | 0ca22c7d6d650c80906bd1217fccf32066cc2502 (diff) | |
java: Add tokens
Only parses Java 8 tokens for now.
Diffstat (limited to 'src/errors.hh')
| -rw-r--r-- | src/errors.hh | 64 |
1 files changed, 64 insertions, 0 deletions
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 <iosfwd> +#include <memory> +#include <string> +#include <string_view> + +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<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 |
