#713: destructuring assignment is no longer statement and correctly returns RHS value

This commit is contained in:
satyr
2010-09-29 05:47:12 +09:00
parent b2313beaf4
commit 7450df8104
9 changed files with 206 additions and 301 deletions

View File

@@ -1,14 +1,8 @@
(function() {
var ASSIGNED, CALLABLE, CODE, COFFEE_ALIASES, COFFEE_KEYWORDS, COMMENT, COMPARE, COMPOUND_ASSIGN, CONVERSIONS, HEREDOC, HEREDOC_INDENT, IDENTIFIER, JSTOKEN, JS_FORBIDDEN, JS_KEYWORDS, LINE_BREAK, LOGIC, Lexer, MATH, MULTILINER, MULTI_DENT, NEXT_CHARACTER, NOT_REGEX, NO_NEWLINE, NUMBER, OPERATOR, REGEX_END, REGEX_ESCAPE, REGEX_INTERPOLATION, REGEX_START, RESERVED, Rewriter, SHIFT, SIMPLESTR, UNARY, WHITESPACE, _ref, compact, count, include, last, starts;
var __slice = Array.prototype.slice;
_ref = require('./rewriter');
Rewriter = _ref.Rewriter;
_ref = require('./helpers');
include = _ref.include;
count = _ref.count;
starts = _ref.starts;
compact = _ref.compact;
last = _ref.last;
Rewriter = require('./rewriter').Rewriter;
_ref = require('./helpers'), include = _ref.include, count = _ref.count, starts = _ref.starts, compact = _ref.compact, last = _ref.last;
exports.Lexer = (function() {
Lexer = function() {};
Lexer.prototype.tokenize = function(code, options) {
@@ -142,9 +136,7 @@
if (!(match = this.chunk.match(COMMENT))) {
return false;
}
_ref2 = match;
comment = _ref2[0];
here = _ref2[1];
_ref2 = match, comment = _ref2[0], here = _ref2[1];
this.line += count(comment, '\n');
this.i += comment.length;
if (here) {
@@ -293,9 +285,7 @@
Lexer.prototype.literalToken = function() {
var _ref2, match, prev, space, spaced, tag, val, value;
if (match = this.chunk.match(OPERATOR)) {
_ref2 = match;
value = _ref2[0];
space = _ref2[1];
_ref2 = match, value = _ref2[0], space = _ref2[1];
if (CODE.test(value)) {
this.tagParameters();
}
@@ -373,9 +363,7 @@
};
Lexer.prototype.sanitizeHeredoc = function(doc, options) {
var _ref2, attempt, herecomment, indent, match;
_ref2 = options;
indent = _ref2.indent;
herecomment = _ref2.herecomment;
_ref2 = options, indent = _ref2.indent, herecomment = _ref2.herecomment;
if (herecomment && !include(doc, '\n')) {
return doc;
}
@@ -446,9 +434,7 @@
_ref2 = delimited;
for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
pair = _ref2[_i];
_ref3 = pair;
open = _ref3[0];
close = _ref3[1];
_ref3 = pair, open = _ref3[0], close = _ref3[1];
if (levels.length && starts(str, close, i) && last(levels) === pair) {
levels.pop();
i += close.length - 1;
@@ -478,9 +464,7 @@
};
Lexer.prototype.interpolateString = function(str, options) {
var _len, _ref2, _ref3, end, escapeQuotes, escaped, expr, heredoc, i, idx, inner, interpolated, lexer, nested, pi, push, quote, s, tag, tok, token, tokens, value;
_ref2 = options || {};
heredoc = _ref2.heredoc;
escapeQuotes = _ref2.escapeQuotes;
_ref2 = options || {}, heredoc = _ref2.heredoc, escapeQuotes = _ref2.escapeQuotes;
quote = str.charAt(0);
if (quote !== '"' || str.length < 3) {
return this.token('STRING', str);
@@ -533,14 +517,11 @@
if (interpolated) {
this.token('(', '(');
}
_ref2 = tokens;
push = _ref2.push;
push = tokens.push;
_ref2 = tokens;
for (i = 0, _len = _ref2.length; i < _len; i++) {
token = _ref2[i];
_ref3 = token;
tag = _ref3[0];
value = _ref3[1];
_ref3 = token, tag = _ref3[0], value = _ref3[1];
if (tag === 'TOKENS') {
push.apply(this.tokens, value);
} else if (tag === 'STRING' && escapeQuotes) {