diff --git a/lib/coffee-script/lexer.js b/lib/coffee-script/lexer.js index 6ba9b72f..54a38311 100644 --- a/lib/coffee-script/lexer.js +++ b/lib/coffee-script/lexer.js @@ -803,7 +803,7 @@ })(); - JS_KEYWORDS = ['true', 'false', 'null', 'this', 'new', 'delete', 'typeof', 'in', 'instanceof', 'return', 'throw', 'break', 'continue', 'debugger', 'yield', 'if', 'else', 'switch', 'for', 'while', 'do', 'try', 'catch', 'finally', 'class', 'extends', 'super']; + JS_KEYWORDS = ['true', 'false', 'null', 'this', 'new', 'delete', 'typeof', 'in', 'instanceof', 'return', 'throw', 'break', 'continue', 'debugger', 'yield', 'yield*', 'if', 'else', 'switch', 'for', 'while', 'do', 'try', 'catch', 'finally', 'class', 'extends', 'super']; COFFEE_KEYWORDS = ['undefined', 'then', 'unless', 'until', 'loop', 'of', 'by', 'when']; @@ -880,7 +880,7 @@ COMPOUND_ASSIGN = ['-=', '+=', '/=', '*=', '%=', '||=', '&&=', '?=', '<<=', '>>=', '>>>=', '&=', '^=', '|=']; - UNARY = ['!', '~', 'NEW', 'TYPEOF', 'DELETE', 'DO', 'YIELD']; + UNARY = ['!', '~', 'NEW', 'TYPEOF', 'DELETE', 'DO', 'YIELD', 'YIELD*']; LOGIC = ['&&', '||', '&', '|', '^']; diff --git a/lib/coffee-script/nodes.js b/lib/coffee-script/nodes.js index 4742ed97..81252c38 100644 --- a/lib/coffee-script/nodes.js +++ b/lib/coffee-script/nodes.js @@ -2378,7 +2378,7 @@ return (new Parens(this)).compileToFragments(o); } plusMinus = op === '+' || op === '-'; - if ((op === 'new' || op === 'typeof' || op === 'delete' || op === 'yield') || plusMinus && this.first instanceof Op && this.first.operator === op) { + if ((op === 'new' || op === 'typeof' || op === 'delete' || op === 'yield' || op === 'yield*') || plusMinus && this.first instanceof Op && this.first.operator === op) { parts.push([this.makeCode(' ')]); } if ((plusMinus && this.first instanceof Op) || (op === 'new' && this.first.isStatement(o))) { diff --git a/src/lexer.coffee b/src/lexer.coffee index 68c4df1d..8fc6aed0 100644 --- a/src/lexer.coffee +++ b/src/lexer.coffee @@ -713,7 +713,7 @@ exports.Lexer = class Lexer JS_KEYWORDS = [ 'true', 'false', 'null', 'this' 'new', 'delete', 'typeof', 'in', 'instanceof' - 'return', 'throw', 'break', 'continue', 'debugger', 'yield' + 'return', 'throw', 'break', 'continue', 'debugger', 'yield', 'yield*' 'if', 'else', 'switch', 'for', 'while', 'do', 'try', 'catch', 'finally' 'class', 'extends', 'super' ] @@ -834,7 +834,7 @@ COMPOUND_ASSIGN = [ ] # Unary tokens. -UNARY = ['!', '~', 'NEW', 'TYPEOF', 'DELETE', 'DO', 'YIELD'] +UNARY = ['!', '~', 'NEW', 'TYPEOF', 'DELETE', 'DO', 'YIELD', 'YIELD*'] # Logical tokens. LOGIC = ['&&', '||', '&', '|', '^'] diff --git a/src/nodes.coffee b/src/nodes.coffee index c0f694e2..1a2f18ab 100644 --- a/src/nodes.coffee +++ b/src/nodes.coffee @@ -1700,8 +1700,8 @@ exports.Op = class Op extends Base if o.level >= LEVEL_ACCESS return (new Parens this).compileToFragments o plusMinus = op in ['+', '-'] - parts.push [@makeCode(' ')] if op in ['new', 'typeof', 'delete', 'yield'] or - plusMinus and @first instanceof Op and @first.operator is op + parts.push [@makeCode(' ')] if op in ['new', 'typeof', 'delete', 'yield' + 'yield*'] or plusMinus and @first instanceof Op and @first.operator is op if (plusMinus and @first instanceof Op) or (op is 'new' and @first.isStatement o) @first = new Parens @first parts.push @first.compileToFragments o, LEVEL_OP diff --git a/test/generators.coffee b/test/generators.coffee index 23320290..b9e95946 100644 --- a/test/generators.coffee +++ b/test/generators.coffee @@ -11,7 +11,8 @@ test "generator definition", -> yield 0 yield 1 yield 2 - y = x() + y = do ->* + yield* x() z = y.next() eq z.value, 0 eq z.done, false