Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(691)

Unified Diff: src/parsing/scanner.h

Issue 1793913002: [parser] implement error reporting for Scanner errors (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebased Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/parsing/scanner.h
diff --git a/src/parsing/scanner.h b/src/parsing/scanner.h
index 9f195e3657fae6e90a2417f52ba6e0497c80a504..bad7429c50419ac902000af323edb8e45eeb951f 100644
--- a/src/parsing/scanner.h
+++ b/src/parsing/scanner.h
@@ -14,6 +14,7 @@
#include "src/globals.h"
#include "src/hashmap.h"
#include "src/list.h"
+#include "src/messages.h"
#include "src/parsing/token.h"
#include "src/unicode.h"
#include "src/unicode-decoder.h"
@@ -354,6 +355,10 @@ class Scanner {
// (the token last returned by Next()).
Location location() const { return current_.location; }
+ bool has_error() const { return scanner_error_ != MessageTemplate::kNone; }
+ MessageTemplate::Template error() const { return scanner_error_; }
+ Location error_location() const { return scanner_error_location_; }
+
// Similar functions for the upcoming token.
// One token look-ahead (past the token returned by Next()).
@@ -476,6 +481,7 @@ class Scanner {
current_.raw_literal_chars = NULL;
next_next_.token = Token::UNINITIALIZED;
found_html_comment_ = false;
+ scanner_error_ = MessageTemplate::kNone;
}
// Support BookmarkScope functionality.
@@ -486,6 +492,18 @@ class Scanner {
void DropBookmark();
static void CopyTokenDesc(TokenDesc* to, TokenDesc* from);
+ void ReportScannerError(MessageTemplate::Template error, int begin, int end) {
adamk 2016/03/18 18:21:55 Please put the location before |error| (same below
caitp (gmail) 2016/03/21 16:15:03 Done.
+ if (has_error()) return;
+ scanner_error_ = error;
+ scanner_error_location_ = Location(begin, end);
+ }
+
+ void ReportScannerError(MessageTemplate::Template error, int begin) {
+ if (has_error()) return;
+ scanner_error_ = error;
+ scanner_error_location_ = Location(begin, begin + 1);
+ }
+
// Literal buffer support
inline void StartLiteral() {
LiteralBuffer* free_buffer =
@@ -631,13 +649,13 @@ class Scanner {
return current_.raw_literal_chars->is_one_byte();
}
- template <bool capture_raw>
+ template <bool capture_raw, bool unicode = false>
uc32 ScanHexNumber(int expected_length);
// Scan a number of any length but not bigger than max_value. For example, the
// number can be 000000001, so it's very long in characters but its value is
// small.
template <bool capture_raw>
- uc32 ScanUnlimitedLengthHexNumber(int max_value);
+ uc32 ScanUnlimitedLengthHexNumber(int max_value, bool& bad_codepoint);
// Scans a single JavaScript token.
void Scan();
@@ -758,6 +776,9 @@ class Scanner {
// Whether this scanner encountered an HTML comment.
bool found_html_comment_;
+
+ MessageTemplate::Template scanner_error_;
+ Location scanner_error_location_;
};
} // namespace internal

Powered by Google App Engine
This is Rietveld 408576698