getify / literalizer

Specialized heuristic lexer for JS to identify complex literals
16 stars 2 forks source link

Various ES6 short-hand function syntax variations not yet handled #16

Closed getify closed 11 years ago

getify commented 11 years ago

ES6 adds a few function syntax variations which drop the "function" keyword and have short-hand grammar instead.

For example:

var a = { foo() { /* I'm a short-hand function in a object property */ } };

var a = foo => { /* I'm an arrow-function */ };

Namely, arrow functions don't require a { } pair for the function body, so that peculiarity needs to be handled.

getify commented 11 years ago

Also, possibly needing extra attention... ES6 array comprehensions and generator comprehensions:

var foo = [for (x of [1,2,3]) if (x % 2 == 1) x];
foo; // [1,3]

var foo = (for (x of [1,2,3]) if (x % 2 == 1) x);
foo.next().value + foo.next().value;  // 4