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

Unified Diff: src/scanner.cc

Issue 1295883002: Sloppy-mode let parsing (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Replace array with direct ivars Created 5 years, 4 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
« no previous file with comments | « src/scanner.h ('k') | src/token.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/scanner.cc
diff --git a/src/scanner.cc b/src/scanner.cc
index c6c0a8d6a23448b7be244224ec48bc5b37b16cee..f6c10b44034e02c5ee3a801fa3f9264ea7049937 100644
--- a/src/scanner.cc
+++ b/src/scanner.cc
@@ -238,6 +238,11 @@ Token::Value Scanner::Next() {
next_.location.end_pos = current_.location.end_pos;
}
current_ = next_;
+ if (next_next_.token != Token::UNINITIALIZED) {
+ next_ = next_next_;
+ next_next_.token = Token::UNINITIALIZED;
+ return current_.token;
+ }
has_line_terminator_before_next_ = false;
has_multiline_comment_before_next_ = false;
if (static_cast<unsigned>(c0_) <= 0x7f) {
@@ -256,6 +261,20 @@ Token::Value Scanner::Next() {
}
+Token::Value Scanner::PeekAhead() {
+ if (next_next_.token != Token::UNINITIALIZED) {
+ return next_next_.token;
+ }
+ TokenDesc prev = current_;
+ Next();
+ Token::Value ret = next_.token;
+ next_next_ = next_;
+ next_ = current_;
+ current_ = prev;
+ return ret;
+}
+
+
// TODO(yangguo): check whether this is actually necessary.
static inline bool IsLittleEndianByteOrderMark(uc32 c) {
// The Unicode value U+FFFE is guaranteed never to be assigned as a
« no previous file with comments | « src/scanner.h ('k') | src/token.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698