OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_PARSING_EXPRESSION_CLASSIFIER_H | 5 #ifndef V8_PARSING_EXPRESSION_CLASSIFIER_H |
6 #define V8_PARSING_EXPRESSION_CLASSIFIER_H | 6 #define V8_PARSING_EXPRESSION_CLASSIFIER_H |
7 | 7 |
8 #include "src/messages.h" | 8 #include "src/messages.h" |
9 #include "src/parsing/scanner.h" | 9 #include "src/parsing/scanner.h" |
10 #include "src/parsing/token.h" | 10 #include "src/parsing/token.h" |
(...skipping 232 matching lines...) Loading... |
243 } | 243 } |
244 | 244 |
245 void RecordBindingPatternError(const Scanner::Location& loc, | 245 void RecordBindingPatternError(const Scanner::Location& loc, |
246 MessageTemplate::Template message, | 246 MessageTemplate::Template message, |
247 const char* arg = nullptr) { | 247 const char* arg = nullptr) { |
248 if (!is_valid_binding_pattern()) return; | 248 if (!is_valid_binding_pattern()) return; |
249 invalid_productions_ |= BindingPatternProduction; | 249 invalid_productions_ |= BindingPatternProduction; |
250 Add(Error(loc, message, kBindingPatternProduction, arg)); | 250 Add(Error(loc, message, kBindingPatternProduction, arg)); |
251 } | 251 } |
252 | 252 |
| 253 void ReplaceBindingPatternError(const Scanner::Location& loc, |
| 254 MessageTemplate::Template message, |
| 255 const char* arg = nullptr) { |
| 256 if (!is_valid_binding_pattern()) { |
| 257 Error& e = reported_error(kBindingPatternProduction); |
| 258 e.location = loc; |
| 259 e.message = message; |
| 260 e.arg = arg; |
| 261 } else { |
| 262 RecordBindingPatternError(loc, message, arg); |
| 263 } |
| 264 } |
| 265 |
253 void RecordAssignmentPatternError(const Scanner::Location& loc, | 266 void RecordAssignmentPatternError(const Scanner::Location& loc, |
254 MessageTemplate::Template message, | 267 MessageTemplate::Template message, |
255 const char* arg = nullptr) { | 268 const char* arg = nullptr) { |
256 if (!is_valid_assignment_pattern()) return; | 269 if (!is_valid_assignment_pattern()) return; |
257 invalid_productions_ |= AssignmentPatternProduction; | 270 invalid_productions_ |= AssignmentPatternProduction; |
258 Add(Error(loc, message, kAssignmentPatternProduction, arg)); | 271 Add(Error(loc, message, kAssignmentPatternProduction, arg)); |
259 } | 272 } |
260 | 273 |
261 void RecordPatternError(const Scanner::Location& loc, | 274 void RecordPatternError(const Scanner::Location& loc, |
262 MessageTemplate::Template message, | 275 MessageTemplate::Template message, |
(...skipping 231 matching lines...) Loading... |
494 }; | 507 }; |
495 | 508 |
496 | 509 |
497 #undef ERROR_CODES | 510 #undef ERROR_CODES |
498 | 511 |
499 | 512 |
500 } // namespace internal | 513 } // namespace internal |
501 } // namespace v8 | 514 } // namespace v8 |
502 | 515 |
503 #endif // V8_PARSING_EXPRESSION_CLASSIFIER_H | 516 #endif // V8_PARSING_EXPRESSION_CLASSIFIER_H |
OLD | NEW |