Automatically close comments at the end of input instead of throwing a "Syntax Error on line 1"

This commit is contained in:
Konstantin Käfer 2011-01-17 15:31:15 -05:00
parent 8e615e549f
commit 1fbcaf2164

View File

@ -193,7 +193,7 @@ mess.Parser = function Parser(env) {
chunks = (function (chunks) { chunks = (function (chunks) {
var j = 0, var j = 0,
skip = /[^"'`\{\}\/]+/g, skip = /[^"'`\{\}\/]+/g,
comment = /\/\*(?:[^*]|\*+[^\/*])*\*+\/|\/\/.*/g, comment = /\/\*(?:[^*]|\*+[^\/*])*(?:\*+\/\n?|\**$)|\/\/.*/g,
level = 0, level = 0,
match, match,
chunk = chunks[0], chunk = chunks[0],
@ -435,7 +435,7 @@ mess.Parser = function Parser(env) {
if (input.charAt(i + 1) === '/') { if (input.charAt(i + 1) === '/') {
return new(tree.Comment)($(/^\/\/.*/), true); return new(tree.Comment)($(/^\/\/.*/), true);
} else if (comment = $(/^\/\*(?:[^*]|\*+[^\/*])*\*+\/\n?/)) { } else if (comment = $(/^\/\*(?:[^*]|\*+[^\/*])*(?:\*+\/\n?|\**$)/)) {
return new(tree.Comment)(comment); return new(tree.Comment)(comment);
} }
}, },