aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/parse/rust-parse.h
diff options
context:
space:
mode:
authorThe Other <simplytheother@gmail.com>2021-03-18 17:27:01 +0800
committerGitHub <noreply@github.com>2021-03-18 09:27:01 +0000
commit3f361bd362bc57cd6a1c12fb8fc259ec22c9d945 (patch)
treeb3a17470590047029ec5a09eba64dacb36409bf9 /gcc/rust/parse/rust-parse.h
parent0581e64df94130ed08c26240478cf5ea43912311 (diff)
downloadgcc-3f361bd362bc57cd6a1c12fb8fc259ec22c9d945.zip
gcc-3f361bd362bc57cd6a1c12fb8fc259ec22c9d945.tar.gz
gcc-3f361bd362bc57cd6a1c12fb8fc259ec22c9d945.tar.bz2
Modify parser error message reporting system to allow recovery (#290)
Added new parser Error struct This is to make the parser reusable for macro expansion.
Diffstat (limited to 'gcc/rust/parse/rust-parse.h')
-rw-r--r--gcc/rust/parse/rust-parse.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/gcc/rust/parse/rust-parse.h b/gcc/rust/parse/rust-parse.h
index 0708068..f6faa96 100644
--- a/gcc/rust/parse/rust-parse.h
+++ b/gcc/rust/parse/rust-parse.h
@@ -19,6 +19,7 @@ along with GCC; see the file COPYING3. If not see
#include "rust-lex.h"
#include "rust-ast-full.h"
+#include "rust-diagnostics.h"
namespace Rust {
/* HACK: used to resolve the expression-or-statement problem at the end of a
@@ -616,6 +617,8 @@ private:
bool done_end_or_else ();
bool done_end_of_file ();
+ void add_error (Error error) { error_table.push_back (std::move (error)); }
+
public:
// Construct parser with specified "managed" token source.
Parser (ManagedTokenSource tokenSource) : lexer (std::move (tokenSource)) {}
@@ -627,9 +630,14 @@ public:
void debug_dump_lex_output (std::ostream &out);
void debug_dump_ast_output (AST::Crate &crate, std::ostream &out);
+ // Returns whether any parsing errors have occurred.
+ bool has_errors () const { return !error_table.empty (); }
+
private:
// The token source (usually lexer) associated with the parser.
ManagedTokenSource lexer;
+ // The error list.
+ std::vector<Error> error_table;
};
} // namespace Rust