summaryrefslogtreecommitdiff
path: root/src/error-handler.h
diff options
context:
space:
mode:
authorBen Smith <binji@chromium.org>2018-09-02 18:22:35 -0700
committerBen Smith <binjimin@gmail.com>2018-09-04 15:13:23 -0700
commitb4125e90c70a6b1bef4480e33f3c838ab4c7cfcb (patch)
tree20c6e46776e5038ac3c97365a9a0435cb81ad340 /src/error-handler.h
parent4a54eb34d3e362c8a49316aff6e989f7c9743ed9 (diff)
downloadwabt-b4125e90c70a6b1bef4480e33f3c838ab4c7cfcb.tar.gz
wabt-b4125e90c70a6b1bef4480e33f3c838ab4c7cfcb.tar.bz2
wabt-b4125e90c70a6b1bef4480e33f3c838ab4c7cfcb.zip
Move WastLexer out of NameResolver, Validator, etc.
Also remove wast-parser-lexer-shared.{cc,h}.
Diffstat (limited to 'src/error-handler.h')
-rw-r--r--src/error-handler.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/error-handler.h b/src/error-handler.h
index cc407993..45e212fd 100644
--- a/src/error-handler.h
+++ b/src/error-handler.h
@@ -17,16 +17,22 @@
#ifndef WABT_ERROR_HANDLER_H_
#define WABT_ERROR_HANDLER_H_
+#include <cstdarg>
#include <string>
#include "src/color.h"
#include "src/common.h"
+#include "src/lexer-source-line-finder.h"
namespace wabt {
+class WastLexer;
+
class ErrorHandler {
public:
explicit ErrorHandler(Location::Type);
+ ErrorHandler(Location::Type,
+ std::unique_ptr<LexerSourceLineFinder> line_finder);
virtual ~ErrorHandler() {}
@@ -44,6 +50,9 @@ class ErrorHandler {
return OnError(error_level, Location(offset), error, std::string(), 0);
}
+ // Helper function for va_lists.
+ bool OnError(ErrorLevel, const Location&, const char* format, va_list args);
+
// OnError will be called with with source_line trimmed to this length.
virtual size_t source_line_max_length() const = 0;
@@ -57,6 +66,8 @@ class ErrorHandler {
protected:
Location::Type location_type_;
+ // TODO(binji): remove unique_ptr
+ std::unique_ptr<LexerSourceLineFinder> line_finder_;
};
class ErrorHandlerNop : public ErrorHandler {
@@ -83,6 +94,7 @@ class ErrorHandlerFile : public ErrorHandler {
};
explicit ErrorHandlerFile(Location::Type,
+ std::unique_ptr<LexerSourceLineFinder> = {},
FILE* file = stderr,
const std::string& header = std::string(),
PrintHeader print_header = PrintHeader::Never,
@@ -111,6 +123,7 @@ class ErrorHandlerFile : public ErrorHandler {
class ErrorHandlerBuffer : public ErrorHandler {
public:
explicit ErrorHandlerBuffer(Location::Type,
+ std::unique_ptr<LexerSourceLineFinder> = {},
size_t source_line_max_length = 80);
bool OnError(ErrorLevel,