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