aboutsummaryrefslogtreecommitdiff
path: root/build/parser
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-01-20 17:18:09 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-01-20 17:18:09 +0200
commitb0524a0b18eec9d5e5c3f6ce30b6cecdd02a6306 (patch)
tree4b1efc586782507e0647e884d6a13c6605298508 /build/parser
parent47751abc43dab40e0ac4a1523994fd533e6a3b22 (diff)
Diagnostic infrastructure revamp
Diffstat (limited to 'build/parser')
-rw-r--r--build/parser27
1 files changed, 15 insertions, 12 deletions
diff --git a/build/parser b/build/parser
index 66c0357..7515908 100644
--- a/build/parser
+++ b/build/parser
@@ -9,10 +9,9 @@
#include <vector>
#include <iosfwd>
#include <utility> // std::move
-#include <exception>
-
#include <build/path>
+#include <build/diagnostics>
namespace build
{
@@ -22,15 +21,11 @@ namespace build
enum class token_type;
class lexer;
- // The handler must assume the diagnostics has already been issued.
- //
- struct parser_error: std::exception {};
-
class parser
{
public:
- parser (std::ostream& diag): diag_ (diag) {}
-
+ // Issues diagnostics and throws failed in case of an error.
+ //
void
parse (std::istream&, const path&, scope&);
@@ -70,14 +65,22 @@ namespace build
token_type
next (token&, token_type&);
- std::ostream&
- error (const token&);
+ // Diagnostics.
+ //
+ private:
+ struct fail_mark_base: build::fail_mark_base<failed>
+ {
+ location_prologue
+ operator() (const token&) const;
+
+ const path* path_;
+ };
+ typedef diag_mark<fail_mark_base> fail_mark;
private:
- std::ostream& diag_;
+ fail_mark fail;
lexer* lexer_;
- const path* path_;
scope* scope_;
};
}