Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/gonzales/gonzales-scss.js

Issue 1917863008: DevTools: [SASS] introduce Gonzales-PE for SCSS parsing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebaseline Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 (function webpackUniversalModuleDefinition(root, factory) {
2 if(typeof exports === 'object' && typeof module === 'object')
3 module.exports = factory();
4 else if(typeof define === 'function' && define.amd)
5 define([], factory);
6 else if(typeof exports === 'object')
7 exports["gonzales"] = factory();
8 else
9 root["gonzales"] = factory();
10 })(this, function() {
11 return /******/ (function(modules) { // webpackBootstrap
12 /******/ // The module cache
13 /******/ var installedModules = {};
14
15 /******/ // The require function
16 /******/ function __webpack_require__(moduleId) {
17
18 /******/ // Check if module is in cache
19 /******/ if(installedModules[moduleId])
20 /******/ return installedModules[moduleId].exports;
21
22 /******/ // Create a new module (and put it into the cache)
23 /******/ var module = installedModules[moduleId] = {
24 /******/ exports: {},
25 /******/ id: moduleId,
26 /******/ loaded: false
27 /******/ };
28
29 /******/ // Execute the module function
30 /******/ modules[moduleId].call(module.exports, module, module.ex ports, __webpack_require__);
31
32 /******/ // Flag the module as loaded
33 /******/ module.loaded = true;
34
35 /******/ // Return the exports of the module
36 /******/ return module.exports;
37 /******/ }
38
39
40 /******/ // expose the modules object (__webpack_modules__)
41 /******/ __webpack_require__.m = modules;
42
43 /******/ // expose the module cache
44 /******/ __webpack_require__.c = installedModules;
45
46 /******/ // __webpack_public_path__
47 /******/ __webpack_require__.p = "";
48
49 /******/ // Load entry module and return exports
50 /******/ return __webpack_require__(0);
51 /******/ })
52 /************************************************************************/
53 /******/ ([
54 /* 0 */
55 /***/ function(module, exports, __webpack_require__) {
56
57 'use strict';
58
59 var Node = __webpack_require__(1);
60 var parse = __webpack_require__(7);
61
62 module.exports = {
63 createNode: function (options) {
64 return new Node(options);
65 },
66 parse: parse
67 };
68
69 /***/ },
70 /* 1 */
71 /***/ function(module, exports, __webpack_require__) {
72
73 'use strict';
74
75 /**
76 * @param {string} type
77 * @param {array|string} content
78 * @param {number} line
79 * @param {number} column
80 * @constructor
81 */
82
83 var _createClass = (function () { function defineProperties(target, prop s) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descrip tor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(ta rget, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoPro ps); if (staticProps) defineProperties(Constructor, staticProps); return Constru ctor; }; })();
84
85 function _classCallCheck(instance, Constructor) { if (!(instance instanc eof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
86
87 var Node = (function () {
88 function Node(options) {
89 _classCallCheck(this, Node);
90
91 this.type = options.type;
92 this.content = options.content;
93 this.syntax = options.syntax;
94
95 if (options.start) this.start = options.start;
96 if (options.end) this.end = options.end;
97 }
98
99 /**
100 * @param {String} type Node type
101 * @return {Boolean} Whether there is a child node of given type
102 */
103
104 Node.prototype.contains = function contains(type) {
105 return this.content.some(function (node) {
106 return node.type === type;
107 });
108 };
109
110 /**
111 * @param {String} type Node type
112 * @param {Function} callback Function to call for every found node
113 */
114
115 Node.prototype.eachFor = function eachFor(type, callback) {
116 if (!Array.isArray(this.content)) return;
117
118 if (typeof type !== 'string') {
119 callback = type;
120 type = null;
121 }
122
123 var l = this.content.length;
124 var breakLoop;
125
126 for (var i = l; i--;) {
127 if (breakLoop === null) break;
128
129 if (!type || this.content[i] && this.content[i].type === type) bre akLoop = callback(this.content[i], i, this);
130 }
131
132 if (breakLoop === null) return null;
133 };
134
135 /**
136 * @param {String} type
137 * @return {?Node} First child node or `null` if nothing's been found.
138 */
139
140 Node.prototype.first = function first(type) {
141 if (!Array.isArray(this.content)) return null;
142
143 if (!type) return this.content[0];
144
145 var i = 0;
146 var l = this.content.length;
147
148 for (; i < l; i++) {
149 if (this.content[i].type === type) return this.content[i];
150 }
151
152 return null;
153 };
154
155 /**
156 * @param {String} type Node type
157 * @param {Function} callback Function to call for every found node
158 */
159
160 Node.prototype.forEach = function forEach(type, callback) {
161 if (!Array.isArray(this.content)) return;
162
163 if (typeof type !== 'string') {
164 callback = type;
165 type = null;
166 }
167
168 var i = 0;
169 var l = this.content.length;
170 var breakLoop;
171
172 for (; i < l; i++) {
173 if (breakLoop === null) break;
174
175 if (!type || this.content[i] && this.content[i].type === type) bre akLoop = callback(this.content[i], i, this);
176 }
177
178 if (breakLoop === null) return null;
179 };
180
181 /**
182 * @param {Number} index
183 * @return {?Node}
184 */
185
186 Node.prototype.get = function get(index) {
187 if (!Array.isArray(this.content)) return null;
188
189 var node = this.content[index];
190 return node ? node : null;
191 };
192
193 /**
194 * @param {Number} index
195 * @param {Node} node
196 */
197
198 Node.prototype.insert = function insert(index, node) {
199 if (!Array.isArray(this.content)) return;
200
201 this.content.splice(index, 0, node);
202 };
203
204 /**
205 * @param {String} type
206 * @return {Boolean} Whether the node is of given type
207 */
208
209 Node.prototype.is = function is(type) {
210 return this.type === type;
211 };
212
213 /**
214 * @param {String} type
215 * @return {?Node} Last child node or `null` if nothing's been found.
216 */
217
218 Node.prototype.last = function last(type) {
219 if (!Array.isArray(this.content)) return null;
220
221 var i = this.content.length - 1;
222 if (!type) return this.content[i];
223
224 for (;; i--) {
225 if (this.content[i].type === type) return this.content[i];
226 }
227
228 return null;
229 };
230
231 /**
232 * Number of child nodes.
233 * @type {number}
234 */
235
236 /**
237 * @param {Number} index
238 * @return {Node}
239 */
240
241 Node.prototype.removeChild = function removeChild(index) {
242 if (!Array.isArray(this.content)) return;
243
244 var removedChild = this.content.splice(index, 1);
245
246 return removedChild;
247 };
248
249 Node.prototype.toJson = function toJson() {
250 return JSON.stringify(this, false, 2);
251 };
252
253 Node.prototype.toString = function toString() {
254 var stringify = undefined;
255
256 try {
257 stringify = __webpack_require__(2)("./" + this.syntax + '/stringif y');
258 } catch (e) {
259 var message = 'Syntax "' + this.syntax + '" is not supported yet, sorry';
260 return console.error(message);
261 }
262
263 return stringify(this);
264 };
265
266 /**
267 * @param {Function} callback
268 */
269
270 Node.prototype.traverse = function traverse(callback, index) {
271 var level = arguments.length <= 2 || arguments[2] === undefined ? 0 : arguments[2];
272 var parent = arguments.length <= 3 || arguments[3] === undefined ? n ull : arguments[3];
273
274 var breakLoop;
275 var x;
276
277 level++;
278
279 callback(this, index, parent, level);
280
281 if (!Array.isArray(this.content)) return;
282
283 for (var i = 0, l = this.content.length; i < l; i++) {
284 breakLoop = this.content[i].traverse(callback, i, level, this);
285 if (breakLoop === null) break;
286
287 // If some nodes were removed or added:
288 if (x = this.content.length - l) {
289 l += x;
290 i += x;
291 }
292 }
293
294 if (breakLoop === null) return null;
295 };
296
297 Node.prototype.traverseByType = function traverseByType(type, callback ) {
298 this.traverse(function (node) {
299 if (node.type === type) callback.apply(node, arguments);
300 });
301 };
302
303 Node.prototype.traverseByTypes = function traverseByTypes(types, callb ack) {
304 this.traverse(function (node) {
305 if (types.indexOf(node.type) !== -1) callback.apply(node, argument s);
306 });
307 };
308
309 _createClass(Node, [{
310 key: 'length',
311 get: function () {
312 if (!Array.isArray(this.content)) return 0;
313 return this.content.length;
314 }
315 }]);
316
317 return Node;
318 })();
319
320 module.exports = Node;
321
322 /***/ },
323 /* 2 */
324 /***/ function(module, exports, __webpack_require__) {
325
326 var map = {
327 "./css/stringify": 3,
328 "./less/stringify": 4,
329 "./sass/stringify": 5,
330 "./scss/stringify": 6
331 };
332 function webpackContext(req) {
333 return __webpack_require__(webpackContextResolve(req));
334 };
335 function webpackContextResolve(req) {
336 return map[req] || (function() { throw new Error("Cannot find mo dule '" + req + "'.") }());
337 };
338 webpackContext.keys = function webpackContextKeys() {
339 return Object.keys(map);
340 };
341 webpackContext.resolve = webpackContextResolve;
342 module.exports = webpackContext;
343 webpackContext.id = 2;
344
345
346 /***/ },
347 /* 3 */
348 /***/ function(module, exports) {
349
350 // jscs:disable maximumLineLength
351
352 'use strict';
353
354 module.exports = function stringify(tree) {
355 // TODO: Better error message
356 if (!tree) throw new Error('We need tree to translate');
357
358 function _t(tree) {
359 var type = tree.type;
360 if (_unique[type]) return _unique[type](tree);
361 if (typeof tree.content === 'string') return tree.content;
362 if (Array.isArray(tree.content)) return _composite(tree.content);
363 return '';
364 }
365
366 function _composite(t, i) {
367 if (!t) return '';
368
369 var s = '';
370 i = i || 0;
371 for (; i < t.length; i++) s += _t(t[i]);
372 return s;
373 }
374
375 var _unique = {
376 'arguments': function (t) {
377 return '(' + _composite(t.content) + ')';
378 },
379 'atkeyword': function (t) {
380 return '@' + _composite(t.content);
381 },
382 'attributeSelector': function (t) {
383 return '[' + _composite(t.content) + ']';
384 },
385 'block': function (t) {
386 return '{' + _composite(t.content) + '}';
387 },
388 'brackets': function (t) {
389 return '[' + _composite(t.content) + ']';
390 },
391 'class': function (t) {
392 return '.' + _composite(t.content);
393 },
394 'color': function (t) {
395 return '#' + t.content;
396 },
397 'expression': function (t) {
398 return 'expression(' + t.content + ')';
399 },
400 'id': function (t) {
401 return '#' + _composite(t.content);
402 },
403 'multilineComment': function (t) {
404 return '/*' + t.content + '*/';
405 },
406 'nthSelector': function (t) {
407 return ':' + _t(t.content[0]) + '(' + _composite(t.content.slice(1 )) + ')';
408 },
409 'parentheses': function (t) {
410 return '(' + _composite(t.content) + ')';
411 },
412 'percentage': function (t) {
413 return _composite(t.content) + '%';
414 },
415 'pseudoClass': function (t) {
416 return ':' + _composite(t.content);
417 },
418 'pseudoElement': function (t) {
419 return '::' + _composite(t.content);
420 },
421 'uri': function (t) {
422 return 'url(' + _composite(t.content) + ')';
423 }
424 };
425
426 return _t(tree);
427 };
428
429 /***/ },
430 /* 4 */
431 /***/ function(module, exports) {
432
433 // jscs:disable maximumLineLength
434
435 'use strict';
436
437 module.exports = function stringify(tree) {
438 // TODO: Better error message
439 if (!tree) throw new Error('We need tree to translate');
440
441 function _t(tree) {
442 var type = tree.type;
443 if (_unique[type]) return _unique[type](tree);
444 if (typeof tree.content === 'string') return tree.content;
445 if (Array.isArray(tree.content)) return _composite(tree.content);
446 return '';
447 }
448
449 function _composite(t, i) {
450 if (!t) return '';
451
452 var s = '';
453 i = i || 0;
454 for (; i < t.length; i++) s += _t(t[i]);
455 return s;
456 }
457
458 var _unique = {
459 'arguments': function (t) {
460 return '(' + _composite(t.content) + ')';
461 },
462 'atkeyword': function (t) {
463 return '@' + _composite(t.content);
464 },
465 'attributeSelector': function (t) {
466 return '[' + _composite(t.content) + ']';
467 },
468 'block': function (t) {
469 return '{' + _composite(t.content) + '}';
470 },
471 'brackets': function (t) {
472 return '[' + _composite(t.content) + ']';
473 },
474 'class': function (t) {
475 return '.' + _composite(t.content);
476 },
477 'color': function (t) {
478 return '#' + t.content;
479 },
480 'escapedString': function (t) {
481 return '~' + t.content;
482 },
483 'expression': function (t) {
484 return 'expression(' + t.content + ')';
485 },
486 'id': function (t) {
487 return '#' + _composite(t.content);
488 },
489 'interpolatedVariable': function (t) {
490 return '@{' + _composite(t.content) + '}';
491 },
492 'multilineComment': function (t) {
493 return '/*' + t.content + '*/';
494 },
495 'nthSelector': function (t) {
496 return ':' + _t(t.content[0]) + '(' + _composite(t.content.slice(1 )) + ')';
497 },
498 'parentheses': function (t) {
499 return '(' + _composite(t.content) + ')';
500 },
501 'percentage': function (t) {
502 return _composite(t.content) + '%';
503 },
504 'pseudoClass': function (t) {
505 return ':' + _composite(t.content);
506 },
507 'pseudoElement': function (t) {
508 return '::' + _composite(t.content);
509 },
510 'singlelineComment': function (t) {
511 return '/' + '/' + t.content;
512 },
513 'uri': function (t) {
514 return 'url(' + _composite(t.content) + ')';
515 },
516 'variable': function (t) {
517 return '@' + _composite(t.content);
518 },
519 'variablesList': function (t) {
520 return _composite(t.content) + '...';
521 }
522 };
523
524 return _t(tree);
525 };
526
527 /***/ },
528 /* 5 */
529 /***/ function(module, exports) {
530
531 // jscs:disable maximumLineLength
532
533 'use strict';
534
535 module.exports = function stringify(tree) {
536 // TODO: Better error message
537 if (!tree) throw new Error('We need tree to translate');
538
539 function _t(tree) {
540 var type = tree.type;
541 if (_unique[type]) return _unique[type](tree);
542 if (typeof tree.content === 'string') return tree.content;
543 if (Array.isArray(tree.content)) return _composite(tree.content);
544 return '';
545 }
546
547 function _composite(t, i) {
548 if (!t) return '';
549
550 var s = '';
551 i = i || 0;
552 for (; i < t.length; i++) s += _t(t[i]);
553 return s;
554 }
555
556 var _unique = {
557 'arguments': function (t) {
558 return '(' + _composite(t.content) + ')';
559 },
560 'atkeyword': function (t) {
561 return '@' + _composite(t.content);
562 },
563 'attributeSelector': function (t) {
564 return '[' + _composite(t.content) + ']';
565 },
566 'block': function (t) {
567 return _composite(t.content);
568 },
569 'brackets': function (t) {
570 return '[' + _composite(t.content) + ']';
571 },
572 'class': function (t) {
573 return '.' + _composite(t.content);
574 },
575 'color': function (t) {
576 return '#' + t.content;
577 },
578 'expression': function (t) {
579 return 'expression(' + t.content + ')';
580 },
581 'id': function (t) {
582 return '#' + _composite(t.content);
583 },
584 'interpolation': function (t) {
585 return '#{' + _composite(t.content) + '}';
586 },
587 'multilineComment': function (t) {
588 return '/*' + t.content;
589 },
590 'nthSelector': function (t) {
591 return ':' + _t(t.content[0]) + '(' + _composite(t.content.slice(1 )) + ')';
592 },
593 'parentheses': function (t) {
594 return '(' + _composite(t.content) + ')';
595 },
596 'percentage': function (t) {
597 return _composite(t.content) + '%';
598 },
599 'placeholder': function (t) {
600 return '%' + _composite(t.content);
601 },
602 'pseudoClass': function (t) {
603 return ':' + _composite(t.content);
604 },
605 'pseudoElement': function (t) {
606 return '::' + _composite(t.content);
607 },
608 'singlelineComment': function (t) {
609 return '/' + '/' + t.content;
610 },
611 'uri': function (t) {
612 return 'url(' + _composite(t.content) + ')';
613 },
614 'variable': function (t) {
615 return '$' + _composite(t.content);
616 },
617 'variablesList': function (t) {
618 return _composite(t.content) + '...';
619 }
620 };
621
622 return _t(tree);
623 };
624
625 /***/ },
626 /* 6 */
627 /***/ function(module, exports) {
628
629 // jscs:disable maximumLineLength
630
631 'use strict';
632
633 module.exports = function stringify(tree) {
634 // TODO: Better error message
635 if (!tree) throw new Error('We need tree to translate');
636
637 function _t(tree) {
638 var type = tree.type;
639 if (_unique[type]) return _unique[type](tree);
640 if (typeof tree.content === 'string') return tree.content;
641 if (Array.isArray(tree.content)) return _composite(tree.content);
642 return '';
643 }
644
645 function _composite(t, i) {
646 if (!t) return '';
647
648 var s = '';
649 i = i || 0;
650 for (; i < t.length; i++) s += _t(t[i]);
651 return s;
652 }
653
654 var _unique = {
655 'arguments': function (t) {
656 return '(' + _composite(t.content) + ')';
657 },
658 'atkeyword': function (t) {
659 return '@' + _composite(t.content);
660 },
661 'attributeSelector': function (t) {
662 return '[' + _composite(t.content) + ']';
663 },
664 'block': function (t) {
665 return '{' + _composite(t.content) + '}';
666 },
667 'brackets': function (t) {
668 return '[' + _composite(t.content) + ']';
669 },
670 'class': function (t) {
671 return '.' + _composite(t.content);
672 },
673 'color': function (t) {
674 return '#' + t.content;
675 },
676 'expression': function (t) {
677 return 'expression(' + t.content + ')';
678 },
679 'id': function (t) {
680 return '#' + _composite(t.content);
681 },
682 'interpolation': function (t) {
683 return '#{' + _composite(t.content) + '}';
684 },
685 'multilineComment': function (t) {
686 return '/*' + t.content + '*/';
687 },
688 'nthSelector': function (t) {
689 return ':' + _t(t.content[0]) + '(' + _composite(t.content.slice(1 )) + ')';
690 },
691 'parentheses': function (t) {
692 return '(' + _composite(t.content) + ')';
693 },
694 'percentage': function (t) {
695 return _composite(t.content) + '%';
696 },
697 'placeholder': function (t) {
698 return '%' + _composite(t.content);
699 },
700 'pseudoClass': function (t) {
701 return ':' + _composite(t.content);
702 },
703 'pseudoElement': function (t) {
704 return '::' + _composite(t.content);
705 },
706 'singlelineComment': function (t) {
707 return '/' + '/' + t.content;
708 },
709 'uri': function (t) {
710 return 'url(' + _composite(t.content) + ')';
711 },
712 'variable': function (t) {
713 return '$' + _composite(t.content);
714 },
715 'variablesList': function (t) {
716 return _composite(t.content) + '...';
717 }
718 };
719
720 return _t(tree);
721 };
722
723 /***/ },
724 /* 7 */
725 /***/ function(module, exports, __webpack_require__) {
726
727 'use strict';
728
729 var ParsingError = __webpack_require__(8);
730 var syntaxes = __webpack_require__(10);
731
732 var isInteger = Number.isInteger || function (value) {
733 return typeof value === 'number' && Math.floor(value) === value;
734 };
735
736 /**
737 * @param {String} css
738 * @param {Object} options
739 * @return {Object} AST
740 */
741 function parser(css, options) {
742 if (typeof css !== 'string') throw new Error('Please, pass a string to parse');else if (!css) return __webpack_require__(16)();
743
744 var syntax = options && options.syntax || 'css';
745 var context = options && options.context || 'stylesheet';
746 var tabSize = options && options.tabSize;
747 if (!isInteger(tabSize) || tabSize < 1) tabSize = 1;
748
749 var syntaxParser = undefined;
750 if (syntaxes[syntax]) {
751 syntaxParser = syntaxes[syntax];
752 } else {
753 syntaxParser = syntaxes;
754 }
755
756 if (!syntaxParser) {
757 var message = 'Syntax "' + syntax + '" is not supported yet, sorry';
758 return console.error(message);
759 }
760
761 var getTokens = syntaxParser.tokenizer;
762 var mark = syntaxParser.mark;
763 var parse = syntaxParser.parse;
764
765 var tokens = getTokens(css, tabSize);
766 mark(tokens);
767
768 var ast;
769 try {
770 ast = parse(tokens, context);
771 } catch (e) {
772 if (!e.syntax) throw e;
773 throw new ParsingError(e, css);
774 }
775
776 return ast;
777 }
778
779 module.exports = parser;
780
781 /***/ },
782 /* 8 */
783 /***/ function(module, exports, __webpack_require__) {
784
785 'use strict';
786
787 var parserPackage = __webpack_require__(9);
788
789 /**
790 * @param {Error} e
791 * @param {String} css
792 */
793 function ParsingError(e, css) {
794 this.line = e.line;
795 this.syntax = e.syntax;
796 this.css_ = css;
797 }
798
799 ParsingError.prototype = Object.defineProperties({
800 /**
801 * @type {String}
802 * @private
803 */
804 customMessage_: '',
805
806 /**
807 * @type {Number}
808 */
809 line: null,
810
811 /**
812 * @type {String}
813 */
814 name: 'Parsing error',
815
816 /**
817 * @type {String}
818 */
819 syntax: null,
820
821 /**
822 * @type {String}
823 */
824 version: parserPackage.version,
825
826 /**
827 * @return {String}
828 */
829 toString: function () {
830 return [this.name + ': ' + this.message, '', this.context, '', 'Synt ax: ' + this.syntax, 'Gonzales PE version: ' + this.version].join('\n');
831 }
832 }, {
833 context: { /**
834 * @type {String}
835 */
836
837 get: function () {
838 var LINES_AROUND = 2;
839
840 var result = [];
841 var currentLineNumber = this.line;
842 var start = currentLineNumber - 1 - LINES_AROUND;
843 var end = currentLineNumber + LINES_AROUND;
844 var lines = this.css_.split(/\r\n|\r|\n/);
845
846 for (var i = start; i < end; i++) {
847 var line = lines[i];
848 if (!line) continue;
849 var ln = i + 1;
850 var mark = ln === currentLineNumber ? '*' : ' ';
851 result.push(ln + mark + '| ' + line);
852 }
853
854 return result.join('\n');
855 },
856 configurable: true,
857 enumerable: true
858 },
859 message: {
860
861 /**
862 * @type {String}
863 */
864
865 get: function () {
866 if (this.customMessage_) {
867 return this.customMessage_;
868 } else {
869 var message = 'Please check validity of the block';
870 if (typeof this.line === 'number') message += ' starting from li ne #' + this.line;
871 return message;
872 }
873 },
874 set: function (message) {
875 this.customMessage_ = message;
876 },
877 configurable: true,
878 enumerable: true
879 }
880 });
881
882 module.exports = ParsingError;
883
884 /***/ },
885 /* 9 */
886 /***/ function(module, exports) {
887
888 module.exports = {
889 "name": "gonzales-pe",
890 "description": "Gonzales Preprocessor Edition (fast CSS parser)" ,
891 "version": "3.3.1",
892 "homepage": "http://github.com/tonyganch/gonzales-pe",
893 "bugs": "http://github.com/tonyganch/gonzales-pe/issues",
894 "license": "MIT",
895 "author": {
896 "name": "Tony Ganch",
897 "email": "tonyganch+github@gmail.com",
898 "url": "http://tonyganch.com"
899 },
900 "main": "./lib/gonzales",
901 "repository": {
902 "type": "git",
903 "url": "http://github.com/tonyganch/gonzales-pe.git"
904 },
905 "scripts": {
906 "autofix-tests": "bash ./scripts/build.sh && bash ./scri pts/autofix-tests.sh",
907 "build": "bash ./scripts/build.sh",
908 "init": "bash ./scripts/init.sh",
909 "log": "bash ./scripts/log.sh",
910 "prepublish": "bash ./scripts/prepublish.sh",
911 "postpublish": "bash ./scripts/postpublish.sh",
912 "test": "bash ./scripts/build.sh && bash ./scripts/test. sh",
913 "watch": "bash ./scripts/watch.sh"
914 },
915 "bin": {
916 "gonzales": "./bin/gonzales.js"
917 },
918 "dependencies": {
919 "minimist": "1.1.x"
920 },
921 "devDependencies": {
922 "babel-loader": "^5.3.2",
923 "coffee-script": "~1.7.1",
924 "jscs": "2.1.0",
925 "jshint": "2.8.0",
926 "json-loader": "^0.5.3",
927 "mocha": "2.2.x",
928 "webpack": "^1.12.2"
929 },
930 "engines": {
931 "node": ">=0.6.0"
932 }
933 };
934
935 /***/ },
936 /* 10 */
937 /***/ function(module, exports, __webpack_require__) {
938
939 'use strict';
940
941 exports.__esModule = true;
942 exports['default'] = {
943 mark: __webpack_require__(11),
944 parse: __webpack_require__(13),
945 stringify: __webpack_require__(6),
946 tokenizer: __webpack_require__(15)
947 };
948 module.exports = exports['default'];
949
950 /***/ },
951 /* 11 */
952 /***/ function(module, exports, __webpack_require__) {
953
954 'use strict';
955
956 var TokenType = __webpack_require__(12);
957
958 module.exports = (function () {
959 /**
960 * Mark whitespaces and comments
961 */
962 function markSC(tokens) {
963 var tokensLength = tokens.length;
964 var ws = -1; // Flag for whitespaces
965 var sc = -1; // Flag for whitespaces and comments
966 var t = undefined; // Current token
967
968 // For every token in the token list, mark spaces and line breaks
969 // as spaces (set both `ws` and `sc` flags). Mark multiline comments
970 // with `sc` flag.
971 // If there are several spaces or tabs or line breaks or multiline
972 // comments in a row, group them: take the last one's index number
973 // and save it to the first token in the group as a reference:
974 // e.g., `ws_last = 7` for a group of whitespaces or `sc_last = 9`
975 // for a group of whitespaces and comments.
976 for (var i = 0; i < tokensLength; i++) {
977 t = tokens[i];
978 switch (t.type) {
979 case TokenType.Space:
980 case TokenType.Tab:
981 case TokenType.Newline:
982 t.ws = true;
983 t.sc = true;
984
985 if (ws === -1) ws = i;
986 if (sc === -1) sc = i;
987
988 break;
989 case TokenType.CommentML:
990 case TokenType.CommentSL:
991 if (ws !== -1) {
992 tokens[ws].ws_last = i - 1;
993 ws = -1;
994 }
995
996 t.sc = true;
997
998 break;
999 default:
1000 if (ws !== -1) {
1001 tokens[ws].ws_last = i - 1;
1002 ws = -1;
1003 }
1004
1005 if (sc !== -1) {
1006 tokens[sc].sc_last = i - 1;
1007 sc = -1;
1008 }
1009 }
1010 }
1011
1012 if (ws !== -1) tokens[ws].ws_last = i - 1;
1013 if (sc !== -1) tokens[sc].sc_last = i - 1;
1014 }
1015
1016 /**
1017 * Pair brackets
1018 */
1019 function markBrackets(tokens) {
1020 var tokensLength = tokens.length;
1021 var ps = []; // Parentheses
1022 var sbs = []; // Square brackets
1023 var cbs = []; // Curly brackets
1024 var t = undefined; // Current token
1025
1026 // For every token in the token list, if we meet an opening (left)
1027 // bracket, push its index number to a corresponding array.
1028 // If we then meet a closing (right) bracket, look at the correspond ing
1029 // array. If there are any elements (records about previously met
1030 // left brackets), take a token of the last left bracket (take
1031 // the last index number from the array and find a token with
1032 // this index number) and save right bracket's index as a reference:
1033 for (var i = 0; i < tokensLength; i++) {
1034 t = tokens[i];
1035 switch (t.type) {
1036 case TokenType.LeftParenthesis:
1037 ps.push(i);
1038 break;
1039 case TokenType.RightParenthesis:
1040 if (ps.length) {
1041 t.left = ps.pop();
1042 tokens[t.left].right = i;
1043 }
1044 break;
1045 case TokenType.LeftSquareBracket:
1046 sbs.push(i);
1047 break;
1048 case TokenType.RightSquareBracket:
1049 if (sbs.length) {
1050 t.left = sbs.pop();
1051 tokens[t.left].right = i;
1052 }
1053 break;
1054 case TokenType.LeftCurlyBracket:
1055 cbs.push(i);
1056 break;
1057 case TokenType.RightCurlyBracket:
1058 if (cbs.length) {
1059 t.left = cbs.pop();
1060 tokens[t.left].right = i;
1061 }
1062 break;
1063 }
1064 }
1065 }
1066
1067 return function (tokens) {
1068 markBrackets(tokens);
1069 markSC(tokens);
1070 };
1071 })();
1072
1073 /***/ },
1074 /* 12 */
1075 /***/ function(module, exports) {
1076
1077 // jscs:disable
1078
1079 'use strict';
1080
1081 module.exports = {
1082 StringSQ: 'StringSQ',
1083 StringDQ: 'StringDQ',
1084 CommentML: 'CommentML',
1085 CommentSL: 'CommentSL',
1086
1087 Newline: 'Newline',
1088 Space: 'Space',
1089 Tab: 'Tab',
1090
1091 ExclamationMark: 'ExclamationMark', // !
1092 QuotationMark: 'QuotationMark', // "
1093 NumberSign: 'NumberSign', // #
1094 DollarSign: 'DollarSign', // $
1095 PercentSign: 'PercentSign', // %
1096 Ampersand: 'Ampersand', // &
1097 Apostrophe: 'Apostrophe', // '
1098 LeftParenthesis: 'LeftParenthesis', // (
1099 RightParenthesis: 'RightParenthesis', // )
1100 Asterisk: 'Asterisk', // *
1101 PlusSign: 'PlusSign', // +
1102 Comma: 'Comma', // ,
1103 HyphenMinus: 'HyphenMinus', // -
1104 FullStop: 'FullStop', // .
1105 Solidus: 'Solidus', // /
1106 Colon: 'Colon', // :
1107 Semicolon: 'Semicolon', // ;
1108 LessThanSign: 'LessThanSign', // <
1109 EqualsSign: 'EqualsSign', // =
1110 EqualitySign: 'EqualitySign', // ==
1111 InequalitySign: 'InequalitySign', // !=
1112 GreaterThanSign: 'GreaterThanSign', // >
1113 QuestionMark: 'QuestionMark', // ?
1114 CommercialAt: 'CommercialAt', // @
1115 LeftSquareBracket: 'LeftSquareBracket', // [
1116 ReverseSolidus: 'ReverseSolidus', // \
1117 RightSquareBracket: 'RightSquareBracket', // ]
1118 CircumflexAccent: 'CircumflexAccent', // ^
1119 LowLine: 'LowLine', // _
1120 LeftCurlyBracket: 'LeftCurlyBracket', // {
1121 VerticalLine: 'VerticalLine', // |
1122 RightCurlyBracket: 'RightCurlyBracket', // }
1123 Tilde: 'Tilde', // ~
1124
1125 Identifier: 'Identifier',
1126 DecimalNumber: 'DecimalNumber'
1127 };
1128
1129 /***/ },
1130 /* 13 */
1131 /***/ function(module, exports, __webpack_require__) {
1132
1133 // jscs:disable maximumLineLength
1134 'use strict';var Node=__webpack_require__(1);var NodeType=__webpack_requ ire__(14);var TokenType=__webpack_require__(12);var tokens=undefined;var tokensL ength=undefined;var pos=undefined;var contexts={'arguments':function(){return ch eckArguments(pos) && getArguments();},'atkeyword':function(){return checkAtkeywo rd(pos) && getAtkeyword();},'atrule':function(){return checkAtrule(pos) && getAt rule();},'block':function(){return checkBlock(pos) && getBlock();},'brackets':fu nction(){return checkBrackets(pos) && getBrackets();},'class':function(){return checkClass(pos) && getClass();},'combinator':function(){return checkCombinator(p os) && getCombinator();},'commentML':function(){return checkCommentML(pos) && ge tCommentML();},'commentSL':function(){return checkCommentSL(pos) && getCommentSL ();},'condition':function(){return checkCondition(pos) && getCondition();},'cond itionalStatement':function(){return checkConditionalStatement(pos) && getConditi onalStatement();},'declaration':function(){return checkDeclaration(pos) && getDe claration();},'declDelim':function(){return checkDeclDelim(pos) && getDeclDelim( );},'default':function(){return checkDefault(pos) && getDefault();},'delim':func tion(){return checkDelim(pos) && getDelim();},'dimension':function(){return chec kDimension(pos) && getDimension();},'expression':function(){return checkExpressi on(pos) && getExpression();},'extend':function(){return checkExtend(pos) && getE xtend();},'function':function(){return checkFunction(pos) && getFunction();},'gl obal':function(){return checkGlobal(pos) && getGlobal();},'ident':function(){ret urn checkIdent(pos) && getIdent();},'important':function(){return checkImportant (pos) && getImportant();},'include':function(){return checkInclude(pos) && getIn clude();},'interpolation':function(){return checkInterpolation(pos) && getInterp olation();},'loop':function(){return checkLoop(pos) && getLoop();},'mixin':funct ion(){return checkMixin(pos) && getMixin();},'namespace':function(){return check Namespace(pos) && getNamespace();},'number':function(){return checkNumber(pos) & & getNumber();},'operator':function(){return checkOperator(pos) && getOperator() ;},'optional':function(){return checkOptional(pos) && getOptional();},'parenthes es':function(){return checkParentheses(pos) && getParentheses();},'parentselecto r':function(){return checkParentSelector(pos) && getParentSelector();},'percenta ge':function(){return checkPercentage(pos) && getPercentage();},'placeholder':fu nction(){return checkPlaceholder(pos) && getPlaceholder();},'progid':function(){ return checkProgid(pos) && getProgid();},'property':function(){return checkPrope rty(pos) && getProperty();},'propertyDelim':function(){return checkPropertyDelim (pos) && getPropertyDelim();},'pseudoc':function(){return checkPseudoc(pos) && g etPseudoc();},'pseudoe':function(){return checkPseudoe(pos) && getPseudoe();},'r uleset':function(){return checkRuleset(pos) && getRuleset();},'s':function(){ret urn checkS(pos) && getS();},'selector':function(){return checkSelector(pos) && g etSelector();},'shash':function(){return checkShash(pos) && getShash();},'string ':function(){return checkString(pos) && getString();},'stylesheet':function(){re turn checkStylesheet(pos) && getStylesheet();},'unary':function(){return checkUn ary(pos) && getUnary();},'uri':function(){return checkUri(pos) && getUri();},'va lue':function(){return checkValue(pos) && getValue();},'variable':function(){ret urn checkVariable(pos) && getVariable();},'variableslist':function(){return chec kVariablesList(pos) && getVariablesList();},'vhash':function(){return checkVhash (pos) && getVhash();}}; /**
1135 * Stop parsing and display error
1136 * @param {Number=} i Token's index number
1137 */function throwError(i){var ln=i?tokens[i].ln:tokens[pos].ln;throw {li ne:ln,syntax:'scss'};} /**
1138 * @param {Object} exclude
1139 * @param {Number} i Token's index number
1140 * @returns {Number}
1141 */function checkExcluding(exclude,i){var start=i;while(i < tokensLength ) {if(exclude[tokens[i++].type])break;}return i - start - 2;} /**
1142 * @param {Number} start
1143 * @param {Number} finish
1144 * @returns {String}
1145 */function joinValues(start,finish){var s='';for(var i=start;i < finish + 1;i++) {s += tokens[i].value;}return s;} /**
1146 * @param {Number} start
1147 * @param {Number} num
1148 * @returns {String}
1149 */function joinValues2(start,num){if(start + num - 1 >= tokensLength)re turn;var s='';for(var i=0;i < num;i++) {s += tokens[start + i].value;}return s;} function getLastPosition(content,line,column,colOffset){return typeof content == = 'string'?getLastPositionForString(content,line,column,colOffset):getLastPositi onForArray(content,line,column,colOffset);}function getLastPositionForString(con tent,line,column,colOffset){var position=[];if(!content){position = [line,column ];if(colOffset)position[1] += colOffset - 1;return position;}var lastLinebreak=c ontent.lastIndexOf('\n');var endsWithLinebreak=lastLinebreak === content.length - 1;var splitContent=content.split('\n');var linebreaksCount=splitContent.length - 1;var prevLinebreak=linebreaksCount === 0 || linebreaksCount === 1?-1:content .length - splitContent[linebreaksCount - 1].length - 2; // Line:
1150 var offset=endsWithLinebreak?linebreaksCount - 1:linebreaksCount;positio n[0] = line + offset; // Column:
1151 if(endsWithLinebreak){offset = prevLinebreak !== -1?content.length - pre vLinebreak:content.length - 1;}else {offset = linebreaksCount !== 0?content.leng th - lastLinebreak - column - 1:content.length - 1;}position[1] = column + offse t;if(!colOffset)return position;if(endsWithLinebreak){position[0]++;position[1] = colOffset;}else {position[1] += colOffset;}return position;}function getLastPo sitionForArray(content,line,column,colOffset){var position;if(content.length === 0){position = [line,column];}else {var c=content[content.length - 1];if(c.hasOw nProperty('end')){position = [c.end.line,c.end.column];}else {position = getLast Position(c.content,line,column);}}if(!colOffset)return position;if(tokens[pos - 1].type !== 'Newline'){position[1] += colOffset;}else {position[0]++;position[1] = 1;}return position;}function newNode(type,content,line,column,end){if(!end)en d = getLastPosition(content,line,column);return new Node({type:type,content:cont ent,start:{line:line,column:column},end:{line:end[0],column:end[1]},syntax:'scss '});} /**
1152 * @param {Number} i Token's index number
1153 * @returns {Number}
1154 */function checkAny(i){return checkBrackets(i) || checkParentheses(i) | | checkString(i) || checkVariablesList(i) || checkVariable(i) || checkPlaceholde r(i) || checkPercentage(i) || checkDimension(i) || checkNumber(i) || checkUri(i) || checkExpression(i) || checkFunction(i) || checkInterpolation(i) || checkIden t(i) || checkClass(i) || checkUnary(i);} /**
1155 * @returns {Array}
1156 */function getAny(){if(checkBrackets(pos))return getBrackets();else if( checkParentheses(pos))return getParentheses();else if(checkString(pos))return ge tString();else if(checkVariablesList(pos))return getVariablesList();else if(chec kVariable(pos))return getVariable();else if(checkPlaceholder(pos))return getPlac eholder();else if(checkPercentage(pos))return getPercentage();else if(checkDimen sion(pos))return getDimension();else if(checkNumber(pos))return getNumber();else if(checkUri(pos))return getUri();else if(checkExpression(pos))return getExpress ion();else if(checkFunction(pos))return getFunction();else if(checkInterpolation (pos))return getInterpolation();else if(checkIdent(pos))return getIdent();else i f(checkClass(pos))return getClass();else if(checkUnary(pos))return getUnary();} /**
1157 * Check if token is part of mixin's arguments.
1158 * @param {Number} i Token's index number
1159 * @returns {Number} Length of arguments
1160 */function checkArguments(i){var start=i;var l=undefined;if(i >= tokens Length || tokens[i].type !== TokenType.LeftParenthesis)return 0;i++;while(i < to kens[start].right) {if(l = checkArgument(i))i += l;else return 0;}return tokens[ start].right - start + 1;} /**
1161 * Check if token is valid to be part of arguments list
1162 * @param {Number} i Token's index number
1163 * @returns {Number} Length of argument
1164 */function checkArgument(i){return checkBrackets(i) || checkParentheses (i) || checkDeclaration(i) || checkFunction(i) || checkVariablesList(i) || check Variable(i) || checkSC(i) || checkDelim(i) || checkDeclDelim(i) || checkString(i ) || checkPercentage(i) || checkDimension(i) || checkNumber(i) || checkUri(i) || checkInterpolation(i) || checkIdent(i) || checkVhash(i) || checkOperator(i) || checkUnary(i);} /**
1165 * @returns {Array} Node that is part of arguments list
1166 */function getArgument(){if(checkBrackets(pos))return getBrackets();els e if(checkParentheses(pos))return getParentheses();else if(checkDeclaration(pos) )return getDeclaration();else if(checkFunction(pos))return getFunction();else if (checkVariablesList(pos))return getVariablesList();else if(checkVariable(pos))re turn getVariable();else if(checkSC(pos))return getSC();else if(checkDelim(pos))r eturn getDelim();else if(checkDeclDelim(pos))return getDeclDelim();else if(check String(pos))return getString();else if(checkPercentage(pos))return getPercentage ();else if(checkDimension(pos))return getDimension();else if(checkNumber(pos))re turn getNumber();else if(checkUri(pos))return getUri();else if(checkInterpolatio n(pos))return getInterpolation();else if(checkIdent(pos))return getIdent();else if(checkVhash(pos))return getVhash();else if(checkOperator(pos))return getOperat or();else if(checkUnary(pos))return getUnary();} /**
1167 * Check if token is part of an @-word (e.g. `@import`, `@include`)
1168 * @param {Number} i Token's index number
1169 * @returns {Number}
1170 */function checkAtkeyword(i){var l; // Check that token is `@`:
1171 if(i >= tokensLength || tokens[i++].type !== TokenType.CommercialAt)retu rn 0;return (l = checkIdentOrInterpolation(i))?l + 1:0;} /**
1172 * Get node with @-word
1173 * @returns {Array} `['atkeyword', ['ident', x]]` where `x` is
1174 * an identifier without
1175 * `@` (e.g. `import`, `include`)
1176 */function getAtkeyword(){var startPos=pos;var x=undefined;pos++;x = ge tIdentOrInterpolation();var token=tokens[startPos];return newNode(NodeType.Atkey wordType,x,token.ln,token.col);} /**
1177 * Check if token is a part of an @-rule
1178 * @param {Number} i Token's index number
1179 * @returns {Number} Length of @-rule
1180 */function checkAtrule(i){var l;if(i >= tokensLength)return 0; // If to ken already has a record of being part of an @-rule,
1181 // return the @-rule's length:
1182 if(tokens[i].atrule_l !== undefined)return tokens[i].atrule_l; // If tok en is part of an @-rule, save the rule's type to token:
1183 if(l = checkKeyframesRule(i))tokens[i].atrule_type = 4;else if(l = check Atruler(i))tokens[i].atrule_type = 1; // @-rule with ruleset
1184 else if(l = checkAtruleb(i))tokens[i].atrule_type = 2; // Block @-rule
1185 else if(l = checkAtrules(i))tokens[i].atrule_type = 3; // Single-line @- rule
1186 else return 0; // If token is part of an @-rule, save the rule's length to token:
1187 tokens[i].atrule_l = l;return l;} /**
1188 * Get node with @-rule
1189 * @returns {Array}
1190 */function getAtrule(){switch(tokens[pos].atrule_type){case 1:return ge tAtruler(); // @-rule with ruleset
1191 case 2:return getAtruleb(); // Block @-rule
1192 case 3:return getAtrules(); // Single-line @-rule
1193 case 4:return getKeyframesRule();}} /**
1194 * Check if token is part of a block @-rule
1195 * @param {Number} i Token's index number
1196 * @returns {Number} Length of the @-rule
1197 */function checkAtruleb(i){var start=i;var l=undefined;if(i >= tokensLe ngth)return 0;if(l = checkAtkeyword(i))i += l;else return 0;if(l = checkTsets(i) )i += l;if(l = checkBlock(i))i += l;else return 0;return i - start;} /**
1198 * Get node with a block @-rule
1199 * @returns {Array} `['atruleb', ['atkeyword', x], y, ['block', z]]`
1200 */function getAtruleb(){var startPos=pos;var x=undefined;x = [getAtkeyw ord()].concat(getTsets()).concat([getBlock()]);var token=tokens[startPos];return newNode(NodeType.AtruleType,x,token.ln,token.col);} /**
1201 * Check if token is part of an @-rule with ruleset
1202 * @param {Number} i Token's index number
1203 * @returns {Number} Length of the @-rule
1204 */function checkAtruler(i){var start=i;var l=undefined;if(i >= tokensLe ngth)return 0;if(l = checkAtkeyword(i))i += l;else return 0;if(l = checkTsets(i) )i += l;if(i < tokensLength && tokens[i].type === TokenType.LeftCurlyBracket)i++ ;else return 0;if(l = checkAtrulers(i))i += l;if(i < tokensLength && tokens[i].t ype === TokenType.RightCurlyBracket)i++;else return 0;return i - start;} /**
1205 * Get node with an @-rule with ruleset
1206 * @returns {Array} ['atruler', ['atkeyword', x], y, z]
1207 */function getAtruler(){var startPos=pos;var x=undefined;x = [getAtkeyw ord()].concat(getTsets());x.push(getAtrulers());var token=tokens[startPos];retur n newNode(NodeType.AtruleType,x,token.ln,token.col);} /**
1208 * @param {Number} i Token's index number
1209 * @returns {Number}
1210 */function checkAtrulers(i){var start=i;var l=undefined;if(i >= tokensL ength)return 0;while(l = checkRuleset(i) || checkAtrule(i) || checkSC(i)) {i += l;}if(i < tokensLength)tokens[i].atrulers_end = 1;return i - start;} /**
1211 * @returns {Array} `['atrulers', x]`
1212 */function getAtrulers(){var startPos=pos;var x=undefined;var token=tok ens[startPos];var line=token.ln;var column=token.col;pos++;x = getSC();while(!to kens[pos].atrulers_end) {if(checkSC(pos))x = x.concat(getSC());else if(checkAtru le(pos))x.push(getAtrule());else if(checkRuleset(pos))x.push(getRuleset());}x = x.concat(getSC());var end=getLastPosition(x,line,column,1);pos++;return newNode( NodeType.BlockType,x,token.ln,token.col,end);} /**
1213 * @param {Number} i Token's index number
1214 * @returns {Number}
1215 */function checkAtrules(i){var start=i;var l=undefined;if(i >= tokensLe ngth)return 0;if(l = checkAtkeyword(i))i += l;else return 0;if(l = checkTsets(i) )i += l;return i - start;} /**
1216 * @returns {Array} `['atrules', ['atkeyword', x], y]`
1217 */function getAtrules(){var startPos=pos;var x=undefined;x = [getAtkeyw ord()].concat(getTsets());var token=tokens[startPos];return newNode(NodeType.Atr uleType,x,token.ln,token.col);} /**
1218 * Check if token is part of a block (e.g. `{...}`).
1219 * @param {Number} i Token's index number
1220 * @returns {Number} Length of the block
1221 */function checkBlock(i){return i < tokensLength && tokens[i].type === TokenType.LeftCurlyBracket?tokens[i].right - i + 1:0;} /**
1222 * Get node with a block
1223 * @returns {Array} `['block', x]`
1224 */function getBlock(){var startPos=pos;var end=tokens[pos].right;var x= [];var token=tokens[startPos];var line=token.ln;var column=token.col;pos++;while (pos < end) {if(checkBlockdecl(pos))x = x.concat(getBlockdecl());else throwError ();}var end_=getLastPosition(x,line,column,1);pos = end + 1;return newNode(NodeT ype.BlockType,x,token.ln,token.col,end_);} /**
1225 * Check if token is part of a declaration (property-value pair)
1226 * @param {Number} i Token's index number
1227 * @returns {Number} Length of the declaration
1228 */function checkBlockdecl(i){var l;if(i >= tokensLength)return 0;if(l = checkBlockdecl1(i))tokens[i].bd_type = 1;else if(l = checkBlockdecl2(i))tokens[ i].bd_type = 2;else if(l = checkBlockdecl3(i))tokens[i].bd_type = 3;else if(l = checkBlockdecl4(i))tokens[i].bd_type = 4;else return 0;return l;} /**
1229 * @returns {Array}
1230 */function getBlockdecl(){switch(tokens[pos].bd_type){case 1:return get Blockdecl1();case 2:return getBlockdecl2();case 3:return getBlockdecl3();case 4: return getBlockdecl4();}} /**
1231 * @param {Number} i Token's index number
1232 * @returns {Number}
1233 */function checkBlockdecl1(i){var start=i;var l=undefined;if(l = checkS C(i))i += l;if(l = checkConditionalStatement(i))tokens[i].bd_kind = 1;else if(l = checkInclude(i))tokens[i].bd_kind = 2;else if(l = checkExtend(i))tokens[i].bd_ kind = 4;else if(l = checkLoop(i))tokens[i].bd_kind = 3;else if(l = checkAtrule( i))tokens[i].bd_kind = 6;else if(l = checkRuleset(i))tokens[i].bd_kind = 7;else if(l = checkDeclaration(i))tokens[i].bd_kind = 5;else return 0;i += l;if(i < tok ensLength && (l = checkDeclDelim(i)))i += l;else return 0;if(l = checkSC(i))i += l;return i - start;} /**
1234 * @returns {Array}
1235 */function getBlockdecl1(){var sc=getSC();var x=undefined;switch(tokens [pos].bd_kind){case 1:x = getConditionalStatement();break;case 2:x = getInclude( );break;case 3:x = getLoop();break;case 4:x = getExtend();break;case 5:x = getDe claration();break;case 6:x = getAtrule();break;case 7:x = getRuleset();break;}re turn sc.concat([x]).concat([getDeclDelim()]).concat(getSC());} /**
1236 * @param {Number} i Token's index number
1237 * @returns {Number}
1238 */function checkBlockdecl2(i){var start=i;var l=undefined;if(l = checkS C(i))i += l;if(l = checkConditionalStatement(i))tokens[i].bd_kind = 1;else if(l = checkInclude(i))tokens[i].bd_kind = 2;else if(l = checkExtend(i))tokens[i].bd_ kind = 4;else if(l = checkMixin(i))tokens[i].bd_kind = 8;else if(l = checkLoop(i ))tokens[i].bd_kind = 3;else if(l = checkAtrule(i))tokens[i].bd_kind = 6;else if (l = checkRuleset(i))tokens[i].bd_kind = 7;else if(l = checkDeclaration(i))token s[i].bd_kind = 5;else return 0;i += l;if(l = checkSC(i))i += l;return i - start; } /**
1239 * @returns {Array}
1240 */function getBlockdecl2(){var sc=getSC();var x=undefined;switch(tokens [pos].bd_kind){case 1:x = getConditionalStatement();break;case 2:x = getInclude( );break;case 3:x = getLoop();break;case 4:x = getExtend();break;case 5:x = getDe claration();break;case 6:x = getAtrule();break;case 7:x = getRuleset();break;cas e 8:x = getMixin();break;}return sc.concat([x]).concat(getSC());} /**
1241 * @param {Number} i Token's index number
1242 * @returns {Number}
1243 */function checkBlockdecl3(i){var start=i;var l=undefined;if(l = checkS C(i))i += l;if(l = checkDeclDelim(i))i += l;else return 0;if(l = checkSC(i))i += l;return i - start;} /**
1244 * @returns {Array} `[s0, ['declDelim'], s1]` where `s0` and `s1` are
1245 * are optional whitespaces.
1246 */function getBlockdecl3(){return getSC().concat([getDeclDelim()]).conc at(getSC());} /**
1247 * @param {Number} i Token's index number
1248 * @returns {Number}
1249 */function checkBlockdecl4(i){return checkSC(i);} /**
1250 * @returns {Array}
1251 */function getBlockdecl4(){return getSC();} /**
1252 * Check if token is part of text inside square brackets, e.g. `[1]`
1253 * @param {Number} i Token's index number
1254 * @returns {Number}
1255 */function checkBrackets(i){if(i >= tokensLength || tokens[i].type !== TokenType.LeftSquareBracket)return 0;return tokens[i].right - i + 1;} /**
1256 * Get node with text inside parentheses or square brackets (e.g. `(1)`)
1257 * @return {Node}
1258 */function getBrackets(){var startPos=pos;var token=tokens[startPos];va r line=token.ln;var column=token.col;pos++;var tsets=getTsets();var end=getLastP osition(tsets,line,column,1);pos++;return newNode(NodeType.BracketsType,tsets,to ken.ln,token.col,end);} /**
1259 * Check if token is part of a class selector (e.g. `.abc`)
1260 * @param {Number} i Token's index number
1261 * @returns {Number} Length of the class selector
1262 */function checkClass(i){var start=i;var l=undefined;if(i >= tokensLeng th)return 0;if(tokens[i].class_l)return tokens[i].class_l;if(tokens[i++].type != = TokenType.FullStop)return 0;if(l = checkIdentOrInterpolation(i))i += l;else re turn 0;return i - start;} /**
1263 * Get node with a class selector
1264 * @returns {Array} `['class', ['ident', x]]` where x is a class's
1265 * identifier (without `.`, e.g. `abc`).
1266 */function getClass(){var startPos=pos;var x=[];pos++;x = x.concat(getI dentOrInterpolation());var token=tokens[startPos];return newNode(NodeType.ClassT ype,x,token.ln,token.col);}function checkCombinator(i){if(i >= tokensLength)retu rn 0;var l=undefined;if(l = checkCombinator1(i))tokens[i].combinatorType = 1;els e if(l = checkCombinator2(i))tokens[i].combinatorType = 2;else if(l = checkCombi nator3(i))tokens[i].combinatorType = 3;return l;}function getCombinator(){var ty pe=tokens[pos].combinatorType;if(type === 1)return getCombinator1();if(type === 2)return getCombinator2();if(type === 3)return getCombinator3();} /**
1267 * (1) `||`
1268 */function checkCombinator1(i){if(tokens[i].type === TokenType.Vertical Line && tokens[i + 1].type === TokenType.VerticalLine)return 2;else return 0;}fu nction getCombinator1(){var type=NodeType.CombinatorType;var token=tokens[pos];v ar line=token.ln;var column=token.col;var content='||';pos += 2;return newNode(t ype,content,line,column);} /**
1269 * (1) `>`
1270 * (2) `+`
1271 * (3) `~`
1272 */function checkCombinator2(i){var type=tokens[i].type;if(type === Toke nType.PlusSign || type === TokenType.GreaterThanSign || type === TokenType.Tilde )return 1;else return 0;}function getCombinator2(){var type=NodeType.CombinatorT ype;var token=tokens[pos];var line=token.ln;var column=token.col;var content=tok ens[pos++].value;return newNode(type,content,line,column);} /**
1273 * (1) `/panda/`
1274 */function checkCombinator3(i){var start=i;if(tokens[i].type === TokenT ype.Solidus)i++;else return 0;var l=undefined;if(l = checkIdent(i))i += l;else r eturn 0;if(tokens[i].type === TokenType.Solidus)i++;else return 0;return i - sta rt;}function getCombinator3(){var type=NodeType.CombinatorType;var token=tokens[ pos];var line=token.ln;var column=token.col; // Skip `/`.
1275 pos++;var ident=getIdent(); // Skip `/`.
1276 pos++;var content='/' + ident.content + '/';return newNode(type,content, line,column);} /**
1277 * Check if token is a multiline comment.
1278 * @param {Number} i Token's index number
1279 * @returns {Number} `1` if token is a multiline comment, otherwise `0`
1280 */function checkCommentML(i){return i < tokensLength && tokens[i].type === TokenType.CommentML?1:0;} /**
1281 * Get node with a multiline comment
1282 * @returns {Array} `['commentML', x]` where `x`
1283 * is the comment's text (without `/*` and `* /`).
1284 */function getCommentML(){var startPos=pos;var s=tokens[pos].value.subs tring(2);var l=s.length;var token=tokens[startPos];var line=token.ln;var column= token.col;if(s.charAt(l - 2) === '*' && s.charAt(l - 1) === '/')s = s.substring( 0,l - 2);var end=getLastPosition(s,line,column,2);if(end[0] === line)end[1] += 2 ;pos++;return newNode(NodeType.CommentMLType,s,token.ln,token.col,end);} /**
1285 * Check if token is part of a single-line comment.
1286 * @param {Number} i Token's index number
1287 * @returns {Number} `1` if token is a single-line comment, otherwise `0 `
1288 */function checkCommentSL(i){return i < tokensLength && tokens[i].type === TokenType.CommentSL?1:0;} /**
1289 * Get node with a single-line comment.
1290 * @returns {Array} `['commentSL', x]` where `x` is comment's message
1291 * (without `//`)
1292 */function getCommentSL(){var startPos=pos;var x=undefined;var token=to kens[startPos];var line=token.ln;var column=token.col;x = tokens[pos++].value.su bstring(2);var end=getLastPosition(x,line,column + 2);return newNode(NodeType.Co mmentSLType,x,token.ln,token.col,end);} /**
1293 * Check if token is part of a condition
1294 * (e.g. `@if ...`, `@else if ...` or `@else ...`).
1295 * @param {Number} i Token's index number
1296 * @returns {Number} Length of the condition
1297 */function checkCondition(i){var start=i;var l=undefined;var _i=undefin ed;var s=undefined;if(i >= tokensLength)return 0;if(l = checkAtkeyword(i))i += l ;else return 0;if(['if','else'].indexOf(tokens[start + 1].value) < 0)return 0;wh ile(i < tokensLength) {if(l = checkBlock(i))break;s = checkSC(i);_i = i + s;if(l = _checkCondition(_i))i += l + s;else break;}return i - start;}function _checkC ondition(i){return checkVariable(i) || checkNumber(i) || checkInterpolation(i) | | checkIdent(i) || checkOperator(i) || checkCombinator(i) || checkString(i);} /* *
1298 * Get node with a condition.
1299 * @returns {Array} `['condition', x]`
1300 */function getCondition(){var startPos=pos;var x=[];var s;var _pos;x.pu sh(getAtkeyword());while(pos < tokensLength) {if(checkBlock(pos))break;s = check SC(pos);_pos = pos + s;if(!_checkCondition(_pos))break;if(s)x = x.concat(getSC() );x.push(_getCondition());}var token=tokens[startPos];return newNode(NodeType.Co nditionType,x,token.ln,token.col);}function _getCondition(){if(checkVariable(pos ))return getVariable();if(checkNumber(pos))return getNumber();if(checkInterpolat ion(pos))return getInterpolation();if(checkIdent(pos))return getIdent();if(check Operator(pos))return getOperator();if(checkCombinator(pos))return getCombinator( );if(checkString(pos))return getString();} /**
1301 * Check if token is part of a conditional statement
1302 * (e.g. `@if ... {} @else if ... {} @else ... {}`).
1303 * @param {Number} i Token's index number
1304 * @returns {Number} Length of the condition
1305 */function checkConditionalStatement(i){var start=i;var l=undefined;if( i >= tokensLength)return 0;if(l = checkCondition(i))i += l;else return 0;if(l = checkSC(i))i += l;if(l = checkBlock(i))i += l;else return 0;return i - start;} / **
1306 * Get node with a condition.
1307 * @returns {Array} `['condition', x]`
1308 */function getConditionalStatement(){var startPos=pos;var x=[];x.push(g etCondition());x = x.concat(getSC());x.push(getBlock());var token=tokens[startPo s];return newNode(NodeType.ConditionalStatementType,x,token.ln,token.col);} /**
1309 * Check if token is part of a declaration (property-value pair)
1310 * @param {Number} i Token's index number
1311 * @returns {Number} Length of the declaration
1312 */function checkDeclaration(i){var start=i;var l=undefined;if(i >= toke nsLength)return 0;if(l = checkProperty(i))i += l;else return 0;if(l = checkSC(i) )i += l;if(l = checkPropertyDelim(i))i++;else return 0;if(l = checkSC(i))i += l; if(l = checkValue(i))i += l;else return 0;return i - start;} /**
1313 * Get node with a declaration
1314 * @returns {Array} `['declaration', ['property', x], ['propertyDelim'],
1315 * ['value', y]]`
1316 */function getDeclaration(){var startPos=pos;var x=[];x.push(getPropert y());x = x.concat(getSC());x.push(getPropertyDelim());x = x.concat(getSC());x.pu sh(getValue());var token=tokens[startPos];return newNode(NodeType.DeclarationTyp e,x,token.ln,token.col);} /**
1317 * Check if token is a semicolon
1318 * @param {Number} i Token's index number
1319 * @returns {Number} `1` if token is a semicolon, otherwise `0`
1320 */function checkDeclDelim(i){return i < tokensLength && tokens[i].type === TokenType.Semicolon?1:0;} /**
1321 * Get node with a semicolon
1322 * @returns {Array} `['declDelim']`
1323 */function getDeclDelim(){var startPos=pos++;var token=tokens[startPos] ;return newNode(NodeType.DeclDelimType,';',token.ln,token.col);} /**
1324 * Check if token if part of `!default` word.
1325 * @param {Number} i Token's index number
1326 * @returns {Number} Length of the `!default` word
1327 */function checkDefault(i){var start=i;var l=undefined;if(i >= tokensLe ngth || tokens[i++].type !== TokenType.ExclamationMark)return 0;if(l = checkSC(i ))i += l;if(tokens[i].value === 'default'){tokens[start].defaultEnd = i;return i - start + 1;}else {return 0;}} /**
1328 * Get node with a `!default` word
1329 * @returns {Array} `['default', sc]` where `sc` is optional whitespace
1330 */function getDefault(){var token=tokens[pos];var line=token.ln;var col umn=token.col;var content=joinValues(pos,token.defaultEnd);pos = token.defaultEn d + 1;return newNode(NodeType.DefaultType,content,line,column);} /**
1331 * Check if token is a comma
1332 * @param {Number} i Token's index number
1333 * @returns {Number} `1` if token is a comma, otherwise `0`
1334 */function checkDelim(i){return i < tokensLength && tokens[i].type === TokenType.Comma?1:0;} /**
1335 * Get node with a comma
1336 * @returns {Array} `['delim']`
1337 */function getDelim(){var startPos=pos;pos++;var token=tokens[startPos] ;return newNode(NodeType.DelimType,',',token.ln,token.col);} /**
1338 * Check if token is part of a number with dimension unit (e.g. `10px`)
1339 * @param {Number} i Token's index number
1340 * @returns {Number}
1341 */function checkDimension(i){var ln=checkNumber(i);var li=undefined;if( i >= tokensLength || !ln || i + ln >= tokensLength)return 0;return (li = checkNm Name2(i + ln))?ln + li:0;} /**
1342 * Get node of a number with dimension unit
1343 * @returns {Array} `['dimension', ['number', x], ['ident', y]]` where
1344 * `x` is a number converted to string (e.g. `'10'`) and `y` is
1345 * a dimension unit (e.g. `'px'`).
1346 */function getDimension(){var startPos=pos;var x=[getNumber()];var toke n=tokens[pos];var ident=newNode(NodeType.IdentType,getNmName2(),token.ln,token.c ol);x.push(ident);token = tokens[startPos];return newNode(NodeType.DimensionType ,x,token.ln,token.col);} /**
1347 * @param {Number} i Token's index number
1348 * @returns {Number}
1349 */function checkExpression(i){var start=i;if(i >= tokensLength || token s[i++].value !== 'expression' || i >= tokensLength || tokens[i].type !== TokenTy pe.LeftParenthesis)return 0;return tokens[i].right - start + 1;} /**
1350 * @returns {Array}
1351 */function getExpression(){var startPos=pos;var e;var token=tokens[star tPos];var line=token.ln;var column=token.col;pos++;e = joinValues(pos + 1,tokens [pos].right - 1);var end=getLastPosition(e,line,column,1);if(end[0] === line)end [1] += 11;pos = tokens[pos].right + 1;return newNode(NodeType.ExpressionType,e,t oken.ln,token.col,end);}function checkExtend(i){var l=0;if(l = checkExtend1(i))t okens[i].extend_child = 1;else if(l = checkExtend2(i))tokens[i].extend_child = 2 ;return l;}function getExtend(){var type=tokens[pos].extend_child;if(type === 1) return getExtend1();else if(type === 2)return getExtend2();} /**
1352 * Checks if token is part of an extend with `!optional` flag.
1353 * @param {Number} i
1354 */function checkExtend1(i){var start=i;var l;if(i >= tokensLength)retur n 0;if(l = checkAtkeyword(i))i += l;else return 0;if(tokens[start + 1].value !== 'extend')return 0;if(l = checkSC(i))i += l;else return 0;if(l = checkSelectorsG roup(i))i += l;else return 0;if(l = checkSC(i))i += l;else return 0;if(l = check Optional(i))i += l;else return 0;return i - start;}function getExtend1(){var sta rtPos=pos;var x=[].concat([getAtkeyword()],getSC(),getSelectorsGroup(),getSC(),[ getOptional()]);var token=tokens[startPos];return newNode(NodeType.ExtendType,x, token.ln,token.col);} /**
1355 * Checks if token is part of an extend without `!optional` flag.
1356 * @param {Number} i
1357 */function checkExtend2(i){var start=i;var l;if(i >= tokensLength)retur n 0;if(l = checkAtkeyword(i))i += l;else return 0;if(tokens[start + 1].value !== 'extend')return 0;if(l = checkSC(i))i += l;else return 0;if(l = checkSelectorsG roup(i))i += l;else return 0;return i - start;}function getExtend2(){var startPo s=pos;var x=[].concat([getAtkeyword()],getSC(),getSelectorsGroup());var token=to kens[startPos];return newNode(NodeType.ExtendType,x,token.ln,token.col);} /**
1358 * @param {Number} i Token's index number
1359 * @returns {Number}
1360 */function checkFunction(i){var start=i;var l=undefined;if(i >= tokensL ength)return 0;if(l = checkIdentOrInterpolation(i))i += l;else return 0;return i < tokensLength && tokens[i].type === TokenType.LeftParenthesis?tokens[i].right - start + 1:0;} /**
1361 * @returns {Array}
1362 */function getFunction(){var startPos=pos;var x=getIdentOrInterpolation ();var body=undefined;body = getArguments();x.push(body);var token=tokens[startP os];return newNode(NodeType.FunctionType,x,token.ln,token.col);} /**
1363 * @returns {Array}
1364 */function getArguments(){var startPos=pos;var x=[];var body=undefined; var token=tokens[startPos];var line=token.ln;var column=token.col;pos++;while(po s < tokensLength && tokens[pos].type !== TokenType.RightParenthesis) {if(checkDe claration(pos))x.push(getDeclaration());else if(checkArgument(pos)){body = getAr gument();if(typeof body.content === 'string')x.push(body);else x = x.concat(body );}else if(checkClass(pos))x.push(getClass());else throwError();}var end=getLast Position(x,line,column,1);pos++;return newNode(NodeType.ArgumentsType,x,token.ln ,token.col,end);} /**
1365 * Check if token is part of an identifier
1366 * @param {Number} i Token's index number
1367 * @returns {Number} Length of the identifier
1368 */function checkIdent(i){var start=i;var interpolations=[];var wasIdent =undefined;var wasInt=false;var l=undefined;if(i >= tokensLength)return 0; // Ch eck if token is part of an identifier starting with `_`:
1369 if(tokens[i].type === TokenType.LowLine)return checkIdentLowLine(i);if(t okens[i].type === TokenType.HyphenMinus && tokens[i + 1].type === TokenType.Deci malNumber)return 0; // If token is a character, `-`, `$` or `*`, skip it & conti nue:
1370 if(l = _checkIdent(i))i += l;else return 0; // Remember if previous toke n's type was identifier:
1371 wasIdent = tokens[i - 1].type === TokenType.Identifier;while(i < tokensL ength) {l = _checkIdent(i);if(!l)break;wasIdent = true;i += l;}if(!wasIdent && ! wasInt && tokens[start].type !== TokenType.Asterisk)return 0;tokens[start].ident _last = i - 1;if(interpolations.length)tokens[start].interpolations = interpolat ions;return i - start;}function _checkIdent(i){if(tokens[i].type === TokenType.H yphenMinus || tokens[i].type === TokenType.Identifier || tokens[i].type === Toke nType.DollarSign || tokens[i].type === TokenType.LowLine || tokens[i].type === T okenType.DecimalNumber || tokens[i].type === TokenType.Asterisk)return 1;return 0;} /**
1372 * Check if token is part of an identifier starting with `_`
1373 * @param {Number} i Token's index number
1374 * @returns {Number} Length of the identifier
1375 */function checkIdentLowLine(i){var start=i;if(i++ >= tokensLength)retu rn 0;for(;i < tokensLength;i++) {if(tokens[i].type !== TokenType.HyphenMinus && tokens[i].type !== TokenType.DecimalNumber && tokens[i].type !== TokenType.LowLi ne && tokens[i].type !== TokenType.Identifier)break;} // Save index number of th e last token of the identifier:
1376 tokens[start].ident_last = i - 1;return i - start;} /**
1377 * Get node with an identifier
1378 * @returns {Array} `['ident', x]` where `x` is identifier's name
1379 */function getIdent(){var startPos=pos;var x=joinValues(pos,tokens[pos] .ident_last);pos = tokens[pos].ident_last + 1;var token=tokens[startPos];return newNode(NodeType.IdentType,x,token.ln,token.col);}function checkIdentOrInterpola tion(i){var start=i;var l=undefined;while(i < tokensLength) {if(l = checkInterpo lation(i) || checkIdent(i))i += l;else break;}return i - start;}function getIden tOrInterpolation(){var x=[];while(pos < tokensLength) {if(checkInterpolation(pos ))x.push(getInterpolation());else if(checkIdent(pos))x.push(getIdent());else bre ak;}return x;} /**
1380 * Check if token is part of `!important` word
1381 * @param {Number} i Token's index number
1382 * @returns {Number}
1383 */function checkImportant(i){var start=i;var l=undefined;if(i >= tokens Length || tokens[i++].type !== TokenType.ExclamationMark)return 0;if(l = checkSC (i))i += l;if(tokens[i].value === 'important'){tokens[start].importantEnd = i;re turn i - start + 1;}else {return 0;}} /**
1384 * Get node with `!important` word
1385 * @returns {Array} `['important', sc]` where `sc` is optional whitespac e
1386 */function getImportant(){var token=tokens[pos];var line=token.ln;var c olumn=token.col;var content=joinValues(pos,token.importantEnd);pos = token.impor tantEnd + 1;return newNode(NodeType.ImportantType,content,line,column);} /**
1387 * Check if token is part of an included mixin (`@include` or `@extend`
1388 * directive).
1389 * @param {Number} i Token's index number
1390 * @returns {Number} Length of the included mixin
1391 */function checkInclude(i){var l;if(i >= tokensLength)return 0;if(l = c heckInclude1(i))tokens[i].include_type = 1;else if(l = checkInclude2(i))tokens[i ].include_type = 2;else if(l = checkInclude3(i))tokens[i].include_type = 3;else if(l = checkInclude4(i))tokens[i].include_type = 4;else if(l = checkInclude5(i)) tokens[i].include_type = 5;return l;} /**
1392 * Check if token is part of `!global` word
1393 * @param {Number} i Token's index number
1394 * @returns {Number}
1395 */function checkGlobal(i){var start=i;var l=undefined;if(i >= tokensLen gth || tokens[i++].type !== TokenType.ExclamationMark)return 0;if(l = checkSC(i) )i += l;if(tokens[i].value === 'global'){tokens[start].globalEnd = i;return i - start + 1;}else {return 0;}} /**
1396 * Get node with `!global` word
1397 */function getGlobal(){var token=tokens[pos];var line=token.ln;var colu mn=token.col;var content=joinValues(pos,token.globalEnd);pos = token.globalEnd + 1;return newNode(NodeType.GlobalType,content,line,column);} /**
1398 * Get node with included mixin
1399 * @returns {Array} `['include', x]`
1400 */function getInclude(){switch(tokens[pos].include_type){case 1:return getInclude1();case 2:return getInclude2();case 3:return getInclude3();case 4:ret urn getInclude4();case 5:return getInclude5();}} /**
1401 * Get node with included mixin with keyfames selector like
1402 * `@include nani(foo) { 0% {}}`
1403 * @param {Number} i Token's index number
1404 * @returns {Number} Length of the include
1405 */function checkInclude1(i){var start=i;var l=undefined;if(l = checkAtk eyword(i))i += l;else return 0;if(tokens[start + 1].value !== 'include')return 0 ;if(l = checkSC(i))i += l;else return 0;if(l = checkIdentOrInterpolation(i))i += l;else return 0;if(l = checkSC(i))i += l;if(l = checkArguments(i))i += l;else r eturn 0;if(l = checkSC(i))i += l;if(l = checkKeyframesBlocks(i))i += l;else retu rn 0;return i - start;} /**
1406 * Get node with included mixin with keyfames selector like
1407 * `@include nani(foo) { 0% {}}`
1408 * @returns {Array} `['include', ['atkeyword', x], sc, ['selector', y], sc,
1409 * ['arguments', z], sc, ['block', q], sc` where `x` is `include` o r
1410 * `extend`, `y` is mixin's identifier (selector), `z` are argument s
1411 * passed to the mixin, `q` is block passed to the mixin containing a
1412 * ruleset > selector > keyframesSelector, and `sc` are optional
1413 * whitespaces
1414 */function getInclude1(){var startPos=pos;var x=[].concat(getAtkeyword( ),getSC(),getIdentOrInterpolation(),getSC(),getArguments(),getSC(),getKeyframesB locks());var token=tokens[startPos];return newNode(NodeType.IncludeType,x,token. ln,token.col);} /**
1415 * Check if token is part of an included mixin like `@include nani(foo) {...}`
1416 * @param {Number} i Token's index number
1417 * @returns {Number} Length of the include
1418 */function checkInclude2(i){var start=i;var l=undefined;if(l = checkAtk eyword(i))i += l;else return 0;if(tokens[start + 1].value !== 'include')return 0 ;if(l = checkSC(i))i += l;else return 0;if(l = checkIdentOrInterpolation(i))i += l;else return 0;if(l = checkSC(i))i += l;if(l = checkArguments(i))i += l;else r eturn 0;if(l = checkSC(i))i += l;if(l = checkBlock(i))i += l;else return 0;retur n i - start;} /**
1419 * Get node with included mixin like `@include nani(foo) {...}`
1420 * @returns {Array} `['include', ['atkeyword', x], sc, ['selector', y], sc,
1421 * ['arguments', z], sc, ['block', q], sc` where `x` is `include` o r
1422 * `extend`, `y` is mixin's identifier (selector), `z` are argument s
1423 * passed to the mixin, `q` is block passed to the mixin and `sc`
1424 * are optional whitespaces
1425 */function getInclude2(){var startPos=pos;var x=[].concat(getAtkeyword( ),getSC(),getIdentOrInterpolation(),getSC(),getArguments(),getSC(),getBlock());v ar token=tokens[startPos];return newNode(NodeType.IncludeType,x,token.ln,token.c ol);} /**
1426 * Check if token is part of an included mixin like `@include nani(foo)`
1427 * @param {Number} i Token's index number
1428 * @returns {Number} Length of the include
1429 */function checkInclude3(i){var start=i;var l=undefined;if(l = checkAtk eyword(i))i += l;else return 0;if(tokens[start + 1].value !== 'include')return 0 ;if(l = checkSC(i))i += l;else return 0;if(l = checkIdentOrInterpolation(i))i += l;else return 0;if(l = checkSC(i))i += l;if(l = checkArguments(i))i += l;else r eturn 0;return i - start;} /**
1430 * Get node with included mixin like `@include nani(foo)`
1431 * @returns {Array} `['include', ['atkeyword', x], sc, ['selector', y], sc,
1432 * ['arguments', z], sc]` where `x` is `include` or `extend`, `y` i s
1433 * mixin's identifier (selector), `z` are arguments passed to the
1434 * mixin and `sc` are optional whitespaces
1435 */function getInclude3(){var startPos=pos;var x=[].concat(getAtkeyword( ),getSC(),getIdentOrInterpolation(),getSC(),getArguments());var token=tokens[sta rtPos];return newNode(NodeType.IncludeType,x,token.ln,token.col);} /**
1436 * Check if token is part of an included mixin with a content block pass ed
1437 * as an argument (e.g. `@include nani {...}`)
1438 * @param {Number} i Token's index number
1439 * @returns {Number} Length of the mixin
1440 */function checkInclude4(i){var start=i;var l=undefined;if(l = checkAtk eyword(i))i += l;else return 0;if(tokens[start + 1].value !== 'include')return 0 ;if(l = checkSC(i))i += l;else return 0;if(l = checkIdentOrInterpolation(i))i += l;else return 0;if(l = checkSC(i))i += l;if(l = checkBlock(i))i += l;else retur n 0;return i - start;} /**
1441 * Get node with an included mixin with a content block passed
1442 * as an argument (e.g. `@include nani {...}`)
1443 * @returns {Array} `['include', x]`
1444 */function getInclude4(){var startPos=pos;var x=[].concat(getAtkeyword( ),getSC(),getIdentOrInterpolation(),getSC(),getBlock());var token=tokens[startPo s];return newNode(NodeType.IncludeType,x,token.ln,token.col);} /**
1445 * @param {Number} i Token's index number
1446 * @returns {Number}
1447 */function checkInclude5(i){var start=i;var l=undefined;if(l = checkAtk eyword(i))i += l;else return 0;if(tokens[start + 1].value !== 'include')return 0 ;if(l = checkSC(i))i += l;else return 0;if(l = checkIdentOrInterpolation(i))i += l;else return 0;return i - start;} /**
1448 * @returns {Array} `['include', x]`
1449 */function getInclude5(){var startPos=pos;var x=[].concat(getAtkeyword( ),getSC(),getIdentOrInterpolation());var token=tokens[startPos];return newNode(N odeType.IncludeType,x,token.ln,token.col);} /**
1450 * Check if token is part of an interpolated variable (e.g. `#{$nani}`).
1451 * @param {Number} i Token's index number
1452 * @returns {Number}
1453 */function checkInterpolation(i){var start=i;var l=undefined;if(i >= to kensLength)return 0;if(tokens[i].type !== TokenType.NumberSign || !tokens[i + 1] || tokens[i + 1].type !== TokenType.LeftCurlyBracket)return 0;i += 2;while(toke ns[i].type !== TokenType.RightCurlyBracket) {if(l = checkArgument(i))i += l;else return 0;}return tokens[i].type === TokenType.RightCurlyBracket?i - start + 1:0 ;} /**
1454 * Get node with an interpolated variable
1455 * @returns {Array} `['interpolation', x]`
1456 */function getInterpolation(){var startPos=pos;var x=[];var token=token s[startPos];var line=token.ln;var column=token.col; // Skip `#{`:
1457 pos += 2;while(pos < tokensLength && tokens[pos].type !== TokenType.Righ tCurlyBracket) {var body=getArgument();if(typeof body.content === 'string')x.pus h(body);else x = x.concat(body);}var end=getLastPosition(x,line,column,1); // Sk ip `}`:
1458 pos++;return newNode(NodeType.InterpolationType,x,token.ln,token.col,end );}function checkKeyframesBlock(i){var start=i;var l=undefined;if(i >= tokensLen gth)return 0;if(l = checkKeyframesSelector(i))i += l;else return 0;if(l = checkS C(i))i += l;if(l = checkBlock(i))i += l;else return 0;return i - start;}function getKeyframesBlock(){var type=NodeType.RulesetType;var token=tokens[pos];var lin e=token.ln;var column=token.col;var content=[].concat([getKeyframesSelector()],g etSC(),[getBlock()]);return newNode(type,content,line,column);}function checkKey framesBlocks(i){var start=i;var l=undefined;if(i < tokensLength && tokens[i].typ e === TokenType.LeftCurlyBracket)i++;else return 0;if(l = checkSC(i))i += l;if(l = checkKeyframesBlock(i))i += l;else return 0;while(tokens[i].type !== TokenTyp e.RightCurlyBracket) {if(l = checkSC(i))i += l;else if(l = checkKeyframesBlock(i ))i += l;else break;}if(i < tokensLength && tokens[i].type === TokenType.RightCu rlyBracket)i++;else return 0;return i - start;}function getKeyframesBlocks(){var type=NodeType.BlockType;var token=tokens[pos];var line=token.ln;var column=toke n.col;var content=[];var keyframesBlocksEnd=token.right; // Skip `{`.
1459 pos++;while(pos < keyframesBlocksEnd) {if(checkSC(pos))content = content .concat(getSC());else if(checkKeyframesBlock(pos))content.push(getKeyframesBlock ());}var end=getLastPosition(content,line,column,1); // Skip `}`.
1460 pos++;return newNode(type,content,line,column,end);} /**
1461 * Check if token is part of a @keyframes rule.
1462 * @param {Number} i Token's index number
1463 * @return {Number} Length of the @keyframes rule
1464 */function checkKeyframesRule(i){var start=i;var l=undefined;if(i >= to kensLength)return 0;if(l = checkAtkeyword(i))i += l;else return 0;var atruleName =joinValues2(i - l,l);if(atruleName.indexOf('keyframes') === -1)return 0;if(l = checkSC(i))i += l;else return 0;if(l = checkIdentOrInterpolation(i))i += l;else return 0;if(l = checkSC(i))i += l;if(l = checkKeyframesBlocks(i))i += l;else ret urn 0;return i - start;} /**
1465 * @return {Node}
1466 */function getKeyframesRule(){var type=NodeType.AtruleType;var token=to kens[pos];var line=token.ln;var column=token.col;var content=[].concat([getAtkey word()],getSC(),getIdentOrInterpolation(),getSC(),[getKeyframesBlocks()]);return newNode(type,content,line,column);}function checkKeyframesSelector(i){var start =i;var l=undefined;if(i >= tokensLength)return 0;if(l = checkIdent(i)){ // Valid selectors are only `from` and `to`.
1467 var selector=joinValues2(i,l);if(selector !== 'from' && selector !== 'to ')return 0;i += l;tokens[start].keyframesSelectorType = 1;}else if(l = checkPerc entage(i)){i += l;tokens[start].keyframesSelectorType = 2;}else if(l = checkInte rpolation(i)){i += l;tokens[start].keyframesSelectorType = 3;}else {return 0;}re turn i - start;}function getKeyframesSelector(){var keyframesSelectorType=NodeTy pe.KeyframesSelectorType;var selectorType=NodeType.SelectorType;var token=tokens [pos];var line=token.ln;var column=token.col;var content=[];if(token.keyframesSe lectorType === 1){content.push(getIdent());}else if(token.keyframesSelectorType === 2){content.push(getPercentage());}else {content.push(getInterpolation());}va r keyframesSelector=newNode(keyframesSelectorType,content,line,column);return ne wNode(selectorType,[keyframesSelector],line,column);} /**
1468 * Check if token is part of a loop.
1469 * @param {Number} i Token's index number
1470 * @returns {Number} Length of the loop
1471 */function checkLoop(i){var start=i;var l=undefined;if(i >= tokensLengt h)return 0;if(l = checkAtkeyword(i))i += l;else return 0;if(['for','each','while '].indexOf(tokens[start + 1].value) < 0)return 0;while(i < tokensLength) {if(l = checkBlock(i)){i += l;break;}else if(l = checkVariable(i) || checkNumber(i) || checkInterpolation(i) || checkIdent(i) || checkSC(i) || checkOperator(i) || chec kCombinator(i) || checkString(i))i += l;else return 0;}return i - start;} /**
1472 * Get node with a loop.
1473 * @returns {Array} `['loop', x]`
1474 */function getLoop(){var startPos=pos;var x=[];x.push(getAtkeyword());w hile(pos < tokensLength) {if(checkBlock(pos)){x.push(getBlock());break;}else if( checkVariable(pos))x.push(getVariable());else if(checkNumber(pos))x.push(getNumb er());else if(checkInterpolation(pos))x.push(getInterpolation());else if(checkId ent(pos))x.push(getIdent());else if(checkOperator(pos))x.push(getOperator());els e if(checkCombinator(pos))x.push(getCombinator());else if(checkSC(pos))x = x.con cat(getSC());else if(checkString(pos))x.push(getString());}var token=tokens[star tPos];return newNode(NodeType.LoopType,x,token.ln,token.col);} /**
1475 * Check if token is part of a mixin
1476 * @param {Number} i Token's index number
1477 * @returns {Number} Length of the mixin
1478 */function checkMixin(i){var start=i;var l=undefined;if(i >= tokensLeng th)return 0;if((l = checkAtkeyword(i)) && tokens[i + 1].value === 'mixin')i += l ;else return 0;if(l = checkSC(i))i += l;if(l = checkIdentOrInterpolation(i))i += l;else return 0;if(l = checkSC(i))i += l;if(l = checkArguments(i))i += l;if(l = checkSC(i))i += l;if(l = checkBlock(i))i += l;else return 0;return i - start;} /**
1479 * Get node with a mixin
1480 * @returns {Array} `['mixin', x]`
1481 */function getMixin(){var startPos=pos;var x=[getAtkeyword()];x = x.con cat(getSC());if(checkIdentOrInterpolation(pos))x = x.concat(getIdentOrInterpolat ion());x = x.concat(getSC());if(checkArguments(pos))x.push(getArguments());x = x .concat(getSC());if(checkBlock(pos))x.push(getBlock());var token=tokens[startPos ];return newNode(NodeType.MixinType,x,token.ln,token.col);} /**
1482 * Check if token is a namespace sign (`|`)
1483 * @param {Number} i Token's index number
1484 * @returns {Number} `1` if token is `|`, `0` if not
1485 */function checkNamespace(i){return i < tokensLength && tokens[i].type === TokenType.VerticalLine?1:0;} /**
1486 * Get node with a namespace sign
1487 * @returns {Array} `['namespace']`
1488 */function getNamespace(){var startPos=pos;pos++;var token=tokens[start Pos];return newNode(NodeType.NamespaceType,'|',token.ln,token.col);} /**
1489 * @param {Number} i Token's index number
1490 * @returns {Number}
1491 */function checkNmName2(i){if(tokens[i].type === TokenType.Identifier)r eturn 1;else if(tokens[i].type !== TokenType.DecimalNumber)return 0;i++;return i < tokensLength && tokens[i].type === TokenType.Identifier?2:1;} /**
1492 * @returns {String}
1493 */function getNmName2(){var s=tokens[pos].value;if(tokens[pos++].type = == TokenType.DecimalNumber && pos < tokensLength && tokens[pos].type === TokenTy pe.Identifier)s += tokens[pos++].value;return s;} /**
1494 * Check if token is part of a number
1495 * @param {Number} i Token's index number
1496 * @returns {Number} Length of number
1497 */function checkNumber(i){if(i >= tokensLength)return 0;if(tokens[i].nu mber_l)return tokens[i].number_l; // `10`:
1498 if(i < tokensLength && tokens[i].type === TokenType.DecimalNumber && (!t okens[i + 1] || tokens[i + 1] && tokens[i + 1].type !== TokenType.FullStop))retu rn tokens[i].number_l = 1,tokens[i].number_l; // `10.`:
1499 if(i < tokensLength && tokens[i].type === TokenType.DecimalNumber && tok ens[i + 1] && tokens[i + 1].type === TokenType.FullStop && (!tokens[i + 2] || to kens[i + 2].type !== TokenType.DecimalNumber))return tokens[i].number_l = 2,toke ns[i].number_l; // `.10`:
1500 if(i < tokensLength && tokens[i].type === TokenType.FullStop && tokens[i + 1].type === TokenType.DecimalNumber)return tokens[i].number_l = 2,tokens[i].n umber_l; // `10.10`:
1501 if(i < tokensLength && tokens[i].type === TokenType.DecimalNumber && tok ens[i + 1] && tokens[i + 1].type === TokenType.FullStop && tokens[i + 2] && toke ns[i + 2].type === TokenType.DecimalNumber)return tokens[i].number_l = 3,tokens[ i].number_l;return 0;} /**
1502 * Get node with number
1503 * @returns {Array} `['number', x]` where `x` is a number converted
1504 * to string.
1505 */function getNumber(){var s='';var startPos=pos;var l=tokens[pos].numb er_l;for(var j=0;j < l;j++) {s += tokens[pos + j].value;}pos += l;var token=toke ns[startPos];return newNode(NodeType.NumberType,s,token.ln,token.col);} /**
1506 * Check if token is an operator (`/`, `%`, `,`, `:` or `=`).
1507 * @param {Number} i Token's index number
1508 * @returns {Number} `1` if token is an operator, otherwise `0`
1509 */function checkOperator(i){if(i >= tokensLength)return 0;switch(tokens [i].type){case TokenType.Solidus:case TokenType.PercentSign:case TokenType.Comma :case TokenType.Colon:case TokenType.EqualsSign:case TokenType.EqualitySign:case TokenType.InequalitySign:case TokenType.LessThanSign:case TokenType.GreaterThan Sign:case TokenType.Asterisk:return 1;}return 0;} /**
1510 * Get node with an operator
1511 * @returns {Array} `['operator', x]` where `x` is an operator converted
1512 * to string.
1513 */function getOperator(){var startPos=pos;var x=tokens[pos++].value;var token=tokens[startPos];return newNode(NodeType.OperatorType,x,token.ln,token.co l);} /**
1514 * Check if token is part of `!optional` word
1515 * @param {Number} i Token's index number
1516 * @returns {Number}
1517 */function checkOptional(i){var start=i;var l=undefined;if(i >= tokensL ength || tokens[i++].type !== TokenType.ExclamationMark)return 0;if(l = checkSC( i))i += l;if(tokens[i].value === 'optional'){tokens[start].optionalEnd = i;retur n i - start + 1;}else {return 0;}} /**
1518 * Get node with `!optional` word
1519 */function getOptional(){var token=tokens[pos];var line=token.ln;var co lumn=token.col;var content=joinValues(pos,token.optionalEnd);pos = token.optiona lEnd + 1;return newNode(NodeType.OptionalType,content,line,column);} /**
1520 * Check if token is part of text inside parentheses, e.g. `(1)`
1521 * @param {Number} i Token's index number
1522 * @return {Number}
1523 */function checkParentheses(i){if(i >= tokensLength || tokens[i].type ! == TokenType.LeftParenthesis)return 0;return tokens[i].right - i + 1;} /**
1524 * Get node with text inside parentheses, e.g. `(1)`
1525 * @return {Node}
1526 */function getParentheses(){var type=NodeType.ParenthesesType;var token =tokens[pos];var line=token.ln;var column=token.col;pos++;var tsets=getTsets();v ar end=getLastPosition(tsets,line,column,1);pos++;return newNode(type,tsets,line ,column,end);} /**
1527 * Check if token is a parent selector (`&`).
1528 * @param {Number} i Token's index number
1529 * @returns {Number}
1530 */function checkParentSelector(i){return i < tokensLength && tokens[i]. type === TokenType.Ampersand?1:0;} /**
1531 * Get node with a parent selector
1532 */function getParentSelector(){var startPos=pos;pos++;var token=tokens[ startPos];return newNode(NodeType.ParentSelectorType,'&',token.ln,token.col);}fu nction checkParentSelectorExtension(i){if(i >= tokensLength)return 0;var start=i ;var l=undefined;while(i < tokensLength) {if(l = checkNumber(i) || checkIdentOrI nterpolation(i))i += l;else break;}return i - start;}function getParentSelectorE xtension(){var type=NodeType.ParentSelectorExtensionType;var token=tokens[pos];v ar line=token.ln;var column=token.col;var content=[];while(pos < tokensLength) { if(checkNumber(pos))content.push(getNumber());else if(checkIdentOrInterpolation( pos))content = content.concat(getIdentOrInterpolation());else break;}return newN ode(type,content,line,column);}function checkParentSelectorWithExtension(i){if(i >= tokensLength)return 0;var start=i;var l=undefined;if(l = checkParentSelector (i))i += l;else return 0;if(l = checkParentSelectorExtension(i))i += l;return i - start;}function getParentSelectorWithExtension(){var content=[getParentSelecto r()];if(checkParentSelectorExtension(pos))content.push(getParentSelectorExtensio n());return content;} /**
1533 * Check if token is part of a number with percent sign (e.g. `10%`)
1534 * @param {Number} i Token's index number
1535 * @returns {Number}
1536 */function checkPercentage(i){var x;if(i >= tokensLength)return 0;x = c heckNumber(i);if(!x || i + x >= tokensLength)return 0;return tokens[i + x].type === TokenType.PercentSign?x + 1:0;} /**
1537 * Get node of number with percent sign
1538 * @returns {Array} `['percentage', ['number', x]]` where `x` is a numbe r
1539 * (without percent sign) converted to string.
1540 */function getPercentage(){var startPos=pos;var x=[getNumber()];var tok en=tokens[startPos];var line=token.ln;var column=token.col;var end=getLastPositi on(x,line,column,1);pos++;return newNode(NodeType.PercentageType,x,token.ln,toke n.col,end);} /**
1541 * Check if token is part of a placeholder selector (e.g. `%abc`).
1542 * @param {Number} i Token's index number
1543 * @returns {Number} Length of the selector
1544 */function checkPlaceholder(i){var l;if(i >= tokensLength)return 0;if(t okens[i].placeholder_l)return tokens[i].placeholder_l;if(tokens[i].type === Toke nType.PercentSign && (l = checkIdentOrInterpolation(i + 1))){tokens[i].placehold er_l = l + 1;return l + 1;}else return 0;} /**
1545 * Get node with a placeholder selector
1546 * @returns {Array} `['placeholder', ['ident', x]]` where x is a placeho lder's
1547 * identifier (without `%`, e.g. `abc`).
1548 */function getPlaceholder(){var startPos=pos;pos++;var x=getIdentOrInte rpolation();var token=tokens[startPos];return newNode(NodeType.PlaceholderType,x ,token.ln,token.col);} /**
1549 * @param {Number} i Token's index number
1550 * @returns {Number}
1551 */function checkProgid(i){var start=i;var l=undefined;if(i >= tokensLen gth)return 0;if(joinValues2(i,6) === 'progid:DXImageTransform.Microsoft.')i += 6 ;else return 0;if(l = checkIdentOrInterpolation(i))i += l;else return 0;if(l = c heckSC(i))i += l;if(tokens[i].type === TokenType.LeftParenthesis){tokens[start]. progid_end = tokens[i].right;i = tokens[i].right + 1;}else return 0;return i - s tart;} /**
1552 * @returns {Array}
1553 */function getProgid(){var startPos=pos;var progid_end=tokens[pos].prog id_end;var x=joinValues(pos,progid_end);pos = progid_end + 1;var token=tokens[st artPos];return newNode(NodeType.ProgidType,x,token.ln,token.col);} /**
1554 * Check if token is part of a property
1555 * @param {Number} i Token's index number
1556 * @returns {Number} Length of the property
1557 */function checkProperty(i){var start=i;var l=undefined;if(i >= tokensL ength)return 0;if(l = checkVariable(i) || checkIdentOrInterpolation(i))i += l;el se return 0;return i - start;} /**
1558 * Get node with a property
1559 * @returns {Array} `['property', x]`
1560 */function getProperty(){var startPos=pos;var x=[];if(checkVariable(pos )){x.push(getVariable());}else {x = x.concat(getIdentOrInterpolation());}var tok en=tokens[startPos];return newNode(NodeType.PropertyType,x,token.ln,token.col);} /**
1561 * Check if token is a colon
1562 * @param {Number} i Token's index number
1563 * @returns {Number} `1` if token is a colon, otherwise `0`
1564 */function checkPropertyDelim(i){return i < tokensLength && tokens[i].t ype === TokenType.Colon?1:0;} /**
1565 * Get node with a colon
1566 * @returns {Array} `['propertyDelim']`
1567 */function getPropertyDelim(){var startPos=pos;pos++;var token=tokens[s tartPos];return newNode(NodeType.PropertyDelimType,':',token.ln,token.col);} /**
1568 * @param {Number} i Token's index number
1569 * @returns {Number}
1570 */function checkPseudo(i){return checkPseudoe(i) || checkPseudoc(i);} / **
1571 * @returns {Array}
1572 */function getPseudo(){if(checkPseudoe(pos))return getPseudoe();if(chec kPseudoc(pos))return getPseudoc();} /**
1573 * @param {Number} i Token's index number
1574 * @returns {Number}
1575 */function checkPseudoe(i){var l;if(i >= tokensLength || tokens[i++].ty pe !== TokenType.Colon || i >= tokensLength || tokens[i++].type !== TokenType.Co lon)return 0;return (l = checkIdentOrInterpolation(i))?l + 2:0;} /**
1576 * @returns {Array}
1577 */function getPseudoe(){var startPos=pos;pos += 2;var x=getIdentOrInter polation();var token=tokens[startPos];return newNode(NodeType.PseudoeType,x,toke n.ln,token.col);} /**
1578 * @param {Number} i Token's index number
1579 * @returns {Number}
1580 */function checkPseudoc(i){var l;if(i >= tokensLength || tokens[i].type !== TokenType.Colon)return 0;if(l = checkPseudoClass3(i))tokens[i].pseudoClassT ype = 3;else if(l = checkPseudoClass4(i))tokens[i].pseudoClassType = 4;else if(l = checkPseudoClass5(i))tokens[i].pseudoClassType = 5;else if(l = checkPseudoCla ss1(i))tokens[i].pseudoClassType = 1;else if(l = checkPseudoClass2(i))tokens[i]. pseudoClassType = 2;else if(l = checkPseudoClass6(i))tokens[i].pseudoClassType = 6;else return 0;return l;} /**
1581 * @returns {Array}
1582 */function getPseudoc(){var childType=tokens[pos].pseudoClassType;if(ch ildType === 1)return getPseudoClass1();if(childType === 2)return getPseudoClass2 ();if(childType === 3)return getPseudoClass3();if(childType === 4)return getPseu doClass4();if(childType === 5)return getPseudoClass5();if(childType === 6)return getPseudoClass6();} /**
1583 * (-) `:not(panda)`
1584 */function checkPseudoClass1(i){var start=i; // Skip `:`.
1585 i++;if(i >= tokensLength)return 0;var l=undefined;if(l = checkIdentOrInt erpolation(i))i += l;else return 0;if(i >= tokensLength || tokens[i].type !== To kenType.LeftParenthesis)return 0;var right=tokens[i].right; // Skip `(`.
1586 i++;if(l = checkSelectorsGroup(i))i += l;else return 0;if(i !== right)re turn 0;return right - start + 1;} /**
1587 * (-) `:not(panda)`
1588 */function getPseudoClass1(){var type=NodeType.PseudocType;var token=to kens[pos];var line=token.ln;var column=token.col;var content=[]; // Skip `:`.
1589 pos++;content = content.concat(getIdentOrInterpolation());{var _type=Nod eType.ArgumentsType;var _token=tokens[pos];var _line=_token.ln;var _column=_toke n.col; // Skip `(`.
1590 pos++;var selectors=getSelectorsGroup();var end=getLastPosition(selector s,_line,_column,1);var args=newNode(_type,selectors,_line,_column,end);content.p ush(args); // Skip `)`.
1591 pos++;}return newNode(type,content,line,column);} /**
1592 * (1) `:nth-child(odd)`
1593 * (2) `:nth-child(even)`
1594 * (3) `:lang(de-DE)`
1595 */function checkPseudoClass2(i){var start=i;var l=0; // Skip `:`.
1596 i++;if(i >= tokensLength)return 0;if(l = checkIdentOrInterpolation(i))i += l;else return 0;if(i >= tokensLength || tokens[i].type !== TokenType.LeftPare nthesis)return 0;var right=tokens[i].right; // Skip `(`.
1597 i++;if(l = checkSC(i))i += l;if(l = checkIdentOrInterpolation(i))i += l; else return 0;if(l = checkSC(i))i += l;if(i !== right)return 0;return i - start + 1;}function getPseudoClass2(){var type=NodeType.PseudocType;var token=tokens[p os];var line=token.ln;var column=token.col;var content=[]; // Skip `:`.
1598 pos++;content = content.concat(getIdentOrInterpolation());var l=tokens[p os].ln;var c=tokens[pos].col;var value=[]; // Skip `(`.
1599 pos++;value = value.concat(getSC()).concat(getIdentOrInterpolation()).co ncat(getSC());var end=getLastPosition(value,l,c,1);var args=newNode(NodeType.Arg umentsType,value,l,c,end);content.push(args); // Skip `)`.
1600 pos++;return newNode(type,content,line,column);} /**
1601 * (-) `:nth-child(-3n + 2)`
1602 */function checkPseudoClass3(i){var start=i;var l=0; // Skip `:`.
1603 i++;if(i >= tokensLength)return 0;if(l = checkIdentOrInterpolation(i))i += l;else return 0;if(i >= tokensLength || tokens[i].type !== TokenType.LeftPare nthesis)return 0;var right=tokens[i].right; // Skip `(`.
1604 i++;if(l = checkSC(i))i += l;if(l = checkUnary(i))i += l;if(i >= tokensL ength)return 0;if(tokens[i].type === TokenType.DecimalNumber)i++;if(i >= tokensL ength)return 0;if(tokens[i].value === 'n')i++;else return 0;if(l = checkSC(i))i += l;if(i >= tokensLength)return 0;if(tokens[i].value === '+' || tokens[i].value === '-')i++;else return 0;if(l = checkSC(i))i += l;if(tokens[i].type === TokenT ype.DecimalNumber)i++;else return 0;if(l = checkSC(i))i += l;if(i !== right)retu rn 0;return i - start + 1;}function getPseudoClass3(){var type=NodeType.PseudocT ype;var token=tokens[pos];var line=token.ln;var column=token.col; // Skip `:`.
1605 pos++;var content=getIdentOrInterpolation();var l=tokens[pos].ln;var c=t okens[pos].col;var value=[]; // Skip `(`.
1606 pos++;if(checkUnary(pos))value.push(getUnary());if(checkNumber(pos))valu e.push(getNumber());{var _l=tokens[pos].ln;var _c=tokens[pos].col;var _content=t okens[pos].value;var ident=newNode(NodeType.IdentType,_content,_l,_c);value.push (ident);pos++;}value = value.concat(getSC());if(checkUnary(pos))value.push(getUn ary());value = value.concat(getSC());if(checkNumber(pos))value.push(getNumber()) ;value = value.concat(getSC());var end=getLastPosition(value,l,c,1);var args=new Node(NodeType.ArgumentsType,value,l,c,end);content.push(args); // Skip `)`.
1607 pos++;return newNode(type,content,line,column);} /**
1608 * (-) `:nth-child(-3n)`
1609 */function checkPseudoClass4(i){var start=i;var l=0; // Skip `:`.
1610 i++;if(i >= tokensLength)return 0;if(l = checkIdentOrInterpolation(i))i += l;else return 0;if(i >= tokensLength)return 0;if(tokens[i].type !== TokenType .LeftParenthesis)return 0;var right=tokens[i].right; // Skip `(`.
1611 i++;if(l = checkSC(i))i += l;if(l = checkUnary(i))i += l;if(tokens[i].ty pe === TokenType.DecimalNumber)i++;if(tokens[i].value === 'n')i++;else return 0; if(l = checkSC(i))i += l;if(i !== right)return 0;return i - start + 1;}function getPseudoClass4(){var type=NodeType.PseudocType;var token=tokens[pos];var line=t oken.ln;var column=token.col; // Skip `:`.
1612 pos++;var content=getIdentOrInterpolation();var l=tokens[pos].ln;var c=t okens[pos].col;var value=[]; // Skip `(`.
1613 pos++;value = value.concat(getSC());if(checkUnary(pos))value.push(getUna ry());if(checkNumber(pos))value.push(getNumber());if(checkIdent(pos))value.push( getIdent());value = value.concat(getSC());var end=getLastPosition(value,l,c,1);v ar args=newNode(NodeType.ArgumentsType,value,l,c,end);content.push(args); // Ski p `)`.
1614 pos++;return newNode(type,content,line,column);} /**
1615 * (-) `:nth-child(+8)`
1616 */function checkPseudoClass5(i){var start=i;var l=0; // Skip `:`.
1617 i++;if(i >= tokensLength)return 0;if(l = checkIdentOrInterpolation(i))i += l;else return 0;if(i >= tokensLength)return 0;if(tokens[i].type !== TokenType .LeftParenthesis)return 0;var right=tokens[i].right; // Skip `(`.
1618 i++;if(l = checkSC(i))i += l;if(l = checkUnary(i))i += l;if(tokens[i].ty pe === TokenType.DecimalNumber)i++;else return 0;if(l = checkSC(i))i += l;if(i ! == right)return 0;return i - start + 1;}function getPseudoClass5(){var type=Node Type.PseudocType;var token=tokens[pos];var line=token.ln;var column=token.col; / / Skip `:`.
1619 pos++;var content=getIdentOrInterpolation();var l=tokens[pos].ln;var c=t okens[pos].col;var value=[]; // Skip `(`.
1620 pos++;if(checkUnary(pos))value.push(getUnary());if(checkNumber(pos))valu e.push(getNumber());value = value.concat(getSC());var end=getLastPosition(value, l,c,1);var args=newNode(NodeType.ArgumentsType,value,l,c,end);content.push(args) ; // Skip `)`.
1621 pos++;return newNode(type,content,line,column);} /**
1622 * (-) `:checked`
1623 */function checkPseudoClass6(i){var start=i;var l=0; // Skip `:`.
1624 i++;if(i >= tokensLength)return 0;if(l = checkIdentOrInterpolation(i))i += l;else return 0;return i - start;}function getPseudoClass6(){var type=NodeTyp e.PseudocType;var token=tokens[pos];var line=token.ln;var column=token.col; // S kip `:`.
1625 pos++;var content=getIdentOrInterpolation();return newNode(type,content, line,column);} /**
1626 * @param {Number} i Token's index number
1627 * @returns {Number}
1628 */function checkRuleset(i){var start=i;var l=undefined;if(i >= tokensLe ngth)return 0;if(l = checkSelectorsGroup(i))i += l;else return 0;if(l = checkSC( i))i += l;if(l = checkBlock(i))i += l;else return 0;return i - start;}function g etRuleset(){var type=NodeType.RulesetType;var token=tokens[pos];var line=token.l n;var column=token.col;var content=[];content = content.concat(getSelectorsGroup ());content = content.concat(getSC());content.push(getBlock());return newNode(ty pe,content,line,column);} /**
1629 * Check if token is marked as a space (if it's a space or a tab
1630 * or a line break).
1631 * @param {Number} i
1632 * @returns {Number} Number of spaces in a row starting with the given t oken.
1633 */function checkS(i){return i < tokensLength && tokens[i].ws?tokens[i]. ws_last - i + 1:0;} /**
1634 * Get node with spaces
1635 * @returns {Array} `['s', x]` where `x` is a string containing spaces
1636 */function getS(){var startPos=pos;var x=joinValues(pos,tokens[pos].ws_ last);pos = tokens[pos].ws_last + 1;var token=tokens[startPos];return newNode(No deType.SType,x,token.ln,token.col);} /**
1637 * Check if token is a space or a comment.
1638 * @param {Number} i Token's index number
1639 * @returns {Number} Number of similar (space or comment) tokens
1640 * in a row starting with the given token.
1641 */function checkSC(i){if(i >= tokensLength)return 0;var l=undefined;var lsc=0;while(i < tokensLength) {if(!(l = checkS(i)) && !(l = checkCommentML(i)) && !(l = checkCommentSL(i)))break;i += l;lsc += l;}return lsc || 0;} /**
1642 * Get node with spaces and comments
1643 * @returns {Array} Array containing nodes with spaces (if there are any )
1644 * and nodes with comments (if there are any):
1645 * `[['s', x]*, ['comment', y]*]` where `x` is a string of spaces
1646 * and `y` is a comment's text (without `/*` and `* /`).
1647 */function getSC(){var sc=[];if(pos >= tokensLength)return sc;while(pos < tokensLength) {if(checkS(pos))sc.push(getS());else if(checkCommentML(pos))sc. push(getCommentML());else if(checkCommentSL(pos))sc.push(getCommentSL());else br eak;}return sc;} /**
1648 * Check if token is part of a hexadecimal number (e.g. `#fff`) inside
1649 * a simple selector
1650 * @param {Number} i Token's index number
1651 * @returns {Number}
1652 */function checkShash(i){var l;if(i >= tokensLength || tokens[i].type ! == TokenType.NumberSign)return 0;return (l = checkIdentOrInterpolation(i + 1))?l + 1:0;} /**
1653 * Get node with a hexadecimal number (e.g. `#fff`) inside a simple
1654 * selector
1655 * @returns {Array} `['shash', x]` where `x` is a hexadecimal number
1656 * converted to string (without `#`, e.g. `fff`)
1657 */function getShash(){var startPos=pos;var token=tokens[startPos];pos++ ;var x=getIdentOrInterpolation();return newNode(NodeType.ShashType,x,token.ln,to ken.col);} /**
1658 * Check if token is part of a string (text wrapped in quotes)
1659 * @param {Number} i Token's index number
1660 * @returns {Number} `1` if token is part of a string, `0` if not
1661 */function checkString(i){return i < tokensLength && (tokens[i].type == = TokenType.StringSQ || tokens[i].type === TokenType.StringDQ)?1:0;} /**
1662 * Get string's node
1663 * @returns {Array} `['string', x]` where `x` is a string (including
1664 * quotes).
1665 */function getString(){var startPos=pos;var x=tokens[pos++].value;var t oken=tokens[startPos];return newNode(NodeType.StringType,x,token.ln,token.col);} /**
1666 * Validate stylesheet: it should consist of any number (0 or more) of
1667 * rulesets (sets of rules with selectors), @-rules, whitespaces or
1668 * comments.
1669 * @param {Number} i Token's index number
1670 * @returns {Number}
1671 */function checkStylesheet(i){var start=i;var l=undefined;while(i < tok ensLength) {if(l = checkSC(i) || checkDeclaration(i) || checkDeclDelim(i) || che ckInclude(i) || checkExtend(i) || checkMixin(i) || checkLoop(i) || checkConditio nalStatement(i) || checkAtrule(i) || checkRuleset(i))i += l;else throwError(i);} return i - start;} /**
1672 * @returns {Array} `['stylesheet', x]` where `x` is all stylesheet's
1673 * nodes.
1674 */function getStylesheet(){var startPos=pos;var x=[];while(pos < tokens Length) {if(checkSC(pos))x = x.concat(getSC());else if(checkRuleset(pos))x.push( getRuleset());else if(checkInclude(pos))x.push(getInclude());else if(checkExtend (pos))x.push(getExtend());else if(checkMixin(pos))x.push(getMixin());else if(che ckLoop(pos))x.push(getLoop());else if(checkConditionalStatement(pos))x.push(getC onditionalStatement());else if(checkAtrule(pos))x.push(getAtrule());else if(chec kDeclaration(pos))x.push(getDeclaration());else if(checkDeclDelim(pos))x.push(ge tDeclDelim());else throwError();}var token=tokens[startPos];return newNode(NodeT ype.StylesheetType,x,token.ln,token.col);} /**
1675 * @param {Number} i Token's index number
1676 * @returns {Number}
1677 */function checkTset(i){return checkVhash(i) || checkOperator(i) || che ckAny(i) || checkSC(i) || checkInterpolation(i);} /**
1678 * @returns {Array}
1679 */function getTset(){if(checkVhash(pos))return getVhash();else if(check Operator(pos))return getOperator();else if(checkAny(pos))return getAny();else if (checkSC(pos))return getSC();else if(checkInterpolation(pos))return getInterpola tion();} /**
1680 * @param {Number} i Token's index number
1681 * @returns {Number}
1682 */function checkTsets(i){var start=i;var l=undefined;if(i >= tokensLeng th)return 0;while(l = checkTset(i)) {i += l;}return i - start;} /**
1683 * @returns {Array}
1684 */function getTsets(){var x=[];var t=undefined;while(t = getTset()) {if (typeof t.content === 'string')x.push(t);else x = x.concat(t);}return x;} /**
1685 * Check if token is an unary (arithmetical) sign (`+` or `-`)
1686 * @param {Number} i Token's index number
1687 * @returns {Number} `1` if token is an unary sign, `0` if not
1688 */function checkUnary(i){return i < tokensLength && (tokens[i].type === TokenType.HyphenMinus || tokens[i].type === TokenType.PlusSign)?1:0;} /**
1689 * Get node with an unary (arithmetical) sign (`+` or `-`)
1690 * @returns {Array} `['unary', x]` where `x` is an unary sign
1691 * converted to string.
1692 */function getUnary(){var startPos=pos;var x=tokens[pos++].value;var to ken=tokens[startPos];return newNode(NodeType.OperatorType,x,token.ln,token.col); } /**
1693 * Check if token is part of URI (e.g. `url('/css/styles.css')`)
1694 * @param {Number} i Token's index number
1695 * @returns {Number} Length of URI
1696 */function checkUri(i){var start=i;if(i >= tokensLength || tokens[i++]. value !== 'url' || i >= tokensLength || tokens[i].type !== TokenType.LeftParenth esis)return 0;return tokens[i].right - start + 1;} /**
1697 * Get node with URI
1698 * @returns {Array} `['uri', x]` where `x` is URI's nodes (without `url`
1699 * and braces, e.g. `['string', ''/css/styles.css'']`).
1700 */function getUri(){var startPos=pos;var uriExcluding={};var uri=undefi ned;var token=undefined;var l=undefined;var raw=undefined;pos += 2;uriExcluding[ TokenType.Space] = 1;uriExcluding[TokenType.Tab] = 1;uriExcluding[TokenType.Newl ine] = 1;uriExcluding[TokenType.LeftParenthesis] = 1;uriExcluding[TokenType.Righ tParenthesis] = 1;if(checkUriContent(pos)){uri = [].concat(getSC()).concat(getUr iContent()).concat(getSC());}else {uri = [].concat(getSC());l = checkExcluding(u riExcluding,pos);token = tokens[pos];raw = newNode(NodeType.RawType,joinValues(p os,pos + l),token.ln,token.col);uri.push(raw);pos += l + 1;uri = uri.concat(getS C());}token = tokens[startPos];var line=token.ln;var column=token.col;var end=ge tLastPosition(uri,line,column,1);pos++;return newNode(NodeType.UriType,uri,token .ln,token.col,end);} /**
1701 * @param {Number} i Token's index number
1702 * @returns {Number}
1703 */function checkUriContent(i){return checkUri1(i) || checkFunction(i);} /**
1704 * @returns {Array}
1705 */function getUriContent(){if(checkUri1(pos))return getString();else if (checkFunction(pos))return getFunction();} /**
1706 * @param {Number} i Token's index number
1707 * @returns {Number}
1708 */function checkUri1(i){var start=i;var l=undefined;if(i >= tokensLengt h)return 0;if(l = checkSC(i))i += l;if(tokens[i].type !== TokenType.StringDQ && tokens[i].type !== TokenType.StringSQ)return 0;i++;if(l = checkSC(i))i += l;retu rn i - start;} /**
1709 * Check if token is part of a value
1710 * @param {Number} i Token's index number
1711 * @returns {Number} Length of the value
1712 */function checkValue(i){var start=i;var l=undefined;var s=undefined;va r _i=undefined;while(i < tokensLength) {if(checkDeclDelim(i))break;s = checkSC(i );_i = i + s;if(l = _checkValue(_i))i += l + s;if(!l || checkBlock(i - l))break; }return i - start;} /**
1713 * @param {Number} i Token's index number
1714 * @returns {Number}
1715 */function _checkValue(i){return checkInterpolation(i) || checkVariable (i) || checkVhash(i) || checkBlock(i) || checkAtkeyword(i) || checkOperator(i) | | checkImportant(i) || checkGlobal(i) || checkDefault(i) || checkProgid(i) || ch eckAny(i);} /**
1716 * @returns {Array}
1717 */function getValue(){var startPos=pos;var x=[];var _pos=undefined;var s=undefined;while(pos < tokensLength) {s = checkSC(pos);_pos = pos + s;if(checkD eclDelim(_pos))break;if(!_checkValue(_pos))break;if(s)x = x.concat(getSC());x.pu sh(_getValue());if(checkBlock(_pos))break;}var token=tokens[startPos];return new Node(NodeType.ValueType,x,token.ln,token.col);} /**
1718 * @returns {Array}
1719 */function _getValue(){if(checkInterpolation(pos))return getInterpolati on();else if(checkVariable(pos))return getVariable();else if(checkVhash(pos))ret urn getVhash();else if(checkBlock(pos))return getBlock();else if(checkAtkeyword( pos))return getAtkeyword();else if(checkOperator(pos))return getOperator();else if(checkImportant(pos))return getImportant();else if(checkGlobal(pos))return get Global();else if(checkDefault(pos))return getDefault();else if(checkProgid(pos)) return getProgid();else if(checkAny(pos))return getAny();} /**
1720 * Check if token is part of a variable
1721 * @param {Number} i Token's index number
1722 * @returns {Number} Length of the variable
1723 */function checkVariable(i){var l;if(i >= tokensLength || tokens[i].typ e !== TokenType.DollarSign)return 0;return (l = checkIdent(i + 1))?l + 1:0;} /**
1724 * Get node with a variable
1725 * @returns {Array} `['variable', ['ident', x]]` where `x` is
1726 * a variable name.
1727 */function getVariable(){var startPos=pos;var x=[];pos++;x.push(getIden t());var token=tokens[startPos];return newNode(NodeType.VariableType,x,token.ln, token.col);} /**
1728 * Check if token is part of a variables list (e.g. `$values...`).
1729 * @param {Number} i Token's index number
1730 * @returns {Number}
1731 */function checkVariablesList(i){var d=0; // Number of dots
1732 var l=undefined;if(i >= tokensLength)return 0;if(l = checkVariable(i))i += l;else return 0;while(i < tokensLength && tokens[i].type === TokenType.FullSt op) {d++;i++;}return d === 3?l + d:0;} /**
1733 * Get node with a variables list
1734 * @returns {Array} `['variableslist', ['variable', ['ident', x]]]` wher e
1735 * `x` is a variable name.
1736 */function getVariablesList(){var startPos=pos;var x=getVariable();var token=tokens[startPos];var line=token.ln;var column=token.col;var end=getLastPos ition([x],line,column,3);pos += 3;return newNode(NodeType.VariablesListType,[x], token.ln,token.col,end);} /**
1737 * Check if token is part of a hexadecimal number (e.g. `#fff`) inside
1738 * some value
1739 * @param {Number} i Token's index number
1740 * @returns {Number}
1741 */function checkVhash(i){var l;if(i >= tokensLength || tokens[i].type ! == TokenType.NumberSign)return 0;return (l = checkNmName2(i + 1))?l + 1:0;} /**
1742 * Get node with a hexadecimal number (e.g. `#fff`) inside some value
1743 * @returns {Array} `['vhash', x]` where `x` is a hexadecimal number
1744 * converted to string (without `#`, e.g. `'fff'`).
1745 */function getVhash(){var startPos=pos;var x=undefined;var token=tokens [startPos];var line=token.ln;var column=token.col;pos++;x = getNmName2();var end =getLastPosition(x,line,column + 1);return newNode(NodeType.VhashType,x,token.ln ,token.col,end);}module.exports = function(_tokens,context){tokens = _tokens;tok ensLength = tokens.length;pos = 0;return contexts[context]();};function checkSel ectorsGroup(i){if(i >= tokensLength)return 0;var start=i;var l=undefined;if(l = checkSelector(i))i += l;else return 0;while(i < tokensLength) {var sb=checkSC(i) ;var c=checkDelim(i + sb);if(!c)break;var sa=checkSC(i + sb + c);if(l = checkSel ector(i + sb + c + sa))i += sb + c + sa + l;else break;}tokens[start].selectorsG roupEnd = i;return i - start;}function getSelectorsGroup(){var selectorsGroup=[] ;var selectorsGroupEnd=tokens[pos].selectorsGroupEnd;selectorsGroup.push(getSele ctor());while(pos < selectorsGroupEnd) {selectorsGroup = selectorsGroup.concat(g etSC());selectorsGroup.push(getDelim());selectorsGroup = selectorsGroup.concat(g etSC());selectorsGroup.push(getSelector());}return selectorsGroup;}function chec kSelector(i){var l;if(l = checkSelector1(i))tokens[i].selectorType = 1;else if(l = checkSelector2(i))tokens[i].selectorType = 2;return l;}function getSelector() {var selectorType=tokens[pos].selectorType;if(selectorType === 1)return getSelec tor1();else return getSelector2();} /**
1746 * Checks for selector which starts with a compound selector.
1747 */function checkSelector1(i){if(i >= tokensLength)return 0;var start=i; var l=undefined;if(l = checkCompoundSelector(i))i += l;else return 0;while(i < t okensLength) {var s=checkSC(i);var c=checkCombinator(i + s);if(!s && !c)break;if (c){i += s + c;s = checkSC(i);}if(l = checkCompoundSelector(i + s))i += s + l;el se break;}tokens[start].selectorEnd = i;return i - start;}function getSelector1( ){var type=NodeType.SelectorType;var token=tokens[pos];var line=token.ln;var col umn=token.col;var selectorEnd=token.selectorEnd;var content=getCompoundSelector( );while(pos < selectorEnd) {if(checkSC(pos))content = content.concat(getSC());el se if(checkCombinator(pos))content.push(getCombinator());else if(checkCompoundSe lector(pos))content = content.concat(getCompoundSelector());}return newNode(type ,content,line,column);} /**
1748 * Checks for a selector that starts with a combinator.
1749 */function checkSelector2(i){if(i >= tokensLength)return 0;var start=i; var l=undefined;if(l = checkCombinator(i))i += l;else return 0;while(i < tokensL ength) {var sb=checkSC(i);if(l = checkCompoundSelector(i + sb))i += sb + l;else break;var sa=checkSC(i);var c=checkCombinator(i + sa);if(!sa && !c)break;if(c){i += sa + c;}}tokens[start].selectorEnd = i;return i - start;}function getSelecto r2(){var type=NodeType.SelectorType;var token=tokens[pos];var line=token.ln;var column=token.col;var selectorEnd=token.selectorEnd;var content=[getCombinator()] ;while(pos < selectorEnd) {if(checkSC(pos))content = content.concat(getSC());els e if(checkCombinator(pos))content.push(getCombinator());else if(checkCompoundSel ector(pos))content = content.concat(getCompoundSelector());}return newNode(type, content,line,column);}function checkCompoundSelector(i){var l=undefined;if(l = c heckCompoundSelector1(i)){tokens[i].compoundSelectorType = 1;}else if(l = checkC ompoundSelector2(i)){tokens[i].compoundSelectorType = 2;}return l;}function getC ompoundSelector(){var type=tokens[pos].compoundSelectorType;if(type === 1)return getCompoundSelector1();if(type === 2)return getCompoundSelector2();}function ch eckCompoundSelector1(i){if(i >= tokensLength)return 0;var start=i;var l=undefine d;if(l = checkTypeSelector(i) || checkPlaceholder(i) || checkParentSelectorWithE xtension(i))i += l;else return 0;while(i < tokensLength) {var _l2=checkShash(i) || checkClass(i) || checkAttributeSelector(i) || checkPseudo(i) || checkPlacehol der(i);if(_l2)i += _l2;else break;}tokens[start].compoundSelectorEnd = i;return i - start;}function getCompoundSelector1(){var sequence=[];var compoundSelectorE nd=tokens[pos].compoundSelectorEnd;if(checkTypeSelector(pos))sequence.push(getTy peSelector());else if(checkPlaceholder(pos))sequence.push(getPlaceholder());else if(checkParentSelectorWithExtension(pos))sequence = sequence.concat(getParentSe lectorWithExtension());while(pos < compoundSelectorEnd) {if(checkShash(pos))sequ ence.push(getShash());else if(checkClass(pos))sequence.push(getClass());else if( checkAttributeSelector(pos))sequence.push(getAttributeSelector());else if(checkP seudo(pos))sequence.push(getPseudo());else if(checkPlaceholder(pos))sequence.pus h(getPlaceholder());}return sequence;}function checkCompoundSelector2(i){if(i >= tokensLength)return 0;var start=i;while(i < tokensLength) {var l=checkShash(i) || checkClass(i) || checkAttributeSelector(i) || checkPseudo(i) || checkPlacehol der(i);if(l)i += l;else break;}tokens[start].compoundSelectorEnd = i;return i - start;}function getCompoundSelector2(){var sequence=[];var compoundSelectorEnd=t okens[pos].compoundSelectorEnd;while(pos < compoundSelectorEnd) {if(checkShash(p os))sequence.push(getShash());else if(checkClass(pos))sequence.push(getClass()); else if(checkAttributeSelector(pos))sequence.push(getAttributeSelector());else i f(checkPseudo(pos))sequence.push(getPseudo());else if(checkPlaceholder(pos))sequ ence.push(getPlaceholder());}return sequence;}function checkTypeSelector(i){if(i >= tokensLength)return 0;var start=i;var l=undefined;if(l = checkNamePrefix(i)) i += l;if(tokens[i].type === TokenType.Asterisk)i++;else if(l = checkIdentOrInte rpolation(i))i += l;else return 0;return i - start;}function getTypeSelector(){v ar type=NodeType.TypeSelectorType;var token=tokens[pos];var line=token.ln;var co lumn=token.col;var content=[];if(checkNamePrefix(pos))content.push(getNamePrefix ());if(checkIdentOrInterpolation(pos))content = content.concat(getIdentOrInterpo lation());return newNode(type,content,line,column);}function checkAttributeSelec tor(i){var l=undefined;if(l = checkAttributeSelector1(i))tokens[i].attributeSele ctorType = 1;else if(l = checkAttributeSelector2(i))tokens[i].attributeSelectorT ype = 2;return l;}function getAttributeSelector(){var type=tokens[pos].attribute SelectorType;if(type === 1)return getAttributeSelector1();else return getAttribu teSelector2();} /**
1750 * (1) `[panda=nani]`
1751 * (2) `[panda='nani']`
1752 * (3) `[panda='nani' i]`
1753 *
1754 */function checkAttributeSelector1(i){var start=i;if(tokens[i].type === TokenType.LeftSquareBracket)i++;else return 0;var l=undefined;if(l = checkSC(i) )i += l;if(l = checkAttributeName(i))i += l;else return 0;if(l = checkSC(i))i += l;if(l = checkAttributeMatch(i))i += l;else return 0;if(l = checkSC(i))i += l;i f(l = checkAttributeValue(i))i += l;else return 0;if(l = checkSC(i))i += l;if(l = checkAttributeFlags(i)){i += l;if(l = checkSC(i))i += l;}if(tokens[i].type === TokenType.RightSquareBracket)i++;else return 0;return i - start;}function getAt tributeSelector1(){var type=NodeType.AttributeSelectorType;var token=tokens[pos] ;var line=token.ln;var column=token.col;var content=[]; // Skip `[`.
1755 pos++;content = content.concat(getSC());content.push(getAttributeName()) ;content = content.concat(getSC());content.push(getAttributeMatch());content = c ontent.concat(getSC());content.push(getAttributeValue());content = content.conca t(getSC());if(checkAttributeFlags(pos)){content.push(getAttributeFlags());conten t = content.concat(getSC());} // Skip `]`.
1756 pos++;var end=getLastPosition(content,line,column,1);return newNode(type ,content,line,column,end);} /**
1757 * (1) `[panda]`
1758 */function checkAttributeSelector2(i){var start=i;if(tokens[i].type === TokenType.LeftSquareBracket)i++;else return 0;var l=undefined;if(l = checkSC(i) )i += l;if(l = checkAttributeName(i))i += l;else return 0;if(l = checkSC(i))i += l;if(tokens[i].type === TokenType.RightSquareBracket)i++;else return 0;return i - start;}function getAttributeSelector2(){var type=NodeType.AttributeSelectorTy pe;var token=tokens[pos];var line=token.ln;var column=token.col;var content=[]; // Skip `[`.
1759 pos++;content = content.concat(getSC());content.push(getAttributeName()) ;content = content.concat(getSC()); // Skip `]`.
1760 pos++;var end=getLastPosition(content,line,column,1);return newNode(type ,content,line,column,end);}function checkAttributeName(i){var start=i;var l=unde fined;if(l = checkNamePrefix(i))i += l;if(l = checkIdentOrInterpolation(i))i += l;else return 0;return i - start;}function getAttributeName(){var type=NodeType. AttributeNameType;var token=tokens[pos];var line=token.ln;var column=token.col;v ar content=[];if(checkNamePrefix(pos))content.push(getNamePrefix());content = co ntent.concat(getIdentOrInterpolation());return newNode(type,content,line,column) ;}function checkAttributeMatch(i){var l=undefined;if(l = checkAttributeMatch1(i) )tokens[i].attributeMatchType = 1;else if(l = checkAttributeMatch2(i))tokens[i]. attributeMatchType = 2;return l;}function getAttributeMatch(){var type=tokens[po s].attributeMatchType;if(type === 1)return getAttributeMatch1();else return getA ttributeMatch2();}function checkAttributeMatch1(i){var start=i;var type=tokens[i ].type;if(type === TokenType.Tilde || type === TokenType.VerticalLine || type == = TokenType.CircumflexAccent || type === TokenType.DollarSign || type === TokenT ype.Asterisk)i++;else return 0;if(tokens[i].type === TokenType.EqualsSign)i++;el se return 0;return i - start;}function getAttributeMatch1(){var type=NodeType.At tributeMatchType;var token=tokens[pos];var line=token.ln;var column=token.col;va r content=tokens[pos].value + tokens[pos + 1].value;pos += 2;return newNode(type ,content,line,column);}function checkAttributeMatch2(i){if(tokens[i].type === To kenType.EqualsSign)return 1;else return 0;}function getAttributeMatch2(){var typ e=NodeType.AttributeMatchType;var token=tokens[pos];var line=token.ln;var column =token.col;var content='=';pos++;return newNode(type,content,line,column);}funct ion checkAttributeValue(i){return checkString(i) || checkIdentOrInterpolation(i) ;}function getAttributeValue(){var type=NodeType.AttributeValueType;var token=to kens[pos];var line=token.ln;var column=token.col;var content=[];if(checkString(p os))content.push(getString());else content = content.concat(getIdentOrInterpolat ion());return newNode(type,content,line,column);}function checkAttributeFlags(i) {return checkIdentOrInterpolation(i);}function getAttributeFlags(){var type=Node Type.AttributeFlagsType;var token=tokens[pos];var line=token.ln;var column=token .col;var content=getIdentOrInterpolation();return newNode(type,content,line,colu mn);}function checkNamePrefix(i){if(i >= tokensLength)return 0;var l=undefined;i f(l = checkNamePrefix1(i))tokens[i].namePrefixType = 1;else if(l = checkNamePref ix2(i))tokens[i].namePrefixType = 2;return l;}function getNamePrefix(){var type= tokens[pos].namePrefixType;if(type === 1)return getNamePrefix1();else return get NamePrefix2();} /**
1761 * (1) `panda|`
1762 * (2) `panda<comment>|`
1763 */function checkNamePrefix1(i){var start=i;var l=undefined;if(l = check NamespacePrefix(i))i += l;else return 0;if(l = checkCommentML(i))i += l;if(l = c heckNamespaceSeparator(i))i += l;else return 0;return i - start;}function getNam ePrefix1(){var type=NodeType.NamePrefixType;var token=tokens[pos];var line=token .ln;var column=token.col;var content=[];content.push(getNamespacePrefix());if(ch eckCommentML(pos))content.push(getCommentML());content.push(getNamespaceSeparato r());return newNode(type,content,line,column);} /**
1764 * (1) `|`
1765 */function checkNamePrefix2(i){return checkNamespaceSeparator(i);}funct ion getNamePrefix2(){var type=NodeType.NamePrefixType;var token=tokens[pos];var line=token.ln;var column=token.col;var content=[getNamespaceSeparator()];return newNode(type,content,line,column);} /**
1766 * (1) `*`
1767 * (2) `panda`
1768 */function checkNamespacePrefix(i){if(i >= tokensLength)return 0;var l= undefined;if(tokens[i].type === TokenType.Asterisk)return 1;else if(l = checkIde ntOrInterpolation(i))return l;else return 0;}function getNamespacePrefix(){var t ype=NodeType.NamespacePrefixType;var token=tokens[pos];var line=token.ln;var col umn=token.col;var content=[];if(checkIdentOrInterpolation(pos))content = content .concat(getIdentOrInterpolation());return newNode(type,content,line,column);} /* *
1769 * (1) `|`
1770 */function checkNamespaceSeparator(i){if(i >= tokensLength)return 0;if( tokens[i].type === TokenType.VerticalLine)return 1;else return 0;}function getNa mespaceSeparator(){var type=NodeType.NamespaceSeparatorType;var token=tokens[pos ];var line=token.ln;var column=token.col;var content='|';pos++;return newNode(ty pe,content,line,column);}
1771
1772 /***/ },
1773 /* 14 */
1774 /***/ function(module, exports) {
1775
1776 'use strict';
1777
1778 module.exports = {
1779 ArgumentsType: 'arguments',
1780 AtkeywordType: 'atkeyword',
1781 AtruleType: 'atrule',
1782 AttributeSelectorType: 'attributeSelector',
1783 AttributeNameType: 'attributeName',
1784 AttributeFlagsType: 'attributeFlags',
1785 AttributeMatchType: 'attributeMatch',
1786 AttributeValueType: 'attributeValue',
1787 BlockType: 'block',
1788 BracketsType: 'brackets',
1789 ClassType: 'class',
1790 CombinatorType: 'combinator',
1791 CommentMLType: 'multilineComment',
1792 CommentSLType: 'singlelineComment',
1793 ConditionType: 'condition',
1794 ConditionalStatementType: 'conditionalStatement',
1795 DeclarationType: 'declaration',
1796 DeclDelimType: 'declarationDelimiter',
1797 DefaultType: 'default',
1798 DelimType: 'delimiter',
1799 DimensionType: 'dimension',
1800 EscapedStringType: 'escapedString',
1801 ExtendType: 'extend',
1802 ExpressionType: 'expression',
1803 FunctionType: 'function',
1804 GlobalType: 'global',
1805 IdentType: 'ident',
1806 ImportantType: 'important',
1807 IncludeType: 'include',
1808 InterpolationType: 'interpolation',
1809 InterpolatedVariableType: 'interpolatedVariable',
1810 KeyframesSelectorType: 'keyframesSelector',
1811 LoopType: 'loop',
1812 MixinType: 'mixin',
1813 NamePrefixType: 'namePrefix',
1814 NamespacePrefixType: 'namespacePrefix',
1815 NamespaceSeparatorType: 'namespaceSeparator',
1816 NumberType: 'number',
1817 OperatorType: 'operator',
1818 OptionalType: 'optional',
1819 ParenthesesType: 'parentheses',
1820 ParentSelectorType: 'parentSelector',
1821 ParentSelectorExtensionType: 'parentSelectorExtension',
1822 PercentageType: 'percentage',
1823 PlaceholderType: 'placeholder',
1824 ProgidType: 'progid',
1825 PropertyType: 'property',
1826 PropertyDelimType: 'propertyDelimiter',
1827 PseudocType: 'pseudoClass',
1828 PseudoeType: 'pseudoElement',
1829 RawType: 'raw',
1830 RulesetType: 'ruleset',
1831 SType: 'space',
1832 SelectorType: 'selector',
1833 ShashType: 'id',
1834 StringType: 'string',
1835 StylesheetType: 'stylesheet',
1836 TypeSelectorType: 'typeSelector',
1837 UriType: 'uri',
1838 ValueType: 'value',
1839 VariableType: 'variable',
1840 VariablesListType: 'variablesList',
1841 VhashType: 'color'
1842 };
1843
1844 /***/ },
1845 /* 15 */
1846 /***/ function(module, exports, __webpack_require__) {
1847
1848 'use strict';
1849
1850 module.exports = function (css, tabSize) {
1851 var TokenType = __webpack_require__(12);
1852
1853 var tokens = [];
1854 var urlMode = false;
1855 var blockMode = 0;
1856 var c = undefined; // Current character
1857 var cn = undefined; // Next character
1858 var pos = 0;
1859 var tn = 0;
1860 var ln = 1;
1861 var col = 1;
1862
1863 var Punctuation = {
1864 ' ': TokenType.Space,
1865 '\n': TokenType.Newline,
1866 '\r': TokenType.Newline,
1867 '\t': TokenType.Tab,
1868 '!': TokenType.ExclamationMark,
1869 '"': TokenType.QuotationMark,
1870 '#': TokenType.NumberSign,
1871 '$': TokenType.DollarSign,
1872 '%': TokenType.PercentSign,
1873 '&': TokenType.Ampersand,
1874 '\'': TokenType.Apostrophe,
1875 '(': TokenType.LeftParenthesis,
1876 ')': TokenType.RightParenthesis,
1877 '*': TokenType.Asterisk,
1878 '+': TokenType.PlusSign,
1879 ',': TokenType.Comma,
1880 '-': TokenType.HyphenMinus,
1881 '.': TokenType.FullStop,
1882 '/': TokenType.Solidus,
1883 ':': TokenType.Colon,
1884 ';': TokenType.Semicolon,
1885 '<': TokenType.LessThanSign,
1886 '=': TokenType.EqualsSign,
1887 '==': TokenType.EqualitySign,
1888 '!=': TokenType.InequalitySign,
1889 '>': TokenType.GreaterThanSign,
1890 '?': TokenType.QuestionMark,
1891 '@': TokenType.CommercialAt,
1892 '[': TokenType.LeftSquareBracket,
1893 ']': TokenType.RightSquareBracket,
1894 '^': TokenType.CircumflexAccent,
1895 '_': TokenType.LowLine,
1896 '{': TokenType.LeftCurlyBracket,
1897 '|': TokenType.VerticalLine,
1898 '}': TokenType.RightCurlyBracket,
1899 '~': TokenType.Tilde
1900 };
1901
1902 /**
1903 * Add a token to the token list
1904 * @param {string} type
1905 * @param {string} value
1906 */
1907 function pushToken(type, value, column) {
1908 tokens.push({
1909 tn: tn++,
1910 ln: ln,
1911 col: column,
1912 type: type,
1913 value: value
1914 });
1915 }
1916
1917 /**
1918 * Check if a character is a decimal digit
1919 * @param {string} c Character
1920 * @returns {boolean}
1921 */
1922 function isDecimalDigit(c) {
1923 return '0123456789'.indexOf(c) >= 0;
1924 }
1925
1926 /**
1927 * Parse spaces
1928 * @param {string} css Unparsed part of CSS string
1929 */
1930 function parseSpaces(css) {
1931 var start = pos;
1932
1933 // Read the string until we meet a non-space character:
1934 for (; pos < css.length; pos++) {
1935 if (css.charAt(pos) !== ' ') break;
1936 }
1937
1938 // Add a substring containing only spaces to tokens:
1939 pushToken(TokenType.Space, css.substring(start, pos--), col);
1940 col += pos - start;
1941 }
1942
1943 /**
1944 * Parse a string within quotes
1945 * @param {string} css Unparsed part of CSS string
1946 * @param {string} q Quote (either `'` or `"`)
1947 */
1948 function parseString(css, q) {
1949 var start = pos;
1950
1951 // Read the string until we meet a matching quote:
1952 for (pos++; pos < css.length; pos++) {
1953 // Skip escaped quotes:
1954 if (css.charAt(pos) === '\\') pos++;else if (css.charAt(pos) === q ) break;
1955 }
1956
1957 // Add the string (including quotes) to tokens:
1958 var type = q === '"' ? TokenType.StringDQ : TokenType.StringSQ;
1959 pushToken(type, css.substring(start, pos + 1), col);
1960 col += pos - start;
1961 }
1962
1963 /**
1964 * Parse numbers
1965 * @param {string} css Unparsed part of CSS string
1966 */
1967 function parseDecimalNumber(css) {
1968 var start = pos;
1969
1970 // Read the string until we meet a character that's not a digit:
1971 for (; pos < css.length; pos++) {
1972 if (!isDecimalDigit(css.charAt(pos))) break;
1973 }
1974
1975 // Add the number to tokens:
1976 pushToken(TokenType.DecimalNumber, css.substring(start, pos--), col) ;
1977 col += pos - start;
1978 }
1979
1980 /**
1981 * Parse identifier
1982 * @param {string} css Unparsed part of CSS string
1983 */
1984 function parseIdentifier(css) {
1985 var start = pos;
1986
1987 // Skip all opening slashes:
1988 while (css.charAt(pos) === '/') pos++;
1989
1990 // Read the string until we meet a punctuation mark:
1991 for (; pos < css.length; pos++) {
1992 // Skip all '\':
1993 if (css.charAt(pos) === '\\') pos++;else if (css.charAt(pos) in Pu nctuation) break;
1994 }
1995
1996 var ident = css.substring(start, pos--);
1997
1998 // Enter url mode if parsed substring is `url`:
1999 if (!urlMode && ident === 'url' && css.charAt(pos + 1) === '(') {
2000 urlMode = true;
2001 }
2002
2003 // Add identifier to tokens:
2004 pushToken(TokenType.Identifier, ident, col);
2005 col += pos - start;
2006 }
2007
2008 /**
2009 * Parse equality sign
2010 */
2011 function parseEquality() {
2012 pushToken(TokenType.EqualitySign, '==', col);
2013 pos++;
2014 col++;
2015 }
2016
2017 /**
2018 * Parse inequality sign
2019 */
2020 function parseInequality() {
2021 pushToken(TokenType.InequalitySign, '!=', col);
2022 pos++;
2023 col++;
2024 }
2025
2026 /**
2027 * Parse a multiline comment
2028 * @param {string} css Unparsed part of CSS string
2029 */
2030 function parseMLComment(css) {
2031 var start = pos;
2032
2033 // Read the string until we meet `*/`.
2034 // Since we already know first 2 characters (`/*`), start reading
2035 // from `pos + 2`:
2036 for (pos += 2; pos < css.length; pos++) {
2037 if (css.charAt(pos) === '*' && css.charAt(pos + 1) === '/') {
2038 pos++;
2039 break;
2040 }
2041 }
2042
2043 // Add full comment (including `/*` and `*/`) to the list of tokens:
2044 var comment = css.substring(start, pos + 1);
2045 pushToken(TokenType.CommentML, comment, col);
2046
2047 var newlines = comment.split('\n');
2048 if (newlines.length > 1) {
2049 ln += newlines.length - 1;
2050 col = newlines[newlines.length - 1].length;
2051 } else {
2052 col += pos - start;
2053 }
2054 }
2055
2056 /**
2057 * Parse a single line comment
2058 * @param {string} css Unparsed part of CSS string
2059 */
2060 function parseSLComment(css) {
2061 var start = pos;
2062
2063 // Read the string until we meet line break.
2064 // Since we already know first 2 characters (`//`), start reading
2065 // from `pos + 2`:
2066 for (pos += 2; pos < css.length; pos++) {
2067 if (css.charAt(pos) === '\n' || css.charAt(pos) === '\r') {
2068 break;
2069 }
2070 }
2071
2072 // Add comment (including `//` and line break) to the list of tokens :
2073 pushToken(TokenType.CommentSL, css.substring(start, pos--), col);
2074 col += pos - start;
2075 }
2076
2077 /**
2078 * Convert a CSS string to a list of tokens
2079 * @param {string} css CSS string
2080 * @returns {Array} List of tokens
2081 * @private
2082 */
2083 function getTokens(css) {
2084 // Parse string, character by character:
2085 for (pos = 0; pos < css.length; col++, pos++) {
2086 c = css.charAt(pos);
2087 cn = css.charAt(pos + 1);
2088
2089 // If we meet `/*`, it's a start of a multiline comment.
2090 // Parse following characters as a multiline comment:
2091 if (c === '/' && cn === '*') {
2092 parseMLComment(css);
2093 }
2094
2095 // If we meet `//` and it is not a part of url:
2096 else if (!urlMode && c === '/' && cn === '/') {
2097 // If we're currently inside a block, treat `//` as a start
2098 // of identifier. Else treat `//` as a start of a single-line
2099 // comment:
2100 parseSLComment(css);
2101 }
2102
2103 // If current character is a double or single quote, it's a star t
2104 // of a string:
2105 else if (c === '"' || c === "'") {
2106 parseString(css, c);
2107 }
2108
2109 // If current character is a space:
2110 else if (c === ' ') {
2111 parseSpaces(css);
2112 }
2113
2114 // If current character is `=`, it must be combined with nex t `=`
2115 else if (c === '=' && cn === '=') {
2116 parseEquality(css);
2117 }
2118
2119 // If we meet `!=`, this must be inequality
2120 else if (c === '!' && cn === '=') {
2121 parseInequality(css);
2122 }
2123
2124 // If current character is a punctuation mark:
2125 else if (c in Punctuation) {
2126 // Check for CRLF here or just LF
2127 if (c === '\r' && cn === '\n' || c === '\n') {
2128 // If \r we know the next character is \n due to s tatement above
2129 // so we push a CRLF token type to the token list and importantly
2130 // skip the next character so as not to double cou nt newlines or
2131 // columns etc
2132 if (c === '\r') {
2133 pushToken(TokenType.Newline, '\r\n', col);
2134 pos++; // If CRLF skip the next character and pu sh crlf token
2135 } else if (c === '\n') {
2136 // If just a LF newline and not part of CRLF n ewline we can just
2137 // push punctuation as usual
2138 pushToken(Punctuation[c], c, col);
2139 }
2140
2141 ln++; // Go to next line
2142 col = 0; // Reset the column count
2143 } else if (c !== '\r' && c !== '\n') {
2144 // Handle all other punctuation and add to list of tokens
2145 pushToken(Punctuation[c], c, col);
2146 } // Go to next line
2147 if (c === ')') urlMode = false; // Exit url mode
2148 if (c === '{') blockMode++; // Enter a block
2149 if (c === '}') blockMode--; // Exit a block
2150 else if (c === '\t' && tabSize > 1) col += tabSize - 1;
2151 }
2152
2153 // If current character is a decimal digit:
2154 else if (isDecimalDigit(c)) {
2155 parseDecimalNumber(css);
2156 }
2157
2158 // If current character is anything else:
2159 else {
2160 parseIdentifier(css);
2161 }
2162 }
2163
2164 return tokens;
2165 }
2166
2167 return getTokens(css);
2168 };
2169
2170 /***/ },
2171 /* 16 */
2172 /***/ function(module, exports, __webpack_require__) {
2173
2174 'use strict';
2175
2176 var Node = __webpack_require__(1);
2177 var NodeTypes = __webpack_require__(14);
2178
2179 module.exports = function () {
2180 return new Node({
2181 type: NodeTypes.StylesheetType,
2182 content: [],
2183 start: [0, 0],
2184 end: [0, 0]
2185 });
2186 };
2187
2188 /***/ }
2189 /******/ ])
2190 });
2191 ;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698