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

Unified Diff: src/lexer/experimental-scanner.h

Issue 91843004: Fix scanning of regexp flags. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Fix regex positions Created 7 years, 1 month 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/lexer/experimental-scanner.h
diff --git a/src/lexer/experimental-scanner.h b/src/lexer/experimental-scanner.h
index e0a0f4c6461323ed7583fc1ff7a29fb2020a5542..fea691a2246be1f6ac6ca5c9f8cd065c12da41eb 100644
--- a/src/lexer/experimental-scanner.h
+++ b/src/lexer/experimental-scanner.h
@@ -396,8 +396,7 @@ bool ExperimentalScanner<Char>::ScanRegExpPattern(bool seen_equal) {
// Previous token is either '/' or '/=', in the second case, the
// pattern starts at =.
- next_.beg_pos = (cursor_ - buffer_) - (seen_equal ? 2 : 1);
- next_.end_pos = (cursor_ - buffer_) - (seen_equal ? 1 : 0);
+ next_.beg_pos = next_.end_pos = (cursor_ - buffer_) - (seen_equal ? 1 : 0);
// Scan regular expression body: According to ECMA-262, 3rd, 7.8.5,
// the scanner should pass uninterpreted bodies to the RegExp
@@ -428,6 +427,7 @@ bool ExperimentalScanner<Char>::ScanRegExpPattern(bool seen_equal) {
if (++cursor_ >= buffer_end_) return false;
}
}
+ next_.end_pos = (cursor_ - buffer_);
++cursor_; // consume '/'
return true;
}
@@ -435,6 +435,7 @@ bool ExperimentalScanner<Char>::ScanRegExpPattern(bool seen_equal) {
template<typename Char>
bool ExperimentalScanner<Char>::ScanRegExpFlags() {
+ next_.beg_pos = cursor_ - buffer_;
// Scan regular expression flags.
while (cursor_ < buffer_end_ && unicode_cache_->IsIdentifierPart(*cursor_)) {
if (*cursor_ != '\\') {
@@ -444,7 +445,7 @@ bool ExperimentalScanner<Char>::ScanRegExpFlags() {
if (++cursor_ >= buffer_end_) break;
}
}
- next_.end_pos = cursor_ - buffer_ - 1;
+ next_.end_pos = cursor_ - buffer_;
return true;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698