mirror of
https://github.com/less/less.js.git
synced 2026-04-09 03:00:20 -04:00
Test out some theoretical back tracking and fix bugs
This commit is contained in:
@@ -1138,6 +1138,8 @@ less.Parser = function Parser(env) {
|
||||
expressions = [], argsSemiColon = [], argsComma = [],
|
||||
isSemiColonSeperated, expressionContainsNamed, name, nameLoop, value, arg;
|
||||
|
||||
save();
|
||||
|
||||
while (true) {
|
||||
if (isCall) {
|
||||
arg = parsers.blockRuleset() || parsers.expression();
|
||||
@@ -1183,13 +1185,17 @@ less.Parser = function Parser(env) {
|
||||
}
|
||||
expressionContainsNamed = true;
|
||||
}
|
||||
|
||||
// we do not support setting a ruleset as a default variable - it doesn't make sense
|
||||
// and to implement it we need backtracking with multiple saves
|
||||
// However if we do want to add it, there is nothing blocking it, just don't error
|
||||
// and remove isCall dependency below
|
||||
value = (isCall && parsers.blockRuleset()) || parsers.expression();
|
||||
|
||||
if (!value) {
|
||||
if (isCall) {
|
||||
error("could not understand value for named argument");
|
||||
} else {
|
||||
restore();
|
||||
returner.args = [];
|
||||
return returner;
|
||||
}
|
||||
@@ -1238,6 +1244,7 @@ less.Parser = function Parser(env) {
|
||||
}
|
||||
}
|
||||
|
||||
forget();
|
||||
returner.args = isSemiColonSeperated ? argsSemiColon : argsComma;
|
||||
return returner;
|
||||
},
|
||||
@@ -1302,6 +1309,8 @@ less.Parser = function Parser(env) {
|
||||
} else {
|
||||
restore();
|
||||
}
|
||||
} else {
|
||||
forget();
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -1529,10 +1538,11 @@ less.Parser = function Parser(env) {
|
||||
},
|
||||
rule: function (tryAnonymous) {
|
||||
var name, value, startOfRule = i, c = input.charAt(startOfRule), important, merge, isVariable;
|
||||
save();
|
||||
|
||||
if (c === '.' || c === '#' || c === '&') { return; }
|
||||
|
||||
save();
|
||||
|
||||
name = this.variable() || this.ruleProperty();
|
||||
if (name) {
|
||||
isVariable = typeof name === "string";
|
||||
@@ -1557,6 +1567,7 @@ less.Parser = function Parser(env) {
|
||||
}
|
||||
|
||||
if (value && this.end()) {
|
||||
forget();
|
||||
return new (tree.Rule)(name, value, important, merge, startOfRule, env.currentFileInfo);
|
||||
} else {
|
||||
furthest = i;
|
||||
|
||||
Reference in New Issue
Block a user