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

Side by Side Diff: src/preparser.cc

Issue 88653003: Add literal handling to experimental scanner. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Landing Created 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/preparser.h ('k') | src/runtime.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 // That means that contextual checks (like a label being declared where 97 // That means that contextual checks (like a label being declared where
98 // it is used) are generally omitted. 98 // it is used) are generally omitted.
99 99
100 void PreParser::ReportUnexpectedToken(Token::Value token) { 100 void PreParser::ReportUnexpectedToken(Token::Value token) {
101 // We don't report stack overflows here, to avoid increasing the 101 // We don't report stack overflows here, to avoid increasing the
102 // stack depth even further. Instead we report it after parsing is 102 // stack depth even further. Instead we report it after parsing is
103 // over, in ParseProgram. 103 // over, in ParseProgram.
104 if (token == Token::ILLEGAL && stack_overflow()) { 104 if (token == Token::ILLEGAL && stack_overflow()) {
105 return; 105 return;
106 } 106 }
107 Scanner::Location source_location = scanner()->location(); 107 ScannerBase::Location source_location = scanner()->location();
108 108
109 // Four of the tokens are treated specially 109 // Four of the tokens are treated specially
110 switch (token) { 110 switch (token) {
111 case Token::EOS: 111 case Token::EOS:
112 return ReportMessageAt(source_location, "unexpected_eos", NULL); 112 return ReportMessageAt(source_location, "unexpected_eos", NULL);
113 case Token::NUMBER: 113 case Token::NUMBER:
114 return ReportMessageAt(source_location, "unexpected_token_number", NULL); 114 return ReportMessageAt(source_location, "unexpected_token_number", NULL);
115 case Token::STRING: 115 case Token::STRING:
116 return ReportMessageAt(source_location, "unexpected_token_string", NULL); 116 return ReportMessageAt(source_location, "unexpected_token_string", NULL);
117 case Token::IDENTIFIER: 117 case Token::IDENTIFIER:
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 case Token::SWITCH: 255 case Token::SWITCH:
256 return ParseSwitchStatement(ok); 256 return ParseSwitchStatement(ok);
257 257
258 case Token::THROW: 258 case Token::THROW:
259 return ParseThrowStatement(ok); 259 return ParseThrowStatement(ok);
260 260
261 case Token::TRY: 261 case Token::TRY:
262 return ParseTryStatement(ok); 262 return ParseTryStatement(ok);
263 263
264 case Token::FUNCTION: { 264 case Token::FUNCTION: {
265 Scanner::Location start_location = scanner()->peek_location(); 265 ScannerBase::Location start_location = scanner()->peek_location();
266 Statement statement = ParseFunctionDeclaration(CHECK_OK); 266 Statement statement = ParseFunctionDeclaration(CHECK_OK);
267 Scanner::Location end_location = scanner()->location(); 267 ScannerBase::Location end_location = scanner()->location();
268 if (!is_classic_mode()) { 268 if (!is_classic_mode()) {
269 ReportMessageAt(start_location.beg_pos, end_location.end_pos, 269 ReportMessageAt(start_location.beg_pos, end_location.end_pos,
270 "strict_function", NULL); 270 "strict_function", NULL);
271 *ok = false; 271 *ok = false;
272 return Statement::Default(); 272 return Statement::Default();
273 } else { 273 } else {
274 return statement; 274 return statement;
275 } 275 }
276 } 276 }
277 277
278 case Token::DEBUGGER: 278 case Token::DEBUGGER:
279 return ParseDebuggerStatement(ok); 279 return ParseDebuggerStatement(ok);
280 280
281 default: 281 default:
282 return ParseExpressionOrLabelledStatement(ok); 282 return ParseExpressionOrLabelledStatement(ok);
283 } 283 }
284 } 284 }
285 285
286 286
287 PreParser::Statement PreParser::ParseFunctionDeclaration(bool* ok) { 287 PreParser::Statement PreParser::ParseFunctionDeclaration(bool* ok) {
288 // FunctionDeclaration :: 288 // FunctionDeclaration ::
289 // 'function' Identifier '(' FormalParameterListopt ')' '{' FunctionBody '}' 289 // 'function' Identifier '(' FormalParameterListopt ')' '{' FunctionBody '}'
290 // GeneratorDeclaration :: 290 // GeneratorDeclaration ::
291 // 'function' '*' Identifier '(' FormalParameterListopt ')' 291 // 'function' '*' Identifier '(' FormalParameterListopt ')'
292 // '{' FunctionBody '}' 292 // '{' FunctionBody '}'
293 Expect(Token::FUNCTION, CHECK_OK); 293 Expect(Token::FUNCTION, CHECK_OK);
294 294
295 bool is_generator = allow_generators() && Check(Token::MUL); 295 bool is_generator = allow_generators() && Check(Token::MUL);
296 Identifier identifier = ParseIdentifier(CHECK_OK); 296 Identifier identifier = ParseIdentifier(CHECK_OK);
297 Scanner::Location location = scanner()->location(); 297 ScannerBase::Location location = scanner()->location();
298 298
299 Expression function_value = ParseFunctionLiteral(is_generator, CHECK_OK); 299 Expression function_value = ParseFunctionLiteral(is_generator, CHECK_OK);
300 300
301 if (function_value.IsStrictFunction() && 301 if (function_value.IsStrictFunction() &&
302 !identifier.IsValidStrictVariable()) { 302 !identifier.IsValidStrictVariable()) {
303 // Strict mode violation, using either reserved word or eval/arguments 303 // Strict mode violation, using either reserved word or eval/arguments
304 // as name of strict function. 304 // as name of strict function.
305 const char* type = "strict_function_name"; 305 const char* type = "strict_function_name";
306 if (identifier.IsFutureStrictReserved() || identifier.IsYield()) { 306 if (identifier.IsFutureStrictReserved() || identifier.IsYield()) {
307 type = "strict_reserved_word"; 307 type = "strict_reserved_word";
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 // contained in extended code. 383 // contained in extended code.
384 // 384 //
385 // However disallowing const in classic mode will break compatibility with 385 // However disallowing const in classic mode will break compatibility with
386 // existing pages. Therefore we keep allowing const with the old 386 // existing pages. Therefore we keep allowing const with the old
387 // non-harmony semantics in classic mode. 387 // non-harmony semantics in classic mode.
388 Consume(Token::CONST); 388 Consume(Token::CONST);
389 switch (language_mode()) { 389 switch (language_mode()) {
390 case CLASSIC_MODE: 390 case CLASSIC_MODE:
391 break; 391 break;
392 case STRICT_MODE: { 392 case STRICT_MODE: {
393 Scanner::Location location = scanner()->peek_location(); 393 ScannerBase::Location location = scanner()->peek_location();
394 ReportMessageAt(location, "strict_const", NULL); 394 ReportMessageAt(location, "strict_const", NULL);
395 *ok = false; 395 *ok = false;
396 return Statement::Default(); 396 return Statement::Default();
397 } 397 }
398 case EXTENDED_MODE: 398 case EXTENDED_MODE:
399 if (var_context != kSourceElement && 399 if (var_context != kSourceElement &&
400 var_context != kForStatement) { 400 var_context != kForStatement) {
401 Scanner::Location location = scanner()->peek_location(); 401 ScannerBase::Location location = scanner()->peek_location();
402 ReportMessageAt(location.beg_pos, location.end_pos, 402 ReportMessageAt(location.beg_pos, location.end_pos,
403 "unprotected_const", NULL); 403 "unprotected_const", NULL);
404 *ok = false; 404 *ok = false;
405 return Statement::Default(); 405 return Statement::Default();
406 } 406 }
407 require_initializer = true; 407 require_initializer = true;
408 break; 408 break;
409 } 409 }
410 } else if (peek() == Token::LET) { 410 } else if (peek() == Token::LET) {
411 // ES6 Draft Rev4 section 12.2.1: 411 // ES6 Draft Rev4 section 12.2.1:
412 // 412 //
413 // LetDeclaration : let LetBindingList ; 413 // LetDeclaration : let LetBindingList ;
414 // 414 //
415 // * It is a Syntax Error if the code that matches this production is not 415 // * It is a Syntax Error if the code that matches this production is not
416 // contained in extended code. 416 // contained in extended code.
417 if (!is_extended_mode()) { 417 if (!is_extended_mode()) {
418 Scanner::Location location = scanner()->peek_location(); 418 ScannerBase::Location location = scanner()->peek_location();
419 ReportMessageAt(location.beg_pos, location.end_pos, 419 ReportMessageAt(location.beg_pos, location.end_pos,
420 "illegal_let", NULL); 420 "illegal_let", NULL);
421 *ok = false; 421 *ok = false;
422 return Statement::Default(); 422 return Statement::Default();
423 } 423 }
424 Consume(Token::LET); 424 Consume(Token::LET);
425 if (var_context != kSourceElement && 425 if (var_context != kSourceElement &&
426 var_context != kForStatement) { 426 var_context != kForStatement) {
427 Scanner::Location location = scanner()->peek_location(); 427 ScannerBase::Location location = scanner()->peek_location();
428 ReportMessageAt(location.beg_pos, location.end_pos, 428 ReportMessageAt(location.beg_pos, location.end_pos,
429 "unprotected_let", NULL); 429 "unprotected_let", NULL);
430 *ok = false; 430 *ok = false;
431 return Statement::Default(); 431 return Statement::Default();
432 } 432 }
433 } else { 433 } else {
434 *ok = false; 434 *ok = false;
435 return Statement::Default(); 435 return Statement::Default();
436 } 436 }
437 437
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 ExpectSemicolon(CHECK_OK); 564 ExpectSemicolon(CHECK_OK);
565 return Statement::Default(); 565 return Statement::Default();
566 } 566 }
567 567
568 568
569 PreParser::Statement PreParser::ParseWithStatement(bool* ok) { 569 PreParser::Statement PreParser::ParseWithStatement(bool* ok) {
570 // WithStatement :: 570 // WithStatement ::
571 // 'with' '(' Expression ')' Statement 571 // 'with' '(' Expression ')' Statement
572 Expect(Token::WITH, CHECK_OK); 572 Expect(Token::WITH, CHECK_OK);
573 if (!is_classic_mode()) { 573 if (!is_classic_mode()) {
574 Scanner::Location location = scanner()->location(); 574 ScannerBase::Location location = scanner()->location();
575 ReportMessageAt(location, "strict_mode_with", NULL); 575 ReportMessageAt(location, "strict_mode_with", NULL);
576 *ok = false; 576 *ok = false;
577 return Statement::Default(); 577 return Statement::Default();
578 } 578 }
579 Expect(Token::LPAREN, CHECK_OK); 579 Expect(Token::LPAREN, CHECK_OK);
580 ParseExpression(true, CHECK_OK); 580 ParseExpression(true, CHECK_OK);
581 Expect(Token::RPAREN, CHECK_OK); 581 Expect(Token::RPAREN, CHECK_OK);
582 582
583 Scope::InsideWith iw(scope_); 583 Scope::InsideWith iw(scope_);
584 ParseStatement(CHECK_OK); 584 ParseStatement(CHECK_OK);
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
709 return Statement::Default(); 709 return Statement::Default();
710 } 710 }
711 711
712 712
713 PreParser::Statement PreParser::ParseThrowStatement(bool* ok) { 713 PreParser::Statement PreParser::ParseThrowStatement(bool* ok) {
714 // ThrowStatement :: 714 // ThrowStatement ::
715 // 'throw' [no line terminator] Expression ';' 715 // 'throw' [no line terminator] Expression ';'
716 716
717 Expect(Token::THROW, CHECK_OK); 717 Expect(Token::THROW, CHECK_OK);
718 if (scanner()->HasAnyLineTerminatorBeforeNext()) { 718 if (scanner()->HasAnyLineTerminatorBeforeNext()) {
719 Scanner::Location pos = scanner()->location(); 719 ScannerBase::Location pos = scanner()->location();
720 ReportMessageAt(pos, "newline_after_throw", NULL); 720 ReportMessageAt(pos, "newline_after_throw", NULL);
721 *ok = false; 721 *ok = false;
722 return Statement::Default(); 722 return Statement::Default();
723 } 723 }
724 ParseExpression(true, CHECK_OK); 724 ParseExpression(true, CHECK_OK);
725 ExpectSemicolon(ok); 725 ExpectSemicolon(ok);
726 return Statement::Default(); 726 return Statement::Default();
727 } 727 }
728 728
729 729
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
818 bool* ok) { 818 bool* ok) {
819 // AssignmentExpression :: 819 // AssignmentExpression ::
820 // ConditionalExpression 820 // ConditionalExpression
821 // YieldExpression 821 // YieldExpression
822 // LeftHandSideExpression AssignmentOperator AssignmentExpression 822 // LeftHandSideExpression AssignmentOperator AssignmentExpression
823 823
824 if (scope_->is_generator() && peek() == Token::YIELD) { 824 if (scope_->is_generator() && peek() == Token::YIELD) {
825 return ParseYieldExpression(ok); 825 return ParseYieldExpression(ok);
826 } 826 }
827 827
828 Scanner::Location before = scanner()->peek_location(); 828 ScannerBase::Location before = scanner()->peek_location();
829 Expression expression = ParseConditionalExpression(accept_IN, CHECK_OK); 829 Expression expression = ParseConditionalExpression(accept_IN, CHECK_OK);
830 830
831 if (!Token::IsAssignmentOp(peek())) { 831 if (!Token::IsAssignmentOp(peek())) {
832 // Parsed conditional expression only (no assignment). 832 // Parsed conditional expression only (no assignment).
833 return expression; 833 return expression;
834 } 834 }
835 835
836 if (!is_classic_mode() && 836 if (!is_classic_mode() &&
837 expression.IsIdentifier() && 837 expression.IsIdentifier() &&
838 expression.AsIdentifier().IsEvalOrArguments()) { 838 expression.AsIdentifier().IsEvalOrArguments()) {
839 Scanner::Location after = scanner()->location(); 839 ScannerBase::Location after = scanner()->location();
840 ReportMessageAt(before.beg_pos, after.end_pos, 840 ReportMessageAt(before.beg_pos, after.end_pos,
841 "strict_lhs_assignment", NULL); 841 "strict_lhs_assignment", NULL);
842 *ok = false; 842 *ok = false;
843 return Expression::Default(); 843 return Expression::Default();
844 } 844 }
845 845
846 Token::Value op = Next(); // Get assignment operator. 846 Token::Value op = Next(); // Get assignment operator.
847 ParseAssignmentExpression(accept_IN, CHECK_OK); 847 ParseAssignmentExpression(accept_IN, CHECK_OK);
848 848
849 if ((op == Token::ASSIGN) && expression.IsThisProperty()) { 849 if ((op == Token::ASSIGN) && expression.IsThisProperty()) {
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
918 // '~' UnaryExpression 918 // '~' UnaryExpression
919 // '!' UnaryExpression 919 // '!' UnaryExpression
920 920
921 Token::Value op = peek(); 921 Token::Value op = peek();
922 if (Token::IsUnaryOp(op)) { 922 if (Token::IsUnaryOp(op)) {
923 op = Next(); 923 op = Next();
924 ParseUnaryExpression(ok); 924 ParseUnaryExpression(ok);
925 return Expression::Default(); 925 return Expression::Default();
926 } else if (Token::IsCountOp(op)) { 926 } else if (Token::IsCountOp(op)) {
927 op = Next(); 927 op = Next();
928 Scanner::Location before = scanner()->peek_location(); 928 ScannerBase::Location before = scanner()->peek_location();
929 Expression expression = ParseUnaryExpression(CHECK_OK); 929 Expression expression = ParseUnaryExpression(CHECK_OK);
930 if (!is_classic_mode() && 930 if (!is_classic_mode() &&
931 expression.IsIdentifier() && 931 expression.IsIdentifier() &&
932 expression.AsIdentifier().IsEvalOrArguments()) { 932 expression.AsIdentifier().IsEvalOrArguments()) {
933 Scanner::Location after = scanner()->location(); 933 ScannerBase::Location after = scanner()->location();
934 ReportMessageAt(before.beg_pos, after.end_pos, 934 ReportMessageAt(before.beg_pos, after.end_pos,
935 "strict_lhs_prefix", NULL); 935 "strict_lhs_prefix", NULL);
936 *ok = false; 936 *ok = false;
937 } 937 }
938 return Expression::Default(); 938 return Expression::Default();
939 } else { 939 } else {
940 return ParsePostfixExpression(ok); 940 return ParsePostfixExpression(ok);
941 } 941 }
942 } 942 }
943 943
944 944
945 PreParser::Expression PreParser::ParsePostfixExpression(bool* ok) { 945 PreParser::Expression PreParser::ParsePostfixExpression(bool* ok) {
946 // PostfixExpression :: 946 // PostfixExpression ::
947 // LeftHandSideExpression ('++' | '--')? 947 // LeftHandSideExpression ('++' | '--')?
948 948
949 Scanner::Location before = scanner()->peek_location(); 949 ScannerBase::Location before = scanner()->peek_location();
950 Expression expression = ParseLeftHandSideExpression(CHECK_OK); 950 Expression expression = ParseLeftHandSideExpression(CHECK_OK);
951 if (!scanner()->HasAnyLineTerminatorBeforeNext() && 951 if (!scanner()->HasAnyLineTerminatorBeforeNext() &&
952 Token::IsCountOp(peek())) { 952 Token::IsCountOp(peek())) {
953 if (!is_classic_mode() && 953 if (!is_classic_mode() &&
954 expression.IsIdentifier() && 954 expression.IsIdentifier() &&
955 expression.AsIdentifier().IsEvalOrArguments()) { 955 expression.AsIdentifier().IsEvalOrArguments()) {
956 Scanner::Location after = scanner()->location(); 956 ScannerBase::Location after = scanner()->location();
957 ReportMessageAt(before.beg_pos, after.end_pos, 957 ReportMessageAt(before.beg_pos, after.end_pos,
958 "strict_lhs_postfix", NULL); 958 "strict_lhs_postfix", NULL);
959 *ok = false; 959 *ok = false;
960 return Expression::Default(); 960 return Expression::Default();
961 } 961 }
962 Next(); 962 Next();
963 return Expression::Default(); 963 return Expression::Default();
964 } 964 }
965 return expression; 965 return expression;
966 } 966 }
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after
1486 } 1486 }
1487 } 1487 }
1488 return Identifier::Default(); 1488 return Identifier::Default();
1489 } 1489 }
1490 1490
1491 1491
1492 PreParser::Identifier PreParser::ParseIdentifier(bool* ok) { 1492 PreParser::Identifier PreParser::ParseIdentifier(bool* ok) {
1493 Token::Value next = Next(); 1493 Token::Value next = Next();
1494 switch (next) { 1494 switch (next) {
1495 case Token::FUTURE_RESERVED_WORD: { 1495 case Token::FUTURE_RESERVED_WORD: {
1496 Scanner::Location location = scanner()->location(); 1496 ScannerBase::Location location = scanner()->location();
1497 ReportMessageAt(location.beg_pos, location.end_pos, 1497 ReportMessageAt(location.beg_pos, location.end_pos,
1498 "reserved_word", NULL); 1498 "reserved_word", NULL);
1499 *ok = false; 1499 *ok = false;
1500 return GetIdentifierSymbol(); 1500 return GetIdentifierSymbol();
1501 } 1501 }
1502 case Token::YIELD: 1502 case Token::YIELD:
1503 if (scope_->is_generator()) { 1503 if (scope_->is_generator()) {
1504 // 'yield' in a generator is only valid as part of a YieldExpression. 1504 // 'yield' in a generator is only valid as part of a YieldExpression.
1505 ReportMessageAt(scanner()->location(), "unexpected_token", "yield"); 1505 ReportMessageAt(scanner()->location(), "unexpected_token", "yield");
1506 *ok = false; 1506 *ok = false;
1507 return Identifier::Yield(); 1507 return Identifier::Yield();
1508 } 1508 }
1509 // FALLTHROUGH 1509 // FALLTHROUGH
1510 case Token::FUTURE_STRICT_RESERVED_WORD: 1510 case Token::FUTURE_STRICT_RESERVED_WORD:
1511 if (!is_classic_mode()) { 1511 if (!is_classic_mode()) {
1512 Scanner::Location location = scanner()->location(); 1512 ScannerBase::Location location = scanner()->location();
1513 ReportMessageAt(location.beg_pos, location.end_pos, 1513 ReportMessageAt(location.beg_pos, location.end_pos,
1514 "strict_reserved_word", NULL); 1514 "strict_reserved_word", NULL);
1515 *ok = false; 1515 *ok = false;
1516 } 1516 }
1517 // FALLTHROUGH 1517 // FALLTHROUGH
1518 case Token::IDENTIFIER: 1518 case Token::IDENTIFIER:
1519 return GetIdentifierSymbol(); 1519 return GetIdentifierSymbol();
1520 default: 1520 default:
1521 *ok = false; 1521 *ok = false;
1522 return Identifier::Default(); 1522 return Identifier::Default();
1523 } 1523 }
1524 } 1524 }
1525 1525
1526 1526
1527 void PreParser::SetStrictModeViolation(Scanner::Location location, 1527 void PreParser::SetStrictModeViolation(ScannerBase::Location location,
1528 const char* type, 1528 const char* type,
1529 bool* ok) { 1529 bool* ok) {
1530 if (!is_classic_mode()) { 1530 if (!is_classic_mode()) {
1531 ReportMessageAt(location, type, NULL); 1531 ReportMessageAt(location, type, NULL);
1532 *ok = false; 1532 *ok = false;
1533 return; 1533 return;
1534 } 1534 }
1535 // Delay report in case this later turns out to be strict code 1535 // Delay report in case this later turns out to be strict code
1536 // (i.e., for function names and parameters prior to a "use strict" 1536 // (i.e., for function names and parameters prior to a "use strict"
1537 // directive). 1537 // directive).
1538 // It's safe to overwrite an existing violation. 1538 // It's safe to overwrite an existing violation.
1539 // It's either from a function that turned out to be non-strict, 1539 // It's either from a function that turned out to be non-strict,
1540 // or it's in the current function (and we just need to report 1540 // or it's in the current function (and we just need to report
1541 // one error), or it's in a unclosed nesting function that wasn't 1541 // one error), or it's in a unclosed nesting function that wasn't
1542 // strict (otherwise we would already be in strict mode). 1542 // strict (otherwise we would already be in strict mode).
1543 strict_mode_violation_location_ = location; 1543 strict_mode_violation_location_ = location;
1544 strict_mode_violation_type_ = type; 1544 strict_mode_violation_type_ = type;
1545 } 1545 }
1546 1546
1547 1547
1548 void PreParser::CheckDelayedStrictModeViolation(int beg_pos, 1548 void PreParser::CheckDelayedStrictModeViolation(int beg_pos,
1549 int end_pos, 1549 int end_pos,
1550 bool* ok) { 1550 bool* ok) {
1551 Scanner::Location location = strict_mode_violation_location_; 1551 ScannerBase::Location location = strict_mode_violation_location_;
1552 if (location.IsValid() && 1552 if (location.IsValid() &&
1553 location.beg_pos > beg_pos && location.end_pos < end_pos) { 1553 location.beg_pos > beg_pos && location.end_pos < end_pos) {
1554 ReportMessageAt(location, strict_mode_violation_type_, NULL); 1554 ReportMessageAt(location, strict_mode_violation_type_, NULL);
1555 *ok = false; 1555 *ok = false;
1556 } 1556 }
1557 } 1557 }
1558 1558
1559 1559
1560 void PreParser::StrictModeIdentifierViolation(Scanner::Location location, 1560 void PreParser::StrictModeIdentifierViolation(ScannerBase::Location location,
1561 const char* eval_args_type, 1561 const char* eval_args_type,
1562 Identifier identifier, 1562 Identifier identifier,
1563 bool* ok) { 1563 bool* ok) {
1564 const char* type = eval_args_type; 1564 const char* type = eval_args_type;
1565 if (identifier.IsFutureReserved()) { 1565 if (identifier.IsFutureReserved()) {
1566 type = "reserved_word"; 1566 type = "reserved_word";
1567 } else if (identifier.IsFutureStrictReserved() || identifier.IsYield()) { 1567 } else if (identifier.IsFutureStrictReserved() || identifier.IsYield()) {
1568 type = "strict_reserved_word"; 1568 type = "strict_reserved_word";
1569 } 1569 }
1570 if (!is_classic_mode()) { 1570 if (!is_classic_mode()) {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1640 ASSERT(IsAccessorAccessorConflict(old_type, type)); 1640 ASSERT(IsAccessorAccessorConflict(old_type, type));
1641 // Both accessors of the same type. 1641 // Both accessors of the same type.
1642 parser()->ReportMessageAt(scanner()->location(), 1642 parser()->ReportMessageAt(scanner()->location(),
1643 "accessor_get_set"); 1643 "accessor_get_set");
1644 } 1644 }
1645 *ok = false; 1645 *ok = false;
1646 } 1646 }
1647 } 1647 }
1648 1648
1649 } } // v8::internal 1649 } } // v8::internal
OLDNEW
« no previous file with comments | « src/preparser.h ('k') | src/runtime.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698