diff options
author | The Other <simplytheother@gmail.com> | 2021-03-18 17:27:01 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-18 09:27:01 +0000 |
commit | 3f361bd362bc57cd6a1c12fb8fc259ec22c9d945 (patch) | |
tree | b3a17470590047029ec5a09eba64dacb36409bf9 /gcc/rust/parse/rust-parse.h | |
parent | 0581e64df94130ed08c26240478cf5ea43912311 (diff) | |
download | gcc-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.h | 8 |
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 |