Comparing version 1.0.1 to 1.1.0
{ | ||
"name": "astq", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "Abstract Syntax Tree (AST) Query Engine", | ||
@@ -5,0 +5,0 @@ "main": "lib/astq.browser.js", |
@@ -33,2 +33,3 @@ /* | ||
grunt.initConfig({ | ||
version: grunt.file.readYAML("VERSION.yml"), | ||
jshint: { | ||
@@ -48,2 +49,8 @@ options: { | ||
transform: [ | ||
[ "browserify-replace", { replace: [ | ||
{ from: /\$major/g, to: "<%= version.major %>" }, | ||
{ from: /\$minor/g, to: "<%= version.minor %>" }, | ||
{ from: /\$micro/g, to: "<%= version.micro %>" }, | ||
{ from: /\$date/g, to: "<%= version.date %>" } | ||
]}], | ||
"6to5ify", | ||
@@ -69,2 +76,8 @@ "pegjs-otf/transform" | ||
transform: [ | ||
[ "browserify-replace", { replace: [ | ||
{ from: /\$major/g, to: "<%= version.major %>" }, | ||
{ from: /\$minor/g, to: "<%= version.minor %>" }, | ||
{ from: /\$micro/g, to: "<%= version.micro %>" }, | ||
{ from: /\$date/g, to: "<%= version.date %>" } | ||
]}], | ||
"6to5ify", | ||
@@ -71,0 +84,0 @@ "pegjs-otf/transform" |
@@ -50,12 +50,14 @@ /* | ||
},{}],10:[function(_dereq_,module,exports){ | ||
"use strict";var _prototypeProperties=function(e,r,t){r&&Object.defineProperties(e,r),t&&Object.defineProperties(e.prototype,t)},_inherits=function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function, not "+typeof r);e.prototype=Object.create(r&&r.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),r&&(e.__proto__=r)},util=_dereq_("./astq-util.js"),ASTQQueryTrace=_dereq_("./astq-query-trace.js"),ASTQQueryExec=function(e){function r(e,r,t,i){this.adapter=e,this.params=r,this.funcs=t,this.trace=i}return _inherits(r,e),_prototypeProperties(r,null,{execQuery:{value:function(e,r){var t=this;this.traceBegin(e,r);var i=[];return e.childs().forEach(function(e){i=i.concat(t.execPath(e,r))}),this.traceEnd(e,r,i),i},writable:!0,configurable:!0},execPath:{value:function(e,r){var t=this;this.traceBegin(e,r);var i=[r];return e.childs().forEach(function(e){var r=[];i.forEach(function(i){r=r.concat(t.execStep(e,i))}),i=r}),this.traceEnd(e,r,i),i},writable:!0,configurable:!0},execStep:{value:function(e,r){var t=this;this.traceBegin(e,r);var i=e.childs(),a=null,c=null,n=null,u=0;if(u<i.length&&"Axis"===i[u].type()&&(a=i[u++]),u<i.length&&"Match"===i[u].type()&&(c=i[u++]),u<i.length&&"Filter"===i[u].type()&&(n=i[u++]),null===c)throw new Error("no matching part in query step");var l=[],s=c.get("id"),o=function(e){var r=t.adapter.getNodeType(e);if("*"===s||s===r){var i=!0;null!==n&&(t.execFilter(n,e)||(i=!1)),i&&l.push(e)}};if(null!==a){var h=a.get("op");if("/"===h)this.adapter.getChildNodes(r).forEach(function(e){return o(e)});else if("//"===h)!function(){var e=function(r){o(r),t.adapter.getChildNodes(r).forEach(function(r){return e(r)})};t.adapter.getChildNodes(r).forEach(function(r){return e(r)})}();else if("<~"===h){var p=this.adapter.getParentNode(r);if(null!==p){for(var x=this.adapter.getChildNodes(p),d=null,f=0;f<x.length&&x[f]!==r;f++)d=x[f];o(d)}}else if("<~~"===h){var b=this.adapter.getParentNode(r);if(null!==b)for(var x=this.adapter.getChildNodes(b),g=0;g<x.length&&x[g]!==r;g++)o(x[g])}else if("~>"===h){var E=this.adapter.getParentNode(r);if(null!==E){var x=this.adapter.getChildNodes(E),v=void 0;for(v=0;v<x.length&&x[v]!==r;v++);v<x.length&&(v++,o(x[v]))}}else if("~~>"===h){var m=this.adapter.getParentNode(r);if(null!==m){var x=this.adapter.getChildNodes(m),y=void 0;for(y=0;y<x.length&&x[y]!==r;y++);if(y<x.length)for(y++;y<x.length;)o(x[y++])}}else if("~^"===h){var w=this.adapter.getParentNode(r);null!==w&&o(w)}else if("~~^"===h)for(var B=r;;){{this.adapter.getParentNode(B)}if(null===parent)break;o(parent),B=parent}}else o(r);return this.traceEnd(e,r,l),l},writable:!0,configurable:!0},execFilter:{value:function(e,r){this.traceBegin(e,r);var t=e.childs()[0],i=this.execExpr(t,r);return i=util.truthy(i),this.traceEnd(e,r,i),i},writable:!0,configurable:!0},execExpr:{value:function(e,r){switch(e.type()){case"ConditionalBinary":return this.execExprConditionalBinary(e,r);case"ConditionalTernary":return this.execExprConditionalTernary(e,r);case"Logical":return this.execExprLogical(e,r);case"Bitwise":return this.execExprBitwise(e,r);case"Relational":return this.execExprRelational(e,r);case"Arithmetical":return this.execExprArithmetical(e,r);case"Unary":return this.execExprUnary(e,r);case"FuncCall":return this.execExprFuncCall(e,r);case"Attribute":return this.execExprAttribute(e,r);case"Param":return this.execExprParam(e,r);case"LiteralString":return this.execExprLiteralString(e,r);case"LiteralRegExp":return this.execExprLiteralRegExp(e,r);case"LiteralNumber":return this.execExprLiteralNumber(e,r);case"LiteralValue":return this.execExprLiteralValue(e,r);case"Path":return this.execExprPath(e,r)}},writable:!0,configurable:!0},execExprConditionalBinary:{value:function(e,r){this.traceBegin(e,r);var t=this.execExpr(e.childs()[0],r);return util.truthy(t)||(t=this.execExpr(e.childs()[1],r)),this.traceEnd(e,r,t),t},writable:!0,configurable:!0},execExprConditionalTernary:{value:function(e,r){this.traceBegin(e,r);var t=this.execExpr(e.childs()[0],r);return t=util.truthy(t)?this.execExpr(e.childs()[1],r):this.execExpr(e.childs()[2],r),this.traceEnd(e,r,t),t},writable:!0,configurable:!0},execExprLogical:{value:function(e,r){this.traceBegin(e,r);var t=!1;switch(e.get("op")){case"&&":t=util.truthy(this.execExpr(e.childs()[0],r)),t&&(t=t&&util.truthy(this.execExpr(e.childs()[1],r)));break;case"||":t=util.truthy(this.execExpr(e.childs()[0],r)),t||(t=t||util.truthy(this.execExpr(e.childs()[1],r)))}return this.traceEnd(e,r,t),t},writable:!0,configurable:!0},execExprBitwise:{value:function(e,r){this.traceBegin(e,r);var t=util.coerce(this.execExpr(e.childs()[0],r),"number"),i=util.coerce(this.execExpr(e.childs()[1],r),"number"),a=void 0;switch(e.get("op")){case"&":a=t&i;break;case"|":a=t|i;break;case"<<":a=t<<i;break;case">>":a=t>>i}return this.traceEnd(e,r,a),a},writable:!0,configurable:!0},execExprRelational:{value:function(e,r){this.traceBegin(e,r);var t=this.execExpr(e.childs()[0],r),i=this.execExpr(e.childs()[1],r),a=void 0;switch(e.get("op")){case"==":a=t===i;break;case"!=":a=t!==i;break;case"<=":a=util.coerce(t,"number")<=util.coerce(i,"number");break;case">=":a=util.coerce(t,"number")>=util.coerce(i,"number");break;case"<":a=util.coerce(t,"number")<util.coerce(i,"number");break;case">":a=util.coerce(t,"number")>util.coerce(i,"number");break;case"=~":a=null!==util.coerce(t,"string").match(util.coerce(i,"regexp"));break;case"!~":a=null===util.coerce(t,"string").match(util.coerce(i,"regexp"))}return this.traceEnd(e,r,a),a},writable:!0,configurable:!0},execExprArithmetical:{value:function(e,r){this.traceBegin(e,r);var t=this.execExpr(e.childs()[0],r),i=this.execExpr(e.childs()[1],r),a=void 0;switch(e.get("op")){case"+":a="string"==typeof t?t+util.coerce(i,"string"):util.coerce(t,"number")+util.coerce(i,"number");break;case"-":a=util.coerce(t,"number")+util.coerce(i,"number");break;case"*":a=util.coerce(t,"number")*util.coerce(i,"number");break;case"/":a=util.coerce(t,"number")/util.coerce(i,"number");break;case"%":a=util.coerce(t,"number")%util.coerce(i,"number");break;case"**":a=Math.pow(util.coerce(t,"number"),util.coerce(i,"number"))}return this.traceEnd(e,r,a),a},writable:!0,configurable:!0},execExprUnary:{value:function(e,r){this.traceBegin(e,r);var t=this.execExpr(e.childs()[0],r),i=void 0;switch(e.get("op")){case"!":i=!util.coerce(t,"boolean");break;case"~":i=~util.coerce(t,"number")}return this.traceEnd(e,r,i),i},writable:!0,configurable:!0},execExprFuncCall:{value:function(e,r){var t=this;this.traceBegin(e,r);var i=e.get("id"),a=[this.adapter,r];e.childs().forEach(function(e){a.push(t.execExpr(e,r))});var c=this.funcs.run(i,a);return this.traceEnd(e,r,c),c},writable:!0,configurable:!0},execExprAttribute:{value:function(e,r){this.traceBegin(e,r);var t=e.get("id"),i=this.adapter.getNodeAttrValue(r,t);return this.traceEnd(e,r,i),i},writable:!0,configurable:!0},execExprParam:{value:function(e,r){this.traceBegin(e,r);var t=e.get("id");if("undefined"==typeof this.params[t])throw new Error('invalid parameter "'+t+'"');var i=this.params[t];return this.traceEnd(e,r,i),i},writable:!0,configurable:!0},execExprLiteralString:{value:function(e,r){this.traceBegin(e,r);var t=e.get("value");return this.traceEnd(e,r,t),t},writable:!0,configurable:!0},execExprLiteralRegExp:{value:function(e,r){this.traceBegin(e,r);var t=e.get("value");return this.traceEnd(e,r,t),t},writable:!0,configurable:!0},execExprLiteralNumber:{value:function(e,r){this.traceBegin(e,r);var t=e.get("value");return this.traceEnd(e,r,t),t},writable:!0,configurable:!0},execExprLiteralValue:{value:function(e,r){this.traceBegin(e,r);var t=e.get("value");return this.traceEnd(e,r,t),t},writable:!0,configurable:!0},execExprPath:{value:function(e,r){this.traceBegin(e,r);var t=this.execPath(e,r);return this.traceEnd(e,r,t),t},writable:!0,configurable:!0}}),r}(ASTQQueryTrace);module.exports=ASTQQueryExec; | ||
"use strict";var _interopRequire=function(e){return e&&e.__esModule?e["default"]:e},_prototypeProperties=function(e,r,t){r&&Object.defineProperties(e,r),t&&Object.defineProperties(e.prototype,t)},_inherits=function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function, not "+typeof r);e.prototype=Object.create(r&&r.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),r&&(e.__proto__=r)},util=_interopRequire(_dereq_("./astq-util.js")),ASTQQueryTrace=_interopRequire(_dereq_("./astq-query-trace.js")),ASTQQueryExec=function(e){function r(e,r,t,i){this.adapter=e,this.params=r,this.funcs=t,this.trace=i}return _inherits(r,e),_prototypeProperties(r,null,{execQuery:{value:function(e,r){var t=this;this.traceBegin(e,r);var i=[];return e.childs().forEach(function(e){i=i.concat(t.execPath(e,r))}),this.traceEnd(e,r,i),i},writable:!0,configurable:!0},execPath:{value:function(e,r){var t=this;this.traceBegin(e,r);var i=[r];return e.childs().forEach(function(e){var r=[];i.forEach(function(i){r=r.concat(t.execStep(e,i))}),i=r}),this.traceEnd(e,r,i),i},writable:!0,configurable:!0},execStep:{value:function(e,r){var t=this;this.traceBegin(e,r);var i=e.childs(),a=null,c=null,n=null,u=0;if(u<i.length&&"Axis"===i[u].type()&&(a=i[u++]),u<i.length&&"Match"===i[u].type()&&(c=i[u++]),u<i.length&&"Filter"===i[u].type()&&(n=i[u++]),null===c)throw new Error("no matching part in query step");var l=[],s=c.get("id"),o=function(e){var r=t.adapter.getNodeType(e);if("*"===s||s===r){var i=!0;null!==n&&(t.execFilter(n,e)||(i=!1)),i&&l.push(e)}};if(null!==a){var h=a.get("op");if("/"===h)this.adapter.getChildNodes(r).forEach(function(e){return o(e)});else if("//"===h)!function(){var e=function(r){o(r),t.adapter.getChildNodes(r).forEach(function(r){return e(r)})};t.adapter.getChildNodes(r).forEach(function(r){return e(r)})}();else if("-/"===h){var p=this.adapter.getParentNode(r);if(null!==p){for(var x=this.adapter.getChildNodes(p),d=null,f=0;f<x.length&&x[f]!==r;f++)d=x[f];o(d)}}else if("-//"===h){var b=this.adapter.getParentNode(r);if(null!==b)for(var x=this.adapter.getChildNodes(b),g=0;g<x.length&&x[g]!==r;g++)o(x[g])}else if("+/"===h){var E=this.adapter.getParentNode(r);if(null!==E){var x=this.adapter.getChildNodes(E),v=void 0;for(v=0;v<x.length&&x[v]!==r;v++);v<x.length&&(v++,o(x[v]))}}else if("+//"===h){var m=this.adapter.getParentNode(r);if(null!==m){var x=this.adapter.getChildNodes(m),y=void 0;for(y=0;y<x.length&&x[y]!==r;y++);if(y<x.length)for(y++;y<x.length;)o(x[y++])}}else if("../"===h){var w=this.adapter.getParentNode(r);null!==w&&o(w)}else if("..//"===h)for(var B=r;;){{this.adapter.getParentNode(B)}if(null===parent)break;o(parent),B=parent}}else o(r);return this.traceEnd(e,r,l),l},writable:!0,configurable:!0},execFilter:{value:function(e,r){this.traceBegin(e,r);var t=e.childs()[0],i=this.execExpr(t,r);return i=util.truthy(i),this.traceEnd(e,r,i),i},writable:!0,configurable:!0},execExpr:{value:function(e,r){switch(e.type()){case"ConditionalBinary":return this.execExprConditionalBinary(e,r);case"ConditionalTernary":return this.execExprConditionalTernary(e,r);case"Logical":return this.execExprLogical(e,r);case"Bitwise":return this.execExprBitwise(e,r);case"Relational":return this.execExprRelational(e,r);case"Arithmetical":return this.execExprArithmetical(e,r);case"Unary":return this.execExprUnary(e,r);case"FuncCall":return this.execExprFuncCall(e,r);case"Attribute":return this.execExprAttribute(e,r);case"Param":return this.execExprParam(e,r);case"LiteralString":return this.execExprLiteralString(e,r);case"LiteralRegExp":return this.execExprLiteralRegExp(e,r);case"LiteralNumber":return this.execExprLiteralNumber(e,r);case"LiteralValue":return this.execExprLiteralValue(e,r);case"Path":return this.execExprPath(e,r)}},writable:!0,configurable:!0},execExprConditionalBinary:{value:function(e,r){this.traceBegin(e,r);var t=this.execExpr(e.childs()[0],r);return util.truthy(t)||(t=this.execExpr(e.childs()[1],r)),this.traceEnd(e,r,t),t},writable:!0,configurable:!0},execExprConditionalTernary:{value:function(e,r){this.traceBegin(e,r);var t=this.execExpr(e.childs()[0],r);return t=util.truthy(t)?this.execExpr(e.childs()[1],r):this.execExpr(e.childs()[2],r),this.traceEnd(e,r,t),t},writable:!0,configurable:!0},execExprLogical:{value:function(e,r){this.traceBegin(e,r);var t=!1;switch(e.get("op")){case"&&":t=util.truthy(this.execExpr(e.childs()[0],r)),t&&(t=t&&util.truthy(this.execExpr(e.childs()[1],r)));break;case"||":t=util.truthy(this.execExpr(e.childs()[0],r)),t||(t=t||util.truthy(this.execExpr(e.childs()[1],r)))}return this.traceEnd(e,r,t),t},writable:!0,configurable:!0},execExprBitwise:{value:function(e,r){this.traceBegin(e,r);var t=util.coerce(this.execExpr(e.childs()[0],r),"number"),i=util.coerce(this.execExpr(e.childs()[1],r),"number"),a=void 0;switch(e.get("op")){case"&":a=t&i;break;case"|":a=t|i;break;case"<<":a=t<<i;break;case">>":a=t>>i}return this.traceEnd(e,r,a),a},writable:!0,configurable:!0},execExprRelational:{value:function(e,r){this.traceBegin(e,r);var t=this.execExpr(e.childs()[0],r),i=this.execExpr(e.childs()[1],r),a=void 0;switch(e.get("op")){case"==":a=t===i;break;case"!=":a=t!==i;break;case"<=":a=util.coerce(t,"number")<=util.coerce(i,"number");break;case">=":a=util.coerce(t,"number")>=util.coerce(i,"number");break;case"<":a=util.coerce(t,"number")<util.coerce(i,"number");break;case">":a=util.coerce(t,"number")>util.coerce(i,"number");break;case"=~":a=null!==util.coerce(t,"string").match(util.coerce(i,"regexp"));break;case"!~":a=null===util.coerce(t,"string").match(util.coerce(i,"regexp"))}return this.traceEnd(e,r,a),a},writable:!0,configurable:!0},execExprArithmetical:{value:function(e,r){this.traceBegin(e,r);var t=this.execExpr(e.childs()[0],r),i=this.execExpr(e.childs()[1],r),a=void 0;switch(e.get("op")){case"+":a="string"==typeof t?t+util.coerce(i,"string"):util.coerce(t,"number")+util.coerce(i,"number");break;case"-":a=util.coerce(t,"number")+util.coerce(i,"number");break;case"*":a=util.coerce(t,"number")*util.coerce(i,"number");break;case"/":a=util.coerce(t,"number")/util.coerce(i,"number");break;case"%":a=util.coerce(t,"number")%util.coerce(i,"number");break;case"**":a=Math.pow(util.coerce(t,"number"),util.coerce(i,"number"))}return this.traceEnd(e,r,a),a},writable:!0,configurable:!0},execExprUnary:{value:function(e,r){this.traceBegin(e,r);var t=this.execExpr(e.childs()[0],r),i=void 0;switch(e.get("op")){case"!":i=!util.coerce(t,"boolean");break;case"~":i=~util.coerce(t,"number")}return this.traceEnd(e,r,i),i},writable:!0,configurable:!0},execExprFuncCall:{value:function(e,r){var t=this;this.traceBegin(e,r);var i=e.get("id"),a=[this.adapter,r];e.childs().forEach(function(e){a.push(t.execExpr(e,r))});var c=this.funcs.run(i,a);return this.traceEnd(e,r,c),c},writable:!0,configurable:!0},execExprAttribute:{value:function(e,r){this.traceBegin(e,r);var t=e.get("id"),i=this.adapter.getNodeAttrValue(r,t);return this.traceEnd(e,r,i),i},writable:!0,configurable:!0},execExprParam:{value:function(e,r){this.traceBegin(e,r);var t=e.get("id");if("undefined"==typeof this.params[t])throw new Error('invalid parameter "'+t+'"');var i=this.params[t];return this.traceEnd(e,r,i),i},writable:!0,configurable:!0},execExprLiteralString:{value:function(e,r){this.traceBegin(e,r);var t=e.get("value");return this.traceEnd(e,r,t),t},writable:!0,configurable:!0},execExprLiteralRegExp:{value:function(e,r){this.traceBegin(e,r);var t=e.get("value");return this.traceEnd(e,r,t),t},writable:!0,configurable:!0},execExprLiteralNumber:{value:function(e,r){this.traceBegin(e,r);var t=e.get("value");return this.traceEnd(e,r,t),t},writable:!0,configurable:!0},execExprLiteralValue:{value:function(e,r){this.traceBegin(e,r);var t=e.get("value");return this.traceEnd(e,r,t),t},writable:!0,configurable:!0},execExprPath:{value:function(e,r){this.traceBegin(e,r);var t=this.execPath(e,r);return this.traceEnd(e,r,t),t},writable:!0,configurable:!0}}),r}(ASTQQueryTrace);module.exports=ASTQQueryExec; | ||
},{"./astq-query-trace.js":11,"./astq-util.js":13}],11:[function(_dereq_,module,exports){ | ||
"use strict";var _prototypeProperties=function(e,t,r){t&&Object.defineProperties(e,t),r&&Object.defineProperties(e.prototype,r)},util=_dereq_("./astq-util.js"),ASTQQueryTrace=function(){function e(){}return _prototypeProperties(e,null,{prefixOf:{value:function(e,t){for(var r=0,i=e;null!==(i=i.parent());)r++;var o=util.pad("",4*r);for(r=0,i=t;null!==(i=this.adapter.getParentNode(i));)r++;var a=util.pad("",4*r);return{prefix1:o,prefix2:a}},writable:!0,configurable:!0},traceBegin:{value:function(e,t){if(this.trace){var r=this.prefixOf(e,t),i=r.prefix1,o=r.prefix2;console.log("ASTQ: execute: | "+util.pad(i+e.type()+" (",-60)+" | "+o+this.adapter.getNodeType(t))}},writable:!0,configurable:!0},traceEnd:{value:function(e,t,r){var i=this;if(this.trace){var o=this.prefixOf(e,t),a=o.prefix1,n=o.prefix2,p=void 0;void 0===r?p="undefined":"object"==typeof r&&r instanceof Array?(p="[",r.forEach(function(e){p+="node("+i.adapter.getNodeType(e)+"),"}),p=p.replace(/,$/,"")+"]"):p=typeof r+"("+r+")",p.length>60&&(p=p.substr(0,60)+"..."),console.log("ASTQ: execute: | "+util.pad(a+"): "+p,-60)+" | "+n+this.adapter.getNodeType(t))}},writable:!0,configurable:!0}}),e}();module.exports=ASTQQueryTrace; | ||
"use strict";var _interopRequire=function(e){return e&&e.__esModule?e["default"]:e},_prototypeProperties=function(e,t,r){t&&Object.defineProperties(e,t),r&&Object.defineProperties(e.prototype,r)},util=_interopRequire(_dereq_("./astq-util.js")),ASTQQueryTrace=function(){function e(){}return _prototypeProperties(e,null,{prefixOf:{value:function(e,t){for(var r=0,i=e;null!==(i=i.parent());)r++;var o=util.pad("",4*r);for(r=0,i=t;null!==(i=this.adapter.getParentNode(i));)r++;var a=util.pad("",4*r);return{prefix1:o,prefix2:a}},writable:!0,configurable:!0},traceBegin:{value:function(e,t){if(this.trace){var r=this.prefixOf(e,t),i=r.prefix1,o=r.prefix2;console.log("ASTQ: execute: | "+util.pad(i+e.type()+" (",-60)+" | "+o+this.adapter.getNodeType(t))}},writable:!0,configurable:!0},traceEnd:{value:function(e,t,r){var i=this;if(this.trace){var o=this.prefixOf(e,t),a=o.prefix1,n=o.prefix2,u=void 0;void 0===r?u="undefined":"object"==typeof r&&r instanceof Array?(u="[",r.forEach(function(e){u+="node("+i.adapter.getNodeType(e)+"),"}),u=u.replace(/,$/,"")+"]"):u=typeof r+"("+r+")",u.length>60&&(u=u.substr(0,60)+"..."),console.log("ASTQ: execute: | "+util.pad(a+"): "+u,-60)+" | "+n+this.adapter.getNodeType(t))}},writable:!0,configurable:!0}}),e}();module.exports=ASTQQueryTrace; | ||
},{"./astq-util.js":13}],12:[function(_dereq_,module,exports){ | ||
"use strict";var _prototypeProperties=function(t,e,r){e&&Object.defineProperties(t,e),r&&Object.defineProperties(t.prototype,r)},ASTY=_dereq_("asty"),PEGUtil=_dereq_("pegjs-util"),ASTQQueryParse=function(){function t(t,e){function r(){this.constructor=t}r.prototype=e.prototype,t.prototype=new r}function e(t,e,r,n,s,u){this.message=t,this.expected=e,this.found=r,this.offset=n,this.line=s,this.column=u,this.name="SyntaxError"}function r(t){function r(){return ru}function n(){return i(ru).line}function s(){return i(ru).column}function u(t){throw a(t,null,ru)}function i(e){function r(e,r,n){var s,u;for(s=r;n>s;s++)u=t.charAt(s),"\n"===u?(e.seenCR||e.line++,e.column=1,e.seenCR=!1):"\r"===u||"\u2028"===u||"\u2029"===u?(e.line++,e.column=1,e.seenCR=!0):(e.column++,e.seenCR=!1)}return nu!==e&&(nu>e&&(nu=0,su={line:1,column:1,seenCR:!1}),r(su,nu,e),nu=e),su}function l(t){uu>eu||(eu>uu&&(uu=eu,iu=[]),iu.push(t))}function a(r,n,s){function u(t){var e=1;for(t.sort(function(t,e){return t.description<e.description?-1:t.description>e.description?1:0});e<t.length;)t[e-1]===t[e]?t.splice(e,1):e++}function l(t,e){function r(t){function e(t){return t.charCodeAt(0).toString(16).toUpperCase()}return t.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\x08/g,"\\b").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\f/g,"\\f").replace(/\r/g,"\\r").replace(/[\x00-\x07\x0B\x0E\x0F]/g,function(t){return"\\x0"+e(t)}).replace(/[\x10-\x1F\x80-\xFF]/g,function(t){return"\\x"+e(t)}).replace(/[\u0180-\u0FFF]/g,function(t){return"\\u0"+e(t)}).replace(/[\u1080-\uFFFF]/g,function(t){return"\\u"+e(t)})}var n,s,u,i=new Array(t.length);for(u=0;u<t.length;u++)i[u]=t[u].description;return n=t.length>1?i.slice(0,-1).join(", ")+" or "+i[t.length-1]:i[0],s=e?'"'+r(e)+'"':"end of input","Expected "+n+" but "+s+" found."}var a=i(s),o=s<t.length?t.charAt(s):null;return null!==n&&u(n),new e(null!==r?r:l(n,o),n,o,s,a.line,a.column)}function o(){var t,e,r,n,s,u=36*eu+0,i=au[u];return i?(eu=i.nextPos,i.result):(t=eu,e=k(),e!==$?(r=c(),r!==$?(n=k(),n!==$?(s=M(),s!==$?(ru=t,e=K(r),t=e):(eu=t,t=J)):(eu=t,t=J)):(eu=t,t=J)):(eu=t,t=J),au[u]={nextPos:eu,result:t},t)}function c(){var e,r,n,s,u,i,a,o,c=36*eu+1,f=au[c];if(f)return eu=f.nextPos,f.result;if(e=eu,r=p(),r!==$){for(n=[],s=eu,u=k(),u!==$?(44===t.charCodeAt(eu)?(i=W,eu++):(i=$,0===lu&&l(X)),i!==$?(a=k(),a!==$?(o=p(),o!==$?(u=[u,i,a,o],s=u):(eu=s,s=J)):(eu=s,s=J)):(eu=s,s=J)):(eu=s,s=J);s!==$;)n.push(s),s=eu,u=k(),u!==$?(44===t.charCodeAt(eu)?(i=W,eu++):(i=$,0===lu&&l(X)),i!==$?(a=k(),a!==$?(o=p(),o!==$?(u=[u,i,a,o],s=u):(eu=s,s=J)):(eu=s,s=J)):(eu=s,s=J)):(eu=s,s=J);n!==$?(ru=e,r=te(r,n),e=r):(eu=e,e=J)}else eu=e,e=J;return au[c]={nextPos:eu,result:e},e}function p(){var t,e,r,n,s,u,i=36*eu+2,l=au[i];if(l)return eu=l.nextPos,l.result;if(t=eu,e=f(),e!==$){for(r=[],n=eu,s=k(),s!==$?(u=d(),u!==$?(s=[s,u],n=s):(eu=n,n=J)):(eu=n,n=J);n!==$;)r.push(n),n=eu,s=k(),s!==$?(u=d(),u!==$?(s=[s,u],n=s):(eu=n,n=J)):(eu=n,n=J);r!==$?(ru=t,e=ee(e,r),t=e):(eu=t,t=J)}else eu=t,t=J;return au[i]={nextPos:eu,result:t},t}function f(){var t,e,r,n,s,u,i=36*eu+3,l=au[i];return l?(eu=l.nextPos,l.result):(t=eu,e=h(),e===$&&(e=re),e!==$?(r=k(),r!==$?(n=v(),n!==$?(s=k(),s!==$?(u=A(),u===$&&(u=re),u!==$?(ru=t,e=ne(e,n,u),t=e):(eu=t,t=J)):(eu=t,t=J)):(eu=t,t=J)):(eu=t,t=J)):(eu=t,t=J),au[i]={nextPos:eu,result:t},t)}function d(){var t,e,r,n,s,u,i=36*eu+4,l=au[i];return l?(eu=l.nextPos,l.result):(t=eu,e=h(),e!==$?(r=k(),r!==$?(n=v(),n!==$?(s=k(),s!==$?(u=A(),u===$&&(u=re),u!==$?(ru=t,e=ne(e,n,u),t=e):(eu=t,t=J)):(eu=t,t=J)):(eu=t,t=J)):(eu=t,t=J)):(eu=t,t=J),au[i]={nextPos:eu,result:t},t)}function h(){var e,r,n,s=36*eu+5,u=au[s];return u?(eu=u.nextPos,u.result):(lu++,e=eu,r=eu,t.substr(eu,2)===ue?(n=ue,eu+=2):(n=$,0===lu&&l(ie)),n===$&&(47===t.charCodeAt(eu)?(n=le,eu++):(n=$,0===lu&&l(ae)),n===$&&(t.substr(eu,3)===oe?(n=oe,eu+=3):(n=$,0===lu&&l(ce)),n===$&&(t.substr(eu,2)===pe?(n=pe,eu+=2):(n=$,0===lu&&l(fe)),n===$&&(t.substr(eu,3)===de?(n=de,eu+=3):(n=$,0===lu&&l(he)),n===$&&(t.substr(eu,2)===ve?(n=ve,eu+=2):(n=$,0===lu&&l(Ae)),n===$&&(t.substr(eu,3)===ye?(n=ye,eu+=3):(n=$,0===lu&&l(xe)),n===$&&(t.substr(eu,2)===be?(n=be,eu+=2):(n=$,0===lu&&l(Pe))))))))),n!==$&&(n=t.substring(r,eu)),r=n,r!==$&&(ru=e,r=ge(r)),e=r,lu--,e===$&&(r=$,0===lu&&l(se)),au[s]={nextPos:eu,result:e},e)}function v(){var e,r,n=36*eu+6,s=au[n];return s?(eu=s.nextPos,s.result):(e=eu,r=j(),r!==$&&(ru=e,r=Ce(r)),e=r,e===$&&(e=eu,42===t.charCodeAt(eu)?(r=me,eu++):(r=$,0===lu&&l(Se)),r!==$&&(ru=e,r=Qe()),e=r),au[n]={nextPos:eu,result:e},e)}function A(){var e,r,n,s,u,i,a=36*eu+7,o=au[a];return o?(eu=o.nextPos,o.result):(e=eu,91===t.charCodeAt(eu)?(r=Ee,eu++):(r=$,0===lu&&l(we)),r!==$?(n=k(),n!==$?(s=y(),s!==$?(u=k(),u!==$?(93===t.charCodeAt(eu)?(i=Fe,eu++):(i=$,0===lu&&l(Re)),i!==$?(ru=e,r=Te(s),e=r):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J),au[a]={nextPos:eu,result:e},e)}function y(){var e,r,n,s,u,i,a,o,c,p,f=36*eu+8,d=au[f];return d?(eu=d.nextPos,d.result):(e=eu,r=x(),r!==$?(n=k(),n!==$?(t.substr(eu,2)===Le?(s=Le,eu+=2):(s=$,0===lu&&l(Ne)),s!==$?(u=k(),u!==$?(i=x(),i!==$?(ru=e,r=qe(r,i),e=r):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J),e===$&&(e=eu,r=x(),r!==$?(n=k(),n!==$?(63===t.charCodeAt(eu)?(s=_e,eu++):(s=$,0===lu&&l(je)),s!==$?(u=k(),u!==$?(i=x(),i!==$?(a=k(),a!==$?(58===t.charCodeAt(eu)?(o=ze,eu++):(o=$,0===lu&&l(Ie)),o!==$?(c=k(),c!==$?(p=x(),p!==$?(ru=e,r=Ue(r,i,p),e=r):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J),e===$&&(e=x())),au[f]={nextPos:eu,result:e},e)}function x(){var e,r,n,s,u,i,a=36*eu+9,o=au[a];return o?(eu=o.nextPos,o.result):(e=eu,r=b(),r!==$?(n=k(),n!==$?(s=eu,t.substr(eu,2)===Ze?(u=Ze,eu+=2):(u=$,0===lu&&l(Ve)),u!==$&&(u=t.substring(s,eu)),s=u,s!==$?(u=k(),u!==$?(i=x(),i!==$?(ru=e,r=ke(r,s,i),e=r):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J),e===$&&(e=b()),au[a]={nextPos:eu,result:e},e)}function b(){var e,r,n,s,u,i,a=36*eu+10,o=au[a];return o?(eu=o.nextPos,o.result):(e=eu,r=P(),r!==$?(n=k(),n!==$?(s=eu,t.substr(eu,2)===Be?(u=Be,eu+=2):(u=$,0===lu&&l(Ge)),u!==$&&(u=t.substring(s,eu)),s=u,s!==$?(u=k(),u!==$?(i=b(),i!==$?(ru=e,r=ke(r,s,i),e=r):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J),e===$&&(e=P()),au[a]={nextPos:eu,result:e},e)}function P(){var e,r,n,s,u,i,a=36*eu+11,o=au[a];return o?(eu=o.nextPos,o.result):(e=eu,r=g(),r!==$?(n=k(),n!==$?(s=eu,124===t.charCodeAt(eu)?(u=Me,eu++):(u=$,0===lu&&l(Oe)),u!==$&&(u=t.substring(s,eu)),s=u,s!==$?(u=k(),u!==$?(i=P(),i!==$?(ru=e,r=Ye(r,s,i),e=r):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J),e===$&&(e=g()),au[a]={nextPos:eu,result:e},e)}function g(){var e,r,n,s,u,i,a=36*eu+12,o=au[a];return o?(eu=o.nextPos,o.result):(e=eu,r=C(),r!==$?(n=k(),n!==$?(s=eu,94===t.charCodeAt(eu)?(u=$e,eu++):(u=$,0===lu&&l(De)),u!==$&&(u=t.substring(s,eu)),s=u,s!==$?(u=k(),u!==$?(i=g(),i!==$?(ru=e,r=Ye(r,s,i),e=r):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J),e===$&&(e=C()),au[a]={nextPos:eu,result:e},e)}function C(){var e,r,n,s,u,i,a=36*eu+13,o=au[a];return o?(eu=o.nextPos,o.result):(e=eu,r=m(),r!==$?(n=k(),n!==$?(s=eu,38===t.charCodeAt(eu)?(u=He,eu++):(u=$,0===lu&&l(Je)),u!==$&&(u=t.substring(s,eu)),s=u,s!==$?(u=k(),u!==$?(i=C(),i!==$?(ru=e,r=Ye(r,s,i),e=r):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J),e===$&&(e=m()),au[a]={nextPos:eu,result:e},e)}function m(){var e,r,n,s,u,i,a=36*eu+14,o=au[a];return o?(eu=o.nextPos,o.result):(e=eu,r=S(),r!==$?(n=k(),n!==$?(s=eu,t.substr(eu,2)===Ke?(u=Ke,eu+=2):(u=$,0===lu&&l(We)),u===$&&(t.substr(eu,2)===Xe?(u=Xe,eu+=2):(u=$,0===lu&&l(tr)),u===$&&(t.substr(eu,2)===er?(u=er,eu+=2):(u=$,0===lu&&l(rr)),u===$&&(t.substr(eu,2)===nr?(u=nr,eu+=2):(u=$,0===lu&&l(sr)),u===$&&(60===t.charCodeAt(eu)?(u=ur,eu++):(u=$,0===lu&&l(ir)),u===$&&(62===t.charCodeAt(eu)?(u=lr,eu++):(u=$,0===lu&&l(ar)),u===$&&(t.substr(eu,2)===or?(u=or,eu+=2):(u=$,0===lu&&l(cr)),u===$&&(t.substr(eu,2)===pr?(u=pr,eu+=2):(u=$,0===lu&&l(fr))))))))),u!==$&&(u=t.substring(s,eu)),s=u,s!==$?(u=k(),u!==$?(i=m(),i!==$?(ru=e,r=dr(r,s,i),e=r):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J),e===$&&(e=S()),au[a]={nextPos:eu,result:e},e)}function S(){var e,r,n,s,u,i,a=36*eu+15,o=au[a];return o?(eu=o.nextPos,o.result):(e=eu,r=Q(),r!==$?(n=k(),n!==$?(s=eu,t.substr(eu,2)===hr?(u=hr,eu+=2):(u=$,0===lu&&l(vr)),u===$&&(t.substr(eu,2)===Ar?(u=Ar,eu+=2):(u=$,0===lu&&l(yr))),u!==$&&(u=t.substring(s,eu)),s=u,s!==$?(u=k(),u!==$?(i=S(),i!==$?(ru=e,r=Ye(r,s,i),e=r):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J),e===$&&(e=Q()),au[a]={nextPos:eu,result:e},e)}function Q(){var e,r,n,s,u,i,a=36*eu+16,o=au[a];return o?(eu=o.nextPos,o.result):(e=eu,r=E(),r!==$?(n=k(),n!==$?(s=eu,43===t.charCodeAt(eu)?(u=xr,eu++):(u=$,0===lu&&l(br)),u===$&&(45===t.charCodeAt(eu)?(u=Pr,eu++):(u=$,0===lu&&l(gr))),u!==$&&(u=t.substring(s,eu)),s=u,s!==$?(u=k(),u!==$?(i=Q(),i!==$?(ru=e,r=Cr(r,s,i),e=r):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J),e===$&&(e=E()),au[a]={nextPos:eu,result:e},e)}function E(){var e,r,n,s,u,i,a=36*eu+17,o=au[a];return o?(eu=o.nextPos,o.result):(e=eu,r=w(),r!==$?(n=k(),n!==$?(s=eu,t.substr(eu,2)===mr?(u=mr,eu+=2):(u=$,0===lu&&l(Sr)),u===$&&(42===t.charCodeAt(eu)?(u=me,eu++):(u=$,0===lu&&l(Se)),u===$&&(47===t.charCodeAt(eu)?(u=le,eu++):(u=$,0===lu&&l(ae)),u===$&&(37===t.charCodeAt(eu)?(u=Qr,eu++):(u=$,0===lu&&l(Er))))),u!==$&&(u=t.substring(s,eu)),s=u,s!==$?(u=k(),u!==$?(i=E(),i!==$?(ru=e,r=Cr(r,s,i),e=r):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J),e===$&&(e=w()),au[a]={nextPos:eu,result:e},e)}function w(){var e,r,n,s=36*eu+18,u=au[s];return u?(eu=u.nextPos,u.result):(e=eu,r=eu,33===t.charCodeAt(eu)?(n=wr,eu++):(n=$,0===lu&&l(Fr)),n===$&&(126===t.charCodeAt(eu)?(n=Rr,eu++):(n=$,0===lu&&l(Tr))),n!==$&&(n=t.substring(r,eu)),r=n,r!==$?(n=F(),n!==$?(ru=e,r=Lr(r,n),e=r):(eu=e,e=J)):(eu=e,e=J),e===$&&(e=F()),au[s]={nextPos:eu,result:e},e)}function F(){var t,e=36*eu+19,r=au[e];return r?(eu=r.nextPos,r.result):(t=R(),t===$&&(t=L(),t===$&&(t=N(),t===$&&(t=q(),t===$&&(t=_(),t===$&&(t=p()))))),au[e]={nextPos:eu,result:t},t)}function R(){var e,r,n,s,u,i,a,o,c=36*eu+20,p=au[c];return p?(eu=p.nextPos,p.result):(e=eu,r=j(),r!==$?(n=k(),n!==$?(40===t.charCodeAt(eu)?(s=Nr,eu++):(s=$,0===lu&&l(qr)),s!==$?(u=k(),u!==$?(i=T(),i===$&&(i=re),i!==$?(a=k(),a!==$?(41===t.charCodeAt(eu)?(o=_r,eu++):(o=$,0===lu&&l(jr)),o!==$?(ru=e,r=zr(r,i),e=r):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J),au[c]={nextPos:eu,result:e},e)}function T(){var e,r,n,s,u,i,a,o,c=36*eu+21,p=au[c];if(p)return eu=p.nextPos,p.result;if(e=eu,r=y(),r!==$){for(n=[],s=eu,u=k(),u!==$?(44===t.charCodeAt(eu)?(i=W,eu++):(i=$,0===lu&&l(X)),i!==$?(a=k(),a!==$?(o=y(),o!==$?(u=[u,i,a,o],s=u):(eu=s,s=J)):(eu=s,s=J)):(eu=s,s=J)):(eu=s,s=J);s!==$;)n.push(s),s=eu,u=k(),u!==$?(44===t.charCodeAt(eu)?(i=W,eu++):(i=$,0===lu&&l(X)),i!==$?(a=k(),a!==$?(o=y(),o!==$?(u=[u,i,a,o],s=u):(eu=s,s=J)):(eu=s,s=J)):(eu=s,s=J)):(eu=s,s=J);n!==$?(ru=e,r=Ir(r,n),e=r):(eu=e,e=J)}else eu=e,e=J;return au[c]={nextPos:eu,result:e},e}function L(){var e,r,n,s=36*eu+22,u=au[s];return u?(eu=u.nextPos,u.result):(lu++,e=eu,64===t.charCodeAt(eu)?(r=Zr,eu++):(r=$,0===lu&&l(Vr)),r!==$?(n=j(),n!==$?(ru=e,r=kr(n),e=r):(eu=e,e=J)):(eu=e,e=J),lu--,e===$&&(r=$,0===lu&&l(Ur)),au[s]={nextPos:eu,result:e},e)}function N(){var e,r,n,s,u,i,a=36*eu+23,o=au[a];return o?(eu=o.nextPos,o.result):(lu++,e=eu,123===t.charCodeAt(eu)?(r=Gr,eu++):(r=$,0===lu&&l(Mr)),r!==$?(n=k(),n!==$?(s=j(),s!==$?(u=k(),u!==$?(125===t.charCodeAt(eu)?(i=Or,eu++):(i=$,0===lu&&l(Yr)),i!==$?(ru=e,r=$r(s),e=r):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J),lu--,e===$&&(r=$,0===lu&&l(Br)),au[a]={nextPos:eu,result:e},e)}function q(){var t,e=36*eu+24,r=au[e];return r?(eu=r.nextPos,r.result):(t=z(),t===$&&(t=U(),t===$&&(t=Z(),t===$&&(t=V()))),au[e]={nextPos:eu,result:t},t)}function _(){var e,r,n,s,u,i,a=36*eu+25,o=au[a];return o?(eu=o.nextPos,o.result):(e=eu,40===t.charCodeAt(eu)?(r=Nr,eu++):(r=$,0===lu&&l(qr)),r!==$?(n=k(),n!==$?(s=y(),s!==$?(u=k(),u!==$?(41===t.charCodeAt(eu)?(i=_r,eu++):(i=$,0===lu&&l(jr)),i!==$?(ru=e,r=Dr(s),e=r):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J),au[a]={nextPos:eu,result:e},e)}function j(){var e,r,n,s,u,i,a,o=36*eu+26,c=au[o];if(c)return eu=c.nextPos,c.result;if(lu++,e=eu,r=eu,n=eu,s=eu,lu++,u=V(),lu--,u===$?s=Jr:(eu=s,s=J),s!==$)if(Kr.test(t.charAt(eu))?(u=t.charAt(eu),eu++):(u=$,0===lu&&l(Wr)),u!==$){for(i=[],Xr.test(t.charAt(eu))?(a=t.charAt(eu),eu++):(a=$,0===lu&&l(tn));a!==$;)i.push(a),Xr.test(t.charAt(eu))?(a=t.charAt(eu),eu++):(a=$,0===lu&&l(tn));i!==$?(s=[s,u,i],n=s):(eu=n,n=J)}else eu=n,n=J;else eu=n,n=J;return n!==$&&(n=t.substring(r,eu)),r=n,r!==$&&(ru=e,r=en(r)),e=r,lu--,e===$&&(r=$,0===lu&&l(Hr)),au[o]={nextPos:eu,result:e},e}function z(){var e,r,n,s,u,i=36*eu+27,a=au[i];if(a)return eu=a.nextPos,a.result;if(lu++,e=eu,34===t.charCodeAt(eu)?(r=nn,eu++):(r=$,0===lu&&l(sn)),r!==$){for(n=[],s=I(),s===$&&(un.test(t.charAt(eu))?(s=t.charAt(eu),eu++):(s=$,0===lu&&l(ln)));s!==$;)n.push(s),s=I(),s===$&&(un.test(t.charAt(eu))?(s=t.charAt(eu),eu++):(s=$,0===lu&&l(ln)));n!==$?(34===t.charCodeAt(eu)?(s=nn,eu++):(s=$,0===lu&&l(sn)),s!==$?(ru=e,r=an(n),e=r):(eu=e,e=J)):(eu=e,e=J)}else eu=e,e=J;if(e===$)if(e=eu,39===t.charCodeAt(eu)?(r=on,eu++):(r=$,0===lu&&l(cn)),r!==$){for(n=eu,s=[],t.substr(eu,2)===pn?(u=pn,eu+=2):(u=$,0===lu&&l(fn)),u===$&&(dn.test(t.charAt(eu))?(u=t.charAt(eu),eu++):(u=$,0===lu&&l(hn)));u!==$;)s.push(u),t.substr(eu,2)===pn?(u=pn,eu+=2):(u=$,0===lu&&l(fn)),u===$&&(dn.test(t.charAt(eu))?(u=t.charAt(eu),eu++):(u=$,0===lu&&l(hn)));s!==$&&(s=t.substring(n,eu)),n=s,n!==$?(39===t.charCodeAt(eu)?(s=on,eu++):(s=$,0===lu&&l(cn)),s!==$?(ru=e,r=vn(n),e=r):(eu=e,e=J)):(eu=e,e=J)}else eu=e,e=J;return lu--,e===$&&(r=$,0===lu&&l(rn)),au[i]={nextPos:eu,result:e},e}function I(){var e,r,n,s,u,i,a,o,c=36*eu+28,p=au[c];return p?(eu=p.nextPos,p.result):(lu++,e=eu,t.substr(eu,2)===yn?(r=yn,eu+=2):(r=$,0===lu&&l(xn)),r!==$&&(ru=e,r=bn()),e=r,e===$&&(e=eu,t.substr(eu,2)===Pn?(r=Pn,eu+=2):(r=$,0===lu&&l(gn)),r!==$&&(ru=e,r=Cn()),e=r,e===$&&(e=eu,39===t.charCodeAt(eu)?(r=on,eu++):(r=$,0===lu&&l(cn)),r!==$&&(ru=e,r=mn()),e=r,e===$&&(e=eu,t.substr(eu,2)===Sn?(r=Sn,eu+=2):(r=$,0===lu&&l(Qn)),r!==$&&(ru=e,r=En()),e=r,e===$&&(e=eu,t.substr(eu,2)===wn?(r=wn,eu+=2):(r=$,0===lu&&l(Fn)),r!==$&&(ru=e,r=Rn()),e=r,e===$&&(e=eu,t.substr(eu,2)===Tn?(r=Tn,eu+=2):(r=$,0===lu&&l(Ln)),r!==$&&(ru=e,r=Nn()),e=r,e===$&&(e=eu,t.substr(eu,2)===qn?(r=qn,eu+=2):(r=$,0===lu&&l(_n)),r!==$&&(ru=e,r=jn()),e=r,e===$&&(e=eu,t.substr(eu,2)===zn?(r=zn,eu+=2):(r=$,0===lu&&l(In)),r!==$&&(ru=e,r=Un()),e=r,e===$&&(e=eu,t.substr(eu,2)===Zn?(r=Zn,eu+=2):(r=$,0===lu&&l(Vn)),r!==$&&(ru=e,r=kn()),e=r,e===$&&(e=eu,t.substr(eu,2)===Bn?(r=Bn,eu+=2):(r=$,0===lu&&l(Gn)),r!==$&&(ru=e,r=Mn()),e=r,e===$&&(e=eu,t.substr(eu,2)===On?(r=On,eu+=2):(r=$,0===lu&&l(Yn)),r!==$?(n=eu,s=eu,$n.test(t.charAt(eu))?(u=t.charAt(eu),eu++):(u=$,0===lu&&l(Dn)),u!==$?($n.test(t.charAt(eu))?(i=t.charAt(eu),eu++):(i=$,0===lu&&l(Dn)),i!==$?(u=[u,i],s=u):(eu=s,s=J)):(eu=s,s=J),s!==$&&(s=t.substring(n,eu)),n=s,n!==$?(ru=e,r=Hn(n),e=r):(eu=e,e=J)):(eu=e,e=J),e===$&&(e=eu,t.substr(eu,2)===Jn?(r=Jn,eu+=2):(r=$,0===lu&&l(Kn)),r!==$?(n=eu,s=eu,$n.test(t.charAt(eu))?(u=t.charAt(eu),eu++):(u=$,0===lu&&l(Dn)),u!==$?($n.test(t.charAt(eu))?(i=t.charAt(eu),eu++):(i=$,0===lu&&l(Dn)),i!==$?($n.test(t.charAt(eu))?(a=t.charAt(eu),eu++):(a=$,0===lu&&l(Dn)),a!==$?($n.test(t.charAt(eu))?(o=t.charAt(eu),eu++):(o=$,0===lu&&l(Dn)),o!==$?(u=[u,i,a,o],s=u):(eu=s,s=J)):(eu=s,s=J)):(eu=s,s=J)):(eu=s,s=J),s!==$&&(s=t.substring(n,eu)),n=s,n!==$?(ru=e,r=Hn(n),e=r):(eu=e,e=J)):(eu=e,e=J)))))))))))),lu--,e===$&&(r=$,0===lu&&l(An)),au[c]={nextPos:eu,result:e},e)}function U(){var e,r,n,s,u,i=36*eu+29,a=au[i];if(a)return eu=a.nextPos,a.result;if(lu++,e=eu,47===t.charCodeAt(eu)?(r=le,eu++):(r=$,0===lu&&l(ae)),r!==$){for(n=eu,s=[],t.substr(eu,2)===Xn?(u=Xn,eu+=2):(u=$,0===lu&&l(ts)),u===$&&(es.test(t.charAt(eu))?(u=t.charAt(eu),eu++):(u=$,0===lu&&l(rs)));u!==$;)s.push(u),t.substr(eu,2)===Xn?(u=Xn,eu+=2):(u=$,0===lu&&l(ts)),u===$&&(es.test(t.charAt(eu))?(u=t.charAt(eu),eu++):(u=$,0===lu&&l(rs)));s!==$&&(s=t.substring(n,eu)),n=s,n!==$?(47===t.charCodeAt(eu)?(s=le,eu++):(s=$,0===lu&&l(ae)),s!==$?(ru=e,r=ns(n),e=r):(eu=e,e=J)):(eu=e,e=J)}else eu=e,e=J;return lu--,e===$&&(r=$,0===lu&&l(Wn)),au[i]={nextPos:eu,result:e},e}function Z(){var e,r,n,s,u,i,a,o,c,p,f,d,h=36*eu+30,v=au[h];if(v)return eu=v.nextPos,v.result;if(lu++,e=eu,r=eu,us.test(t.charAt(eu))?(n=t.charAt(eu),eu++):(n=$,0===lu&&l(is)),n===$&&(n=re),n!==$&&(n=t.substring(r,eu)),r=n,r!==$)if(t.substr(eu,2)===ls?(n=ls,eu+=2):(n=$,0===lu&&l(as)),n!==$){if(s=eu,u=[],os.test(t.charAt(eu))?(i=t.charAt(eu),eu++):(i=$,0===lu&&l(cs)),i!==$)for(;i!==$;)u.push(i),os.test(t.charAt(eu))?(i=t.charAt(eu),eu++):(i=$,0===lu&&l(cs));else u=J;u!==$&&(u=t.substring(s,eu)),s=u,s!==$?(ru=e,r=ps(r,s),e=r):(eu=e,e=J)}else eu=e,e=J;else eu=e,e=J;if(e===$){if(e=eu,r=eu,us.test(t.charAt(eu))?(n=t.charAt(eu),eu++):(n=$,0===lu&&l(is)),n===$&&(n=re),n!==$&&(n=t.substring(r,eu)),r=n,r!==$)if(t.substr(eu,2)===fs?(n=fs,eu+=2):(n=$,0===lu&&l(ds)),n!==$){if(s=eu,u=[],hs.test(t.charAt(eu))?(i=t.charAt(eu),eu++):(i=$,0===lu&&l(vs)),i!==$)for(;i!==$;)u.push(i),hs.test(t.charAt(eu))?(i=t.charAt(eu),eu++):(i=$,0===lu&&l(vs));else u=J;u!==$&&(u=t.substring(s,eu)),s=u,s!==$?(ru=e,r=As(r,s),e=r):(eu=e,e=J)}else eu=e,e=J;else eu=e,e=J;if(e===$){if(e=eu,r=eu,us.test(t.charAt(eu))?(n=t.charAt(eu),eu++):(n=$,0===lu&&l(is)),n===$&&(n=re),n!==$&&(n=t.substring(r,eu)),r=n,r!==$)if(t.substr(eu,2)===ys?(n=ys,eu+=2):(n=$,0===lu&&l(xs)),n!==$){if(s=eu,u=[],$n.test(t.charAt(eu))?(i=t.charAt(eu),eu++):(i=$,0===lu&&l(Dn)),i!==$)for(;i!==$;)u.push(i),$n.test(t.charAt(eu))?(i=t.charAt(eu),eu++):(i=$,0===lu&&l(Dn));else u=J;u!==$&&(u=t.substring(s,eu)),s=u,s!==$?(ru=e,r=bs(r,s),e=r):(eu=e,e=J)}else eu=e,e=J;else eu=e,e=J;if(e===$){if(e=eu,r=eu,n=eu,us.test(t.charAt(eu))?(s=t.charAt(eu),eu++):(s=$,0===lu&&l(is)),s===$&&(s=re),s!==$){for(u=[],Ps.test(t.charAt(eu))?(i=t.charAt(eu),eu++):(i=$,0===lu&&l(gs));i!==$;)u.push(i),Ps.test(t.charAt(eu))?(i=t.charAt(eu),eu++):(i=$,0===lu&&l(gs));if(u!==$)if(46===t.charCodeAt(eu)?(i=Cs,eu++):(i=$,0===lu&&l(ms)),i!==$){if(a=[],Ps.test(t.charAt(eu))?(o=t.charAt(eu),eu++):(o=$,0===lu&&l(gs)),o!==$)for(;o!==$;)a.push(o),Ps.test(t.charAt(eu))?(o=t.charAt(eu),eu++):(o=$,0===lu&&l(gs));else a=J;if(a!==$){if(o=eu,Ss.test(t.charAt(eu))?(c=t.charAt(eu),eu++):(c=$,0===lu&&l(Qs)),c!==$)if(us.test(t.charAt(eu))?(p=t.charAt(eu),eu++):(p=$,0===lu&&l(is)),p===$&&(p=re),p!==$){if(f=[],Ps.test(t.charAt(eu))?(d=t.charAt(eu),eu++):(d=$,0===lu&&l(gs)),d!==$)for(;d!==$;)f.push(d),Ps.test(t.charAt(eu))?(d=t.charAt(eu),eu++):(d=$,0===lu&&l(gs));else f=J;f!==$?(c=[c,p,f],o=c):(eu=o,o=J)}else eu=o,o=J;else eu=o,o=J;o===$&&(o=re),o!==$?(s=[s,u,i,a,o],n=s):(eu=n,n=J)}else eu=n,n=J}else eu=n,n=J;else eu=n,n=J}else eu=n,n=J;if(n!==$&&(n=t.substring(r,eu)),r=n,r!==$&&(ru=e,r=Es(r)),e=r,e===$){if(e=eu,r=eu,n=eu,us.test(t.charAt(eu))?(s=t.charAt(eu),eu++):(s=$,0===lu&&l(is)),s===$&&(s=re),s!==$){if(u=[],Ps.test(t.charAt(eu))?(i=t.charAt(eu),eu++):(i=$,0===lu&&l(gs)),i!==$)for(;i!==$;)u.push(i),Ps.test(t.charAt(eu))?(i=t.charAt(eu),eu++):(i=$,0===lu&&l(gs));else u=J;u!==$?(s=[s,u],n=s):(eu=n,n=J)}else eu=n,n=J;n!==$&&(n=t.substring(r,eu)),r=n,r!==$&&(ru=e,r=ws(r)),e=r}}}}return lu--,e===$&&(r=$,0===lu&&l(ss)),au[h]={nextPos:eu,result:e},e}function V(){var e,r,n=36*eu+31,s=au[n];return s?(eu=s.nextPos,s.result):(lu++,e=eu,t.substr(eu,4)===Rs?(r=Rs,eu+=4):(r=$,0===lu&&l(Ts)),r!==$&&(ru=e,r=Ls()),e=r,e===$&&(e=eu,t.substr(eu,5)===Ns?(r=Ns,eu+=5):(r=$,0===lu&&l(qs)),r!==$&&(ru=e,r=_s()),e=r,e===$&&(e=eu,t.substr(eu,4)===js?(r=js,eu+=4):(r=$,0===lu&&l(zs)),r!==$&&(ru=e,r=Is()),e=r,e===$&&(e=eu,t.substr(eu,3)===Us?(r=Us,eu+=3):(r=$,0===lu&&l(Zs)),r!==$&&(ru=e,r=Vs()),e=r,e===$&&(e=eu,t.substr(eu,9)===ks?(r=ks,eu+=9):(r=$,0===lu&&l(Bs)),r!==$&&(ru=e,r=Gs()),e=r)))),lu--,e===$&&(r=$,0===lu&&l(Fs)),au[n]={nextPos:eu,result:e},e)}function k(){var t,e,r=36*eu+32,n=au[r];if(n)return eu=n.nextPos,n.result;for(lu++,t=[],e=B(),e===$&&(e=G());e!==$;)t.push(e),e=B(),e===$&&(e=G());return lu--,t===$&&(e=$,0===lu&&l(Ms)),au[r]={nextPos:eu,result:t},t}function B(){var e,r,n,s,u,i,a=36*eu+33,o=au[a];if(o)return eu=o.nextPos,o.result;if(lu++,e=eu,t.substr(eu,2)===Ys?(r=Ys,eu+=2):(r=$,0===lu&&l($s)),r!==$){for(n=[],s=eu,u=eu,lu++,t.substr(eu,2)===Ds?(i=Ds,eu+=2):(i=$,0===lu&&l(Hs)),lu--,i===$?u=Jr:(eu=u,u=J),u!==$?(t.length>eu?(i=t.charAt(eu),eu++):(i=$,0===lu&&l(Js)),i!==$?(u=[u,i],s=u):(eu=s,s=J)):(eu=s,s=J);s!==$;)n.push(s),s=eu,u=eu,lu++,t.substr(eu,2)===Ds?(i=Ds,eu+=2):(i=$,0===lu&&l(Hs)),lu--,i===$?u=Jr:(eu=u,u=J),u!==$?(t.length>eu?(i=t.charAt(eu),eu++):(i=$,0===lu&&l(Js)),i!==$?(u=[u,i],s=u):(eu=s,s=J)):(eu=s,s=J);n!==$?(t.substr(eu,2)===Ds?(s=Ds,eu+=2):(s=$,0===lu&&l(Hs)),s!==$?(r=[r,n,s],e=r):(eu=e,e=J)):(eu=e,e=J)}else eu=e,e=J;return lu--,e===$&&(r=$,0===lu&&l(Os)),au[a]={nextPos:eu,result:e},e}function G(){var e,r,n=36*eu+34,s=au[n];if(s)return eu=s.nextPos,s.result;if(lu++,e=[],Ws.test(t.charAt(eu))?(r=t.charAt(eu),eu++):(r=$,0===lu&&l(Xs)),r!==$)for(;r!==$;)e.push(r),Ws.test(t.charAt(eu))?(r=t.charAt(eu),eu++):(r=$,0===lu&&l(Xs));else e=J;return lu--,e===$&&(r=$,0===lu&&l(Ks)),au[n]={nextPos:eu,result:e},e}function M(){var e,r,n=36*eu+35,s=au[n];return s?(eu=s.nextPos,s.result):(lu++,e=eu,lu++,t.length>eu?(r=t.charAt(eu),eu++):(r=$,0===lu&&l(Js)),lu--,r===$?e=Jr:(eu=e,e=J),lu--,e===$&&(r=$,0===lu&&l(tu)),au[n]={nextPos:eu,result:e},e)}var O,Y=arguments.length>1?arguments[1]:{},$={},D={query:o},H=o,J=$,K=function(t){return t},W=",",X={type:"literal",value:",",description:'","'},te=function(t,e){return cu("Query").add(ou(t,e,3))},ee=function(t,e){return cu("Path").add(ou(t,e,1))},re=null,ne=function(t,e,r){return cu("Step").add(t,e,r)},se={type:"other",description:"axis"},ue="//",ie={type:"literal",value:"//",description:'"//"'},le="/",ae={type:"literal",value:"/",description:'"/"'},oe="~~>",ce={type:"literal",value:"~~>",description:'"~~>"'},pe="~>",fe={type:"literal",value:"~>",description:'"~>"'},de="<~~",he={type:"literal",value:"<~~",description:'"<~~"'},ve="<~",Ae={type:"literal",value:"<~",description:'"<~"'},ye="~~^",xe={type:"literal",value:"~~^",description:'"~~^"'},be="~^",Pe={type:"literal",value:"~^",description:'"~^"'},ge=function(t){return cu("Axis").set({op:t})},Ce=function(t){return cu("Match").merge(t)},me="*",Se={type:"literal",value:"*",description:'"*"'},Qe=function(){return cu("Match").set({id:"*"})},Ee="[",we={type:"literal",value:"[",description:'"["'},Fe="]",Re={type:"literal",value:"]",description:'"]"'},Te=function(t){return cu("Filter").add(t)},Le="?:",Ne={type:"literal",value:"?:",description:'"?:"'},qe=function(t,e){return cu("ConditionalBinary").add(t,e)},_e="?",je={type:"literal",value:"?",description:'"?"'},ze=":",Ie={type:"literal",value:":",description:'":"'},Ue=function(t,e,r){return cu("ConditionalTernary").add(t,e,r)},Ze="||",Ve={type:"literal",value:"||",description:'"||"'},ke=function(t,e,r){return cu("Logical").set({op:e}).add(t,r)},Be="&&",Ge={type:"literal",value:"&&",description:'"&&"'},Me="|",Oe={type:"literal",value:"|",description:'"|"'},Ye=function(t,e,r){return cu("Bitwise").set({op:e}).add(t,r)},$e="^",De={type:"literal",value:"^",description:'"^"'},He="&",Je={type:"literal",value:"&",description:'"&"'},Ke="==",We={type:"literal",value:"==",description:'"=="'},Xe="!=",tr={type:"literal",value:"!=",description:'"!="'},er="<=",rr={type:"literal",value:"<=",description:'"<="'},nr=">=",sr={type:"literal",value:">=",description:'">="'},ur="<",ir={type:"literal",value:"<",description:'"<"'},lr=">",ar={type:"literal",value:">",description:'">"'},or="=~",cr={type:"literal",value:"=~",description:'"=~"'},pr="!~",fr={type:"literal",value:"!~",description:'"!~"'},dr=function(t,e,r){return cu("Relational").set({op:e}).add(t,r)},hr="<<",vr={type:"literal",value:"<<",description:'"<<"'},Ar=">>",yr={type:"literal",value:">>",description:'">>"'},xr="+",br={type:"literal",value:"+",description:'"+"'},Pr="-",gr={type:"literal",value:"-",description:'"-"'},Cr=function(t,e,r){return cu("Arithmetical").set({op:e}).add(t,r)},mr="**",Sr={type:"literal",value:"**",description:'"**"'},Qr="%",Er={type:"literal",value:"%",description:'"%"'},wr="!",Fr={type:"literal",value:"!",description:'"!"'},Rr="~",Tr={type:"literal",value:"~",description:'"~"'},Lr=function(t,e){return cu("Unary").set({op:t}).add(e)},Nr="(",qr={type:"literal",value:"(",description:'"("'},_r=")",jr={type:"literal",value:")",description:'")"'},zr=function(t,e){return cu("FuncCall").merge(t).add(e)},Ir=function(t,e){return ou(t,e,3)},Ur={type:"other",description:"node attribute"},Zr="@",Vr={type:"literal",value:"@",description:'"@"'},kr=function(t){return cu("Attribute").merge(t)},Br={type:"other",description:"query parameter reference"},Gr="{",Mr={type:"literal",value:"{",description:'"{"'},Or="}",Yr={type:"literal",value:"}",description:'"}"'},$r=function(t){return cu("Param").merge(t)},Dr=function(t){return t},Hr={type:"other",description:"identifier"},Jr=void 0,Kr=/^[a-zA-Z_]/,Wr={type:"class",value:"[a-zA-Z_]",description:"[a-zA-Z_]"},Xr=/^[a-zA-Z0-9_\-]/,tn={type:"class",value:"[a-zA-Z0-9_\\-]",description:"[a-zA-Z0-9_\\-]"},en=function(t){return cu("Identifier").set({id:t})},rn={type:"other",description:"quoted string literal"},nn='"',sn={type:"literal",value:'"',description:'"\\""'},un=/^[^"]/,ln={type:"class",value:'[^"]',description:'[^"]'},an=function(t){return cu("LiteralString").set({value:t.join("")})},on="'",cn={type:"literal",value:"'",description:'"\'"'},pn="\\'",fn={type:"literal",value:"\\'",description:'"\\\\\'"'},dn=/^[^']/,hn={type:"class",value:"[^']",description:"[^']"},vn=function(t){return cu("LiteralString").set({value:t.replace(/\\'/g,"'")})},An={type:"other",description:"escaped string character"},yn="\\\\",xn={type:"literal",value:"\\\\",description:'"\\\\\\\\"'},bn=function(){return"\\"},Pn='\\"',gn={type:"literal",value:'\\"',description:'"\\\\\\""'},Cn=function(){return'"'},mn=function(){return"'"},Sn="\\b",Qn={type:"literal",value:"\\b",description:'"\\\\b"'},En=function(){return"\b"},wn="\\v",Fn={type:"literal",value:"\\v",description:'"\\\\v"'},Rn=function(){return""},Tn="\\f",Ln={type:"literal",value:"\\f",description:'"\\\\f"'},Nn=function(){return"\f"},qn="\\t",_n={type:"literal",value:"\\t",description:'"\\\\t"'},jn=function(){return" "},zn="\\r",In={type:"literal",value:"\\r",description:'"\\\\r"'},Un=function(){return"\r"},Zn="\\n",Vn={type:"literal",value:"\\n",description:'"\\\\n"'},kn=function(){return"\n"},Bn="\\e",Gn={type:"literal",value:"\\e",description:'"\\\\e"'},Mn=function(){return""},On="\\x",Yn={type:"literal",value:"\\x",description:'"\\\\x"'},$n=/^[0-9a-fA-F]/,Dn={type:"class",value:"[0-9a-fA-F]",description:"[0-9a-fA-F]"},Hn=function(t){return String.fromCharCode(parseInt(t,16))},Jn="\\u",Kn={type:"literal",value:"\\u",description:'"\\\\u"'},Wn={type:"other",description:"regular expression literal"},Xn="\\/",ts={type:"literal",value:"\\/",description:'"\\\\/"'},es=/^[^\/]/,rs={type:"class",value:"[^\\/]",description:"[^\\/]"},ns=function(t){var e;try{e=new RegExp(t.replace(/\\\//g,"/"))}catch(r){u(r.message)}return cu("LiteralRegExp").set({value:e})},ss={type:"other",description:"numeric literal"},us=/^[+\-]/,is={type:"class",value:"[+\\-]",description:"[+\\-]"},ls="0b",as={type:"literal",value:"0b",description:'"0b"'},os=/^[01]/,cs={type:"class",value:"[01]",description:"[01]"},ps=function(t,e){return cu("LiteralNumber").set({value:parseInt(t+e,2)})},fs="0o",ds={type:"literal",value:"0o",description:'"0o"'},hs=/^[0-7]/,vs={type:"class",value:"[0-7]",description:"[0-7]"},As=function(t,e){return cu("LiteralNumber").set({value:parseInt(t+e,8)})},ys="0x",xs={type:"literal",value:"0x",description:'"0x"'},bs=function(t,e){return cu("LiteralNumber").set({value:parseInt(t+e,16)})},Ps=/^[0-9]/,gs={type:"class",value:"[0-9]",description:"[0-9]"},Cs=".",ms={type:"literal",value:".",description:'"."'},Ss=/^[eE]/,Qs={type:"class",value:"[eE]",description:"[eE]"},Es=function(t){return cu("LiteralNumber").set({value:parseFloat(t)})},ws=function(t){return cu("LiteralNumber").set({value:parseInt(t,10)})},Fs={type:"other",description:"global value"},Rs="true",Ts={type:"literal",value:"true",description:'"true"'},Ls=function(){return cu("LiteralValue").set({value:!0})},Ns="false",qs={type:"literal",value:"false",description:'"false"'},_s=function(){return cu("LiteralValue").set({value:!1})},js="null",zs={type:"literal",value:"null",description:'"null"'},Is=function(){return cu("LiteralValue").set({value:null})},Us="NaN",Zs={type:"literal",value:"NaN",description:'"NaN"'},Vs=function(){return cu("LiteralValue").set({value:0/0})},ks="undefined",Bs={type:"literal",value:"undefined",description:'"undefined"'},Gs=function(){return cu("LiteralValue").set({value:void 0})},Ms={type:"other",description:"optional blank"},Os={type:"other",description:"multi-line comment"},Ys="/*",$s={type:"literal",value:"/*",description:'"/*"'},Ds="*/",Hs={type:"literal",value:"*/",description:'"*/"'},Js={type:"any",description:"any character"},Ks={type:"other",description:"any whitespaces"},Ws=/^[ \t\r\n]/,Xs={type:"class",value:"[ \\t\\r\\n]",description:"[ \\t\\r\\n]"},tu={type:"other",description:"end of file"},eu=0,ru=0,nu=0,su={line:1,column:1,seenCR:!1},uu=0,iu=[],lu=0,au={};if("startRule"in Y){if(!(Y.startRule in D))throw new Error("Can't start parsing from rule \""+Y.startRule+'".');H=D[Y.startRule]}var ou=Y.util.makeUnroll(n,s,r,e),cu=Y.util.makeAST(n,s,r,Y);if(O=H(),O!==$&&eu===t.length)return O;throw O!==$&&eu<t.length&&l({type:"end",description:"end of input"}),a(null,iu,uu)}return t(e,Error),{SyntaxError:e,parse:r}}(),ASTQQueryExec=_dereq_("./astq-query-exec.js"),ASTQQuery=function(){function t(t){this.asty=new ASTY,this.ast=null,t&&this.compile(t)}return _prototypeProperties(t,null,{compile:{value:function(t,e){var r=this;e&&console.log("ASTQ: compile: +-------------------------------------------------------------------------------------------------------\nASTQ: compile: | "+t);var n=PEGUtil.parse(ASTQQueryParse,t,{startRule:"query",makeAST:function(t,e,n,s){return r.asty.create.apply(r.asty,s).pos(t,e,n)}});if(null!==n.error)throw new Error("ASTQ: compile: query parsing failed:\n"+PEGUtil.errorMessage(n.error,!0).replace(/^/gm,"ERROR: "));return this.ast=n.ast,e&&console.log("ASTQ: compile: +-------------------------------------------------------------------------------------------------------\n"+this.dump().replace(/\n$/,"").replace(/^/gm,"ASTQ: compile: | ")),this},writable:!0,configurable:!0},dump:{value:function(){return this.ast.dump()},writable:!0,configurable:!0},execute:{value:function(t,e,r,n,s){s&&console.log("ASTQ: execute: +--------------------------------------------------------------+----------------------------------------");var u=new ASTQQueryExec(e,r,n,s);return u.execQuery(this.ast,t)},writable:!0,configurable:!0}}),t}();module.exports=ASTQQuery; | ||
"use strict";var _interopRequire=function(t){return t&&t.__esModule?t["default"]:t},_prototypeProperties=function(t,e,r){e&&Object.defineProperties(t,e),r&&Object.defineProperties(t.prototype,r)},ASTY=_dereq_("asty"),PEGUtil=_dereq_("pegjs-util"),ASTQQueryParse=function(){function t(t,e){function r(){this.constructor=t}r.prototype=e.prototype,t.prototype=new r}function e(t,e,r,n,s,u){this.message=t,this.expected=e,this.found=r,this.offset=n,this.line=s,this.column=u,this.name="SyntaxError"}function r(t){function r(){return ru}function n(){return i(ru).line}function s(){return i(ru).column}function u(t){throw a(t,null,ru)}function i(e){function r(e,r,n){var s,u;for(s=r;n>s;s++)u=t.charAt(s),"\n"===u?(e.seenCR||e.line++,e.column=1,e.seenCR=!1):"\r"===u||"\u2028"===u||"\u2029"===u?(e.line++,e.column=1,e.seenCR=!0):(e.column++,e.seenCR=!1)}return nu!==e&&(nu>e&&(nu=0,su={line:1,column:1,seenCR:!1}),r(su,nu,e),nu=e),su}function l(t){uu>eu||(eu>uu&&(uu=eu,iu=[]),iu.push(t))}function a(r,n,s){function u(t){var e=1;for(t.sort(function(t,e){return t.description<e.description?-1:t.description>e.description?1:0});e<t.length;)t[e-1]===t[e]?t.splice(e,1):e++}function l(t,e){function r(t){function e(t){return t.charCodeAt(0).toString(16).toUpperCase()}return t.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\x08/g,"\\b").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\f/g,"\\f").replace(/\r/g,"\\r").replace(/[\x00-\x07\x0B\x0E\x0F]/g,function(t){return"\\x0"+e(t)}).replace(/[\x10-\x1F\x80-\xFF]/g,function(t){return"\\x"+e(t)}).replace(/[\u0180-\u0FFF]/g,function(t){return"\\u0"+e(t)}).replace(/[\u1080-\uFFFF]/g,function(t){return"\\u"+e(t)})}var n,s,u,i=new Array(t.length);for(u=0;u<t.length;u++)i[u]=t[u].description;return n=t.length>1?i.slice(0,-1).join(", ")+" or "+i[t.length-1]:i[0],s=e?'"'+r(e)+'"':"end of input","Expected "+n+" but "+s+" found."}var a=i(s),o=s<t.length?t.charAt(s):null;return null!==n&&u(n),new e(null!==r?r:l(n,o),n,o,s,a.line,a.column)}function o(){var t,e,r,n,s,u=36*eu+0,i=au[u];return i?(eu=i.nextPos,i.result):(t=eu,e=k(),e!==$?(r=c(),r!==$?(n=k(),n!==$?(s=G(),s!==$?(ru=t,e=K(r),t=e):(eu=t,t=J)):(eu=t,t=J)):(eu=t,t=J)):(eu=t,t=J),au[u]={nextPos:eu,result:t},t)}function c(){var e,r,n,s,u,i,a,o,c=36*eu+1,f=au[c];if(f)return eu=f.nextPos,f.result;if(e=eu,r=p(),r!==$){for(n=[],s=eu,u=k(),u!==$?(44===t.charCodeAt(eu)?(i=W,eu++):(i=$,0===lu&&l(X)),i!==$?(a=k(),a!==$?(o=p(),o!==$?(u=[u,i,a,o],s=u):(eu=s,s=J)):(eu=s,s=J)):(eu=s,s=J)):(eu=s,s=J);s!==$;)n.push(s),s=eu,u=k(),u!==$?(44===t.charCodeAt(eu)?(i=W,eu++):(i=$,0===lu&&l(X)),i!==$?(a=k(),a!==$?(o=p(),o!==$?(u=[u,i,a,o],s=u):(eu=s,s=J)):(eu=s,s=J)):(eu=s,s=J)):(eu=s,s=J);n!==$?(ru=e,r=te(r,n),e=r):(eu=e,e=J)}else eu=e,e=J;return au[c]={nextPos:eu,result:e},e}function p(){var t,e,r,n,s,u,i=36*eu+2,l=au[i];if(l)return eu=l.nextPos,l.result;if(t=eu,e=f(),e!==$){for(r=[],n=eu,s=k(),s!==$?(u=d(),u!==$?(s=[s,u],n=s):(eu=n,n=J)):(eu=n,n=J);n!==$;)r.push(n),n=eu,s=k(),s!==$?(u=d(),u!==$?(s=[s,u],n=s):(eu=n,n=J)):(eu=n,n=J);r!==$?(ru=t,e=ee(e,r),t=e):(eu=t,t=J)}else eu=t,t=J;return au[i]={nextPos:eu,result:t},t}function f(){var t,e,r,n,s,u,i=36*eu+3,l=au[i];return l?(eu=l.nextPos,l.result):(t=eu,e=h(),e===$&&(e=re),e!==$?(r=k(),r!==$?(n=v(),n!==$?(s=k(),s!==$?(u=A(),u===$&&(u=re),u!==$?(ru=t,e=ne(e,n,u),t=e):(eu=t,t=J)):(eu=t,t=J)):(eu=t,t=J)):(eu=t,t=J)):(eu=t,t=J),au[i]={nextPos:eu,result:t},t)}function d(){var t,e,r,n,s,u,i=36*eu+4,l=au[i];return l?(eu=l.nextPos,l.result):(t=eu,e=h(),e!==$?(r=k(),r!==$?(n=v(),n!==$?(s=k(),s!==$?(u=A(),u===$&&(u=re),u!==$?(ru=t,e=ne(e,n,u),t=e):(eu=t,t=J)):(eu=t,t=J)):(eu=t,t=J)):(eu=t,t=J)):(eu=t,t=J),au[i]={nextPos:eu,result:t},t)}function h(){var e,r,n,s=36*eu+5,u=au[s];return u?(eu=u.nextPos,u.result):(lu++,e=eu,r=eu,t.substr(eu,2)===ue?(n=ue,eu+=2):(n=$,0===lu&&l(ie)),n===$&&(47===t.charCodeAt(eu)?(n=le,eu++):(n=$,0===lu&&l(ae)),n===$&&(t.substr(eu,3)===oe?(n=oe,eu+=3):(n=$,0===lu&&l(ce)),n===$&&(t.substr(eu,2)===pe?(n=pe,eu+=2):(n=$,0===lu&&l(fe)),n===$&&(t.substr(eu,3)===de?(n=de,eu+=3):(n=$,0===lu&&l(he)),n===$&&(t.substr(eu,2)===ve?(n=ve,eu+=2):(n=$,0===lu&&l(Ae)),n===$&&(t.substr(eu,4)===ye?(n=ye,eu+=4):(n=$,0===lu&&l(xe)),n===$&&(t.substr(eu,3)===be?(n=be,eu+=3):(n=$,0===lu&&l(Pe))))))))),n!==$&&(n=t.substring(r,eu)),r=n,r!==$&&(ru=e,r=ge(r)),e=r,lu--,e===$&&(r=$,0===lu&&l(se)),au[s]={nextPos:eu,result:e},e)}function v(){var e,r,n=36*eu+6,s=au[n];return s?(eu=s.nextPos,s.result):(e=eu,r=j(),r!==$&&(ru=e,r=Ce(r)),e=r,e===$&&(e=eu,42===t.charCodeAt(eu)?(r=me,eu++):(r=$,0===lu&&l(Se)),r!==$&&(ru=e,r=Qe()),e=r),au[n]={nextPos:eu,result:e},e)}function A(){var e,r,n,s,u,i,a=36*eu+7,o=au[a];return o?(eu=o.nextPos,o.result):(e=eu,91===t.charCodeAt(eu)?(r=Re,eu++):(r=$,0===lu&&l(Ee)),r!==$?(n=k(),n!==$?(s=y(),s!==$?(u=k(),u!==$?(93===t.charCodeAt(eu)?(i=we,eu++):(i=$,0===lu&&l(Fe)),i!==$?(ru=e,r=Te(s),e=r):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J),au[a]={nextPos:eu,result:e},e)}function y(){var e,r,n,s,u,i,a,o,c,p,f=36*eu+8,d=au[f];return d?(eu=d.nextPos,d.result):(e=eu,r=x(),r!==$?(n=k(),n!==$?(t.substr(eu,2)===Le?(s=Le,eu+=2):(s=$,0===lu&&l(qe)),s!==$?(u=k(),u!==$?(i=x(),i!==$?(ru=e,r=_e(r,i),e=r):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J),e===$&&(e=eu,r=x(),r!==$?(n=k(),n!==$?(63===t.charCodeAt(eu)?(s=Ne,eu++):(s=$,0===lu&&l(je)),s!==$?(u=k(),u!==$?(i=x(),i!==$?(a=k(),a!==$?(58===t.charCodeAt(eu)?(o=ze,eu++):(o=$,0===lu&&l(Ie)),o!==$?(c=k(),c!==$?(p=x(),p!==$?(ru=e,r=Ue(r,i,p),e=r):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J),e===$&&(e=x())),au[f]={nextPos:eu,result:e},e)}function x(){var e,r,n,s,u,i,a=36*eu+9,o=au[a];return o?(eu=o.nextPos,o.result):(e=eu,r=b(),r!==$?(n=k(),n!==$?(s=eu,t.substr(eu,2)===Ze?(u=Ze,eu+=2):(u=$,0===lu&&l(Ve)),u!==$&&(u=t.substring(s,eu)),s=u,s!==$?(u=k(),u!==$?(i=x(),i!==$?(ru=e,r=ke(r,s,i),e=r):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J),e===$&&(e=b()),au[a]={nextPos:eu,result:e},e)}function b(){var e,r,n,s,u,i,a=36*eu+10,o=au[a];return o?(eu=o.nextPos,o.result):(e=eu,r=P(),r!==$?(n=k(),n!==$?(s=eu,t.substr(eu,2)===Me?(u=Me,eu+=2):(u=$,0===lu&&l(Be)),u!==$&&(u=t.substring(s,eu)),s=u,s!==$?(u=k(),u!==$?(i=b(),i!==$?(ru=e,r=ke(r,s,i),e=r):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J),e===$&&(e=P()),au[a]={nextPos:eu,result:e},e)}function P(){var e,r,n,s,u,i,a=36*eu+11,o=au[a];return o?(eu=o.nextPos,o.result):(e=eu,r=g(),r!==$?(n=k(),n!==$?(s=eu,124===t.charCodeAt(eu)?(u=Ge,eu++):(u=$,0===lu&&l(Oe)),u!==$&&(u=t.substring(s,eu)),s=u,s!==$?(u=k(),u!==$?(i=P(),i!==$?(ru=e,r=Ye(r,s,i),e=r):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J),e===$&&(e=g()),au[a]={nextPos:eu,result:e},e)}function g(){var e,r,n,s,u,i,a=36*eu+12,o=au[a];return o?(eu=o.nextPos,o.result):(e=eu,r=C(),r!==$?(n=k(),n!==$?(s=eu,94===t.charCodeAt(eu)?(u=$e,eu++):(u=$,0===lu&&l(De)),u!==$&&(u=t.substring(s,eu)),s=u,s!==$?(u=k(),u!==$?(i=g(),i!==$?(ru=e,r=Ye(r,s,i),e=r):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J),e===$&&(e=C()),au[a]={nextPos:eu,result:e},e)}function C(){var e,r,n,s,u,i,a=36*eu+13,o=au[a];return o?(eu=o.nextPos,o.result):(e=eu,r=m(),r!==$?(n=k(),n!==$?(s=eu,38===t.charCodeAt(eu)?(u=He,eu++):(u=$,0===lu&&l(Je)),u!==$&&(u=t.substring(s,eu)),s=u,s!==$?(u=k(),u!==$?(i=C(),i!==$?(ru=e,r=Ye(r,s,i),e=r):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J),e===$&&(e=m()),au[a]={nextPos:eu,result:e},e)}function m(){var e,r,n,s,u,i,a=36*eu+14,o=au[a];return o?(eu=o.nextPos,o.result):(e=eu,r=S(),r!==$?(n=k(),n!==$?(s=eu,t.substr(eu,2)===Ke?(u=Ke,eu+=2):(u=$,0===lu&&l(We)),u===$&&(t.substr(eu,2)===Xe?(u=Xe,eu+=2):(u=$,0===lu&&l(tr)),u===$&&(t.substr(eu,2)===er?(u=er,eu+=2):(u=$,0===lu&&l(rr)),u===$&&(t.substr(eu,2)===nr?(u=nr,eu+=2):(u=$,0===lu&&l(sr)),u===$&&(60===t.charCodeAt(eu)?(u=ur,eu++):(u=$,0===lu&&l(ir)),u===$&&(62===t.charCodeAt(eu)?(u=lr,eu++):(u=$,0===lu&&l(ar)),u===$&&(t.substr(eu,2)===or?(u=or,eu+=2):(u=$,0===lu&&l(cr)),u===$&&(t.substr(eu,2)===pr?(u=pr,eu+=2):(u=$,0===lu&&l(fr))))))))),u!==$&&(u=t.substring(s,eu)),s=u,s!==$?(u=k(),u!==$?(i=m(),i!==$?(ru=e,r=dr(r,s,i),e=r):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J),e===$&&(e=S()),au[a]={nextPos:eu,result:e},e)}function S(){var e,r,n,s,u,i,a=36*eu+15,o=au[a];return o?(eu=o.nextPos,o.result):(e=eu,r=Q(),r!==$?(n=k(),n!==$?(s=eu,t.substr(eu,2)===hr?(u=hr,eu+=2):(u=$,0===lu&&l(vr)),u===$&&(t.substr(eu,2)===Ar?(u=Ar,eu+=2):(u=$,0===lu&&l(yr))),u!==$&&(u=t.substring(s,eu)),s=u,s!==$?(u=k(),u!==$?(i=S(),i!==$?(ru=e,r=Ye(r,s,i),e=r):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J),e===$&&(e=Q()),au[a]={nextPos:eu,result:e},e)}function Q(){var e,r,n,s,u,i,a=36*eu+16,o=au[a];return o?(eu=o.nextPos,o.result):(e=eu,r=R(),r!==$?(n=k(),n!==$?(s=eu,43===t.charCodeAt(eu)?(u=xr,eu++):(u=$,0===lu&&l(br)),u===$&&(45===t.charCodeAt(eu)?(u=Pr,eu++):(u=$,0===lu&&l(gr))),u!==$&&(u=t.substring(s,eu)),s=u,s!==$?(u=k(),u!==$?(i=Q(),i!==$?(ru=e,r=Cr(r,s,i),e=r):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J),e===$&&(e=R()),au[a]={nextPos:eu,result:e},e)}function R(){var e,r,n,s,u,i,a=36*eu+17,o=au[a];return o?(eu=o.nextPos,o.result):(e=eu,r=E(),r!==$?(n=k(),n!==$?(s=eu,t.substr(eu,2)===mr?(u=mr,eu+=2):(u=$,0===lu&&l(Sr)),u===$&&(42===t.charCodeAt(eu)?(u=me,eu++):(u=$,0===lu&&l(Se)),u===$&&(47===t.charCodeAt(eu)?(u=le,eu++):(u=$,0===lu&&l(ae)),u===$&&(37===t.charCodeAt(eu)?(u=Qr,eu++):(u=$,0===lu&&l(Rr))))),u!==$&&(u=t.substring(s,eu)),s=u,s!==$?(u=k(),u!==$?(i=R(),i!==$?(ru=e,r=Cr(r,s,i),e=r):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J),e===$&&(e=E()),au[a]={nextPos:eu,result:e},e)}function E(){var e,r,n,s=36*eu+18,u=au[s];return u?(eu=u.nextPos,u.result):(e=eu,r=eu,33===t.charCodeAt(eu)?(n=Er,eu++):(n=$,0===lu&&l(wr)),n===$&&(126===t.charCodeAt(eu)?(n=Fr,eu++):(n=$,0===lu&&l(Tr))),n!==$&&(n=t.substring(r,eu)),r=n,r!==$?(n=w(),n!==$?(ru=e,r=Lr(r,n),e=r):(eu=e,e=J)):(eu=e,e=J),e===$&&(e=w()),au[s]={nextPos:eu,result:e},e)}function w(){var t,e=36*eu+19,r=au[e];return r?(eu=r.nextPos,r.result):(t=F(),t===$&&(t=L(),t===$&&(t=q(),t===$&&(t=_(),t===$&&(t=N(),t===$&&(t=p()))))),au[e]={nextPos:eu,result:t},t)}function F(){var e,r,n,s,u,i,a,o,c=36*eu+20,p=au[c];return p?(eu=p.nextPos,p.result):(e=eu,r=j(),r!==$?(n=k(),n!==$?(40===t.charCodeAt(eu)?(s=qr,eu++):(s=$,0===lu&&l(_r)),s!==$?(u=k(),u!==$?(i=T(),i===$&&(i=re),i!==$?(a=k(),a!==$?(41===t.charCodeAt(eu)?(o=Nr,eu++):(o=$,0===lu&&l(jr)),o!==$?(ru=e,r=zr(r,i),e=r):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J),au[c]={nextPos:eu,result:e},e)}function T(){var e,r,n,s,u,i,a,o,c=36*eu+21,p=au[c];if(p)return eu=p.nextPos,p.result;if(e=eu,r=y(),r!==$){for(n=[],s=eu,u=k(),u!==$?(44===t.charCodeAt(eu)?(i=W,eu++):(i=$,0===lu&&l(X)),i!==$?(a=k(),a!==$?(o=y(),o!==$?(u=[u,i,a,o],s=u):(eu=s,s=J)):(eu=s,s=J)):(eu=s,s=J)):(eu=s,s=J);s!==$;)n.push(s),s=eu,u=k(),u!==$?(44===t.charCodeAt(eu)?(i=W,eu++):(i=$,0===lu&&l(X)),i!==$?(a=k(),a!==$?(o=y(),o!==$?(u=[u,i,a,o],s=u):(eu=s,s=J)):(eu=s,s=J)):(eu=s,s=J)):(eu=s,s=J);n!==$?(ru=e,r=Ir(r,n),e=r):(eu=e,e=J)}else eu=e,e=J;return au[c]={nextPos:eu,result:e},e}function L(){var e,r,n,s=36*eu+22,u=au[s];return u?(eu=u.nextPos,u.result):(lu++,e=eu,64===t.charCodeAt(eu)?(r=Zr,eu++):(r=$,0===lu&&l(Vr)),r!==$?(n=j(),n!==$?(ru=e,r=kr(n),e=r):(eu=e,e=J)):(eu=e,e=J),lu--,e===$&&(r=$,0===lu&&l(Ur)),au[s]={nextPos:eu,result:e},e)}function q(){var e,r,n,s,u,i,a=36*eu+23,o=au[a];return o?(eu=o.nextPos,o.result):(lu++,e=eu,123===t.charCodeAt(eu)?(r=Br,eu++):(r=$,0===lu&&l(Gr)),r!==$?(n=k(),n!==$?(s=j(),s!==$?(u=k(),u!==$?(125===t.charCodeAt(eu)?(i=Or,eu++):(i=$,0===lu&&l(Yr)),i!==$?(ru=e,r=$r(s),e=r):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J),lu--,e===$&&(r=$,0===lu&&l(Mr)),au[a]={nextPos:eu,result:e},e)}function _(){var t,e=36*eu+24,r=au[e];return r?(eu=r.nextPos,r.result):(t=z(),t===$&&(t=U(),t===$&&(t=Z(),t===$&&(t=V()))),au[e]={nextPos:eu,result:t},t)}function N(){var e,r,n,s,u,i,a=36*eu+25,o=au[a];return o?(eu=o.nextPos,o.result):(e=eu,40===t.charCodeAt(eu)?(r=qr,eu++):(r=$,0===lu&&l(_r)),r!==$?(n=k(),n!==$?(s=y(),s!==$?(u=k(),u!==$?(41===t.charCodeAt(eu)?(i=Nr,eu++):(i=$,0===lu&&l(jr)),i!==$?(ru=e,r=Dr(s),e=r):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J)):(eu=e,e=J),au[a]={nextPos:eu,result:e},e)}function j(){var e,r,n,s,u,i,a,o=36*eu+26,c=au[o];if(c)return eu=c.nextPos,c.result;if(lu++,e=eu,r=eu,n=eu,s=eu,lu++,u=V(),lu--,u===$?s=Jr:(eu=s,s=J),s!==$)if(Kr.test(t.charAt(eu))?(u=t.charAt(eu),eu++):(u=$,0===lu&&l(Wr)),u!==$){for(i=[],Xr.test(t.charAt(eu))?(a=t.charAt(eu),eu++):(a=$,0===lu&&l(tn));a!==$;)i.push(a),Xr.test(t.charAt(eu))?(a=t.charAt(eu),eu++):(a=$,0===lu&&l(tn));i!==$?(s=[s,u,i],n=s):(eu=n,n=J)}else eu=n,n=J;else eu=n,n=J;return n!==$&&(n=t.substring(r,eu)),r=n,r!==$&&(ru=e,r=en(r)),e=r,lu--,e===$&&(r=$,0===lu&&l(Hr)),au[o]={nextPos:eu,result:e},e}function z(){var e,r,n,s,u,i=36*eu+27,a=au[i];if(a)return eu=a.nextPos,a.result;if(lu++,e=eu,34===t.charCodeAt(eu)?(r=nn,eu++):(r=$,0===lu&&l(sn)),r!==$){for(n=[],s=I(),s===$&&(un.test(t.charAt(eu))?(s=t.charAt(eu),eu++):(s=$,0===lu&&l(ln)));s!==$;)n.push(s),s=I(),s===$&&(un.test(t.charAt(eu))?(s=t.charAt(eu),eu++):(s=$,0===lu&&l(ln)));n!==$?(34===t.charCodeAt(eu)?(s=nn,eu++):(s=$,0===lu&&l(sn)),s!==$?(ru=e,r=an(n),e=r):(eu=e,e=J)):(eu=e,e=J)}else eu=e,e=J;if(e===$)if(e=eu,39===t.charCodeAt(eu)?(r=on,eu++):(r=$,0===lu&&l(cn)),r!==$){for(n=eu,s=[],t.substr(eu,2)===pn?(u=pn,eu+=2):(u=$,0===lu&&l(fn)),u===$&&(dn.test(t.charAt(eu))?(u=t.charAt(eu),eu++):(u=$,0===lu&&l(hn)));u!==$;)s.push(u),t.substr(eu,2)===pn?(u=pn,eu+=2):(u=$,0===lu&&l(fn)),u===$&&(dn.test(t.charAt(eu))?(u=t.charAt(eu),eu++):(u=$,0===lu&&l(hn)));s!==$&&(s=t.substring(n,eu)),n=s,n!==$?(39===t.charCodeAt(eu)?(s=on,eu++):(s=$,0===lu&&l(cn)),s!==$?(ru=e,r=vn(n),e=r):(eu=e,e=J)):(eu=e,e=J)}else eu=e,e=J;return lu--,e===$&&(r=$,0===lu&&l(rn)),au[i]={nextPos:eu,result:e},e}function I(){var e,r,n,s,u,i,a,o,c=36*eu+28,p=au[c];return p?(eu=p.nextPos,p.result):(lu++,e=eu,t.substr(eu,2)===yn?(r=yn,eu+=2):(r=$,0===lu&&l(xn)),r!==$&&(ru=e,r=bn()),e=r,e===$&&(e=eu,t.substr(eu,2)===Pn?(r=Pn,eu+=2):(r=$,0===lu&&l(gn)),r!==$&&(ru=e,r=Cn()),e=r,e===$&&(e=eu,39===t.charCodeAt(eu)?(r=on,eu++):(r=$,0===lu&&l(cn)),r!==$&&(ru=e,r=mn()),e=r,e===$&&(e=eu,t.substr(eu,2)===Sn?(r=Sn,eu+=2):(r=$,0===lu&&l(Qn)),r!==$&&(ru=e,r=Rn()),e=r,e===$&&(e=eu,t.substr(eu,2)===En?(r=En,eu+=2):(r=$,0===lu&&l(wn)),r!==$&&(ru=e,r=Fn()),e=r,e===$&&(e=eu,t.substr(eu,2)===Tn?(r=Tn,eu+=2):(r=$,0===lu&&l(Ln)),r!==$&&(ru=e,r=qn()),e=r,e===$&&(e=eu,t.substr(eu,2)===_n?(r=_n,eu+=2):(r=$,0===lu&&l(Nn)),r!==$&&(ru=e,r=jn()),e=r,e===$&&(e=eu,t.substr(eu,2)===zn?(r=zn,eu+=2):(r=$,0===lu&&l(In)),r!==$&&(ru=e,r=Un()),e=r,e===$&&(e=eu,t.substr(eu,2)===Zn?(r=Zn,eu+=2):(r=$,0===lu&&l(Vn)),r!==$&&(ru=e,r=kn()),e=r,e===$&&(e=eu,t.substr(eu,2)===Mn?(r=Mn,eu+=2):(r=$,0===lu&&l(Bn)),r!==$&&(ru=e,r=Gn()),e=r,e===$&&(e=eu,t.substr(eu,2)===On?(r=On,eu+=2):(r=$,0===lu&&l(Yn)),r!==$?(n=eu,s=eu,$n.test(t.charAt(eu))?(u=t.charAt(eu),eu++):(u=$,0===lu&&l(Dn)),u!==$?($n.test(t.charAt(eu))?(i=t.charAt(eu),eu++):(i=$,0===lu&&l(Dn)),i!==$?(u=[u,i],s=u):(eu=s,s=J)):(eu=s,s=J),s!==$&&(s=t.substring(n,eu)),n=s,n!==$?(ru=e,r=Hn(n),e=r):(eu=e,e=J)):(eu=e,e=J),e===$&&(e=eu,t.substr(eu,2)===Jn?(r=Jn,eu+=2):(r=$,0===lu&&l(Kn)),r!==$?(n=eu,s=eu,$n.test(t.charAt(eu))?(u=t.charAt(eu),eu++):(u=$,0===lu&&l(Dn)),u!==$?($n.test(t.charAt(eu))?(i=t.charAt(eu),eu++):(i=$,0===lu&&l(Dn)),i!==$?($n.test(t.charAt(eu))?(a=t.charAt(eu),eu++):(a=$,0===lu&&l(Dn)),a!==$?($n.test(t.charAt(eu))?(o=t.charAt(eu),eu++):(o=$,0===lu&&l(Dn)),o!==$?(u=[u,i,a,o],s=u):(eu=s,s=J)):(eu=s,s=J)):(eu=s,s=J)):(eu=s,s=J),s!==$&&(s=t.substring(n,eu)),n=s,n!==$?(ru=e,r=Hn(n),e=r):(eu=e,e=J)):(eu=e,e=J)))))))))))),lu--,e===$&&(r=$,0===lu&&l(An)),au[c]={nextPos:eu,result:e},e)}function U(){var e,r,n,s,u,i=36*eu+29,a=au[i];if(a)return eu=a.nextPos,a.result;if(lu++,e=eu,47===t.charCodeAt(eu)?(r=le,eu++):(r=$,0===lu&&l(ae)),r!==$){for(n=eu,s=[],t.substr(eu,2)===Xn?(u=Xn,eu+=2):(u=$,0===lu&&l(ts)),u===$&&(es.test(t.charAt(eu))?(u=t.charAt(eu),eu++):(u=$,0===lu&&l(rs)));u!==$;)s.push(u),t.substr(eu,2)===Xn?(u=Xn,eu+=2):(u=$,0===lu&&l(ts)),u===$&&(es.test(t.charAt(eu))?(u=t.charAt(eu),eu++):(u=$,0===lu&&l(rs)));s!==$&&(s=t.substring(n,eu)),n=s,n!==$?(47===t.charCodeAt(eu)?(s=le,eu++):(s=$,0===lu&&l(ae)),s!==$?(ru=e,r=ns(n),e=r):(eu=e,e=J)):(eu=e,e=J)}else eu=e,e=J;return lu--,e===$&&(r=$,0===lu&&l(Wn)),au[i]={nextPos:eu,result:e},e}function Z(){var e,r,n,s,u,i,a,o,c,p,f,d,h=36*eu+30,v=au[h];if(v)return eu=v.nextPos,v.result;if(lu++,e=eu,r=eu,us.test(t.charAt(eu))?(n=t.charAt(eu),eu++):(n=$,0===lu&&l(is)),n===$&&(n=re),n!==$&&(n=t.substring(r,eu)),r=n,r!==$)if(t.substr(eu,2)===ls?(n=ls,eu+=2):(n=$,0===lu&&l(as)),n!==$){if(s=eu,u=[],os.test(t.charAt(eu))?(i=t.charAt(eu),eu++):(i=$,0===lu&&l(cs)),i!==$)for(;i!==$;)u.push(i),os.test(t.charAt(eu))?(i=t.charAt(eu),eu++):(i=$,0===lu&&l(cs));else u=J;u!==$&&(u=t.substring(s,eu)),s=u,s!==$?(ru=e,r=ps(r,s),e=r):(eu=e,e=J)}else eu=e,e=J;else eu=e,e=J;if(e===$){if(e=eu,r=eu,us.test(t.charAt(eu))?(n=t.charAt(eu),eu++):(n=$,0===lu&&l(is)),n===$&&(n=re),n!==$&&(n=t.substring(r,eu)),r=n,r!==$)if(t.substr(eu,2)===fs?(n=fs,eu+=2):(n=$,0===lu&&l(ds)),n!==$){if(s=eu,u=[],hs.test(t.charAt(eu))?(i=t.charAt(eu),eu++):(i=$,0===lu&&l(vs)),i!==$)for(;i!==$;)u.push(i),hs.test(t.charAt(eu))?(i=t.charAt(eu),eu++):(i=$,0===lu&&l(vs));else u=J;u!==$&&(u=t.substring(s,eu)),s=u,s!==$?(ru=e,r=As(r,s),e=r):(eu=e,e=J)}else eu=e,e=J;else eu=e,e=J;if(e===$){if(e=eu,r=eu,us.test(t.charAt(eu))?(n=t.charAt(eu),eu++):(n=$,0===lu&&l(is)),n===$&&(n=re),n!==$&&(n=t.substring(r,eu)),r=n,r!==$)if(t.substr(eu,2)===ys?(n=ys,eu+=2):(n=$,0===lu&&l(xs)),n!==$){if(s=eu,u=[],$n.test(t.charAt(eu))?(i=t.charAt(eu),eu++):(i=$,0===lu&&l(Dn)),i!==$)for(;i!==$;)u.push(i),$n.test(t.charAt(eu))?(i=t.charAt(eu),eu++):(i=$,0===lu&&l(Dn));else u=J;u!==$&&(u=t.substring(s,eu)),s=u,s!==$?(ru=e,r=bs(r,s),e=r):(eu=e,e=J)}else eu=e,e=J;else eu=e,e=J;if(e===$){if(e=eu,r=eu,n=eu,us.test(t.charAt(eu))?(s=t.charAt(eu),eu++):(s=$,0===lu&&l(is)),s===$&&(s=re),s!==$){for(u=[],Ps.test(t.charAt(eu))?(i=t.charAt(eu),eu++):(i=$,0===lu&&l(gs));i!==$;)u.push(i),Ps.test(t.charAt(eu))?(i=t.charAt(eu),eu++):(i=$,0===lu&&l(gs));if(u!==$)if(46===t.charCodeAt(eu)?(i=Cs,eu++):(i=$,0===lu&&l(ms)),i!==$){if(a=[],Ps.test(t.charAt(eu))?(o=t.charAt(eu),eu++):(o=$,0===lu&&l(gs)),o!==$)for(;o!==$;)a.push(o),Ps.test(t.charAt(eu))?(o=t.charAt(eu),eu++):(o=$,0===lu&&l(gs));else a=J;if(a!==$){if(o=eu,Ss.test(t.charAt(eu))?(c=t.charAt(eu),eu++):(c=$,0===lu&&l(Qs)),c!==$)if(us.test(t.charAt(eu))?(p=t.charAt(eu),eu++):(p=$,0===lu&&l(is)),p===$&&(p=re),p!==$){if(f=[],Ps.test(t.charAt(eu))?(d=t.charAt(eu),eu++):(d=$,0===lu&&l(gs)),d!==$)for(;d!==$;)f.push(d),Ps.test(t.charAt(eu))?(d=t.charAt(eu),eu++):(d=$,0===lu&&l(gs));else f=J;f!==$?(c=[c,p,f],o=c):(eu=o,o=J)}else eu=o,o=J;else eu=o,o=J;o===$&&(o=re),o!==$?(s=[s,u,i,a,o],n=s):(eu=n,n=J)}else eu=n,n=J}else eu=n,n=J;else eu=n,n=J}else eu=n,n=J;if(n!==$&&(n=t.substring(r,eu)),r=n,r!==$&&(ru=e,r=Rs(r)),e=r,e===$){if(e=eu,r=eu,n=eu,us.test(t.charAt(eu))?(s=t.charAt(eu),eu++):(s=$,0===lu&&l(is)),s===$&&(s=re),s!==$){if(u=[],Ps.test(t.charAt(eu))?(i=t.charAt(eu),eu++):(i=$,0===lu&&l(gs)),i!==$)for(;i!==$;)u.push(i),Ps.test(t.charAt(eu))?(i=t.charAt(eu),eu++):(i=$,0===lu&&l(gs));else u=J;u!==$?(s=[s,u],n=s):(eu=n,n=J)}else eu=n,n=J;n!==$&&(n=t.substring(r,eu)),r=n,r!==$&&(ru=e,r=Es(r)),e=r}}}}return lu--,e===$&&(r=$,0===lu&&l(ss)),au[h]={nextPos:eu,result:e},e}function V(){var e,r,n=36*eu+31,s=au[n];return s?(eu=s.nextPos,s.result):(lu++,e=eu,t.substr(eu,4)===Fs?(r=Fs,eu+=4):(r=$,0===lu&&l(Ts)),r!==$&&(ru=e,r=Ls()),e=r,e===$&&(e=eu,t.substr(eu,5)===qs?(r=qs,eu+=5):(r=$,0===lu&&l(_s)),r!==$&&(ru=e,r=Ns()),e=r,e===$&&(e=eu,t.substr(eu,4)===js?(r=js,eu+=4):(r=$,0===lu&&l(zs)),r!==$&&(ru=e,r=Is()),e=r,e===$&&(e=eu,t.substr(eu,3)===Us?(r=Us,eu+=3):(r=$,0===lu&&l(Zs)),r!==$&&(ru=e,r=Vs()),e=r,e===$&&(e=eu,t.substr(eu,9)===ks?(r=ks,eu+=9):(r=$,0===lu&&l(Ms)),r!==$&&(ru=e,r=Bs()),e=r)))),lu--,e===$&&(r=$,0===lu&&l(ws)),au[n]={nextPos:eu,result:e},e)}function k(){var t,e,r=36*eu+32,n=au[r];if(n)return eu=n.nextPos,n.result;for(lu++,t=[],e=M(),e===$&&(e=B());e!==$;)t.push(e),e=M(),e===$&&(e=B());return lu--,t===$&&(e=$,0===lu&&l(Gs)),au[r]={nextPos:eu,result:t},t}function M(){var e,r,n,s,u,i,a=36*eu+33,o=au[a];if(o)return eu=o.nextPos,o.result;if(lu++,e=eu,t.substr(eu,2)===Ys?(r=Ys,eu+=2):(r=$,0===lu&&l($s)),r!==$){for(n=[],s=eu,u=eu,lu++,t.substr(eu,2)===Ds?(i=Ds,eu+=2):(i=$,0===lu&&l(Hs)),lu--,i===$?u=Jr:(eu=u,u=J),u!==$?(t.length>eu?(i=t.charAt(eu),eu++):(i=$,0===lu&&l(Js)),i!==$?(u=[u,i],s=u):(eu=s,s=J)):(eu=s,s=J);s!==$;)n.push(s),s=eu,u=eu,lu++,t.substr(eu,2)===Ds?(i=Ds,eu+=2):(i=$,0===lu&&l(Hs)),lu--,i===$?u=Jr:(eu=u,u=J),u!==$?(t.length>eu?(i=t.charAt(eu),eu++):(i=$,0===lu&&l(Js)),i!==$?(u=[u,i],s=u):(eu=s,s=J)):(eu=s,s=J);n!==$?(t.substr(eu,2)===Ds?(s=Ds,eu+=2):(s=$,0===lu&&l(Hs)),s!==$?(r=[r,n,s],e=r):(eu=e,e=J)):(eu=e,e=J)}else eu=e,e=J;return lu--,e===$&&(r=$,0===lu&&l(Os)),au[a]={nextPos:eu,result:e},e}function B(){var e,r,n=36*eu+34,s=au[n];if(s)return eu=s.nextPos,s.result;if(lu++,e=[],Ws.test(t.charAt(eu))?(r=t.charAt(eu),eu++):(r=$,0===lu&&l(Xs)),r!==$)for(;r!==$;)e.push(r),Ws.test(t.charAt(eu))?(r=t.charAt(eu),eu++):(r=$,0===lu&&l(Xs));else e=J;return lu--,e===$&&(r=$,0===lu&&l(Ks)),au[n]={nextPos:eu,result:e},e}function G(){var e,r,n=36*eu+35,s=au[n];return s?(eu=s.nextPos,s.result):(lu++,e=eu,lu++,t.length>eu?(r=t.charAt(eu),eu++):(r=$,0===lu&&l(Js)),lu--,r===$?e=Jr:(eu=e,e=J),lu--,e===$&&(r=$,0===lu&&l(tu)),au[n]={nextPos:eu,result:e},e)}var O,Y=arguments.length>1?arguments[1]:{},$={},D={query:o},H=o,J=$,K=function(t){return t},W=",",X={type:"literal",value:",",description:'","'},te=function(t,e){return cu("Query").add(ou(t,e,3))},ee=function(t,e){return cu("Path").add(ou(t,e,1))},re=null,ne=function(t,e,r){return cu("Step").add(t,e,r)},se={type:"other",description:"axis"},ue="//",ie={type:"literal",value:"//",description:'"//"'},le="/",ae={type:"literal",value:"/",description:'"/"'},oe="+//",ce={type:"literal",value:"+//",description:'"+//"'},pe="+/",fe={type:"literal",value:"+/",description:'"+/"'},de="-//",he={type:"literal",value:"-//",description:'"-//"'},ve="-/",Ae={type:"literal",value:"-/",description:'"-/"'},ye="..//",xe={type:"literal",value:"..//",description:'"..//"'},be="../",Pe={type:"literal",value:"../",description:'"../"'},ge=function(t){return cu("Axis").set({op:t})},Ce=function(t){return cu("Match").merge(t)},me="*",Se={type:"literal",value:"*",description:'"*"'},Qe=function(){return cu("Match").set({id:"*"})},Re="[",Ee={type:"literal",value:"[",description:'"["'},we="]",Fe={type:"literal",value:"]",description:'"]"'},Te=function(t){return cu("Filter").add(t)},Le="?:",qe={type:"literal",value:"?:",description:'"?:"'},_e=function(t,e){return cu("ConditionalBinary").add(t,e)},Ne="?",je={type:"literal",value:"?",description:'"?"'},ze=":",Ie={type:"literal",value:":",description:'":"'},Ue=function(t,e,r){return cu("ConditionalTernary").add(t,e,r)},Ze="||",Ve={type:"literal",value:"||",description:'"||"'},ke=function(t,e,r){return cu("Logical").set({op:e}).add(t,r)},Me="&&",Be={type:"literal",value:"&&",description:'"&&"'},Ge="|",Oe={type:"literal",value:"|",description:'"|"'},Ye=function(t,e,r){return cu("Bitwise").set({op:e}).add(t,r)},$e="^",De={type:"literal",value:"^",description:'"^"'},He="&",Je={type:"literal",value:"&",description:'"&"'},Ke="==",We={type:"literal",value:"==",description:'"=="'},Xe="!=",tr={type:"literal",value:"!=",description:'"!="'},er="<=",rr={type:"literal",value:"<=",description:'"<="'},nr=">=",sr={type:"literal",value:">=",description:'">="'},ur="<",ir={type:"literal",value:"<",description:'"<"'},lr=">",ar={type:"literal",value:">",description:'">"'},or="=~",cr={type:"literal",value:"=~",description:'"=~"'},pr="!~",fr={type:"literal",value:"!~",description:'"!~"'},dr=function(t,e,r){return cu("Relational").set({op:e}).add(t,r)},hr="<<",vr={type:"literal",value:"<<",description:'"<<"'},Ar=">>",yr={type:"literal",value:">>",description:'">>"'},xr="+",br={type:"literal",value:"+",description:'"+"'},Pr="-",gr={type:"literal",value:"-",description:'"-"'},Cr=function(t,e,r){return cu("Arithmetical").set({op:e}).add(t,r)},mr="**",Sr={type:"literal",value:"**",description:'"**"'},Qr="%",Rr={type:"literal",value:"%",description:'"%"'},Er="!",wr={type:"literal",value:"!",description:'"!"'},Fr="~",Tr={type:"literal",value:"~",description:'"~"'},Lr=function(t,e){return cu("Unary").set({op:t}).add(e)},qr="(",_r={type:"literal",value:"(",description:'"("'},Nr=")",jr={type:"literal",value:")",description:'")"'},zr=function(t,e){return cu("FuncCall").merge(t).add(e)},Ir=function(t,e){return ou(t,e,3)},Ur={type:"other",description:"node attribute"},Zr="@",Vr={type:"literal",value:"@",description:'"@"'},kr=function(t){return cu("Attribute").merge(t)},Mr={type:"other",description:"query parameter reference"},Br="{",Gr={type:"literal",value:"{",description:'"{"'},Or="}",Yr={type:"literal",value:"}",description:'"}"'},$r=function(t){return cu("Param").merge(t)},Dr=function(t){return t},Hr={type:"other",description:"identifier"},Jr=void 0,Kr=/^[a-zA-Z_]/,Wr={type:"class",value:"[a-zA-Z_]",description:"[a-zA-Z_]"},Xr=/^[a-zA-Z0-9_\-]/,tn={type:"class",value:"[a-zA-Z0-9_\\-]",description:"[a-zA-Z0-9_\\-]"},en=function(t){return cu("Identifier").set({id:t})},rn={type:"other",description:"quoted string literal"},nn='"',sn={type:"literal",value:'"',description:'"\\""'},un=/^[^"]/,ln={type:"class",value:'[^"]',description:'[^"]'},an=function(t){return cu("LiteralString").set({value:t.join("")})},on="'",cn={type:"literal",value:"'",description:'"\'"'},pn="\\'",fn={type:"literal",value:"\\'",description:'"\\\\\'"'},dn=/^[^']/,hn={type:"class",value:"[^']",description:"[^']"},vn=function(t){return cu("LiteralString").set({value:t.replace(/\\'/g,"'")})},An={type:"other",description:"escaped string character"},yn="\\\\",xn={type:"literal",value:"\\\\",description:'"\\\\\\\\"'},bn=function(){return"\\"},Pn='\\"',gn={type:"literal",value:'\\"',description:'"\\\\\\""'},Cn=function(){return'"'},mn=function(){return"'"},Sn="\\b",Qn={type:"literal",value:"\\b",description:'"\\\\b"'},Rn=function(){return"\b"},En="\\v",wn={type:"literal",value:"\\v",description:'"\\\\v"'},Fn=function(){return""},Tn="\\f",Ln={type:"literal",value:"\\f",description:'"\\\\f"'},qn=function(){return"\f"},_n="\\t",Nn={type:"literal",value:"\\t",description:'"\\\\t"'},jn=function(){return" "},zn="\\r",In={type:"literal",value:"\\r",description:'"\\\\r"'},Un=function(){return"\r"},Zn="\\n",Vn={type:"literal",value:"\\n",description:'"\\\\n"'},kn=function(){return"\n"},Mn="\\e",Bn={type:"literal",value:"\\e",description:'"\\\\e"'},Gn=function(){return""},On="\\x",Yn={type:"literal",value:"\\x",description:'"\\\\x"'},$n=/^[0-9a-fA-F]/,Dn={type:"class",value:"[0-9a-fA-F]",description:"[0-9a-fA-F]"},Hn=function(t){return String.fromCharCode(parseInt(t,16))},Jn="\\u",Kn={type:"literal",value:"\\u",description:'"\\\\u"'},Wn={type:"other",description:"regular expression literal"},Xn="\\/",ts={type:"literal",value:"\\/",description:'"\\\\/"'},es=/^[^\/]/,rs={type:"class",value:"[^\\/]",description:"[^\\/]"},ns=function(t){var e;try{e=new RegExp(t.replace(/\\\//g,"/"))}catch(r){u(r.message)}return cu("LiteralRegExp").set({value:e})},ss={type:"other",description:"numeric literal"},us=/^[+\-]/,is={type:"class",value:"[+\\-]",description:"[+\\-]"},ls="0b",as={type:"literal",value:"0b",description:'"0b"'},os=/^[01]/,cs={type:"class",value:"[01]",description:"[01]"},ps=function(t,e){return cu("LiteralNumber").set({value:parseInt(t+e,2)})},fs="0o",ds={type:"literal",value:"0o",description:'"0o"'},hs=/^[0-7]/,vs={type:"class",value:"[0-7]",description:"[0-7]"},As=function(t,e){return cu("LiteralNumber").set({value:parseInt(t+e,8)})},ys="0x",xs={type:"literal",value:"0x",description:'"0x"'},bs=function(t,e){return cu("LiteralNumber").set({value:parseInt(t+e,16)})},Ps=/^[0-9]/,gs={type:"class",value:"[0-9]",description:"[0-9]"},Cs=".",ms={type:"literal",value:".",description:'"."'},Ss=/^[eE]/,Qs={type:"class",value:"[eE]",description:"[eE]"},Rs=function(t){return cu("LiteralNumber").set({value:parseFloat(t)})},Es=function(t){return cu("LiteralNumber").set({value:parseInt(t,10)})},ws={type:"other",description:"global value"},Fs="true",Ts={type:"literal",value:"true",description:'"true"'},Ls=function(){return cu("LiteralValue").set({value:!0})},qs="false",_s={type:"literal",value:"false",description:'"false"'},Ns=function(){return cu("LiteralValue").set({value:!1})},js="null",zs={type:"literal",value:"null",description:'"null"'},Is=function(){return cu("LiteralValue").set({value:null})},Us="NaN",Zs={type:"literal",value:"NaN",description:'"NaN"'},Vs=function(){return cu("LiteralValue").set({value:0/0})},ks="undefined",Ms={type:"literal",value:"undefined",description:'"undefined"'},Bs=function(){return cu("LiteralValue").set({value:void 0})},Gs={type:"other",description:"optional blank"},Os={type:"other",description:"multi-line comment"},Ys="/*",$s={type:"literal",value:"/*",description:'"/*"'},Ds="*/",Hs={type:"literal",value:"*/",description:'"*/"'},Js={type:"any",description:"any character"},Ks={type:"other",description:"any whitespaces"},Ws=/^[ \t\r\n]/,Xs={type:"class",value:"[ \\t\\r\\n]",description:"[ \\t\\r\\n]"},tu={type:"other",description:"end of file"},eu=0,ru=0,nu=0,su={line:1,column:1,seenCR:!1},uu=0,iu=[],lu=0,au={};if("startRule"in Y){if(!(Y.startRule in D))throw new Error("Can't start parsing from rule \""+Y.startRule+'".');H=D[Y.startRule]}var ou=Y.util.makeUnroll(n,s,r,e),cu=Y.util.makeAST(n,s,r,Y);if(O=H(),O!==$&&eu===t.length)return O;throw O!==$&&eu<t.length&&l({type:"end",description:"end of input"}),a(null,iu,uu)}return t(e,Error),{SyntaxError:e,parse:r}}(),ASTQQueryExec=_interopRequire(_dereq_("./astq-query-exec.js")),ASTQQuery=function(){function t(t){this.asty=new ASTY,this.ast=null,t&&this.compile(t)}return _prototypeProperties(t,null,{compile:{value:function(t,e){var r=this;e&&console.log("ASTQ: compile: +-------------------------------------------------------------------------------------------------------\nASTQ: compile: | "+t);var n=PEGUtil.parse(ASTQQueryParse,t,{startRule:"query",makeAST:function(t,e,n,s){return r.asty.create.apply(r.asty,s).pos(t,e,n)}});if(null!==n.error)throw new Error("ASTQ: compile: query parsing failed:\n"+PEGUtil.errorMessage(n.error,!0).replace(/^/gm,"ERROR: "));return this.ast=n.ast,e&&console.log("ASTQ: compile: +-------------------------------------------------------------------------------------------------------\n"+this.dump().replace(/\n$/,"").replace(/^/gm,"ASTQ: compile: | ")),this},writable:!0,configurable:!0},dump:{value:function(){return this.ast.dump()},writable:!0,configurable:!0},execute:{value:function(t,e,r,n,s){s&&console.log("ASTQ: execute: +--------------------------------------------------------------+----------------------------------------");var u=new ASTQQueryExec(e,r,n,s);return u.execQuery(this.ast,t)},writable:!0,configurable:!0}}),t}();module.exports=ASTQQuery; | ||
},{"./astq-query-exec.js":10,"asty":1,"pegjs-util":2}],13:[function(_dereq_,module,exports){ | ||
"use strict";var ASTQUtil={pad:function(e,r){return 0>r?e.length>-r?e.substr(0,-r):e+Array(-r+1-e.length).join(" "):e.length>r?e.substr(0,r):Array(r+1-e.length).join(" ")+e},truthy:function(e){var r=void 0;switch(typeof e){case"boolean":r=e;break;case"number":r=0!==e&&!isNaN(e);break;case"string":r=""!==e;break;case"object":r=!1,null!==e&&(r=!0,e instanceof Array&&(r=e.length>0));break;default:r=!1}return r},coerce:function(e,r){var t=void 0;try{switch(r){case"boolean":t=Boolean(e);break;case"number":t=Number(e);break;case"string":t=String(e);break;case"regexp":t=new RegExp(e);break;default:t=e}}catch(a){throw new Error("cannot coerce value into type "+r)}return t}};module.exports=ASTQUtil; | ||
"use strict";var ASTQUtil={pad:function e(r,t){var a=0>t?-t:t;if(r.length>a)r=r.substr(0,a);else{var e=Array(a+1-r.length).join(" ");r=0>t?r+e:e+r}return r},truthy:function(e){var r=void 0;switch(typeof e){case"boolean":r=e;break;case"number":r=0!==e&&!isNaN(e);break;case"string":r=""!==e;break;case"object":r=!1,null!==e&&(r=!0,e instanceof Array&&(r=e.length>0));break;default:r=!1}return r},coerce:function(e,r){if(typeof e!==r)try{switch(r){case"boolean":e=Boolean(e);break;case"number":e=Number(e);break;case"string":e=String(e);break;case"regexp":e=new RegExp(e)}}catch(t){throw new Error("cannot coerce value into type "+r)}return e}};module.exports=ASTQUtil; | ||
},{}],14:[function(_dereq_,module,exports){ | ||
"use strict";var _prototypeProperties=function(e,r,t){r&&Object.defineProperties(e,r),t&&Object.defineProperties(e.prototype,t)},ASTQAdapter=_dereq_("./astq-adapter.js"),ASTQAdapterASTY=_dereq_("./astq-adapter-asty.js"),ASTQAdapterMOZAST=_dereq_("./astq-adapter-xmldom.js"),ASTQAdapterXMLDOM=_dereq_("./astq-adapter-xmldom.js"),ASTQFuncs=_dereq_("./astq-funcs.js"),ASTQFuncsSTD=_dereq_("./astq-funcs-std.js"),ASTQCache=_dereq_("./astq-cache.js"),ASTQQuery=_dereq_("./astq-query.js"),ASTQ=function(){function e(){if(!(this instanceof e))return new e;this._adapter=new ASTQAdapter,this._funcs=new ASTQFuncs,this._cache=new ASTQCache,this._adapter.register(ASTQAdapterMOZAST),this._adapter.register(ASTQAdapterXMLDOM),this._adapter.register(ASTQAdapterASTY);for(var r in ASTQFuncsSTD)this.func(r,ASTQFuncsSTD[r])}return _prototypeProperties(e,null,{adapter:{value:function r(r){if(1!==arguments.length)throw new Error("ASTQ#adapter: invalid number of arguments");return this._adapter.unregister(),this._adapter.register(r),this},writable:!0,configurable:!0},func:{value:function t(e,t){if(2!==arguments.length)throw new Error("ASTQ#func: invalid number of arguments");return this._funcs.register(e,t),this},writable:!0,configurable:!0},cache:{value:function(e){if(1!==arguments.length)throw new Error("ASTQ#cache: invalid number of arguments");return this._cache.limit(e),this},writable:!0,configurable:!0},compile:{value:function(e,r){if(arguments.length<1)throw new Error("ASTQ#compile: too less arguments");if(arguments.length>2)throw new Error("ASTQ#compile: too many arguments");void 0===r&&(r=!1);var t=this._cache.get(e);return void 0===t&&(t=new ASTQQuery,t.compile(e,r),this._cache.set(e,t)),t},writable:!0,configurable:!0},execute:{value:function(e,r,t,n){if(arguments.length<2)throw new Error("ASTQ#execute: too less arguments");if(arguments.length>4)throw new Error("ASTQ#execute: too many arguments");void 0===t&&(t={}),void 0===n&&(n=!1);var a=this._adapter.select(e);if(void 0===a)throw new Error("ASTQ#execute: no suitable adapter found for node");return r.execute(e,a,t,this._funcs,n)},writable:!0,configurable:!0},query:{value:function(e,r,t,n){if(arguments.length<2)throw new Error("ASTQ#query: too less arguments");if(arguments.length>4)throw new Error("ASTQ#query: too many arguments");return void 0===t&&(t={}),void 0===n&&(n=!1),this.execute(e,this.compile(r,n),t,n)},writable:!0,configurable:!0}}),e}();module.exports=ASTQ; | ||
},{"./astq-adapter-asty.js":3,"./astq-adapter-xmldom.js":5,"./astq-adapter.js":6,"./astq-cache.js":7,"./astq-funcs-std.js":8,"./astq-funcs.js":9,"./astq-query.js":12}]},{},[3,4,5,6,7,8,9,10,11,12,13,14])(14) | ||
"use strict";var version={major:1,minor:1,micro:0,date:20150201};module.exports=version; | ||
},{}],15:[function(_dereq_,module,exports){ | ||
"use strict";var _interopRequire=function(e){return e&&e.__esModule?e["default"]:e},_prototypeProperties=function(e,r,t){r&&Object.defineProperties(e,r),t&&Object.defineProperties(e.prototype,t)},ASTQAdapter=_interopRequire(_dereq_("./astq-adapter.js")),ASTQAdapterASTY=_interopRequire(_dereq_("./astq-adapter-asty.js")),ASTQAdapterMOZAST=_interopRequire(_dereq_("./astq-adapter-mozast.js")),ASTQAdapterXMLDOM=_interopRequire(_dereq_("./astq-adapter-xmldom.js")),ASTQFuncs=_interopRequire(_dereq_("./astq-funcs.js")),ASTQFuncsSTD=_interopRequire(_dereq_("./astq-funcs-std.js")),ASTQCache=_interopRequire(_dereq_("./astq-cache.js")),ASTQQuery=_interopRequire(_dereq_("./astq-query.js")),ASTQVersion=_interopRequire(_dereq_("./astq-version.js")),ASTQ=function(){function e(){this._adapter=new ASTQAdapter,this._adapter.register(ASTQAdapterMOZAST),this._adapter.register(ASTQAdapterXMLDOM),this._adapter.register(ASTQAdapterASTY),this._funcs=new ASTQFuncs;for(var e in ASTQFuncsSTD)this.func(e,ASTQFuncsSTD[e]);this._cache=new ASTQCache}return _prototypeProperties(e,null,{version:{value:function(){return ASTQVersion},writable:!0,configurable:!0},adapter:{value:function r(r){if(1!==arguments.length)throw new Error("ASTQ#adapter: invalid number of arguments");return this._adapter.unregister(),this._adapter.register(r),this},writable:!0,configurable:!0},func:{value:function t(e,t){if(2!==arguments.length)throw new Error("ASTQ#func: invalid number of arguments");return this._funcs.register(e,t),this},writable:!0,configurable:!0},cache:{value:function(e){if(1!==arguments.length)throw new Error("ASTQ#cache: invalid number of arguments");return this._cache.limit(e),this},writable:!0,configurable:!0},compile:{value:function(e,r){if(arguments.length<1)throw new Error("ASTQ#compile: too less arguments");if(arguments.length>2)throw new Error("ASTQ#compile: too many arguments");void 0===r&&(r=!1);var t=this._cache.get(e);return void 0===t&&(t=new ASTQQuery,t.compile(e,r),this._cache.set(e,t)),t},writable:!0,configurable:!0},execute:{value:function(e,r,t,i){if(arguments.length<2)throw new Error("ASTQ#execute: too less arguments");if(arguments.length>4)throw new Error("ASTQ#execute: too many arguments");void 0===t&&(t={}),void 0===i&&(i=!1);var n=this._adapter.select(e);if(void 0===n)throw new Error("ASTQ#execute: no suitable adapter found for node");return r.execute(e,n,t,this._funcs,i)},writable:!0,configurable:!0},query:{value:function(e,r,t,i){if(arguments.length<2)throw new Error("ASTQ#query: too less arguments");if(arguments.length>4)throw new Error("ASTQ#query: too many arguments");return void 0===t&&(t={}),void 0===i&&(i=!1),this.execute(e,this.compile(r,i),t,i)},writable:!0,configurable:!0}}),e}();module.exports=ASTQ; | ||
},{"./astq-adapter-asty.js":3,"./astq-adapter-mozast.js":4,"./astq-adapter-xmldom.js":5,"./astq-adapter.js":6,"./astq-cache.js":7,"./astq-funcs-std.js":8,"./astq-funcs.js":9,"./astq-query.js":12,"./astq-version.js":14}]},{},[3,4,5,6,7,8,9,10,11,12,13,14,15])(15) | ||
}); | ||
@@ -62,0 +64,0 @@ |
{ | ||
"name": "astq", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "Abstract Syntax Tree (AST) Query Engine", | ||
@@ -38,4 +38,5 @@ "keywords": [ "abstract", "syntax", "tree", "query", "engine", "adaptable" ], | ||
"browserify-header": "~0.9.1", | ||
"browserify-derequire": "~0.9.1" | ||
"browserify-derequire": "~0.9.1", | ||
"browserify-replace": "~0.9.0" | ||
} | ||
} |
@@ -82,3 +82,3 @@ | ||
axis ::= "//" | "/" | "~~>" | "~>" | "<~~" | "<~" | "~~^" | "~^" | ||
axis ::= "//" | "/" | "+//" | "+/" | "-//" | "-/" | "../" | "..//" | ||
match ::= id | "*" | ||
@@ -160,2 +160,5 @@ filter ::= "[" expr "]" | ||
- `ASTQ#version(): { major: Number, minor: Number, micro: Number, date: Number }`:<br/> | ||
Return the current ASTq library version details. | ||
- `ASTQ#func(name: String, func: (adapter: Adapter, node: Object, [...]) => Any): ASTQ`:<br/> | ||
@@ -166,4 +169,4 @@ Register function named `name` by providing the callback `func` which has | ||
/* the built-in implementation for "type" */ | ||
astq.func("type", function (adapter, node) => { | ||
/* the built-in implementation for "depth" */ | ||
astq.func("depth", function (adapter, node) => { | ||
var depth = 1 | ||
@@ -170,0 +173,0 @@ while ((node = adapter.getParentNode(node)) !== null) |
@@ -49,3 +49,3 @@ /* | ||
module.exports = ASTQAdapterASTY | ||
export default ASTQAdapterASTY | ||
@@ -79,3 +79,3 @@ /* | ||
module.exports = ASTQAdapterMozAST | ||
export default ASTQAdapterMozAST | ||
@@ -54,3 +54,3 @@ /* | ||
module.exports = ASTQAdapterXMLDOM | ||
export default ASTQAdapterXMLDOM | ||
@@ -25,3 +25,3 @@ /* | ||
class ASTQAdapter { | ||
export default class ASTQAdapter { | ||
constructor () { | ||
@@ -55,3 +55,1 @@ this._adapters = [] | ||
module.exports = ASTQAdapter | ||
@@ -25,3 +25,4 @@ /* | ||
class ASTQCache { | ||
export default class ASTQCache { | ||
/* create LRU cache instance */ | ||
constructor () { | ||
@@ -38,2 +39,4 @@ this._index = {} | ||
} | ||
/* get or set the cache limit */ | ||
limit (max) { | ||
@@ -47,2 +50,4 @@ let maxOld = this._max | ||
} | ||
/* configure function to be called before item is disposed */ | ||
dispose (cb) { | ||
@@ -52,11 +57,19 @@ this._dispose = cb | ||
} | ||
/* get number of items */ | ||
length () { | ||
return this._cur | ||
} | ||
/* get keys of all items in order */ | ||
keys () { | ||
return this.each(function (val, key) { this.push(key) }, []) | ||
} | ||
/* get values of all items in order */ | ||
values () { | ||
return this.each(function (val /*, key */) { this.push(val) }, []) | ||
} | ||
/* iterate over all items in order */ | ||
each (cb, ctx) { | ||
@@ -73,2 +86,4 @@ if (arguments < 2) | ||
} | ||
/* check whether item exists under key */ | ||
has (key) { | ||
@@ -78,2 +93,4 @@ let bucket = this._index[key] | ||
} | ||
/* get value under key without promoting item */ | ||
peek (key) { | ||
@@ -89,2 +106,4 @@ let bucket = this._index[key] | ||
} | ||
/* explicity promote item under key */ | ||
touch (key) { | ||
@@ -96,2 +115,4 @@ let bucket = this._index[key] | ||
} | ||
/* get value under key */ | ||
get (key) { | ||
@@ -102,2 +123,4 @@ let val = this.peek(key) | ||
} | ||
/* set value under key */ | ||
set (key, val, expires) { | ||
@@ -131,2 +154,4 @@ if (arguments.length < 3) | ||
} | ||
/* delete item under key */ | ||
del (key) { | ||
@@ -142,2 +167,4 @@ let bucket = this._index[key] | ||
} | ||
/* delete all items */ | ||
clear () { | ||
@@ -148,2 +175,4 @@ while (this._cur > 0) | ||
} | ||
/* INTERNAL: purge all LRU items above limit */ | ||
_purge () { | ||
@@ -153,2 +182,4 @@ while (this._cur > this._max) | ||
} | ||
/* INTERNAL: promote item */ | ||
_promote (bucket) { | ||
@@ -159,4 +190,5 @@ /* promote bucket to be MRU bucket */ | ||
} | ||
/* INTERNAL: detach bucket from list */ | ||
_detach (bucket) { | ||
/* detach bucket from list */ | ||
bucket.older.newer = bucket.newer | ||
@@ -167,4 +199,5 @@ bucket.newer.older = bucket.older | ||
} | ||
/* INTERNAL: attach bucket to list as MRU bucket */ | ||
_attach (bucket) { | ||
/* attach bucket to list as MRU bucket */ | ||
bucket.older = this._newHead.older | ||
@@ -177,3 +210,1 @@ bucket.newer = this._newHead | ||
module.exports = ASTQCache | ||
@@ -109,2 +109,2 @@ /* | ||
module.exports = stdfuncs | ||
export default stdfuncs |
@@ -25,3 +25,3 @@ /* | ||
class ASTQFuncs { | ||
export default class ASTQFuncs { | ||
constructor () { | ||
@@ -42,2 +42,1 @@ this._funcs = {} | ||
module.exports = ASTQFuncs |
@@ -25,6 +25,6 @@ /* | ||
let util = require("./astq-util.js") | ||
let ASTQQueryTrace = require("./astq-query-trace.js") | ||
import util from "./astq-util.js" | ||
import ASTQQueryTrace from "./astq-query-trace.js" | ||
let ASTQQueryExec = class ASTQQueryExec extends ASTQQueryTrace { | ||
export default class ASTQQueryExec extends ASTQQueryTrace { | ||
constructor (adapter, params, funcs, trace) { | ||
@@ -110,3 +110,3 @@ this.adapter = adapter | ||
} | ||
else if (op === "<~") { | ||
else if (op === "-/") { | ||
/* direct left sibling */ | ||
@@ -125,3 +125,3 @@ let parent = this.adapter.getParentNode(T) | ||
} | ||
else if (op === "<~~") { | ||
else if (op === "-//") { | ||
/* transitive left siblings */ | ||
@@ -138,3 +138,3 @@ let parent = this.adapter.getParentNode(T) | ||
} | ||
else if (op === "~>") { | ||
else if (op === "+/") { | ||
/* direct right sibling */ | ||
@@ -154,3 +154,3 @@ let parent = this.adapter.getParentNode(T) | ||
} | ||
else if (op === "~~>") { | ||
else if (op === "+//") { | ||
/* transitive right siblings */ | ||
@@ -171,3 +171,3 @@ let parent = this.adapter.getParentNode(T) | ||
} | ||
else if (op === "~^") { | ||
else if (op === "../") { | ||
/* direct parent */ | ||
@@ -178,3 +178,3 @@ let parent = this.adapter.getParentNode(T) | ||
} | ||
else if (op === "~~^") { | ||
else if (op === "..//") { | ||
/* transitive parents */ | ||
@@ -401,2 +401,1 @@ let node = T | ||
module.exports = ASTQQueryExec |
@@ -25,5 +25,6 @@ /* | ||
let util = require("./astq-util.js") | ||
import util from "./astq-util.js" | ||
let ASTQQueryTrace = class ASTQQueryTrace { | ||
export default class ASTQQueryTrace { | ||
/* determine output prefix based on tree depth */ | ||
prefixOf (Q, T) { | ||
@@ -43,2 +44,3 @@ let depth = 0 | ||
/* begin tracing step */ | ||
traceBegin (Q, T) { | ||
@@ -53,2 +55,3 @@ if (!this.trace) | ||
/* end tracing step */ | ||
traceEnd (Q, T, val) { | ||
@@ -78,2 +81,1 @@ if (!this.trace) | ||
module.exports = ASTQQueryTrace |
@@ -28,2 +28,3 @@ /* | ||
/* load external dependencies */ | ||
let ASTY = require("asty") | ||
@@ -33,2 +34,3 @@ let PEG = require("pegjs-otf") | ||
/* get query parser (by loading and on-the-fly compiling PEG.js grammar) */ | ||
let ASTQQueryParse = PEG.buildParserFromFile( | ||
@@ -39,5 +41,7 @@ __dirname + "/astq-query-parse.pegjs", | ||
let ASTQQueryExec = require("./astq-query-exec.js") | ||
/* get query executor */ | ||
import ASTQQueryExec from "./astq-query-exec.js" | ||
let ASTQQuery = class ASTQQuery { | ||
export default class ASTQQuery { | ||
/* create a new instance of the query instance */ | ||
constructor (selector) { | ||
@@ -49,2 +53,4 @@ this.asty = new ASTY() | ||
} | ||
/* compile query selector into AST */ | ||
compile (selector, trace) { | ||
@@ -69,5 +75,9 @@ if (trace) | ||
} | ||
/* dump the query AST */ | ||
dump () { | ||
return this.ast.dump() | ||
} | ||
/* execute the query AST onto node */ | ||
execute (node, adapter, params, funcs, trace) { | ||
@@ -81,3 +91,1 @@ if (trace) | ||
module.exports = ASTQQuery | ||
@@ -26,8 +26,15 @@ /* | ||
let ASTQUtil = { | ||
/* pad a string with spaces to the left/right */ | ||
pad (str, num) { | ||
if (num < 0) | ||
return (str.length > -num ? str.substr(0, -num) : (str + Array((-num) + 1 - str.length).join(" "))) | ||
else | ||
return (str.length > num ? str.substr(0, num) : Array(num + 1 - str.length).join(" ") + str) | ||
let n = num < 0 ? -num : num | ||
if (str.length > n) | ||
str = str.substr(0, n) | ||
else { | ||
let pad = Array((n + 1) - str.length).join(" ") | ||
str = num < 0 ? (str + pad) : (pad + str) | ||
} | ||
return str | ||
}, | ||
/* check whether value is "true" (or can be considered to be true) */ | ||
truthy (value) { | ||
@@ -50,3 +57,3 @@ let result | ||
if (value instanceof Array) | ||
result = (value.length > 0) | ||
result = value.length > 0 | ||
} | ||
@@ -59,29 +66,31 @@ break | ||
}, | ||
/* coerce value to particular type */ | ||
coerce (value, type) { | ||
let result | ||
try { | ||
switch (type) { | ||
case "boolean": | ||
result = Boolean(value) | ||
break | ||
case "number": | ||
result = Number(value) | ||
break | ||
case "string": | ||
result = String(value) | ||
break | ||
case "regexp": | ||
result = new RegExp(value) | ||
break | ||
default: | ||
result = value | ||
if (typeof value !== type) { | ||
try { | ||
switch (type) { | ||
case "boolean": | ||
value = Boolean(value) | ||
break | ||
case "number": | ||
value = Number(value) | ||
break | ||
case "string": | ||
value = String(value) | ||
break | ||
case "regexp": | ||
value = new RegExp(value) | ||
break | ||
} | ||
} | ||
catch (e) { | ||
throw new Error("cannot coerce value into type " + type) | ||
} | ||
} | ||
catch (e) { | ||
throw new Error("cannot coerce value into type " + type) | ||
} | ||
return result | ||
return value | ||
} | ||
} | ||
module.exports = ASTQUtil | ||
export default ASTQUtil | ||
@@ -25,24 +25,38 @@ /* | ||
let ASTQAdapter = require("./astq-adapter.js") | ||
let ASTQAdapterASTY = require("./astq-adapter-asty.js") | ||
let ASTQAdapterMOZAST = require("./astq-adapter-xmldom.js") | ||
let ASTQAdapterXMLDOM = require("./astq-adapter-xmldom.js") | ||
let ASTQFuncs = require("./astq-funcs.js") | ||
let ASTQFuncsSTD = require("./astq-funcs-std.js") | ||
let ASTQCache = require("./astq-cache.js") | ||
let ASTQQuery = require("./astq-query.js") | ||
/* load internal dependencies */ | ||
import ASTQAdapter from "./astq-adapter.js" | ||
import ASTQAdapterASTY from "./astq-adapter-asty.js" | ||
import ASTQAdapterMOZAST from "./astq-adapter-mozast.js" | ||
import ASTQAdapterXMLDOM from "./astq-adapter-xmldom.js" | ||
import ASTQFuncs from "./astq-funcs.js" | ||
import ASTQFuncsSTD from "./astq-funcs-std.js" | ||
import ASTQCache from "./astq-cache.js" | ||
import ASTQQuery from "./astq-query.js" | ||
import ASTQVersion from "./astq-version.js" | ||
let ASTQ = class ASTQ { | ||
/* define the API class */ | ||
export default class ASTQ { | ||
/* create a new ASTq instance */ | ||
constructor () { | ||
if (!(this instanceof ASTQ)) | ||
return new ASTQ() | ||
/* create adapter registry and pre-register standard adapters */ | ||
this._adapter = new ASTQAdapter() | ||
this._funcs = new ASTQFuncs() | ||
this._cache = new ASTQCache() | ||
this._adapter.register(ASTQAdapterMOZAST) | ||
this._adapter.register(ASTQAdapterXMLDOM) | ||
this._adapter.register(ASTQAdapterASTY) | ||
/* create function registry and pre-register standard functions */ | ||
this._funcs = new ASTQFuncs() | ||
for (let name in ASTQFuncsSTD) | ||
this.func(name, ASTQFuncsSTD[name]) | ||
/* create LRU cache */ | ||
this._cache = new ASTQCache() | ||
} | ||
/* return the version information */ | ||
version () { | ||
return ASTQVersion | ||
} | ||
/* switch to a custom adapter */ | ||
adapter (adapter) { | ||
@@ -55,2 +69,4 @@ if (arguments.length !== 1) | ||
} | ||
/* register an additional function */ | ||
func (name, func) { | ||
@@ -62,2 +78,4 @@ if (arguments.length !== 2) | ||
} | ||
/* configure the LRU cache limit */ | ||
cache (entries) { | ||
@@ -69,2 +87,4 @@ if (arguments.length !== 1) | ||
} | ||
/* individual step 1: compile selector DSL into a query AST */ | ||
compile (selector, trace) { | ||
@@ -85,2 +105,4 @@ if (arguments.length < 1) | ||
} | ||
/* individual step 2: execute query AST onto node */ | ||
execute (node, query, params, trace) { | ||
@@ -100,2 +122,4 @@ if (arguments.length < 2) | ||
} | ||
/* all-in-one step: execute selector DSL onto node */ | ||
query (node, selector, params, trace) { | ||
@@ -114,3 +138,1 @@ if (arguments.length < 2) | ||
module.exports = ASTQ | ||
@@ -33,7 +33,15 @@ /* | ||
var astq = new ASTQ(); | ||
expect(astq).to.respondTo("version") | ||
expect(astq).to.respondTo("adapter") | ||
expect(astq).to.respondTo("func") | ||
expect(astq).to.respondTo("cache") | ||
expect(astq).to.respondTo("compile") | ||
expect(astq).to.respondTo("execute") | ||
expect(astq).to.respondTo("query") | ||
expect(astq.version()).to.have.property("major") | ||
expect(astq.version()).to.have.property("minor") | ||
expect(astq.version()).to.have.property("micro") | ||
expect(astq.version()).to.have.property("date") | ||
astq.func("add", function (a, b) { return a + b }) | ||
@@ -62,4 +70,4 @@ | ||
expect(astq.query(node1, "// * [ @foo == 'bar' ]")).to.have.members([ node6 ]) | ||
expect(astq.query(node1, "// * [ @foo == 'bar' ] ~~> * [ @quux == 'baz' ]")).to.have.members([ node7 ]) | ||
expect(astq.query(node1, "// * [ @foo == 'bar' && ~~> * [ @quux == 'baz' ] ]")).to.have.members([ node6 ]) | ||
expect(astq.query(node1, "// * [ @foo == 'bar' ] +// * [ @quux == 'baz' ]")).to.have.members([ node7 ]) | ||
expect(astq.query(node1, "// * [ @foo == 'bar' && +// * [ @quux == 'baz' ] ]")).to.have.members([ node6 ]) | ||
expect(astq.query(node1, "// * [ pos() <= 1 ]")).to.have.members([ node2, node5 ]) | ||
@@ -66,0 +74,0 @@ expect(astq.query(node1, "// * [ count(/*) == 3 ]")).to.have.members([ node3 ]) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
442029
27
6890
263
12