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

Issue 12646003: Add parser support for generators. (Closed)

Created:
7 years, 9 months ago by wingo
Modified:
7 years, 8 months ago
Base URL:
git://github.com/v8/v8.git@bleeding_edge
Visibility:
Public.

Description

Add parser support for generators. This patchset begins by adding support for "yield", which is unlike other tokens in JS. In a generator, whether strict or classic, it is a syntactic keyword. In classic mode it is an identifier. In strict mode it is reserved. This patch adds YIELD as a token to the scanner, and adapts the preparser and parser appropriately. It also parses "function*", indicating that a function is actually a generator, for both eagerly and lazily parsed functions. Currently "yield" just compiles as "return". BUG=v8:2355 TEST=mjsunit/harmony/generators-parsing Committed: http://code.google.com/p/v8/source/detail?r=14116

Patch Set 1 #

Total comments: 1

Patch Set 2 : #

Patch Set 3 : Fix missed case in PreParser::peek_any_identifier. #

Patch Set 4 : Finish parser, build AST, add tests #

Total comments: 13

Patch Set 5 : is_generator() in Parser::FunctionState; more tests; other fixes #

Total comments: 4

Patch Set 6 : Preparser respects --harmony-generators #

Patch Set 7 : Fix bad initialization list in last preparser commit #

Total comments: 2
Unified diffs Side-by-side diffs Delta from patch set Stats (+374 lines, -40 lines) Patch
M src/ast.h View 1 2 3 9 chunks +49 lines, -4 lines 0 comments Download
M src/ast.cc View 1 2 3 1 chunk +1 line, -0 lines 0 comments Download
M src/compiler.cc View 1 2 3 1 chunk +1 line, -0 lines 0 comments Download
M src/flag-definitions.h View 1 2 3 2 chunks +2 lines, -0 lines 0 comments Download
M src/full-codegen.cc View 1 2 3 4 2 chunks +28 lines, -0 lines 0 comments Download
M src/hydrogen.cc View 1 2 3 4 2 chunks +10 lines, -0 lines 0 comments Download
M src/objects.h View 1 2 3 2 chunks +4 lines, -0 lines 0 comments Download
M src/objects-inl.h View 1 2 3 1 chunk +1 line, -0 lines 0 comments Download
M src/parser.h View 1 2 3 4 6 chunks +10 lines, -0 lines 0 comments Download
M src/parser.cc View 1 2 3 4 5 24 chunks +77 lines, -17 lines 0 comments Download
M src/preparser.h View 1 2 3 4 5 6 13 chunks +25 lines, -8 lines 0 comments Download
M src/preparser.cc View 1 2 3 4 5 15 chunks +51 lines, -9 lines 0 comments Download
M src/prettyprinter.cc View 1 2 3 2 chunks +11 lines, -0 lines 0 comments Download
M src/scanner.h View 1 2 3 4 5 1 chunk +2 lines, -1 line 0 comments Download
M src/scanner.cc View 1 chunk +1 line, -1 line 0 comments Download
M src/token.h View 1 2 3 1 chunk +1 line, -0 lines 0 comments Download
A test/mjsunit/harmony/generators-parsing.js View 1 2 3 4 1 chunk +100 lines, -0 lines 2 comments Download

Messages

Total messages: 13 (0 generated)
wingo
7 years, 9 months ago (2013-03-11 11:56:12 UTC) #1
wingo
https://codereview.chromium.org/12646003/diff/1/src/preparser.cc File src/preparser.cc (right): https://codereview.chromium.org/12646003/diff/1/src/preparser.cc#newcode1123 src/preparser.cc:1123: case i::Token::YIELD: This FIXME is to mark that this ...
7 years, 9 months ago (2013-03-11 12:10:53 UTC) #2
Michael Starzinger
This CL definitely requires parsing tests. I would put them into a separate mjsunit/harmony/generator-parsing.js file. ...
7 years, 9 months ago (2013-03-11 15:42:10 UTC) #3
wingo
Thanks for the notes. I was trying to show that parsing yield in this way ...
7 years, 9 months ago (2013-03-12 09:43:37 UTC) #4
Michael Starzinger
This is already looking pretty good. First round of comments. I didn't look at the ...
7 years, 9 months ago (2013-03-14 22:29:24 UTC) #5
Michael Starzinger
The more I think about it ... https://codereview.chromium.org/12646003/diff/13001/src/parser.cc File src/parser.cc (right): https://codereview.chromium.org/12646003/diff/13001/src/parser.cc#newcode4368 src/parser.cc:4368: scope->set_inside_generator(is_generator); Actually, ...
7 years, 9 months ago (2013-03-14 22:48:23 UTC) #6
wingo
Thanks for the review. I believe I addressed all of your comments in the new ...
7 years, 9 months ago (2013-03-15 10:03:33 UTC) #7
wingo
On 2013/03/15 10:03:33, wingo wrote: > Thanks for the review. I believe I addressed all ...
7 years, 9 months ago (2013-03-28 15:28:59 UTC) #8
Michael Starzinger
LGTM with two final comments. I will land this for you as soon as those ...
7 years, 8 months ago (2013-04-02 11:08:54 UTC) #9
wingo
https://codereview.chromium.org/12646003/diff/25001/src/preparser.cc File src/preparser.cc (right): https://codereview.chromium.org/12646003/diff/25001/src/preparser.cc#newcode304 src/preparser.cc:304: bool is_generator = Check(i::Token::MUL); On 2013/04/02 11:08:55, Michael Starzinger ...
7 years, 8 months ago (2013-04-02 15:56:01 UTC) #10
Michael Starzinger
Committed patchset #7 manually as r14116 (presubmit successful).
7 years, 8 months ago (2013-04-02 17:35:26 UTC) #11
arv (Not doing code reviews)
Drive by... https://codereview.chromium.org/12646003/diff/45003/test/mjsunit/harmony/generators-parsing.js File test/mjsunit/harmony/generators-parsing.js (right): https://codereview.chromium.org/12646003/diff/45003/test/mjsunit/harmony/generators-parsing.js#newcode77 test/mjsunit/harmony/generators-parsing.js:77: assertThrows("function f*() { yield: 1 }", SyntaxError) ...
7 years, 8 months ago (2013-04-04 20:56:11 UTC) #12
Michael Starzinger
7 years, 8 months ago (2013-04-05 08:36:04 UTC) #13
Message was sent while issue was closed.
https://codereview.chromium.org/12646003/diff/45003/test/mjsunit/harmony/gene...
File test/mjsunit/harmony/generators-parsing.js (right):

https://codereview.chromium.org/12646003/diff/45003/test/mjsunit/harmony/gene...
test/mjsunit/harmony/generators-parsing.js:77: assertThrows("function f*() {
yield: 1 }", SyntaxError)
On 2013/04/04 20:56:11, arv wrote:
> This should be function* f()

See https://codereview.chromium.org/13575010/ for the fix.

Powered by Google App Engine
This is Rietveld 408576698