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

Side by Side Diff: src/preparser.h

Issue 348893007: Allow yield expressions without a RHS. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Update tests, fix function* () { yield* } Created 6 years, 5 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/ast.h ('k') | test/cctest/test-parsing.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 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_PREPARSER_H 5 #ifndef V8_PREPARSER_H
6 #define V8_PREPARSER_H 6 #define V8_PREPARSER_H
7 7
8 #include "src/v8.h" 8 #include "src/v8.h"
9 9
10 #include "src/func-name-inferrer.h" 10 #include "src/func-name-inferrer.h"
(...skipping 1774 matching lines...) Expand 10 before | Expand all | Expand 10 after
1785 fni_->Leave(); 1785 fni_->Leave();
1786 } 1786 }
1787 1787
1788 return factory()->NewAssignment(op, expression, right, pos); 1788 return factory()->NewAssignment(op, expression, right, pos);
1789 } 1789 }
1790 1790
1791 template <class Traits> 1791 template <class Traits>
1792 typename ParserBase<Traits>::ExpressionT 1792 typename ParserBase<Traits>::ExpressionT
1793 ParserBase<Traits>::ParseYieldExpression(bool* ok) { 1793 ParserBase<Traits>::ParseYieldExpression(bool* ok) {
1794 // YieldExpression :: 1794 // YieldExpression ::
1795 // 'yield' '*'? AssignmentExpression 1795 // 'yield' ([no line terminator] '*'? AssignmentExpression)?
1796 int pos = peek_position(); 1796 int pos = peek_position();
1797 Expect(Token::YIELD, CHECK_OK); 1797 Expect(Token::YIELD, CHECK_OK);
1798 Yield::Kind kind =
1799 Check(Token::MUL) ? Yield::DELEGATING : Yield::SUSPEND;
1800 ExpressionT generator_object = 1798 ExpressionT generator_object =
1801 factory()->NewVariableProxy(function_state_->generator_object_variable()); 1799 factory()->NewVariableProxy(function_state_->generator_object_variable());
1802 ExpressionT expression = 1800 ExpressionT expression = Traits::EmptyExpression();
1803 ParseAssignmentExpression(false, CHECK_OK); 1801 Yield::Kind kind = Yield::SUSPEND;
1802 if (!scanner()->HasAnyLineTerminatorBeforeNext()) {
1803 if (Check(Token::MUL)) kind = Yield::DELEGATING;
1804 switch (peek()) {
1805 case Token::EOS:
1806 case Token::SEMICOLON:
1807 case Token::RBRACE:
1808 case Token::RBRACK:
1809 case Token::RPAREN:
1810 case Token::COLON:
1811 case Token::COMMA:
1812 // The above set of tokens is the complete set of tokens that can appear
1813 // after an AssignmentExpression, and none of them can start an
1814 // AssignmentExpression. This allows us to avoid looking for an RHS for
1815 // a Yield::SUSPEND operation, given only one look-ahead token.
1816 if (kind == Yield::SUSPEND)
1817 break;
1818 ASSERT(kind == Yield::DELEGATING);
1819 // Delegating yields require an RHS; fall through.
1820 default:
1821 expression = ParseAssignmentExpression(false, CHECK_OK);
1822 break;
1823 }
1824 }
1804 typename Traits::Type::YieldExpression yield = 1825 typename Traits::Type::YieldExpression yield =
1805 factory()->NewYield(generator_object, expression, kind, pos); 1826 factory()->NewYield(generator_object, expression, kind, pos);
1806 if (kind == Yield::DELEGATING) { 1827 if (kind == Yield::DELEGATING) {
1807 yield->set_index(function_state_->NextHandlerIndex()); 1828 yield->set_index(function_state_->NextHandlerIndex());
1808 } 1829 }
1809 return yield; 1830 return yield;
1810 } 1831 }
1811 1832
1812 1833
1813 // Precedence = 3 1834 // Precedence = 3
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
2206 parser()->ReportMessage("accessor_get_set"); 2227 parser()->ReportMessage("accessor_get_set");
2207 } 2228 }
2208 *ok = false; 2229 *ok = false;
2209 } 2230 }
2210 } 2231 }
2211 2232
2212 2233
2213 } } // v8::internal 2234 } } // v8::internal
2214 2235
2215 #endif // V8_PREPARSER_H 2236 #endif // V8_PREPARSER_H
OLDNEW
« no previous file with comments | « src/ast.h ('k') | test/cctest/test-parsing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698