On 2014/06/18 14:04:56, arv wrote:
On 2014/06/18 07:21:52, marja wrote:
> Though, it was sort of expected that this is complicated, since we
don't yet
> know whether we're in an arrow function or not when we see (foo,
bar, ... :/
Unfortunately, you ain't seen nothing yet! ♫♪♫♪
Once we add support for destructuring (especially the
CoverInitializedName)
and
rest params, we have to parse the paren expression as a
CoverParenthesizedExpressionAndArrowParameterList, and then go back and
reparse
and/or validate that.
For example:
var value = (a = 1, {x, y: z, w: {v}, [a, b, ...c], q);
var arrow = (a = 1, {x, y: z, w: {v}, [a, b, ...c], q) => { ... };
To support rest and CoverInitializedName we also need to support
var arrow = ({x = 1}, ...xs) => { ... };
var error = ({x = 1}, ...xs); // SyntaxError: Unexpected token =
Anyway, I don't want to derail too much. I'm very excited that you are
working
on basic arrow function support even though I think the whole parsing
part of
it
will need to be reimplemented when we add support rest and destructuring.
We discussed this when Adrian started on this, and concluded that we should
do
it incrementally. Most of the basic machinery should stay the same. In
fact, if
done right, I would expect destructuring to be an extension of what the
current
CL does.
We also concluded that reparsing is not an option, due to various
constraints in
V8. We have to use validation, as the current CL already does. The tricky
part,
though, is what to do in the preparser, which does not generate an AST to
validate. As I see it, we will have to parse the cover grammar, and for each
production synthesize success flags for both expression and parameter list
(i.e., parse both possibilities simultaneously). I think that is what the
current CL also has to do, although it should be easier here (so far,
parameter
lists are strictly a subgrammar of expressions).
https://codereview.chromium.org/160073006/
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.