2010-07-25 03:15:12 -04:00
|
|
|
(function() {
|
2010-11-11 21:48:08 -05:00
|
|
|
var BALANCED_PAIRS, EXPRESSION_CLOSE, EXPRESSION_END, EXPRESSION_START, IMPLICIT_BLOCK, IMPLICIT_CALL, IMPLICIT_END, IMPLICIT_FUNC, IMPLICIT_UNSPACED_CALL, INVERSES, LINEBREAKS, Rewriter, SINGLE_CLOSERS, SINGLE_LINERS, left, rite, _i, _len, _ref;
|
2010-10-19 23:27:15 -04:00
|
|
|
var __indexOf = Array.prototype.indexOf || function(item) {
|
2010-10-24 20:51:55 -04:00
|
|
|
for (var i = 0, l = this.length; i < l; i++) {
|
|
|
|
if (this[i] === item) return i;
|
|
|
|
}
|
2010-10-19 23:27:15 -04:00
|
|
|
return -1;
|
2010-11-01 23:41:05 -04:00
|
|
|
}, __slice = Array.prototype.slice;
|
2010-11-11 21:48:08 -05:00
|
|
|
exports.Rewriter = Rewriter = function() {
|
|
|
|
function Rewriter() {}
|
|
|
|
Rewriter.prototype.rewrite = function(_arg) {
|
|
|
|
this.tokens = _arg;
|
|
|
|
this.removeLeadingNewlines();
|
|
|
|
this.removeMidExpressionNewlines();
|
|
|
|
this.closeOpenCalls();
|
|
|
|
this.closeOpenIndexes();
|
|
|
|
this.addImplicitIndentation();
|
|
|
|
this.tagPostfixConditionals();
|
|
|
|
this.addImplicitBraces();
|
|
|
|
this.addImplicitParentheses();
|
|
|
|
this.ensureBalance(BALANCED_PAIRS);
|
|
|
|
this.rewriteClosingParens();
|
|
|
|
return this.tokens;
|
2010-11-09 08:20:09 -05:00
|
|
|
};
|
2010-11-11 21:48:08 -05:00
|
|
|
Rewriter.prototype.scanTokens = function(block) {
|
|
|
|
var i, token, tokens;
|
|
|
|
tokens = this.tokens;
|
|
|
|
i = 0;
|
|
|
|
while (token = tokens[i]) {
|
|
|
|
i += block.call(this, token, i, tokens);
|
2010-10-02 05:57:16 -04:00
|
|
|
}
|
2010-11-11 21:48:08 -05:00
|
|
|
return true;
|
2010-11-09 08:20:09 -05:00
|
|
|
};
|
2010-11-11 21:48:08 -05:00
|
|
|
Rewriter.prototype.detectEnd = function(i, condition, action) {
|
|
|
|
var levels, token, tokens, _ref, _ref2;
|
|
|
|
tokens = this.tokens;
|
|
|
|
levels = 0;
|
|
|
|
while (token = tokens[i]) {
|
|
|
|
if (levels === 0 && condition.call(this, token, i)) {
|
|
|
|
return action.call(this, token, i);
|
|
|
|
}
|
|
|
|
if (!token || levels < 0) {
|
|
|
|
return action.call(this, token, i - 1);
|
|
|
|
}
|
|
|
|
if (_ref = token[0], __indexOf.call(EXPRESSION_START, _ref) >= 0) {
|
|
|
|
levels += 1;
|
|
|
|
} else if (_ref2 = token[0], __indexOf.call(EXPRESSION_END, _ref2) >= 0) {
|
|
|
|
levels -= 1;
|
|
|
|
}
|
|
|
|
i += 1;
|
|
|
|
}
|
|
|
|
return i - 1;
|
2010-11-09 08:20:09 -05:00
|
|
|
};
|
2010-11-11 21:48:08 -05:00
|
|
|
Rewriter.prototype.removeLeadingNewlines = function() {
|
|
|
|
var i, tag, _len;
|
|
|
|
for (i = 0, _len = this.tokens.length; i < _len; i++) {
|
|
|
|
tag = this.tokens[i][0];
|
|
|
|
if (tag !== 'TERMINATOR') {
|
|
|
|
break;
|
|
|
|
}
|
2010-11-09 08:20:09 -05:00
|
|
|
}
|
2010-11-11 21:48:08 -05:00
|
|
|
if (i) {
|
|
|
|
return this.tokens.splice(0, i);
|
2010-10-02 05:57:16 -04:00
|
|
|
}
|
|
|
|
};
|
2010-11-11 21:48:08 -05:00
|
|
|
Rewriter.prototype.removeMidExpressionNewlines = function() {
|
|
|
|
return this.scanTokens(function(token, i, tokens) {
|
|
|
|
var _ref;
|
|
|
|
if (!(token[0] === 'TERMINATOR' && (_ref = this.tag(i + 1), __indexOf.call(EXPRESSION_CLOSE, _ref) >= 0))) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
tokens.splice(i, 1);
|
|
|
|
return 0;
|
|
|
|
});
|
2010-08-08 17:37:28 -04:00
|
|
|
};
|
2010-11-11 21:48:08 -05:00
|
|
|
Rewriter.prototype.closeOpenCalls = function() {
|
|
|
|
var action, condition;
|
|
|
|
condition = function(token, i) {
|
|
|
|
var _ref;
|
|
|
|
return ((_ref = token[0]) === ')' || _ref === 'CALL_END') || token[0] === 'OUTDENT' && this.tag(i - 1) === ')';
|
|
|
|
};
|
|
|
|
action = function(token, i) {
|
|
|
|
return this.tokens[token[0] === 'OUTDENT' ? i - 1 : i][0] = 'CALL_END';
|
|
|
|
};
|
|
|
|
return this.scanTokens(function(token, i) {
|
|
|
|
if (token[0] === 'CALL_START') {
|
|
|
|
this.detectEnd(i + 1, condition, action);
|
|
|
|
}
|
2010-10-07 11:56:01 -04:00
|
|
|
return 1;
|
2010-11-11 21:48:08 -05:00
|
|
|
});
|
2010-02-27 19:46:45 -05:00
|
|
|
};
|
2010-11-11 21:48:08 -05:00
|
|
|
Rewriter.prototype.closeOpenIndexes = function() {
|
|
|
|
var action, condition;
|
|
|
|
condition = function(token, i) {
|
|
|
|
var _ref;
|
|
|
|
return (_ref = token[0]) === ']' || _ref === 'INDEX_END';
|
|
|
|
};
|
|
|
|
action = function(token, i) {
|
|
|
|
return token[0] = 'INDEX_END';
|
|
|
|
};
|
|
|
|
return this.scanTokens(function(token, i) {
|
|
|
|
if (token[0] === 'INDEX_START') {
|
|
|
|
this.detectEnd(i + 1, condition, action);
|
|
|
|
}
|
2010-10-07 11:56:01 -04:00
|
|
|
return 1;
|
2010-11-11 21:48:08 -05:00
|
|
|
});
|
|
|
|
};
|
|
|
|
Rewriter.prototype.addImplicitBraces = function() {
|
2010-11-14 14:21:55 -05:00
|
|
|
var action, condition, stack, start, startIndent;
|
2010-11-11 21:48:08 -05:00
|
|
|
stack = [];
|
|
|
|
start = null;
|
2010-11-14 14:21:55 -05:00
|
|
|
startIndent = 0;
|
2010-11-11 21:48:08 -05:00
|
|
|
condition = function(token, i) {
|
|
|
|
var one, tag, three, two, _ref, _ref2;
|
2010-11-12 20:18:52 -05:00
|
|
|
_ref = this.tokens, one = _ref[i + 1], two = _ref[i + 2], three = _ref[i + 3];
|
|
|
|
if ('HERECOMMENT' === (one != null ? one[0] : void 0)) {
|
2010-11-11 21:48:08 -05:00
|
|
|
return false;
|
2010-08-14 11:42:19 -04:00
|
|
|
}
|
2010-10-07 11:56:01 -04:00
|
|
|
tag = token[0];
|
2010-11-14 14:21:55 -05:00
|
|
|
return ((tag === 'TERMINATOR' || tag === 'OUTDENT') && !((two != null ? two[0] : void 0) === ':' || (one != null ? one[0] : void 0) === '@' && (three != null ? three[0] : void 0) === ':')) || (tag === ',' && one && ((_ref2 = one[0]) !== 'IDENTIFIER' && _ref2 !== 'NUMBER' && _ref2 !== 'STRING' && _ref2 !== '@' && _ref2 !== 'TERMINATOR' && _ref2 !== 'OUTDENT' && _ref2 !== '('));
|
2010-11-11 21:48:08 -05:00
|
|
|
};
|
|
|
|
action = function(token, i) {
|
|
|
|
return this.tokens.splice(i, 0, ['}', '}', token[2]]);
|
|
|
|
};
|
|
|
|
return this.scanTokens(function(token, i, tokens) {
|
2010-11-13 12:17:09 -05:00
|
|
|
var ago1, ago2, idx, tag, tok, value, _ref, _ref2;
|
2010-11-11 21:48:08 -05:00
|
|
|
if (_ref = (tag = token[0]), __indexOf.call(EXPRESSION_START, _ref) >= 0) {
|
|
|
|
stack.push([(tag === 'INDENT' && this.tag(i - 1) === '{' ? '{' : tag), i]);
|
|
|
|
return 1;
|
2010-10-07 11:56:01 -04:00
|
|
|
}
|
2010-11-11 21:48:08 -05:00
|
|
|
if (__indexOf.call(EXPRESSION_END, tag) >= 0) {
|
|
|
|
start = stack.pop();
|
|
|
|
return 1;
|
2010-10-07 11:56:01 -04:00
|
|
|
}
|
2010-11-11 21:48:08 -05:00
|
|
|
if (!(tag === ':' && ((ago2 = this.tag(i - 2)) === ':' || (ago1 = this.tag(i - 1)) === ')' && this.tag(start[1] - 1) === ':' || ((_ref2 = stack[stack.length - 1]) != null ? _ref2[0] : void 0) !== '{'))) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
stack.push(['{']);
|
|
|
|
idx = ago1 === ')' ? start[1] : ago2 === '@' ? i - 2 : i - 1;
|
|
|
|
if (this.tag(idx - 2) === 'HERECOMMENT') {
|
|
|
|
idx -= 2;
|
2010-08-14 11:42:19 -04:00
|
|
|
}
|
2010-11-13 12:17:09 -05:00
|
|
|
value = new String('{');
|
|
|
|
value.generated = true;
|
|
|
|
tok = ['{', value, token[2]];
|
2010-11-11 21:48:08 -05:00
|
|
|
tok.generated = true;
|
|
|
|
tokens.splice(idx, 0, tok);
|
2010-10-02 05:57:16 -04:00
|
|
|
this.detectEnd(i + 2, condition, action);
|
2010-11-11 21:48:08 -05:00
|
|
|
return 2;
|
|
|
|
});
|
|
|
|
};
|
|
|
|
Rewriter.prototype.addImplicitParentheses = function() {
|
2010-11-12 00:05:30 -05:00
|
|
|
var action, noCall;
|
|
|
|
noCall = false;
|
2010-11-11 21:48:08 -05:00
|
|
|
action = function(token, i) {
|
|
|
|
var idx;
|
|
|
|
idx = token[0] === 'OUTDENT' ? i + 1 : i;
|
|
|
|
return this.tokens.splice(idx, 0, ['CALL_END', ')', token[2]]);
|
|
|
|
};
|
|
|
|
return this.scanTokens(function(token, i, tokens) {
|
|
|
|
var callObject, next, prev, seenSingle, tag, _ref, _ref2;
|
|
|
|
tag = token[0];
|
2010-11-12 00:05:30 -05:00
|
|
|
if (tag === 'CLASS' || tag === 'IF' || tag === 'UNLESS') {
|
|
|
|
noCall = true;
|
2010-11-11 21:48:08 -05:00
|
|
|
}
|
|
|
|
prev = tokens[i - 1], next = tokens[i + 1];
|
2010-11-12 00:05:30 -05:00
|
|
|
callObject = !noCall && tag === 'INDENT' && next && next.generated && next[0] === '{' && prev && (_ref = prev[0], __indexOf.call(IMPLICIT_FUNC, _ref) >= 0);
|
2010-11-11 21:48:08 -05:00
|
|
|
seenSingle = false;
|
|
|
|
if (__indexOf.call(LINEBREAKS, tag) >= 0) {
|
2010-11-12 00:05:30 -05:00
|
|
|
noCall = false;
|
2010-11-11 21:48:08 -05:00
|
|
|
}
|
|
|
|
if (prev && !prev.spaced && tag === '?') {
|
|
|
|
token.call = true;
|
|
|
|
}
|
|
|
|
if (!(callObject || (prev != null ? prev.spaced : void 0) && (prev.call || (_ref2 = prev[0], __indexOf.call(IMPLICIT_FUNC, _ref2) >= 0)) && (__indexOf.call(IMPLICIT_CALL, tag) >= 0 || !(token.spaced || token.newLine) && __indexOf.call(IMPLICIT_UNSPACED_CALL, tag) >= 0))) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
tokens.splice(i, 0, ['CALL_START', '(', token[2]]);
|
|
|
|
this.detectEnd(i + (callObject ? 2 : 1), function(token, i) {
|
|
|
|
var post, _ref;
|
|
|
|
if (!seenSingle && token.fromThen) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
tag = token[0];
|
|
|
|
if (tag === 'IF' || tag === 'ELSE' || tag === 'UNLESS' || tag === '->' || tag === '=>') {
|
|
|
|
seenSingle = true;
|
|
|
|
}
|
|
|
|
if ((tag === '.' || tag === '?.' || tag === '::') && this.tag(i - 1) === 'OUTDENT') {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return !token.generated && this.tag(i - 1) !== ',' && __indexOf.call(IMPLICIT_END, tag) >= 0 && (tag !== 'INDENT' || (this.tag(i - 2) !== 'CLASS' && (_ref = this.tag(i - 1), __indexOf.call(IMPLICIT_BLOCK, _ref) < 0) && !((post = this.tokens[i + 1]) && post.generated && post[0] === '{')));
|
|
|
|
}, action);
|
|
|
|
if (prev[0] === '?') {
|
|
|
|
prev[0] = 'FUNC_EXIST';
|
|
|
|
}
|
|
|
|
return 2;
|
|
|
|
});
|
|
|
|
};
|
|
|
|
Rewriter.prototype.addImplicitIndentation = function() {
|
|
|
|
return this.scanTokens(function(token, i, tokens) {
|
|
|
|
var action, condition, indent, outdent, starter, tag, _ref, _ref2;
|
|
|
|
tag = token[0];
|
|
|
|
if (tag === 'TERMINATOR' && this.tag(i + 1) === 'THEN') {
|
2010-10-02 05:57:16 -04:00
|
|
|
tokens.splice(i, 1);
|
2010-11-11 21:48:08 -05:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if (tag === 'ELSE' && this.tag(i - 1) !== 'OUTDENT') {
|
|
|
|
tokens.splice.apply(tokens, [i, 0].concat(__slice.call(this.indentation(token))));
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
if (tag === 'CATCH' && ((_ref = this.tag(i + 2)) === 'OUTDENT' || _ref === 'TERMINATOR' || _ref === 'FINALLY')) {
|
|
|
|
tokens.splice.apply(tokens, [i + 2, 0].concat(__slice.call(this.indentation(token))));
|
|
|
|
return 4;
|
|
|
|
}
|
|
|
|
if (__indexOf.call(SINGLE_LINERS, tag) >= 0 && this.tag(i + 1) !== 'INDENT' && !(tag === 'ELSE' && this.tag(i + 1) === 'IF')) {
|
|
|
|
starter = tag;
|
|
|
|
_ref2 = this.indentation(token), indent = _ref2[0], outdent = _ref2[1];
|
|
|
|
if (starter === 'THEN') {
|
|
|
|
indent.fromThen = true;
|
|
|
|
}
|
|
|
|
indent.generated = outdent.generated = true;
|
|
|
|
tokens.splice(i + 1, 0, indent);
|
|
|
|
condition = function(token, i) {
|
|
|
|
var _ref;
|
|
|
|
return token[1] !== ';' && (_ref = token[0], __indexOf.call(SINGLE_CLOSERS, _ref) >= 0) && !(token[0] === 'ELSE' && (starter !== 'IF' && starter !== 'THEN'));
|
|
|
|
};
|
|
|
|
action = function(token, i) {
|
|
|
|
return this.tokens.splice((this.tag(i - 1) === ',' ? i - 1 : i), 0, outdent);
|
|
|
|
};
|
|
|
|
this.detectEnd(i + 2, condition, action);
|
|
|
|
if (tag === 'THEN') {
|
|
|
|
tokens.splice(i, 1);
|
|
|
|
}
|
|
|
|
return 1;
|
2010-07-25 02:42:37 -04:00
|
|
|
}
|
2010-07-25 03:15:12 -04:00
|
|
|
return 1;
|
2010-11-11 21:48:08 -05:00
|
|
|
});
|
2010-07-25 02:42:37 -04:00
|
|
|
};
|
2010-11-11 21:48:08 -05:00
|
|
|
Rewriter.prototype.tagPostfixConditionals = function() {
|
|
|
|
var condition;
|
|
|
|
condition = function(token, i) {
|
|
|
|
var _ref;
|
|
|
|
return (_ref = token[0]) === 'TERMINATOR' || _ref === 'INDENT';
|
|
|
|
};
|
|
|
|
return this.scanTokens(function(token, i) {
|
|
|
|
var original, _ref;
|
|
|
|
if ((_ref = token[0]) !== 'IF' && _ref !== 'UNLESS') {
|
|
|
|
return 1;
|
2010-11-08 23:07:51 -05:00
|
|
|
}
|
2010-11-11 21:48:08 -05:00
|
|
|
original = token;
|
|
|
|
this.detectEnd(i + 1, condition, function(token, i) {
|
|
|
|
if (token[0] !== 'INDENT') {
|
|
|
|
return original[0] = 'POST_' + original[0];
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return 1;
|
2010-08-11 21:07:47 -04:00
|
|
|
});
|
2010-11-11 21:48:08 -05:00
|
|
|
};
|
|
|
|
Rewriter.prototype.ensureBalance = function(pairs) {
|
|
|
|
var close, level, levels, open, openLine, tag, token, _i, _j, _len, _len2, _ref, _ref2;
|
|
|
|
levels = {};
|
|
|
|
openLine = {};
|
|
|
|
_ref = this.tokens;
|
|
|
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
|
|
|
token = _ref[_i];
|
|
|
|
tag = token[0];
|
|
|
|
for (_j = 0, _len2 = pairs.length; _j < _len2; _j++) {
|
|
|
|
_ref2 = pairs[_j], open = _ref2[0], close = _ref2[1];
|
|
|
|
levels[open] |= 0;
|
|
|
|
if (tag === open) {
|
|
|
|
if (levels[open]++ === 0) {
|
|
|
|
openLine[open] = token[2];
|
|
|
|
}
|
|
|
|
} else if (tag === close && --levels[open] < 0) {
|
|
|
|
throw Error("too many " + token[1] + " on line " + (token[2] + 1));
|
2010-10-02 05:57:16 -04:00
|
|
|
}
|
2010-07-25 03:15:12 -04:00
|
|
|
}
|
2010-10-02 05:57:16 -04:00
|
|
|
}
|
2010-11-11 21:48:08 -05:00
|
|
|
for (open in levels) {
|
|
|
|
level = levels[open];
|
|
|
|
if (level > 0) {
|
|
|
|
throw Error("unclosed " + open + " on line " + (openLine[open] + 1));
|
|
|
|
}
|
2010-10-02 05:57:16 -04:00
|
|
|
}
|
2010-11-11 21:48:08 -05:00
|
|
|
return this;
|
|
|
|
};
|
|
|
|
Rewriter.prototype.rewriteClosingParens = function() {
|
|
|
|
var debt, key, stack;
|
|
|
|
stack = [];
|
|
|
|
debt = {};
|
|
|
|
for (key in INVERSES) {
|
|
|
|
debt[key] = 0;
|
2010-10-02 05:57:16 -04:00
|
|
|
}
|
2010-11-11 21:48:08 -05:00
|
|
|
return this.scanTokens(function(token, i, tokens) {
|
|
|
|
var inv, match, mtag, oppos, tag, val, _ref;
|
|
|
|
if (_ref = (tag = token[0]), __indexOf.call(EXPRESSION_START, _ref) >= 0) {
|
|
|
|
stack.push(token);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
if (__indexOf.call(EXPRESSION_END, tag) < 0) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
if (debt[inv = INVERSES[tag]] > 0) {
|
|
|
|
debt[inv] -= 1;
|
|
|
|
tokens.splice(i, 1);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
match = stack.pop();
|
|
|
|
mtag = match[0];
|
|
|
|
oppos = INVERSES[mtag];
|
|
|
|
if (tag === oppos) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
debt[mtag] += 1;
|
|
|
|
val = [oppos, mtag === 'INDENT' ? match[1] : oppos];
|
|
|
|
if (this.tag(i + 2) === mtag) {
|
|
|
|
tokens.splice(i + 3, 0, val);
|
|
|
|
stack.push(match);
|
|
|
|
} else {
|
|
|
|
tokens.splice(i, 0, val);
|
|
|
|
}
|
2010-07-25 03:15:12 -04:00
|
|
|
return 1;
|
2010-11-11 21:48:08 -05:00
|
|
|
});
|
|
|
|
};
|
|
|
|
Rewriter.prototype.indentation = function(token) {
|
|
|
|
return [['INDENT', 2, token[2]], ['OUTDENT', 2, token[2]]];
|
|
|
|
};
|
|
|
|
Rewriter.prototype.tag = function(i) {
|
|
|
|
var _ref;
|
|
|
|
return (_ref = this.tokens[i]) != null ? _ref[0] : void 0;
|
|
|
|
};
|
|
|
|
return Rewriter;
|
|
|
|
}();
|
2010-10-02 05:57:16 -04:00
|
|
|
BALANCED_PAIRS = [['(', ')'], ['[', ']'], ['{', '}'], ['INDENT', 'OUTDENT'], ['CALL_START', 'CALL_END'], ['PARAM_START', 'PARAM_END'], ['INDEX_START', 'INDEX_END']];
|
2010-03-07 14:41:52 -05:00
|
|
|
INVERSES = {};
|
2010-10-02 05:57:16 -04:00
|
|
|
EXPRESSION_START = [];
|
|
|
|
EXPRESSION_END = [];
|
2010-10-21 21:51:06 -04:00
|
|
|
for (_i = 0, _len = BALANCED_PAIRS.length; _i < _len; _i++) {
|
2010-10-02 05:57:16 -04:00
|
|
|
_ref = BALANCED_PAIRS[_i], left = _ref[0], rite = _ref[1];
|
|
|
|
EXPRESSION_START.push(INVERSES[rite] = left);
|
|
|
|
EXPRESSION_END.push(INVERSES[left] = rite);
|
2010-03-07 14:41:52 -05:00
|
|
|
}
|
|
|
|
EXPRESSION_CLOSE = ['CATCH', 'WHEN', 'ELSE', 'FINALLY'].concat(EXPRESSION_END);
|
2010-09-08 20:15:16 -04:00
|
|
|
IMPLICIT_FUNC = ['IDENTIFIER', 'SUPER', ')', 'CALL_END', ']', 'INDEX_END', '@', 'THIS'];
|
2010-10-19 11:52:07 -04:00
|
|
|
IMPLICIT_CALL = ['IDENTIFIER', 'NUMBER', 'STRING', 'JS', 'REGEX', 'NEW', 'PARAM_START', 'CLASS', 'IF', 'UNLESS', 'TRY', 'SWITCH', 'THIS', 'BOOL', 'UNARY', '@', '->', '=>', '[', '(', '{', '--', '++'];
|
|
|
|
IMPLICIT_UNSPACED_CALL = ['+', '-'];
|
2010-03-07 14:41:52 -05:00
|
|
|
IMPLICIT_BLOCK = ['->', '=>', '{', '[', ','];
|
2010-11-02 00:25:04 -04:00
|
|
|
IMPLICIT_END = ['POST_IF', 'POST_UNLESS', 'FOR', 'WHILE', 'UNTIL', 'WHEN', 'BY', 'LOOP', 'TERMINATOR', 'INDENT'];
|
2010-10-02 05:57:16 -04:00
|
|
|
SINGLE_LINERS = ['ELSE', '->', '=>', 'TRY', 'FINALLY', 'THEN'];
|
2010-03-07 14:41:52 -05:00
|
|
|
SINGLE_CLOSERS = ['TERMINATOR', 'CATCH', 'FINALLY', 'ELSE', 'OUTDENT', 'LEADING_WHEN'];
|
2010-08-14 19:56:00 -04:00
|
|
|
LINEBREAKS = ['TERMINATOR', 'INDENT', 'OUTDENT'];
|
2010-09-21 03:53:58 -04:00
|
|
|
}).call(this);
|