From 32a868bd1cff206ac04c99100021e7cff0f18ed2 Mon Sep 17 00:00:00 2001 From: Samu Lang Date: Sun, 11 Apr 2021 20:42:49 +0100 Subject: [PATCH] Make sparqljs dependency internal sparqlToBlockly now takes a string --- demo/src/SparqlEditor.ts | 13 +++++-------- docs/app.js | 2 +- package/index.d.ts | 2 +- package/package-lock.json | 4 ++-- package/package.json | 2 +- package/src/index.ts | 7 +++++-- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/demo/src/SparqlEditor.ts b/demo/src/SparqlEditor.ts index 353f3dba..bcd20a14 100644 --- a/demo/src/SparqlEditor.ts +++ b/demo/src/SparqlEditor.ts @@ -1,5 +1,4 @@ -import * as SparqlJS from "sparqljs" -import * as SparqlBlockly from "sparql-blockly" +import * as SparqlBlockly from "sparql-blockly" export class SparqlEditor extends HTMLElement { private async connectedCallback() { @@ -36,11 +35,11 @@ export class SparqlEditor extends HTMLElement { const query = this.validate() if (query) { - this.dispatchEvent(new CustomEvent("sparql", { detail: SparqlBlockly.sparqlToBlockly(query) })) + this.dispatchEvent(new CustomEvent("sparql", { detail: query })) } } - private validate(): SparqlJS.SparqlQuery { + private validate(): Element { this.error = "" this.classList.remove("invalid") this.classList.remove("valid") @@ -48,14 +47,12 @@ export class SparqlEditor extends HTMLElement { const sparql = this.value if (sparql) { - const parser = new SparqlJS.Parser({ sparqlStar: true }) - try { - const query = parser.parse(sparql) + const blocklyDom = SparqlBlockly.sparqlToBlockly(sparql) this.classList.add("valid") - return query + return blocklyDom } catch (e) { this.error = e.message diff --git a/docs/app.js b/docs/app.js index fd34837e..0f32baae 100644 --- a/docs/app.js +++ b/docs/app.js @@ -1 +1 @@ -(()=>{var e={640:function(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r),Object.defineProperty(e,i,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),s=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||i(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),s(r(970),t),s(r(498),t),s(r(381),t),s(r(808),t),s(r(16),t),s(r(387),t),s(r(573),t)},970:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BlankNode=void 0,t.BlankNode=class{constructor(e){this.termType="BlankNode",this.value=e}equals(e){return!!e&&"BlankNode"===e.termType&&e.value===this.value}}},498:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DataFactory=void 0;const i=r(970),s=r(381),a=r(808),n=r(16),o=r(387),u=r(573);let c=0;t.DataFactory=class{constructor(e){this.blankNodeCounter=0,e=e||{},this.blankNodePrefix=e.blankNodePrefix||`df_${c++}_`}namedNode(e){return new n.NamedNode(e)}blankNode(e){return new i.BlankNode(e||`${this.blankNodePrefix}${this.blankNodeCounter++}`)}literal(e,t){return new a.Literal(e,t)}variable(e){return new u.Variable(e)}defaultGraph(){return s.DefaultGraph.INSTANCE}quad(e,t,r,i){return new o.Quad(e,t,r,i||this.defaultGraph())}fromTerm(e){switch(e.termType){case"NamedNode":return this.namedNode(e.value);case"BlankNode":return this.blankNode(e.value);case"Literal":return e.language?this.literal(e.value,e.language):e.datatype.equals(a.Literal.XSD_STRING)?this.literal(e.value):this.literal(e.value,this.fromTerm(e.datatype));case"Variable":return this.variable(e.value);case"DefaultGraph":return this.defaultGraph();case"Quad":return this.quad(this.fromTerm(e.subject),this.fromTerm(e.predicate),this.fromTerm(e.object),this.fromTerm(e.graph))}}fromQuad(e){return this.fromTerm(e)}resetBlankNodeCounter(){this.blankNodeCounter=0}}},381:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultGraph=void 0;class r{constructor(){this.termType="DefaultGraph",this.value=""}equals(e){return!!e&&"DefaultGraph"===e.termType}}t.DefaultGraph=r,r.INSTANCE=new r},808:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Literal=void 0;const i=r(16);class s{constructor(e,t){this.termType="Literal",this.value=e,"string"==typeof t?(this.language=t,this.datatype=s.RDF_LANGUAGE_STRING):t?(this.language="",this.datatype=t):(this.language="",this.datatype=s.XSD_STRING)}equals(e){return!!e&&"Literal"===e.termType&&e.value===this.value&&e.language===this.language&&e.datatype.equals(this.datatype)}}t.Literal=s,s.RDF_LANGUAGE_STRING=new i.NamedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#langString"),s.XSD_STRING=new i.NamedNode("http://www.w3.org/2001/XMLSchema#string")},16:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NamedNode=void 0,t.NamedNode=class{constructor(e){this.termType="NamedNode",this.value=e}equals(e){return!!e&&"NamedNode"===e.termType&&e.value===this.value}}},387:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Quad=void 0,t.Quad=class{constructor(e,t,r,i){this.termType="Quad",this.value="",this.subject=e,this.predicate=t,this.object=r,this.graph=i}equals(e){return!!e&&("Quad"===e.termType||!e.termType)&&this.subject.equals(e.subject)&&this.predicate.equals(e.predicate)&&this.object.equals(e.object)&&this.graph.equals(e.graph)}}},573:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Variable=void 0,t.Variable=class{constructor(e){this.termType="Variable",this.value=e}equals(e){return!!e&&"Variable"===e.termType&&e.value===this.value}}},404:e=>{function t(e){this._options=e=e||{};var t=e.prefixes||{};this._prefixByIri={};var r=[];for(var i in t){var s=t[i];n(s)&&(this._prefixByIri[s]=i,r.push(s))}var a=r.join("|").replace(/[\]\/\(\)\*\+\?\.\\\$]/g,"\\$&");this._prefixRegex=new RegExp("^("+a+")([a-zA-Z][\\-_a-zA-Z0-9]*)$"),this._usedPrefixes={},this._sparqlStar=e.sparqlStar,this._indent=n(e.indent)?e.indent:" ",this._newline=n(e.newline)?e.newline:"\n",this._explicitDatatype=Boolean(e.explicitDatatype)}t.prototype.toQuery=function(e){var t="";return e.queryType&&(t+=e.queryType.toUpperCase()+" "),e.reduced&&(t+="REDUCED "),e.distinct&&(t+="DISTINCT "),e.variables?t+=c(e.variables,void 0,(function(e){return o(e)?this.toEntity(e):"("+this.toExpression(e.expression)+" AS "+a(e.variable)+")"}),this)+" ":e.template&&(t+=this.group(e.template,!0)+this._newline),e.from&&(t+=this.graphs("FROM ",e.from.default)+this.graphs("FROM NAMED ",e.from.named)),e.where&&(t+="WHERE "+this.group(e.where,!0)+this._newline),e.updates&&(t+=c(e.updates,";"+this._newline,this.toUpdate,this)),e.group&&(t+="GROUP BY "+c(e.group,void 0,(function(e){var t=n(e.expression)?e.expression:"("+this.toExpression(e.expression)+")";return e.variable?"("+t+" AS "+a(e.variable)+")":t}),this)+this._newline),e.having&&(t+="HAVING ("+c(e.having,void 0,this.toExpression,this)+")"+this._newline),e.order&&(t+="ORDER BY "+c(e.order,void 0,(function(e){var t="("+this.toExpression(e.expression)+")";return e.descending?"DESC "+t:t}),this)+this._newline),e.offset&&(t+="OFFSET "+e.offset+this._newline),e.limit&&(t+="LIMIT "+e.limit+this._newline),e.values&&(t+=this.values(e)),(t=this.baseAndPrefixes(e)+t).trim()},t.prototype.baseAndPrefixes=function(e){var t=e.base?"BASE <"+e.base+">"+this._newline:"",r="";for(var i in e.prefixes)(this._options.allPrefixes||this._usedPrefixes[i])&&(r+="PREFIX "+i+": <"+e.prefixes[i]+">"+this._newline);return t+r},t.prototype.toPattern=function(e){var t=e.type||e instanceof Array&&"array"||(e.subject&&e.predicate&&e.object?"triple":"");if(!(t in this))throw new Error("Unknown entry type: "+t);return this[t](e)},t.prototype.triple=function(e){return this.toEntity(e.subject)+" "+this.toEntity(e.predicate)+" "+this.toEntity(e.object)+"."},t.prototype.array=function(e){return c(e,this._newline,this.toPattern,this)},t.prototype.bgp=function(e){return this.encodeTriples(e.triples)},t.prototype.encodeTriples=function(e){if(!e.length)return"";for(var t=[],r=void 0,i=void 0,s=0;s":case">=":case"<=":case"&&":case"||":case"=":case"!=":case"+":case"-":case"*":case"/":return(o(s[0])?this.toEntity(s[0]):"("+this.toExpression(s[0])+")")+" "+t+" "+(o(s[1])?this.toEntity(s[1]):"("+this.toExpression(s[1])+")");case"!":return"!("+this.toExpression(s[0])+")";case"uminus":return"-("+this.toExpression(s[0])+")";case"notin":t="NOT IN";case"in":return this.toExpression(s[0])+" "+t+"("+(n(s[1])?s[1]:c(s[1],", ",this.toExpression,this))+")";case"notexists":t="NOT EXISTS";case"exists":return t+" "+this.group(s[0],!0);default:return t+"("+c(s,", ",this.toExpression,this)+")"}default:throw new Error("Unknown expression type: "+e.type)}},t.prototype.toEntity=function(e){if(o(e))switch(e.termType){case"Wildcard":return"*";case"Variable":return a(e);case"BlankNode":return"_:"+e.value;case"Literal":var t=e.value||"",s=e.language||"",n=e.datatype;if(e='"'+t.replace(r,i)+'"',s)e+="@"+s;else if(n){if(!this._explicitDatatype)switch(n.value){case"http://www.w3.org/2001/XMLSchema#string":return e;case"http://www.w3.org/2001/XMLSchema#integer":if(/^\d+$/.test(t))return t+" "}e+="^^"+this.encodeIRI(n.value)}return e;case"Quad":if(!this._sparqlStar)throw new Error("SPARQL* support is not enabled");return e.graph&&"DefaultGraph"!==e.graph.termType?"<< GRAPH "+this.toEntity(e.graph)+" { "+this.toEntity(e.subject)+" "+this.toEntity(e.predicate)+" "+this.toEntity(e.object)+" } >>":"<< "+this.toEntity(e.subject)+" "+this.toEntity(e.predicate)+" "+this.toEntity(e.object)+" >>";default:return this.encodeIRI(e.value)}else{var u=e.items.map(this.toEntity,this),c=e.pathType;switch(c){case"^":case"!":return c+u[0];case"*":case"+":case"?":return"("+u[0]+c+")";default:return"("+u.join(c)+")"}}};var r=/["\\\t\n\r\b\f]/g,i=function(e){return s[e]},s={"\\":"\\\\",'"':'\\"',"\t":"\\t","\n":"\\n","\r":"\\r","\b":"\\b","\f":"\\f"};function a(e){return"?"+e.value}function n(e){return"string"==typeof e}function o(e){return"string"==typeof e.termType}function u(e,t){if(!e||!o(e))return!1;if(!t||!o(t))return!1;if(e.termType!==t.termType)return!1;switch(e.termType){case"Literal":return e.value===t.value&&e.language===t.language&&u(e.datatype,t.datatype);case"Quad":return u(e.subject,t.subject)&&u(e.predicate,t.predicate)&&u(e.object,t.object)&&u(e.graph,t.graph);default:return e.value===t.value}}function c(e,t,r,i){return e.map(r,i).join(n(t)?t:" ")}t.prototype.encodeIRI=function(e){var t=this._prefixRegex.exec(e);if(t){var r=this._prefixByIri[t[1]];return this._usedPrefixes[r]=!0,r+":"+t[2]}return"<"+e+">"},t.prototype.toUpdate=function(e){switch(e.type||e.updateType){case"load":return"LOAD"+(e.source?" "+this.toEntity(e.source):"")+(e.destination?" INTO GRAPH "+this.toEntity(e.destination):"");case"insert":return"INSERT DATA "+this.group(e.insert,!0);case"delete":return"DELETE DATA "+this.group(e.delete,!0);case"deletewhere":return"DELETE WHERE "+this.group(e.delete,!0);case"insertdelete":return(e.graph?"WITH "+this.toEntity(e.graph)+this._newline:"")+(e.delete.length?"DELETE "+this.group(e.delete,!0)+this._newline:"")+(e.insert.length?"INSERT "+this.group(e.insert,!0)+this._newline:"")+(e.using?this.graphs("USING ",e.using.default):"")+(e.using?this.graphs("USING NAMED ",e.using.named):"")+"WHERE "+this.group(e.where,!0);case"add":case"copy":case"move":return e.type.toUpperCase()+(e.source.default?" DEFAULT ":" ")+"TO "+this.toEntity(e.destination.name);case"create":case"clear":case"drop":return e.type.toUpperCase()+(e.silent?" SILENT ":" ")+(e.graph.default?"DEFAULT":e.graph.named?"NAMED":e.graph.all?"ALL":"GRAPH "+this.toEntity(e.graph.name));default:throw new Error("Unknown update query type: "+e.type)}},t.prototype.indent=function(e){return e.replace(/^/gm,this._indent)},e.exports=function(e={}){return{stringify:function(r){var i=Object.create(e);return i.prefixes=r.prefixes,new t(i).toQuery(r)},createGenerator:function(){return new t(e)}}}},107:(e,t,r)=>{e=r.nmd(e);var i=function(){var e=function(e,t,r,i){for(r=r||{},i=e.length;i--;r[e[i]]=t);return r},t=[6,12,15,28,41,50,55,107,117,120,122,123,132,133,138,320,321,322,323,324],i=[2,208],s=[107,117,120,122,123,132,133,138,320,321,322,323,324],a=[1,20],n=[1,29],o=[6,90],u=[45,46,58],c=[45,58],l=[1,58],p=[1,60],h=[1,56],d=[1,59],f=[1,65],y=[1,66],F=[26,34,35],E=[13,16,310],b=[119,141,318,325],_=[13,16,119,141,310],g=[1,88],D=[1,92],T=[1,94],A=[119,141,318,319,325],m=[13,16,119,141,310,319],v=[1,100],N=[2,250],k=[1,99],C=[13,16,34,35,87,93,224,229,243,244,297,298,299,300,301,302,303,304,305,306,307,308,309,310],S=[6,45,46,58,68,75,78,86,88,90],I=[6,13,16,34,45,46,58,68,75,78,86,88,90,310],L=[6,13,16,26,34,35,37,38,45,46,48,58,68,75,78,86,87,88,90,93,100,116,119,132,133,135,140,167,168,170,173,174,191,195,217,222,224,225,229,233,243,244,248,252,256,271,276,293,297,298,299,300,301,302,303,304,305,306,307,308,309,310,326,328,329,331,332,333,334,335,336,337,338],w=[34,35,45,46,58],R=[13,16,34,35,87,273,274,275,277,279,280,282,283,286,288,297,298,299,300,301,302,303,304,305,306,307,308,309,310,338,339,340,341,342,343],O=[2,451],x=[1,123],P=[1,117],$=[1,124],U=[1,125],G=[6,13,16,34,35,46,48,87,90,93,119,167,168,170,173,174,224,229,243,244,297,298,299,300,301,302,303,304,305,306,307,308,309,310,326],B=[2,309],j=[1,142],M=[1,140],V=[6,191],q=[2,326],H=[2,314],Q=[45,135],W=[6,48,78,86,88,90],z=[2,254],X=[1,156],Z=[1,158],Y=[6,48,75,78,86,88,90],K=[2,252],J=[1,164],ee=[1,176],te=[1,174],re=[1,184],ie=[1,182],se=[1,175],ae=[1,180],ne=[1,181],oe=[1,185],ue=[1,186],ce=[1,189],le=[1,190],pe=[1,191],he=[1,192],de=[1,193],fe=[1,194],ye=[1,195],Fe=[1,196],Ee=[1,197],be=[1,198],_e=[1,199],ge=[6,68,75,78,86,88,90],De=[37,38,191,248,276],Te=[37,38,191,248,252,276],Ae=[37,38,191,248,252,256,271,276,293,304,305,306,307,308,309,332,333,334,335,336,337,338],me=[26,37,38,191,248,252,256,271,276,293,304,305,306,307,308,309,329,332,333,334,335,336,337,338],ve=[1,229],Ne=[1,230],ke=[1,232],Ce=[1,233],Se=[1,234],Ie=[1,235],Le=[1,237],we=[1,238],Re=[2,458],Oe=[1,240],xe=[1,241],Pe=[1,242],$e=[1,248],Ue=[1,243],Ge=[1,244],Be=[1,245],je=[1,246],Me=[1,247],Ve=[13,16,48,87,100,229,297,298,299,300,301,302,303,304,305,306,307,308,309,310],qe=[48,93],He=[34,38],Qe=[6,116,191],We=[48,119],ze=[6,48,86,88,90],Xe=[2,338],Ze=[2,330],Ye=[1,293],Ke=[1,295],Je=[48,119,326],et=[13,16,34,195,310],tt=[13,16,34,35,38,46,48,87,90,93,119,167,168,170,173,174,191,195,217,222,224,225,229,233,243,244,276,297,298,299,300,301,302,303,304,305,306,307,308,309,310,326],rt=[13,16,26,34,35,37,38,46,48,87,90,93,100,119,167,168,170,173,174,191,195,217,222,224,225,229,233,243,244,248,252,256,271,276,293,297,298,299,300,301,302,303,304,305,306,307,308,309,310,326,329,332,333,334,335,336,337,338],it=[13,16,26,34,35,37,38,46,48,87,90,93,100,119,167,168,170,173,174,191,195,217,222,224,225,229,233,243,244,248,252,256,271,276,293,295,296,297,298,299,300,301,302,303,304,305,306,307,308,309,310,326,329,332,333,334,335,336,337,338],st=[13,16,34,35,87,217,271,273,274,275,277,279,280,282,283,286,288,297,298,299,300,301,302,303,304,305,306,307,308,309,310,332,338,339,340,341,342,343],at=[1,329],nt=[1,330],ot=[1,332],ut=[1,331],ct=[6,13,16,26,34,35,37,38,46,48,75,78,81,83,86,87,88,90,93,119,167,168,170,173,174,191,224,229,243,244,248,252,256,271,273,274,275,276,277,279,280,282,283,286,288,293,297,298,299,300,301,302,303,304,305,306,307,308,309,310,326,329,332,333,334,335,336,337,338,339,340,341,342,343],lt=[1,340],pt=[1,339],ht=[35,93],dt=[1,353],ft=[1,354],yt=[1,367],Ft=[6,48,90],Et=[6,13,16,35,48,78,86,88,90,273,274,275,277,279,280,282,283,286,288,310,338,339,340,341,342,343],bt=[6,13,16,34,35,46,48,78,81,83,86,87,88,90,93,119,167,168,170,173,174,224,229,243,244,273,274,275,277,279,280,282,283,286,288,297,298,299,300,301,302,303,304,305,306,307,308,309,310,326,338,339,340,341,342,343],_t=[46,48,90,119,167,168,170,173,174],gt=[1,386],Dt=[1,387],Tt=[1,393],At=[1,392],mt=[48,119,191,225,326],vt=[2,370],Nt=[13,16,34,35,38,87,93,224,229,243,244,297,298,299,300,301,302,303,304,305,306,307,308,309,310],kt=[13,16,34,35,38,46,48,87,90,93,119,167,168,170,173,174,191,224,225,229,243,244,276,297,298,299,300,301,302,303,304,305,306,307,308,309,310,326],Ct=[13,16,26,34,35,87,217,271,273,274,275,277,279,280,282,283,286,288,297,298,299,300,301,302,303,304,305,306,307,308,309,310,332,338,339,340,341,342,343],St=[13,16,38,48,87,100,229,297,298,299,300,301,302,303,304,305,306,307,308,309,310],It=[35,48],Lt=[2,329],wt=[1,451],Rt=[1,448],Ot=[1,449],xt=[6,13,16,26,34,35,37,38,46,48,68,75,78,81,83,86,87,88,90,93,119,167,168,170,173,174,191,224,229,243,244,248,252,256,271,273,274,275,276,277,279,280,282,283,286,288,293,297,298,299,300,301,302,303,304,305,306,307,308,309,310,326,327,329,332,333,334,335,336,337,338,339,340,341,342,343],Pt=[13,16,35,195,217,222,310],$t=[2,384],Ut=[1,469],Gt=[46,48,90,119,167,168,170,173,174,326],Bt=[13,16,34,35,195,217,222,310],jt=[6,13,16,34,35,48,75,78,86,88,90,273,274,275,277,279,280,282,283,286,288,310,338,339,340,341,342,343],Mt=[13,16,34,35,38,46,48,87,90,93,119,167,168,170,173,174,191,195,224,225,229,243,244,276,297,298,299,300,301,302,303,304,305,306,307,308,309,310,326],Vt=[6,13,16,34,35,48,81,83,86,88,90,273,274,275,277,279,280,282,283,286,288,310,338,339,340,341,342,343],qt=[13,16,34,35,46,48,87,90,93,119,167,168,170,173,174,224,229,243,244,297,298,299,300,301,302,303,304,305,306,307,308,309,310],Ht=[13,16,34,310],Qt=[13,16,34,35,46,48,87,90,93,119,167,168,170,173,174,224,229,243,244,297,298,299,300,301,302,303,304,305,306,307,308,309,310,326],Wt=[2,341],zt=[46,48,90,119,167,168,170,173,174,191,225,326],Xt=[13,16,34,35,37,38,46,48,87,90,93,119,167,168,170,173,174,191,195,217,222,224,225,229,233,243,244,276,297,298,299,300,301,302,303,304,305,306,307,308,309,310,326],Zt=[2,336],Yt=[13,16,35,195,217,310],Kt=[13,16,34,35,38,46,48,87,90,93,119,167,168,170,173,174,191,195,217,222,224,225,229,243,244,276,297,298,299,300,301,302,303,304,305,306,307,308,309,310,326],Jt=[13,16,38,87,100,229,297,298,299,300,301,302,303,304,305,306,307,308,309,310],er=[13,16,34,38,48,87,100,195,229,233,297,298,299,300,301,302,303,304,305,306,307,308,309,310],tr=[13,16,34,35,48,87,93,119,224,229,243,244,297,298,299,300,301,302,303,304,305,306,307,308,309,310],rr=[13,16,34,35,38,87,93,224,229,243,244,297,298,299,300,301,302,303,304,305,306,307,308,309,310,328,329],ir=[13,16,26,34,35,38,87,93,224,229,243,244,297,298,299,300,301,302,303,304,305,306,307,308,309,310,328,329,331,332],sr=[1,630],ar=[1,631],nr=[2,324],or=[13,16,38,195,222,310],ur={trace:function(){},yy:{},symbols_:{error:2,QueryOrUpdate:3,Prologue:4,QueryOrUpdate_group0:5,EOF:6,Prologue_repetition0:7,Query:8,Query_group0:9,Query_option0:10,BaseDecl:11,BASE:12,IRIREF:13,PrefixDecl:14,PREFIX:15,PNAME_NS:16,SelectQuery:17,SelectClauseWildcard:18,SelectQuery_repetition0:19,WhereClause:20,SolutionModifierNoGroup:21,SelectClauseVars:22,SelectQuery_repetition1:23,SolutionModifier:24,SelectClauseBase:25,"*":26,SelectClauseVars_repetition_plus0:27,SELECT:28,SelectClauseBase_option0:29,SubSelect:30,SubSelect_option0:31,SubSelect_option1:32,SelectClauseItem:33,VAR:34,"(":35,Expression:36,AS:37,")":38,VarTriple:39,ConstructQuery:40,CONSTRUCT:41,ConstructTemplate:42,ConstructQuery_repetition0:43,ConstructQuery_repetition1:44,WHERE:45,"{":46,ConstructQuery_option0:47,"}":48,DescribeQuery:49,DESCRIBE:50,DescribeQuery_group0:51,DescribeQuery_repetition0:52,DescribeQuery_option0:53,AskQuery:54,ASK:55,AskQuery_repetition0:56,DatasetClause:57,FROM:58,DatasetClause_option0:59,iri:60,WhereClause_option0:61,GroupGraphPattern:62,SolutionModifier_option0:63,SolutionModifierNoGroup_option0:64,SolutionModifierNoGroup_option1:65,SolutionModifierNoGroup_option2:66,GroupClause:67,GROUP:68,BY:69,GroupClause_repetition_plus0:70,GroupCondition:71,BuiltInCall:72,FunctionCall:73,HavingClause:74,HAVING:75,HavingClause_repetition_plus0:76,OrderClause:77,ORDER:78,OrderClause_repetition_plus0:79,OrderCondition:80,ASC:81,BrackettedExpression:82,DESC:83,Constraint:84,LimitOffsetClauses:85,LIMIT:86,INTEGER:87,OFFSET:88,ValuesClause:89,VALUES:90,InlineData:91,InlineData_repetition0:92,NIL:93,InlineData_repetition1:94,InlineData_repetition_plus2:95,InlineData_repetition3:96,DataBlockValue:97,Literal:98,ConstTriple:99,UNDEF:100,DataBlockValueList:101,DataBlockValueList_repetition_plus0:102,Update:103,Update_repetition0:104,Update1:105,Update_option0:106,LOAD:107,Update1_option0:108,Update1_option1:109,Update1_group0:110,Update1_option2:111,GraphRefAll:112,Update1_group1:113,Update1_option3:114,GraphOrDefault:115,TO:116,CREATE:117,Update1_option4:118,GRAPH:119,INSERTDATA:120,QuadPattern:121,DELETEDATA:122,DELETEWHERE:123,Update1_option5:124,InsertClause:125,Update1_option6:126,Update1_repetition0:127,Update1_option7:128,DeleteClause:129,Update1_option8:130,Update1_repetition1:131,DELETE:132,INSERT:133,UsingClause:134,USING:135,UsingClause_option0:136,WithClause:137,WITH:138,IntoGraphClause:139,INTO:140,DEFAULT:141,GraphOrDefault_option0:142,GraphRefAll_group0:143,QuadPattern_option0:144,QuadPattern_repetition0:145,QuadsNotTriples:146,QuadsNotTriples_group0:147,QuadsNotTriples_option0:148,QuadsNotTriples_option1:149,QuadsNotTriples_option2:150,TriplesTemplate:151,TriplesTemplate_repetition0:152,TriplesSameSubject:153,TriplesTemplate_option0:154,GroupGraphPatternSub:155,GroupGraphPatternSub_option0:156,GroupGraphPatternSub_repetition0:157,GroupGraphPatternSubTail:158,GraphPatternNotTriples:159,GroupGraphPatternSubTail_option0:160,GroupGraphPatternSubTail_option1:161,TriplesBlock:162,TriplesBlock_repetition0:163,TriplesSameSubjectPath:164,TriplesBlock_option0:165,GraphPatternNotTriples_repetition0:166,OPTIONAL:167,MINUS:168,GraphPatternNotTriples_group0:169,SERVICE:170,GraphPatternNotTriples_option0:171,GraphPatternNotTriples_group1:172,FILTER:173,BIND:174,FunctionCall_option0:175,FunctionCall_repetition0:176,ExpressionList:177,ExpressionList_repetition0:178,ConstructTemplate_option0:179,ConstructTriples:180,ConstructTriples_repetition0:181,ConstructTriples_option0:182,TriplesSameSubject_group0:183,PropertyListNotEmpty:184,TriplesNode:185,PropertyList:186,PropertyList_option0:187,VerbObjectList:188,PropertyListNotEmpty_repetition0:189,SemiOptionalVerbObjectList:190,";":191,SemiOptionalVerbObjectList_option0:192,Verb:193,ObjectList:194,a:195,ObjectList_repetition0:196,GraphNode:197,TriplesSameSubjectPath_group0:198,PropertyListPathNotEmpty:199,TriplesNodePath:200,TriplesSameSubjectPath_option0:201,PropertyListPathNotEmpty_group0:202,PropertyListPathNotEmpty_repetition0:203,GraphNodePath:204,PropertyListPathNotEmpty_repetition1:205,PropertyListPathNotEmptyTail:206,PropertyListPathNotEmptyTail_group0:207,Path:208,Path_repetition0:209,PathSequence:210,PathSequence_repetition0:211,PathEltOrInverse:212,PathElt:213,PathPrimary:214,PathElt_option0:215,PathEltOrInverse_option0:216,"!":217,PathNegatedPropertySet:218,PathOneInPropertySet:219,PathNegatedPropertySet_repetition0:220,PathNegatedPropertySet_option0:221,"^":222,TriplesNode_repetition_plus0:223,"[":224,"]":225,TriplesNodePath_repetition_plus0:226,GraphNode_group0:227,GraphNodePath_group0:228,"<<":229,VarTriple_group0:230,VarTriple_group1:231,VarTriple_group2:232,">>":233,VarTriple_group3:234,VarTriple_group4:235,ConstTriple_group0:236,ConstTriple_group1:237,ConstTriple_group2:238,ConstTriple_group3:239,ConstTriple_group4:240,VarOrTerm:241,Term:242,BLANK_NODE_LABEL:243,ANON:244,ConditionalAndExpression:245,Expression_repetition0:246,ExpressionTail:247,"||":248,RelationalExpression:249,ConditionalAndExpression_repetition0:250,ConditionalAndExpressionTail:251,"&&":252,AdditiveExpression:253,RelationalExpression_group0:254,RelationalExpression_option0:255,IN:256,MultiplicativeExpression:257,AdditiveExpression_repetition0:258,AdditiveExpressionTail:259,AdditiveExpressionTail_group0:260,NumericLiteralPositive:261,AdditiveExpressionTail_repetition0:262,NumericLiteralNegative:263,AdditiveExpressionTail_repetition1:264,UnaryExpression:265,MultiplicativeExpression_repetition0:266,MultiplicativeExpressionTail:267,MultiplicativeExpressionTail_group0:268,UnaryExpression_option0:269,PrimaryExpression:270,"-":271,Aggregate:272,FUNC_ARITY0:273,FUNC_ARITY1:274,FUNC_ARITY2:275,",":276,IF:277,BuiltInCall_group0:278,BOUND:279,BNODE:280,BuiltInCall_option0:281,EXISTS:282,COUNT:283,Aggregate_option0:284,Aggregate_group0:285,FUNC_AGGREGATE:286,Aggregate_option1:287,GROUP_CONCAT:288,Aggregate_option2:289,Aggregate_option3:290,GroupConcatSeparator:291,SEPARATOR:292,"=":293,String:294,LANGTAG:295,"^^":296,DECIMAL:297,DOUBLE:298,BOOLEAN:299,STRING_LITERAL1:300,STRING_LITERAL2:301,STRING_LITERAL_LONG1:302,STRING_LITERAL_LONG2:303,INTEGER_POSITIVE:304,DECIMAL_POSITIVE:305,DOUBLE_POSITIVE:306,INTEGER_NEGATIVE:307,DECIMAL_NEGATIVE:308,DOUBLE_NEGATIVE:309,PNAME_LN:310,QueryOrUpdate_group0_option0:311,Prologue_repetition0_group0:312,SelectClauseBase_option0_group0:313,DISTINCT:314,REDUCED:315,DescribeQuery_group0_repetition_plus0_group0:316,DescribeQuery_group0_repetition_plus0:317,NAMED:318,SILENT:319,CLEAR:320,DROP:321,ADD:322,MOVE:323,COPY:324,ALL:325,".":326,UNION:327,"|":328,"/":329,PathElt_option0_group0:330,"?":331,"+":332,"!=":333,"<":334,">":335,"<=":336,">=":337,NOT:338,CONCAT:339,COALESCE:340,SUBSTR:341,REGEX:342,REPLACE:343,$accept:0,$end:1},terminals_:{2:"error",6:"EOF",12:"BASE",13:"IRIREF",15:"PREFIX",16:"PNAME_NS",26:"*",28:"SELECT",34:"VAR",35:"(",37:"AS",38:")",41:"CONSTRUCT",45:"WHERE",46:"{",48:"}",50:"DESCRIBE",55:"ASK",58:"FROM",68:"GROUP",69:"BY",75:"HAVING",78:"ORDER",81:"ASC",83:"DESC",86:"LIMIT",87:"INTEGER",88:"OFFSET",90:"VALUES",93:"NIL",100:"UNDEF",107:"LOAD",116:"TO",117:"CREATE",119:"GRAPH",120:"INSERTDATA",122:"DELETEDATA",123:"DELETEWHERE",132:"DELETE",133:"INSERT",135:"USING",138:"WITH",140:"INTO",141:"DEFAULT",167:"OPTIONAL",168:"MINUS",170:"SERVICE",173:"FILTER",174:"BIND",191:";",195:"a",217:"!",222:"^",224:"[",225:"]",229:"<<",233:">>",243:"BLANK_NODE_LABEL",244:"ANON",248:"||",252:"&&",256:"IN",271:"-",273:"FUNC_ARITY0",274:"FUNC_ARITY1",275:"FUNC_ARITY2",276:",",277:"IF",279:"BOUND",280:"BNODE",282:"EXISTS",283:"COUNT",286:"FUNC_AGGREGATE",288:"GROUP_CONCAT",292:"SEPARATOR",293:"=",295:"LANGTAG",296:"^^",297:"DECIMAL",298:"DOUBLE",299:"BOOLEAN",300:"STRING_LITERAL1",301:"STRING_LITERAL2",302:"STRING_LITERAL_LONG1",303:"STRING_LITERAL_LONG2",304:"INTEGER_POSITIVE",305:"DECIMAL_POSITIVE",306:"DOUBLE_POSITIVE",307:"INTEGER_NEGATIVE",308:"DECIMAL_NEGATIVE",309:"DOUBLE_NEGATIVE",310:"PNAME_LN",314:"DISTINCT",315:"REDUCED",318:"NAMED",319:"SILENT",320:"CLEAR",321:"DROP",322:"ADD",323:"MOVE",324:"COPY",325:"ALL",326:".",327:"UNION",328:"|",329:"/",331:"?",332:"+",333:"!=",334:"<",335:">",336:"<=",337:">=",338:"NOT",339:"CONCAT",340:"COALESCE",341:"SUBSTR",342:"REGEX",343:"REPLACE"},productions_:[0,[3,3],[4,1],[8,2],[11,2],[14,3],[17,4],[17,4],[18,2],[22,2],[25,2],[30,4],[30,4],[33,1],[33,5],[33,5],[40,5],[40,7],[49,5],[54,4],[57,3],[20,2],[24,2],[21,3],[67,3],[71,1],[71,1],[71,3],[71,5],[71,1],[74,2],[77,3],[80,2],[80,2],[80,1],[80,1],[85,2],[85,2],[85,4],[85,4],[89,2],[91,4],[91,4],[91,6],[97,1],[97,1],[97,1],[97,1],[101,3],[103,3],[105,4],[105,3],[105,5],[105,4],[105,2],[105,2],[105,2],[105,6],[105,6],[129,2],[125,2],[134,3],[137,2],[139,3],[115,1],[115,2],[112,2],[112,1],[121,4],[146,7],[151,3],[62,3],[62,3],[155,2],[158,3],[162,3],[159,2],[159,2],[159,2],[159,3],[159,4],[159,2],[159,6],[159,6],[159,1],[84,1],[84,1],[84,1],[73,2],[73,6],[177,1],[177,4],[42,3],[180,3],[153,2],[153,2],[186,1],[184,2],[190,2],[188,2],[193,1],[193,1],[193,1],[194,2],[164,2],[164,2],[199,4],[206,1],[206,3],[208,2],[210,2],[213,2],[212,2],[214,1],[214,1],[214,2],[214,3],[218,1],[218,1],[218,4],[219,1],[219,1],[219,2],[219,2],[185,3],[185,3],[200,3],[200,3],[197,1],[197,1],[204,1],[204,1],[39,9],[39,5],[99,9],[99,5],[241,1],[241,1],[242,1],[242,1],[242,1],[242,1],[242,1],[36,2],[247,2],[245,2],[251,2],[249,1],[249,3],[249,4],[253,2],[259,2],[259,2],[259,2],[257,2],[267,2],[265,2],[265,2],[265,2],[270,1],[270,1],[270,1],[270,1],[270,1],[270,1],[82,3],[72,1],[72,2],[72,4],[72,6],[72,8],[72,2],[72,4],[72,2],[72,4],[72,3],[272,5],[272,5],[272,6],[291,4],[98,1],[98,2],[98,3],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[294,1],[294,1],[294,1],[294,1],[261,1],[261,1],[261,1],[263,1],[263,1],[263,1],[60,1],[60,1],[60,1],[311,0],[311,1],[5,1],[5,1],[312,1],[312,1],[7,0],[7,2],[9,1],[9,1],[9,1],[9,1],[10,0],[10,1],[19,0],[19,2],[23,0],[23,2],[27,1],[27,2],[313,1],[313,1],[29,0],[29,1],[31,0],[31,1],[32,0],[32,1],[43,0],[43,2],[44,0],[44,2],[47,0],[47,1],[316,1],[316,1],[317,1],[317,2],[51,1],[51,1],[52,0],[52,2],[53,0],[53,1],[56,0],[56,2],[59,0],[59,1],[61,0],[61,1],[63,0],[63,1],[64,0],[64,1],[65,0],[65,1],[66,0],[66,1],[70,1],[70,2],[76,1],[76,2],[79,1],[79,2],[92,0],[92,2],[94,0],[94,2],[95,1],[95,2],[96,0],[96,2],[102,1],[102,2],[104,0],[104,4],[106,0],[106,2],[108,0],[108,1],[109,0],[109,1],[110,1],[110,1],[111,0],[111,1],[113,1],[113,1],[113,1],[114,0],[114,1],[118,0],[118,1],[124,0],[124,1],[126,0],[126,1],[127,0],[127,2],[128,0],[128,1],[130,0],[130,1],[131,0],[131,2],[136,0],[136,1],[142,0],[142,1],[143,1],[143,1],[143,1],[144,0],[144,1],[145,0],[145,2],[147,1],[147,1],[148,0],[148,1],[149,0],[149,1],[150,0],[150,1],[152,0],[152,3],[154,0],[154,1],[156,0],[156,1],[157,0],[157,2],[160,0],[160,1],[161,0],[161,1],[163,0],[163,3],[165,0],[165,1],[166,0],[166,3],[169,1],[169,1],[171,0],[171,1],[172,1],[172,1],[175,0],[175,1],[176,0],[176,3],[178,0],[178,3],[179,0],[179,1],[181,0],[181,3],[182,0],[182,1],[183,1],[183,1],[187,0],[187,1],[189,0],[189,2],[192,0],[192,1],[196,0],[196,3],[198,1],[198,1],[201,0],[201,1],[202,1],[202,1],[203,0],[203,3],[205,0],[205,2],[207,1],[207,1],[209,0],[209,3],[211,0],[211,3],[330,1],[330,1],[330,1],[215,0],[215,1],[216,0],[216,1],[220,0],[220,3],[221,0],[221,1],[223,1],[223,2],[226,1],[226,2],[227,1],[227,1],[228,1],[228,1],[230,1],[230,1],[231,1],[231,1],[232,1],[232,1],[234,1],[234,1],[235,1],[235,1],[236,1],[236,1],[237,1],[237,1],[238,1],[238,1],[239,1],[239,1],[240,1],[240,1],[246,0],[246,2],[250,0],[250,2],[254,1],[254,1],[254,1],[254,1],[254,1],[254,1],[255,0],[255,1],[258,0],[258,2],[260,1],[260,1],[262,0],[262,2],[264,0],[264,2],[266,0],[266,2],[268,1],[268,1],[269,0],[269,1],[278,1],[278,1],[278,1],[278,1],[278,1],[281,0],[281,1],[284,0],[284,1],[285,1],[285,1],[287,0],[287,1],[289,0],[289,1],[290,0],[290,1]],performAction:function(e,t,r,i,s,a,n){var o,u,c,l,p=a.length-1;switch(s){case 1:if(a[p-1]=a[p-1]||{},ii.base&&(a[p-1].base=ii.base),ii.base="",a[p-1].prefixes=ii.prefixes,ii.prefixes=null,"update"===a[p-1].type){const e={};for(const t of a[p-1].updates)if("insert"===t.updateType){const r={};for(const e of t.insert)if("bgp"===e.type||"graph"===e.type)for(const t of e.triples)"BlankNode"===t.subject.termType&&(r[t.subject.value]=!0),"BlankNode"===t.predicate.termType&&(r[t.predicate.value]=!0),"BlankNode"===t.object.termType&&(r[t.object.value]=!0);for(const t of Object.keys(r)){if(e[t])throw new Error("Detected reuse blank node across different INSERT DATA clauses");e[t]=!0}}}return a[p-1];case 3:this.$=Nr(a[p-1],a[p],{type:"query"});break;case 4:ii.base=Cr(a[p]);break;case 5:ii.prefixes||(ii.prefixes={}),a[p-1]=a[p-1].substr(0,a[p-1].length-1),a[p]=Cr(a[p]),ii.prefixes[a[p-1]]=a[p];break;case 6:this.$=Nr(a[p-3],Or(a[p-2]),a[p-1],a[p]);break;case 7:if(!ii.skipUngroupedVariableCheck&&(Zr(a[p-3].variables.map((e=>zr(e.expression)))).some((e=>"count"===e.aggregation&&!(e.expression instanceof cr)))||a[p].group))for(const e of a[p-3].variables)if("Variable"===e.termType){if(!a[p].group||!a[p].group.map((e=>Wr(e))).includes(Wr(e)))throw Error("Projection of ungrouped variable (?"+Wr(e)+")")}else if(0===zr(e.expression).length){const t=Xr(e.expression);for(const e of t)if(!a[p].group.map((e=>Wr(e))).includes(Wr(e)))throw Error("Use of ungrouped variable in projection of operation (?"+Wr(e)+")")}const e=a[p-1].where.filter((e=>"query"===e.type));if(e.length>0){const t=a[p-3].variables.filter((e=>e.variable&&e.variable.value)).map((e=>e.variable.value)),r=Zr(e.map((e=>e.variables))).map((e=>e.value||e.variable.value));for(const e of t)if(r.indexOf(e)>=0)throw Error("Target id of 'AS' (?"+e+") already used in subquery")}this.$=Nr(a[p-3],Or(a[p-2]),a[p-1],a[p]);break;case 8:this.$=Nr(a[p-1],{variables:[new cr]});break;case 9:const t=function(e){const t=e.slice().sort(),r=[];for(let e=0;ee.value||e.variable.value)));if(t.length>0)throw Error("Two or more of the resulting columns have the same name (?"+t[0]+")");this.$=Nr(a[p-1],{variables:a[p]});break;case 10:this.$=Nr({queryType:"SELECT"},a[p]&&(a[p-1]=Ar(a[p]),a[p]={},a[p][a[p-1]]=!0,a[p]));break;case 11:case 12:this.$=Nr(a[p-3],a[p-2],a[p-1],a[p],{type:"query"});break;case 13:case 100:case 136:case 164:this.$=Sr(a[p]);break;case 14:case 28:this.$=Lr(a[p-3],{variable:Sr(a[p-1])});break;case 15:this.$=Jr(Lr(a[p-3],{variable:Sr(a[p-1])}));break;case 16:this.$=Nr({queryType:"CONSTRUCT",template:a[p-3]},Or(a[p-2]),a[p-1],a[p]);break;case 17:this.$=Nr({queryType:"CONSTRUCT",template:a[p-2]=a[p-2]?a[p-2].triples:[]},Or(a[p-5]),{where:[{type:"bgp",triples:vr([],a[p-2])}]},a[p]);break;case 18:this.$=Nr({queryType:"DESCRIBE",variables:"*"===a[p-3]?[new cr]:a[p-3].map(Sr)},Or(a[p-2]),a[p-1],a[p]);break;case 19:this.$=Nr({queryType:"ASK"},Or(a[p-2]),a[p-1],a[p]);break;case 20:case 61:this.$={iri:a[p],named:!!a[p-1]};break;case 21:this.$={where:a[p].patterns};break;case 22:this.$=Nr(a[p-1],a[p]);break;case 23:this.$=Nr(a[p-2],a[p-1],a[p]);break;case 24:this.$={group:a[p]};break;case 25:case 26:case 32:case 34:this.$=Lr(a[p]);break;case 27:this.$=Lr(a[p-1]);break;case 29:case 35:this.$=Lr(Sr(a[p]));break;case 30:this.$={having:a[p]};break;case 31:this.$={order:a[p]};break;case 33:this.$=Lr(a[p],{descending:!0});break;case 36:this.$={limit:xr(a[p])};break;case 37:this.$={offset:xr(a[p])};break;case 38:this.$={limit:xr(a[p-2]),offset:xr(a[p])};break;case 39:this.$={limit:xr(a[p]),offset:xr(a[p-2])};break;case 40:this.$={type:"values",values:a[p]};break;case 41:this.$=a[p-1].map((function(e){var t={};return t[a[p-3]]=e,t}));break;case 42:this.$=a[p-1].map((function(){return{}}));break;case 43:var h=a[p-4].length;a[p-4]=a[p-4].map(Sr),this.$=a[p-1].map((function(e){if(e.length!==h)throw Error("Inconsistent VALUES length");for(var t={},r=0;r"bind"===e.type))){const t=a[p-1].indexOf(e),r=new Set;for(const e of a[p-1].slice(0,t))"group"!==e.type&&"bgp"!==e.type||Kr(e).forEach((e=>r.add(e)));if(r.has(e.variable.value))throw Error("Variable used to bind is already bound (?"+e.variable.value+")")}this.$={type:"group",patterns:a[p-1]};break;case 73:this.$=a[p-1]?kr([a[p-1]],a[p]):kr(a[p]);break;case 74:this.$=a[p]?[a[p-2],a[p]]:a[p-2];break;case 76:a[p-1].length?this.$={type:"union",patterns:kr(a[p-1].map(Pr),[Pr(a[p])])}:this.$=a[p];break;case 77:this.$=Nr(a[p],{type:"optional"});break;case 78:this.$=Nr(a[p],{type:"minus"});break;case 79:this.$=Nr(a[p],{type:"graph",name:Sr(a[p-1])});break;case 80:this.$=Nr(a[p],{type:"service",name:Sr(a[p-1]),silent:!!a[p-2]});break;case 81:this.$={type:"filter",expression:a[p]};break;case 82:this.$={type:"bind",variable:Sr(a[p-1]),expression:a[p-3]};break;case 83:this.$=Jr({type:"bind",variable:Sr(a[p-1]),expression:a[p-3]});break;case 88:this.$={type:"functionCall",function:a[p-1],args:[]};break;case 89:this.$={type:"functionCall",function:a[p-5],args:mr(a[p-2],a[p-1]),distinct:!!a[p-3]};break;case 90:case 107:case 118:case 208:case 216:case 218:case 230:case 232:case 242:case 246:case 266:case 268:case 272:case 276:case 299:case 305:case 316:case 326:case 332:case 338:case 342:case 352:case 354:case 358:case 366:case 370:case 378:case 380:case 384:case 386:case 395:case 427:case 429:case 439:case 443:case 445:case 447:this.$=[];break;case 91:this.$=mr(a[p-2],a[p-1]);break;case 93:this.$=kr(a[p-2],[a[p-1]]);break;case 94:case 104:this.$=a[p].map((function(e){return Nr(Ur(a[p-1]),e)}));break;case 95:this.$=vr(a[p].map((function(e){return Nr(Ur(a[p-1].entity),e)})),a[p-1].triples);break;case 97:this.$=kr([a[p-1]],a[p]);break;case 98:this.$=kr(a[p]);break;case 99:this.$=Qr(a[p-1],a[p]);break;case 102:case 114:case 121:this.$=ii.factory.namedNode(pr);break;case 103:this.$=mr(a[p-1],a[p]);break;case 105:this.$=a[p]?vr(a[p].map((function(e){return Nr(Ur(a[p-1].entity),e)})),a[p-1].triples):a[p-1].triples;break;case 106:this.$=Qr(Sr(a[p-3]),mr(a[p-2],a[p-1]),a[p]);break;case 108:this.$=Qr(Sr(a[p-1]),a[p]);break;case 109:this.$=a[p-1].length?wr("|",mr(a[p-1],a[p])):a[p];break;case 110:this.$=a[p-1].length?wr("/",mr(a[p-1],a[p])):a[p];break;case 111:this.$=a[p]?wr(a[p],[a[p-1]]):a[p-1];break;case 112:this.$=a[p-1]?wr(a[p-1],[a[p]]):a[p];break;case 115:case 122:this.$=wr(a[p-1],[a[p]]);break;case 119:this.$=wr("|",mr(a[p-2],a[p-1]));break;case 123:this.$=wr(a[p-1],[ii.factory.namedNode(pr)]);break;case 124:case 126:this.$=function(e){var t=Gr(),r=t,i=[],s=[];e.forEach((function(e){i.push(e.entity),vr(s,e.triples)}));for(var a=0,n=0,o=i.length,u=Array(2*o);al&&N.push("'"+this.terminals_[A]+"'");S=d.showPosition?"Parse error on line "+(o+1)+":\n"+d.showPosition()+"\nExpecting "+N.join(", ")+", got '"+(this.terminals_[b]||b)+"'":"Parse error on line "+(o+1)+": Unexpected "+(b==p?"end of input":"'"+(this.terminals_[b]||b)+"'"),this.parseError(S,{text:d.match,token:this.terminals_[b]||b,line:d.yylineno,loc:F,expected:N})}if(D[0]instanceof Array&&D.length>1)throw new Error("Parse Error: multiple actions possible at state: "+g+", token: "+b);switch(D[0]){case 1:r.push(b),i.push(d.yytext),s.push(d.yylloc),r.push(D[1]),b=null,_?(b=_,_=null):(u=d.yyleng,n=d.yytext,o=d.yylineno,F=d.yylloc,c>0&&c--);break;case 2:if(m=this.productions_[D[1]][1],C.$=i[i.length-m],C._$={first_line:s[s.length-(m||1)].first_line,last_line:s[s.length-1].last_line,first_column:s[s.length-(m||1)].first_column,last_column:s[s.length-1].last_column},E&&(C._$.range=[s[s.length-(m||1)].range[0],s[s.length-1].range[1]]),void 0!==(T=this.performAction.apply(C,[n,u,o,f.yy,D[1],i,s].concat(h))))return T;m&&(r=r.slice(0,-1*m*2),i=i.slice(0,-1*m),s=s.slice(0,-1*m)),r.push(this.productions_[D[1]][0]),i.push(C.$),s.push(C._$),v=a[r[r.length-2]][r[r.length-1]],r.push(v);break;case 3:return!0}}return!0}},cr=r(348).R,lr="http://www.w3.org/1999/02/22-rdf-syntax-ns#",pr=lr+"type",hr=lr+"first",dr=lr+"rest",fr=lr+"nil",yr="http://www.w3.org/2001/XMLSchema#",Fr=yr+"integer",Er=yr+"decimal",br=yr+"double",_r=yr+"boolean",gr="",Dr="",Tr="";function Ar(e){return e.toLowerCase()}function mr(e,t){return e.push(t),e}function vr(e,t){return e.push.apply(e,t),e}function Nr(e){e||(e={});for(var t,r=1,i=arguments.length;r>10),56320+(1023&s))}var a=Mr[i];if(!a)throw new Error;return a}))}catch(e){return""}if(Vr.exec(e))throw new Error("Invalid unicode codepoint of surrogate pair without corresponding codepoint in "+e);return e}function Qr(e,t,r){var i=[],s=[];return t.forEach((function(t){i.push(Ur(null,e,t.entity)),vr(s,t.triples)})),kr(i,r||[],s)}function Wr(e){return e.variable?e.variable.value:e.value||e.expression.value}function zr(e){if(!e)return[];if("aggregate"===e.type)return[e];if("operation"===e.type){const t=[];for(const r of e.args)t.push(...zr(r));return t}return[]}function Xr(e){const t=new Set,r=function(e){e&&("Variable"===e.termType?t.add(e):"operation"===e.type&&e.args.forEach(r))};return r(e),t}function Zr(e,t=1,r=[]){for(const i of e)t>0&&i instanceof Array?Zr(i,t-1,r):r.push(i);return r}function Yr(e){return"Variable"===e.termType}function Kr(e){if(e.triples){const t=[];for(const r of e.triples)Yr(r.subject)&&t.push(r.subject.value),Yr(r.predicate)&&t.push(r.predicate.value),Yr(r.object)&&t.push(r.object.value);return t}if(e.patterns){const t=[];for(const r of e.patterns)t.push(...Kr(r));return t}return[]}function Jr(e){if(!ii.sparqlStar)throw new Error("SPARQL* support is not enabled");return e}function ei(e){for(const t of e){if("graph"===t.type&&"Variable"===t.name.termType)throw new Error("Detected illegal variable in GRAPH");if("bgp"===t.type||"graph"===t.type)for(const e of t.triples)if("Variable"===e.subject.termType||"Variable"===e.predicate.termType||"Variable"===e.object.termType)throw new Error("Detected illegal variable in BGP")}return e}function ti(e){for(const t of e)if("bgp"===t.type)for(const e of t.triples)if("BlankNode"===e.subject.termType||"BlankNode"===e.predicate.termType||"BlankNode"===e.object.termType)throw new Error("Detected illegal blank node in BGP");return e}var ri={EOF:1,parseError:function(e,t){if(!this.yy.parser)throw new Error(e);this.yy.parser.parseError(e,t)},setInput:function(e,t){return this.yy=t||this.yy||{},this._input=e,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var e=this._input[0];return this.yytext+=e,this.yyleng++,this.offset++,this.match+=e,this.matched+=e,e.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),e},unput:function(e){var t=e.length,r=e.split(/(?:\r\n?|\n)/g);this._input=e+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-t),this.offset-=t;var i=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),r.length-1&&(this.yylineno-=r.length-1);var s=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:r?(r.length===i.length?this.yylloc.first_column:0)+i[i.length-r.length].length-r[0].length:this.yylloc.first_column-t},this.options.ranges&&(this.yylloc.range=[s[0],s[0]+this.yyleng-t]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},less:function(e){this.unput(this.match.slice(e))},pastInput:function(){var e=this.matched.substr(0,this.matched.length-this.match.length);return(e.length>20?"...":"")+e.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var e=this.match;return e.length<20&&(e+=this._input.substr(0,20-e.length)),(e.substr(0,20)+(e.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var e=this.pastInput(),t=new Array(e.length+1).join("-");return e+this.upcomingInput()+"\n"+t+"^"},test_match:function(e,t){var r,i,s;if(this.options.backtrack_lexer&&(s={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(s.yylloc.range=this.yylloc.range.slice(0))),(i=e[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=i.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:i?i[i.length-1].length-i[i.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+e[0].length},this.yytext+=e[0],this.match+=e[0],this.matches=e,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(e[0].length),this.matched+=e[0],r=this.performAction.call(this,this.yy,this,t,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),r)return r;if(this._backtrack){for(var a in s)this[a]=s[a];return!1}return!1},next:function(){if(this.done)return this.EOF;var e,t,r,i;this._input||(this.done=!0),this._more||(this.yytext="",this.match="");for(var s=this._currentRules(),a=0;at[0].length)){if(t=r,i=a,this.options.backtrack_lexer){if(!1!==(e=this.test_match(r,s[a])))return e;if(this._backtrack){t=!1;continue}return!1}if(!this.options.flex)break}return t?!1!==(e=this.test_match(t,s[i]))&&e:""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){return this.next()||this.lex()},begin:function(e){this.conditionStack.push(e)},popState:function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(e){return(e=this.conditionStack.length-1-Math.abs(e||0))>=0?this.conditionStack[e]:"INITIAL"},pushState:function(e){this.begin(e)},stateStackSize:function(){return this.conditionStack.length},options:{flex:!0,"case-insensitive":!0},performAction:function(e,t,r,i){switch(r){case 0:break;case 1:return 12;case 2:return 15;case 3:return 28;case 4:return 314;case 5:return 315;case 6:return 35;case 7:return 37;case 8:return 38;case 9:return 26;case 10:return 41;case 11:return 45;case 12:return 46;case 13:return 48;case 14:return 50;case 15:return 55;case 16:return 58;case 17:return 318;case 18:return 68;case 19:return 69;case 20:return 75;case 21:return 78;case 22:return 81;case 23:return 83;case 24:return 86;case 25:return 88;case 26:return 90;case 27:return 191;case 28:return 107;case 29:return 319;case 30:return 140;case 31:return 320;case 32:return 321;case 33:return 117;case 34:return 322;case 35:return 116;case 36:return 323;case 37:return 324;case 38:return 120;case 39:return 122;case 40:return 123;case 41:return 138;case 42:return 132;case 43:return 133;case 44:return 135;case 45:return 141;case 46:return 119;case 47:return 325;case 48:return 326;case 49:return 167;case 50:return 170;case 51:return 174;case 52:return 100;case 53:return 168;case 54:return 327;case 55:return 173;case 56:return 229;case 57:return 233;case 58:return 276;case 59:return 195;case 60:return 328;case 61:return 329;case 62:return 222;case 63:return 331;case 64:return 332;case 65:return 217;case 66:return 224;case 67:return 225;case 68:return 248;case 69:return 252;case 70:return 293;case 71:return 333;case 72:return 334;case 73:return 335;case 74:return 336;case 75:return 337;case 76:return 256;case 77:return 338;case 78:return 271;case 79:return 279;case 80:return 280;case 81:return 273;case 82:return 274;case 83:return 275;case 84:return 339;case 85:return 340;case 86:return 277;case 87:return 342;case 88:return 341;case 89:return 343;case 90:return 282;case 91:return 283;case 92:return 286;case 93:return 288;case 94:return 292;case 95:return 296;case 96:return 299;case 97:return 13;case 98:return 16;case 99:return 310;case 100:return 243;case 101:return 34;case 102:return 295;case 103:return 87;case 104:return 297;case 105:return 298;case 106:return 304;case 107:return 305;case 108:return 306;case 109:return 307;case 110:return 308;case 111:return 309;case 112:return"EXPONENT";case 113:return 300;case 114:return 301;case 115:return 302;case 116:return 303;case 117:return 93;case 118:return 244;case 119:return 6;case 120:return"INVALID";case 121:console.log(t.yytext)}},rules:[/^(?:\s+|(#[^\n\r]*))/i,/^(?:BASE)/i,/^(?:PREFIX)/i,/^(?:SELECT)/i,/^(?:DISTINCT)/i,/^(?:REDUCED)/i,/^(?:\()/i,/^(?:AS)/i,/^(?:\))/i,/^(?:\*)/i,/^(?:CONSTRUCT)/i,/^(?:WHERE)/i,/^(?:\{)/i,/^(?:\})/i,/^(?:DESCRIBE)/i,/^(?:ASK)/i,/^(?:FROM)/i,/^(?:NAMED)/i,/^(?:GROUP)/i,/^(?:BY)/i,/^(?:HAVING)/i,/^(?:ORDER)/i,/^(?:ASC)/i,/^(?:DESC)/i,/^(?:LIMIT)/i,/^(?:OFFSET)/i,/^(?:VALUES)/i,/^(?:;)/i,/^(?:LOAD)/i,/^(?:SILENT)/i,/^(?:INTO)/i,/^(?:CLEAR)/i,/^(?:DROP)/i,/^(?:CREATE)/i,/^(?:ADD)/i,/^(?:TO)/i,/^(?:MOVE)/i,/^(?:COPY)/i,/^(?:INSERT((\s+|(#[^\n\r]*)\n\r?)+)DATA)/i,/^(?:DELETE((\s+|(#[^\n\r]*)\n\r?)+)DATA)/i,/^(?:DELETE((\s+|(#[^\n\r]*)\n\r?)+)WHERE)/i,/^(?:WITH)/i,/^(?:DELETE)/i,/^(?:INSERT)/i,/^(?:USING)/i,/^(?:DEFAULT)/i,/^(?:GRAPH)/i,/^(?:ALL)/i,/^(?:\.)/i,/^(?:OPTIONAL)/i,/^(?:SERVICE)/i,/^(?:BIND)/i,/^(?:UNDEF)/i,/^(?:MINUS)/i,/^(?:UNION)/i,/^(?:FILTER)/i,/^(?:<<)/i,/^(?:>>)/i,/^(?:,)/i,/^(?:a)/i,/^(?:\|)/i,/^(?:\/)/i,/^(?:\^)/i,/^(?:\?)/i,/^(?:\+)/i,/^(?:!)/i,/^(?:\[)/i,/^(?:\])/i,/^(?:\|\|)/i,/^(?:&&)/i,/^(?:=)/i,/^(?:!=)/i,/^(?:<)/i,/^(?:>)/i,/^(?:<=)/i,/^(?:>=)/i,/^(?:IN)/i,/^(?:NOT)/i,/^(?:-)/i,/^(?:BOUND)/i,/^(?:BNODE)/i,/^(?:(RAND|NOW|UUID|STRUUID))/i,/^(?:(LANG|DATATYPE|IRI|URI|ABS|CEIL|FLOOR|ROUND|STRLEN|STR|UCASE|LCASE|ENCODE_FOR_URI|YEAR|MONTH|DAY|HOURS|MINUTES|SECONDS|TIMEZONE|TZ|MD5|SHA1|SHA256|SHA384|SHA512|isIRI|isURI|isBLANK|isLITERAL|isNUMERIC))/i,/^(?:(LANGMATCHES|CONTAINS|STRSTARTS|STRENDS|STRBEFORE|STRAFTER|STRLANG|STRDT|sameTerm))/i,/^(?:CONCAT)/i,/^(?:COALESCE)/i,/^(?:IF)/i,/^(?:REGEX)/i,/^(?:SUBSTR)/i,/^(?:REPLACE)/i,/^(?:EXISTS)/i,/^(?:COUNT)/i,/^(?:SUM|MIN|MAX|AVG|SAMPLE)/i,/^(?:GROUP_CONCAT)/i,/^(?:SEPARATOR)/i,/^(?:\^\^)/i,/^(?:true|false)/i,/^(?:(<(?:[^<>\"\{\}\|\^`\\\u0000-\u0020])*>))/i,/^(?:((([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])(?:(?:(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040])|\.)*(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040]))?)?:))/i,/^(?:(((([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])(?:(?:(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040])|\.)*(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040]))?)?:)((?:((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|:|[0-9]|((%([0-9A-Fa-f])([0-9A-Fa-f]))|(\\(_|~|\.|-|!|\$|&|'|\(|\)|\*|\+|,|;|=|\/|\?|#|@|%))))(?:(?:(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040])|\.|:|((%([0-9A-Fa-f])([0-9A-Fa-f]))|(\\(_|~|\.|-|!|\$|&|'|\(|\)|\*|\+|,|;|=|\/|\?|#|@|%))))*(?:(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040])|:|((%([0-9A-Fa-f])([0-9A-Fa-f]))|(\\(_|~|\.|-|!|\$|&|'|\(|\)|\*|\+|,|;|=|\/|\?|#|@|%)))))?)))/i,/^(?:(_:(?:((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|[0-9])(?:(?:(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040])|\.)*(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040]))?))/i,/^(?:([\?\$]((?:((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|[0-9])(?:((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040])*)))/i,/^(?:(@[a-zA-Z]+(?:-[a-zA-Z0-9]+)*))/i,/^(?:([0-9]+))/i,/^(?:([0-9]*\.[0-9]+))/i,/^(?:([0-9]+\.[0-9]*([eE][+-]?[0-9]+)|\.([0-9])+([eE][+-]?[0-9]+)|([0-9])+([eE][+-]?[0-9]+)))/i,/^(?:(\+([0-9]+)))/i,/^(?:(\+([0-9]*\.[0-9]+)))/i,/^(?:(\+([0-9]+\.[0-9]*([eE][+-]?[0-9]+)|\.([0-9])+([eE][+-]?[0-9]+)|([0-9])+([eE][+-]?[0-9]+))))/i,/^(?:(-([0-9]+)))/i,/^(?:(-([0-9]*\.[0-9]+)))/i,/^(?:(-([0-9]+\.[0-9]*([eE][+-]?[0-9]+)|\.([0-9])+([eE][+-]?[0-9]+)|([0-9])+([eE][+-]?[0-9]+))))/i,/^(?:([eE][+-]?[0-9]+))/i,/^(?:('(?:(?:[^\u0027\u005C\u000A\u000D])|(\\[tbnrf\\\"']|\\u([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])|\\U([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])))*'))/i,/^(?:("(?:(?:[^\u0022\u005C\u000A\u000D])|(\\[tbnrf\\\"']|\\u([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])|\\U([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])))*"))/i,/^(?:('''(?:(?:'|'')?(?:[^'\\]|(\\[tbnrf\\\"']|\\u([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])|\\U([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f]))))*'''))/i,/^(?:("""(?:(?:"|"")?(?:[^\"\\]|(\\[tbnrf\\\"']|\\u([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])|\\U([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f]))))*"""))/i,/^(?:(\((\u0020|\u0009|\u000D|\u000A)*\)))/i,/^(?:(\[(\u0020|\u0009|\u000D|\u000A)*\]))/i,/^(?:$)/i,/^(?:.)/i,/^(?:.)/i],conditions:{INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121],inclusive:!0}}};function ii(){this.yy={}}return ur.lexer=ri,ii.prototype=ur,ur.Parser=ii,new ii}();t.parser=i,t.Parser=i.Parser,t.parse=function(){return i.parse.apply(i,arguments)},t.main=function(e){e[1]||(console.log("Usage: "+e[0]+" FILE"),process.exit(1));var i=r(270).readFileSync(r(80).normalize(e[1]),"utf8");return t.parser.parse(i)},r.c[r.s]===e&&t.main(process.argv.slice(1))},348:e=>{class t{constructor(){return r||this}equals(e){return e&&this.termType===e.termType}}Object.defineProperty(t.prototype,"value",{enumerable:!0,value:"*"}),Object.defineProperty(t.prototype,"termType",{enumerable:!0,value:"Wildcard"});var r=new t;e.exports.R=t},619:(e,t,r)=>{var i=r(107).Parser,s=r(404),a=r(348).R,{DataFactory:n}=r(640);e.exports={Parser:function({prefixes:e,baseIRI:t,factory:r,sparqlStar:s,skipUngroupedVariableCheck:a}={}){var o={};for(var u in e||{})o[u]=e[u];var c=new i;return c.parse=function(){return i.base=t||"",i.prefixes=Object.create(o),i.factory=r||new n,i.sparqlStar=Boolean(s),i.skipUngroupedVariableCheck=Boolean(a),i.prototype.parse.apply(c,arguments)},c._resetBlanks=i._resetBlanks,c},Generator:s,Wildcard:a}},722:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AppMain=void 0;class r extends HTMLElement{constructor(){super(...arguments),this.monitorHash=!0}connectedCallback(){document.addEventListener("DOMContentLoaded",this.onLoad.bind(this)),window.addEventListener("hashchange",this.onHash.bind(this))}get sparql(){return this.querySelector("sparql-editor")}get blockly(){return this.querySelector("blockly-canvas")}onHash(){this.monitorHash&&this.setFromHash()}onLoad(){this.sparql.addEventListener("sparql",this.onSparql.bind(this)),this.sparql.addEventListener("input",this.onInput.bind(this)),this.blockly.addEventListener("blocks",this.onBlocks.bind(this)),this.blockly.addEventListener("load",this.onBlocklyLoad.bind(this))}onSparql(e){this.blockly.dom=e.detail}onInput(){this.updateUrl()}onBlocks(e){this.sparql.value=e.detail,this.updateUrl()}onBlocklyLoad(){this.setFromHash()}setFromHash(){const e=window.location.hash.split("#")[1];e&&this.sparql.setAndNotify(decodeURIComponent(e))}updateUrl(){this.monitorHash=!1,window.location.hash=encodeURIComponent(this.sparql.value),window.setTimeout((()=>this.monitorHash=!0),250)}}t.AppMain=r},79:function(e,t,r){"use strict";var i=this&&this.__awaiter||function(e,t,r,i){return new(r||(r=Promise))((function(s,a){function n(e){try{u(i.next(e))}catch(e){a(e)}}function o(e){try{u(i.throw(e))}catch(e){a(e)}}function u(e){var t;e.done?s(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(n,o)}u((i=i.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.BlocklyCanvas=void 0;const s=r(564),a=r(505);class n extends HTMLElement{constructor(){super(...arguments),this.typing=!1}connectedCallback(){return i(this,void 0,void 0,(function*(){s.Blocks.sparql11_faketallblock={init:function(){this.appendDummyInput(),this.appendDummyInput()}};const e={sounds:!1,toolbox:yield this.getToolboxData(),horizontalLayout:window.innerWidth<768,zoom:{controls:!0,wheel:!0,startScale:1,maxScale:3,minScale:.01,scaleSpeed:1.2,pinch:!0}},t=s.inject(this,e);t.addChangeListener(this.workspaceChanged.bind(this)),window.setInterval((()=>s.svgResize(t)),1e3),t.registerButtonCallback("example",n.exampleButtonClicked),this.dispatchEvent(new Event("load"))}))}set dom(e){if(e){const t=s.getMainWorkspace();t.clear(),this.typing=!0,s.Xml.domToWorkspace(e,t)}}getToolboxData(){return i(this,void 0,void 0,(function*(){const e=this.getAttribute("toolbox-data"),t=yield fetch(e);return yield t.text()}))}workspaceChanged(e){switch(e.type){case s.Events.CHANGE:case s.Events.DELETE:case s.Events.MOVE:this.typing||this.generateCode();break;case s.Events.FINISHED_LOADING:this.typing=!1}}generateCode(){const e=s.getMainWorkspace();for(const t of e.getTopBlocks(!1))switch(t.type){case"sparql11_query":case"sparql11_update":this.dispatchEvent(new CustomEvent("blocks",{detail:a.blocklyToSparql(t)}))}}static exampleButtonClicked(e){window.location.hash=encodeURIComponent(e.info.query),e.getTargetWorkspace().getFlyout().hide()}}t.BlocklyCanvas=n},234:function(e,t,r){"use strict";var i=this&&this.__awaiter||function(e,t,r,i){return new(r||(r=Promise))((function(s,a){function n(e){try{u(i.next(e))}catch(e){a(e)}}function o(e){try{u(i.throw(e))}catch(e){a(e)}}function u(e){var t;e.done?s(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(n,o)}u((i=i.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.SparqlEditor=void 0;const s=r(619),a=r(505);class n extends HTMLElement{connectedCallback(){return i(this,void 0,void 0,(function*(){this.editorElement.addEventListener("input",this.input.bind(this))}))}get editorElement(){return this.querySelector("textarea")}get errorElement(){return this.querySelector("span")}set error(e){this.errorElement.innerText=e}get value(){return this.editorElement.value}set value(e){this.editorElement.value=e,this.validate()}setAndNotify(e){this.editorElement.value=e,this.input()}input(){const e=this.validate();e&&this.dispatchEvent(new CustomEvent("sparql",{detail:a.sparqlToBlockly(e)}))}validate(){this.error="",this.classList.remove("invalid"),this.classList.remove("valid");const e=this.value;if(e){const t=new s.Parser({sparqlStar:!0});try{const r=t.parse(e);return this.classList.add("valid"),r}catch(e){this.error=e.message,this.classList.add("invalid")}}}}t.SparqlEditor=n},607:(e,t,r)=>{"use strict";const i=r(722),s=r(79),a=r(234);customElements.define("app-main",i.AppMain),customElements.define("blockly-canvas",s.BlocklyCanvas),customElements.define("sparql-editor",a.SparqlEditor)},564:e=>{"use strict";e.exports=Blockly},505:e=>{"use strict";e.exports=SparqlBlockly},270:()=>{},80:()=>{}},t={};function r(i){var s=t[i];if(void 0!==s)return s.exports;var a=t[i]={id:i,loaded:!1,exports:{}};return e[i].call(a.exports,a,a.exports,r),a.loaded=!0,a.exports}r.c=t,r.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),r(r.s=607)})(); \ No newline at end of file +(()=>{"use strict";var t={722:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AppMain=void 0;class n extends HTMLElement{constructor(){super(...arguments),this.monitorHash=!0}connectedCallback(){document.addEventListener("DOMContentLoaded",this.onLoad.bind(this)),window.addEventListener("hashchange",this.onHash.bind(this))}get sparql(){return this.querySelector("sparql-editor")}get blockly(){return this.querySelector("blockly-canvas")}onHash(){this.monitorHash&&this.setFromHash()}onLoad(){this.sparql.addEventListener("sparql",this.onSparql.bind(this)),this.sparql.addEventListener("input",this.onInput.bind(this)),this.blockly.addEventListener("blocks",this.onBlocks.bind(this)),this.blockly.addEventListener("load",this.onBlocklyLoad.bind(this))}onSparql(t){this.blockly.dom=t.detail}onInput(){this.updateUrl()}onBlocks(t){this.sparql.value=t.detail,this.updateUrl()}onBlocklyLoad(){this.setFromHash()}setFromHash(){const t=window.location.hash.split("#")[1];t&&this.sparql.setAndNotify(decodeURIComponent(t))}updateUrl(){this.monitorHash=!1,window.location.hash=encodeURIComponent(this.sparql.value),window.setTimeout((()=>this.monitorHash=!0),250)}}e.AppMain=n},79:function(t,e,n){var s=this&&this.__awaiter||function(t,e,n,s){return new(n||(n=Promise))((function(i,o){function a(t){try{l(s.next(t))}catch(t){o(t)}}function r(t){try{l(s.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,r)}l((s=s.apply(t,e||[])).next())}))};Object.defineProperty(e,"__esModule",{value:!0}),e.BlocklyCanvas=void 0;const i=n(564),o=n(505);class a extends HTMLElement{constructor(){super(...arguments),this.typing=!1}connectedCallback(){return s(this,void 0,void 0,(function*(){i.Blocks.sparql11_faketallblock={init:function(){this.appendDummyInput(),this.appendDummyInput()}};const t={sounds:!1,toolbox:yield this.getToolboxData(),horizontalLayout:window.innerWidth<768,zoom:{controls:!0,wheel:!0,startScale:1,maxScale:3,minScale:.01,scaleSpeed:1.2,pinch:!0}},e=i.inject(this,t);e.addChangeListener(this.workspaceChanged.bind(this)),window.setInterval((()=>i.svgResize(e)),1e3),e.registerButtonCallback("example",a.exampleButtonClicked),this.dispatchEvent(new Event("load"))}))}set dom(t){if(t){const e=i.getMainWorkspace();e.clear(),this.typing=!0,i.Xml.domToWorkspace(t,e)}}getToolboxData(){return s(this,void 0,void 0,(function*(){const t=this.getAttribute("toolbox-data"),e=yield fetch(t);return yield e.text()}))}workspaceChanged(t){switch(t.type){case i.Events.CHANGE:case i.Events.DELETE:case i.Events.MOVE:this.typing||this.generateCode();break;case i.Events.FINISHED_LOADING:this.typing=!1}}generateCode(){const t=i.getMainWorkspace();for(const e of t.getTopBlocks(!1))switch(e.type){case"sparql11_query":case"sparql11_update":this.dispatchEvent(new CustomEvent("blocks",{detail:o.blocklyToSparql(e)}))}}static exampleButtonClicked(t){window.location.hash=encodeURIComponent(t.info.query),t.getTargetWorkspace().getFlyout().hide()}}e.BlocklyCanvas=a},234:function(t,e,n){var s=this&&this.__awaiter||function(t,e,n,s){return new(n||(n=Promise))((function(i,o){function a(t){try{l(s.next(t))}catch(t){o(t)}}function r(t){try{l(s.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,r)}l((s=s.apply(t,e||[])).next())}))};Object.defineProperty(e,"__esModule",{value:!0}),e.SparqlEditor=void 0;const i=n(505);class o extends HTMLElement{connectedCallback(){return s(this,void 0,void 0,(function*(){this.editorElement.addEventListener("input",this.input.bind(this))}))}get editorElement(){return this.querySelector("textarea")}get errorElement(){return this.querySelector("span")}set error(t){this.errorElement.innerText=t}get value(){return this.editorElement.value}set value(t){this.editorElement.value=t,this.validate()}setAndNotify(t){this.editorElement.value=t,this.input()}input(){const t=this.validate();t&&this.dispatchEvent(new CustomEvent("sparql",{detail:t}))}validate(){this.error="",this.classList.remove("invalid"),this.classList.remove("valid");const t=this.value;if(t)try{const e=i.sparqlToBlockly(t);return this.classList.add("valid"),e}catch(t){this.error=t.message,this.classList.add("invalid")}}}e.SparqlEditor=o},564:t=>{t.exports=Blockly},505:t=>{t.exports=SparqlBlockly}},e={};function n(s){var i=e[s];if(void 0!==i)return i.exports;var o=e[s]={exports:{}};return t[s].call(o.exports,o,o.exports,n),o.exports}(()=>{const t=n(722),e=n(79),s=n(234);customElements.define("app-main",t.AppMain),customElements.define("blockly-canvas",e.BlocklyCanvas),customElements.define("sparql-editor",s.SparqlEditor)})()})(); \ No newline at end of file diff --git a/package/index.d.ts b/package/index.d.ts index be76a857..41ce0aaf 100644 --- a/package/index.d.ts +++ b/package/index.d.ts @@ -1,7 +1,7 @@ import * as SparqlJS from "sparqljs"; import * as Blockly from "blockly"; -export declare function sparqlToBlockly(sparql: SparqlJS.SparqlQuery): Element; +export declare function sparqlToBlockly(sparql: string): Element; // eslint-disable-next-line @typescript-eslint/no-explicit-any export declare function blocklyToSparql(block: Blockly.Block): string | any[]; diff --git a/package/package-lock.json b/package/package-lock.json index 360aaf36..4cf48932 100644 --- a/package/package-lock.json +++ b/package/package-lock.json @@ -1,12 +1,12 @@ { "name": "sparql-blockly", - "version": "0.0.4-17", + "version": "0.0.4-19", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "sparql-blockly", - "version": "0.0.4-17", + "version": "0.0.4-19", "license": "MIT", "dependencies": { "@rdfjs/term-map": "^1.0.0", diff --git a/package/package.json b/package/package.json index 5e870488..48251711 100644 --- a/package/package.json +++ b/package/package.json @@ -1,6 +1,6 @@ { "name": "sparql-blockly", - "version": "0.0.4-17", + "version": "0.0.4-19", "description": "A library for working with SPARQL in Blockly", "main": "dist/index.js", "license": "MIT", diff --git a/package/src/index.ts b/package/src/index.ts index 419987aa..fa8a5f81 100644 --- a/package/src/index.ts +++ b/package/src/index.ts @@ -4,8 +4,11 @@ import CodeGenerator from "./CodeGenerator" import * as SparqlJS from "sparqljs" import * as Blockly from "blockly" -export function sparqlToBlockly(sparql: SparqlJS.SparqlQuery): Element { - return new BlockGenerator().visit(sparql)?.xml +export function sparqlToBlockly(sparql: string): Element { + const parser = new SparqlJS.Parser({ sparqlStar: true }) + const query = parser.parse(sparql) + + return new BlockGenerator().visit(query)?.xml } // eslint-disable-next-line @typescript-eslint/no-explicit-any