[Pkg-javascript-commits] [less.js] 44/88: Test out some theoretical back tracking and fix bugs

Jonas Smedegaard dr at jones.dk
Mon Oct 26 23:22:25 UTC 2015


This is an automated email from the git hooks/post-receive script.

js pushed a commit to annotated tag v1.7.0
in repository less.js.

commit ef3c63fb9ae920f1e969b707ba296ac6d930e579
Author: Luke Page <luke.a.page at gmail.com>
Date:   Wed Feb 12 23:34:14 2014 +0000

    Test out some theoretical back tracking and fix bugs
---
 lib/less/parser.js | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/lib/less/parser.js b/lib/less/parser.js
index 8231bf8..46c74cf 100644
--- a/lib/less/parser.js
+++ b/lib/less/parser.js
@@ -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;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/less.js.git



More information about the Pkg-javascript-commits mailing list