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

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

Issue 2665513002: [parser] Lift template literal invalid escape restriction (Closed)
Patch Set: rebase harder 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 615 matching lines...) Expand 10 before | Expand all | Expand 10 after
868 return true; 870 return true;
869 } 871 }
870 return false; 872 return false;
871 } 873 }
872 874
873 bool PeekInOrOf() { 875 bool PeekInOrOf() {
874 return peek() == Token::IN || PeekContextualKeyword(CStrVector("of")); 876 return peek() == Token::IN || PeekContextualKeyword(CStrVector("of"));
875 } 877 }
876 878
877 // Checks whether an octal literal was last seen between beg_pos and end_pos. 879 // Checks whether an octal literal was last seen between beg_pos and end_pos.
878 // If so, reports an error. Only called for strict mode and template strings. 880 // Only called for strict mode strings.
879 void CheckOctalLiteral(int beg_pos, int end_pos, bool is_template, bool* ok) { 881 void CheckStrictOctalLiteral(int beg_pos, int end_pos, bool* ok) {
880 Scanner::Location octal = scanner()->octal_position(); 882 Scanner::Location octal = scanner()->octal_position();
881 if (octal.IsValid() && beg_pos <= octal.beg_pos && 883 if (octal.IsValid() && beg_pos <= octal.beg_pos &&
882 octal.end_pos <= end_pos) { 884 octal.end_pos <= end_pos) {
883 MessageTemplate::Template message = 885 MessageTemplate::Template message = scanner()->octal_message();
884 is_template ? MessageTemplate::kTemplateOctalLiteral
885 : scanner()->octal_message();
886 DCHECK_NE(message, MessageTemplate::kNone); 886 DCHECK_NE(message, MessageTemplate::kNone);
887 impl()->ReportMessageAt(octal, message); 887 impl()->ReportMessageAt(octal, message);
888 scanner()->clear_octal_position(); 888 scanner()->clear_octal_position();
889 if (message == MessageTemplate::kStrictDecimalWithLeadingZero) { 889 if (message == MessageTemplate::kStrictDecimalWithLeadingZero) {
890 impl()->CountUsage(v8::Isolate::kDecimalWithLeadingZeroInStrictMode); 890 impl()->CountUsage(v8::Isolate::kDecimalWithLeadingZeroInStrictMode);
891 } 891 }
892 *ok = false; 892 *ok = false;
893 } 893 }
894 } 894 }
895 895
896 inline void CheckStrictOctalLiteral(int beg_pos, int end_pos, bool* ok) { 896 // Checks if an octal literal or an invalid hex or unicode escape sequence
897 CheckOctalLiteral(beg_pos, end_pos, false, ok); 897 // appears between beg_pos and end_pos. In the presence of such, either
898 } 898 // returns false or reports an error, depending on dont_throw. Otherwise
899 899 // returns true.
900 inline void CheckTemplateOctalLiteral(int beg_pos, int end_pos, bool* ok) { 900 inline bool CheckTemplateEscapes(int beg_pos, int end_pos, bool dont_throw,
901 CheckOctalLiteral(beg_pos, end_pos, true, ok); 901 bool* ok) {
902 Scanner::Location octal = scanner()->octal_position();
903 if (octal.IsValid() && beg_pos <= octal.beg_pos &&
904 octal.end_pos <= end_pos) {
905 if (dont_throw) {
906 scanner()->clear_octal_position();
907 return false;
908 }
909 MessageTemplate::Template message =
910 MessageTemplate::kTemplateOctalLiteral;
911 impl()->ReportMessageAt(octal, message);
912 scanner()->clear_octal_position();
913 *ok = false;
914 } else if (scanner()->has_error()) {
915 if (dont_throw) {
916 scanner()->clear_error();
917 return false;
918 }
919 impl()->ReportMessageAt(scanner()->error_location(), scanner()->error());
920 scanner()->clear_error();
921 *ok = false;
922 }
923 return true;
902 } 924 }
903 925
904 void CheckDestructuringElement(ExpressionT element, int beg_pos, int end_pos); 926 void CheckDestructuringElement(ExpressionT element, int beg_pos, int end_pos);
905 927
906 // Checking the name of a function literal. This has to be done after parsing 928 // Checking the name of a function literal. This has to be done after parsing
907 // the function, since the function can declare itself strict. 929 // the function, since the function can declare itself strict.
908 void CheckFunctionName(LanguageMode language_mode, IdentifierT function_name, 930 void CheckFunctionName(LanguageMode language_mode, IdentifierT function_name,
909 FunctionNameValidity function_name_validity, 931 FunctionNameValidity function_name_validity,
910 const Scanner::Location& function_name_loc, bool* ok) { 932 const Scanner::Location& function_name_loc, bool* ok) {
911 if (function_name_validity == kSkipFunctionNameCheck) return; 933 if (function_name_validity == kSkipFunctionNameCheck) return;
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
1198 const FormalParametersT& parameters, 1220 const FormalParametersT& parameters,
1199 bool* ok); 1221 bool* ok);
1200 void ParseAsyncFunctionBody(Scope* scope, StatementListT body, 1222 void ParseAsyncFunctionBody(Scope* scope, StatementListT body,
1201 FunctionKind kind, FunctionBodyType type, 1223 FunctionKind kind, FunctionBodyType type,
1202 bool accept_IN, int pos, bool* ok); 1224 bool accept_IN, int pos, bool* ok);
1203 ExpressionT ParseAsyncFunctionLiteral(bool* ok); 1225 ExpressionT ParseAsyncFunctionLiteral(bool* ok);
1204 ExpressionT ParseClassLiteral(IdentifierT name, 1226 ExpressionT ParseClassLiteral(IdentifierT name,
1205 Scanner::Location class_name_location, 1227 Scanner::Location class_name_location,
1206 bool name_is_strict_reserved, 1228 bool name_is_strict_reserved,
1207 int class_token_pos, bool* ok); 1229 int class_token_pos, bool* ok);
1230 template <bool tagged>
vogelheim 2017/02/13 17:36:06 Why is this a template parameter, rather than a re
bakkot1 2017/02/13 20:22:24 I default to using template parameters for statica
1208 ExpressionT ParseTemplateLiteral(ExpressionT tag, int start, bool* ok); 1231 ExpressionT ParseTemplateLiteral(ExpressionT tag, int start, bool* ok);
1209 ExpressionT ParseSuperExpression(bool is_new, bool* ok); 1232 ExpressionT ParseSuperExpression(bool is_new, bool* ok);
1210 ExpressionT ParseDynamicImportExpression(bool* ok); 1233 ExpressionT ParseDynamicImportExpression(bool* ok);
1211 ExpressionT ParseNewTargetExpression(bool* ok); 1234 ExpressionT ParseNewTargetExpression(bool* ok);
1212 1235
1213 void ParseFormalParameter(FormalParametersT* parameters, bool* ok); 1236 void ParseFormalParameter(FormalParametersT* parameters, bool* ok);
1214 void ParseFormalParameterList(FormalParametersT* parameters, bool* ok); 1237 void ParseFormalParameterList(FormalParametersT* parameters, bool* ok);
1215 void CheckArityRestrictions(int param_count, FunctionKind function_type, 1238 void CheckArityRestrictions(int param_count, FunctionKind function_type,
1216 bool has_rest, int formals_start_pos, 1239 bool has_rest, int formals_start_pos,
1217 int formals_end_pos, bool* ok); 1240 int formals_end_pos, bool* ok);
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
1480 1503
1481 bool allow_natives_; 1504 bool allow_natives_;
1482 bool allow_tailcalls_; 1505 bool allow_tailcalls_;
1483 bool allow_harmony_do_expressions_; 1506 bool allow_harmony_do_expressions_;
1484 bool allow_harmony_function_sent_; 1507 bool allow_harmony_function_sent_;
1485 bool allow_harmony_restrictive_generators_; 1508 bool allow_harmony_restrictive_generators_;
1486 bool allow_harmony_trailing_commas_; 1509 bool allow_harmony_trailing_commas_;
1487 bool allow_harmony_class_fields_; 1510 bool allow_harmony_class_fields_;
1488 bool allow_harmony_object_rest_spread_; 1511 bool allow_harmony_object_rest_spread_;
1489 bool allow_harmony_dynamic_import_; 1512 bool allow_harmony_dynamic_import_;
1513 bool allow_harmony_template_escapes_;
1490 1514
1491 friend class DiscardableZoneScope; 1515 friend class DiscardableZoneScope;
1492 }; 1516 };
1493 1517
1494 template <typename Impl> 1518 template <typename Impl>
1495 ParserBase<Impl>::FunctionState::FunctionState( 1519 ParserBase<Impl>::FunctionState::FunctionState(
1496 FunctionState** function_state_stack, ScopeState** scope_stack, 1520 FunctionState** function_state_stack, ScopeState** scope_stack,
1497 DeclarationScope* scope) 1521 DeclarationScope* scope)
1498 : ScopeState(scope_stack, scope), 1522 : ScopeState(scope_stack, scope),
1499 next_materialized_literal_index_(0), 1523 next_materialized_literal_index_(0),
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
1849 CHECK_OK); 1873 CHECK_OK);
1850 class_name_location = scanner()->location(); 1874 class_name_location = scanner()->location();
1851 } 1875 }
1852 return ParseClassLiteral(name, class_name_location, 1876 return ParseClassLiteral(name, class_name_location,
1853 is_strict_reserved_name, class_token_pos, ok); 1877 is_strict_reserved_name, class_token_pos, ok);
1854 } 1878 }
1855 1879
1856 case Token::TEMPLATE_SPAN: 1880 case Token::TEMPLATE_SPAN:
1857 case Token::TEMPLATE_TAIL: 1881 case Token::TEMPLATE_TAIL:
1858 BindingPatternUnexpectedToken(); 1882 BindingPatternUnexpectedToken();
1859 return ParseTemplateLiteral(impl()->NoTemplateTag(), beg_pos, ok); 1883 return ParseTemplateLiteral<false>(impl()->NoTemplateTag(), beg_pos, ok);
1860 1884
1861 case Token::MOD: 1885 case Token::MOD:
1862 if (allow_natives() || extension_ != NULL) { 1886 if (allow_natives() || extension_ != NULL) {
1863 BindingPatternUnexpectedToken(); 1887 BindingPatternUnexpectedToken();
1864 return ParseV8Intrinsic(ok); 1888 return ParseV8Intrinsic(ok);
1865 } 1889 }
1866 break; 1890 break;
1867 1891
1868 case Token::DO: 1892 case Token::DO:
1869 if (allow_harmony_do_expressions()) { 1893 if (allow_harmony_do_expressions()) {
(...skipping 1400 matching lines...) Expand 10 before | Expand all | Expand 10 after
3270 result, factory()->NewStringLiteral(name, pos), pos); 3294 result, factory()->NewStringLiteral(name, pos), pos);
3271 impl()->PushLiteralName(name); 3295 impl()->PushLiteralName(name);
3272 break; 3296 break;
3273 } 3297 }
3274 3298
3275 case Token::TEMPLATE_SPAN: 3299 case Token::TEMPLATE_SPAN:
3276 case Token::TEMPLATE_TAIL: { 3300 case Token::TEMPLATE_TAIL: {
3277 impl()->RewriteNonPattern(CHECK_OK); 3301 impl()->RewriteNonPattern(CHECK_OK);
3278 BindingPatternUnexpectedToken(); 3302 BindingPatternUnexpectedToken();
3279 ArrowFormalParametersUnexpectedToken(); 3303 ArrowFormalParametersUnexpectedToken();
3280 result = ParseTemplateLiteral(result, position(), CHECK_OK); 3304 result = ParseTemplateLiteral<true>(result, position(), CHECK_OK);
3281 break; 3305 break;
3282 } 3306 }
3283 3307
3284 default: 3308 default:
3285 return result; 3309 return result;
3286 } 3310 }
3287 } 3311 }
3288 } 3312 }
3289 3313
3290 template <typename Impl> 3314 template <typename Impl>
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
3545 if (scanner()->current_token() == Token::IDENTIFIER) { 3569 if (scanner()->current_token() == Token::IDENTIFIER) {
3546 pos = position(); 3570 pos = position();
3547 } else { 3571 } else {
3548 pos = peek_position(); 3572 pos = peek_position();
3549 if (expression->IsFunctionLiteral()) { 3573 if (expression->IsFunctionLiteral()) {
3550 // If the tag function looks like an IIFE, set_parenthesized() to 3574 // If the tag function looks like an IIFE, set_parenthesized() to
3551 // force eager compilation. 3575 // force eager compilation.
3552 expression->AsFunctionLiteral()->SetShouldEagerCompile(); 3576 expression->AsFunctionLiteral()->SetShouldEagerCompile();
3553 } 3577 }
3554 } 3578 }
3555 expression = ParseTemplateLiteral(expression, pos, CHECK_OK); 3579 expression = ParseTemplateLiteral<true>(expression, pos, CHECK_OK);
3556 break; 3580 break;
3557 } 3581 }
3558 case Token::ILLEGAL: { 3582 case Token::ILLEGAL: {
3559 ReportUnexpectedTokenAt(scanner()->peek_location(), Token::ILLEGAL); 3583 ReportUnexpectedTokenAt(scanner()->peek_location(), Token::ILLEGAL);
3560 *ok = false; 3584 *ok = false;
3561 return impl()->EmptyExpression(); 3585 return impl()->EmptyExpression();
3562 } 3586 }
3563 default: 3587 default:
3564 return expression; 3588 return expression;
3565 } 3589 }
(...skipping 871 matching lines...) Expand 10 before | Expand all | Expand 10 after
4437 &is_strict_reserved, CHECK_OK); 4461 &is_strict_reserved, CHECK_OK);
4438 } 4462 }
4439 return impl()->ParseFunctionLiteral( 4463 return impl()->ParseFunctionLiteral(
4440 name, scanner()->location(), 4464 name, scanner()->location(),
4441 is_strict_reserved ? kFunctionNameIsStrictReserved 4465 is_strict_reserved ? kFunctionNameIsStrictReserved
4442 : kFunctionNameValidityUnknown, 4466 : kFunctionNameValidityUnknown,
4443 FunctionKind::kAsyncFunction, pos, type, language_mode(), CHECK_OK); 4467 FunctionKind::kAsyncFunction, pos, type, language_mode(), CHECK_OK);
4444 } 4468 }
4445 4469
4446 template <typename Impl> 4470 template <typename Impl>
4471 template <bool tagged>
4447 typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseTemplateLiteral( 4472 typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseTemplateLiteral(
4448 ExpressionT tag, int start, bool* ok) { 4473 ExpressionT tag, int start, bool* ok) {
4449 // A TemplateLiteral is made up of 0 or more TEMPLATE_SPAN tokens (literal 4474 // A TemplateLiteral is made up of 0 or more TEMPLATE_SPAN tokens (literal
4450 // text followed by a substitution expression), finalized by a single 4475 // text followed by a substitution expression), finalized by a single
4451 // TEMPLATE_TAIL. 4476 // TEMPLATE_TAIL.
4452 // 4477 //
4453 // In terms of draft language, TEMPLATE_SPAN may be either the TemplateHead or 4478 // In terms of draft language, TEMPLATE_SPAN may be either the TemplateHead or
4454 // TemplateMiddle productions, while TEMPLATE_TAIL is either TemplateTail, or 4479 // TemplateMiddle productions, while TEMPLATE_TAIL is either TemplateTail, or
4455 // NoSubstitutionTemplate. 4480 // NoSubstitutionTemplate.
4456 // 4481 //
4457 // When parsing a TemplateLiteral, we must have scanned either an initial 4482 // When parsing a TemplateLiteral, we must have scanned either an initial
4458 // TEMPLATE_SPAN, or a TEMPLATE_TAIL. 4483 // TEMPLATE_SPAN, or a TEMPLATE_TAIL.
4459 CHECK(peek() == Token::TEMPLATE_SPAN || peek() == Token::TEMPLATE_TAIL); 4484 CHECK(peek() == Token::TEMPLATE_SPAN || peek() == Token::TEMPLATE_TAIL);
4460 4485
4486 bool allow_illegal_escapes = tagged && allow_harmony_template_escapes();
4487 bool should_cook = true;
4488
4461 // If we reach a TEMPLATE_TAIL first, we are parsing a NoSubstitutionTemplate. 4489 // If we reach a TEMPLATE_TAIL first, we are parsing a NoSubstitutionTemplate.
4462 // In this case we may simply consume the token and build a template with a 4490 // In this case we may simply consume the token and build a template with a
4463 // single TEMPLATE_SPAN and no expressions. 4491 // single TEMPLATE_SPAN and no expressions.
4464 if (peek() == Token::TEMPLATE_TAIL) { 4492 if (peek() == Token::TEMPLATE_TAIL) {
4465 Consume(Token::TEMPLATE_TAIL); 4493 Consume(Token::TEMPLATE_TAIL);
4466 int pos = position(); 4494 int pos = position();
4467 CheckTemplateOctalLiteral(pos, peek_position(), CHECK_OK);
4468 typename Impl::TemplateLiteralState ts = impl()->OpenTemplateLiteral(pos); 4495 typename Impl::TemplateLiteralState ts = impl()->OpenTemplateLiteral(pos);
4469 impl()->AddTemplateSpan(&ts, true); 4496 should_cook = CheckTemplateEscapes(pos, peek_position(),
4497 allow_illegal_escapes, CHECK_OK);
4498 impl()->AddTemplateSpan(&ts, should_cook, true);
4470 return impl()->CloseTemplateLiteral(&ts, start, tag); 4499 return impl()->CloseTemplateLiteral(&ts, start, tag);
4471 } 4500 }
4472 4501
4473 Consume(Token::TEMPLATE_SPAN); 4502 Consume(Token::TEMPLATE_SPAN);
4474 int pos = position(); 4503 int pos = position();
4504 should_cook = CheckTemplateEscapes(pos, peek_position(),
4505 allow_illegal_escapes, CHECK_OK);
4475 typename Impl::TemplateLiteralState ts = impl()->OpenTemplateLiteral(pos); 4506 typename Impl::TemplateLiteralState ts = impl()->OpenTemplateLiteral(pos);
4476 impl()->AddTemplateSpan(&ts, false); 4507 impl()->AddTemplateSpan(&ts, should_cook, false);
4477 Token::Value next; 4508 Token::Value next;
4478 4509
4479 // If we open with a TEMPLATE_SPAN, we must scan the subsequent expression, 4510 // If we open with a TEMPLATE_SPAN, we must scan the subsequent expression,
4480 // and repeat if the following token is a TEMPLATE_SPAN as well (in this 4511 // and repeat if the following token is a TEMPLATE_SPAN as well (in this
4481 // case, representing a TemplateMiddle). 4512 // case, representing a TemplateMiddle).
4482 4513
4483 do { 4514 do {
4484 CheckTemplateOctalLiteral(pos, peek_position(), CHECK_OK);
4485 next = peek(); 4515 next = peek();
4486 if (next == Token::EOS) { 4516 if (next == Token::EOS) {
4487 impl()->ReportMessageAt(Scanner::Location(start, peek_position()), 4517 impl()->ReportMessageAt(Scanner::Location(start, peek_position()),
4488 MessageTemplate::kUnterminatedTemplate); 4518 MessageTemplate::kUnterminatedTemplate);
4489 *ok = false; 4519 *ok = false;
4490 return impl()->EmptyExpression(); 4520 return impl()->EmptyExpression();
4491 } else if (next == Token::ILLEGAL) { 4521 } else if (next == Token::ILLEGAL) {
4492 impl()->ReportMessageAt( 4522 impl()->ReportMessageAt(
4493 Scanner::Location(position() + 1, peek_position()), 4523 Scanner::Location(position() + 1, peek_position()),
4494 MessageTemplate::kUnexpectedToken, "ILLEGAL", kSyntaxError); 4524 MessageTemplate::kUnexpectedToken, "ILLEGAL", kSyntaxError);
(...skipping 25 matching lines...) Expand all
4520 *ok = false; 4550 *ok = false;
4521 return impl()->EmptyExpression(); 4551 return impl()->EmptyExpression();
4522 } else if (next == Token::ILLEGAL) { 4552 } else if (next == Token::ILLEGAL) {
4523 impl()->ReportMessageAt( 4553 impl()->ReportMessageAt(
4524 Scanner::Location(position() + 1, peek_position()), 4554 Scanner::Location(position() + 1, peek_position()),
4525 MessageTemplate::kUnexpectedToken, "ILLEGAL", kSyntaxError); 4555 MessageTemplate::kUnexpectedToken, "ILLEGAL", kSyntaxError);
4526 *ok = false; 4556 *ok = false;
4527 return impl()->EmptyExpression(); 4557 return impl()->EmptyExpression();
4528 } 4558 }
4529 4559
4530 impl()->AddTemplateSpan(&ts, next == Token::TEMPLATE_TAIL); 4560 should_cook = CheckTemplateEscapes(pos, peek_position(),
4561 allow_illegal_escapes, CHECK_OK);
4562 impl()->AddTemplateSpan(&ts, should_cook, next == Token::TEMPLATE_TAIL);
4531 } while (next == Token::TEMPLATE_SPAN); 4563 } while (next == Token::TEMPLATE_SPAN);
4532 4564
4533 DCHECK_EQ(next, Token::TEMPLATE_TAIL); 4565 DCHECK_EQ(next, Token::TEMPLATE_TAIL);
4534 CheckTemplateOctalLiteral(pos, peek_position(), CHECK_OK);
4535 // Once we've reached a TEMPLATE_TAIL, we can close the TemplateLiteral. 4566 // Once we've reached a TEMPLATE_TAIL, we can close the TemplateLiteral.
4536 return impl()->CloseTemplateLiteral(&ts, start, tag); 4567 return impl()->CloseTemplateLiteral(&ts, start, tag);
4537 } 4568 }
4538 4569
4539 template <typename Impl> 4570 template <typename Impl>
4540 typename ParserBase<Impl>::ExpressionT 4571 typename ParserBase<Impl>::ExpressionT
4541 ParserBase<Impl>::CheckAndRewriteReferenceExpression( 4572 ParserBase<Impl>::CheckAndRewriteReferenceExpression(
4542 ExpressionT expression, int beg_pos, int end_pos, 4573 ExpressionT expression, int beg_pos, int end_pos,
4543 MessageTemplate::Template message, bool* ok) { 4574 MessageTemplate::Template message, bool* ok) {
4544 return CheckAndRewriteReferenceExpression(expression, beg_pos, end_pos, 4575 return CheckAndRewriteReferenceExpression(expression, beg_pos, end_pos,
(...skipping 1206 matching lines...) Expand 10 before | Expand all | Expand 10 after
5751 return; 5782 return;
5752 } 5783 }
5753 } 5784 }
5754 5785
5755 #undef CHECK_OK_VOID 5786 #undef CHECK_OK_VOID
5756 5787
5757 } // namespace internal 5788 } // namespace internal
5758 } // namespace v8 5789 } // namespace v8
5759 5790
5760 #endif // V8_PARSING_PARSER_BASE_H 5791 #endif // V8_PARSING_PARSER_BASE_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698