mirror of
https://github.com/less/less.js.git
synced 2026-05-01 03:00:22 -04:00
Minor fixes. #1615
This commit is contained in:
@@ -368,7 +368,6 @@ less.Parser = function Parser(env) {
|
||||
k, ko, cc, cc2, matched;
|
||||
|
||||
function fail(msg, index) {
|
||||
index = index || k;
|
||||
error = new(LessError)({
|
||||
index: index || k,
|
||||
type: 'Parse',
|
||||
@@ -409,8 +408,7 @@ less.Parser = function Parser(env) {
|
||||
continue;
|
||||
case 92: // \
|
||||
if (k < len - 1) { k++; continue; }
|
||||
fail("unescaped '\\'");
|
||||
break;
|
||||
return fail("unescaped `\\`");
|
||||
case 34:
|
||||
case 39:
|
||||
case 96: // ", ' and `
|
||||
@@ -422,17 +420,13 @@ less.Parser = function Parser(env) {
|
||||
if (cc2 == cc) { matched = 1; break; }
|
||||
if (cc2 == 92) { // \
|
||||
if (k == len - 1) {
|
||||
fail("unescaped '\\'");
|
||||
break;
|
||||
return fail("unescaped `\\`");
|
||||
}
|
||||
k++;
|
||||
}
|
||||
}
|
||||
if (matched) { continue; }
|
||||
if (!error) {
|
||||
fail("unmatched '" + String.fromCharCode(cc) + "'", ko);
|
||||
}
|
||||
break;
|
||||
return fail("unmatched `" + String.fromCharCode(cc) + "`", ko);
|
||||
case 47: // /, check for comment
|
||||
if (parenLevel || (k == len - 1)) { continue; }
|
||||
cc2 = input.charCodeAt(k + 1);
|
||||
@@ -452,50 +446,41 @@ less.Parser = function Parser(env) {
|
||||
if (input.charCodeAt(k + 1) == 47) { break; }
|
||||
}
|
||||
if (k == len - 1) {
|
||||
fail("missing closing `*/`", ko);
|
||||
return fail("missing closing `*/`", ko);
|
||||
}
|
||||
}
|
||||
continue;
|
||||
case 42: // *, check for unmatched */
|
||||
if ((k < len - 1) && (input.charCodeAt(k + 1) == 47)) {
|
||||
fail("unmatched `/*`");
|
||||
break;
|
||||
return fail("unmatched `/*`");
|
||||
}
|
||||
continue;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
|
||||
// only reaches here on error
|
||||
break;
|
||||
}
|
||||
|
||||
if (!error) {
|
||||
if (level !== 0) {
|
||||
if (level > 0) {
|
||||
if ((lastMultiComment > lastOpening) && (lastMultiCommentEndBrace > lastMultiComment)) {
|
||||
fail("missing closing `}` or `*/`", lastOpening);
|
||||
} else {
|
||||
fail("missing closing `}`", lastOpening);
|
||||
}
|
||||
if (level !== 0) {
|
||||
if (level > 0) {
|
||||
if ((lastMultiComment > lastOpening) && (lastMultiCommentEndBrace > lastMultiComment)) {
|
||||
return fail("missing closing `}` or `*/`", lastOpening);
|
||||
} else {
|
||||
fail("missing opening `{`", lastClosing);
|
||||
return fail("missing closing `}`", lastOpening);
|
||||
}
|
||||
} else if (checkParenLevel && (parenLevel !== 0)) {
|
||||
fail((parenLevel > 0) ? "missing closing `)`" : "missing opening `(`");
|
||||
}
|
||||
return fail("missing opening `{`", lastClosing);
|
||||
} else if (checkParenLevel && (parenLevel !== 0)) {
|
||||
return fail((parenLevel > 0) ? "missing closing `)`" : "missing opening `(`");
|
||||
}
|
||||
|
||||
emitChunk(true);
|
||||
return chunks;
|
||||
})(str);
|
||||
|
||||
current = chunks[0];
|
||||
|
||||
if (error) {
|
||||
return callback(new(LessError)(error, env));
|
||||
}
|
||||
|
||||
current = chunks[0];
|
||||
|
||||
// Start with the primary rule.
|
||||
// The whole syntax tree is held under a Ruleset node,
|
||||
// with the `root` property set to true, so no `{}` are
|
||||
|
||||
Reference in New Issue
Block a user