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

@@ -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) {