LiDa_Search/js/lib/peg-0.10.0.min.js

12 lines
103 KiB
JavaScript
Raw Normal View History

2022-10-10 10:08:39 +02:00
/*
* PEG.js 0.10.0
*
* http://pegjs.org/
*
* Copyright (c) 2010-2016 David Majda
* Licensed under the MIT license.
*/
!function(u){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=u();else if("function"==typeof define&&define.amd)define([],u);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.peg=u()}}(function(){var define,module,exports;return function u(e,t,r){function n(s,i){if(!t[s]){if(!e[s]){var a="function"==typeof require&&require;if(!i&&a)return a(s,!0);if(o)return o(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var p=t[s]={exports:{}};e[s][0].call(p.exports,function(u){var t=e[s][1][u];return n(t?t:u)},p,p.exports,u,e,t,r)}return t[s].exports}for(var o="function"==typeof require&&require,s=0;s<r.length;s++)n(r[s]);return n}({1:[function(u,e,t){"use strict";var r=u("../utils/arrays"),n=u("./visitor"),o={findRule:function(u,e){return r.find(u.rules,function(u){return u.name===e})},indexOfRule:function(u,e){return r.indexOf(u.rules,function(u){return u.name===e})},alwaysConsumesOnSuccess:function(u,e){function t(){return!0}function s(){return!1}function i(u){return a(u.expression)}var a=n.build({rule:i,named:i,choice:function(u){return r.every(u.alternatives,a)},action:i,sequence:function(u){return r.some(u.elements,a)},labeled:i,text:i,simple_and:s,simple_not:s,optional:s,zero_or_more:s,one_or_more:i,group:i,semantic_and:s,semantic_not:s,rule_ref:function(e){return a(o.findRule(u,e.name))},literal:function(u){return""!==u.value},class:t,any:t});return a(e)}};e.exports=o},{"../utils/arrays":17,"./visitor":13}],2:[function(require,module,exports){"use strict";var arrays=require("../utils/arrays"),objects=require("../utils/objects"),compiler={visitor:require("./visitor"),passes:{check:{reportUndefinedRules:require("./passes/report-undefined-rules"),reportDuplicateRules:require("./passes/report-duplicate-rules"),reportDuplicateLabels:require("./passes/report-duplicate-labels"),reportInfiniteRecursion:require("./passes/report-infinite-recursion"),reportInfiniteRepetition:require("./passes/report-infinite-repetition")},transform:{removeProxyRules:require("./passes/remove-proxy-rules")},generate:{generateBytecode:require("./passes/generate-bytecode"),generateJS:require("./passes/generate-js")}},compile:function(ast,passes,options){options=void 0!==options?options:{};var stage;options=objects.clone(options),objects.defaults(options,{allowedStartRules:[ast.rules[0].name],cache:!1,dependencies:{},exportVar:null,format:"bare",optimize:"speed",output:"parser",trace:!1});for(stage in passes)passes.hasOwnProperty(stage)&&arrays.each(passes[stage],function(u){u(ast,options)});switch(options.output){case"parser":return eval(ast.code);case"source":return ast.code}}};module.exports=compiler},{"../utils/arrays":17,"../utils/objects":19,"./passes/generate-bytecode":5,"./passes/generate-js":6,"./passes/remove-proxy-rules":7,"./passes/report-duplicate-labels":8,"./passes/report-duplicate-rules":9,"./passes/report-infinite-recursion":10,"./passes/report-infinite-repetition":11,"./passes/report-undefined-rules":12,"./visitor":13}],3:[function(u,e,t){"use strict";function r(u){return u.charCodeAt(0).toString(16).toUpperCase()}var n={stringEscape:function(u){return u.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\x08/g,"\\b").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\f/g,"\\f").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(u){return"\\x0"+r(u)}).replace(/[\x10-\x1F\x7F-\xFF]/g,function(u){return"\\x"+r(u)}).replace(/[\u0100-\u0FFF]/g,function(u){return"\\u0"+r(u)}).replace(/[\u1000-\uFFFF]/g,function(u){return"\\u"+r(u)})},regexpClassEscape:function(u){return u.replace(/\\/g,"\\\\").replace(/\//g,"\\/").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\v/g,"\\x0B").replace(/\f/g,"\\f").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(u){return"\\x0"+r(u)}).replace(/[\x10-\x1F\x7F-\xFF]/g,function(u){return"\\x"+r(u)}).replace(/[\u0100-\u0FFF]/g,function(u){return"\\u0"+r(u)}).replace(/[\u1000-\uF
o.push("")):arrays.each(ast.rules,function(u){o.push(indent2(generateRuleFunction(u))),o.push("")}),ast.initializer&&(o.push(indent2(ast.initializer.code)),o.push("")),"size"===options.optimize?o.push(" peg$result = peg$parseRule(peg$startRuleIndex);"):o.push(" peg$result = peg$startRuleFunction();"),o.push([""," if (peg$result !== peg$FAILED && peg$currPos === input.length) {"," return peg$result;"," } else {"," if (peg$result !== peg$FAILED && peg$currPos < input.length) {"," peg$fail(peg$endExpectation());"," }",""," throw peg$buildStructuredError("," peg$maxFailExpected,"," peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null,"," peg$maxFailPos < input.length"," ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1)"," : peg$computeLocation(peg$maxFailPos, peg$maxFailPos)"," );"," }","}"].join("\n")),o.join("\n")}function generateWrapper(u){function e(){return["/*"," * Generated by PEG.js 0.10.0."," *"," * http://pegjs.org/"," */"].join("\n")}function t(){return options.trace?["{"," SyntaxError: peg$SyntaxError,"," DefaultTracer: peg$DefaultTracer,"," parse: peg$parse","}"].join("\n"):["{"," SyntaxError: peg$SyntaxError,"," parse: peg$parse","}"].join("\n")}var r={bare:function(){return[e(),"(function() {",' "use strict";',"",indent2(u),"",indent2("return "+t()+";"),"})()"].join("\n")},commonjs:function(){var r=[],n=objects.keys(options.dependencies),o=arrays.map(n,function(u){return u+' = require("'+js.stringEscape(options.dependencies[u])+'")'});return r.push([e(),"",'"use strict";',""].join("\n")),o.length>0&&(r.push("var "+o.join(", ")+";"),r.push("")),r.push([u,"","module.exports = "+t()+";",""].join("\n")),r.join("\n")},amd:function(){var r=objects.values(options.dependencies),n=objects.keys(options.dependencies),o="["+arrays.map(r,function(u){return'"'+js.stringEscape(u)+'"'}).join(", ")+"]",s=n.join(", ");return[e(),"define("+o+", function("+s+") {",' "use strict";',"",indent2(u),"",indent2("return "+t()+";"),"});",""].join("\n")},globals:function(){return[e(),"(function(root) {",' "use strict";',"",indent2(u),"",indent2("root."+options.exportVar+" = "+t()+";"),"})(this);",""].join("\n")},umd:function(){var r=[],n=objects.values(options.dependencies),o=objects.keys(options.dependencies),s="["+arrays.map(n,function(u){return'"'+js.stringEscape(u)+'"'}).join(", ")+"]",i=arrays.map(n,function(u){return'require("'+js.stringEscape(u)+'")'}).join(", "),a=o.join(", ");return r.push([e(),"(function(root, factory) {",' if (typeof define === "function" && define.amd) {'," define("+s+", factory);",' } else if (typeof module === "object" && module.exports) {'," module.exports = factory("+i+");"].join("\n")),null!==options.exportVar&&r.push([" } else {"," root."+options.exportVar+" = factory();"].join("\n")),r.push([" }","})(this, function("+a+") {",' "use strict";',"",indent2(u),"",indent2("return "+t()+";"),"});",""].join("\n")),r.join("\n")}};return r[options.format]()}ast.code=generateWrapper(generateToplevel())}var arrays=require("../../utils/arrays"),objects=require("../../utils/objects"),asts=require("../asts"),op=require("../opcodes"),js=require("../js");module.exports=generateJS},{"../../utils/arrays":17,"../../utils/objects":19,"../asts":1,"../js":3,"../opcodes":4}],7:[function(u,e,t){"use strict";function r(u,e){function t(u){return"rule"===u.type&&"rule_ref"===u.expression.type}function r(u,e,t){var r=o.build({rule_ref:function(u){u.name===e&&(u.name=t)}});r(u)}var s=[];n.each(u.rules,function(o,i){t(o)&&(r(u,o.name,o.expression.name),n.contains(e.allowedStartRules,o.name)||s.push(i))}),s.reverse(),n.each(s,function(e){u.rules.splice(e,1)})}var n=u("../../utils/arrays"),o=u("../visitor");e.exports=r},{"../../utils/arrays":17,"../visitor":13}],8:[function(u,e,t){"use strict";function r(u){function e(u,e){t(u.expression,s.clone(e))}var t=i.build({rule:function(u){t(u.expression,{})},choice:function(u,e){o.each(u.alternatives,function(u){t(u,s.clone(e))})},action:e,labeled:function(u,e){if(e.hasOwnProper
Vo+=5):(t=de,0===Zo&&E(Ho)),t!==de?(r=Vo,Zo++,n=q(),Zo--,n===de?r=void 0:(Vo=r,r=de),r!==de?(t=[t,r],e=t):(Vo=e,e=de)):(Vo=e,e=de),e}function ie(){var e,t,r,n;return e=Vo,u.substr(Vo,4)===qo?(t=qo,Vo+=4):(t=de,0===Zo&&E(zo)),t!==de?(r=Vo,Zo++,n=q(),Zo--,n===de?r=void 0:(Vo=r,r=de),r!==de?(t=[t,r],e=t):(Vo=e,e=de)):(Vo=e,e=de),e}function ae(){var u,e;for(u=[],e=S(),e===de&&(e=O(),e===de&&(e=j()));e!==de;)u.push(e),e=S(),e===de&&(e=O(),e===de&&(e=j()));return u}function ce(){var u,e;for(u=[],e=S(),e===de&&(e=w());e!==de;)u.push(e),e=S(),e===de&&(e=w());return u}function pe(){var e,t,r,n;return e=Vo,t=ae(),t!==de?(59===u.charCodeAt(Vo)?(r=Mo,Vo++):(r=de,0===Zo&&E(Go)),r!==de?(t=[t,r],e=t):(Vo=e,e=de)):(Vo=e,e=de),e===de&&(e=Vo,t=ce(),t!==de?(r=T(),r===de&&(r=null),r!==de?(n=O(),n!==de?(t=[t,r,n],e=t):(Vo=e,e=de)):(Vo=e,e=de)):(Vo=e,e=de),e===de&&(e=Vo,t=ae(),t!==de?(r=Ae(),r!==de?(t=[t,r],e=t):(Vo=e,e=de)):(Vo=e,e=de))),e}function Ae(){var e,t;return e=Vo,Zo++,u.length>Vo?(t=u.charAt(Vo),Vo++):(t=de,0===Zo&&E(ut)),Zo--,t===de?e=void 0:(Vo=e,e=de),e}function le(u){var e,t=[];for(e=0;e<u.length;e++)""!==u[e]&&t.push(u[e]);return t}function Ee(u,e){return u?u[e]:null}function Ce(u,e){var t,r=new Array(u.length);for(t=0;t<u.length;t++)r[t]=u[t][e];return r}function fe(u,e,t){return[u].concat(Ce(e,t))}e=void 0!==e?e:{};var Fe,de={},he={Grammar:F},ge=F,De=function(u,e){return{type:"grammar",initializer:Ee(u,0),rules:Ce(e,0),location:r()}},Be=function(u){return{type:"initializer",code:u,location:r()}},ve="=",me=s("=",!1),be=function(u,e,t){return{type:"rule",name:u,expression:null!==e?{type:"named",name:e[0],expression:t,location:r()}:t,location:r()}},xe="/",Pe=s("/",!1),_e=function(u,e){return e.length>0?{type:"choice",alternatives:fe(u,e,3),location:r()}:u},ye=function(u,e){return null!==e?{type:"action",expression:u,code:e[1],location:r()}:u},$e=function(u,e){return e.length>0?{type:"sequence",elements:fe(u,e,1),location:r()}:u},Re=":",ke=s(":",!1),Se=function(u,e){return{type:"labeled",label:u,expression:e,location:r()}},Ie=function(u,e){return{type:Ko[u],expression:e,location:r()}},Oe="$",je=s("$",!1),Le="&",we=s("&",!1),Te="!",Ne=s("!",!1),Ue=function(u,e){return{type:Qo[e],expression:u,location:r()}},He="?",qe=s("?",!1),ze="*",Me=s("*",!1),Ge="+",Ve=s("+",!1),Ye="(",We=s("(",!1),Xe=")",Je=s(")",!1),Ze=function(u){return"labeled"===u.type||"sequence"===u.type?{type:"group",expression:u}:u},Ke=function(u){return{type:"rule_ref",name:u,location:r()}},Qe=function(u,e){return{type:us[u],code:e,location:r()}},ut=a(),et=p("whitespace"),tt="\t",rt=s("\t",!1),nt="\v",ot=s("\v",!1),st="\f",it=s("\f",!1),at=" ",ct=s(" ",!1),pt=" ",At=s(" ",!1),lt="\ufeff",Et=s("\ufeff",!1),Ct=/^[\n\r\u2028\u2029]/,ft=i(["\n","\r","\u2028","\u2029"],!1,!1),Ft=p("end of line"),dt="\n",ht=s("\n",!1),gt="\r\n",Dt=s("\r\n",!1),Bt="\r",vt=s("\r",!1),mt="\u2028",bt=s("\u2028",!1),xt="\u2029",Pt=s("\u2029",!1),_t=p("comment"),yt="/*",$t=s("/*",!1),Rt="*/",kt=s("*/",!1),St="//",It=s("//",!1),Ot=function(u){return u},jt=p("identifier"),Lt=function(u,e){return u+e.join("")},wt="_",Tt=s("_",!1),Nt="\\",Ut=s("\\",!1),Ht=function(u){return u},qt="",zt=s("",!1),Mt="",Gt=s("",!1),Vt=p("literal"),Yt="i",Wt=s("i",!1),Xt=function(u,e){return{type:"literal",value:u,ignoreCase:null!==e,location:r()}},Jt=p("string"),Zt='"',Kt=s('"',!1),Qt=function(u){return u.join("")},ur="'",er=s("'",!1),tr=function(){return t()},rr=p("character class"),nr="[",or=s("[",!1),sr="^",ir=s("^",!1),ar="]",cr=s("]",!1),pr=function(u,e,t){return{type:"class",parts:le(e),inverted:null!==u,ignoreCase:null!==t,location:r()}},Ar="-",lr=s("-",!1),Er=function(u,e){return u.charCodeAt(0)>e.charCodeAt(0)&&o("Invalid character range: "+t()+"."),[u,e]},Cr=function(){return""},fr="0",Fr=s("0",!1),dr=function(){return"\0"},hr="b",gr=s("b",!1),Dr=function(){return"\b"},Br="f",vr=s("f",!1),mr=function(){return"\f"},br="n",xr=s("n",!1),Pr=function(){return"\n"},_r="r",yr=s("r",!1),$r=function(){return"\r"},Rr="t",kr=s("t",!1),Sr=function(){return"\t"},Ir="v",Or=s("v",!1),jr=function(){return"\v"}
line:1,column:1}],Xo=0,Jo=[],Zo=0;if("startRule"in e){if(!(e.startRule in he))throw new Error("Can't start parsing from rule \""+e.startRule+'".');ge=he[e.startRule]}var Ko={$:"text","&":"simple_and","!":"simple_not"},Qo={"?":"optional","*":"zero_or_more","+":"one_or_more"},us={"&":"semantic_and","!":"semantic_not"};if(Fe=ge(),Fe!==de&&Vo===u.length)return Fe;throw Fe!==de&&Vo<u.length&&E(c()),f(Jo,Xo<u.length?u.charAt(Xo):null,Xo<u.length?l(Xo,Xo+1):l(Xo,Xo))}r(n,Error),n.buildMessage=function(u,e){function t(u){return u.charCodeAt(0).toString(16).toUpperCase()}function r(u){return u.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(u){return"\\x0"+t(u)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(u){return"\\x"+t(u)})}function n(u){return u.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(u){return"\\x0"+t(u)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(u){return"\\x"+t(u)})}function o(u){return a[u.type](u)}function s(u){var e,t,r=new Array(u.length);for(e=0;e<u.length;e++)r[e]=o(u[e]);if(r.sort(),r.length>0){for(e=1,t=1;e<r.length;e++)r[e-1]!==r[e]&&(r[t]=r[e],t++);r.length=t}switch(r.length){case 1:return r[0];case 2:return r[0]+" or "+r[1];default:return r.slice(0,-1).join(", ")+", or "+r[r.length-1]}}function i(u){return u?'"'+r(u)+'"':"end of input"}var a={literal:function(u){return'"'+r(u.text)+'"'},class:function(u){var e,t="";for(e=0;e<u.parts.length;e++)t+=u.parts[e]instanceof Array?n(u.parts[e][0])+"-"+n(u.parts[e][1]):n(u.parts[e]);return"["+(u.inverted?"^":"")+t+"]"},any:function(u){return"any character"},end:function(u){return"end of input"},other:function(u){return u.description}};return"Expected "+s(u)+" but "+i(e)+" found."},e.exports={SyntaxError:n,parse:o}},{}],16:[function(u,e,t){"use strict";var r=u("./utils/arrays"),n=u("./utils/objects"),o={VERSION:"0.10.0",GrammarError:u("./grammar-error"),parser:u("./parser"),compiler:u("./compiler"),generate:function(u,e){function t(u){var e,t={};for(e in u)u.hasOwnProperty(e)&&(t[e]=n.values(u[e]));return t}e=void 0!==e?e:{},e=n.clone(e);var s="plugins"in e?e.plugins:[],i={parser:o.parser,passes:t(o.compiler.passes)};return r.each(s,function(u){u.use(i,e)}),o.compiler.compile(i.parser.parse(u),i.passes,e)}};e.exports=o},{"./compiler":2,"./grammar-error":14,"./parser":15,"./utils/arrays":17,"./utils/objects":19}],17:[function(u,e,t){"use strict";var r={range:function(u,e){var t,r,n=e-u,o=new Array(n);for(t=0,r=u;t<n;t++,r++)o[t]=r;return o},find:function(u,e){var t,r=u.length;if("function"==typeof e){for(t=0;t<r;t++)if(e(u[t]))return u[t]}else for(t=0;t<r;t++)if(u[t]===e)return u[t]},indexOf:function(u,e){var t,r=u.length;if("function"==typeof e){for(t=0;t<r;t++)if(e(u[t]))return t}else for(t=0;t<r;t++)if(u[t]===e)return t;return-1},contains:function(u,e){return r.indexOf(u,e)!==-1},each:function(u,e){var t,r=u.length;for(t=0;t<r;t++)e(u[t],t)},map:function(u,e){var t,r=u.length,n=new Array(r);for(t=0;t<r;t++)n[t]=e(u[t],t);return n},pluck:function(u,e){return r.map(u,function(u){return u[e]})},every:function(u,e){var t,r=u.length;for(t=0;t<r;t++)if(!e(u[t]))return!1;return!0},some:function(u,e){var t,r=u.length;for(t=0;t<r;t++)if(e(u[t]))return!0;return!1}};e.exports=r},{}],18:[function(u,e,t){"use strict";var r={subclass:function(u,e){function t(){this.constructor=u}t.prototype=e.prototype,u.prototype=new t}};e.exports=r},{}],19:[function(u,e,t){"use strict";var r={keys:function(u){var e,t=[];for(e in u)u.hasOwnProperty(e)&&t.push(e);return t},values:function(u){var e,t=[];for(e in u)u.hasOwnProperty(e)&&t.push(u[e]);return t},clone:function(u){var e,t={};for(e in u)u.hasOwnProperty(e)&&(t[e]=u[e]);return t},defaults:function(u,e){var t;for(t in e)e.hasOwnProperty(t)&&(t in u||(u[t]=e[t]))}};e.exports=r},{}]},{},[16])(16)});