Revision: 18134
Author:   [email protected]
Date:     Thu Nov 28 15:29:06 2013 UTC
Log:      Fix scanning of regexp flags.

Set start and end positions of regex body and regex flags so that later literal construction produces correct result.

BUG=
[email protected]

Review URL: https://codereview.chromium.org/91843004
http://code.google.com/p/v8/source/detail?r=18134

Modified:
 /branches/experimental/parser/src/lexer/experimental-scanner.h

=======================================
--- /branches/experimental/parser/src/lexer/experimental-scanner.h Wed Nov 27 15:28:46 2013 UTC +++ /branches/experimental/parser/src/lexer/experimental-scanner.h Thu Nov 28 15:29:06 2013 UTC
@@ -396,8 +396,7 @@

   // 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 @@
       if (++cursor_ >= buffer_end_) return false;
     }
   }
+  next_.end_pos = (cursor_ - buffer_);
   ++cursor_;  // consume '/'
   return true;
 }
@@ -435,6 +435,7 @@

 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 @@
       if (++cursor_ >= buffer_end_) break;
     }
   }
-  next_.end_pos = cursor_ - buffer_ - 1;
+  next_.end_pos = cursor_ - buffer_;
   return true;
 }

--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to