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

Unified Diff: src/preparser.h

Issue 857433004: Report SyntaxError on Token::ILLEGAL in ParseTemplateLiteral (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 11 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 | « no previous file | test/cctest/test-parsing.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/preparser.h
diff --git a/src/preparser.h b/src/preparser.h
index f67c7563d04099b0f080e9b1995abb4c07631074..09f6b1dc3d51c26b9cc1b7badc3b11a9139bf78a 100644
--- a/src/preparser.h
+++ b/src/preparser.h
@@ -2942,11 +2942,17 @@ ParserBase<Traits>::ParseTemplateLiteral(ExpressionT tag, int start, bool* ok) {
do {
CheckTemplateOctalLiteral(pos, peek_position(), CHECK_OK);
next = peek();
- if (!next) {
+ if (next == Token::EOS) {
ReportMessageAt(Scanner::Location(start, peek_position()),
"unterminated_template");
*ok = false;
return Traits::EmptyExpression();
+ } else if (next == Token::ILLEGAL) {
+ Traits::ReportMessageAt(
+ Scanner::Location(position() + 1, peek_position()),
+ "unexpected_token", "ILLEGAL", false);
+ *ok = false;
+ return Traits::EmptyExpression();
}
int expr_pos = peek_position();
@@ -2966,10 +2972,16 @@ ParserBase<Traits>::ParseTemplateLiteral(ExpressionT tag, int start, bool* ok) {
Next();
pos = position();
- if (!next) {
+ if (next == Token::EOS) {
ReportMessageAt(Scanner::Location(start, pos), "unterminated_template");
*ok = false;
return Traits::EmptyExpression();
+ } else if (next == Token::ILLEGAL) {
arv (Not doing code reviews) 2015/01/19 17:24:32 Can this code duplication be prevented?
caitp (gmail) 2015/01/19 17:27:04 The first `else if (next == Token::ILLEGAL)` block
+ Traits::ReportMessageAt(
+ Scanner::Location(position() + 1, peek_position()),
+ "unexpected_token", "ILLEGAL", false);
+ *ok = false;
+ return Traits::EmptyExpression();
}
Traits::AddTemplateSpan(&ts, next == Token::TEMPLATE_TAIL);
« no previous file with comments | « no previous file | test/cctest/test-parsing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698