Use anonymous functions for the parsers.. It saves us some file size.
This commit is contained in:
parent
46060d466f
commit
76eb332b24
@ -180,7 +180,7 @@ less.parser = {
|
||||
return root;
|
||||
},
|
||||
parsers: {
|
||||
primary: function primary(root) {
|
||||
primary: function (root) {
|
||||
var node;
|
||||
|
||||
while (node = $(this.ruleset, []) || $(this.rule) || $(this.mixin.definition, []) ||
|
||||
@ -191,7 +191,7 @@ less.parser = {
|
||||
return root;
|
||||
},
|
||||
entities: {
|
||||
string: function string() {
|
||||
string: function () {
|
||||
var str;
|
||||
if (input[i] !== '"' && input[i] !== "'") return;
|
||||
|
||||
@ -199,11 +199,11 @@ less.parser = {
|
||||
return new(tree.Quoted)(str);
|
||||
}
|
||||
},
|
||||
keyword: function keyword() {
|
||||
keyword: function () {
|
||||
var k;
|
||||
if (k = $(/[A-Za-z-]+/g)) { return new(tree.Keyword)(k) }
|
||||
},
|
||||
call: function call() {
|
||||
call: function () {
|
||||
var name, args;
|
||||
|
||||
if (! (name = $(/([a-zA-Z0-9_-]+)\(/g))) return;
|
||||
@ -216,7 +216,7 @@ less.parser = {
|
||||
|
||||
if (name) { return new(tree.Call)(name[1], args) }
|
||||
},
|
||||
arguments: function arguments() {
|
||||
arguments: function () {
|
||||
var args = [], arg;
|
||||
|
||||
while (arg = $(this.expression)) {
|
||||
@ -225,14 +225,14 @@ less.parser = {
|
||||
}
|
||||
return args;
|
||||
},
|
||||
accessor: function accessor() {
|
||||
accessor: function () {
|
||||
},
|
||||
literal: function literal() {
|
||||
literal: function () {
|
||||
return $(this.entities.dimension) ||
|
||||
$(this.entities.color) ||
|
||||
$(this.entities.string);
|
||||
},
|
||||
url: function url() {
|
||||
url: function () {
|
||||
var value;
|
||||
|
||||
if (! $(/url\(/g)) return;
|
||||
@ -241,9 +241,9 @@ less.parser = {
|
||||
|
||||
return new(tree.URL)(value);
|
||||
},
|
||||
font: function font() {
|
||||
font: function () {
|
||||
},
|
||||
variable: function variable(def) {
|
||||
variable: function (def) {
|
||||
var name;
|
||||
|
||||
if (input[i] !== '@') return;
|
||||
@ -251,7 +251,7 @@ less.parser = {
|
||||
if (def && (name = $(/(@[a-zA-Z0-9_-]+)\s*:/g))) { return name[1] }
|
||||
else if (!def && (name = $(/@[a-zA-Z0-9_-]+/g))) { return new(tree.Variable)(name) }
|
||||
},
|
||||
color: function color() {
|
||||
color: function () {
|
||||
var rgb;
|
||||
|
||||
if (input[i] !== '#') return;
|
||||
@ -259,7 +259,7 @@ less.parser = {
|
||||
return new(tree.Color)(rgb[1]);
|
||||
}
|
||||
},
|
||||
dimension: function dimension() {
|
||||
dimension: function () {
|
||||
var value;
|
||||
|
||||
if (value = $(/(-?[0-9]*\.?[0-9]+)(px|%|em|pc|ex|in|deg|s|ms|pt|cm|mm)?/g)) {
|
||||
@ -268,7 +268,7 @@ less.parser = {
|
||||
}
|
||||
},
|
||||
mixin: {
|
||||
call: function mixinCall() {
|
||||
call: function () {
|
||||
var prefix, mixin, mixins = [];
|
||||
|
||||
if (input[i] !== '.') return;
|
||||
@ -281,7 +281,7 @@ less.parser = {
|
||||
return new(tree.mixin.Call)(mixins);
|
||||
}
|
||||
},
|
||||
definition: function mixinDefinition(root) {
|
||||
definition: function (root) {
|
||||
var name, params = [], match, ruleset, param, value;
|
||||
|
||||
if (input[i] !== '.' || peek(/[^{]*(;|})/g)) return;
|
||||
@ -311,7 +311,7 @@ less.parser = {
|
||||
}
|
||||
}
|
||||
},
|
||||
entity: function entity() {
|
||||
entity: function () {
|
||||
var entities = [
|
||||
"url", "variable", "call", "accessor",
|
||||
"keyword", "literal", "font"
|
||||
@ -323,7 +323,7 @@ less.parser = {
|
||||
}
|
||||
}
|
||||
},
|
||||
alpha: function alpha() {
|
||||
alpha: function () {
|
||||
var value;
|
||||
|
||||
if (! $(/opacity=/gi)) return;
|
||||
@ -332,7 +332,7 @@ less.parser = {
|
||||
return new(tree.Alpha)(value);
|
||||
}
|
||||
},
|
||||
combinator: function combinator() {
|
||||
combinator: function () {
|
||||
var match;
|
||||
if (match = $(/[+>~]/g) || $('&') || $(/::/g)) {
|
||||
return new(tree.Combinator)(match);
|
||||
@ -340,14 +340,14 @@ less.parser = {
|
||||
return new(tree.Combinator);
|
||||
}
|
||||
},
|
||||
selector: function selector() {
|
||||
selector: function () {
|
||||
var sel, e, elements = [], match;
|
||||
|
||||
while (e = $(this.element)) { elements.push(e) }
|
||||
|
||||
if (elements.length > 0) { return new(tree.Selector)(elements) }
|
||||
},
|
||||
element: function element() {
|
||||
element: function () {
|
||||
var e, t;
|
||||
|
||||
c = $(this.combinator);
|
||||
@ -355,10 +355,10 @@ less.parser = {
|
||||
|
||||
if (e) { return new(tree.Element)(c, e) }
|
||||
},
|
||||
tag: function tag() {
|
||||
tag: function () {
|
||||
return $(/[a-zA-Z][a-zA-Z-]*[0-9]?/g) || $('*');
|
||||
},
|
||||
attribute: function attribute() {
|
||||
attribute: function () {
|
||||
var attr = '', key, val, op;
|
||||
|
||||
if (! $('[')) return;
|
||||
@ -374,14 +374,14 @@ less.parser = {
|
||||
|
||||
if (attr) { return "[" + attr + "]" }
|
||||
},
|
||||
block: function block(node) {
|
||||
block: function (node) {
|
||||
var content;
|
||||
|
||||
if ($('{') && (content = $(this.primary, node)) && $('}')) {
|
||||
return content;
|
||||
}
|
||||
},
|
||||
ruleset: function ruleset(root) {
|
||||
ruleset: function (root) {
|
||||
var selectors = [], s, rules, match;
|
||||
|
||||
if (peek(/[^{]+[;}]/g)) return;
|
||||
@ -402,7 +402,7 @@ less.parser = {
|
||||
return new(tree.Ruleset)(selectors, rules);
|
||||
}
|
||||
},
|
||||
rule: function rule() {
|
||||
rule: function () {
|
||||
var name, value, match;
|
||||
|
||||
if (name = $(this.property) || $(this.entities.variable, true)) {
|
||||
@ -415,7 +415,7 @@ less.parser = {
|
||||
}
|
||||
}
|
||||
},
|
||||
directive: function directive(root) {
|
||||
directive: function (root) {
|
||||
var name, value, rules, types;
|
||||
|
||||
if (input[i] !== '@') return;
|
||||
@ -435,7 +435,7 @@ less.parser = {
|
||||
}
|
||||
}
|
||||
},
|
||||
value: function value() {
|
||||
value: function () {
|
||||
var e, expressions = [], important;
|
||||
|
||||
while (e = $(this.expression)) {
|
||||
@ -448,7 +448,7 @@ less.parser = {
|
||||
return new(tree.Value)(expressions, important);
|
||||
}
|
||||
},
|
||||
sub: function sub() {
|
||||
sub: function () {
|
||||
var e;
|
||||
|
||||
if ($('(') && (e = $(this.expression)) && $(')')) {
|
||||
@ -483,7 +483,7 @@ less.parser = {
|
||||
return o;
|
||||
}
|
||||
},
|
||||
expression: function expression() {
|
||||
expression: function () {
|
||||
var e, delim, entities = [], d;
|
||||
|
||||
while (e = $(this.addition) || $(this.entity)) {
|
||||
@ -493,7 +493,7 @@ less.parser = {
|
||||
return new(tree.Expression)(entities);
|
||||
}
|
||||
},
|
||||
property: function property() {
|
||||
property: function () {
|
||||
var name;
|
||||
|
||||
if (name = $(/(\*?-?[-a-z]+)\s*:/g)) {
|
||||
|
Loading…
Reference in New Issue
Block a user