Merge commit 'StanAngeloff/issue_309'

This commit is contained in:
Jeremy Ashkenas 2010-04-11 09:22:31 -04:00
commit 8de2fb9009
2 changed files with 14 additions and 13 deletions

View File

@ -60,9 +60,6 @@
this.extract_next_token();
}
this.close_indentation();
if (o.rewrite === false) {
return this.tokens;
}
return (new Rewriter()).rewrite(this.tokens);
};
// At every position, run through this list of attempted matches,
@ -464,7 +461,7 @@
// new Lexer, tokenize the interpolated contents, and merge them into the
// token stream.
Lexer.prototype.interpolate_string = function interpolate_string(str, escape_quotes) {
var _a, _b, _c, _d, _e, escaped, expr, group, i, inner, interp, interpolated, lexer, match, nested, pi, quote, tag, token, tokens, value;
var _a, _b, _c, _d, _e, _f, _g, escaped, expr, group, i, index, inner, interp, interpolated, lexer, match, nested, pi, quote, tag, token, tokens, value;
if (str.length < 3 || !starts(str, '"')) {
return this.token('STRING', str);
} else {
@ -497,9 +494,13 @@
inner = expr.substring(2, expr.length - 1);
if (inner.length) {
nested = lexer.tokenize(("(" + inner + ")"), {
rewrite: false,
line: this.line
});
_c = nested;
for (index = 0, _d = _c.length; index < _d; index++) {
value = _c[index];
value[0] === 'CALL_END' ? (nested[index][0] = ')') : null;
}
nested.pop();
tokens.push(['TOKENS', nested]);
} else {
@ -520,12 +521,12 @@
if (interpolated) {
this.token('(', '(');
}
_c = tokens;
for (i = 0, _d = _c.length; i < _d; i++) {
token = _c[i];
_e = token;
tag = _e[0];
value = _e[1];
_e = tokens;
for (i = 0, _f = _e.length; i < _f; i++) {
token = _e[i];
_g = token;
tag = _g[0];
value = _g[1];
if (tag === 'TOKENS') {
this.tokens = this.tokens.concat(value);
} else if (tag === 'STRING' && escape_quotes) {

View File

@ -56,7 +56,6 @@ exports.Lexer: class Lexer
@chunk: @code.slice @i
@extract_next_token()
@close_indentation()
return @tokens if o.rewrite is off
(new Rewriter()).rewrite @tokens
# At every position, run through this list of attempted matches,
@ -366,7 +365,8 @@ exports.Lexer: class Lexer
tokens.push ['STRING', "$quote${ str.substring(pi, i) }$quote"] if pi < i
inner: expr.substring(2, expr.length - 1)
if inner.length
nested: lexer.tokenize "($inner)", {rewrite: no, line: @line}
nested: lexer.tokenize "($inner)", {line: @line}
(nested[index][0]: ')') for value, index in nested when value[0] is 'CALL_END'
nested.pop()
tokens.push ['TOKENS', nested]
else