reader/wgsl: Abort after raising too many errors

Change-Id: I641ee8c2e34e059a02742d06c24f96acecb39cd3
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33720
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: David Neto <dneto@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
diff --git a/src/reader/wgsl/parser_impl.h b/src/reader/wgsl/parser_impl.h
index 9b6a841..e533847 100644
--- a/src/reader/wgsl/parser_impl.h
+++ b/src/reader/wgsl/parser_impl.h
@@ -233,6 +233,15 @@
   /// @returns true if the parse was successful, false otherwise.
   bool Parse();
 
+  /// set_max_diagnostics sets the maximum number of reported errors before
+  /// aborting parsing.
+  /// @param limit the new maximum number of errors
+  void set_max_errors(size_t limit) { max_errors_ = limit; }
+
+  /// @return the number of maximum number of reported errors before aborting
+  /// parsing.
+  size_t get_max_errors() const { return max_errors_; }
+
   /// @returns true if an error was encountered.
   bool has_error() const { return diags_.contains_errors(); }
 
@@ -779,6 +788,7 @@
   int silence_errors_ = 0;
   std::unordered_map<std::string, ast::type::Type*> registered_constructs_;
   ast::Module module_;
+  size_t max_errors_ = 25;
 };
 
 }  // namespace wgsl