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

Side by Side Diff: src/preparser.cc

Issue 220473014: Make stray 'return' an early error (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 8 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/preparser.h ('k') | src/runtime.cc » ('j') | src/runtime.cc » ('J')
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 564 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 } 575 }
576 ExpectSemicolon(CHECK_OK); 576 ExpectSemicolon(CHECK_OK);
577 return Statement::Default(); 577 return Statement::Default();
578 } 578 }
579 579
580 580
581 PreParser::Statement PreParser::ParseReturnStatement(bool* ok) { 581 PreParser::Statement PreParser::ParseReturnStatement(bool* ok) {
582 // ReturnStatement :: 582 // ReturnStatement ::
583 // 'return' [no line terminator] Expression? ';' 583 // 'return' [no line terminator] Expression? ';'
584 584
585 // Consume the return token. It is necessary to do the before 585 // Consume the return token. It is necessary to do before
586 // reporting any errors on it, because of the way errors are 586 // reporting any errors on it, because of the way errors are
587 // reported (underlining). 587 // reported (underlining).
588 Expect(Token::RETURN, CHECK_OK); 588 Expect(Token::RETURN, CHECK_OK);
589 589
590 // An ECMAScript program is considered syntactically incorrect if it 590 // An ECMAScript program is considered syntactically incorrect if it
591 // contains a return statement that is not within the body of a 591 // contains a return statement that is not within the body of a
592 // function. See ECMA-262, section 12.9, page 67. 592 // function. See ECMA-262, section 12.9, page 67.
593 // This is not handled during preparsing. 593 // This is not handled during preparsing.
594 594
595 Token::Value tok = peek(); 595 Token::Value tok = peek();
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
967 967
968 968
969 void PreParser::LogSymbol() { 969 void PreParser::LogSymbol() {
970 if (log_->ShouldLogSymbols()) { 970 if (log_->ShouldLogSymbols()) {
971 scanner()->LogSymbol(log_, position()); 971 scanner()->LogSymbol(log_, position());
972 } 972 }
973 } 973 }
974 974
975 975
976 } } // v8::internal 976 } } // v8::internal
OLDNEW
« no previous file with comments | « src/preparser.h ('k') | src/runtime.cc » ('j') | src/runtime.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698