the rewriter is done

This commit is contained in:
Jeremy Ashkenas
2010-01-30 18:29:53 -05:00
parent c6457e010d
commit bad50c9aee
4 changed files with 193 additions and 55 deletions

View File

@@ -51,6 +51,8 @@
// The stack of all indent levels we are currently within.
this.tokens = [];
// Collection of all parsed tokens in the form [:TOKEN_TYPE, value]
this.spaced = null;
// The last token that has a space following it.
while (this.i < this.code.length) {
this.chunk = this.code.slice(this.i);
this.extract_next_token();
@@ -235,7 +237,7 @@
if (!((space = this.match(WHITESPACE, 1)))) {
return false;
}
this.value().spaced = true;
this.spaced = this.value();
this.i += space.length;
return true;
};
@@ -266,7 +268,7 @@
}
value = value || this.chunk.substr(0, 1);
tag = value.match(ASSIGNMENT) ? 'ASSIGN' : value;
if (this.value() && !this.value().spaced && CALLABLE.indexOf(this.tag() >= 0)) {
if (this.value() !== this.spaced && CALLABLE.indexOf(this.tag()) >= 0) {
if (value === '(') {
tag = 'CALL_START';
}
@@ -331,12 +333,11 @@
// parameter identifiers in order to avoid this. Also, parameter lists can
// make use of splats.
lex.prototype.tag_parameters = function tag_parameters() {
var __a, i, tok;
var i, tok;
if (this.tag() !== ')') {
return null;
}
i = 0;
__a = [];
while (true) {
i += 1;
tok = this.tokens[this.tokens.length - i];
@@ -351,7 +352,7 @@
return (tok[0] = 'PARAM_START');
}
}
return __a;
return true;
};
// Close up all remaining open blocks. IF the first token is an indent,
// axe it.