mirror of
https://github.com/less/less.js.git
synced 2026-04-09 03:00:20 -04:00
make operations left-associative Closes #20
This commit is contained in:
@@ -827,24 +827,22 @@ less.Parser = function Parser(env) {
|
||||
}
|
||||
},
|
||||
multiplication: function () {
|
||||
var m, a, op;
|
||||
var m, a, op, operation;
|
||||
if (m = $(this.operand)) {
|
||||
if ((op = $(/[\/*]/g)) && (a = $(this.multiplication))) {
|
||||
return new(tree.Operation)(op, [m, a]);
|
||||
} else {
|
||||
return m;
|
||||
while ((op = $(/[\/*]/g)) && (a = $(this.operand))) {
|
||||
operation = new(tree.Operation)(op, [operation || m, a]);
|
||||
}
|
||||
return operation || m;
|
||||
}
|
||||
},
|
||||
addition: function () {
|
||||
var m, a, op;
|
||||
var m, a, op, operation;
|
||||
if (m = $(this.multiplication)) {
|
||||
if ((op = $(/[-+]\s+/g) || (input[i - 1] != ' ' && $(/[-+]/g))) &&
|
||||
(a = $(this.addition))) {
|
||||
return new(tree.Operation)(op, [m, a]);
|
||||
} else {
|
||||
return m;
|
||||
while ((op = $(/[-+]\s+/g) || (input[i - 1] != ' ' && $(/[-+]/g))) &&
|
||||
(a = $(this.multiplication))) {
|
||||
operation = new(tree.Operation)(op, [operation || m, a]);
|
||||
}
|
||||
return operation || m;
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user