Implementing sethaurus' suggestion for better temp variable names -- getting rid of the numbers.

This commit is contained in:
Jeremy Ashkenas 2010-02-16 18:00:40 -05:00
parent e4bb6c91e7
commit db6bc0ba02
8 changed files with 256 additions and 256 deletions

View File

@ -50,14 +50,14 @@
};
// Pretty-print a token stream.
exports.print_tokens = function print_tokens(tokens) {
var _1, _2, _3, strings, token;
var _a, _b, _c, strings, token;
strings = (function() {
_1 = []; _2 = tokens;
for (_3 = 0; _3 < _2.length; _3++) {
token = _2[_3];
_1.push('[' + token[0] + ' ' + token[1].toString().replace(/\n/, '\\n') + ']');
_a = []; _b = tokens;
for (_c = 0; _c < _b.length; _c++) {
token = _b[_c];
_a.push('[' + token[0] + ' ' + token[1].toString().replace(/\n/, '\\n') + ']');
}
return _1;
return _a;
}).call(this);
return puts(strings.join(' '));
};

View File

@ -1,5 +1,5 @@
(function(){
var Parser, _1, _2, _3, _4, _5, _6, bnf, grammar, name, non_terminal, o, operators, option, part, tokens, unwrap;
var Parser, _a, _b, _c, _d, _e, _f, bnf, grammar, name, non_terminal, o, operators, option, part, tokens, unwrap;
var __hasProp = Object.prototype.hasOwnProperty;
Parser = require('jison').Parser;
// DSL ===================================================================
@ -523,24 +523,24 @@
// Make the Jison parser.
bnf = {};
tokens = [];
_1 = grammar;
for (name in _1) if (__hasProp.call(_1, name)) {
non_terminal = _1[name];
_a = grammar;
for (name in _a) if (__hasProp.call(_a, name)) {
non_terminal = _a[name];
bnf[name] = (function() {
_2 = []; _3 = non_terminal;
for (_4 = 0; _4 < _3.length; _4++) {
option = _3[_4];
_2.push((function() {
_5 = option[0].split(" ");
for (_6 = 0; _6 < _5.length; _6++) {
part = _5[_6];
_b = []; _c = non_terminal;
for (_d = 0; _d < _c.length; _d++) {
option = _c[_d];
_b.push((function() {
_e = option[0].split(" ");
for (_f = 0; _f < _e.length; _f++) {
part = _e[_f];
!grammar[part] ? tokens.push(part) : null;
}
name === "Root" ? (option[1] = "return " + option[1]) : null;
return option;
}).call(this));
}
return _2;
return _b;
}).call(this);
}
tokens = tokens.join(" ");

View File

@ -30,16 +30,16 @@
};
// Quickie inheritance convenience wrapper to reduce typing.
inherit = function inherit(parent, props) {
var _1, _2, klass, name, prop;
var _a, _b, klass, name, prop;
klass = del(props, 'constructor');
_1 = function(){};
_1.prototype = parent.prototype;
_a = function(){};
_a.prototype = parent.prototype;
klass.__superClass__ = parent.prototype;
klass.prototype = new _1();
klass.prototype = new _a();
klass.prototype.constructor = klass;
_2 = props;
for (name in _2) if (__hasProp.call(_2, name)) {
prop = _2[name];
_b = props;
for (name in _b) if (__hasProp.call(_b, name)) {
prop = _b[name];
((klass.prototype[name] = prop));
}
return klass;
@ -86,20 +86,20 @@
};
// Quick short method for the current indentation level, plus tabbing in.
Node.prototype.idt = function idt(tabs) {
var _1, _2, _3, _4, i, idt;
var _a, _b, _c, _d, i, idt;
idt = (this.indent || '');
_3 = 0; _4 = (tabs || 0);
for (_2=0, i=_3; (_3 <= _4 ? i < _4 : i > _4); (_3 <= _4 ? i += 1 : i -= 1), _2++) {
_c = 0; _d = (tabs || 0);
for (_b=0, i=_c; (_c <= _d ? i < _d : i > _d); (_c <= _d ? i += 1 : i -= 1), _b++) {
idt += TAB;
}
return idt;
};
// Does this node, or any of its children, contain a node of a certain kind?
Node.prototype.contains = function contains(block) {
var _1, _2, node;
_1 = this.children;
for (_2 = 0; _2 < _1.length; _2++) {
node = _1[_2];
var _a, _b, node;
_a = this.children;
for (_b = 0; _b < _a.length; _b++) {
node = _a[_b];
if (block(node)) {
return true;
}
@ -168,14 +168,14 @@
},
// Compile each expression in the Expressions body.
compile_node: function compile_node(o) {
var _1, _2, _3, node;
var _a, _b, _c, node;
return ((function() {
_1 = []; _2 = this.expressions;
for (_3 = 0; _3 < _2.length; _3++) {
node = _2[_3];
_1.push(this.compile_expression(node, _.clone(o)));
_a = []; _b = this.expressions;
for (_c = 0; _c < _b.length; _c++) {
node = _b[_c];
_a.push(this.compile_expression(node, _.clone(o)));
}
return _1;
return _a;
}).call(this)).join("\n");
},
// If this is the top-level Expressions, wrap everything in a safety closure.
@ -315,7 +315,7 @@
return this.base.is_statement && this.base.is_statement() && !this.has_properties();
},
compile_node: function compile_node(o) {
var _1, _2, baseline, code, only, part, parts, prop, props, soaked, temp;
var _a, _b, baseline, code, only, part, parts, prop, props, soaked, temp;
soaked = false;
only = del(o, 'only_first');
props = only ? this.properties.slice(0, this.properties.length - 1) : this.properties;
@ -324,9 +324,9 @@
baseline = '(' + baseline + ')';
}
parts = [baseline];
_1 = props;
for (_2 = 0; _2 < _1.length; _2++) {
prop = _1[_2];
_a = props;
for (_b = 0; _b < _a.length; _b++) {
prop = _a[_b];
if (prop instanceof AccessorNode && prop.soak) {
soaked = true;
if (this.base instanceof CallNode && prop === props[0]) {
@ -383,19 +383,19 @@
},
// Compile a vanilla function call.
compile_node: function compile_node(o) {
var _1, _2, _3, arg, args;
var _a, _b, _c, arg, args;
if (_.any(this.args, function(a) {
return a instanceof SplatNode;
})) {
return this.compile_splat(o);
}
args = ((function() {
_1 = []; _2 = this.args;
for (_3 = 0; _3 < _2.length; _3++) {
arg = _2[_3];
_1.push(arg.compile(o));
_a = []; _b = this.args;
for (_c = 0; _c < _b.length; _c++) {
arg = _b[_c];
_a.push(arg.compile(o));
}
return _1;
return _a;
}).call(this)).join(', ');
if (this.variable === 'super') {
return this.compile_super(args, o);
@ -412,20 +412,20 @@
},
// Compile a function call being passed variable arguments.
compile_splat: function compile_splat(o) {
var _1, _2, arg, args, code, i, meth, obj;
var _a, _b, arg, args, code, i, meth, obj;
meth = this.variable.compile(o);
obj = this.variable.source || 'this';
args = (function() {
_1 = []; _2 = this.args;
for (i = 0; i < _2.length; i++) {
arg = _2[i];
_1.push((function() {
_a = []; _b = this.args;
for (i = 0; i < _b.length; i++) {
arg = _b[i];
_a.push((function() {
code = arg.compile(o);
code = arg instanceof SplatNode ? code : '[' + code + ']';
return i === 0 ? code : '.concat(' + code + ')';
}).call(this));
}
return _1;
return _a;
}).call(this);
return this.prefix + meth + '.apply(' + obj + ', ' + args.join('') + ')';
},
@ -564,24 +564,24 @@
// AssignNodes get interleaved correctly, with no trailing commas or
// commas affixed to comments. TODO: Extract this and add it to ArrayNode.
compile_node: function compile_node(o) {
var _1, _2, _3, _4, _5, i, indent, inner, join, last_noncom, non_comments, prop, props;
var _a, _b, _c, _d, _e, i, indent, inner, join, last_noncom, non_comments, prop, props;
o.indent = this.idt(1);
non_comments = (function() {
_1 = []; _2 = this.properties;
for (_3 = 0; _3 < _2.length; _3++) {
prop = _2[_3];
_a = []; _b = this.properties;
for (_c = 0; _c < _b.length; _c++) {
prop = _b[_c];
if (!(prop instanceof CommentNode)) {
_1.push(prop);
_a.push(prop);
}
}
return _1;
return _a;
}).call(this);
last_noncom = non_comments[non_comments.length - 1];
props = (function() {
_4 = []; _5 = this.properties;
for (i = 0; i < _5.length; i++) {
prop = _5[i];
_4.push((function() {
_d = []; _e = this.properties;
for (i = 0; i < _e.length; i++) {
prop = _e[i];
_d.push((function() {
join = ",\n";
if ((prop === last_noncom) || (prop instanceof CommentNode)) {
join = "\n";
@ -593,7 +593,7 @@
return indent + prop.compile(o) + join;
}).call(this));
}
return _4;
return _d;
}).call(this);
props = props.join('');
inner = props ? '\n' + props + '\n' + this.idt() : '';
@ -608,13 +608,13 @@
return this;
},
compile_node: function compile_node(o) {
var _1, _2, code, ending, i, obj, objects;
var _a, _b, code, ending, i, obj, objects;
o.indent = this.idt(1);
objects = (function() {
_1 = []; _2 = this.objects;
for (i = 0; i < _2.length; i++) {
obj = _2[i];
_1.push((function() {
_a = []; _b = this.objects;
for (i = 0; i < _b.length; i++) {
obj = _b[i];
_a.push((function() {
code = obj.compile(o);
if (obj instanceof CommentNode) {
return '\n' + code + '\n' + o.indent;
@ -625,7 +625,7 @@
}
}).call(this));
}
return _1;
return _a;
}).call(this);
objects = objects.join('');
ending = objects.indexOf('\n') >= 0 ? "\n" + this.idt() + ']' : ']';
@ -718,19 +718,19 @@
// object literals to a value. Peeks at their properties to assign inner names.
// See: http://wiki.ecmascript.org/doku.php?id=harmony:destructuring
compile_pattern_match: function compile_pattern_match(o) {
var _1, _2, access_class, assigns, i, idx, obj, val, val_var;
var _a, _b, access_class, assigns, i, idx, obj, val, val_var;
val_var = o.scope.free_variable();
assigns = [this.idt() + val_var + ' = ' + this.value.compile(o) + ';'];
o.top = true;
o.as_statement = true;
_1 = this.variable.base.objects;
for (i = 0; i < _1.length; i++) {
obj = _1[i];
_a = this.variable.base.objects;
for (i = 0; i < _a.length; i++) {
obj = _a[i];
idx = i;
if (this.variable.is_object()) {
_2 = [obj.value, obj.variable.base];
obj = _2[0];
idx = _2[1];
_b = [obj.value, obj.variable.base];
obj = _b[0];
idx = _b[1];
}
access_class = this.variable.is_array() ? IndexNode : AccessorNode;
if (obj instanceof SplatNode) {
@ -769,7 +769,7 @@
return this;
},
compile_node: function compile_node(o) {
var _1, _2, _3, _4, _5, code, func, inner, name_part, param, params, shared_scope, splat, top;
var _a, _b, _c, _d, _e, code, func, inner, name_part, param, params, shared_scope, splat, top;
shared_scope = del(o, 'shared_scope');
top = del(o, 'top');
o.scope = shared_scope || new Scope(o.scope, this.body, this);
@ -784,16 +784,16 @@
this.body.unshift(splat);
}
params = ((function() {
_1 = []; _2 = this.params;
for (_3 = 0; _3 < _2.length; _3++) {
param = _2[_3];
_1.push(param.compile(o));
_a = []; _b = this.params;
for (_c = 0; _c < _b.length; _c++) {
param = _b[_c];
_a.push(param.compile(o));
}
return _1;
return _a;
}).call(this));
_4 = params;
for (_5 = 0; _5 < _4.length; _5++) {
param = _4[_5];
_d = params;
for (_e = 0; _e < _d.length; _e++) {
param = _d[_e];
(o.scope.parameter(param));
}
code = this.body.expressions.length ? '\n' + this.body.compile_with_declarations(o) + '\n' : '';
@ -923,20 +923,20 @@
// Mimic Python's chained comparisons. See:
// http://docs.python.org/reference/expressions.html#notin
compile_chain: function compile_chain(o) {
var _1, shared;
var _a, shared;
shared = this.first.unwrap().second;
if (shared instanceof CallNode) {
_1 = shared.compile_reference(o);
this.first.second = _1[0];
shared = _1[1];
_a = shared.compile_reference(o);
this.first.second = _a[0];
shared = _a[1];
}
return '(' + this.first.compile(o) + ') && (' + shared.compile(o) + ' ' + this.operator + ' ' + this.second.compile(o) + ')';
},
compile_assignment: function compile_assignment(o) {
var _1, first, second;
_1 = [this.first.compile(o), this.second.compile(o)];
first = _1[0];
second = _1[1];
var _a, first, second;
_a = [this.first.compile(o), this.second.compile(o)];
first = _a[0];
second = _a[1];
if (first.match(IDENTIFIER)) {
o.scope.find(first);
}
@ -946,10 +946,10 @@
return first + ' = ' + first + ' ' + this.operator.substr(0, 2) + ' ' + second;
},
compile_existence: function compile_existence(o) {
var _1, first, second;
_1 = [this.first.compile(o), this.second.compile(o)];
first = _1[0];
second = _1[1];
var _a, first, second;
_a = [this.first.compile(o), this.second.compile(o)];
first = _a[0];
second = _a[1];
return ExistenceNode.compile_test(o, this.first) + ' ? ' + first + ' : ' + second;
},
compile_unary: function compile_unary(o) {
@ -1007,14 +1007,14 @@
}
}));
ExistenceNode.compile_test = function compile_test(o, variable) {
var _1, _2, first, second;
_1 = [variable, variable];
first = _1[0];
second = _1[1];
var _a, _b, first, second;
_a = [variable, variable];
first = _a[0];
second = _a[1];
if (variable instanceof CallNode) {
_2 = variable.compile_reference(o);
first = _2[0];
second = _2[1];
_b = variable.compile_reference(o);
first = _b[0];
second = _b[1];
}
return '(typeof ' + first.compile(o) + ' !== "undefined" && ' + second.compile(o) + ' !== null)';
};
@ -1042,7 +1042,7 @@
ForNode = (exports.ForNode = inherit(Node, {
type: 'For',
constructor: function constructor(body, source, name, index) {
var _1;
var _a;
this.body = body;
this.name = name;
this.index = index || null;
@ -1051,9 +1051,9 @@
this.step = source.step;
this.object = !!source.object;
if (this.object) {
_1 = [this.index, this.name];
this.name = _1[0];
this.index = _1[1];
_a = [this.index, this.name];
this.name = _a[0];
this.index = _a[1];
}
this.children = _.compact([this.body, this.source, this.filter]);
return this;
@ -1164,15 +1164,15 @@
},
// Rewrite a chain of IfNodes with their switch condition for equality.
rewrite_condition: function rewrite_condition(expression) {
var _1, _2, _3, cond;
var _a, _b, _c, cond;
this.condition = (function() {
if (this.multiple) {
_1 = []; _2 = this.condition;
for (_3 = 0; _3 < _2.length; _3++) {
cond = _2[_3];
_1.push(new OpNode('is', expression, cond));
_a = []; _b = this.condition;
for (_c = 0; _c < _b.length; _c++) {
cond = _b[_c];
_a.push(new OpNode('is', expression, cond));
}
return _1;
return _a;
} else {
return new OpNode('is', expression, this.condition);
}
@ -1198,14 +1198,14 @@
return this.statement = this.statement || !!(this.comment || this.tags.statement || this.body.is_statement() || (this.else_body && this.else_body.is_statement()));
},
compile_condition: function compile_condition(o) {
var _1, _2, _3, cond;
var _a, _b, _c, cond;
return ((function() {
_1 = []; _2 = _.flatten([this.condition]);
for (_3 = 0; _3 < _2.length; _3++) {
cond = _2[_3];
_1.push(cond.compile(o));
_a = []; _b = _.flatten([this.condition]);
for (_c = 0; _c < _b.length; _c++) {
cond = _b[_c];
_a.push(cond.compile(o));
}
return _1;
return _a;
}).call(this)).join(' || ');
},
compile_node: function compile_node(o) {

View File

@ -14,14 +14,14 @@
};
// Parse the argument array, calling defined callbacks, returning the remaining non-option arguments.
op.prototype.parse = function parse(args) {
var _1, _2, arg, callback, is_option, results, rule, value;
var _a, _b, arg, callback, is_option, results, rule, value;
results = [];
args = args.concat([]);
while (((arg = args.shift()))) {
is_option = false;
_1 = this.rules;
for (_2 = 0; _2 < _1.length; _2++) {
rule = _1[_2];
_a = this.rules;
for (_b = 0; _b < _a.length; _b++) {
rule = _a[_b];
if (rule.letter === arg || rule.flag === arg) {
callback = this.actions[rule.name];
value = rule.argument && args.shift();
@ -40,13 +40,13 @@
};
// Return the help text for this OptionParser, for --help and such.
op.prototype.help = function help() {
var _1, _2, _3, _4, has_shorts, lines, longest, rule, text;
var _a, _b, _c, _d, has_shorts, lines, longest, rule, text;
longest = 0;
has_shorts = false;
lines = [this.banner, '', this.options_title];
_1 = this.rules;
for (_2 = 0; _2 < _1.length; _2++) {
rule = _1[_2];
_a = this.rules;
for (_b = 0; _b < _a.length; _b++) {
rule = _a[_b];
if (rule.letter) {
has_shorts = true;
}
@ -54,9 +54,9 @@
longest = rule.flag.length;
}
}
_3 = this.rules;
for (_4 = 0; _4 < _3.length; _4++) {
rule = _3[_4];
_c = this.rules;
for (_d = 0; _d < _c.length; _d++) {
rule = _c[_d];
has_shorts ? (text = rule.letter ? spaces(2) + rule.letter + ', ' : spaces(6)) : null;
text += spaces(longest, rule.flag) + spaces(3);
text += rule.description;
@ -72,18 +72,18 @@
// Build rules from a list of valid switch tuples in the form:
// [letter-flag, long-flag, help], or [long-flag, help].
build_rules = function build_rules(rules) {
var _1, _2, _3, tuple;
_1 = []; _2 = rules;
for (_3 = 0; _3 < _2.length; _3++) {
tuple = _2[_3];
_1.push((function() {
var _a, _b, _c, tuple;
_a = []; _b = rules;
for (_c = 0; _c < _b.length; _c++) {
tuple = _b[_c];
_a.push((function() {
if (tuple.length < 3) {
tuple.unshift(null);
}
return build_rule.apply(this, tuple);
}).call(this));
}
return _1;
return _a;
};
// Build a rule from a short-letter-flag, long-form-flag, and help text.
build_rule = function build_rule(letter, flag, description) {

View File

@ -1,5 +1,5 @@
(function(){
var BALANCED_PAIRS, EXPRESSION_CLOSE, EXPRESSION_START, EXPRESSION_TAIL, IMPLICIT_BLOCK, IMPLICIT_CALL, IMPLICIT_END, IMPLICIT_FUNC, INVERSES, SINGLE_CLOSERS, SINGLE_LINERS, _1, _2, _3, _4, _5, _6, _7, _8, pair, re;
var BALANCED_PAIRS, EXPRESSION_CLOSE, EXPRESSION_START, EXPRESSION_TAIL, IMPLICIT_BLOCK, IMPLICIT_CALL, IMPLICIT_END, IMPLICIT_FUNC, INVERSES, SINGLE_CLOSERS, SINGLE_LINERS, _a, _b, _c, _d, _e, _f, _g, _h, pair, re;
var __hasProp = Object.prototype.hasOwnProperty;
if (!((typeof process !== "undefined" && process !== null))) {
this.exports = this;
@ -12,21 +12,21 @@
BALANCED_PAIRS = [['(', ')'], ['[', ']'], ['{', '}'], ['INDENT', 'OUTDENT'], ['PARAM_START', 'PARAM_END'], ['CALL_START', 'CALL_END'], ['INDEX_START', 'INDEX_END']];
// Tokens that signal the start of a balanced pair.
EXPRESSION_START = (function() {
_1 = []; _2 = BALANCED_PAIRS;
for (_3 = 0; _3 < _2.length; _3++) {
pair = _2[_3];
_1.push(pair[0]);
_a = []; _b = BALANCED_PAIRS;
for (_c = 0; _c < _b.length; _c++) {
pair = _b[_c];
_a.push(pair[0]);
}
return _1;
return _a;
}).call(this);
// Tokens that signal the end of a balanced pair.
EXPRESSION_TAIL = (function() {
_4 = []; _5 = BALANCED_PAIRS;
for (_6 = 0; _6 < _5.length; _6++) {
pair = _5[_6];
_4.push(pair[1]);
_d = []; _e = BALANCED_PAIRS;
for (_f = 0; _f < _e.length; _f++) {
pair = _e[_f];
_d.push(pair[1]);
}
return _4;
return _d;
}).call(this);
// Tokens that indicate the close of a clause of an expression.
EXPRESSION_CLOSE = ['CATCH', 'WHEN', 'ELSE', 'FINALLY'].concat(EXPRESSION_TAIL);
@ -37,9 +37,9 @@
IMPLICIT_CALL = ['IDENTIFIER', 'NUMBER', 'STRING', 'JS', 'REGEX', 'NEW', 'PARAM_START', 'TRY', 'DELETE', 'TYPEOF', 'SWITCH', 'TRUE', 'FALSE', 'YES', 'NO', 'ON', 'OFF', '!', '!!', 'NOT', '@', '->', '=>', '[', '(', '{'];
// The inverse mappings of token pairs we're trying to fix up.
INVERSES = {};
_7 = BALANCED_PAIRS;
for (_8 = 0; _8 < _7.length; _8++) {
pair = _7[_8];
_g = BALANCED_PAIRS;
for (_h = 0; _h < _g.length; _h++) {
pair = _g[_h];
INVERSES[pair[0]] = pair[1];
INVERSES[pair[1]] = pair[0];
}
@ -194,7 +194,7 @@
stack = [0];
return this.scan_tokens((function(__this) {
var __func = function(prev, token, post, i) {
var _10, _11, _12, _9, idx, last, size, stack_pointer, tag, tmp;
var _i, _j, _k, _l, idx, last, size, stack_pointer, tag, tmp;
tag = token[0];
if (tag === 'INDENT') {
stack.push(0);
@ -210,8 +210,8 @@
if (stack[stack.length - 1] > 0 || tag === 'INDENT') {
idx = tag === 'OUTDENT' ? i + 1 : i;
stack_pointer = tag === 'INDENT' ? 2 : 1;
_11 = 0; _12 = stack[stack.length - stack_pointer];
for (_10=0, tmp=_11; (_11 <= _12 ? tmp < _12 : tmp > _12); (_11 <= _12 ? tmp += 1 : tmp -= 1), _10++) {
_k = 0; _l = stack[stack.length - stack_pointer];
for (_j=0, tmp=_k; (_k <= _l ? tmp < _l : tmp > _l); (_k <= _l ? tmp += 1 : tmp -= 1), _j++) {
this.tokens.splice(idx, 0, ['CALL_END', ')', token[2]]);
}
size = stack[stack.length - stack_pointer] + 1;
@ -275,17 +275,17 @@
// Ensure that all listed pairs of tokens are correctly balanced throughout
// the course of the token stream.
re.prototype.ensure_balance = function ensure_balance(pairs) {
var _10, _9, key, levels, unclosed, value;
var _i, _j, key, levels, unclosed, value;
levels = {};
this.scan_tokens((function(__this) {
var __func = function(prev, token, post, i) {
var _10, _11, _9, close, open;
_9 = pairs;
for (_10 = 0; _10 < _9.length; _10++) {
pair = _9[_10];
_11 = pair;
open = _11[0];
close = _11[1];
var _i, _j, _k, close, open;
_i = pairs;
for (_j = 0; _j < _i.length; _j++) {
pair = _i[_j];
_k = pair;
open = _k[0];
close = _k[1];
levels[open] = levels[open] || 0;
if (token[0] === open) {
levels[open] += 1;
@ -304,14 +304,14 @@
});
})(this));
unclosed = (function() {
_9 = []; _10 = levels;
for (key in _10) if (__hasProp.call(_10, key)) {
value = _10[key];
_i = []; _j = levels;
for (key in _j) if (__hasProp.call(_j, key)) {
value = _j[key];
if (value > 0) {
_9.push(key);
_i.push(key);
}
}
return _9;
return _i;
}).call(this);
if (unclosed.length) {
throw new Error("unclosed " + unclosed[0]);
@ -331,12 +331,12 @@
// up balanced in the end.
//
re.prototype.rewrite_closing_parens = function rewrite_closing_parens() {
var _9, debt, key, stack, val;
var _i, debt, key, stack, val;
stack = [];
debt = {};
_9 = INVERSES;
for (key in _9) if (__hasProp.call(_9, key)) {
val = _9[key];
_i = INVERSES;
for (key in _i) if (__hasProp.call(_i, key)) {
val = _i[key];
((debt[key] = 0));
}
return this.scan_tokens((function(__this) {

View File

@ -16,7 +16,7 @@
this.expressions = expressions;
this.method = method;
this.variables = {};
this.temp_variable = this.parent ? this.parent.temp_variable : 1;
this.temp_var = this.parent ? this.parent.temp_var : '_a';
return this;
});
// Look up a variable in lexical scope, or declare it if not found.
@ -47,13 +47,13 @@
};
// Find an available, short, name for a compiler-generated variable.
Scope.prototype.free_variable = function free_variable() {
var id;
id = '_' + this.temp_variable;
while (this.check(id)) {
id = '_' + (this.temp_variable += 1);
var ordinal;
while (this.check(this.temp_var)) {
ordinal = 1 + parseInt(this.temp_var.substr(1), 36);
this.temp_var = '_' + ordinal.toString(36).replace(/\d/g, 'a');
}
this.variables[id] = 'var';
return id;
this.variables[this.temp_var] = 'var';
return this.temp_var;
};
// Ensure that an assignment is made at the top of scope (or top-level
// scope, if requested).
@ -78,45 +78,45 @@
};
// Return the list of variables first declared in current scope.
Scope.prototype.declared_variables = function declared_variables() {
var _1, _2, key, val;
var _a, _b, key, val;
return ((function() {
_1 = []; _2 = this.variables;
for (key in _2) if (__hasProp.call(_2, key)) {
val = _2[key];
_a = []; _b = this.variables;
for (key in _b) if (__hasProp.call(_b, key)) {
val = _b[key];
if (val === 'var') {
_1.push(key);
_a.push(key);
}
}
return _1;
return _a;
}).call(this)).sort();
};
// Return the list of variables that are supposed to be assigned at the top
// of scope.
Scope.prototype.assigned_variables = function assigned_variables() {
var _1, _2, key, val;
var _a, _b, key, val;
return ((function() {
_1 = []; _2 = this.variables;
for (key in _2) if (__hasProp.call(_2, key)) {
val = _2[key];
_a = []; _b = this.variables;
for (key in _b) if (__hasProp.call(_b, key)) {
val = _b[key];
if (val.assigned) {
_1.push([key, val.value]);
_a.push([key, val.value]);
}
}
return _1;
return _a;
}).call(this)).sort();
};
Scope.prototype.compiled_declarations = function compiled_declarations() {
return this.declared_variables().join(', ');
};
Scope.prototype.compiled_assignments = function compiled_assignments() {
var _1, _2, _3, t;
var _a, _b, _c, t;
return ((function() {
_1 = []; _2 = this.assigned_variables();
for (_3 = 0; _3 < _2.length; _3++) {
t = _2[_3];
_1.push(t[0] + ' = ' + t[1]);
_a = []; _b = this.assigned_variables();
for (_c = 0; _c < _b.length; _c++) {
t = _b[_c];
_a.push(t[0] + ' = ' + t[1]);
}
return _1;
return _a;
}).call(this)).join(', ');
};
})();

View File

@ -40,22 +40,22 @@
// The cornerstone, an each implementation.
// Handles objects implementing forEach, arrays, and raw objects.
_.each = function each(obj, iterator, context) {
var _1, _2, _3, _4, _5, _6, i, index, key, val;
var _a, _b, _c, _d, _e, _f, i, index, key, val;
index = 0;
try {
if (obj.forEach) {
return obj.forEach(iterator, context);
}
if (_.isNumber(obj.length)) {
_1 = []; _4 = 0; _5 = obj.length;
for (_3=0, i=_4; (_4 <= _5 ? i < _5 : i > _5); (_4 <= _5 ? i += 1 : i -= 1), _3++) {
_1.push(iterator.call(context, obj[i], i, obj));
_a = []; _d = 0; _e = obj.length;
for (_c=0, i=_d; (_d <= _e ? i < _e : i > _e); (_d <= _e ? i += 1 : i -= 1), _c++) {
_a.push(iterator.call(context, obj[i], i, obj));
}
return _1;
return _a;
}
_6 = obj;
for (key in _6) if (__hasProp.call(_6, key)) {
val = _6[key];
_f = obj;
for (key in _f) if (__hasProp.call(_f, key)) {
val = _f[key];
iterator.call(context, val, key, obj);
}
} catch (e) {
@ -173,13 +173,13 @@
// Determine if a given value is included in the array or object,
// based on '==='.
_.include = function include(obj, target) {
var _1, key, val;
var _a, key, val;
if (obj && _.isFunction(obj.indexOf)) {
return _.indexOf(obj, target) !== -1;
}
_1 = obj;
for (key in _1) if (__hasProp.call(_1, key)) {
val = _1[key];
_a = obj;
for (key in _a) if (__hasProp.call(_a, key)) {
val = _a[key];
if (val === target) {
return true;
}
@ -188,15 +188,15 @@
};
// Invoke a method with arguments on every item in a collection.
_.invoke = function invoke(obj, method) {
var _1, _2, _3, args, val;
var _a, _b, _c, args, val;
var arguments = Array.prototype.slice.call(arguments, 0);
args = _.rest(arguments, 2);
_1 = []; _2 = obj;
for (_3 = 0; _3 < _2.length; _3++) {
val = _2[_3];
_1.push((method ? val[method] : val).apply(val, args));
_a = []; _b = obj;
for (_c = 0; _c < _b.length; _c++) {
val = _b[_c];
_a.push((method ? val[method] : val).apply(val, args));
}
return _1;
return _a;
};
// Convenience version of a common use case of map: fetching a property.
_.pluck = function pluck(obj, key) {
@ -315,14 +315,14 @@
};
// Trim out all falsy values from an array.
_.compact = function compact(array) {
var _1, _2, _3, _4, _5, i;
_1 = []; _4 = 0; _5 = array.length;
for (_3=0, i=_4; (_4 <= _5 ? i < _5 : i > _5); (_4 <= _5 ? i += 1 : i -= 1), _3++) {
var _a, _b, _c, _d, _e, i;
_a = []; _d = 0; _e = array.length;
for (_c=0, i=_d; (_d <= _e ? i < _e : i > _e); (_d <= _e ? i += 1 : i -= 1), _c++) {
if (array[i]) {
_1.push(array[i]);
_a.push(array[i]);
}
}
return _1;
return _a;
};
// Return a completely flattened version of an array.
_.flatten = function flatten(array) {
@ -336,26 +336,26 @@
};
// Return a version of the array that does not contain the specified value(s).
_.without = function without(array) {
var _1, _2, _3, val, values;
var _a, _b, _c, val, values;
var arguments = Array.prototype.slice.call(arguments, 0);
values = _.rest(arguments);
_1 = []; _2 = _.toArray(array);
for (_3 = 0; _3 < _2.length; _3++) {
val = _2[_3];
_a = []; _b = _.toArray(array);
for (_c = 0; _c < _b.length; _c++) {
val = _b[_c];
if (!_.include(values, val)) {
_1.push(val);
_a.push(val);
}
}
return _1;
return _a;
};
// Produce a duplicate-free version of the array. If the array has already
// been sorted, you have the option of using a faster algorithm.
_.uniq = function uniq(array, isSorted) {
var _1, el, i, memo;
var _a, el, i, memo;
memo = [];
_1 = _.toArray(array);
for (i = 0; i < _1.length; i++) {
el = _1[i];
_a = _.toArray(array);
for (i = 0; i < _a.length; i++) {
el = _a[i];
if (i === 0 || (isSorted === true ? _.last(memo) !== el : !_.include(memo, el))) {
memo.push(el);
}
@ -377,12 +377,12 @@
// Zip together multiple lists into a single array -- elements that share
// an index go together.
_.zip = function zip() {
var _1, _2, _3, _4, i, length, results;
var _a, _b, _c, _d, i, length, results;
var arguments = Array.prototype.slice.call(arguments, 0);
length = _.max(_.pluck(arguments, 'length'));
results = new Array(length);
_3 = 0; _4 = length;
for (_2=0, i=_3; (_3 <= _4 ? i < _4 : i > _4); (_3 <= _4 ? i += 1 : i -= 1), _2++) {
_c = 0; _d = length;
for (_b=0, i=_c; (_c <= _d ? i < _d : i > _d); (_c <= _d ? i += 1 : i -= 1), _b++) {
results[i] = _.pluck(arguments, String(i));
}
return results;
@ -427,7 +427,7 @@
// the native Python range() function. See:
// http://docs.python.org/library/functions.html#range
_.range = function range(start, stop, step) {
var _1, a, i, idx, len, range, solo;
var _a, a, i, idx, len, range, solo;
var arguments = Array.prototype.slice.call(arguments, 0);
a = arguments;
solo = a.length <= 1;
@ -440,7 +440,7 @@
}
range = new Array(len);
idx = 0;
_1 = [];
_a = [];
while (true) {
if ((step > 0 ? i - stop : stop - i) >= 0) {
return range;
@ -449,7 +449,7 @@
idx++;
i += step;
}
return _1;
return _a;
};
// ----------------------- Function Functions: -----------------------------
// Create a function bound to a given object (assigning 'this', and arguments,
@ -506,11 +506,11 @@
var arguments = Array.prototype.slice.call(arguments, 0);
funcs = arguments;
return (function() {
var _1, _2, _3, _4, args, i;
var _a, _b, _c, _d, args, i;
var arguments = Array.prototype.slice.call(arguments, 0);
args = arguments;
_3 = (funcs.length - 1); _4 = 0;
for (_2=0, i=_3; (_3 <= _4 ? i <= _4 : i >= _4); (_3 <= _4 ? i += 1 : i -= 1), _2++) {
_c = (funcs.length - 1); _d = 0;
for (_b=0, i=_c; (_c <= _d ? i <= _d : i >= _d); (_c <= _d ? i += 1 : i -= 1), _b++) {
args = [funcs[i].apply(this, args)];
}
return args[0];
@ -519,16 +519,16 @@
// ------------------------- Object Functions: ----------------------------
// Retrieve the names of an object's properties.
_.keys = function keys(obj) {
var _1, _2, key, val;
var _a, _b, key, val;
if (_.isArray(obj)) {
return _.range(0, obj.length);
}
_1 = []; _2 = obj;
for (key in _2) if (__hasProp.call(_2, key)) {
val = _2[key];
_1.push(key);
_a = []; _b = obj;
for (key in _b) if (__hasProp.call(_b, key)) {
val = _b[key];
_a.push(key);
}
return _1;
return _a;
};
// Retrieve the values of an object's properties.
_.values = function values(obj) {
@ -542,10 +542,10 @@
};
// Extend a given object with all of the properties in a source object.
_.extend = function extend(destination, source) {
var _1, key, val;
_1 = source;
for (key in _1) if (__hasProp.call(_1, key)) {
val = _1[key];
var _a, key, val;
_a = source;
for (key in _a) if (__hasProp.call(_a, key)) {
val = _a[key];
destination[key] = val;
}
return destination;

View File

@ -12,7 +12,7 @@ Scope: exports.Scope: (parent, expressions, method) ->
@expressions: expressions
@method: method
@variables: {}
@temp_variable: if @parent then @parent.temp_variable else 1
@temp_var: if @parent then @parent.temp_var else '_a'
this
# Look up a variable in lexical scope, or declare it if not found.
@ -38,11 +38,11 @@ Scope::reset: (name) ->
# Find an available, short, name for a compiler-generated variable.
Scope::free_variable: ->
id: '_' + @temp_variable
while @check(id)
id: '_' + (@temp_variable += 1)
@variables[id]: 'var'
id
while @check @temp_var
ordinal: 1 + parseInt @temp_var.substr(1), 36
@temp_var: '_' + ordinal.toString(36).replace(/\d/g, 'a')
@variables[@temp_var]: 'var'
@temp_var
# Ensure that an assignment is made at the top of scope (or top-level
# scope, if requested).