fixes #1442: javascript literals should increase line count when they

contain newlines
This commit is contained in:
Michael Ficarra
2011-06-17 11:26:39 -04:00
parent dfcff3f0fc
commit a1f1afe3ed
2 changed files with 6 additions and 2 deletions

View File

@@ -190,7 +190,9 @@
if (!(this.chunk.charAt(0) === '`' && (match = JSTOKEN.exec(this.chunk)))) {
return 0;
}
this.token('JS', (script = match[0]).slice(1, -1));
script = match[0];
this.line += count(script, '\n');
this.token('JS', script.slice(1, -1));
return script.length;
};
Lexer.prototype.regexToken = function() {

View File

@@ -181,7 +181,9 @@ exports.Lexer = class Lexer
# Matches JavaScript interpolated directly into the source via backticks.
jsToken: ->
return 0 unless @chunk.charAt(0) is '`' and match = JSTOKEN.exec @chunk
@token 'JS', (script = match[0]).slice 1, -1
script = match[0]
@line += count script, '\n'
@token 'JS', script[1...-1]
script.length
# Matches regular expression literals. Lexing regular expressions is difficult