Brunobkr/llama.cpp_AlgMor24_github
ΩFFFΣLLIa • llama.cpp • AlgMor24 ██████╗ ███████╗███████╗███████╗██╗ ██╗ ██╗ █████╗ ██╔═══██╗██╔════╝██╔════╝██╔════╝██║ ██║ ██║██╔══██╗ ██║ ██║█████╗ █████╗ █████╗ ██║ ██║ ██║███████║ ██║ ██║██╔══╝ ██╔══╝ ██╔══╝ ██║ ██║ ██║██╔══██║ ╚██████╔╝██║ ██║ ███████╗███████╗███████╗██║██║ ██║ ╚═════╝ ╚═╝ ╚═╝ ╚══════╝╚══════╝╚══════╝╚═╝╚═╝ ╚═╝ High-Performance LLM / VLM Inference & Autonomous Agentic Ecosystem… See the full description on the dataset page: https://huggingface.co/datasets/Brunobkr/llama.cpp_AlgMor24_github.
03.1k
1(function (global, factory) {2 typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :3 typeof define === 'function' && define.amd ? define(factory) :4 (global = global || self, global.esquery = factory());5}(this, (function () { 'use strict';6 7 function _arrayLikeToArray(r, a) {8 (null == a || a > r.length) && (a = r.length);9 for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];10 return n;11 }12 function _arrayWithHoles(r) {13 if (Array.isArray(r)) return r;14 }15 function _arrayWithoutHoles(r) {16 if (Array.isArray(r)) return _arrayLikeToArray(r);17 }18 function _iterableToArray(r) {19 if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);20 }21 function _iterableToArrayLimit(r, l) {22 var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];23 if (null != t) {24 var e,25 n,26 i,27 u,28 a = [],29 f = !0,30 o = !1;31 try {32 if (i = (t = t.call(r)).next, 0 === l) {33 if (Object(t) !== t) return;34 f = !1;35 } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);36 } catch (r) {37 o = !0, n = r;38 } finally {39 try {40 if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;41 } finally {42 if (o) throw n;43 }44 }45 return a;46 }47 }48 function _nonIterableRest() {49 throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");50 }51 function _nonIterableSpread() {52 throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");53 }54 function _slicedToArray(r, e) {55 return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();56 }57 function _toConsumableArray(r) {58 return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();59 }60 function _typeof(o) {61 "@babel/helpers - typeof";62 63 return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {64 return typeof o;65 } : function (o) {66 return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;67 }, _typeof(o);68 }69 function _unsupportedIterableToArray(r, a) {70 if (r) {71 if ("string" == typeof r) return _arrayLikeToArray(r, a);72 var t = {}.toString.call(r).slice(8, -1);73 return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;74 }75 }76 77 var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};78 79 function createCommonjsModule(fn, module) {80 return module = { exports: {} }, fn(module, module.exports), module.exports;81 }82 83 var estraverse = createCommonjsModule(function (module, exports) {84 /*85 Copyright (C) 2012-2013 Yusuke Suzuki <utatane.tea@gmail.com>86 Copyright (C) 2012 Ariya Hidayat <ariya.hidayat@gmail.com>87 88 Redistribution and use in source and binary forms, with or without89 modification, are permitted provided that the following conditions are met:90 91 * Redistributions of source code must retain the above copyright92 notice, this list of conditions and the following disclaimer.93 * Redistributions in binary form must reproduce the above copyright94 notice, this list of conditions and the following disclaimer in the95 documentation and/or other materials provided with the distribution.96 97 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"98 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE99 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE100 ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY101 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES102 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;103 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND104 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT105 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF106 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.107 */108 /*jslint vars:false, bitwise:true*/109 /*jshint indent:4*/110 /*global exports:true*/111 (function clone(exports) {112 113 var Syntax, VisitorOption, VisitorKeys, BREAK, SKIP, REMOVE;114 function deepCopy(obj) {115 var ret = {},116 key,117 val;118 for (key in obj) {119 if (obj.hasOwnProperty(key)) {120 val = obj[key];121 if (typeof val === 'object' && val !== null) {122 ret[key] = deepCopy(val);123 } else {124 ret[key] = val;125 }126 }127 }128 return ret;129 }130 131 // based on LLVM libc++ upper_bound / lower_bound132 // MIT License133 134 function upperBound(array, func) {135 var diff, len, i, current;136 len = array.length;137 i = 0;138 while (len) {139 diff = len >>> 1;140 current = i + diff;141 if (func(array[current])) {142 len = diff;143 } else {144 i = current + 1;145 len -= diff + 1;146 }147 }148 return i;149 }150 Syntax = {151 AssignmentExpression: 'AssignmentExpression',152 AssignmentPattern: 'AssignmentPattern',153 ArrayExpression: 'ArrayExpression',154 ArrayPattern: 'ArrayPattern',155 ArrowFunctionExpression: 'ArrowFunctionExpression',156 AwaitExpression: 'AwaitExpression',157 // CAUTION: It's deferred to ES7.158 BlockStatement: 'BlockStatement',159 BinaryExpression: 'BinaryExpression',160 BreakStatement: 'BreakStatement',161 CallExpression: 'CallExpression',162 CatchClause: 'CatchClause',163 ChainExpression: 'ChainExpression',164 ClassBody: 'ClassBody',165 ClassDeclaration: 'ClassDeclaration',166 ClassExpression: 'ClassExpression',167 ComprehensionBlock: 'ComprehensionBlock',168 // CAUTION: It's deferred to ES7.169 ComprehensionExpression: 'ComprehensionExpression',170 // CAUTION: It's deferred to ES7.171 ConditionalExpression: 'ConditionalExpression',172 ContinueStatement: 'ContinueStatement',173 DebuggerStatement: 'DebuggerStatement',174 DirectiveStatement: 'DirectiveStatement',175 DoWhileStatement: 'DoWhileStatement',176 EmptyStatement: 'EmptyStatement',177 ExportAllDeclaration: 'ExportAllDeclaration',178 ExportDefaultDeclaration: 'ExportDefaultDeclaration',179 ExportNamedDeclaration: 'ExportNamedDeclaration',180 ExportSpecifier: 'ExportSpecifier',181 ExpressionStatement: 'ExpressionStatement',182 ForStatement: 'ForStatement',183 ForInStatement: 'ForInStatement',184 ForOfStatement: 'ForOfStatement',185 FunctionDeclaration: 'FunctionDeclaration',186 FunctionExpression: 'FunctionExpression',187 GeneratorExpression: 'GeneratorExpression',188 // CAUTION: It's deferred to ES7.189 Identifier: 'Identifier',190 IfStatement: 'IfStatement',191 ImportExpression: 'ImportExpression',192 ImportDeclaration: 'ImportDeclaration',193 ImportDefaultSpecifier: 'ImportDefaultSpecifier',194 ImportNamespaceSpecifier: 'ImportNamespaceSpecifier',195 ImportSpecifier: 'ImportSpecifier',196 Literal: 'Literal',197 LabeledStatement: 'LabeledStatement',198 LogicalExpression: 'LogicalExpression',199 MemberExpression: 'MemberExpression',200 MetaProperty: 'MetaProperty',201 MethodDefinition: 'MethodDefinition',202 ModuleSpecifier: 'ModuleSpecifier',203 NewExpression: 'NewExpression',204 ObjectExpression: 'ObjectExpression',205 ObjectPattern: 'ObjectPattern',206 PrivateIdentifier: 'PrivateIdentifier',207 Program: 'Program',208 Property: 'Property',209 PropertyDefinition: 'PropertyDefinition',210 RestElement: 'RestElement',211 ReturnStatement: 'ReturnStatement',212 SequenceExpression: 'SequenceExpression',213 SpreadElement: 'SpreadElement',214 Super: 'Super',215 SwitchStatement: 'SwitchStatement',216 SwitchCase: 'SwitchCase',217 TaggedTemplateExpression: 'TaggedTemplateExpression',218 TemplateElement: 'TemplateElement',219 TemplateLiteral: 'TemplateLiteral',220 ThisExpression: 'ThisExpression',221 ThrowStatement: 'ThrowStatement',222 TryStatement: 'TryStatement',223 UnaryExpression: 'UnaryExpression',224 UpdateExpression: 'UpdateExpression',225 VariableDeclaration: 'VariableDeclaration',226 VariableDeclarator: 'VariableDeclarator',227 WhileStatement: 'WhileStatement',228 WithStatement: 'WithStatement',229 YieldExpression: 'YieldExpression'230 };231 VisitorKeys = {232 AssignmentExpression: ['left', 'right'],233 AssignmentPattern: ['left', 'right'],234 ArrayExpression: ['elements'],235 ArrayPattern: ['elements'],236 ArrowFunctionExpression: ['params', 'body'],237 AwaitExpression: ['argument'],238 // CAUTION: It's deferred to ES7.239 BlockStatement: ['body'],240 BinaryExpression: ['left', 'right'],241 BreakStatement: ['label'],242 CallExpression: ['callee', 'arguments'],243 CatchClause: ['param', 'body'],244 ChainExpression: ['expression'],245 ClassBody: ['body'],246 ClassDeclaration: ['id', 'superClass', 'body'],247 ClassExpression: ['id', 'superClass', 'body'],248 ComprehensionBlock: ['left', 'right'],249 // CAUTION: It's deferred to ES7.250 ComprehensionExpression: ['blocks', 'filter', 'body'],251 // CAUTION: It's deferred to ES7.252 ConditionalExpression: ['test', 'consequent', 'alternate'],253 ContinueStatement: ['label'],254 DebuggerStatement: [],255 DirectiveStatement: [],256 DoWhileStatement: ['body', 'test'],257 EmptyStatement: [],258 ExportAllDeclaration: ['source'],259 ExportDefaultDeclaration: ['declaration'],260 ExportNamedDeclaration: ['declaration', 'specifiers', 'source'],261 ExportSpecifier: ['exported', 'local'],262 ExpressionStatement: ['expression'],263 ForStatement: ['init', 'test', 'update', 'body'],264 ForInStatement: ['left', 'right', 'body'],265 ForOfStatement: ['left', 'right', 'body'],266 FunctionDeclaration: ['id', 'params', 'body'],267 FunctionExpression: ['id', 'params', 'body'],268 GeneratorExpression: ['blocks', 'filter', 'body'],269 // CAUTION: It's deferred to ES7.270 Identifier: [],271 IfStatement: ['test', 'consequent', 'alternate'],272 ImportExpression: ['source'],273 ImportDeclaration: ['specifiers', 'source'],274 ImportDefaultSpecifier: ['local'],275 ImportNamespaceSpecifier: ['local'],276 ImportSpecifier: ['imported', 'local'],277 Literal: [],278 LabeledStatement: ['label', 'body'],279 LogicalExpression: ['left', 'right'],280 MemberExpression: ['object', 'property'],281 MetaProperty: ['meta', 'property'],282 MethodDefinition: ['key', 'value'],283 ModuleSpecifier: [],284 NewExpression: ['callee', 'arguments'],285 ObjectExpression: ['properties'],286 ObjectPattern: ['properties'],287 PrivateIdentifier: [],288 Program: ['body'],289 Property: ['key', 'value'],290 PropertyDefinition: ['key', 'value'],291 RestElement: ['argument'],292 ReturnStatement: ['argument'],293 SequenceExpression: ['expressions'],294 SpreadElement: ['argument'],295 Super: [],296 SwitchStatement: ['discriminant', 'cases'],297 SwitchCase: ['test', 'consequent'],298 TaggedTemplateExpression: ['tag', 'quasi'],299 TemplateElement: [],300 TemplateLiteral: ['quasis', 'expressions'],301 ThisExpression: [],302 ThrowStatement: ['argument'],303 TryStatement: ['block', 'handler', 'finalizer'],304 UnaryExpression: ['argument'],305 UpdateExpression: ['argument'],306 VariableDeclaration: ['declarations'],307 VariableDeclarator: ['id', 'init'],308 WhileStatement: ['test', 'body'],309 WithStatement: ['object', 'body'],310 YieldExpression: ['argument']311 };312 313 // unique id314 BREAK = {};315 SKIP = {};316 REMOVE = {};317 VisitorOption = {318 Break: BREAK,319 Skip: SKIP,320 Remove: REMOVE321 };322 function Reference(parent, key) {323 this.parent = parent;324 this.key = key;325 }326 Reference.prototype.replace = function replace(node) {327 this.parent[this.key] = node;328 };329 Reference.prototype.remove = function remove() {330 if (Array.isArray(this.parent)) {331 this.parent.splice(this.key, 1);332 return true;333 } else {334 this.replace(null);335 return false;336 }337 };338 function Element(node, path, wrap, ref) {339 this.node = node;340 this.path = path;341 this.wrap = wrap;342 this.ref = ref;343 }344 function Controller() {}345 346 // API:347 // return property path array from root to current node348 Controller.prototype.path = function path() {349 var i, iz, j, jz, result, element;350 function addToPath(result, path) {351 if (Array.isArray(path)) {352 for (j = 0, jz = path.length; j < jz; ++j) {353 result.push(path[j]);354 }355 } else {356 result.push(path);357 }358 }359 360 // root node361 if (!this.__current.path) {362 return null;363 }364 365 // first node is sentinel, second node is root element366 result = [];367 for (i = 2, iz = this.__leavelist.length; i < iz; ++i) {368 element = this.__leavelist[i];369 addToPath(result, element.path);370 }371 addToPath(result, this.__current.path);372 return result;373 };374 375 // API:376 // return type of current node377 Controller.prototype.type = function () {378 var node = this.current();379 return node.type || this.__current.wrap;380 };381 382 // API:383 // return array of parent elements384 Controller.prototype.parents = function parents() {385 var i, iz, result;386 387 // first node is sentinel388 result = [];389 for (i = 1, iz = this.__leavelist.length; i < iz; ++i) {390 result.push(this.__leavelist[i].node);391 }392 return result;393 };394 395 // API:396 // return current node397 Controller.prototype.current = function current() {398 return this.__current.node;399 };400 Controller.prototype.__execute = function __execute(callback, element) {401 var previous, result;402 result = undefined;403 previous = this.__current;404 this.__current = element;405 this.__state = null;406 if (callback) {407 result = callback.call(this, element.node, this.__leavelist[this.__leavelist.length - 1].node);408 }409 this.__current = previous;410 return result;411 };412 413 // API:414 // notify control skip / break415 Controller.prototype.notify = function notify(flag) {416 this.__state = flag;417 };418 419 // API:420 // skip child nodes of current node421 Controller.prototype.skip = function () {422 this.notify(SKIP);423 };424 425 // API:426 // break traversals427 Controller.prototype['break'] = function () {428 this.notify(BREAK);429 };430 431 // API:432 // remove node433 Controller.prototype.remove = function () {434 this.notify(REMOVE);435 };436 Controller.prototype.__initialize = function (root, visitor) {437 this.visitor = visitor;438 this.root = root;439 this.__worklist = [];440 this.__leavelist = [];441 this.__current = null;442 this.__state = null;443 this.__fallback = null;444 if (visitor.fallback === 'iteration') {445 this.__fallback = Object.keys;446 } else if (typeof visitor.fallback === 'function') {447 this.__fallback = visitor.fallback;448 }449 this.__keys = VisitorKeys;450 if (visitor.keys) {451 this.__keys = Object.assign(Object.create(this.__keys), visitor.keys);452 }453 };454 function isNode(node) {455 if (node == null) {456 return false;457 }458 return typeof node === 'object' && typeof node.type === 'string';459 }460 function isProperty(nodeType, key) {461 return (nodeType === Syntax.ObjectExpression || nodeType === Syntax.ObjectPattern) && 'properties' === key;462 }463 function candidateExistsInLeaveList(leavelist, candidate) {464 for (var i = leavelist.length - 1; i >= 0; --i) {465 if (leavelist[i].node === candidate) {466 return true;467 }468 }469 return false;470 }471 Controller.prototype.traverse = function traverse(root, visitor) {472 var worklist, leavelist, element, node, nodeType, ret, key, current, current2, candidates, candidate, sentinel;473 this.__initialize(root, visitor);474 sentinel = {};475 476 // reference477 worklist = this.__worklist;478 leavelist = this.__leavelist;479 480 // initialize481 worklist.push(new Element(root, null, null, null));482 leavelist.push(new Element(null, null, null, null));483 while (worklist.length) {484 element = worklist.pop();485 if (element === sentinel) {486 element = leavelist.pop();487 ret = this.__execute(visitor.leave, element);488 if (this.__state === BREAK || ret === BREAK) {489 return;490 }491 continue;492 }493 if (element.node) {494 ret = this.__execute(visitor.enter, element);495 if (this.__state === BREAK || ret === BREAK) {496 return;497 }498 worklist.push(sentinel);499 leavelist.push(element);500 if (this.__state === SKIP || ret === SKIP) {501 continue;502 }503 node = element.node;504 nodeType = node.type || element.wrap;505 candidates = this.__keys[nodeType];506 if (!candidates) {507 if (this.__fallback) {508 candidates = this.__fallback(node);509 } else {510 throw new Error('Unknown node type ' + nodeType + '.');511 }512 }513 current = candidates.length;514 while ((current -= 1) >= 0) {515 key = candidates[current];516 candidate = node[key];517 if (!candidate) {518 continue;519 }520 if (Array.isArray(candidate)) {521 current2 = candidate.length;522 while ((current2 -= 1) >= 0) {523 if (!candidate[current2]) {524 continue;525 }526 if (candidateExistsInLeaveList(leavelist, candidate[current2])) {527 continue;528 }529 if (isProperty(nodeType, candidates[current])) {530 element = new Element(candidate[current2], [key, current2], 'Property', null);531 } else if (isNode(candidate[current2])) {532 element = new Element(candidate[current2], [key, current2], null, null);533 } else {534 continue;535 }536 worklist.push(element);537 }538 } else if (isNode(candidate)) {539 if (candidateExistsInLeaveList(leavelist, candidate)) {540 continue;541 }542 worklist.push(new Element(candidate, key, null, null));543 }544 }545 }546 }547 };548 Controller.prototype.replace = function replace(root, visitor) {549 var worklist, leavelist, node, nodeType, target, element, current, current2, candidates, candidate, sentinel, outer, key;550 function removeElem(element) {551 var i, key, nextElem, parent;552 if (element.ref.remove()) {553 // When the reference is an element of an array.554 key = element.ref.key;555 parent = element.ref.parent;556 557 // If removed from array, then decrease following items' keys.558 i = worklist.length;559 while (i--) {560 nextElem = worklist[i];561 if (nextElem.ref && nextElem.ref.parent === parent) {562 if (nextElem.ref.key < key) {563 break;564 }565 --nextElem.ref.key;566 }567 }568 }569 }570 this.__initialize(root, visitor);571 sentinel = {};572 573 // reference574 worklist = this.__worklist;575 leavelist = this.__leavelist;576 577 // initialize578 outer = {579 root: root580 };581 element = new Element(root, null, null, new Reference(outer, 'root'));582 worklist.push(element);583 leavelist.push(element);584 while (worklist.length) {585 element = worklist.pop();586 if (element === sentinel) {587 element = leavelist.pop();588 target = this.__execute(visitor.leave, element);589 590 // node may be replaced with null,591 // so distinguish between undefined and null in this place592 if (target !== undefined && target !== BREAK && target !== SKIP && target !== REMOVE) {593 // replace594 element.ref.replace(target);595 }596 if (this.__state === REMOVE || target === REMOVE) {597 removeElem(element);598 }599 if (this.__state === BREAK || target === BREAK) {600 return outer.root;601 }602 continue;603 }604 target = this.__execute(visitor.enter, element);605 606 // node may be replaced with null,607 // so distinguish between undefined and null in this place608 if (target !== undefined && target !== BREAK && target !== SKIP && target !== REMOVE) {609 // replace610 element.ref.replace(target);611 element.node = target;612 }613 if (this.__state === REMOVE || target === REMOVE) {614 removeElem(element);615 element.node = null;616 }617 if (this.__state === BREAK || target === BREAK) {618 return outer.root;619 }620 621 // node may be null622 node = element.node;623 if (!node) {624 continue;625 }626 worklist.push(sentinel);627 leavelist.push(element);628 if (this.__state === SKIP || target === SKIP) {629 continue;630 }631 nodeType = node.type || element.wrap;632 candidates = this.__keys[nodeType];633 if (!candidates) {634 if (this.__fallback) {635 candidates = this.__fallback(node);636 } else {637 throw new Error('Unknown node type ' + nodeType + '.');638 }639 }640 current = candidates.length;641 while ((current -= 1) >= 0) {642 key = candidates[current];643 candidate = node[key];644 if (!candidate) {645 continue;646 }647 if (Array.isArray(candidate)) {648 current2 = candidate.length;649 while ((current2 -= 1) >= 0) {650 if (!candidate[current2]) {651 continue;652 }653 if (isProperty(nodeType, candidates[current])) {654 element = new Element(candidate[current2], [key, current2], 'Property', new Reference(candidate, current2));655 } else if (isNode(candidate[current2])) {656 element = new Element(candidate[current2], [key, current2], null, new Reference(candidate, current2));657 } else {658 continue;659 }660 worklist.push(element);661 }662 } else if (isNode(candidate)) {663 worklist.push(new Element(candidate, key, null, new Reference(node, key)));664 }665 }666 }667 return outer.root;668 };669 function traverse(root, visitor) {670 var controller = new Controller();671 return controller.traverse(root, visitor);672 }673 function replace(root, visitor) {674 var controller = new Controller();675 return controller.replace(root, visitor);676 }677 function extendCommentRange(comment, tokens) {678 var target;679 target = upperBound(tokens, function search(token) {680 return token.range[0] > comment.range[0];681 });682 comment.extendedRange = [comment.range[0], comment.range[1]];683 if (target !== tokens.length) {684 comment.extendedRange[1] = tokens[target].range[0];685 }686 target -= 1;687 if (target >= 0) {688 comment.extendedRange[0] = tokens[target].range[1];689 }690 return comment;691 }692 function attachComments(tree, providedComments, tokens) {693 // At first, we should calculate extended comment ranges.694 var comments = [],695 comment,696 len,697 i,698 cursor;699 if (!tree.range) {700 throw new Error('attachComments needs range information');701 }702 703 // tokens array is empty, we attach comments to tree as 'leadingComments'704 if (!tokens.length) {705 if (providedComments.length) {706 for (i = 0, len = providedComments.length; i < len; i += 1) {707 comment = deepCopy(providedComments[i]);708 comment.extendedRange = [0, tree.range[0]];709 comments.push(comment);710 }711 tree.leadingComments = comments;712 }713 return tree;714 }715 for (i = 0, len = providedComments.length; i < len; i += 1) {716 comments.push(extendCommentRange(deepCopy(providedComments[i]), tokens));717 }718 719 // This is based on John Freeman's implementation.720 cursor = 0;721 traverse(tree, {722 enter: function (node) {723 var comment;724 while (cursor < comments.length) {725 comment = comments[cursor];726 if (comment.extendedRange[1] > node.range[0]) {727 break;728 }729 if (comment.extendedRange[1] === node.range[0]) {730 if (!node.leadingComments) {731 node.leadingComments = [];732 }733 node.leadingComments.push(comment);734 comments.splice(cursor, 1);735 } else {736 cursor += 1;737 }738 }739 740 // already out of owned node741 if (cursor === comments.length) {742 return VisitorOption.Break;743 }744 if (comments[cursor].extendedRange[0] > node.range[1]) {745 return VisitorOption.Skip;746 }747 }748 });749 cursor = 0;750 traverse(tree, {751 leave: function (node) {752 var comment;753 while (cursor < comments.length) {754 comment = comments[cursor];755 if (node.range[1] < comment.extendedRange[0]) {756 break;757 }758 if (node.range[1] === comment.extendedRange[0]) {759 if (!node.trailingComments) {760 node.trailingComments = [];761 }762 node.trailingComments.push(comment);763 comments.splice(cursor, 1);764 } else {765 cursor += 1;766 }767 }768 769 // already out of owned node770 if (cursor === comments.length) {771 return VisitorOption.Break;772 }773 if (comments[cursor].extendedRange[0] > node.range[1]) {774 return VisitorOption.Skip;775 }776 }777 });778 return tree;779 }780 exports.Syntax = Syntax;781 exports.traverse = traverse;782 exports.replace = replace;783 exports.attachComments = attachComments;784 exports.VisitorKeys = VisitorKeys;785 exports.VisitorOption = VisitorOption;786 exports.Controller = Controller;787 exports.cloneEnvironment = function () {788 return clone({});789 };790 return exports;791 })(exports);792 /* vim: set sw=4 ts=4 et tw=80 : */793 });794 795 var parser = createCommonjsModule(function (module) {796 /*797 * Generated by PEG.js 0.10.0.798 *799 * http://pegjs.org/800 */801 (function (root, factory) {802 if ( module.exports) {803 module.exports = factory();804 }805 })(commonjsGlobal, function () {806 807 function peg$subclass(child, parent) {808 function ctor() {809 this.constructor = child;810 }811 ctor.prototype = parent.prototype;812 child.prototype = new ctor();813 }814 function peg$SyntaxError(message, expected, found, location) {815 this.message = message;816 this.expected = expected;817 this.found = found;818 this.location = location;819 this.name = "SyntaxError";820 if (typeof Error.captureStackTrace === "function") {821 Error.captureStackTrace(this, peg$SyntaxError);822 }823 }824 peg$subclass(peg$SyntaxError, Error);825 peg$SyntaxError.buildMessage = function (expected, found) {826 var DESCRIBE_EXPECTATION_FNS = {827 literal: function literal(expectation) {828 return "\"" + literalEscape(expectation.text) + "\"";829 },830 "class": function _class(expectation) {831 var escapedParts = "",832 i;833 for (i = 0; i < expectation.parts.length; i++) {834 escapedParts += expectation.parts[i] instanceof Array ? classEscape(expectation.parts[i][0]) + "-" + classEscape(expectation.parts[i][1]) : classEscape(expectation.parts[i]);835 }836 return "[" + (expectation.inverted ? "^" : "") + escapedParts + "]";837 },838 any: function any(expectation) {839 return "any character";840 },841 end: function end(expectation) {842 return "end of input";843 },844 other: function other(expectation) {845 return expectation.description;846 }847 };848 function hex(ch) {849 return ch.charCodeAt(0).toString(16).toUpperCase();850 }851 function literalEscape(s) {852 return s.replace(/\\/g, '\\\\').replace(/"/g, '\\"').replace(/\0/g, '\\0').replace(/\t/g, '\\t').replace(/\n/g, '\\n').replace(/\r/g, '\\r').replace(/[\x00-\x0F]/g, function (ch) {853 return '\\x0' + hex(ch);854 }).replace(/[\x10-\x1F\x7F-\x9F]/g, function (ch) {855 return '\\x' + hex(ch);856 });857 }858 function classEscape(s) {859 return s.replace(/\\/g, '\\\\').replace(/\]/g, '\\]').replace(/\^/g, '\\^').replace(/-/g, '\\-').replace(/\0/g, '\\0').replace(/\t/g, '\\t').replace(/\n/g, '\\n').replace(/\r/g, '\\r').replace(/[\x00-\x0F]/g, function (ch) {860 return '\\x0' + hex(ch);861 }).replace(/[\x10-\x1F\x7F-\x9F]/g, function (ch) {862 return '\\x' + hex(ch);863 });864 }865 function describeExpectation(expectation) {866 return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation);867 }868 function describeExpected(expected) {869 var descriptions = new Array(expected.length),870 i,871 j;872 for (i = 0; i < expected.length; i++) {873 descriptions[i] = describeExpectation(expected[i]);874 }875 descriptions.sort();876 if (descriptions.length > 0) {877 for (i = 1, j = 1; i < descriptions.length; i++) {878 if (descriptions[i - 1] !== descriptions[i]) {879 descriptions[j] = descriptions[i];880 j++;881 }882 }883 descriptions.length = j;884 }885 switch (descriptions.length) {886 case 1:887 return descriptions[0];888 case 2:889 return descriptions[0] + " or " + descriptions[1];890 default:891 return descriptions.slice(0, -1).join(", ") + ", or " + descriptions[descriptions.length - 1];892 }893 }894 function describeFound(found) {895 return found ? "\"" + literalEscape(found) + "\"" : "end of input";896 }897 return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found.";898 };899 function peg$parse(input, options) {900 options = options !== void 0 ? options : {};901 var peg$FAILED = {},902 peg$startRuleFunctions = {903 start: peg$parsestart904 },905 peg$startRuleFunction = peg$parsestart,906 peg$c0 = function peg$c0(ss) {907 return ss.length === 1 ? ss[0] : {908 type: 'matches',909 selectors: ss910 };911 },912 peg$c1 = function peg$c1() {913 return void 0;914 },915 peg$c2 = " ",916 peg$c3 = peg$literalExpectation(" ", false),917 peg$c4 = /^[^ [\],():#!=><~+.]/,918 peg$c5 = peg$classExpectation([" ", "[", "]", ",", "(", ")", ":", "#", "!", "=", ">", "<", "~", "+", "."], true, false),919 peg$c6 = function peg$c6(i) {920 return i.join('');921 },922 peg$c7 = ">",923 peg$c8 = peg$literalExpectation(">", false),924 peg$c9 = function peg$c9() {925 return 'child';926 },927 peg$c10 = "~",928 peg$c11 = peg$literalExpectation("~", false),929 peg$c12 = function peg$c12() {930 return 'sibling';931 },932 peg$c13 = "+",933 peg$c14 = peg$literalExpectation("+", false),934 peg$c15 = function peg$c15() {935 return 'adjacent';936 },937 peg$c16 = function peg$c16() {938 return 'descendant';939 },940 peg$c17 = ",",941 peg$c18 = peg$literalExpectation(",", false),942 peg$c19 = function peg$c19(s, ss) {943 return [s].concat(ss.map(function (s) {944 return s[3];945 }));946 },947 peg$c20 = function peg$c20(op, s) {948 if (!op) return s;949 return {950 type: op,951 left: {952 type: 'exactNode'953 },954 right: s955 };956 },957 peg$c21 = function peg$c21(a, ops) {958 return ops.reduce(function (memo, rhs) {959 return {960 type: rhs[0],961 left: memo,962 right: rhs[1]963 };964 }, a);965 },966 peg$c22 = "!",967 peg$c23 = peg$literalExpectation("!", false),968 peg$c24 = function peg$c24(subject, as) {969 var b = as.length === 1 ? as[0] : {970 type: 'compound',971 selectors: as972 };973 if (subject) b.subject = true;974 return b;975 },976 peg$c25 = "*",977 peg$c26 = peg$literalExpectation("*", false),978 peg$c27 = function peg$c27(a) {979 return {980 type: 'wildcard',981 value: a982 };983 },984 peg$c28 = "#",985 peg$c29 = peg$literalExpectation("#", false),986 peg$c30 = function peg$c30(i) {987 return {988 type: 'identifier',989 value: i990 };991 },992 peg$c31 = "[",993 peg$c32 = peg$literalExpectation("[", false),994 peg$c33 = "]",995 peg$c34 = peg$literalExpectation("]", false),996 peg$c35 = function peg$c35(v) {997 return v;998 },999 peg$c36 = /^[><!]/,1000 peg$c37 = peg$classExpectation([">", "<", "!"], false, false),1001 peg$c38 = "=",1002 peg$c39 = peg$literalExpectation("=", false),1003 peg$c40 = function peg$c40(a) {1004 return (a || '') + '=';1005 },1006 peg$c41 = /^[><]/,1007 peg$c42 = peg$classExpectation([">", "<"], false, false),1008 peg$c43 = ".",1009 peg$c44 = peg$literalExpectation(".", false),1010 peg$c45 = function peg$c45(a, as) {1011 return [].concat.apply([a], as).join('');1012 },1013 peg$c46 = function peg$c46(name, op, value) {1014 return {1015 type: 'attribute',1016 name: name,1017 operator: op,1018 value: value1019 };1020 },1021 peg$c47 = function peg$c47(name) {1022 return {1023 type: 'attribute',1024 name: name1025 };1026 },1027 peg$c48 = "\"",1028 peg$c49 = peg$literalExpectation("\"", false),1029 peg$c50 = /^[^\\"]/,1030 peg$c51 = peg$classExpectation(["\\", "\""], true, false),1031 peg$c52 = "\\",1032 peg$c53 = peg$literalExpectation("\\", false),1033 peg$c54 = peg$anyExpectation(),1034 peg$c55 = function peg$c55(a, b) {1035 return a + b;1036 },1037 peg$c56 = function peg$c56(d) {1038 return {1039 type: 'literal',1040 value: strUnescape(d.join(''))1041 };1042 },1043 peg$c57 = "'",1044 peg$c58 = peg$literalExpectation("'", false),1045 peg$c59 = /^[^\\']/,1046 peg$c60 = peg$classExpectation(["\\", "'"], true, false),1047 peg$c61 = /^[0-9]/,1048 peg$c62 = peg$classExpectation([["0", "9"]], false, false),1049 peg$c63 = function peg$c63(a, b) {1050 // Can use `a.flat().join('')` once supported1051 var leadingDecimals = a ? [].concat.apply([], a).join('') : '';1052 return {1053 type: 'literal',1054 value: parseFloat(leadingDecimals + b.join(''))1055 };1056 },1057 peg$c64 = function peg$c64(i) {1058 return {1059 type: 'literal',1060 value: i1061 };1062 },1063 peg$c65 = "type(",1064 peg$c66 = peg$literalExpectation("type(", false),1065 peg$c67 = /^[^ )]/,1066 peg$c68 = peg$classExpectation([" ", ")"], true, false),1067 peg$c69 = ")",1068 peg$c70 = peg$literalExpectation(")", false),1069 peg$c71 = function peg$c71(t) {1070 return {1071 type: 'type',1072 value: t.join('')1073 };1074 },1075 peg$c72 = /^[imsu]/,1076 peg$c73 = peg$classExpectation(["i", "m", "s", "u"], false, false),1077 peg$c74 = "/",1078 peg$c75 = peg$literalExpectation("/", false),1079 peg$c76 = function peg$c76(pattern, flgs) {1080 return {1081 type: 'regexp',1082 value: new RegExp(pattern.join(''), flgs ? flgs.join('') : '')1083 };1084 },1085 peg$c77 = /^[^\]\\]/,1086 peg$c78 = peg$classExpectation(["]", "\\"], true, false),1087 peg$c79 = function peg$c79(cs) {1088 return '[' + cs.join('') + ']';1089 },1090 peg$c80 = function peg$c80(a) {1091 return '\\' + a;1092 },1093 peg$c81 = /^[^\/\\[]/,1094 peg$c82 = peg$classExpectation(["/", "\\", "["], true, false),1095 peg$c83 = function peg$c83(cs) {1096 return cs.join('');1097 },1098 peg$c84 = function peg$c84(i, is) {1099 return {1100 type: 'field',1101 name: is.reduce(function (memo, p) {1102 return memo + p[0] + p[1];1103 }, i)1104 };1105 },1106 peg$c85 = ":not(",1107 peg$c86 = peg$literalExpectation(":not(", false),1108 peg$c87 = function peg$c87(ss) {1109 return {1110 type: 'not',1111 selectors: ss1112 };1113 },1114 peg$c88 = ":matches(",1115 peg$c89 = peg$literalExpectation(":matches(", false),1116 peg$c90 = function peg$c90(ss) {1117 return {1118 type: 'matches',1119 selectors: ss1120 };1121 },1122 peg$c91 = ":is(",1123 peg$c92 = peg$literalExpectation(":is(", false),1124 peg$c93 = ":has(",1125 peg$c94 = peg$literalExpectation(":has(", false),1126 peg$c95 = function peg$c95(ss) {1127 return {1128 type: 'has',1129 selectors: ss1130 };1131 },1132 peg$c96 = ":first-child",1133 peg$c97 = peg$literalExpectation(":first-child", false),1134 peg$c98 = function peg$c98() {1135 return nth(1);1136 },1137 peg$c99 = ":last-child",1138 peg$c100 = peg$literalExpectation(":last-child", false),1139 peg$c101 = function peg$c101() {1140 return nthLast(1);1141 },1142 peg$c102 = ":nth-child(",1143 peg$c103 = peg$literalExpectation(":nth-child(", false),1144 peg$c104 = function peg$c104(n) {1145 return nth(parseInt(n.join(''), 10));1146 },1147 peg$c105 = ":nth-last-child(",1148 peg$c106 = peg$literalExpectation(":nth-last-child(", false),1149 peg$c107 = function peg$c107(n) {1150 return nthLast(parseInt(n.join(''), 10));1151 },1152 peg$c108 = ":",1153 peg$c109 = peg$literalExpectation(":", false),1154 peg$c110 = function peg$c110(c) {1155 return {1156 type: 'class',1157 name: c1158 };1159 },1160 peg$currPos = 0,1161 peg$posDetailsCache = [{1162 line: 1,1163 column: 11164 }],1165 peg$maxFailPos = 0,1166 peg$maxFailExpected = [],1167 peg$resultsCache = {},1168 peg$result;1169 if ("startRule" in options) {1170 if (!(options.startRule in peg$startRuleFunctions)) {1171 throw new Error("Can't start parsing from rule \"" + options.startRule + "\".");1172 }1173 peg$startRuleFunction = peg$startRuleFunctions[options.startRule];1174 }1175 function peg$literalExpectation(text, ignoreCase) {1176 return {1177 type: "literal",1178 text: text,1179 ignoreCase: ignoreCase1180 };1181 }1182 function peg$classExpectation(parts, inverted, ignoreCase) {1183 return {1184 type: "class",1185 parts: parts,1186 inverted: inverted,1187 ignoreCase: ignoreCase1188 };1189 }1190 function peg$anyExpectation() {1191 return {1192 type: "any"1193 };1194 }1195 function peg$endExpectation() {1196 return {1197 type: "end"1198 };1199 }1200 function peg$computePosDetails(pos) {