switched from alphabetical __a __b temporary variables, to numeric _1, _2, which will be shorter in most cases

This commit is contained in:
Jeremy Ashkenas
2010-02-15 21:55:57 -05:00
parent 48c501a7a2
commit 4ea8be8e0b
8 changed files with 257 additions and 266 deletions

View File

@@ -1,5 +1,5 @@
(function(){
var BALANCED_PAIRS, EXPRESSION_CLOSE, EXPRESSION_START, EXPRESSION_TAIL, IMPLICIT_CALL, IMPLICIT_END, IMPLICIT_FUNC, INVERSES, SINGLE_CLOSERS, SINGLE_LINERS, __a, __b, __c, __d, __e, __f, __g, __h, pair, re;
var BALANCED_PAIRS, EXPRESSION_CLOSE, EXPRESSION_START, EXPRESSION_TAIL, IMPLICIT_CALL, IMPLICIT_END, IMPLICIT_FUNC, INVERSES, SINGLE_CLOSERS, SINGLE_LINERS, _1, _2, _3, _4, _5, _6, _7, _8, 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() {
__a = []; __b = BALANCED_PAIRS;
for (__c = 0; __c < __b.length; __c++) {
pair = __b[__c];
__a.push(pair[0]);
_1 = []; _2 = BALANCED_PAIRS;
for (_3 = 0; _3 < _2.length; _3++) {
pair = _2[_3];
_1.push(pair[0]);
}
return __a;
return _1;
}).call(this);
// Tokens that signal the end of a balanced pair.
EXPRESSION_TAIL = (function() {
__d = []; __e = BALANCED_PAIRS;
for (__f = 0; __f < __e.length; __f++) {
pair = __e[__f];
__d.push(pair[1]);
_4 = []; _5 = BALANCED_PAIRS;
for (_6 = 0; _6 < _5.length; _6++) {
pair = _5[_6];
_4.push(pair[1]);
}
return __d;
return _4;
}).call(this);
// Tokens that indicate the close of a clause of an expression.
EXPRESSION_CLOSE = ['CATCH', 'WHEN', 'ELSE', 'FINALLY'].concat(EXPRESSION_TAIL);
@@ -36,9 +36,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 = {};
__g = BALANCED_PAIRS;
for (__h = 0; __h < __g.length; __h++) {
pair = __g[__h];
_7 = BALANCED_PAIRS;
for (_8 = 0; _8 < _7.length; _8++) {
pair = _7[_8];
INVERSES[pair[0]] = pair[1];
INVERSES[pair[1]] = pair[0];
}
@@ -193,7 +193,7 @@
stack = [0];
return this.scan_tokens((function(__this) {
var __func = function(prev, token, post, i) {
var __i, __j, __k, __l, idx, last, size, tmp;
var _10, _11, _12, _9, idx, last, size, tmp;
if (token[0] === 'INDENT') {
stack.push(0);
}
@@ -203,8 +203,8 @@
}
if (stack[stack.length - 1] > 0 && (IMPLICIT_END.indexOf(token[0]) >= 0 || !(typeof post !== "undefined" && post !== null))) {
idx = token[0] === 'OUTDENT' ? i + 1 : i;
__k = 0; __l = stack[stack.length - 1];
for (__j=0, tmp=__k; (__k <= __l ? tmp < __l : tmp > __l); (__k <= __l ? tmp += 1 : tmp -= 1), __j++) {
_11 = 0; _12 = stack[stack.length - 1];
for (_10=0, tmp=_11; (_11 <= _12 ? tmp < _12 : tmp > _12); (_11 <= _12 ? tmp += 1 : tmp -= 1), _10++) {
this.tokens.splice(idx, 0, ['CALL_END', ')', token[2]]);
}
size = stack[stack.length - 1] + 1;
@@ -267,17 +267,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 __i, __j, key, levels, unclosed, value;
var _10, _9, key, levels, unclosed, value;
levels = {};
this.scan_tokens((function(__this) {
var __func = function(prev, token, post, i) {
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];
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];
levels[open] = levels[open] || 0;
if (token[0] === open) {
levels[open] += 1;
@@ -296,14 +296,14 @@
});
})(this));
unclosed = (function() {
__i = []; __j = levels;
for (key in __j) if (__hasProp.call(__j, key)) {
value = __j[key];
_9 = []; _10 = levels;
for (key in _10) if (__hasProp.call(_10, key)) {
value = _10[key];
if (value > 0) {
__i.push(key);
_9.push(key);
}
}
return __i;
return _9;
}).call(this);
if (unclosed.length) {
throw "unclosed " + unclosed[0];
@@ -323,12 +323,12 @@
// up balanced in the end.
//
re.prototype.rewrite_closing_parens = function rewrite_closing_parens() {
var __i, debt, key, stack, val;
var _9, debt, key, stack, val;
stack = [];
debt = {};
__i = INVERSES;
for (key in __i) if (__hasProp.call(__i, key)) {
val = __i[key];
_9 = INVERSES;
for (key in _9) if (__hasProp.call(_9, key)) {
val = _9[key];
((debt[key] = 0));
}
return this.scan_tokens((function(__this) {