3 if (typeof environment === "object" && ({}).toString.call(environment) === "[object Environment]") {
5 // Details on how to detect Rhino: https://github.com/ringo/ringojs/issues/88
9 } else if (typeof(window) === 'undefined') {
12 tree = require('less/tree');
16 if (typeof(window.less) === 'undefined') { window.less = {} }
18 tree = window.less.tree = {};
19 less.mode = 'browser';
24 // A relatively straight-forward predictive parser.
25 // There is no tokenization/lexing stage, the input is parsed
28 // To make the parser fast enough to run in the browser, several
29 // optimization had to be made:
31 // - Matching and slicing on a huge input is often cause of slowdowns.
32 // The solution is to chunkify the input into smaller strings.
33 // The chunks are stored in the `chunks` var,
34 // `j` holds the current chunk index, and `current` holds
35 // the index of the current chunk in relation to `input`.
36 // This gives us an almost 4x speed-up.
38 // - In many cases, we don't need to match individual tokens;
39 // for example, if a value doesn't hold any variables, operations
40 // or dynamic references, the parser can effectively 'skip' it,
41 // treating it as a literal.
42 // An example would be '1px solid #000' - which evaluates to itself,
43 // we don't need to know what the individual components are.
44 // The drawback, of course is that you don't get the benefits of
45 // syntax-checking on the CSS. This gives us a 50% speed-up in the parser,
46 // and a smaller speed-up in the code-gen.
49 // Token matching is done with the `$` function, which either takes
50 // a terminal string or regexp, or a non-terminal function to call.
51 // It also takes care of moving all the indices forwards.
54 less.Parser = function Parser(env) {
55 var input, // LeSS input string
56 i, // current index in `input`
58 temp, // temporarily holds a chunk's state, for backtracking
59 memo, // temporarily holds `i`, when backtracking
60 furthest, // furthest index the parser has gone to
61 chunks, // chunkified input
62 current, // index of current chunk, in `input`
67 // This function is called after all files
68 // have been imported through `@import`.
69 var finish = function () {};
71 var imports = this.imports = {
72 paths: env && env.paths || [], // Search paths, when importing
73 queue: [], // Files which haven't been imported yet
74 files: {}, // Holds the imported parse trees
75 mime: env && env.mime, // MIME type of .less files
76 push: function (path, callback) {
78 this.queue.push(path);
81 // Import a file asynchronously
83 less.Parser.importer(path, this.paths, function (root) {
84 that.queue.splice(that.queue.indexOf(path), 1); // Remove the path from the queue
85 that.files[path] = root; // Store the root
89 if (that.queue.length === 0) { finish() } // Call `finish` if we're done importing
94 function save() { temp = chunks[j], memo = i, current = i }
95 function restore() { chunks[j] = temp, i = memo, current = i }
99 chunks[j] = chunks[j].slice(i - current);
104 // Parse from a token, regexp or string, and move forward if match
107 var match, args, length, c, index, endIndex, k, mem;
112 if (tok instanceof Function) {
113 return tok.call(parser.parsers);
117 // Either match a single character in the input,
118 // or match a regexp in the current chunk (chunk[j]).
120 } else if (typeof(tok) === 'string') {
121 match = input.charAt(i) === tok ? tok : null;
127 if (match = tok.exec(chunks[j])) {
128 length = match[0].length;
134 // The match is confirmed, add the match length to `i`,
135 // and consume any extra white-space characters (' ' || '\n')
136 // which come after that. The reason for this is that LeSS's
137 // grammar is mostly white-space insensitive.
141 endIndex = i + chunks[j].length - length;
143 while (i < endIndex) {
144 c = input.charCodeAt(i);
145 if (! (c === 32 || c === 10 || c === 9)) { break }
148 chunks[j] = chunks[j].slice(length + (i - mem));
151 if (chunks[j].length === 0 && j < chunks.length - 1) { j++ }
153 if(typeof(match) === 'string') {
156 return match.length === 1 ? match[0] : match;
161 // Same as $(), but don't change the state of the parser,
162 // just return the match.
164 if (typeof(tok) === 'string') {
165 return input.charAt(i) === tok;
167 if (tok.test(chunks[j])) {
175 this.env = env = env || {};
177 // The optimization level dictates the thoroughness of the parser,
178 // the lower the number, the less nodes it will create in the tree.
179 // This could matter for debugging, or if you want to access
180 // the individual nodes in the tree.
181 this.optimization = ('optimization' in this.env) ? this.env.optimization : 1;
183 this.env.filename = this.env.filename || null;
192 // Parse an input string into an abstract syntax tree,
193 // call `callback` when done.
195 parse: function (str, callback) {
196 var root, start, end, zone, line, lines, buff = [], c, error = null;
198 i = j = current = furthest = 0;
200 input = str.replace(/\r\n/g, '\n');
202 // Split the input into chunks.
203 chunks = (function (chunks) {
205 skip = /[^"'`\{\}\/\(\)]+/g,
206 comment = /\/\*(?:[^*]|\*+[^\/*])*\*+\/|\/\/.*/g,
213 for (var i = 0, c, cc; i < input.length; i++) {
215 if (match = skip.exec(input)) {
216 if (match.index === i) {
217 i += match[0].length;
218 chunk.push(match[0]);
222 comment.lastIndex = i;
224 if (!inString && !inParam && c === '/') {
225 cc = input.charAt(i + 1);
226 if (cc === '/' || cc === '*') {
227 if (match = comment.exec(input)) {
228 if (match.index === i) {
229 i += match[0].length;
230 chunk.push(match[0]);
237 if (c === '{' && !inString && !inParam) { level ++;
239 } else if (c === '}' && !inString && !inParam) { level --;
241 chunks[++j] = chunk = [];
242 } else if (c === '(' && !inString && !inParam) {
245 } else if (c === ')' && !inString && inParam) {
249 if (c === '"' || c === "'" || c === '`') {
253 inString = inString === c ? false : inString;
262 message: "Missing closing `}`",
263 filename: env.filename
267 return chunks.map(function (c) { return c.join('') });;
270 // Start with the primary rule.
271 // The whole syntax tree is held under a Ruleset node,
272 // with the `root` property set to true, so no `{}` are
273 // output. The callback is called when the input is parsed.
274 root = new(tree.Ruleset)([], $(this.parsers.primary));
277 root.toCSS = (function (evaluate) {
278 var line, lines, column;
280 return function (options, variables) {
283 options = options || {};
285 // Allows setting variables with a hash, so:
287 // `{ color: new(tree.Color)('#f01') }` will become:
289 // new(tree.Rule)('@color',
291 // new(tree.Expression)([
292 // new(tree.Color)('#f01')
297 if (typeof(variables) === 'object' && !Array.isArray(variables)) {
298 variables = Object.keys(variables).map(function (k) {
299 var value = variables[k];
301 if (! (value instanceof tree.Value)) {
302 if (! (value instanceof tree.Expression)) {
303 value = new(tree.Expression)([value]);
305 value = new(tree.Value)([value]);
307 return new(tree.Rule)('@' + k, value, false, 0);
309 frames = [new(tree.Ruleset)(null, variables)];
313 var css = evaluate.call(this, { frames: frames })
314 .toCSS([], { compress: options.compress || false });
316 lines = input.split('\n');
317 line = getLine(e.index);
319 for (var n = e.index, column = -1;
320 n >= 0 && input.charAt(n) !== '\n';
326 filename: env.filename,
328 line: typeof(line) === 'number' ? line + 1 : null,
329 callLine: e.call && (getLine(e.call) + 1),
330 callExtract: lines[getLine(e.call)],
340 if (options.compress) {
341 return css.replace(/(\s)+/g, "$1");
346 function getLine(index) {
347 return index ? (input.slice(0, index).match(/\n/g) || "").length : null;
352 // If `i` is smaller than the `input.length - 1`,
353 // it means the parser wasn't able to parse the whole
354 // string, so we've got a parsing error.
356 // We try to extract a \n delimited string,
357 // showing the line where the parse error occured.
358 // We split it up into two parts (the part which parsed,
359 // and the part which didn't), so we can color them differently.
360 if (i < input.length - 1) {
362 lines = input.split('\n');
363 line = (input.slice(0, i).match(/\n/g) || "").length + 1;
365 for (var n = i, column = -1; n >= 0 && input.charAt(n) !== '\n'; n--) { column++ }
369 message: "Syntax Error on line " + line,
371 filename: env.filename,
382 if (this.imports.queue.length > 0) {
383 finish = function () { callback(error, root) };
385 callback(error, root);
390 // Here in, the parsing rules/functions
392 // The basic structure of the syntax tree generated is as follows:
394 // Ruleset -> Rule -> Value -> Expression -> Entity
396 // Here's some LESS code:
400 // border: 1px solid #000;
405 // And here's what the parse tree might look like:
407 // Ruleset (Selector '.class', [
408 // Rule ("color", Value ([Expression [Color #fff]]))
409 // Rule ("border", Value ([Expression [Dimension 1px][Keyword "solid"][Color #000]]))
410 // Rule ("width", Value ([Expression [Operation "+" [Variable "@w"][Dimension 4px]]]))
411 // Ruleset (Selector [Element '>', '.child'], [...])
414 // In general, most rules will try to parse a token with the `$()` function, and if the return
415 // value is truly, will return a new node, of the relevant type. Sometimes, we need to check
416 // first, before parsing, that's when we use `peek()`.
420 // The `primary` rule is the *entry* and *exit* point of the parser.
421 // The rules here can appear at any level of the parse tree.
423 // The recursive nature of the grammar is an interplay between the `block`
424 // rule, which represents `{ ... }`, the `ruleset` rule, and this `primary` rule,
425 // as represented by this simplified grammar:
427 // primary → (ruleset | rule)+
428 // ruleset → selector+ block
429 // block → '{' primary '}'
431 // Only at one point is the primary rule not called from the
432 // block rule: at the root level.
434 primary: function () {
437 while ((node = $(this.mixin.definition) || $(this.rule) || $(this.ruleset) ||
438 $(this.mixin.call) || $(this.comment) || $(this.directive))
440 node && root.push(node);
445 // We create a Comment node for CSS comments `/* */`,
446 // but keep the LeSS comments `//` silent, by just skipping
448 comment: function () {
451 if (input.charAt(i) !== '/') return;
453 if (input.charAt(i + 1) === '/') {
454 return new(tree.Comment)($(/^\/\/.*/), true);
455 } else if (comment = $(/^\/\*(?:[^*]|\*+[^\/*])*\*+\/\n?/)) {
456 return new(tree.Comment)(comment);
461 // Entities are tokens which can be found inside an Expression
465 // A string, which supports escaping " and '
467 // "milky way" 'he\'s the one!'
469 quoted: function () {
472 if (input.charAt(j) === '~') { j++, e = true } // Escaped strings
473 if (input.charAt(j) !== '"' && input.charAt(j) !== "'") return;
477 if (str = $(/^"((?:[^"\\\r\n]|\\.)*)"|'((?:[^'\\\r\n]|\\.)*)'/)) {
478 return new(tree.Quoted)(str[0], str[1] || str[2], e);
483 // A catch-all word, such as:
485 // black border-collapse
487 keyword: function () {
489 if (k = $(/^[_A-Za-z-][_A-Za-z0-9-]*/)) { return new(tree.Keyword)(k) }
497 // We also try to catch IE's `alpha()`, but let the `alpha` parser
498 // deal with the details.
500 // The arguments are parsed with the `entities.arguments` parser.
503 var name, args, index = i;
505 if (! (name = /^([\w-]+|%)\(/.exec(chunks[j]))) return;
507 name = name[1].toLowerCase();
509 if (name === 'url') { return null }
510 else { i += name.length }
512 if (name === 'alpha') { return $(this.alpha) }
514 $('('); // Parse the '(' and consume whitespace.
516 args = $(this.entities.arguments);
518 if (! $(')')) return;
520 if (name) { return new(tree.Call)(name, args, index) }
522 arguments: function () {
525 while (arg = $(this.expression)) {
527 if (! $(',')) { break }
531 literal: function () {
532 return $(this.entities.dimension) ||
533 $(this.entities.color) ||
534 $(this.entities.quoted);
538 // Parse url() tokens
540 // We use a specific rule for urls, because they don't really behave like
541 // standard function calls. The difference is that the argument doesn't have
542 // to be enclosed within a string, so it can't be parsed as an Expression.
547 if (input.charAt(i) !== 'u' || !$(/^url\(/)) return;
548 value = $(this.entities.quoted) || $(this.entities.variable) ||
549 $(this.entities.dataURI) || $(/^[-\w%@$\/.&=:;#+?~]+/) || "";
550 if (! $(')')) throw new(Error)("missing closing ) for url()");
552 return new(tree.URL)((value.value || value.data || value instanceof tree.Variable)
553 ? value : new(tree.Anonymous)(value), imports.paths);
556 dataURI: function () {
561 obj.mime = $(/^[^\/]+\/[^,;)]+/) || '';
562 obj.charset = $(/^;\s*charset=[^,;)]+/) || '';
563 obj.base64 = $(/^;\s*base64/) || '';
564 obj.data = $(/^,\s*[^)]+/);
566 if (obj.data) { return obj }
571 // A Variable entity, such as `@fink`, in
573 // width: @fink + 2px
575 // We use a different parser for variable definitions,
576 // see `parsers.variable`.
578 variable: function () {
581 if (input.charAt(i) === '@' && (name = $(/^@@?[\w-]+/))) {
582 return new(tree.Variable)(name, index);
587 // A Hexadecimal color
591 // `rgb` and `hsl` colors are parsed through the `entities.call` parser.
596 if (input.charAt(i) === '#' && (rgb = $(/^#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})/))) {
597 return new(tree.Color)(rgb[1]);
602 // A Dimension, that is, a number and a unit
606 dimension: function () {
607 var value, c = input.charCodeAt(i);
608 if ((c > 57 || c < 45) || c === 47) return;
610 if (value = $(/^(-?\d*\.?\d+)(px|%|em|rem|pc|ex|in|deg|s|ms|pt|cm|mm|rad|grad|turn)?/)) {
611 return new(tree.Dimension)(value[1], value[2]);
616 // JavaScript code to be evaluated
618 // `window.location.href`
620 javascript: function () {
623 if (input.charAt(j) === '~') { j++, e = true } // Escaped strings
624 if (input.charAt(j) !== '`') { return }
628 if (str = $(/^`([^`]*)`/)) {
629 return new(tree.JavaScript)(str[1], i, e);
635 // The variable part of a variable definition. Used in the `rule` parser
639 variable: function () {
642 if (input.charAt(i) === '@' && (name = $(/^(@[\w-]+)\s*:/))) { return name[1] }
646 // A font size/line-height shorthand
650 // We need to peek first, or we'll match on keywords and dimensions
652 shorthand: function () {
655 if (! peek(/^[@\w.%-]+\/[@\w.-]+/)) return;
657 if ((a = $(this.entity)) && $('/') && (b = $(this.entity))) {
658 return new(tree.Shorthand)(a, b);
667 // A Mixin call, with an optional argument list
669 // #mixins > .square(#fff);
670 // .rounded(4px, black);
673 // The `while` loop is there because mixins can be
674 // namespaced, but we only support the child and descendant
678 var elements = [], e, c, args, index = i, s = input.charAt(i);
680 if (s !== '.' && s !== '#') { return }
682 while (e = $(/^[#.](?:[\w-]|\\(?:[a-fA-F0-9]{1,6} ?|[^a-fA-F0-9]))+/)) {
683 elements.push(new(tree.Element)(c, e));
686 $('(') && (args = $(this.entities.arguments)) && $(')');
688 if (elements.length > 0 && ($(';') || peek('}'))) {
689 return new(tree.mixin.Call)(elements, args, index);
694 // A Mixin definition, with a list of parameters
696 // .rounded (@radius: 2px, @color) {
700 // Until we have a finer grained state-machine, we have to
701 // do a look-ahead, to make sure we don't have a mixin call.
702 // See the `rule` function for more information.
704 // We start by matching `.rounded (`, and then proceed on to
705 // the argument list, which has optional default values.
706 // We store the parameters in `params`, with a `value` key,
707 // if there is a value, such as in the case of `@radius`.
709 // Once we've got our params list, and a closing `)`, we parse
710 // the `{...}` block.
712 definition: function () {
713 var name, params = [], match, ruleset, param, value;
715 if ((input.charAt(i) !== '.' && input.charAt(i) !== '#') ||
716 peek(/^[^{]*(;|})/)) return;
718 if (match = $(/^([#.](?:[\w-]|\\(?:[a-fA-F0-9]{1,6} ?|[^a-fA-F0-9]))+)\s*\(/)) {
721 while (param = $(this.entities.variable) || $(this.entities.literal)
722 || $(this.entities.keyword)) {
724 if (param instanceof tree.Variable) {
726 if (value = $(this.expression)) {
727 params.push({ name: param.name, value: value });
729 throw new(Error)("Expected value");
732 params.push({ name: param.name });
735 params.push({ value: param });
737 if (! $(',')) { break }
739 if (! $(')')) throw new(Error)("Expected )");
741 ruleset = $(this.block);
744 return new(tree.mixin.Definition)(name, params, ruleset);
751 // Entities are the smallest recognized token,
752 // and can be found inside a rule's value.
754 entity: function () {
755 return $(this.entities.literal) || $(this.entities.variable) || $(this.entities.url) ||
756 $(this.entities.call) || $(this.entities.keyword) || $(this.entities.javascript) ||
761 // A Rule terminator. Note that we use `peek()` to check for '}',
762 // because the `block` rule will be expecting it, but we still need to make sure
763 // it's there, if ';' was ommitted.
766 return $(';') || peek('}');
770 // IE's alpha function
777 if (! $(/^\(opacity=/i)) return;
778 if (value = $(/^\d+/) || $(this.entities.variable)) {
779 if (! $(')')) throw new(Error)("missing closing ) for alpha()");
780 return new(tree.Alpha)(value);
785 // A Selector Element
790 // input[type="text"]
792 // Elements are the building blocks for Selectors,
793 // they are made out of a `Combinator` (see combinator rule),
794 // and an element name, such as a tag a class, or `*`.
796 element: function () {
799 c = $(this.combinator);
800 e = $(/^(?:[.#]?|:*)(?:[\w-]|\\(?:[a-fA-F0-9]{1,6} ?|[^a-fA-F0-9]))+/) || $('*') || $(this.attribute) || $(/^\([^)@]+\)/) || $(/^(?:\d*\.)?\d+%/);
802 if (e) { return new(tree.Element)(c, e) }
804 if (c.value && c.value[0] === '&') {
805 return new(tree.Element)(c, null);
810 // Combinators combine elements together, in a Selector.
812 // Because our parser isn't white-space sensitive, special care
813 // has to be taken, when parsing the descendant combinator, ` `,
814 // as it's an empty space. We have to check the previous character
815 // in the input, to see if it's a ` ` character. More info on how
816 // we deal with this in *combinator.js*.
818 combinator: function () {
819 var match, c = input.charAt(i);
821 if (c === '>' || c === '+' || c === '~') {
823 while (input.charAt(i) === ' ') { i++ }
824 return new(tree.Combinator)(c);
825 } else if (c === '&') {
828 if(input.charAt(i) === ' ') {
831 while (input.charAt(i) === ' ') { i++ }
832 return new(tree.Combinator)(match);
833 } else if (c === ':' && input.charAt(i + 1) === ':') {
835 while (input.charAt(i) === ' ') { i++ }
836 return new(tree.Combinator)('::');
837 } else if (input.charAt(i - 1) === ' ') {
838 return new(tree.Combinator)(" ");
840 return new(tree.Combinator)(null);
850 // Selectors are made out of one or more Elements, see above.
852 selector: function () {
853 var sel, e, elements = [], c, match;
855 while (e = $(this.element)) {
858 if (c === '{' || c === '}' || c === ';' || c === ',') { break }
861 if (elements.length > 0) { return new(tree.Selector)(elements) }
864 return $(/^[a-zA-Z][a-zA-Z-]*[0-9]?/) || $('*');
866 attribute: function () {
867 var attr = '', key, val, op;
869 if (! $('[')) return;
871 if (key = $(/^[a-zA-Z-]+/) || $(this.entities.quoted)) {
872 if ((op = $(/^[|~*$^]?=/)) &&
873 (val = $(this.entities.quoted) || $(/^[\w-]+/))) {
874 attr = [key, op, val.toCSS ? val.toCSS() : val].join('');
875 } else { attr = key }
878 if (! $(']')) return;
880 if (attr) { return "[" + attr + "]" }
884 // The `block` rule is used by `ruleset` and `mixin.definition`.
885 // It's a wrapper around the `primary` rule, with added `{}`.
890 if ($('{') && (content = $(this.primary)) && $('}')) {
896 // div, .class, body > p {...}
898 ruleset: function () {
899 var selectors = [], s, rules, match;
902 while (s = $(this.selector)) {
905 if (! $(',')) { break }
909 if (selectors.length > 0 && (rules = $(this.block))) {
910 return new(tree.Ruleset)(selectors, rules);
918 var name, value, c = input.charAt(i), important, match;
921 if (c === '.' || c === '#' || c === '&') { return }
923 if (name = $(this.variable) || $(this.property)) {
924 if ((name.charAt(0) != '@') && (match = /^([^@+\/'"*`(;{}-]*);/.exec(chunks[j]))) {
925 i += match[0].length - 1;
926 value = new(tree.Anonymous)(match[1]);
927 } else if (name === "font") {
928 value = $(this.font);
930 value = $(this.value);
932 important = $(this.important);
934 if (value && $(this.end)) {
935 return new(tree.Rule)(name, value, important, memo);
944 // An @import directive
948 // Depending on our environemnt, importing is done differently:
949 // In the browser, it's an XHR request, in Node, it would be a
950 // file-system operation. The function used for importing is
951 // stored in `import`, which we pass to the Import constructor.
953 "import": function () {
955 if ($(/^@import\s+/) &&
956 (path = $(this.entities.quoted) || $(this.entities.url)) &&
958 return new(tree.Import)(path, imports);
967 directive: function () {
968 var name, value, rules, types;
970 if (input.charAt(i) !== '@') return;
972 if (value = $(this['import'])) {
974 } else if (name = $(/^@media|@page/) || $(/^@(?:-webkit-|-moz-)?keyframes/)) {
975 types = ($(/^[^{]+/) || '').trim();
976 if (rules = $(this.block)) {
977 return new(tree.Directive)(name + " " + types, rules);
979 } else if (name = $(/^@[-a-z]+/)) {
980 if (name === '@font-face') {
981 if (rules = $(this.block)) {
982 return new(tree.Directive)(name, rules);
984 } else if ((value = $(this.entity)) && $(';')) {
985 return new(tree.Directive)(name, value);
990 var value = [], expression = [], weight, shorthand, font, e;
992 while (e = $(this.shorthand) || $(this.entity)) {
995 value.push(new(tree.Expression)(expression));
998 while (e = $(this.expression)) {
1000 if (! $(',')) { break }
1003 return new(tree.Value)(value);
1007 // A Value is a comma-delimited list of Expressions
1009 // font-family: Baskerville, Georgia, serif;
1011 // In a Rule, a Value represents everything after the `:`,
1012 // and before the `;`.
1014 value: function () {
1015 var e, expressions = [], important;
1017 while (e = $(this.expression)) {
1018 expressions.push(e);
1019 if (! $(',')) { break }
1022 if (expressions.length > 0) {
1023 return new(tree.Value)(expressions);
1026 important: function () {
1027 if (input.charAt(i) === '!') {
1028 return $(/^! *important/);
1034 if ($('(') && (e = $(this.expression)) && $(')')) {
1038 multiplication: function () {
1039 var m, a, op, operation;
1040 if (m = $(this.operand)) {
1041 while ((op = ($('/') || $('*'))) && (a = $(this.operand))) {
1042 operation = new(tree.Operation)(op, [operation || m, a]);
1044 return operation || m;
1047 addition: function () {
1048 var m, a, op, operation;
1049 if (m = $(this.multiplication)) {
1050 while ((op = $(/^[-+]\s+/) || (input.charAt(i - 1) != ' ' && ($('+') || $('-')))) &&
1051 (a = $(this.multiplication))) {
1052 operation = new(tree.Operation)(op, [operation || m, a]);
1054 return operation || m;
1059 // An operand is anything that can be part of an operation,
1060 // such as a Color, or a Variable
1062 operand: function () {
1063 var negate, p = input.charAt(i + 1);
1065 if (input.charAt(i) === '-' && (p === '@' || p === '(')) { negate = $('-') }
1066 var o = $(this.sub) || $(this.entities.dimension) ||
1067 $(this.entities.color) || $(this.entities.variable) ||
1068 $(this.entities.call);
1069 return negate ? new(tree.Operation)('*', [new(tree.Dimension)(-1), o])
1074 // Expressions either represent mathematical operations,
1075 // or white-space delimited Entities.
1080 expression: function () {
1081 var e, delim, entities = [], d;
1083 while (e = $(this.addition) || $(this.entity)) {
1086 if (entities.length > 0) {
1087 return new(tree.Expression)(entities);
1090 property: function () {
1093 if (name = $(/^(\*?-?[-a-z_0-9]+)\s*:/)) {
1101 if (less.mode === 'browser' || less.mode === 'rhino') {
1103 // Used by `@import` directives
1105 less.Parser.importer = function (path, paths, callback, env) {
1106 if (path.charAt(0) !== '/' && paths.length > 0) {
1107 path = paths[0] + path;
1109 // We pass `true` as 3rd argument, to force the reload of the import.
1110 // This is so we can get the syntax tree as opposed to just the CSS output,
1111 // as we need this to evaluate the current stylesheet.
1112 loadStyleSheet({ href: path, title: path, type: env.mime }, callback, true);