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

Side by Side Diff: src/preparser.cc

Issue 7218009: Make multi-line comments not count when checking whether --> is first on a line. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Undid too much. Created 9 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « src/parser.cc ('k') | src/preparser-api.cc » ('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 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 return Statement::Default(); 376 return Statement::Default();
377 } 377 }
378 378
379 379
380 PreParser::Statement PreParser::ParseContinueStatement(bool* ok) { 380 PreParser::Statement PreParser::ParseContinueStatement(bool* ok) {
381 // ContinueStatement :: 381 // ContinueStatement ::
382 // 'continue' [no line terminator] Identifier? ';' 382 // 'continue' [no line terminator] Identifier? ';'
383 383
384 Expect(i::Token::CONTINUE, CHECK_OK); 384 Expect(i::Token::CONTINUE, CHECK_OK);
385 i::Token::Value tok = peek(); 385 i::Token::Value tok = peek();
386 if (!scanner_->has_line_terminator_before_next() && 386 if (!scanner_->HasAnyLineTerminatorBeforeNext() &&
387 tok != i::Token::SEMICOLON && 387 tok != i::Token::SEMICOLON &&
388 tok != i::Token::RBRACE && 388 tok != i::Token::RBRACE &&
389 tok != i::Token::EOS) { 389 tok != i::Token::EOS) {
390 ParseIdentifier(CHECK_OK); 390 ParseIdentifier(CHECK_OK);
391 } 391 }
392 ExpectSemicolon(CHECK_OK); 392 ExpectSemicolon(CHECK_OK);
393 return Statement::Default(); 393 return Statement::Default();
394 } 394 }
395 395
396 396
397 PreParser::Statement PreParser::ParseBreakStatement(bool* ok) { 397 PreParser::Statement PreParser::ParseBreakStatement(bool* ok) {
398 // BreakStatement :: 398 // BreakStatement ::
399 // 'break' [no line terminator] Identifier? ';' 399 // 'break' [no line terminator] Identifier? ';'
400 400
401 Expect(i::Token::BREAK, CHECK_OK); 401 Expect(i::Token::BREAK, CHECK_OK);
402 i::Token::Value tok = peek(); 402 i::Token::Value tok = peek();
403 if (!scanner_->has_line_terminator_before_next() && 403 if (!scanner_->HasAnyLineTerminatorBeforeNext() &&
404 tok != i::Token::SEMICOLON && 404 tok != i::Token::SEMICOLON &&
405 tok != i::Token::RBRACE && 405 tok != i::Token::RBRACE &&
406 tok != i::Token::EOS) { 406 tok != i::Token::EOS) {
407 ParseIdentifier(CHECK_OK); 407 ParseIdentifier(CHECK_OK);
408 } 408 }
409 ExpectSemicolon(CHECK_OK); 409 ExpectSemicolon(CHECK_OK);
410 return Statement::Default(); 410 return Statement::Default();
411 } 411 }
412 412
413 413
414 PreParser::Statement PreParser::ParseReturnStatement(bool* ok) { 414 PreParser::Statement PreParser::ParseReturnStatement(bool* ok) {
415 // ReturnStatement :: 415 // ReturnStatement ::
416 // 'return' [no line terminator] Expression? ';' 416 // 'return' [no line terminator] Expression? ';'
417 417
418 // Consume the return token. It is necessary to do the before 418 // Consume the return token. It is necessary to do the before
419 // reporting any errors on it, because of the way errors are 419 // reporting any errors on it, because of the way errors are
420 // reported (underlining). 420 // reported (underlining).
421 Expect(i::Token::RETURN, CHECK_OK); 421 Expect(i::Token::RETURN, CHECK_OK);
422 422
423 // An ECMAScript program is considered syntactically incorrect if it 423 // An ECMAScript program is considered syntactically incorrect if it
424 // contains a return statement that is not within the body of a 424 // contains a return statement that is not within the body of a
425 // function. See ECMA-262, section 12.9, page 67. 425 // function. See ECMA-262, section 12.9, page 67.
426 // This is not handled during preparsing. 426 // This is not handled during preparsing.
427 427
428 i::Token::Value tok = peek(); 428 i::Token::Value tok = peek();
429 if (!scanner_->has_line_terminator_before_next() && 429 if (!scanner_->HasAnyLineTerminatorBeforeNext() &&
430 tok != i::Token::SEMICOLON && 430 tok != i::Token::SEMICOLON &&
431 tok != i::Token::RBRACE && 431 tok != i::Token::RBRACE &&
432 tok != i::Token::EOS) { 432 tok != i::Token::EOS) {
433 ParseExpression(true, CHECK_OK); 433 ParseExpression(true, CHECK_OK);
434 } 434 }
435 ExpectSemicolon(CHECK_OK); 435 ExpectSemicolon(CHECK_OK);
436 return Statement::Default(); 436 return Statement::Default();
437 } 437 }
438 438
439 439
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 ParseStatement(ok); 570 ParseStatement(ok);
571 return Statement::Default(); 571 return Statement::Default();
572 } 572 }
573 573
574 574
575 PreParser::Statement PreParser::ParseThrowStatement(bool* ok) { 575 PreParser::Statement PreParser::ParseThrowStatement(bool* ok) {
576 // ThrowStatement :: 576 // ThrowStatement ::
577 // 'throw' [no line terminator] Expression ';' 577 // 'throw' [no line terminator] Expression ';'
578 578
579 Expect(i::Token::THROW, CHECK_OK); 579 Expect(i::Token::THROW, CHECK_OK);
580 if (scanner_->has_line_terminator_before_next()) { 580 if (scanner_->HasAnyLineTerminatorBeforeNext()) {
581 i::JavaScriptScanner::Location pos = scanner_->location(); 581 i::JavaScriptScanner::Location pos = scanner_->location();
582 ReportMessageAt(pos.beg_pos, pos.end_pos, 582 ReportMessageAt(pos.beg_pos, pos.end_pos,
583 "newline_after_throw", NULL); 583 "newline_after_throw", NULL);
584 *ok = false; 584 *ok = false;
585 return Statement::Default(); 585 return Statement::Default();
586 } 586 }
587 ParseExpression(true, CHECK_OK); 587 ParseExpression(true, CHECK_OK);
588 ExpectSemicolon(ok); 588 ExpectSemicolon(ok);
589 return Statement::Default(); 589 return Statement::Default();
590 } 590 }
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
793 } 793 }
794 } 794 }
795 795
796 796
797 PreParser::Expression PreParser::ParsePostfixExpression(bool* ok) { 797 PreParser::Expression PreParser::ParsePostfixExpression(bool* ok) {
798 // PostfixExpression :: 798 // PostfixExpression ::
799 // LeftHandSideExpression ('++' | '--')? 799 // LeftHandSideExpression ('++' | '--')?
800 800
801 i::Scanner::Location before = scanner_->peek_location(); 801 i::Scanner::Location before = scanner_->peek_location();
802 Expression expression = ParseLeftHandSideExpression(CHECK_OK); 802 Expression expression = ParseLeftHandSideExpression(CHECK_OK);
803 if (!scanner_->has_line_terminator_before_next() && 803 if (!scanner_->HasAnyLineTerminatorBeforeNext() &&
804 i::Token::IsCountOp(peek())) { 804 i::Token::IsCountOp(peek())) {
805 if (strict_mode() && expression.IsIdentifier() && 805 if (strict_mode() && expression.IsIdentifier() &&
806 expression.AsIdentifier().IsEvalOrArguments()) { 806 expression.AsIdentifier().IsEvalOrArguments()) {
807 i::Scanner::Location after = scanner_->location(); 807 i::Scanner::Location after = scanner_->location();
808 ReportMessageAt(before.beg_pos, after.end_pos, 808 ReportMessageAt(before.beg_pos, after.end_pos,
809 "strict_lhs_postfix", NULL); 809 "strict_lhs_postfix", NULL);
810 *ok = false; 810 *ok = false;
811 return Expression::Default(); 811 return Expression::Default();
812 } 812 }
813 Next(); 813 Next();
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
1267 1267
1268 1268
1269 void PreParser::ExpectSemicolon(bool* ok) { 1269 void PreParser::ExpectSemicolon(bool* ok) {
1270 // Check for automatic semicolon insertion according to 1270 // Check for automatic semicolon insertion according to
1271 // the rules given in ECMA-262, section 7.9, page 21. 1271 // the rules given in ECMA-262, section 7.9, page 21.
1272 i::Token::Value tok = peek(); 1272 i::Token::Value tok = peek();
1273 if (tok == i::Token::SEMICOLON) { 1273 if (tok == i::Token::SEMICOLON) {
1274 Next(); 1274 Next();
1275 return; 1275 return;
1276 } 1276 }
1277 if (scanner_->has_line_terminator_before_next() || 1277 if (scanner_->HasAnyLineTerminatorBeforeNext() ||
1278 tok == i::Token::RBRACE || 1278 tok == i::Token::RBRACE ||
1279 tok == i::Token::EOS) { 1279 tok == i::Token::EOS) {
1280 return; 1280 return;
1281 } 1281 }
1282 Expect(i::Token::SEMICOLON, ok); 1282 Expect(i::Token::SEMICOLON, ok);
1283 } 1283 }
1284 1284
1285 1285
1286 void PreParser::LogSymbol() { 1286 void PreParser::LogSymbol() {
1287 int identifier_pos = scanner_->location().beg_pos; 1287 int identifier_pos = scanner_->location().beg_pos;
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
1420 } 1420 }
1421 return result; 1421 return result;
1422 } 1422 }
1423 1423
1424 bool PreParser::peek_any_identifier() { 1424 bool PreParser::peek_any_identifier() {
1425 i::Token::Value next = peek(); 1425 i::Token::Value next = peek();
1426 return next == i::Token::IDENTIFIER || 1426 return next == i::Token::IDENTIFIER ||
1427 next == i::Token::FUTURE_RESERVED_WORD; 1427 next == i::Token::FUTURE_RESERVED_WORD;
1428 } 1428 }
1429 } } // v8::preparser 1429 } } // v8::preparser
OLDNEW
« no previous file with comments | « src/parser.cc ('k') | src/preparser-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698