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

Unified Diff: src/scanner.cc

Issue 778813003: ES6 template literals: Fix issue with template after rbrace (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add tests without newlines Created 6 years 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') | test/mjsunit/harmony/templates.js » ('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 c533e5754cbc784e8994c338c6e8ef833f52e88d..561c30b58a12e0cb2c5e54d16bfc2e1572c9cd3e 100644
--- a/src/scanner.cc
+++ b/src/scanner.cc
@@ -647,7 +647,7 @@ void Scanner::Scan() {
case '`':
if (HarmonyTemplates()) {
- token = ScanTemplateSpan();
+ token = ScanTemplateStart();
break;
}
@@ -808,19 +808,8 @@ Token::Value Scanner::ScanTemplateSpan() {
// A TEMPLATE_SPAN should always be followed by an Expression, while a
// TEMPLATE_TAIL terminates a TemplateLiteral and does not need to be
// followed by an Expression.
- //
-
- if (next_.token == Token::RBRACE) {
- // After parsing an Expression, the source position is incorrect due to
- // having scanned the brace. Push the RBRACE back into the stream.
- PushBack('}');
- }
- next_.location.beg_pos = source_pos();
Token::Value result = Token::TEMPLATE_SPAN;
- DCHECK(c0_ == '`' || c0_ == '}');
- Advance(); // Consume ` or }
-
LiteralScope literal(this, true);
while (true) {
@@ -881,6 +870,21 @@ Token::Value Scanner::ScanTemplateSpan() {
}
+Token::Value Scanner::ScanTemplateStart() {
+ DCHECK(c0_ == '`');
+ next_.location.beg_pos = source_pos();
+ Advance(); // Consume `
+ return ScanTemplateSpan();
+}
+
+
+Token::Value Scanner::ScanTemplateContinuation() {
+ DCHECK_EQ(next_.token, Token::RBRACE);
+ next_.location.beg_pos = source_pos() - 1; // We already consumed }
+ return ScanTemplateSpan();
+}
+
+
void Scanner::ScanDecimalDigits() {
while (IsDecimalDigit(c0_))
AddLiteralCharAdvance();
« no previous file with comments | « src/scanner.h ('k') | test/mjsunit/harmony/templates.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698