updated lexer to allow 'yield*'

This commit is contained in:
Andreas Lubbe
2013-12-26 01:16:02 -08:00
parent 25b1eee293
commit 64e78a2bec
2 changed files with 9 additions and 1 deletions

View File

@@ -427,7 +427,7 @@
};
Lexer.prototype.literalToken = function() {
var match, prev, tag, value, _ref2, _ref3, _ref4, _ref5;
var match, poppedToken, prev, tag, value, _ref2, _ref3, _ref4, _ref5;
if (match = OPERATOR.exec(this.chunk)) {
value = match[0];
if (CODE.test(value)) {
@@ -451,6 +451,10 @@
if (value === ';') {
this.seenFor = false;
tag = 'TERMINATOR';
} else if (value === '*' && prev[1] === 'yield' && !prev.spaced) {
poppedToken = this.tokens.pop();
tag = 'UNARY';
value = 'yield*';
} else if (__indexOf.call(MATH, value) >= 0) {
tag = 'MATH';
} else if (__indexOf.call(COMPARE, value) >= 0) {

View File

@@ -404,6 +404,10 @@ exports.Lexer = class Lexer
if value is ';'
@seenFor = no
tag = 'TERMINATOR'
else if value is '*' and prev[1] is 'yield' and not prev.spaced
poppedToken = @tokens.pop()
tag = 'UNARY'
value = 'yield*'
else if value in MATH then tag = 'MATH'
else if value in COMPARE then tag = 'COMPARE'
else if value in COMPOUND_ASSIGN then tag = 'COMPOUND_ASSIGN'