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

Side by Side Diff: src/parsing/parser-base.h

Issue 2665513002: [parser] Lift template literal invalid escape restriction (Closed)
Patch Set: address comments Created 3 years, 10 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 unified diff | Download patch
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_PARSING_PARSER_BASE_H 5 #ifndef V8_PARSING_PARSER_BASE_H
6 #define V8_PARSING_PARSER_BASE_H 6 #define V8_PARSING_PARSER_BASE_H
7 7
8 #include "src/ast/ast.h" 8 #include "src/ast/ast.h"
9 #include "src/ast/scopes.h" 9 #include "src/ast/scopes.h"
10 #include "src/bailout-reason.h" 10 #include "src/bailout-reason.h"
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 default_eager_compile_hint_(FunctionLiteral::kShouldLazyCompile), 218 default_eager_compile_hint_(FunctionLiteral::kShouldLazyCompile),
219 function_literal_id_(0), 219 function_literal_id_(0),
220 allow_natives_(false), 220 allow_natives_(false),
221 allow_tailcalls_(false), 221 allow_tailcalls_(false),
222 allow_harmony_do_expressions_(false), 222 allow_harmony_do_expressions_(false),
223 allow_harmony_function_sent_(false), 223 allow_harmony_function_sent_(false),
224 allow_harmony_restrictive_generators_(false), 224 allow_harmony_restrictive_generators_(false),
225 allow_harmony_trailing_commas_(false), 225 allow_harmony_trailing_commas_(false),
226 allow_harmony_class_fields_(false), 226 allow_harmony_class_fields_(false),
227 allow_harmony_object_rest_spread_(false), 227 allow_harmony_object_rest_spread_(false),
228 allow_harmony_dynamic_import_(false) {} 228 allow_harmony_dynamic_import_(false),
229 allow_harmony_template_escapes_(false) {}
229 230
230 #define ALLOW_ACCESSORS(name) \ 231 #define ALLOW_ACCESSORS(name) \
231 bool allow_##name() const { return allow_##name##_; } \ 232 bool allow_##name() const { return allow_##name##_; } \
232 void set_allow_##name(bool allow) { allow_##name##_ = allow; } 233 void set_allow_##name(bool allow) { allow_##name##_ = allow; }
233 234
234 ALLOW_ACCESSORS(natives); 235 ALLOW_ACCESSORS(natives);
235 ALLOW_ACCESSORS(tailcalls); 236 ALLOW_ACCESSORS(tailcalls);
236 ALLOW_ACCESSORS(harmony_do_expressions); 237 ALLOW_ACCESSORS(harmony_do_expressions);
237 ALLOW_ACCESSORS(harmony_function_sent); 238 ALLOW_ACCESSORS(harmony_function_sent);
238 ALLOW_ACCESSORS(harmony_restrictive_generators); 239 ALLOW_ACCESSORS(harmony_restrictive_generators);
239 ALLOW_ACCESSORS(harmony_trailing_commas); 240 ALLOW_ACCESSORS(harmony_trailing_commas);
240 ALLOW_ACCESSORS(harmony_class_fields); 241 ALLOW_ACCESSORS(harmony_class_fields);
241 ALLOW_ACCESSORS(harmony_object_rest_spread); 242 ALLOW_ACCESSORS(harmony_object_rest_spread);
242 ALLOW_ACCESSORS(harmony_dynamic_import); 243 ALLOW_ACCESSORS(harmony_dynamic_import);
244 ALLOW_ACCESSORS(harmony_template_escapes);
243 245
244 #undef ALLOW_ACCESSORS 246 #undef ALLOW_ACCESSORS
245 247
246 uintptr_t stack_limit() const { return stack_limit_; } 248 uintptr_t stack_limit() const { return stack_limit_; }
247 249
248 void set_stack_limit(uintptr_t stack_limit) { stack_limit_ = stack_limit; } 250 void set_stack_limit(uintptr_t stack_limit) { stack_limit_ = stack_limit; }
249 251
250 void set_default_eager_compile_hint( 252 void set_default_eager_compile_hint(
251 FunctionLiteral::EagerCompileHint eager_compile_hint) { 253 FunctionLiteral::EagerCompileHint eager_compile_hint) {
252 default_eager_compile_hint_ = eager_compile_hint; 254 default_eager_compile_hint_ = eager_compile_hint;
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 return true; 859 return true;
858 } 860 }
859 return false; 861 return false;
860 } 862 }
861 863
862 bool PeekInOrOf() { 864 bool PeekInOrOf() {
863 return peek() == Token::IN || PeekContextualKeyword(CStrVector("of")); 865 return peek() == Token::IN || PeekContextualKeyword(CStrVector("of"));
864 } 866 }
865 867
866 // Checks whether an octal literal was last seen between beg_pos and end_pos. 868 // Checks whether an octal literal was last seen between beg_pos and end_pos.
867 // If so, reports an error. Only called for strict mode and template strings. 869 // Only called for strict mode strings.
868 void CheckOctalLiteral(int beg_pos, int end_pos, bool is_template, bool* ok) { 870 void CheckStrictOctalLiteral(int beg_pos, int end_pos, bool* ok) {
869 Scanner::Location octal = scanner()->octal_position(); 871 Scanner::Location octal = scanner()->octal_position();
870 if (octal.IsValid() && beg_pos <= octal.beg_pos && 872 if (octal.IsValid() && beg_pos <= octal.beg_pos &&
871 octal.end_pos <= end_pos) { 873 octal.end_pos <= end_pos) {
872 MessageTemplate::Template message = 874 MessageTemplate::Template message = scanner()->octal_message();
873 is_template ? MessageTemplate::kTemplateOctalLiteral
874 : scanner()->octal_message();
875 DCHECK_NE(message, MessageTemplate::kNone); 875 DCHECK_NE(message, MessageTemplate::kNone);
876 impl()->ReportMessageAt(octal, message); 876 impl()->ReportMessageAt(octal, message);
877 scanner()->clear_octal_position(); 877 scanner()->clear_octal_position();
878 if (message == MessageTemplate::kStrictDecimalWithLeadingZero) { 878 if (message == MessageTemplate::kStrictDecimalWithLeadingZero) {
879 impl()->CountUsage(v8::Isolate::kDecimalWithLeadingZeroInStrictMode); 879 impl()->CountUsage(v8::Isolate::kDecimalWithLeadingZeroInStrictMode);
880 } 880 }
881 *ok = false; 881 *ok = false;
882 } 882 }
883 } 883 }
884 884
885 inline void CheckStrictOctalLiteral(int beg_pos, int end_pos, bool* ok) { 885 // Checks if an octal literal or an invalid hex or unicode escape sequence
886 CheckOctalLiteral(beg_pos, end_pos, false, ok); 886 // appears between beg_pos and end_pos. In the presence of such, either
887 } 887 // returns false or reports an error, depending on dont_throw. Otherwise
888 888 // returns true.
889 inline void CheckTemplateOctalLiteral(int beg_pos, int end_pos, bool* ok) { 889 inline bool CheckTemplateEscapes(int beg_pos, int end_pos, bool dont_throw,
890 CheckOctalLiteral(beg_pos, end_pos, true, ok); 890 bool* ok) {
891 Scanner::Location octal = scanner()->octal_position();
892 if (octal.IsValid() && beg_pos <= octal.beg_pos &&
893 octal.end_pos <= end_pos) {
894 if (dont_throw) {
895 scanner()->clear_octal_position();
896 return false;
897 }
898 MessageTemplate::Template message =
899 MessageTemplate::kTemplateOctalLiteral;
900 impl()->ReportMessageAt(octal, message);
901 scanner()->clear_octal_position();
902 *ok = false;
903 } else if (scanner()->has_invalid_template_escape()) {
904 if (dont_throw) {
905 scanner()->clear_invalid_template_escape();
906 return false;
907 }
908 impl()->ReportMessageAt(scanner()->invalid_template_escape_location(),
909 scanner()->invalid_template_escape_message());
910 scanner()->clear_invalid_template_escape();
911 *ok = false;
912 }
913 return true;
891 } 914 }
892 915
893 void CheckDestructuringElement(ExpressionT element, int beg_pos, int end_pos); 916 void CheckDestructuringElement(ExpressionT element, int beg_pos, int end_pos);
894 917
895 // Checking the name of a function literal. This has to be done after parsing 918 // Checking the name of a function literal. This has to be done after parsing
896 // the function, since the function can declare itself strict. 919 // the function, since the function can declare itself strict.
897 void CheckFunctionName(LanguageMode language_mode, IdentifierT function_name, 920 void CheckFunctionName(LanguageMode language_mode, IdentifierT function_name,
898 FunctionNameValidity function_name_validity, 921 FunctionNameValidity function_name_validity,
899 const Scanner::Location& function_name_loc, bool* ok) { 922 const Scanner::Location& function_name_loc, bool* ok) {
900 if (function_name_validity == kSkipFunctionNameCheck) return; 923 if (function_name_validity == kSkipFunctionNameCheck) return;
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
1187 const FormalParametersT& parameters, 1210 const FormalParametersT& parameters,
1188 bool* ok); 1211 bool* ok);
1189 void ParseAsyncFunctionBody(Scope* scope, StatementListT body, 1212 void ParseAsyncFunctionBody(Scope* scope, StatementListT body,
1190 FunctionKind kind, FunctionBodyType type, 1213 FunctionKind kind, FunctionBodyType type,
1191 bool accept_IN, int pos, bool* ok); 1214 bool accept_IN, int pos, bool* ok);
1192 ExpressionT ParseAsyncFunctionLiteral(bool* ok); 1215 ExpressionT ParseAsyncFunctionLiteral(bool* ok);
1193 ExpressionT ParseClassLiteral(IdentifierT name, 1216 ExpressionT ParseClassLiteral(IdentifierT name,
1194 Scanner::Location class_name_location, 1217 Scanner::Location class_name_location,
1195 bool name_is_strict_reserved, 1218 bool name_is_strict_reserved,
1196 int class_token_pos, bool* ok); 1219 int class_token_pos, bool* ok);
1197 ExpressionT ParseTemplateLiteral(ExpressionT tag, int start, bool* ok); 1220 ExpressionT ParseTemplateLiteral(ExpressionT tag, int start, bool tagged,
1221 bool* ok);
1198 ExpressionT ParseSuperExpression(bool is_new, bool* ok); 1222 ExpressionT ParseSuperExpression(bool is_new, bool* ok);
1199 ExpressionT ParseDynamicImportExpression(bool* ok); 1223 ExpressionT ParseDynamicImportExpression(bool* ok);
1200 ExpressionT ParseNewTargetExpression(bool* ok); 1224 ExpressionT ParseNewTargetExpression(bool* ok);
1201 1225
1202 void ParseFormalParameter(FormalParametersT* parameters, bool* ok); 1226 void ParseFormalParameter(FormalParametersT* parameters, bool* ok);
1203 void ParseFormalParameterList(FormalParametersT* parameters, bool* ok); 1227 void ParseFormalParameterList(FormalParametersT* parameters, bool* ok);
1204 void CheckArityRestrictions(int param_count, FunctionKind function_type, 1228 void CheckArityRestrictions(int param_count, FunctionKind function_type,
1205 bool has_rest, int formals_start_pos, 1229 bool has_rest, int formals_start_pos,
1206 int formals_end_pos, bool* ok); 1230 int formals_end_pos, bool* ok);
1207 1231
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
1496 1520
1497 bool allow_natives_; 1521 bool allow_natives_;
1498 bool allow_tailcalls_; 1522 bool allow_tailcalls_;
1499 bool allow_harmony_do_expressions_; 1523 bool allow_harmony_do_expressions_;
1500 bool allow_harmony_function_sent_; 1524 bool allow_harmony_function_sent_;
1501 bool allow_harmony_restrictive_generators_; 1525 bool allow_harmony_restrictive_generators_;
1502 bool allow_harmony_trailing_commas_; 1526 bool allow_harmony_trailing_commas_;
1503 bool allow_harmony_class_fields_; 1527 bool allow_harmony_class_fields_;
1504 bool allow_harmony_object_rest_spread_; 1528 bool allow_harmony_object_rest_spread_;
1505 bool allow_harmony_dynamic_import_; 1529 bool allow_harmony_dynamic_import_;
1530 bool allow_harmony_template_escapes_;
1506 1531
1507 friend class DiscardableZoneScope; 1532 friend class DiscardableZoneScope;
1508 }; 1533 };
1509 1534
1510 template <typename Impl> 1535 template <typename Impl>
1511 ParserBase<Impl>::FunctionState::FunctionState( 1536 ParserBase<Impl>::FunctionState::FunctionState(
1512 FunctionState** function_state_stack, ScopeState** scope_stack, 1537 FunctionState** function_state_stack, ScopeState** scope_stack,
1513 DeclarationScope* scope) 1538 DeclarationScope* scope)
1514 : ScopeState(scope_stack, scope), 1539 : ScopeState(scope_stack, scope),
1515 next_materialized_literal_index_(0), 1540 next_materialized_literal_index_(0),
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
1866 CHECK_OK); 1891 CHECK_OK);
1867 class_name_location = scanner()->location(); 1892 class_name_location = scanner()->location();
1868 } 1893 }
1869 return ParseClassLiteral(name, class_name_location, 1894 return ParseClassLiteral(name, class_name_location,
1870 is_strict_reserved_name, class_token_pos, ok); 1895 is_strict_reserved_name, class_token_pos, ok);
1871 } 1896 }
1872 1897
1873 case Token::TEMPLATE_SPAN: 1898 case Token::TEMPLATE_SPAN:
1874 case Token::TEMPLATE_TAIL: 1899 case Token::TEMPLATE_TAIL:
1875 BindingPatternUnexpectedToken(); 1900 BindingPatternUnexpectedToken();
1876 return ParseTemplateLiteral(impl()->NoTemplateTag(), beg_pos, ok); 1901 return ParseTemplateLiteral(impl()->NoTemplateTag(), beg_pos, false, ok);
1877 1902
1878 case Token::MOD: 1903 case Token::MOD:
1879 if (allow_natives() || extension_ != NULL) { 1904 if (allow_natives() || extension_ != NULL) {
1880 BindingPatternUnexpectedToken(); 1905 BindingPatternUnexpectedToken();
1881 return ParseV8Intrinsic(ok); 1906 return ParseV8Intrinsic(ok);
1882 } 1907 }
1883 break; 1908 break;
1884 1909
1885 case Token::DO: 1910 case Token::DO:
1886 if (allow_harmony_do_expressions()) { 1911 if (allow_harmony_do_expressions()) {
(...skipping 1400 matching lines...) Expand 10 before | Expand all | Expand 10 after
3287 result, factory()->NewStringLiteral(name, pos), pos); 3312 result, factory()->NewStringLiteral(name, pos), pos);
3288 impl()->PushLiteralName(name); 3313 impl()->PushLiteralName(name);
3289 break; 3314 break;
3290 } 3315 }
3291 3316
3292 case Token::TEMPLATE_SPAN: 3317 case Token::TEMPLATE_SPAN:
3293 case Token::TEMPLATE_TAIL: { 3318 case Token::TEMPLATE_TAIL: {
3294 impl()->RewriteNonPattern(CHECK_OK); 3319 impl()->RewriteNonPattern(CHECK_OK);
3295 BindingPatternUnexpectedToken(); 3320 BindingPatternUnexpectedToken();
3296 ArrowFormalParametersUnexpectedToken(); 3321 ArrowFormalParametersUnexpectedToken();
3297 result = ParseTemplateLiteral(result, position(), CHECK_OK); 3322 result = ParseTemplateLiteral(result, position(), true, CHECK_OK);
3298 break; 3323 break;
3299 } 3324 }
3300 3325
3301 default: 3326 default:
3302 return result; 3327 return result;
3303 } 3328 }
3304 } 3329 }
3305 } 3330 }
3306 3331
3307 template <typename Impl> 3332 template <typename Impl>
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
3562 if (scanner()->current_token() == Token::IDENTIFIER) { 3587 if (scanner()->current_token() == Token::IDENTIFIER) {
3563 pos = position(); 3588 pos = position();
3564 } else { 3589 } else {
3565 pos = peek_position(); 3590 pos = peek_position();
3566 if (expression->IsFunctionLiteral()) { 3591 if (expression->IsFunctionLiteral()) {
3567 // If the tag function looks like an IIFE, set_parenthesized() to 3592 // If the tag function looks like an IIFE, set_parenthesized() to
3568 // force eager compilation. 3593 // force eager compilation.
3569 expression->AsFunctionLiteral()->SetShouldEagerCompile(); 3594 expression->AsFunctionLiteral()->SetShouldEagerCompile();
3570 } 3595 }
3571 } 3596 }
3572 expression = ParseTemplateLiteral(expression, pos, CHECK_OK); 3597 expression = ParseTemplateLiteral(expression, pos, true, CHECK_OK);
3573 break; 3598 break;
3574 } 3599 }
3575 case Token::ILLEGAL: { 3600 case Token::ILLEGAL: {
3576 ReportUnexpectedTokenAt(scanner()->peek_location(), Token::ILLEGAL); 3601 ReportUnexpectedTokenAt(scanner()->peek_location(), Token::ILLEGAL);
3577 *ok = false; 3602 *ok = false;
3578 return impl()->EmptyExpression(); 3603 return impl()->EmptyExpression();
3579 } 3604 }
3580 default: 3605 default:
3581 return expression; 3606 return expression;
3582 } 3607 }
(...skipping 865 matching lines...) Expand 10 before | Expand all | Expand 10 after
4448 } 4473 }
4449 return impl()->ParseFunctionLiteral( 4474 return impl()->ParseFunctionLiteral(
4450 name, scanner()->location(), 4475 name, scanner()->location(),
4451 is_strict_reserved ? kFunctionNameIsStrictReserved 4476 is_strict_reserved ? kFunctionNameIsStrictReserved
4452 : kFunctionNameValidityUnknown, 4477 : kFunctionNameValidityUnknown,
4453 FunctionKind::kAsyncFunction, pos, type, language_mode(), CHECK_OK); 4478 FunctionKind::kAsyncFunction, pos, type, language_mode(), CHECK_OK);
4454 } 4479 }
4455 4480
4456 template <typename Impl> 4481 template <typename Impl>
4457 typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseTemplateLiteral( 4482 typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseTemplateLiteral(
4458 ExpressionT tag, int start, bool* ok) { 4483 ExpressionT tag, int start, bool tagged, bool* ok) {
4459 // A TemplateLiteral is made up of 0 or more TEMPLATE_SPAN tokens (literal 4484 // A TemplateLiteral is made up of 0 or more TEMPLATE_SPAN tokens (literal
4460 // text followed by a substitution expression), finalized by a single 4485 // text followed by a substitution expression), finalized by a single
4461 // TEMPLATE_TAIL. 4486 // TEMPLATE_TAIL.
4462 // 4487 //
4463 // In terms of draft language, TEMPLATE_SPAN may be either the TemplateHead or 4488 // In terms of draft language, TEMPLATE_SPAN may be either the TemplateHead or
4464 // TemplateMiddle productions, while TEMPLATE_TAIL is either TemplateTail, or 4489 // TemplateMiddle productions, while TEMPLATE_TAIL is either TemplateTail, or
4465 // NoSubstitutionTemplate. 4490 // NoSubstitutionTemplate.
4466 // 4491 //
4467 // When parsing a TemplateLiteral, we must have scanned either an initial 4492 // When parsing a TemplateLiteral, we must have scanned either an initial
4468 // TEMPLATE_SPAN, or a TEMPLATE_TAIL. 4493 // TEMPLATE_SPAN, or a TEMPLATE_TAIL.
4469 CHECK(peek() == Token::TEMPLATE_SPAN || peek() == Token::TEMPLATE_TAIL); 4494 CHECK(peek() == Token::TEMPLATE_SPAN || peek() == Token::TEMPLATE_TAIL);
4470 4495
4496 bool allow_illegal_escapes = tagged && allow_harmony_template_escapes();
4497 bool should_cook = true;
4498
4471 // If we reach a TEMPLATE_TAIL first, we are parsing a NoSubstitutionTemplate. 4499 // If we reach a TEMPLATE_TAIL first, we are parsing a NoSubstitutionTemplate.
4472 // In this case we may simply consume the token and build a template with a 4500 // In this case we may simply consume the token and build a template with a
4473 // single TEMPLATE_SPAN and no expressions. 4501 // single TEMPLATE_SPAN and no expressions.
4474 if (peek() == Token::TEMPLATE_TAIL) { 4502 if (peek() == Token::TEMPLATE_TAIL) {
4475 Consume(Token::TEMPLATE_TAIL); 4503 Consume(Token::TEMPLATE_TAIL);
4476 int pos = position(); 4504 int pos = position();
4477 CheckTemplateOctalLiteral(pos, peek_position(), CHECK_OK);
4478 typename Impl::TemplateLiteralState ts = impl()->OpenTemplateLiteral(pos); 4505 typename Impl::TemplateLiteralState ts = impl()->OpenTemplateLiteral(pos);
4479 impl()->AddTemplateSpan(&ts, true); 4506 should_cook = CheckTemplateEscapes(pos, peek_position(),
4507 allow_illegal_escapes, CHECK_OK);
4508 impl()->AddTemplateSpan(&ts, should_cook, true);
4480 return impl()->CloseTemplateLiteral(&ts, start, tag); 4509 return impl()->CloseTemplateLiteral(&ts, start, tag);
4481 } 4510 }
4482 4511
4483 Consume(Token::TEMPLATE_SPAN); 4512 Consume(Token::TEMPLATE_SPAN);
4484 int pos = position(); 4513 int pos = position();
4514 should_cook = CheckTemplateEscapes(pos, peek_position(),
4515 allow_illegal_escapes, CHECK_OK);
4485 typename Impl::TemplateLiteralState ts = impl()->OpenTemplateLiteral(pos); 4516 typename Impl::TemplateLiteralState ts = impl()->OpenTemplateLiteral(pos);
4486 impl()->AddTemplateSpan(&ts, false); 4517 impl()->AddTemplateSpan(&ts, should_cook, false);
4487 Token::Value next; 4518 Token::Value next;
4488 4519
4489 // If we open with a TEMPLATE_SPAN, we must scan the subsequent expression, 4520 // If we open with a TEMPLATE_SPAN, we must scan the subsequent expression,
4490 // and repeat if the following token is a TEMPLATE_SPAN as well (in this 4521 // and repeat if the following token is a TEMPLATE_SPAN as well (in this
4491 // case, representing a TemplateMiddle). 4522 // case, representing a TemplateMiddle).
4492 4523
4493 do { 4524 do {
4494 CheckTemplateOctalLiteral(pos, peek_position(), CHECK_OK);
4495 next = peek(); 4525 next = peek();
4496 if (next == Token::EOS) { 4526 if (next == Token::EOS) {
4497 impl()->ReportMessageAt(Scanner::Location(start, peek_position()), 4527 impl()->ReportMessageAt(Scanner::Location(start, peek_position()),
4498 MessageTemplate::kUnterminatedTemplate); 4528 MessageTemplate::kUnterminatedTemplate);
4499 *ok = false; 4529 *ok = false;
4500 return impl()->EmptyExpression(); 4530 return impl()->EmptyExpression();
4501 } else if (next == Token::ILLEGAL) { 4531 } else if (next == Token::ILLEGAL) {
4502 impl()->ReportMessageAt( 4532 impl()->ReportMessageAt(
4503 Scanner::Location(position() + 1, peek_position()), 4533 Scanner::Location(position() + 1, peek_position()),
4504 MessageTemplate::kUnexpectedToken, "ILLEGAL", kSyntaxError); 4534 MessageTemplate::kUnexpectedToken, "ILLEGAL", kSyntaxError);
(...skipping 25 matching lines...) Expand all
4530 *ok = false; 4560 *ok = false;
4531 return impl()->EmptyExpression(); 4561 return impl()->EmptyExpression();
4532 } else if (next == Token::ILLEGAL) { 4562 } else if (next == Token::ILLEGAL) {
4533 impl()->ReportMessageAt( 4563 impl()->ReportMessageAt(
4534 Scanner::Location(position() + 1, peek_position()), 4564 Scanner::Location(position() + 1, peek_position()),
4535 MessageTemplate::kUnexpectedToken, "ILLEGAL", kSyntaxError); 4565 MessageTemplate::kUnexpectedToken, "ILLEGAL", kSyntaxError);
4536 *ok = false; 4566 *ok = false;
4537 return impl()->EmptyExpression(); 4567 return impl()->EmptyExpression();
4538 } 4568 }
4539 4569
4540 impl()->AddTemplateSpan(&ts, next == Token::TEMPLATE_TAIL); 4570 should_cook = CheckTemplateEscapes(pos, peek_position(),
4571 allow_illegal_escapes, CHECK_OK);
4572 impl()->AddTemplateSpan(&ts, should_cook, next == Token::TEMPLATE_TAIL);
4541 } while (next == Token::TEMPLATE_SPAN); 4573 } while (next == Token::TEMPLATE_SPAN);
4542 4574
4543 DCHECK_EQ(next, Token::TEMPLATE_TAIL); 4575 DCHECK_EQ(next, Token::TEMPLATE_TAIL);
4544 CheckTemplateOctalLiteral(pos, peek_position(), CHECK_OK);
4545 // Once we've reached a TEMPLATE_TAIL, we can close the TemplateLiteral. 4576 // Once we've reached a TEMPLATE_TAIL, we can close the TemplateLiteral.
4546 return impl()->CloseTemplateLiteral(&ts, start, tag); 4577 return impl()->CloseTemplateLiteral(&ts, start, tag);
4547 } 4578 }
4548 4579
4549 template <typename Impl> 4580 template <typename Impl>
4550 typename ParserBase<Impl>::ExpressionT 4581 typename ParserBase<Impl>::ExpressionT
4551 ParserBase<Impl>::CheckAndRewriteReferenceExpression( 4582 ParserBase<Impl>::CheckAndRewriteReferenceExpression(
4552 ExpressionT expression, int beg_pos, int end_pos, 4583 ExpressionT expression, int beg_pos, int end_pos,
4553 MessageTemplate::Template message, bool* ok) { 4584 MessageTemplate::Template message, bool* ok) {
4554 return CheckAndRewriteReferenceExpression(expression, beg_pos, end_pos, 4585 return CheckAndRewriteReferenceExpression(expression, beg_pos, end_pos,
(...skipping 1212 matching lines...) Expand 10 before | Expand all | Expand 10 after
5767 } 5798 }
5768 5799
5769 #undef CHECK_OK 5800 #undef CHECK_OK
5770 #undef CHECK_OK_CUSTOM 5801 #undef CHECK_OK_CUSTOM
5771 #undef CHECK_OK_VOID 5802 #undef CHECK_OK_VOID
5772 5803
5773 } // namespace internal 5804 } // namespace internal
5774 } // namespace v8 5805 } // namespace v8
5775 5806
5776 #endif // V8_PARSING_PARSER_BASE_H 5807 #endif // V8_PARSING_PARSER_BASE_H
OLDNEW
« no previous file with comments | « src/parsing/parser.cc ('k') | src/parsing/preparser.h » ('j') | src/parsing/scanner.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698