coffee-lex
Advanced tools
Comparing version 7.0.6 to 7.0.7
@@ -137,10 +137,21 @@ "use strict"; | ||
} | ||
/** | ||
* Mimic the STRING_OMIT regex from the CoffeeScript lexer, and split on all | ||
* newlines that remain after that operation. That operation finds all escaped | ||
* newlines (which may have a backslash, then any number of spaces, then a | ||
* newline), and removes everything from the backslash to the next | ||
* non-whitespace character (so it may skip later newlines). | ||
*/ | ||
function splitUnescapedNewlines(str) { | ||
var lines = ['']; | ||
var numBackslashes = 0; | ||
var isEatingWhitespace = false; | ||
for (var i = 0; i < str.length; i++) { | ||
if (str[i] === '\n' && numBackslashes % 2 === 0) { | ||
if (str[i] === '\n' && numBackslashes % 2 === 0 && !isEatingWhitespace) { | ||
lines.push(''); | ||
} | ||
else { | ||
if (str[i] === '\n' && numBackslashes % 2 === 1) { | ||
isEatingWhitespace = true; | ||
} | ||
if (str[i] === '\\') { | ||
@@ -152,2 +163,5 @@ numBackslashes++; | ||
} | ||
if (!' \t\n'.includes(str[i])) { | ||
isEatingWhitespace = false; | ||
} | ||
lines[lines.length - 1] += str[i]; | ||
@@ -154,0 +168,0 @@ } |
@@ -48,3 +48,3 @@ { | ||
}, | ||
"version": "7.0.6" | ||
"version": "7.0.7" | ||
} |
Sorry, the diff of this file is not supported yet
160229
3729