Fixing issue #1046.
This commit is contained in:
parent
7c7b9a4be1
commit
4c18ddf549
12
lib/lexer.js
12
lib/lexer.js
|
@ -480,7 +480,7 @@
|
|||
throw new Error("missing " + (stack.pop()) + ", starting on line " + (this.line + 1));
|
||||
};
|
||||
Lexer.prototype.interpolateString = function(str, options) {
|
||||
var expr, heredoc, i, inner, interpolated, letter, nested, pi, regex, tag, tokens, value, _len, _ref, _ref2, _ref3;
|
||||
var expr, heredoc, i, inner, interpolated, len, letter, nested, pi, regex, tag, tokens, value, _len, _ref, _ref2, _ref3;
|
||||
if (options == null) {
|
||||
options = {};
|
||||
}
|
||||
|
@ -509,11 +509,13 @@
|
|||
if (((_ref = nested[0]) != null ? _ref[0] : void 0) === 'TERMINATOR') {
|
||||
nested.shift();
|
||||
}
|
||||
if (nested.length > 1) {
|
||||
nested.unshift(['(', '(']);
|
||||
nested.push([')', ')']);
|
||||
if (len = nested.length) {
|
||||
if (len > 1) {
|
||||
nested.unshift(['(', '(']);
|
||||
nested.push([')', ')']);
|
||||
}
|
||||
tokens.push(['TOKENS', nested]);
|
||||
}
|
||||
tokens.push(['TOKENS', nested]);
|
||||
}
|
||||
i += expr.length;
|
||||
pi = i + 1;
|
||||
|
|
|
@ -439,10 +439,11 @@ exports.Lexer = class Lexer
|
|||
nested = new Lexer().tokenize inner, line: @line, rewrite: off
|
||||
nested.pop()
|
||||
nested.shift() if nested[0]?[0] is 'TERMINATOR'
|
||||
if nested.length > 1
|
||||
nested.unshift ['(', '(']
|
||||
nested.push [')', ')']
|
||||
tokens.push ['TOKENS', nested]
|
||||
if len = nested.length
|
||||
if len > 1
|
||||
nested.unshift ['(', '(']
|
||||
nested.push [')', ')']
|
||||
tokens.push ['TOKENS', nested]
|
||||
i += expr.length
|
||||
pi = i + 1
|
||||
tokens.push ['NEOSTRING', str.slice pi] if i > pi < str.length
|
||||
|
|
|
@ -101,3 +101,7 @@ eq ''' '\\\' ''', " '\\' "
|
|||
eq """ "\\\" """, ' "\\" '
|
||||
|
||||
eq ''' <- keep these spaces -> ''', ' <- keep these spaces -> '
|
||||
|
||||
|
||||
test "#1046, empty string interpolations", ->
|
||||
eq "#{ }", ''
|
||||
|
|
Loading…
Reference in New Issue