mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-05-03 03:00:14 -04:00
first attempt at including 'yield*'
This commit is contained in:
@@ -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 = ['&&', '||', '&', '|', '^'];
|
||||
|
||||
|
||||
@@ -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))) {
|
||||
|
||||
@@ -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 = ['&&', '||', '&', '|', '^']
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user