Skip to content

Commit

Permalink
Don't insert semicolons before multi-line strings.
Browse files Browse the repository at this point in the history
(Escaped) newlines in multi-line strings don't count as
newlines for semicolon insertion purposes.
  • Loading branch information
Paul Baumgart committed Sep 23, 2011
1 parent 3dc988b commit 48d2fe7
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/parse-js.js
Expand Up @@ -291,12 +291,12 @@ function tokenizer($TEXT) {

function peek() { return S.text.charAt(S.pos); };

function next(signal_eof) {
function next(signal_eof, in_string) {
var ch = S.text.charAt(S.pos++);
if (signal_eof && !ch)
throw EX_EOF;
if (ch == "\n") {
S.newline_before = true;
S.newline_before = S.newline_before || !in_string;
++S.line;
S.col = 0;
} else {
Expand Down Expand Up @@ -393,8 +393,8 @@ function tokenizer($TEXT) {
}
};

function read_escaped_char() {
var ch = next(true);
function read_escaped_char(in_string) {
var ch = next(true, in_string);
switch (ch) {
case "n" : return "\n";
case "r" : return "\r";
Expand Down Expand Up @@ -442,7 +442,7 @@ function tokenizer($TEXT) {
return false;
});
if (octal_len > 0) ch = String.fromCharCode(parseInt(ch, 8));
else ch = read_escaped_char();
else ch = read_escaped_char(true);
}
else if (ch == quote) break;
ret += ch;
Expand Down

0 comments on commit 48d2fe7

Please sign in to comment.