stop supressing left-hand whitespace in newline'd strings. Make 'em more literal.

This commit is contained in:
Jeremy Ashkenas 2010-08-16 22:02:37 -04:00
parent 474c372b17
commit a8c6a641d7
3 changed files with 5 additions and 7 deletions

View File

@ -1,5 +1,5 @@
(function() { (function() {
var ASSIGNED, CALLABLE, CODE, COFFEE_ALIASES, COFFEE_KEYWORDS, COMMENT, COMPARE, COMPOUND_ASSIGN, CONVERSIONS, HEREDOC, HEREDOC_INDENT, IDENTIFIER, JS_CLEANER, JS_FORBIDDEN, JS_KEYWORDS, LAST_DENT, LAST_DENTS, LINE_BREAK, LOGIC, Lexer, MATH, MULTILINER, MULTI_DENT, NEXT_CHARACTER, NOT_REGEX, NO_NEWLINE, NUMBER, OPERATOR, REGEX_END, REGEX_ESCAPE, REGEX_INTERPOLATION, REGEX_START, RESERVED, Rewriter, SHIFT, STRING_NEWLINES, UNARY, WHITESPACE, _a, _b, _c, compact, count, helpers, include, starts; var ASSIGNED, CALLABLE, CODE, COFFEE_ALIASES, COFFEE_KEYWORDS, COMMENT, COMPARE, COMPOUND_ASSIGN, CONVERSIONS, HEREDOC, HEREDOC_INDENT, IDENTIFIER, JS_CLEANER, JS_FORBIDDEN, JS_KEYWORDS, LAST_DENT, LAST_DENTS, LINE_BREAK, LOGIC, Lexer, MATH, MULTILINER, MULTI_DENT, NEXT_CHARACTER, NOT_REGEX, NO_NEWLINE, NUMBER, OPERATOR, REGEX_END, REGEX_ESCAPE, REGEX_INTERPOLATION, REGEX_START, RESERVED, Rewriter, SHIFT, UNARY, WHITESPACE, _a, _b, _c, compact, count, helpers, include, starts;
var __slice = Array.prototype.slice; var __slice = Array.prototype.slice;
if (typeof process !== "undefined" && process !== null) { if (typeof process !== "undefined" && process !== null) {
_a = require('./rewriter'); _a = require('./rewriter');
@ -141,7 +141,7 @@
if (!(string = this.balancedToken(['"', '"'], ['#{', '}']) || this.balancedToken(["'", "'"]))) { if (!(string = this.balancedToken(['"', '"'], ['#{', '}']) || this.balancedToken(["'", "'"]))) {
return false; return false;
} }
this.interpolateString(string.replace(STRING_NEWLINES, " \\\n")); this.interpolateString(string.replace(/\n/g, '\\\n'));
this.line += count(string, "\n"); this.line += count(string, "\n");
this.i += string.length; this.i += string.length;
return true; return true;
@ -615,7 +615,6 @@
REGEX_ESCAPE = /\\[^\$]/g; REGEX_ESCAPE = /\\[^\$]/g;
JS_CLEANER = /(^`|`$)/g; JS_CLEANER = /(^`|`$)/g;
MULTILINER = /\n/g; MULTILINER = /\n/g;
STRING_NEWLINES = /\n[ \t]*/g;
NO_NEWLINE = /^([+\*&|\/\-%=<>!.\\][<>=&|]*|and|or|is|isnt|not|delete|typeof|instanceof)$/; NO_NEWLINE = /^([+\*&|\/\-%=<>!.\\][<>=&|]*|and|or|is|isnt|not|delete|typeof|instanceof)$/;
HEREDOC_INDENT = /(\n+([ \t]*)|^([ \t]+))/g; HEREDOC_INDENT = /(\n+([ \t]*)|^([ \t]+))/g;
ASSIGNED = /^\s*(([a-zA-Z\$_@]\w*|["'][^\r\n]+?["']|\d+)[ \t]*?[:=][^=])/; ASSIGNED = /^\s*(([a-zA-Z\$_@]\w*|["'][^\r\n]+?["']|\d+)[ \t]*?[:=][^=])/;

View File

@ -123,7 +123,7 @@ exports.Lexer = class Lexer
return false unless string = return false unless string =
@balancedToken(['"', '"'], ['#{', '}']) or @balancedToken(['"', '"'], ['#{', '}']) or
@balancedToken ["'", "'"] @balancedToken ["'", "'"]
@interpolateString string.replace STRING_NEWLINES, " \\\n" @interpolateString string.replace /\n/g, '\\\n'
@line += count string, "\n" @line += count string, "\n"
@i += string.length @i += string.length
true true
@ -536,7 +536,6 @@ REGEX_ESCAPE = /\\[^\$]/g
# Token cleaning regexes. # Token cleaning regexes.
JS_CLEANER = /(^`|`$)/g JS_CLEANER = /(^`|`$)/g
MULTILINER = /\n/g MULTILINER = /\n/g
STRING_NEWLINES = /\n[ \t]*/g
NO_NEWLINE = /^([+\*&|\/\-%=<>!.\\][<>=&|]*|and|or|is|isnt|not|delete|typeof|instanceof)$/ NO_NEWLINE = /^([+\*&|\/\-%=<>!.\\][<>=&|]*|and|or|is|isnt|not|delete|typeof|instanceof)$/
HEREDOC_INDENT = /(\n+([ \t]*)|^([ \t]+))/g HEREDOC_INDENT = /(\n+([ \t]*)|^([ \t]+))/g
ASSIGNED = /^\s*(([a-zA-Z\$_@]\w*|["'][^\r\n]+?["']|\d+)[ \t]*?[:=][^=])/ ASSIGNED = /^\s*(([a-zA-Z\$_@]\w*|["'][^\r\n]+?["']|\d+)[ \t]*?[:=][^=])/

View File

@ -60,8 +60,8 @@ ok money$ is '\(\(\(dollars\)\)\)'
multiline = "one multiline = "one
two two
three" three"
ok multiline is 'one two three' ok multiline is 'one two three'