diff --git a/build/output/knockout-latest.debug.js b/build/output/knockout-latest.debug.js index 97b8dd5..f9f5007 100644 --- a/build/output/knockout-latest.debug.js +++ b/build/output/knockout-latest.debug.js @@ -565,7 +565,11 @@ ko.exportSymbol('ko.utils.domNodeDisposal.removeDisposeCallback', ko.utils.domNo // for example elements which are not normally allowed to exist on their own. // If you've referenced jQuery we'll use that rather than duplicating its code. if (typeof jQuery != 'undefined') { - jQuery(node)['html'](html); + try { + jQuery(node)['html'](html); + } catch (x) { + jQuery(node)['html'](html.replace("<","<").replace(">",">")); + } } else { // ... otherwise, use KO's own parsing logic. var parsedNodes = ko.utils.parseHtmlFragment(html); @@ -1238,6 +1242,30 @@ ko.jsonExpressionRewriting = (function () { return jsonString; }, + //@modified + parseURIsInJSONString: function(jsonString) { + var re = /["']?(<|\[)[a-z:\/.#?&%]+(\]|>)['"]?/g; + var acum = ""; + var found = re.exec(jsonString); + while(found != null) { + if((found[0][0] === "'" || found[0][0] === '"') && + (found[0][found[0].length-1] === "'" || found[0][found[0].length-1] === '"')) { + var parts = jsonString.split(found[0]); + acum = acum + parts[0] + found[0]; + jsonString = parts[1]; + } else { + var w = found[0]; + var index = found.index; + var pref = jsonString.substring(0,index); + acum = pref+"sko.current().tryProperty('"+w+"')"; + jsonString= jsonString.substring(index+w.length); + } + found = re.exec(jsonString); + } + + return acum+jsonString; + }, + insertPropertyReaderWritersIntoJson: function (jsonString) { var parsed = ko.jsonExpressionRewriting.parseJson(jsonString); var propertyAccessorTokens = []; @@ -1245,6 +1273,8 @@ ko.jsonExpressionRewriting = (function () { var isFirst = true; for (var key in parsed) { var value = parsed[key]; + + value = this.parseURIsInJSONString(value); if (isWriteableValue(value)) { if (propertyAccessorTokens.length > 0) propertyAccessorTokens.push(", "); @@ -1309,7 +1339,13 @@ ko.exportSymbol('ko.jsonExpressionRewriting.insertPropertyReaderWritersIntoJson' var json = " { " + ko.jsonExpressionRewriting.insertPropertyReaderWritersIntoJson(attributeText) + " } "; return ko.utils.evalWithinScope(json, viewModel === null ? window : viewModel, node); } catch (ex) { - throw new Error("Unable to parse binding attribute.\nMessage: " + ex + ";\nAttribute value: " + attributeText); + if(typeof(console) !== 'undefined') { + console.log("!!! ERROR"); + console.log(attributeText); + console.log(ex); + } + //@modified + //throw new Error("Unable to parse binding attribute.\nMessage: " + ex + ";\nAttribute value: " + attributeText); } } @@ -1797,7 +1833,12 @@ ko.bindingHandlers['attr'] = { if ((attrValue === false) || (attrValue === null) || (attrValue === undefined)) element.removeAttribute(attrName); else - element.setAttribute(attrName, attrValue.toString()); + // @modified + var actualValue = attrValue.toString(); + if(actualValue[0] === '<' && actualValue[actualValue.length-1] === '>') { + actualValue = actualValue.substring(1,actualValue.length-1); + } + element.setAttribute(attrName, actualValue); } } } @@ -1951,9 +1992,24 @@ ko.exportSymbol('ko.templateRewriting.applyMemoizedBindingsToNextSibling', ko.te ko.renderTemplateForEach = function (template, arrayOrObservableArray, options, targetNode) { return new ko.dependentObservable(function () { var unwrappedArray = ko.utils.unwrapObservable(arrayOrObservableArray) || []; - if (typeof unwrappedArray.length == "undefined") // Coerce single value into array + + // @modified + if (unwrappedArray.constructor != Array) // Coerce single value into array unwrappedArray = [unwrappedArray]; + // @modified + // wrapping automatically non objects + for(var i=0; i "+uri); + var uri; - if(uri == null) { + if(relValue != null) { + uri = relValue(); + uri = sko.NTUri(uri); + sko.log("*** OBSERVABLE READING RELATED DEPENDING NODE ABOT ID:"+nextId+" URI -> "+uri); + } else { sko.log(" ** NEXT URI IS NULL, GEN BLANK LABEL"); uri = sko.nextBlankLabel(); } @@ -3338,20 +3395,72 @@ sko.Resource.storeObserver = function(skoResource) { node.forEach(function(triple){ if(triple.object.interfaceName === 'NamedNode') { sko.log(" "+triple.predicate.toNT()+" -> "+triple.object.toNT()); - newValues[triple.predicate.toNT()] = triple.object.toNT(); + + if(newValues[triple.predicate.toNT()] != null) { + if(newValues[triple.predicate.toNT()].constructor === Array) { + // more than one, added to array. + // @todo what if named nodes and literals are mixed? + newValues[triple.predicate.toNT()].push(triple.object.toNT()); + newValues[triple.predicate.toNT()].sort(); + } else { + newValues[triple.predicate.toNT()] = [newValues[triple.predicate.toNT()], triple.object.toNT()]; + } + + } else { + newValues[triple.predicate.toNT()] = triple.object.toNT(); + } } else { if(skoResource.defaultLanguage() != null) { if(newValues[triple.predicate.toNT()] == null || triple.object.language == skoResource.defaultLanguage()) { - sko.log(" "+triple.predicate.toNT()+" -> "+triple.object.valueOf()); - newValues[triple.predicate.toNT()] = triple.object.valueOf(); - newValuesLangs[triple.predicate.toNT()] = triple.object.language; + if(newValues[triple.predicate.toNT()] != null) { + if(newValues[triple.predicate.toNT()].constructor === Array) { + // more than one, added to array. + // The value in the array cannot have a null lang + // @todo what if named nodes and literals are mixed? + newValues[triple.predicate.toNT()].push(triple.object.valueOf()); + newValues[triple.predicate.toNT()].sort(); + } else { + if(newValuesLangs[triple.predicate.toNT()] != triple.object.language) { + // replace old value (no lang) by a new value with lang + newValues[triple.predicate.toNT()] = triple.object.valueOf(); + newValuesLangs[triple.predicate.toNT()] = triple.object.language; + } else { + // last value was a single value with the correct lang -> now is an array + newValues[triple.predicate.toNT()] = [newValues[triple.predicate.toNT()], triple.object.valueOf()]; + } + } + } else { + // set up a default value, with null or correct lang + sko.log(" "+triple.predicate.toNT()+" -> "+triple.object.valueOf()); + newValues[triple.predicate.toNT()] = triple.object.valueOf(); + newValuesLangs[triple.predicate.toNT()] = triple.object.language; + } } } else { - if(newValues[triple.predicate.toNT()] == null || triple.object.language == null) { - sko.log(" "+triple.predicate.toNT()+" -> "+triple.object.valueOf()); - newValues[triple.predicate.toNT()] = triple.object.valueOf(); - newValuesLangs[triple.predicate.toNT()] = triple.object.language; - } + if(newValues[triple.predicate.toNT()] == null || triple.object.language == null) { + if(newValues[triple.predicate.toNT()] != null) { + if(newValues[triple.predicate.toNT()].constructor === Array) { + // more than one, added to array. + // @todo what if named nodes and literals are mixed? + newValues[triple.predicate.toNT()].push(triple.object.valueOf()); + newValues[triple.predicate.toNT()].sort(); + } else { + if(newValuesLangs[triple.predicate.toNT()] != null) { + // replace old value (with lang) by a new value with no lang + newValues[triple.predicate.toNT()] = triple.object.valueOf(); + newValuesLangs[triple.predicate.toNT()] = triple.object.language; + } else { + // last value was a single value with the correct lang -> now is an array + newValues[triple.predicate.toNT()] = [newValues[triple.predicate.toNT()], triple.object.valueOf()]; + } + + } + } else { + sko.log(" "+triple.predicate.toNT()+" -> "+triple.object.valueOf()); + newValues[triple.predicate.toNT()] = triple.object.valueOf(); + newValuesLangs[triple.predicate.toNT()] = triple.object.language; + } + } } } }); @@ -3365,12 +3474,21 @@ sko.Resource.storeObserver = function(skoResource) { for(var p in skoResource.valuesMap) { if(newValues[p] != null) { newValueMap[p] = newValues[p]; - if(skoResource.valuesMap[p] !== newValues[p]) { - toUpdate.push(p); - if(newValuesLangs[p] != null || skoResource.literalLangs[p] != null) { - skoResource.literalLangs[p] = newValuesLangs[p]; + if(skoResource.valuesMap[p] && + skoResource.valuesMap[p].constructor === Array && + newValue[p].constructor === Array) { + if(skoResource.valuesMap[p].length != newValue[p].length) { + // @todo check also the individual URIS + toUpdate.push(p); + } + } else { + if(skoResource.valuesMap[p] !== newValues[p]) { + toUpdate.push(p); + if(newValuesLangs[p] != null || skoResource.literalLangs[p] != null) { + skoResource.literalLangs[p] = newValuesLangs[p]; + } } - } + } } else { toNullify.push(p); delete skoResource.literalLangs[p]; diff --git a/build/output/knockout-latest.js b/build/output/knockout-latest.js index 135d2fb..df71245 100644 --- a/build/output/knockout-latest.js +++ b/build/output/knockout-latest.js @@ -5,27 +5,27 @@ (function(window,undefined){ var ko=window.ko={};ko.exportSymbol=function(a,d){for(var c=a.split("."),b=window,e=0;eko.utils.arrayIndexOf(b,a[c])&&b.push(a[c]);return b},arrayMap:function(a,b){for(var a=a||[],c=[],d=0,e=a.length;da.length?!1:a.substring(0,b.length)===b},evalWithinScope:function(a,b,c){if(void 0===b)return(new Function("return "+ -a))();b.skonode=c;return(new Function("__SKO__sc","with(__SKO__sc){ var innerNode=skonode; return ("+a+") }"))(b)},domNodeIsContainedBy:function(a,b){if(b.compareDocumentPosition)return 16==(b.compareDocumentPosition(a)&16);for(;null!=a;){if(a==b)return!0;a=a.parentNode}return!1},domNodeIsAttachedToDocument:function(a){return ko.utils.domNodeIsContainedBy(a,document)},registerEventHandler:function(b,c,d){if("undefined"!=typeof jQuery){if(a(b,c))var e=d,d=function(a,b){var c=this.checked;if(b)this.checked= -!0!==b.checkedStateBeforeEvent;e.call(this,a);this.checked=c};jQuery(b).bind(c,d)}else if("function"==typeof b.addEventListener)b.addEventListener(c,d,!1);else if("undefined"!=typeof b.attachEvent)b.attachEvent("on"+c,function(a){d.call(b,a)});else throw Error("Browser doesn't support addEventListener or attachEvent");},triggerEvent:function(b,c){if(!b||!b.nodeType)throw Error("element must be a DOM node when calling triggerEvent");if("undefined"!=typeof jQuery){var d=[];a(b,c)&&d.push({checkedStateBeforeEvent:b.checked}); -jQuery(b).trigger(c,d)}else if("function"==typeof document.createEvent)if("function"==typeof b.dispatchEvent)d=document.createEvent(g[c]||"HTMLEvents"),d.initEvent(c,!0,!0,window,0,0,0,0,0,!1,!1,!1,!1,0,b),b.dispatchEvent(d);else throw Error("The supplied element doesn't support dispatchEvent");else if("undefined"!=typeof b.fireEvent){if("click"==c&&"INPUT"==b.tagName&&("checkbox"==b.type.toLowerCase()||"radio"==b.type.toLowerCase()))b.checked=!0!==b.checked;b.fireEvent("on"+c)}else throw Error("Browser doesn't support triggering events"); -},unwrapObservable:function(a){return ko.isObservable(a)?a():a},domNodeHasCssClass:function(a,b){var c=(a.className||"").split(/\s+/);return 0<=ko.utils.arrayIndexOf(c,b)},toggleDomNodeCssClass:function(a,b,c){var d=ko.utils.domNodeHasCssClass(a,b);if(c&&!d)a.className=(a.className||"")+" "+b;else if(d&&!c){for(var c=(a.className||"").split(/\s+/),d="",e=0;eko.utils.arrayIndexOf(b,a[c])&&b.push(a[c]);return b},arrayMap:function(a,b){for(var a=a||[],c=[],e=0,d=a.length;ea.length?!1:a.substring(0,b.length)===b},evalWithinScope:function(a,b,c){if(void 0===b)return(new Function("return "+ +a))();b.skonode=c;return(new Function("__SKO__sc","with(__SKO__sc){ var innerNode=skonode; return ("+a+") }"))(b)},domNodeIsContainedBy:function(a,b){if(b.compareDocumentPosition)return 16==(b.compareDocumentPosition(a)&16);for(;null!=a;){if(a==b)return!0;a=a.parentNode}return!1},domNodeIsAttachedToDocument:function(a){return ko.utils.domNodeIsContainedBy(a,document)},registerEventHandler:function(b,c,e){if("undefined"!=typeof jQuery){if(a(b,c))var d=e,e=function(a,b){var c=this.checked;if(b)this.checked= +!0!==b.checkedStateBeforeEvent;d.call(this,a);this.checked=c};jQuery(b).bind(c,e)}else if("function"==typeof b.addEventListener)b.addEventListener(c,e,!1);else if("undefined"!=typeof b.attachEvent)b.attachEvent("on"+c,function(a){e.call(b,a)});else throw Error("Browser doesn't support addEventListener or attachEvent");},triggerEvent:function(b,c){if(!b||!b.nodeType)throw Error("element must be a DOM node when calling triggerEvent");if("undefined"!=typeof jQuery){var e=[];a(b,c)&&e.push({checkedStateBeforeEvent:b.checked}); +jQuery(b).trigger(c,e)}else if("function"==typeof document.createEvent)if("function"==typeof b.dispatchEvent)e=document.createEvent(g[c]||"HTMLEvents"),e.initEvent(c,!0,!0,window,0,0,0,0,0,!1,!1,!1,!1,0,b),b.dispatchEvent(e);else throw Error("The supplied element doesn't support dispatchEvent");else if("undefined"!=typeof b.fireEvent){if("click"==c&&"INPUT"==b.tagName&&("checkbox"==b.type.toLowerCase()||"radio"==b.type.toLowerCase()))b.checked=!0!==b.checked;b.fireEvent("on"+c)}else throw Error("Browser doesn't support triggering events"); +},unwrapObservable:function(a){return ko.isObservable(a)?a():a},domNodeHasCssClass:function(a,b){var c=(a.className||"").split(/\s+/);return 0<=ko.utils.arrayIndexOf(c,b)},toggleDomNodeCssClass:function(a,b,c){var e=ko.utils.domNodeHasCssClass(a,b);if(c&&!e)a.className=(a.className||"")+" "+b;else if(e&&!c){for(var c=(a.className||"").split(/\s+/),e="",d=0;d",""]||!d.indexOf("",""]||(!d.indexOf("",""]||[0,"",""];for(c.innerHTML=d[1]+a+d[2];d[0]--;)c=c.lastChild;a=ko.utils.makeArray(c.childNodes)}return a};ko.utils.setHtml= -function(a,d){ko.utils.emptyDomNode(a);if(null!==d&&void 0!==d)if("string"!=typeof d&&(d=d.toString()),"undefined"!=typeof jQuery)jQuery(a).html(d);else for(var c=ko.utils.parseHtmlFragment(d),b=0;b",">"))}else for(var b=ko.utils.parseHtmlFragment(d),e=0;e"},unmemoize:function(a, d){var g=c[a];if(void 0===g)throw Error("Couldn't find any memo with ID "+a+". Perhaps it's already been unmemoized.");try{return g.apply(null,d||[]),!0}finally{delete c[a]}},unmemoizeDomNodeAndDescendants:function(a,c){var g=[];d(a,g);for(var h=0,f=g.length;h"==a[a.length-1]?!0:null!==a.match(b)}var c=/\[ko_token_(\d+)\]/g,b=/^[\_$a-z][\_$a-z0-9]*(\[.*?\])*(\.[\_$a-z][\_$a-z0-9]*(\[.*?\])*)*$/i,e=["true","false"];return{parseJson:function(b){b=ko.utils.stringTrim(b);if(3>b.length)return{};for(var c=[],d=null,e,i,k="{"==b.charAt(0)?1:0;k";break;case "{":d=k;i=1;e="}";break;case "[":d=k,e="]"}else if("}"==e&&"{"==m)i++;else if("}"==e&&"}"==m&&1"===k[k.length-1]&&"about"!==i&&"rel"!==i?b.push(i+" : function(__ko_value) { sko.current = function() { return sko.currentResource(innerNode); }; sko.current().tryProperty('"+k+"') = __ko_value; }"):null!=k.match(/^\[[^,;"\]\}\{\[\.:]+:[^,;"\}\]\{\[\.:]+\]$/)&&"about"!==i&&"rel"!==i?b.push(i+" : function(__ko_value) { sko.current = function() { return sko.currentResource(innerNode); }; sko.current().tryProperty('"+ -k+"') = __ko_value; }"):"<"===k[0]&&">"===k[k.length-1]&&("about"===i||"rel"===i)||"["===k[0]&&"]"===k[k.length-1]&&("about"===i||"rel"===i)||(/tryProperty\([^)]+\)$/.test(k)||/prop\([^)]+\)$/.test(k)?b.push(i+" : function(__ko_value) { sko.current = function() { return sko.currentResource(innerNode); }; "+k+"(__ko_value); }"):b.push(i+" : function(__ko_value) { sko.current = function() { return sko.currentResource(innerNode); }; "+k+" = __ko_value; }")));e?e=!1:c+=", ";c="<"===k[0]&&">"===k[k.length- -1]&&"about"!==i&&"rel"!==i?c+i+": (function(){ sko.current = function() { return sko.currentResource(innerNode); }; return sko.current().tryProperty('"+k+"') })()":null!=k.match(/^\[[^,;"\]\}\{\[\.:]+:[^,;"\}\]\{\[\.:]+\]$/)&&"about"!==i&&"rel"!==i?c+i+": (function(){ sko.current = function() { return sko.currentResource(innerNode); }; return sko.current().tryProperty('"+k+"') })()":"<"===k[0]&&">"===k[k.length-1]&&("about"===i||"rel"===i)?c+i+": '"+k.slice(1,k.length-1)+"'":null!=k.match(/^\[[^,;"\]\}\{\[\.:]+:[^,;"\}\]\{\[\.:]+\]$/)&& -("about"===i||"rel"===i)?c+i+": sko.rdf.prefixes.resolve('"+k.slice(1,k.length-1)+"')":c+i+": (function(){ sko.current = function() { return sko.currentResource(innerNode); }; return "+k+" })()"}a=c;0)['"]?/g,c="",d=b.exec(a);null!=d;){if(("'"===d[0][0]||'"'===d[0][0])&&("'"===d[0][d[0].length-1]||'"'===d[0][d[0].length-1]))a=a.split(d[0]),c=c+a[0]+d[0],a=a[1];else var e=d[0],d=d.index,c=a.substring(0,d)+"sko.current().tryProperty('"+e+"')",a=a.substring(d+e.length);d=b.exec(a)}return c+a},insertPropertyReaderWritersIntoJson:function(a){var a=ko.jsonExpressionRewriting.parseJson(a),b=[],c="",e=!0,i;for(i in a){var k=a[i],k=this.parseURIsInJSONString(k);d(k)&&(0< +b.length&&b.push(", "),"<"===k[0]&&">"===k[k.length-1]&&"about"!==i&&"rel"!==i?b.push(i+" : function(__ko_value) { sko.current = function() { return sko.currentResource(innerNode); }; sko.current().tryProperty('"+k+"') = __ko_value; }"):null!=k.match(/^\[[^,;"\]\}\{\[\.:]+:[^,;"\}\]\{\[\.:]+\]$/)&&"about"!==i&&"rel"!==i?b.push(i+" : function(__ko_value) { sko.current = function() { return sko.currentResource(innerNode); }; sko.current().tryProperty('"+k+"') = __ko_value; }"):"<"===k[0]&&">"===k[k.length- +1]&&("about"===i||"rel"===i)||"["===k[0]&&"]"===k[k.length-1]&&("about"===i||"rel"===i)||(/tryProperty\([^)]+\)$/.test(k)||/prop\([^)]+\)$/.test(k)?b.push(i+" : function(__ko_value) { sko.current = function() { return sko.currentResource(innerNode); }; "+k+"(__ko_value); }"):b.push(i+" : function(__ko_value) { sko.current = function() { return sko.currentResource(innerNode); }; "+k+" = __ko_value; }")));e?e=!1:c+=", ";c="<"===k[0]&&">"===k[k.length-1]&&"about"!==i&&"rel"!==i?c+i+": (function(){ sko.current = function() { return sko.currentResource(innerNode); }; return sko.current().tryProperty('"+ +k+"') })()":null!=k.match(/^\[[^,;"\]\}\{\[\.:]+:[^,;"\}\]\{\[\.:]+\]$/)&&"about"!==i&&"rel"!==i?c+i+": (function(){ sko.current = function() { return sko.currentResource(innerNode); }; return sko.current().tryProperty('"+k+"') })()":"<"===k[0]&&">"===k[k.length-1]&&("about"===i||"rel"===i)?c+i+": '"+k.slice(1,k.length-1)+"'":null!=k.match(/^\[[^,;"\]\}\{\[\.:]+:[^,;"\}\]\{\[\.:]+\]$/)&&("about"===i||"rel"===i)?c+i+": sko.rdf.prefixes.resolve('"+k.slice(1,k.length-1)+"')":c+i+": (function(){ sko.current = function() { return sko.currentResource(innerNode); }; return "+ +k+" })()"}a=c;0"),!1)}};ko.bindingHandlers.uniqueName.currentIndex=0; ko.bindingHandlers.checked={init:function(a,d,c){ko.utils.registerEventHandler(a,"click",function(){var b;if("checkbox"==a.type)b=a.checked;else if("radio"==a.type&&a.checked)b=a.value;else return;var e=d();"checkbox"==a.type&&ko.utils.unwrapObservable(e)instanceof Array?(b=ko.utils.arrayIndexOf(ko.utils.unwrapObservable(e),a.value),a.checked&&0>b?e.push(a.value):!a.checked&&0<=b&&e.splice(b,1)):ko.isWriteableObservable(e)?e()!==b&&e(b):(e=c(),e._ko_property_writers&&e._ko_property_writers.checked&& e._ko_property_writers.checked(b))});"radio"==a.type&&!a.name&&ko.bindingHandlers.uniqueName.init(a,function(){return!0})},update:function(a,d){var c=ko.utils.unwrapObservable(d());if("checkbox"==a.type)a.checked=c instanceof Array?0<=ko.utils.arrayIndexOf(c,a.value):c,c&&ko.utils.isIe6&&a.mergeAttributes(document.createElement(""),!1);else if("radio"==a.type)a.checked=a.value==c,a.value==c&&(ko.utils.isIe6||ko.utils.isIe7)&&a.mergeAttributes(document.createElement(""), -!1)}};ko.bindingHandlers.attr={update:function(a,d){var c=ko.utils.unwrapObservable(d())||{},b;for(b in c)if("string"==typeof b){var e=ko.utils.unwrapObservable(c[b]);!1===e||null===e||void 0===e?a.removeAttribute(b):a.setAttribute(b,e.toString())}}}; +!1)}};ko.bindingHandlers.attr={update:function(a,d){var c=ko.utils.unwrapObservable(d())||{},b;for(b in c)if("string"==typeof b){var e=ko.utils.unwrapObservable(c[b]);if(!1===e||null===e||void 0===e)a.removeAttribute(b);else var g=e.toString();"<"===g[0]&&">"===g[g.length-1]&&(g=g.substring(1,g.length-1));a.setAttribute(b,g)}}}; ko.templateEngine=function(){this.renderTemplate=function(){throw"Override renderTemplate in your ko.templateEngine subclass";};this.isTemplateRewritten=function(){throw"Override isTemplateRewritten in your ko.templateEngine subclass";};this.rewriteTemplate=function(){throw"Override rewriteTemplate in your ko.templateEngine subclass";};this.createJavaScriptEvaluatorBlock=function(){throw"Override createJavaScriptEvaluatorBlock in your ko.templateEngine subclass";}}; ko.exportSymbol("ko.templateEngine",ko.templateEngine); ko.templateRewriting=function(){var a=/(<[a-z]+\d*(\s+(?!data-bind=)[a-z0-9\-]+(=(\"[^\"]*\"|\'[^\']*\'))?)*\s+)data-bind=(["'])([\s\S]*?)\5/gi;return{ensureTemplateIsRewritten:function(a,c){c.isTemplateRewritten(a)||c.rewriteTemplate(a,function(a){return ko.templateRewriting.memoizeBindingAttributeSyntax(a,c)})},memoizeBindingAttributeSyntax:function(d,c){return d.replace(a,function(a,d,g,h,f,j,i){a=ko.jsonExpressionRewriting.insertPropertyReaderWritersIntoJson(i);return c.createJavaScriptEvaluatorBlock("ko.templateRewriting.applyMemoizedBindingsToNextSibling(function() { return (function() { var innerNode=skonode; return { "+ a+" } })() })")+d})},applyMemoizedBindingsToNextSibling:function(a){return ko.memoization.memoize(function(c,b){c.nextSibling&&sko.traceResources(c.nextSibling,b,function(){sko.traceRelations(c.nextSibling,b,function(){ko.applyBindingsToNode(c.nextSibling,a,b)})})})}}}();ko.exportSymbol("ko.templateRewriting",ko.templateRewriting);ko.exportSymbol("ko.templateRewriting.applyMemoizedBindingsToNextSibling",ko.templateRewriting.applyMemoizedBindingsToNextSibling); (function(){function a(a,b,e,g,h){var f=ko.utils.unwrapObservable(g),h=h||{},j=h.templateEngine||d;ko.templateRewriting.ensureTemplateIsRewritten(e,j);e=j.renderTemplate(e,f,h);if("number"!=typeof e.length||0 "+e+" : "+b+" 8b");sko.aboutResourceMap[e]=new sko.Resource(e,b,c)})):sko.log("*** Related resource hasn't changed"),b;if(null==b){sko.log("*** related resource is null");sko.log(" ** NEXT URI IS NULL, GEN BLANK LABEL");var c=sko.nextBlankLabel();sko.log(" ** setting parent node related resource to "+ c);a[h](c)}else sko.aboutResourceMap[e]?(sko.log("*** setting new value for related resource "+c),sko.log(" ------------\> "+e+" : "+c+" 9"),sko.aboutResourceMap[e].about(c)):sko.log("!! Should I create the new blank node?");return c}sko.log("!!! parent resource doest not link to the related resource")}else sko.log("!!! impossible to find parent resource")},write:function(a){null==a&&(sko.log(" ** NEXT URI IS NULL, GEN BLANK LABEL"),a=sko.nextBlankLabel());a=sko.NTUri(a);sko.log("*** OBSERVABLE WRITING RELATED DEPENDING NODE ABOT ID:"+ e+" URI -> "+a);var b=sko.currentResource(jQuery(d).parent().toArray()[0]);null!=b?(sko.log("*** Found parent resource: "+b.about()),b[g]?(sko.log("*** Setting new related resource in parent resource found: "+a),b[g](a)):sko.log("!!! parent resource doest not link to the related resource")):sko.log("!!! impossible to find parent resource")},owner:c});c=sko.about[e].subscribe(function(a){sko.log("*** OBSERVING RELATED NODE ABOT ID:"+e+" new value -> "+a);null==a&&(sko.log(" ** NEXT URI IS NULL, GEN BLANK LABEL"), -a=sko.nextBlankLabel());a=sko.NTUri(a);null!=sko.about[e]()?sko.plainUri(a)!==sko.plainUri(sko.about[e]())&&sko.store.node(sko.plainUri(a),function(b,c){b?(c.toArray(),sko.log(" ------------\> "+e+" : "+h+" 10"),sko.aboutResourceMap[e].about(h)):sko.log("Error updating 1 resource for URI:"+a+" in SKO about related node observer")}):sko.log("!! this resource is now null, should be removed from list of resources?")})}else sko.about[e]=ko.dependentObservable({read:function(){var b=a(),b=sko.NTUri(b); -sko.log("*** OBSERVABLE READING RELATED DEPENDING NODE ABOT ID:"+e+" URI -> "+b);null==b&&(sko.log(" ** NEXT URI IS NULL, GEN BLANK LABEL"),b=sko.nextBlankLabel());var c=sko.currentResource(jQuery(d).parent().toArray()[0]);if(null!=c){sko.log("*** Found parent resource: "+c.about());if(c[b]){var g=c[b]();sko.log("*** found related resource: "+g);sko.store.node(sko.plainUri(g),function(a,b){sko.log(" ------------\> "+e+" : "+g+" 11");sko.aboutResourceMap[e]=new sko.Resource(e,g,b)});return g}sko.log("!!! parent resource doest not link to the related resource")}else sko.log("!!! impossible to find parent resource")}, +a=sko.nextBlankLabel());a=sko.NTUri(a);null!=sko.about[e]()?sko.plainUri(a)!==sko.plainUri(sko.about[e]())&&sko.store.node(sko.plainUri(a),function(b,c){b?(c.toArray(),sko.log(" ------------\> "+e+" : "+h+" 10"),sko.aboutResourceMap[e].about(h)):sko.log("Error updating 1 resource for URI:"+a+" in SKO about related node observer")}):sko.log("!! this resource is now null, should be removed from list of resources?")})}else sko.about[e]=ko.dependentObservable({read:function(){var b;null!=a?(b=a(),b=sko.NTUri(b), +sko.log("*** OBSERVABLE READING RELATED DEPENDING NODE ABOT ID:"+e+" URI -> "+b)):(sko.log(" ** NEXT URI IS NULL, GEN BLANK LABEL"),b=sko.nextBlankLabel());var c=sko.currentResource(jQuery(d).parent().toArray()[0]);if(null!=c){sko.log("*** Found parent resource: "+c.about());if(c[b]){var g=c[b]();sko.log("*** found related resource: "+g);sko.store.node(sko.plainUri(g),function(a,b){sko.log(" ------------\> "+e+" : "+g+" 11");sko.aboutResourceMap[e]=new sko.Resource(e,g,b)});return g}sko.log("!!! parent resource doest not link to the related resource")}else sko.log("!!! impossible to find parent resource")}, write:function(b){var b=sko.NTUri(b),c=sko.currentResource(jQuery(d).parent().toArray()[0]);sko.log("*** OBSERVABLE WRITING RELATED DEPENDING NODE ABOT ID:"+e+" URI -> "+b);null==b&&(sko.log(" ** NEXT URI IS NULL, GEN BLANK LABEL"),b=sko.nextBlankLabel());null!=c?(sko.log("*** Found parent resource: "+c.about()),c[a()]?(sko.log("*** Setting new related resource in parent resource found: "+b),c[a()](b),a(b)):sko.log("!!! parent resource doest not link to the related resource")):sko.log("!!! impossible to find parent resource")}, owner:c}),c=sko.about[e].subscribe(function(a){a=sko.NTUri(a);sko.log("*** OBSERVING RELATED NODE (F) ABOT ID:"+e+" new value -> "+a);null==a&&(sko.log(" ** NEXT URI IS NULL, GEN BLANK LABEL"),a=sko.nextBlankLabel());sko.plainUri(a)!=sko.plainUri(sko.about[e]())?sko.store.node(sko.plainUri(a),function(b,c){if(b){var d=c.toArray()[0].subject.valueOf();sko.log(" ------------\> "+e+" : "+d+" 12");sko.aboutResourceMap[e].about(d)}else sko.log("Error updating 2 resource for URI:"+a+" in SKO about related node observer")}): sko.log("*** Related about resource hasn't changed")});sko.aboutResourceSubscriptionMap[e]=c;b(e)};sko.plainUri=function(a){if("<"===a[0]&&">"==a[a.length-1])return a.slice(1,a.length-1);if(null!=a.match(/\[[^,;"\]\}\{\[\.:]+:[^,;"\}\]\{\[\.:]+\]/)){a=a.slice(1,a.length-1);resolved=sko.rdf.prefixes.resolve(a);if(null==resolved)throw"The CURIE "+a+" cannot be resolved";return resolved}return a}; @@ -134,8 +135,10 @@ d&&!sko.isSKOBlankNode(d)){var c='"'+this.valuesMap[a]+'"',d='"'+d+'"';null!=thi sko.Resource.prototype.disconnect=function(){sko.log(" ** DISCONNECTING");sko.store.stopObservingNode(this.storeObserverFn);sko.log(" ** disconnected STORE");for(var a=0;a "+d.toArray().length);d.forEach(function(d){if("NamedNode"===d.object.interfaceName)sko.log(" "+d.predicate.toNT()+" -> "+d.object.toNT()),c[d.predicate.toNT()]=d.object.toNT();else if(null!=a.defaultLanguage()){if(null==c[d.predicate.toNT()]||d.object.language==a.defaultLanguage())sko.log(" "+ -d.predicate.toNT()+" -> "+d.object.valueOf()),c[d.predicate.toNT()]=d.object.valueOf(),b[d.predicate.toNT()]=d.object.language}else if(null==c[d.predicate.toNT()]||null==d.object.language)sko.log(" "+d.predicate.toNT()+" -> "+d.object.valueOf()),c[d.predicate.toNT()]=d.object.valueOf(),b[d.predicate.toNT()]=d.object.language});var e={},d=[],g=[],h=[],f;for(f in a.valuesMap)if(null!=c[f]){if(e[f]=c[f],a.valuesMap[f]!==c[f]&&(g.push(f),null!=b[f]||null!=a.literalLangs[f]))a.literalLangs[f]=b[f]}else d.push(f), +sko.Resource.storeObserver=function(a){return function(d){sko.log("*** received notification change from STORE in resource "+a.about());if(0!==a.about().indexOf("_:sko")){var c={},b={};sko.log("*** triples in STORE resource -> "+d.toArray().length);d.forEach(function(d){if("NamedNode"===d.object.interfaceName)sko.log(" "+d.predicate.toNT()+" -> "+d.object.toNT()),null!=c[d.predicate.toNT()]?c[d.predicate.toNT()].constructor===Array?(c[d.predicate.toNT()].push(d.object.toNT()),c[d.predicate.toNT()].sort()): +c[d.predicate.toNT()]=[c[d.predicate.toNT()],d.object.toNT()]:c[d.predicate.toNT()]=d.object.toNT();else if(null!=a.defaultLanguage()){if(null==c[d.predicate.toNT()]||d.object.language==a.defaultLanguage())null!=c[d.predicate.toNT()]?c[d.predicate.toNT()].constructor===Array?(c[d.predicate.toNT()].push(d.object.valueOf()),c[d.predicate.toNT()].sort()):b[d.predicate.toNT()]!=d.object.language?(c[d.predicate.toNT()]=d.object.valueOf(),b[d.predicate.toNT()]=d.object.language):c[d.predicate.toNT()]=[c[d.predicate.toNT()], +d.object.valueOf()]:(sko.log(" "+d.predicate.toNT()+" -> "+d.object.valueOf()),c[d.predicate.toNT()]=d.object.valueOf(),b[d.predicate.toNT()]=d.object.language)}else if(null==c[d.predicate.toNT()]||null==d.object.language)null!=c[d.predicate.toNT()]?c[d.predicate.toNT()].constructor===Array?(c[d.predicate.toNT()].push(d.object.valueOf()),c[d.predicate.toNT()].sort()):null!=b[d.predicate.toNT()]?(c[d.predicate.toNT()]=d.object.valueOf(),b[d.predicate.toNT()]=d.object.language):c[d.predicate.toNT()]= +[c[d.predicate.toNT()],d.object.valueOf()]:(sko.log(" "+d.predicate.toNT()+" -> "+d.object.valueOf()),c[d.predicate.toNT()]=d.object.valueOf(),b[d.predicate.toNT()]=d.object.language)});var e={},d=[],g=[],h=[],f;for(f in a.valuesMap)if(null!=c[f])if(e[f]=c[f],a.valuesMap[f]&&a.valuesMap[f].constructor===Array&&newValue[f].constructor===Array)a.valuesMap[f].length!=newValue[f].length&&g.push(f);else{if(a.valuesMap[f]!==c[f]&&(g.push(f),null!=b[f]||null!=a.literalLangs[f]))a.literalLangs[f]=b[f]}else d.push(f), delete a.literalLangs[f];for(f in c)null==a.valuesMap[f]&&(h.push(f),e[f]=c[f],a.literalLangs[f]=b[f]);a.valuesMap=e;for(f=0;f NULL"),a[d[f]](null);for(f=0;f "+a.valuesMap[g[f]]),a[g[f]](a.valuesMap[g[f]]);for(f=0;f "+a.valuesMap[h[f]]),a[h[f]]=ko.observable(a.valuesMap[h[f]]),a[sko.plainUri(h[f])]=a[h[f]];sko.Class.check(a);sko.log("*** END MODIFICATION")}}}; sko.traceResources=function(a,d,c){sko.log("** TRACING:");sko.log(a);var b=[];(jQuery(a).attr("about")||jQuery(a).attr("data-bind"))&&b.push(a);var a=jQuery(a).find("*[about], *[data-bind]").toArray(),b=b.concat(a),e=function(a,c){node=b[c._i];var f=jQuery(node).attr("about");null==jQuery(node).attr("aboutId")?(null==f&&(dataBind=jQuery(node).attr("data-bind"),null!=dataBind&&-1!=dataBind.indexOf("about:")&&(f=/s*([^ ]+)s*,?/.exec(dataBind.split("about:")[1])[0],","===f[f.length-1]&&(f=f.slice(0, f.length-1)))),null!=f&&""!=f?("string"===typeof f&&"<"!==f[0]&&">"!==f[f.length-1]&&"["!==f[0]&&"]"!==f[f.length-1]&&(f=d[f]),sko.about(f,d,function(b){jQuery(node).attr("aboutId",b);a(e,c)})):a(e,c)):a(e,c)};Utils.repeat(0,b.length,e,function(){c()})}; diff --git a/deps/rdf_store.js b/deps/rdf_store.js index 17729b6..72c4350 100644 --- a/deps/rdf_store.js +++ b/deps/rdf_store.js @@ -1,5 +1,11 @@ (function() { + + if(typeof(console)=='undefined') { + console = {}; + console.log = function(e){}; + } + var Utils = {}; @@ -22,9 +28,13 @@ Utils.recur = function(c){ } }; +Utils.clone = function(o) { + return JSON.parse(JSON.stringify(o)); +}; + Utils.shuffle = function(o){ //v1.0 - for(var j, x, i = o.length; i; j = parseInt(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x); - return o; + for(var j, x, i = o.length; i; j = parseInt(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x){}; + return o; }; Utils.include = function(a,v) { @@ -64,7 +74,7 @@ Utils.repeat = function(c,max,floop,fend,env) { floop(function(floop,env){ // avoid stack overflow // deadly hack - Utils.recur(function(){ Utils.repeat(c+1, max, floop, fend, env) }); + Utils.recur(function(){ Utils.repeat(c+1, max, floop, fend, env); }); },env); } else { fend(env); @@ -105,7 +115,7 @@ Utils.seq = function() { }, function(){ callback(); }); - } + }; }; @@ -216,12 +226,12 @@ Utils.parseISO8601Components = function (str) { minutes = Number(d[8]); seconds = Number(d[10]); - if(d[12]) { millisecs = Number("0." + d[12]) * 1000 } + if(d[12]) { millisecs = Number("0." + d[12]) * 1000; } if(d[13]==="Z") { timezone = 0; } else if (d[14]) { - var timezone = 0; + timezone = 0; if(d[17]) { timezone = Number(d[17]); } @@ -290,7 +300,6 @@ Utils.compareDateComponents = function(stra,strb) { }; // RDF utils - Utils.lexicalFormLiteral = function(term, env) { var value = term.value; var lang = term.lang; @@ -300,23 +309,32 @@ Utils.lexicalFormLiteral = function(term, env) { if(value != null && type != null && typeof(type) != 'string') { var typeValue = type.value; - if(typeValue != null) { - indexedValue = '"' + term.value + '"^^<' + typeValue + '>'; - } else { + if(typeValue == null) { var typePrefix = type.prefix; var typeSuffix = type.suffix; var resolvedPrefix = env.namespaces[typePrefix]; term.type = resolvedPrefix+typeSuffix; - indexedValue = '"' + term.value + '"^^<' + resolvedPrefix + typeSuffix + '>'; + typeValue = resolvedPrefix+typeSuffix; } + // normalization + if(typeValue.indexOf('hexBinary') != -1) { + indexedValue = '"' + term.value.toLowerCase() + '"^^<' + typeValue + '>'; + } else { + indexedValue = '"' + term.value + '"^^<' + typeValue + '>'; + } } else { if(lang == null && type == null) { indexedValue = '"' + value + '"'; } else if(type == null) { indexedValue = '"' + value + '"' + "@" + lang; } else { - indexedValue = '"' + term.value + '"^^<'+type+'>'; + // normalization + if(type.indexOf('hexBinary') != -1) { + indexedValue = '"' + term.value.toLowerCase() + '"^^<'+type+'>'; + } else { + indexedValue = '"' + term.value + '"^^<'+type+'>'; + } } } return indexedValue; @@ -335,10 +353,12 @@ Utils.lexicalFormBaseUri = function(term, env) { var resolvedPrefix = env.namespaces[prefix]; if(resolvedPrefix != null) { uri = resolvedPrefix+suffix; + } else { + uri = prefix+":"+suffix; } } else { //console.log(" - URI is not prefixed"); - uri = term.value + uri = term.value; } if(uri===null) { @@ -360,15 +380,14 @@ Utils.lexicalFormBaseUri = function(term, env) { Utils.lexicalFormTerm = function(term, ns) { if(term.token === 'uri') { - return {'uri': Utils.lexicalFormBaseUri(term, ns)} + return {'uri': Utils.lexicalFormBaseUri(term, ns)}; } else if(term.token === 'literal') { return {'literal': Utils.lexicalFormLiteral(term, ns)}; } else if(term.token === 'blank') { - var label = '_:'+ns.blank; - ns.blank = ns.blank+1; + var label = '_:'+term.value; return {'blank': label}; } else { - callback(false, 'Token of kind '+term.token+' cannot transformed into its lexical form'); + throw "Error, cannot get lexical form of unknown token: "+term.token; } }; @@ -411,7 +430,7 @@ Utils.hashTerm = function(term) { } return term; } -} +}; // end of ./src/js-trees/src/utils.js // exports @@ -421,7 +440,7 @@ var left = -1; var right = 1; -/* +/** * @doc * Implementation based on * @@ -509,6 +528,12 @@ InMemoryBTree.Tree.prototype._updateRootNode = function(node) { return node; }; +InMemoryBTree.Tree.prototype.clear = function() { + this.root = this._allocateNode(); + this.root.isLeaf = true; + this.root.level = 0; + this._updateRootNode(this.root); +}; /** * search @@ -1127,8 +1152,8 @@ InMemoryBTree.Tree.prototype.audit = function(showOutput) { if(n.isLeaf === false) { for(var i=0; i check exists : hack only present in the inMemoryAsyncBTree implementation + var result = BaseTree.Tree.prototype.search.call(this, quad, true); // true -> check exists : not present in all the b-tree implementations, check first. if(callback) callback(result) @@ -1411,7 +1438,13 @@ QuadIndex.Tree.prototype.search = function(quad, callback) { }; QuadIndex.Tree.prototype.range = function(pattern, callback) { - var result = this._rangeTraverse(this,this.root, pattern); + var result = null; + if(typeof(this.root)==='string') { + result = this._rangeTraverse(this,this._diskRead(this.root), pattern); + } else { + result = this._rangeTraverse(this,this.root, pattern); + } + if(callback) callback(result); @@ -1423,7 +1456,6 @@ QuadIndex.Tree.prototype._rangeTraverse = function(tree,node, pattern) { var acum = []; var pendingNodes = [node]; var node, idxMin, idxMax; - while(pendingNodes.length > 0) { node = pendingNodes.shift(); idxMin = 0; @@ -1440,7 +1472,8 @@ QuadIndex.Tree.prototype._rangeTraverse = function(tree,node, pattern) { } } else { - var childNode = tree._diskRead(node.children[idxMin]); + var pointer = node.children[idxMin] + var childNode = tree._diskRead(pointer); pendingNodes.push(childNode); var idxMax = idxMin; @@ -1456,7 +1489,6 @@ QuadIndex.Tree.prototype._rangeTraverse = function(tree,node, pattern) { } } } - return acum; }; @@ -1495,7 +1527,10 @@ QuadBackend.QuadBackend = function(configuration, callback) { for(var i=0; i>> 0; + if (typeof fun != "function") + throw new TypeError(); + + var res = []; + var thisp = arguments[1]; + for (var i = 0; i < len; i++) + { + if (i in t) + { + var val = t[i]; // in case fun mutates this + if (fun.call(thisp, val, i, t)) + res.push(val); + } + } + + return res; + }; + } + +} +// define node.js module +else if(typeof(module) !== 'undefined' && module.exports) +{ + var jsonld = {}; + //module.exports = jsonld; + Exception = function(obj) + { + _setMembers(this, obj); + this.stack = new Error().stack; + }; +} + + +jsonldParser = jsonld; + +var defaultContext = { "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#", + "rdfs": "http://www.w3.org/2000/01/rdf-schema#", + "owl": "http://www.w3.org/2002/07/owl#", + "xsd": "http://www.w3.org/2001/XMLSchema#", + "dcterms": "http://purl.org/dc/terms/", + "foaf": "http://xmlns.com/foaf/0.1/", + "cal": "http://www.w3.org/2002/12/cal/ical#", + "vcard": "http://www.w3.org/2006/vcard/ns# ", + "geo": "http://www.w3.org/2003/01/geo/wgs84_pos#", + "cc": "http://creativecommons.org/ns#", + "sioc": "http://rdfs.org/sioc/ns#", + "doap": "http://usefulinc.com/ns/doap#", + "com": "http://purl.org/commerce#", + "ps": "http://purl.org/payswarm#", + "gr": "http://purl.org/goodrelations/v1#", + "sig": "http://purl.org/signature#", + "ccard": "http://purl.org/commerce/creditcard#" + }; + +/* + * Globals and helper functions. + */ +var ns = +{ + xsd: 'http://www.w3.org/2001/XMLSchema#' }; -// imports +var xsd = +{ + 'boolean': ns.xsd + 'boolean', + 'double': ns.xsd + 'double', + 'integer': ns.xsd + 'integer' +}; -TurtleParser.parser = (function(){ - /* Generated by PEG.js 0.6.1 (http://pegjs.majda.cz/). */ - - var result = { - /* - * Parses the input with a generated parser. If the parsing is successfull, - * returns a value explicitly or implicitly specified by the grammar from - * which the parser was generated (see |PEG.buildParser|). If the parsing is - * unsuccessful, throws |PEG.parser.SyntaxError| describing the error. - */ - innerParse: function(input, startRule) { - var parseFunctions = { - "ANON": parse_ANON, - "BLANK_NODE_LABEL": parse_BLANK_NODE_LABEL, - "BlankNode": parse_BlankNode, - "BlankNodePropertyList": parse_BlankNodePropertyList, - "BooleanLiteral": parse_BooleanLiteral, - "COMMENT": parse_COMMENT, - "Collection": parse_Collection, - "DECIMAL": parse_DECIMAL, - "DECIMAL_NEGATIVE": parse_DECIMAL_NEGATIVE, - "DECIMAL_POSITIVE": parse_DECIMAL_POSITIVE, - "DOUBLE": parse_DOUBLE, - "DOUBLE_NEGATIVE": parse_DOUBLE_NEGATIVE, - "DOUBLE_POSITIVE": parse_DOUBLE_POSITIVE, - "ECHAR": parse_ECHAR, - "EXPONENT": parse_EXPONENT, - "GraphNode": parse_GraphNode, - "GraphTerm": parse_GraphTerm, - "INTEGER": parse_INTEGER, - "INTEGER_NEGATIVE": parse_INTEGER_NEGATIVE, - "INTEGER_POSITIVE": parse_INTEGER_POSITIVE, - "IRI_REF": parse_IRI_REF, - "IRIref": parse_IRIref, - "LANGTAG": parse_LANGTAG, - "NIL": parse_NIL, - "NumericLiteral": parse_NumericLiteral, - "NumericLiteralNegative": parse_NumericLiteralNegative, - "NumericLiteralPositive": parse_NumericLiteralPositive, - "NumericLiteralUnsigned": parse_NumericLiteralUnsigned, - "ObjectList": parse_ObjectList, - "PNAME_LN": parse_PNAME_LN, - "PNAME_NS": parse_PNAME_NS, - "PN_CHARS": parse_PN_CHARS, - "PN_CHARS_BASE": parse_PN_CHARS_BASE, - "PN_CHARS_U": parse_PN_CHARS_U, - "PN_LOCAL": parse_PN_LOCAL, - "PN_PREFIX": parse_PN_PREFIX, - "PathAlternative": parse_PathAlternative, - "PathElt": parse_PathElt, - "PathEltOrInverse": parse_PathEltOrInverse, - "PathMod": parse_PathMod, - "PathNegatedPropertySet": parse_PathNegatedPropertySet, - "PathOneInPropertySet": parse_PathOneInPropertySet, - "PathPrimary": parse_PathPrimary, - "PathSequence": parse_PathSequence, - "PrefixedName": parse_PrefixedName, - "PropertyList": parse_PropertyList, - "PropertyListNotEmpty": parse_PropertyListNotEmpty, - "PropertyListNotEmptyPath": parse_PropertyListNotEmptyPath, - "PropertyListPath": parse_PropertyListPath, - "RDFLiteral": parse_RDFLiteral, - "STRING_LITERAL1": parse_STRING_LITERAL1, - "STRING_LITERAL2": parse_STRING_LITERAL2, - "STRING_LITERAL_LONG1": parse_STRING_LITERAL_LONG1, - "STRING_LITERAL_LONG2": parse_STRING_LITERAL_LONG2, - "String": parse_String, - "TriplesBlock": parse_TriplesBlock, - "TriplesNode": parse_TriplesNode, - "TriplesSameSubject": parse_TriplesSameSubject, - "VAR1": parse_VAR1, - "VAR2": parse_VAR2, - "VARNAME": parse_VARNAME, - "Var": parse_Var, - "VarOrIRIref": parse_VarOrIRIref, - "VarOrTerm": parse_VarOrTerm, - "Verb": parse_Verb, - "VerbPath": parse_VerbPath, - "WS": parse_WS, - "base": parse_base, - "directive": parse_directive, - "prefixID": parse_prefixID, - "statement": parse_statement, - "turtleDoc": parse_turtleDoc - }; - - if (startRule !== undefined) { - if (parseFunctions[startRule] === undefined) { - throw new Error("Invalid rule name: " + quote(startRule) + "."); - } - } else { - startRule = "turtleDoc"; +/** + * Sets a subject's property to the given object value. If a value already + * exists, it will be appended to an array. + * + * @param s the subject. + * @param p the property. + * @param o the object. + */ +var _setProperty = function(s, p, o) +{ + if(p in s) + { + if(s[p].constructor === Array) + { + s[p].push(o); } - - var pos = 0; - var reportMatchFailures = true; - var rightmostMatchFailuresPos = 0; - var rightmostMatchFailuresExpected = []; - var cache = {}; - - function padLeft(input, padding, length) { - var result = input; - - var padLength = length - input.length; - for (var i = 0; i < padLength; i++) { - result = padding + result; - } - - return result; + else + { + s[p] = [s[p], o]; } - - function escape(ch) { - var charCode = ch.charCodeAt(0); - - if (charCode <= 0xFF) { - var escapeChar = 'x'; - var length = 2; - } else { - var escapeChar = 'u'; - var length = 4; - } - - return '\\' + escapeChar + padLeft(charCode.toString(16).toUpperCase(), '0', length); + } + else + { + s[p] = o; + } +}; + +/** + * Clones an object, array, or string/number. If cloning an object, the keys + * will be sorted. + * + * @param value the value to clone. + * + * @return the cloned value. + */ +var _clone = function(value) +{ + var rval; + + if(value.constructor === Object) + { + rval = {}; + var keys = Object.keys(value).sort(); + for(var i in keys) + { + var key = keys[i]; + rval[key] = _clone(value[key]); } - - function quote(s) { - /* - * ECMA-262, 5th ed., 7.8.4: All characters may appear literally in a - * string literal except for the closing quote character, backslash, - * carriage return, line separator, paragraph separator, and line feed. - * Any character may appear in the form of an escape sequence. - */ - return '"' + s - .replace(/\\/g, '\\\\') // backslash - .replace(/"/g, '\\"') // closing quote character - .replace(/\r/g, '\\r') // carriage return - .replace(/\n/g, '\\n') // line feed - .replace(/[\x80-\uFFFF]/g, escape) // non-ASCII characters - + '"'; + } + else if(value.constructor === Array) + { + rval = []; + for(var i in value) + { + rval[i] = _clone(value[i]); + } + } + else + { + rval = value; + } + + return rval; +}; + +/** + * Gets the keywords from a context. + * + * @param ctx the context. + * + * @return the keywords. + */ +var _getKeywords = function(ctx) +{ + // TODO: reduce calls to this function by caching keywords in processor + // state + + var rval = + { + '@id': '@id', + '@language': '@language', + '@literal': '@literal', + '@type': '@type' + }; + + if(ctx) + { + // gather keyword aliases from context + var keywords = {}; + for(var key in ctx) + { + if(ctx[key].constructor === String && ctx[key] in rval) + { + keywords[ctx[key]] = key; + } } - function matchFailed(failure) { - if (pos < rightmostMatchFailuresPos) { - return; - } - - if (pos > rightmostMatchFailuresPos) { - rightmostMatchFailuresPos = pos; - rightmostMatchFailuresExpected = []; - } - - rightmostMatchFailuresExpected.push(failure); + // overwrite keywords + for(var key in keywords) + { + rval[key] = keywords[key]; } - - function parse_turtleDoc() { - var cacheKey = 'turtleDoc@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - - var result1 = []; - var result2 = parse_statement(); - while (result2 !== null) { - result1.push(result2); - var result2 = parse_statement(); - } - var result0 = result1 !== null - ? (function(sts) { - return sts; - })(result1) - : null; - - - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; + } + + return rval; +}; + +/** + * Gets the iri associated with a term. + * + * @param ctx the context. + * @param term the term. + * + * @return the iri or NULL. + */ +var _getTermIri = function(ctx, term) +{ + var rval = null; + if(term in ctx) + { + if(ctx[term].constructor === String) + { + rval = ctx[term]; } - - function parse_statement() { - var cacheKey = 'statement@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - - var savedPos1 = pos; - var result12 = []; - var result19 = parse_WS(); - while (result19 !== null) { - result12.push(result19); - var result19 = parse_WS(); - } - if (result12 !== null) { - var result13 = parse_directive(); - if (result13 !== null) { - var result14 = []; - var result18 = parse_WS(); - while (result18 !== null) { - result14.push(result18); - var result18 = parse_WS(); - } - if (result14 !== null) { - if (input.substr(pos, 1) === ".") { - var result15 = "."; - pos += 1; - } else { - var result15 = null; - if (reportMatchFailures) { - matchFailed("\".\""); - } - } - if (result15 !== null) { - var result16 = []; - var result17 = parse_WS(); - while (result17 !== null) { - result16.push(result17); - var result17 = parse_WS(); - } - if (result16 !== null) { - var result11 = [result12, result13, result14, result15, result16]; - } else { - var result11 = null; - pos = savedPos1; - } - } else { - var result11 = null; - pos = savedPos1; - } - } else { - var result11 = null; - pos = savedPos1; - } - } else { - var result11 = null; - pos = savedPos1; - } - } else { - var result11 = null; - pos = savedPos1; - } - var result10 = result11 !== null - ? (function(d) { - return d; - })(result11[1]) - : null; - if (result10 !== null) { - var result0 = result10; - } else { - var savedPos0 = pos; - var result5 = []; - var result9 = parse_WS(); - while (result9 !== null) { - result5.push(result9); - var result9 = parse_WS(); - } - if (result5 !== null) { - var result6 = parse_TriplesBlock(); - if (result6 !== null) { - var result7 = []; - var result8 = parse_WS(); - while (result8 !== null) { - result7.push(result8); - var result8 = parse_WS(); - } - if (result7 !== null) { - var result4 = [result5, result6, result7]; - } else { - var result4 = null; - pos = savedPos0; - } - } else { - var result4 = null; - pos = savedPos0; + else if(ctx[term].constructor === Object && '@id' in ctx[term]) + { + rval = ctx[term]['@id']; + } + } + return rval; +}; + +/** + * Compacts an IRI into a term or prefix if it can be. IRIs will not be + * compacted to relative IRIs if they match the given context's default + * vocabulary. + * + * @param ctx the context to use. + * @param iri the IRI to compact. + * @param usedCtx a context to update if a value was used from "ctx". + * + * @return the compacted IRI as a term or prefix or the original IRI. + */ +var _compactIri = function(ctx, iri, usedCtx) +{ + var rval = null; + + // check the context for a term that could shorten the IRI + // (give preference to terms over prefixes) + for(var key in ctx) + { + // skip special context keys (start with '@') + if(key.length > 0 && key[0] !== '@') + { + // compact to a term + if(iri === _getTermIri(ctx, key)) + { + rval = key; + if(usedCtx !== null) + { + usedCtx[key] = _clone(ctx[key]); } - } else { - var result4 = null; - pos = savedPos0; - } - var result3 = result4 !== null - ? (function(ts) { - return ts; - })(result4[1]) - : null; - if (result3 !== null) { - var result0 = result3; - } else { - var result2 = parse_WS(); - if (result2 !== null) { - var result1 = []; - while (result2 !== null) { - result1.push(result2); - var result2 = parse_WS(); - } - } else { - var result1 = null; + break; + } + } + } + + // term not found, if term is @type, use keyword + if(rval === null && iri === '@type') + { + rval = _getKeywords(ctx)['@type']; + } + + // term not found, check the context for a prefix + if(rval === null) + { + for(var key in ctx) + { + // skip special context keys (start with '@') + if(key.length > 0 && key[0] !== '@') + { + // see if IRI begins with the next IRI from the context + var ctxIri = _getTermIri(ctx, key); + if(ctxIri !== null) + { + var idx = iri.indexOf(ctxIri); + + // compact to a prefix + if(idx === 0 && iri.length > ctxIri.length) + { + rval = key + ':' + iri.substr(ctxIri.length); + if(usedCtx !== null) + { + usedCtx[key] = _clone(ctx[key]); + } + break; + } } - if (result1 !== null) { - var result0 = result1; - } else { - var result0 = null;; - }; - }; - } - - - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; + } + } + } + + // could not compact IRI + if(rval === null) + { + rval = iri; + } + + return rval; +}; + +/** + * Expands a term into an absolute IRI. The term may be a regular term, a + * prefix, a relative IRI, or an absolute IRI. In any case, the associated + * absolute IRI will be returned. + * + * @param ctx the context to use. + * @param term the term to expand. + * @param usedCtx a context to update if a value was used from "ctx". + * + * @return the expanded term as an absolute IRI. + */ +var _expandTerm = function(ctx, term, usedCtx) +{ + var rval = term; + + // get JSON-LD keywords + var keywords = _getKeywords(ctx); + + // 1. If the property has a colon, it is a prefix or an absolute IRI: + var idx = term.indexOf(':'); + if(idx !== -1) + { + // get the potential prefix + var prefix = term.substr(0, idx); + + // expand term if prefix is in context, otherwise leave it be + if(prefix in ctx) + { + // prefix found, expand property to absolute IRI + var iri = _getTermIri(ctx, prefix); + rval = iri + term.substr(idx + 1); + if(usedCtx !== null) + { + usedCtx[prefix] = _clone(ctx[prefix]); + } + } + } + // 2. If the property is in the context, then it's a term. + else if(term in ctx) + { + rval = _getTermIri(ctx, term); + if(usedCtx !== null) + { + usedCtx[term] = _clone(ctx[term]); + } + } + // 3. The property is a keyword. + else + { + for(var key in keywords) + { + if(term === keywords[key]) + { + rval = key; + break; + } + } + } + + return rval; +}; + +/** + * Sorts the keys in a context. + * + * @param ctx the context to sort. + * + * @return the sorted context. + */ +var _sortContextKeys = function(ctx) +{ + // sort keys + var rval = {}; + var keys = Object.keys(ctx).sort(); + for(var k in keys) + { + var key = keys[k]; + rval[key] = ctx[key]; + } + return rval; +}; + +/** + * Gets whether or not a value is a reference to a subject (or a subject with + * no properties). + * + * @param value the value to check. + * + * @return true if the value is a reference to a subject, false if not. + */ +var _isReference = function(value) +{ + // Note: A value is a reference to a subject if all of these hold true: + // 1. It is an Object. + // 2. It is has an @id key. + // 3. It has only 1 key. + return (value !== null && + value.constructor === Object && + '@id' in value && + Object.keys(value).length === 1); +}; + +/** + * Gets whether or not a value is a subject with properties. + * + * @param value the value to check. + * + * @return true if the value is a subject with properties, false if not. + */ +var _isSubject = function(value) +{ + var rval = false; + + // Note: A value is a subject if all of these hold true: + // 1. It is an Object. + // 2. It is not a literal. + // 3. It has more than 1 key OR any existing key is not '@id'. + if(value !== null && value.constructor === Object && !('@literal' in value)) + { + var keyCount = Object.keys(value).length; + rval = (keyCount > 1 || !('@id' in value)); + } + + return rval; +}; + +/* + * JSON-LD API. + */ + +/** + * Normalizes a JSON-LD object. + * + * @param input the JSON-LD object to normalize. + * + * @return the normalized JSON-LD object. + */ +jsonld.normalize = function(input) +{ + return new Processor().normalize(input); +}; + +/** + * Removes the context from a JSON-LD object, expanding it to full-form. + * + * @param input the JSON-LD object to remove the context from. + * + * @return the context-neutral JSON-LD object. + */ +jsonld.expand = function(input) +{ + return new Processor().expand({}, null, input); +}; + +/** + * Expands the given JSON-LD object and then compacts it using the + * given context. + * + * @param ctx the new context to use. + * @param input the input JSON-LD object. + * + * @return the output JSON-LD object. + */ +jsonld.compact = function(ctx, input) +{ + var rval = null; + + // TODO: should context simplification be optional? (ie: remove context + // entries that are not used in the output) + + if(input !== null) + { + // fully expand input + input = jsonld.expand(input); + + var tmp; + if(input.constructor === Array) + { + rval = []; + tmp = input; + } + else + { + tmp = [input]; } - function parse_directive() { - var cacheKey = 'directive@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - - var result2 = parse_prefixID(); - if (result2 !== null) { - var result0 = result2; - } else { - var result1 = parse_base(); - if (result1 !== null) { - var result0 = result1; - } else { - var result0 = null;; - }; - } - - - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; + // merge context if it is an array + if(ctx.constructor === Array) + { + ctx = jsonld.mergeContexts({}, ctx); } - function parse_base() { - var cacheKey = 'base@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - - var savedPos0 = pos; - var result2 = []; - var result7 = parse_WS(); - while (result7 !== null) { - result2.push(result7); - var result7 = parse_WS(); - } - if (result2 !== null) { - if (input.substr(pos, 5) === "@base") { - var result3 = "@base"; - pos += 5; - } else { - var result3 = null; - if (reportMatchFailures) { - matchFailed("\"@base\""); - } - } - if (result3 !== null) { - var result6 = parse_WS(); - if (result6 !== null) { - var result4 = []; - while (result6 !== null) { - result4.push(result6); - var result6 = parse_WS(); - } - } else { - var result4 = null; - } - if (result4 !== null) { - var result5 = parse_IRI_REF(); - if (result5 !== null) { - var result1 = [result2, result3, result4, result5]; - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; + for(var i in tmp) + { + // setup output context + var ctxOut = {}; + + // compact + var out = new Processor().compact(_clone(ctx), null, tmp[i], ctxOut); + + // add context if used + if(Object.keys(ctxOut).length > 0) + { + // sort context keys + ctxOut = _sortContextKeys(ctxOut); + + // sort keys + var keys = Object.keys(out); + keys.sort(); + + // put @context first + keys.unshift('@context'); + out['@context'] = ctxOut; + + // order keys in output + var ordered = {}; + for(var k in keys) + { + var key = keys[k]; + ordered[key] = out[key]; + } + out = ordered; + } + + if(rval === null) + { + rval = out; + } + else + { + rval.push(out); + } + } + } + + return rval; +}; + +/** + * Merges one context with another. + * + * @param ctx1 the context to overwrite/append to. + * @param ctx2 the new context to merge onto ctx1. + * + * @return the merged context. + */ +jsonld.mergeContexts = function(ctx1, ctx2) +{ + // merge first context if it is an array + if(ctx1.constructor === Array) + { + ctx1 = jsonld.mergeContexts({}, ctx1); + } + + // copy context to merged output + var merged = _clone(ctx1); + + if(ctx2.constructor === Array) + { + // merge array of contexts in order + for(var i in ctx2) + { + merged = jsonld.mergeContexts(merged, ctx2[i]); + } + } + else + { + // if the new context contains any IRIs that are in the merged context, + // remove them from the merged context, they will be overwritten + for(var key in ctx2) + { + // ignore special keys starting with '@' + if(key.indexOf('@') !== 0) + { + for(var mkey in merged) + { + if(merged[mkey] === ctx2[key]) + { + // FIXME: update related coerce rules + delete merged[mkey]; + break; + } } - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - var result0 = result1 !== null - ? (function(i) { - registerDefaultPrefix(i); - - base = {}; - base.token = 'base'; - base.value = i; - - return base; - })(result1[3]) - : null; - - - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; + } } - - function parse_prefixID() { - var cacheKey = 'prefixID@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - - var savedPos0 = pos; - var result2 = []; - var result12 = parse_WS(); - while (result12 !== null) { - result2.push(result12); - var result12 = parse_WS(); - } - if (result2 !== null) { - if (input.substr(pos, 7) === "@prefix") { - var result3 = "@prefix"; - pos += 7; - } else { - var result3 = null; - if (reportMatchFailures) { - matchFailed("\"@prefix\""); + + // merge contexts + for(var key in ctx2) + { + merged[key] = _clone(ctx2[key]); + } + } + + return merged; +}; + +/** + * Expands a term into an absolute IRI. The term may be a regular term, a + * prefix, a relative IRI, or an absolute IRI. In any case, the associated + * absolute IRI will be returned. + * + * @param ctx the context to use. + * @param term the term to expand. + * + * @return the expanded term as an absolute IRI. + */ +jsonld.expandTerm = _expandTerm; + +/** + * Compacts an IRI into a term or prefix if it can be. IRIs will not be + * compacted to relative IRIs if they match the given context's default + * vocabulary. + * + * @param ctx the context to use. + * @param iri the IRI to compact. + * + * @return the compacted IRI as a term or prefix or the original IRI. + */ +jsonld.compactIri = function(ctx, iri) +{ + return _compactIri(ctx, iri, null); +}; + +/** + * Frames JSON-LD input. + * + * @param input the JSON-LD input. + * @param frame the frame to use. + * @param options framing options to use. + * + * @return the framed output. + */ +jsonld.frame = function(input, frame, options) +{ + return new Processor().frame(input, frame, options); +}; + +/** + * Generates triples given a JSON-LD input. Each triple that is generated + * results in a call to the given callback. The callback takes 3 parameters: + * subject, property, and object. If the callback returns false then this + * method will stop generating triples and return. If the callback is null, + * then an array with triple objects containing "s", "p", "o" properties will + * be returned. + * + * The object or "o" property will be a JSON-LD formatted object. + * + * @param input the JSON-LD input. + * @param callback the triple callback. + * + * @return an array of triple objects if callback is null, null otherwise. + */ +jsonld.toTriples = function(input, graph, callback) +{ + var rval = null; + + // normalize input + var normalized = jsonld.normalize(input); + + // setup default callback + callback = callback || null; + if(callback === null) + { + rval = []; + callback = function(s, p, o) + { + rval.push({'subject': Utils.lexicalFormTerm(s), + 'predicate': Utils.lexicalFormTerm(p), + 'object': Utils.lexicalFormTerm(o), + 'graph': graph}); + }; + } + + // generate triples + var quit = false; + for(var i1 in normalized) + { + var e = normalized[i1]; + var s = e['@id']; + if(s[0] == "_") { + s = {'token':'blank', 'value':s.split(":")[1]}; + } else { + s = {'token':'uri', 'value':s}; + } + + for(var p in e) + { + if(p !== '@id') + { + var obj = e[p]; + if(obj.constructor !== Array) + { + obj = [obj]; + } + for(var i2 in obj) + { + var obji2 = obj[i2]; + if(p === '@type') { + p = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type'; + obji2 = {'token':'uri', 'value':obji2}; + } else if(typeof(obji2) === 'string') { + obji2 = {'token': 'literal', 'value':obji2}; + } else if(obji2['@id'] != null) { + if(obji2['@id'][0] == "_") { + obji2 = {'token':'blank', 'value':obji2['@id'].split(":")[1]}; + } else { + obji2 = {'token':'uri', 'value':obji2['@id']}; + } + } else if(obji2['@type'] != null) { + obji2 = {'token':'literal', 'value':obji2['@literal'], 'type':obji2['@type']}; + } else if(obji2['@language'] != null) { + obji2 = {'token':'literal', 'value':obji2['@literal'], 'lang':obji2['@language']}; + } + + quit = (callback(s, {'token':'uri', 'value':p}, obji2) === false); + if(quit) + { + break; + } } - } - if (result3 !== null) { - var result11 = parse_WS(); - if (result11 !== null) { - var result4 = []; - while (result11 !== null) { - result4.push(result11); - var result11 = parse_WS(); - } - } else { - var result4 = null; + if(quit) + { + break; } - if (result4 !== null) { - var result10 = parse_PN_PREFIX(); - var result5 = result10 !== null ? result10 : ''; - if (result5 !== null) { - if (input.substr(pos, 1) === ":") { - var result6 = ":"; - pos += 1; - } else { - var result6 = null; - if (reportMatchFailures) { - matchFailed("\":\""); - } - } - if (result6 !== null) { - var result7 = []; - var result9 = parse_WS(); - while (result9 !== null) { - result7.push(result9); - var result9 = parse_WS(); + } + } + if(quit) + { + break; + } + } + + return rval; +}; + +/** + * Resolves external @context URLs. Every @context URL in the given JSON-LD + * object is resolved using the given URL-resolver function. Once all of + * the @contexts have been resolved, the given result callback is invoked. + * + * @param input the JSON-LD input object (or array). + * @param resolver the resolver method that takes a URL and a callback that + * receives a JSON-LD serialized @context or null on error (with + * optional an error object as the second parameter). + * @param callback the callback to be invoked with the fully-resolved + * JSON-LD output (object or array) or null on error (with an + * optional error array as the second parameter). + */ +jsonld.resolve = function(input, resolver, callback) +{ + // find all @context URLs + var urls = {}; + var findUrls = function(input, replace) + { + if(input.constructor === Array) + { + for(var i in input) + { + findUrls(input[i]); + } + } + else if(input.constructor === Object) + { + for(var key in input) + { + if(key === '@context') + { + // @context is an array that might contain URLs + if(input[key].constructor === Array) + { + var list = input[key]; + for(var i in list) + { + if(list[i].constructor === String) + { + // replace w/resolved @context if appropriate + if(replace) + { + list[i] = urls[list[i]]; + } + // unresolved @context found + else + { + urls[list[i]] = {}; + } + } } - if (result7 !== null) { - var result8 = parse_IRI_REF(); - if (result8 !== null) { - var result1 = [result2, result3, result4, result5, result6, result7, result8]; - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; + } + else if(input[key].constructor === String) + { + // replace w/resolved @context if appropriate + if(replace) + { + input[key] = urls[input[key]]; + } + // unresolved @context found + else + { + urls[input[key]] = {}; } - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; + } } - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - var result0 = result1 !== null - ? (function(p, l) { - - registerPrefix(p,l); - - prefix = {}; - prefix.token = 'prefix'; - prefix.prefix = p; - prefix.local = l; - - return prefix; - })(result1[3], result1[6]) - : null; - - - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; + } } - - function parse_TriplesBlock() { - var cacheKey = 'TriplesBlock@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var savedPos0 = pos; - var result2 = parse_TriplesSameSubject(); - if (result2 !== null) { - var savedPos1 = pos; - var result5 = []; - var result9 = parse_WS(); - while (result9 !== null) { - result5.push(result9); - var result9 = parse_WS(); - } - if (result5 !== null) { - if (input.substr(pos, 1) === ".") { - var result6 = "."; - pos += 1; - } else { - var result6 = null; - if (reportMatchFailures) { - matchFailed("\".\""); - } + }; + findUrls(input, false); + + // state for resolving URLs + var count = Object.keys(urls).length; + var errors = null; + + if(count === 0) + { + callback(input, errors); + } + else + { + // resolve all URLs + for(var url in urls) + { + resolver(url, function(result, error) + { + --count; + + if(result === null) + { + errors = errors || []; + errors.push({ url: url, error: error }); + } + else + { + try + { + if(result.constructor === String) + { + urls[url] = JSON.parse(result)['@context']; + } + else + { + urls[url] = result['@context']; + } + } + catch(ex) + { + errors = errors || []; + errors.push({ url: url, error: ex }); + } } - if (result6 !== null) { - var result8 = parse_TriplesBlock(); - var result7 = result8 !== null ? result8 : ''; - if (result7 !== null) { - var result4 = [result5, result6, result7]; - } else { - var result4 = null; - pos = savedPos1; - } - } else { - var result4 = null; - pos = savedPos1; + + if(count === 0) + { + if(errors === null) + { + findUrls(input, true); + } + callback(input, errors); } - } else { - var result4 = null; - pos = savedPos1; - } - var result3 = result4 !== null ? result4 : ''; - if (result3 !== null) { - var result1 = [result2, result3]; - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - var result0 = result1 !== null - ? (function(b, bs) { - var triples = b.triplesContext; - var toTest = null; - if(typeof(bs) === 'object') { - if(bs.length != null) { - if(bs[2].triplesContext!=null) { - triples = triples.concat(bs[2].triplesContext); - } - } - } - - return {token:'triples', - triplesContext: triples} - })(result1[0], result1[1]) - : null; - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("[54] TriplesBlock"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; + }); } - - function parse_TriplesSameSubject() { - var cacheKey = 'TriplesSameSubject@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var savedPos1 = pos; - var result11 = []; - var result16 = parse_WS(); - while (result16 !== null) { - result11.push(result16); - var result16 = parse_WS(); - } - if (result11 !== null) { - var result12 = parse_VarOrTerm(); - if (result12 !== null) { - var result13 = []; - var result15 = parse_WS(); - while (result15 !== null) { - result13.push(result15); - var result15 = parse_WS(); + } +}; + +// TODO: organizational rewrite + +/** + * Constructs a new JSON-LD processor. + */ +var Processor = function() +{ +}; + +/** + * Recursively compacts a value. This method will compact IRIs to prefixes or + * terms and do reverse type coercion to compact a value. + * + * @param ctx the context to use. + * @param property the property that points to the value, NULL for none. + * @param value the value to compact. + * @param usedCtx a context to update if a value was used from "ctx". + * + * @return the compacted value. + */ +Processor.prototype.compact = function(ctx, property, value, usedCtx) +{ + var rval; + + // get JSON-LD keywords + var keywords = _getKeywords(ctx); + + if(value === null) + { + // return null, but check coerce type to add to usedCtx + rval = null; + this.getCoerceType(ctx, property, usedCtx); + } + else if(value.constructor === Array) + { + // recursively add compacted values to array + rval = []; + for(var i in value) + { + rval.push(this.compact(ctx, property, value[i], usedCtx)); + } + } + // graph literal/disjoint graph + else if( + value.constructor === Object && + '@id' in value && value['@id'].constructor === Array) + { + rval = {}; + rval[keywords['@id']] = this.compact( + ctx, property, value['@id'], usedCtx); + } + // recurse if value is a subject + else if(_isSubject(value)) + { + // recursively handle sub-properties that aren't a sub-context + rval = {}; + for(var key in value) + { + if(value[key] !== '@context') + { + // set object to compacted property, only overwrite existing + // properties if the property actually compacted + var p = _compactIri(ctx, key, usedCtx); + if(p !== key || !(p in rval)) + { + // FIXME: clean old values from the usedCtx here ... or just + // change usedCtx to be built at the end of processing? + rval[p] = this.compact(ctx, key, value[key], usedCtx); + } + } + } + } + else + { + // get coerce type + var coerce = this.getCoerceType(ctx, property, usedCtx); + + // get type from value, to ensure coercion is valid + var type = null; + if(value.constructor === Object) + { + // type coercion can only occur if language is not specified + if(!('@language' in value)) + { + // type must match coerce type if specified + if('@type' in value) + { + type = value['@type']; + } + // type is ID (IRI) + else if('@id' in value) + { + type = '@id'; + } + // can be coerced to any type + else + { + type = coerce; + } + } + } + // type can be coerced to anything + else if(value.constructor === String) + { + type = coerce; + } + + // types that can be auto-coerced from a JSON-builtin + if(coerce === null && + (type === xsd['boolean'] || type === xsd['integer'] || + type === xsd['double'])) + { + coerce = type; + } + + // do reverse type-coercion + if(coerce !== null) + { + // type is only null if a language was specified, which is an error + // if type coercion is specified + if(type === null) + { + throw { + message: 'Cannot coerce type when a language is specified. ' + + 'The language information would be lost.' + }; + } + // if the value type does not match the coerce type, it is an error + else if(type !== coerce) + { + throw new Exception({ + message: 'Cannot coerce type because the type does ' + + 'not match.', + type: type, + expected: coerce + }); + } + // do reverse type-coercion + else + { + if(value.constructor === Object) + { + if('@id' in value) + { + rval = value['@id']; + } + else if('@literal' in value) + { + rval = value['@literal']; + } } - if (result13 !== null) { - var result14 = parse_PropertyListNotEmpty(); - if (result14 !== null) { - var result10 = [result11, result12, result13, result14]; - } else { - var result10 = null; - pos = savedPos1; - } - } else { - var result10 = null; - pos = savedPos1; + else + { + rval = value; } - } else { - var result10 = null; - pos = savedPos1; - } - } else { - var result10 = null; - pos = savedPos1; - } - var result9 = result10 !== null - ? (function(s, pairs) { - var triplesContext = pairs.triplesContext; - var subject = s; - if(pairs.pairs) { - for(var i=0; i< pairs.pairs.length; i++) { - var pair = pairs.pairs[i]; - var triple = null; - if(subject.token && subject.token==='triplesnodecollection') { - triple = {subject: subject.chainSubject[0], predicate: pair[0], object: pair[1]} - triplesContext.push(triple); - triplesContext = triplesContext.concat(subject.triplesContext); - } else { - triple = {subject: subject, predicate: pair[0], object: pair[1]} - triplesContext.push(triple); - } - } - } - - var token = {}; - token.token = "triplessamesubject"; - token.triplesContext = triplesContext; - token.chainSubject = subject; - - return token; - })(result10[1], result10[3]) - : null; - if (result9 !== null) { - var result0 = result9; - } else { - var savedPos0 = pos; - var result3 = []; - var result8 = parse_WS(); - while (result8 !== null) { - result3.push(result8); - var result8 = parse_WS(); - } - if (result3 !== null) { - var result4 = parse_TriplesNode(); - if (result4 !== null) { - var result5 = []; - var result7 = parse_WS(); - while (result7 !== null) { - result5.push(result7); - var result7 = parse_WS(); - } - if (result5 !== null) { - var result6 = parse_PropertyList(); - if (result6 !== null) { - var result2 = [result3, result4, result5, result6]; - } else { - var result2 = null; - pos = savedPos0; - } - } else { - var result2 = null; - pos = savedPos0; - } - } else { - var result2 = null; - pos = savedPos0; + + // do basic JSON types conversion + if(coerce === xsd['boolean']) + { + rval = (rval === 'true' || rval != 0); } - } else { - var result2 = null; - pos = savedPos0; - } - var result1 = result2 !== null - ? (function(tn, pairs) { - var triplesContext = tn.triplesContext; - var subject = tn.chainSubject; - - if(pairs.pairs) { - for(var i=0; i< pairs.pairs.length; i++) { - var pair = pairs.pairs[i]; - if(tn.token === "triplesnodecollection") { - for(var j=0; j v2. + */ +var _compare = function(v1, v2) +{ + var rval = 0; + + if(v1.constructor === Array && v2.constructor === Array) + { + for(var i = 0; i < v1.length && rval === 0; ++i) + { + rval = _compare(v1[i], v2[i]); + } + } + else + { + rval = (v1 < v2 ? -1 : (v1 > v2 ? 1 : 0)); + } + + return rval; +}; + +/** + * Compares two keys in an object. If the key exists in one object + * and not the other, the object with the key is less. If the key exists in + * both objects, then the one with the lesser value is less. + * + * @param o1 the first object. + * @param o2 the second object. + * @param key the key. + * + * @return -1 if o1 < o2, 0 if o1 == o2, 1 if o1 > o2. + */ +var _compareObjectKeys = function(o1, o2, key) +{ + var rval = 0; + if(key in o1) + { + if(key in o2) + { + rval = _compare(o1[key], o2[key]); + } + else + { + rval = -1; + } + } + else if(key in o2) + { + rval = 1; + } + return rval; +}; + +/** + * Compares two object values. + * + * @param o1 the first object. + * @param o2 the second object. + * + * @return -1 if o1 < o2, 0 if o1 == o2, 1 if o1 > o2. + */ +var _compareObjects = function(o1, o2) +{ + var rval = 0; + + if(o1.constructor === String) + { + if(o2.constructor !== String) + { + rval = -1; + } + else + { + rval = _compare(o1, o2); + } + } + else if(o2.constructor === String) + { + rval = 1; + } + else + { + rval = _compareObjectKeys(o1, o2, '@literal'); + if(rval === 0) + { + if('@literal' in o1) + { + rval = _compareObjectKeys(o1, o2, '@type'); + if(rval === 0) + { + rval = _compareObjectKeys(o1, o2, '@language'); + } + } + // both are '@id' objects + else + { + rval = _compare(o1['@id'], o2['@id']); + } + } + } + + return rval; +}; + +/** + * Compares the object values between two bnodes. + * + * @param a the first bnode. + * @param b the second bnode. + * + * @return -1 if a < b, 0 if a == b, 1 if a > b. + */ +var _compareBlankNodeObjects = function(a, b) +{ + var rval = 0; + + /* + 3. For each property, compare sorted object values. + 3.1. The bnode with fewer objects is first. + 3.2. For each object value, compare only literals and non-bnodes. + 3.2.1. The bnode with fewer non-bnodes is first. + 3.2.2. The bnode with a string object is first. + 3.2.3. The bnode with the alphabetically-first string is first. + 3.2.4. The bnode with a @literal is first. + 3.2.5. The bnode with the alphabetically-first @literal is first. + 3.2.6. The bnode with the alphabetically-first @type is first. + 3.2.7. The bnode with a @language is first. + 3.2.8. The bnode with the alphabetically-first @language is first. + 3.2.9. The bnode with the alphabetically-first @id is first. + */ + + for(var p in a) + { + // skip IDs (IRIs) + if(p !== '@id') + { + // step #3.1 + var lenA = (a[p].constructor === Array) ? a[p].length : 1; + var lenB = (b[p].constructor === Array) ? b[p].length : 1; + rval = _compare(lenA, lenB); + + // step #3.2.1 + if(rval === 0) + { + // normalize objects to an array + var objsA = a[p]; + var objsB = b[p]; + if(objsA.constructor !== Array) + { + objsA = [objsA]; + objsB = [objsB]; } - while (result5 !== null) { - result4.push(result5); - var savedPos1 = pos; - if (input.substr(pos, 1) === ",") { - var result6 = ","; - pos += 1; - } else { - var result6 = null; - if (reportMatchFailures) { - matchFailed("\",\""); - } - } - if (result6 !== null) { - var result7 = []; - var result9 = parse_WS(); - while (result9 !== null) { - result7.push(result9); - var result9 = parse_WS(); - } - if (result7 !== null) { - var result8 = parse_GraphNode(); - if (result8 !== null) { - var result5 = [result6, result7, result8]; - } else { - var result5 = null; - pos = savedPos1; + + // compare non-bnodes (remove bnodes from comparison) + objsA = objsA.filter(function(e) {return !_isNamedBlankNode(e);}); + objsB = objsB.filter(function(e) {return !_isNamedBlankNode(e);}); + rval = _compare(objsA.length, objsB.length); + } + + // steps #3.2.2-3.2.9 + if(rval === 0) + { + objsA.sort(_compareObjects); + objsB.sort(_compareObjects); + for(var i = 0; i < objsA.length && rval === 0; ++i) + { + rval = _compareObjects(objsA[i], objsB[i]); + } + } + + if(rval !== 0) + { + break; + } + } + } + + return rval; +}; + +/** + * Creates a blank node name generator using the given prefix for the + * blank nodes. + * + * @param prefix the prefix to use. + * + * @return the blank node name generator. + */ +var _createNameGenerator = function(prefix) +{ + var count = -1; + var ng = { + next: function() + { + ++count; + return ng.current(); + }, + current: function() + { + return '_:' + prefix + count; + }, + inNamespace: function(iri) + { + return iri.indexOf('_:' + prefix) === 0; + } + }; + return ng; +}; + +/** + * Populates a map of all named subjects from the given input and an array + * of all unnamed bnodes (includes embedded ones). + * + * @param input the input (must be expanded, no context). + * @param subjects the subjects map to populate. + * @param bnodes the bnodes array to populate. + */ +var _collectSubjects = function(input, subjects, bnodes) +{ + if(input === null) + { + // nothing to collect + } + else if(input.constructor === Array) + { + for(var i in input) + { + _collectSubjects(input[i], subjects, bnodes); + } + } + else if(input.constructor === Object) + { + if('@id' in input) + { + // graph literal/disjoint graph + if(input['@id'].constructor == Array) + { + _collectSubjects(input['@id'], subjects, bnodes); + } + // named subject + else if(_isSubject(input)) + { + subjects[input['@id']] = input; + } + } + // unnamed blank node + else if(_isBlankNode(input)) + { + bnodes.push(input); + } + + // recurse through subject properties + for(var key in input) + { + _collectSubjects(input[key], subjects, bnodes); + } + } +}; + +/** + * Flattens the given value into a map of unique subjects. It is assumed that + * all blank nodes have been uniquely named before this call. Array values for + * properties will be sorted. + * + * @param parent the value's parent, NULL for none. + * @param parentProperty the property relating the value to the parent. + * @param value the value to flatten. + * @param subjects the map of subjects to write to. + */ +var _flatten = function(parent, parentProperty, value, subjects) +{ + var flattened = null; + + if(value === null) + { + // drop null values + } + else if(value.constructor === Array) + { + // list of objects or a disjoint graph + for(var i in value) + { + _flatten(parent, parentProperty, value[i], subjects); + } + } + else if(value.constructor === Object) + { + // already-expanded value or special-case reference-only @type + if('@literal' in value || parentProperty === '@type') + { + flattened = _clone(value); + } + // graph literal/disjoint graph + else if(value['@id'].constructor === Array) + { + // cannot flatten embedded graph literals + if(parent !== null) + { + throw { + message: 'Embedded graph literals cannot be flattened.' + }; + } + + // top-level graph literal + for(var idx in value['@id']) + { + _flatten(parent, parentProperty, value['@id'][idx], subjects); + } + } + // regular subject + else + { + // create or fetch existing subject + var subject; + if(value['@id'] in subjects) + { + // FIXME: '@id' might be a graph literal (as {}) + subject = subjects[value['@id']]; + } + else + { + // FIXME: '@id' might be a graph literal (as {}) + subject = {'@id': value['@id']}; + subjects[value['@id']] = subject; + } + flattened = {'@id': subject['@id']}; + + // flatten embeds + for(var key in value) + { + var v = value[key]; + + // drop null values, skip @id (it is already set above) + if(v !== null && key !== '@id') + { + if(key in subject) + { + if(subject[key].constructor !== Array) + { + subject[key] = [subject[key]]; } - } else { - var result5 = null; - pos = savedPos1; - } - } else { - var result5 = null; - pos = savedPos1; - } + } + else + { + subject[key] = []; + } + + _flatten(subject[key], key, v, subjects); + if(subject[key].length === 1) + { + // convert subject[key] to object if it has only 1 + subject[key] = subject[key][0]; + } } - if (result4 !== null) { - var result1 = [result2, result3, result4]; - } else { - var result1 = null; - pos = savedPos0; + } + } + } + // string value + else + { + flattened = value; + } + + // add flattened value to parent + if(flattened !== null && parent !== null) + { + if(parent.constructor === Array) + { + // do not add duplicate IRIs for the same property + var duplicate = false; + if(flattened.constructor === Object && '@id' in flattened) + { + duplicate = (parent.filter(function(e) + { + return (e.constructor === Object && '@id' in e && + e['@id'] === flattened['@id']); + }).length > 0); + } + if(!duplicate) + { + parent.push(flattened); + } + } + else + { + parent[parentProperty] = flattened; + } + } +}; + + +/** + * Assigns unique names to blank nodes that are unnamed in the given input. + * + * @param input the input to assign names to. + */ +Processor.prototype.nameBlankNodes = function(input) +{ + // create temporary blank node name generator + var ng = this.ng.tmp = _createNameGenerator('tmp'); + + // collect subjects and unnamed bnodes + var subjects = {}; + var bnodes = []; + _collectSubjects(input, subjects, bnodes); + + // uniquely name all unnamed bnodes + for(var i in bnodes) + { + var bnode = bnodes[i]; + if(!('@id' in bnode)) + { + // generate names until one is unique + while(ng.next() in subjects){} + bnode['@id'] = ng.current(); + subjects[ng.current()] = bnode; + } + } +}; + +/** + * Renames a blank node, changing its references, etc. The method assumes + * that the given name is unique. + * + * @param b the blank node to rename. + * @param id the new name to use. + */ +Processor.prototype.renameBlankNode = function(b, id) +{ + var old = b['@id']; + + // update bnode IRI + b['@id'] = id; + + // update subjects map + var subjects = this.subjects; + subjects[id] = subjects[old]; + delete subjects[old]; + + // update reference and property lists + this.edges.refs[id] = this.edges.refs[old]; + this.edges.props[id] = this.edges.props[old]; + delete this.edges.refs[old]; + delete this.edges.props[old]; + + // update references to this bnode + var refs = this.edges.refs[id].all; + for(var i in refs) + { + var iri = refs[i].s; + if(iri === old) + { + iri = id; + } + var ref = subjects[iri]; + var props = this.edges.props[iri].all; + for(var i2 in props) + { + if(props[i2].s === old) + { + props[i2].s = id; + + // normalize property to array for single code-path + var p = props[i2].p; + var tmp = (ref[p].constructor === Object) ? [ref[p]] : + (ref[p].constructor === Array) ? ref[p] : []; + for(var n in tmp) + { + if(tmp[n].constructor === Object && + '@id' in tmp[n] && tmp[n]['@id'] === old) + { + tmp[n]['@id'] = id; + } } - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - var result0 = result1 !== null - ? (function(obj, objs) { - - var toReturn = []; - - toReturn.push(obj); - - for(var i=0; i 0) + { + if(resort) + { + resort = false; + bnodes.sort(function(a, b) + { + return self.deepCompareBlankNodes(a, b); + }); } - function parse_Verb() { - var cacheKey = 'Verb@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var result3 = parse_VarOrIRIref(); - if (result3 !== null) { - var result0 = result3; - } else { - if (input.substr(pos, 1) === "a") { - var result2 = "a"; - pos += 1; - } else { - var result2 = null; - if (reportMatchFailures) { - matchFailed("\"a\""); + // name all bnodes according to the first bnode's relation mappings + var bnode = bnodes.shift(); + var iri = bnode['@id']; + var dirs = ['props', 'refs']; + for(var d in dirs) + { + var dir = dirs[d]; + + // if no serialization has been computed, name only the first node + if(this.serializations[iri][dir] === null) + { + var mapping = {}; + mapping[iri] = 's1'; + } + else + { + mapping = this.serializations[iri][dir].m; + } + + // sort keys by value to name them in order + var keys = Object.keys(mapping); + keys.sort(function(a, b) + { + return _compare(mapping[a], mapping[b]); + }); + + // name bnodes in mapping + var renamed = []; + for(var i in keys) + { + var iriK = keys[i]; + if(!c14n.inNamespace(iri) && iriK in subjects) + { + this.renameBlankNode(subjects[iriK], c14n.next()); + renamed.push(iriK); + } + } + + // only keep non-canonically named bnodes + var tmp = bnodes; + bnodes = []; + for(var i in tmp) + { + var b = tmp[i]; + var iriB = b['@id']; + if(!c14n.inNamespace(iriB)) + { + // mark serializations related to the named bnodes as dirty + for(var i2 in renamed) + { + if(this.markSerializationDirty(iriB, renamed[i2], dir)) + { + // resort if a serialization was marked dirty + resort = true; + } + } + bnodes.push(b); } - } - var result1 = result2 !== null - ? (function() { - return{token: 'uri', prefix:null, suffix:null, value:"http://www.w3.org/1999/02/22-rdf-syntax-ns#type"} - })() - : null; - if (result1 !== null) { - var result0 = result1; - } else { - var result0 = null;; - }; - } - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("[71] Verb"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; + } } - - function parse_PropertyListNotEmptyPath() { - var cacheKey = 'PropertyListNotEmptyPath@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var savedPos0 = pos; - var result13 = parse_VerbPath(); - if (result13 !== null) { - var result1 = result13; - } else { - var result12 = parse_Var(); - if (result12 !== null) { - var result1 = result12; - } else { - var result1 = null;; - }; - } - if (result1 !== null) { - var result2 = parse_ObjectList(); - if (result2 !== null) { - var result3 = []; - var savedPos1 = pos; - if (input.substr(pos, 1) === ";") { - var result5 = ";"; - pos += 1; - } else { - var result5 = null; - if (reportMatchFailures) { - matchFailed("\";\""); - } - } - if (result5 !== null) { - var savedPos2 = pos; - var result11 = parse_VerbPath(); - if (result11 !== null) { - var result8 = result11; - } else { - var result10 = parse_Var(); - if (result10 !== null) { - var result8 = result10; - } else { - var result8 = null;; - }; - } - if (result8 !== null) { - var result9 = parse_ObjectList(); - if (result9 !== null) { - var result7 = [result8, result9]; - } else { - var result7 = null; - pos = savedPos2; - } - } else { - var result7 = null; - pos = savedPos2; - } - var result6 = result7 !== null ? result7 : ''; - if (result6 !== null) { - var result4 = [result5, result6]; - } else { - var result4 = null; - pos = savedPos1; - } - } else { - var result4 = null; - pos = savedPos1; - } - while (result4 !== null) { - result3.push(result4); - var savedPos1 = pos; - if (input.substr(pos, 1) === ";") { - var result5 = ";"; - pos += 1; - } else { - var result5 = null; - if (reportMatchFailures) { - matchFailed("\";\""); - } - } - if (result5 !== null) { - var savedPos2 = pos; - var result11 = parse_VerbPath(); - if (result11 !== null) { - var result8 = result11; - } else { - var result10 = parse_Var(); - if (result10 !== null) { - var result8 = result10; - } else { - var result8 = null;; - }; - } - if (result8 !== null) { - var result9 = parse_ObjectList(); - if (result9 !== null) { - var result7 = [result8, result9]; - } else { - var result7 = null; - pos = savedPos2; + } + + // sort property lists that now have canonically-named bnodes + for(var key in edges.props) + { + if(edges.props[key].bnodes.length > 0) + { + var bnode = subjects[key]; + for(var p in bnode) + { + if(p.indexOf('@') !== 0 && bnode[p].constructor === Array) + { + bnode[p].sort(_compareObjects); + } + } + } + } +}; + +/** + * A MappingBuilder is used to build a mapping of existing blank node names + * to a form for serialization. The serialization is used to compare blank + * nodes against one another to determine a sort order. + */ +MappingBuilder = function() +{ + this.count = 1; + this.processed = {}; + this.mapping = {}; + this.adj = {}; + this.keyStack = [{ keys: ['s1'], idx: 0 }]; + this.done = {}; + this.s = ''; +}; + +/** + * Copies this MappingBuilder. + * + * @return the MappingBuilder copy. + */ +MappingBuilder.prototype.copy = function() +{ + var rval = new MappingBuilder(); + rval.count = this.count; + rval.processed = _clone(this.processed); + rval.mapping = _clone(this.mapping); + rval.adj = _clone(this.adj); + rval.keyStack = _clone(this.keyStack); + rval.done = _clone(this.done); + rval.s = this.s; + return rval; +}; + +/** + * Maps the next name to the given bnode IRI if the bnode IRI isn't already in + * the mapping. If the given bnode IRI is canonical, then it will be given + * a shortened form of the same name. + * + * @param iri the blank node IRI to map the next name to. + * + * @return the mapped name. + */ +MappingBuilder.prototype.mapNode = function(iri) +{ + if(!(iri in this.mapping)) + { + if(iri.indexOf('_:c14n') === 0) + { + this.mapping[iri] = 'c' + iri.substr(6); + } + else + { + this.mapping[iri] = 's' + this.count++; + } + } + return this.mapping[iri]; +}; + +/** + * Serializes the properties of the given bnode for its relation serialization. + * + * @param b the blank node. + * + * @return the serialized properties. + */ +var _serializeProperties = function(b) +{ + var rval = ''; + + var first = true; + for(var p in b) + { + if(p !== '@id') + { + if(first) + { + first = false; + } + else + { + rval += '|'; + } + + // property + rval += '<' + p + '>'; + + // object(s) + var objs = (b[p].constructor === Array) ? b[p] : [b[p]]; + for(var oi in objs) + { + var o = objs[oi]; + if(o.constructor === Object) + { + // ID (IRI) + if('@id' in o) + { + if(_isBlankNodeIri(o['@id'])) + { + rval += '_:'; + } + else + { + rval += '<' + o['@id'] + '>'; } - } else { - var result7 = null; - pos = savedPos2; - } - var result6 = result7 !== null ? result7 : ''; - if (result6 !== null) { - var result4 = [result5, result6]; - } else { - var result4 = null; - pos = savedPos1; - } - } else { - var result4 = null; - pos = savedPos1; - } + } + // literal + else + { + rval += '"' + o['@literal'] + '"'; + + // type literal + if('@type' in o) + { + rval += '^^<' + o['@type'] + '>'; + } + // language literal + else if('@language' in o) + { + rval += '@' + o['@language']; + } + } } - if (result3 !== null) { - var result0 = [result1, result2, result3]; - } else { - var result0 = null; - pos = savedPos0; + // plain literal + else + { + rval += '"' + o + '"'; } - } else { - var result0 = null; - pos = savedPos0; - } - } else { - var result0 = null; - pos = savedPos0; - } - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("[73] PropertyListNotEmptyPath"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; + } } - - function parse_PropertyListPath() { - var cacheKey = 'PropertyListPath@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var result1 = parse_PropertyListNotEmpty(); - var result0 = result1 !== null ? result1 : ''; - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("[74] PropertyListPath"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; + } + + return rval; +}; + +/** + * Recursively increments the relation serialization for a mapping. + * + * @param subjects the subjects in the graph. + * @param edges the edges in the graph. + */ +MappingBuilder.prototype.serialize = function(subjects, edges) +{ + if(this.keyStack.length > 0) + { + // continue from top of key stack + var next = this.keyStack.pop(); + for(; next.idx < next.keys.length; ++next.idx) + { + var k = next.keys[next.idx]; + if(!(k in this.adj)) + { + this.keyStack.push(next); + break; + } + + if(k in this.done) + { + // mark cycle + this.s += '_' + k; + } + else + { + // mark key as serialized + this.done[k] = true; + + // serialize top-level key and its details + var s = k; + var adj = this.adj[k]; + var iri = adj.i; + if(iri in subjects) + { + var b = subjects[iri]; + + // serialize properties + s += '[' + _serializeProperties(b) + ']'; + + // serialize references + var first = true; + s += '['; + var refs = edges.refs[iri].all; + for(var r in refs) + { + if(first) + { + first = false; + } + else + { + s += '|'; + } + s += '<' + refs[r].p + '>'; + s += _isBlankNodeIri(refs[r].s) ? + '_:' : ('<' + refs[r].s + '>'); + } + s += ']'; + } + + // serialize adjacent node keys + s += adj.k.join(''); + this.s += s; + this.keyStack.push({ keys: adj.k, idx: 0 }); + this.serialize(subjects, edges); + } } - - function parse_VerbPath() { - var cacheKey = 'VerbPath@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var result1 = parse_PathAlternative(); - var result0 = result1 !== null - ? (function(p) { - var path = {}; - path.token = 'path'; - path.value = p; - - return p; - })(result1) - : null; - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("[75]"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; + } +}; + +/** + * Marks a relation serialization as dirty if necessary. + * + * @param iri the IRI of the bnode to check. + * @param changed the old IRI of the bnode that changed. + * @param dir the direction to check ('props' or 'refs'). + * + * @return true if marked dirty, false if not. + */ +Processor.prototype.markSerializationDirty = function(iri, changed, dir) +{ + var rval = false; + + var s = this.serializations[iri]; + if(s[dir] !== null && changed in s[dir].m) + { + s[dir] = null; + rval = true; + } + + return rval; +}; + +/** + * Rotates the elements in an array one position. + * + * @param a the array. + */ +var _rotate = function(a) +{ + a.unshift.apply(a, a.splice(1, a.length)); +}; + +/** + * Compares two serializations for the same blank node. If the two + * serializations aren't complete enough to determine if they are equal (or if + * they are actually equal), 0 is returned. + * + * @param s1 the first serialization. + * @param s2 the second serialization. + * + * @return -1 if s1 < s2, 0 if s1 == s2 (or indeterminate), 1 if s1 > v2. + */ +var _compareSerializations = function(s1, s2) +{ + var rval = 0; + + if(s1.length == s2.length) + { + rval = _compare(s1, s2); + } + else if(s1.length > s2.length) + { + rval = _compare(s1.substr(0, s2.length), s2); + } + else + { + rval = _compare(s1, s2.substr(0, s1.length)); + } + + return rval; +}; + +/** + * Recursively serializes adjacent bnode combinations for a bnode. + * + * @param s the serialization to update. + * @param iri the IRI of the bnode being serialized. + * @param siri the serialization name for the bnode IRI. + * @param mb the MappingBuilder to use. + * @param dir the edge direction to use ('props' or 'refs'). + * @param mapped all of the already-mapped adjacent bnodes. + * @param notMapped all of the not-yet mapped adjacent bnodes. + */ +Processor.prototype.serializeCombos = function( + s, iri, siri, mb, dir, mapped, notMapped) +{ + // handle recursion + if(notMapped.length > 0) + { + // copy mapped nodes + mapped = _clone(mapped); + + // map first bnode in list + mapped[mb.mapNode(notMapped[0].s)] = notMapped[0].s; + + // recurse into remaining possible combinations + var original = mb.copy(); + notMapped = notMapped.slice(1); + var rotations = Math.max(1, notMapped.length); + for(var r = 0; r < rotations; ++r) + { + var m = (r === 0) ? mb : original.copy(); + this.serializeCombos(s, iri, siri, m, dir, mapped, notMapped); + + // rotate not-mapped for next combination + _rotate(notMapped); } - - function parse_PathAlternative() { - var cacheKey = 'PathAlternative@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var savedPos0 = pos; - var result1 = parse_PathSequence(); - if (result1 !== null) { - var result2 = []; - var savedPos1 = pos; - if (input.substr(pos, 1) === "|") { - var result4 = "|"; - pos += 1; - } else { - var result4 = null; - if (reportMatchFailures) { - matchFailed("\"|\""); - } - } - if (result4 !== null) { - var result5 = parse_PathSequence(); - if (result5 !== null) { - var result3 = [result4, result5]; - } else { - var result3 = null; - pos = savedPos1; - } - } else { - var result3 = null; - pos = savedPos1; - } - while (result3 !== null) { - result2.push(result3); - var savedPos1 = pos; - if (input.substr(pos, 1) === "|") { - var result4 = "|"; - pos += 1; - } else { - var result4 = null; - if (reportMatchFailures) { - matchFailed("\"|\""); - } - } - if (result4 !== null) { - var result5 = parse_PathSequence(); - if (result5 !== null) { - var result3 = [result4, result5]; - } else { - var result3 = null; - pos = savedPos1; - } - } else { - var result3 = null; - pos = savedPos1; - } - } - if (result2 !== null) { - var result0 = [result1, result2]; - } else { - var result0 = null; - pos = savedPos0; - } - } else { - var result0 = null; - pos = savedPos0; - } - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("[78] PathAlternative"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_PathSequence() { - var cacheKey = 'PathSequence@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var savedPos0 = pos; - var result1 = parse_PathEltOrInverse(); - if (result1 !== null) { - var result2 = []; - var savedPos1 = pos; - if (input.substr(pos, 1) === "/") { - var result4 = "/"; - pos += 1; - } else { - var result4 = null; - if (reportMatchFailures) { - matchFailed("\"/\""); - } - } - if (result4 !== null) { - var result5 = parse_PathEltOrInverse(); - if (result5 !== null) { - var result3 = [result4, result5]; - } else { - var result3 = null; - pos = savedPos1; - } - } else { - var result3 = null; - pos = savedPos1; - } - while (result3 !== null) { - result2.push(result3); - var savedPos1 = pos; - if (input.substr(pos, 1) === "/") { - var result4 = "/"; - pos += 1; - } else { - var result4 = null; - if (reportMatchFailures) { - matchFailed("\"/\""); - } - } - if (result4 !== null) { - var result5 = parse_PathEltOrInverse(); - if (result5 !== null) { - var result3 = [result4, result5]; - } else { - var result3 = null; - pos = savedPos1; - } - } else { - var result3 = null; - pos = savedPos1; - } - } - if (result2 !== null) { - var result0 = [result1, result2]; - } else { - var result0 = null; - pos = savedPos0; - } - } else { - var result0 = null; - pos = savedPos0; - } - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("[79] PathSequence"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_PathElt() { - var cacheKey = 'PathElt@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var savedPos0 = pos; - var result1 = parse_PathPrimary(); - if (result1 !== null) { - var result3 = parse_PathMod(); - var result2 = result3 !== null ? result3 : ''; - if (result2 !== null) { - var result0 = [result1, result2]; - } else { - var result0 = null; - pos = savedPos0; - } - } else { - var result0 = null; - pos = savedPos0; - } - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("[88] PathElt"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_PathEltOrInverse() { - var cacheKey = 'PathEltOrInverse@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var result4 = parse_PathElt(); - if (result4 !== null) { - var result0 = result4; - } else { - var savedPos0 = pos; - if (input.substr(pos, 1) === "^") { - var result2 = "^"; - pos += 1; - } else { - var result2 = null; - if (reportMatchFailures) { - matchFailed("\"^\""); - } - } - if (result2 !== null) { - var result3 = parse_PathElt(); - if (result3 !== null) { - var result1 = [result2, result3]; - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - if (result1 !== null) { - var result0 = result1; - } else { - var result0 = null;; - }; - } - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("[81] PathEltOrInverse"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; + } + // no more adjacent bnodes to map, update serialization + else + { + var keys = Object.keys(mapped).sort(); + mb.adj[siri] = { i: iri, k: keys, m: mapped }; + mb.serialize(this.subjects, this.edges); + + // optimize away mappings that are already too large + if(s[dir] === null || _compareSerializations(mb.s, s[dir].s) <= 0) + { + // recurse into adjacent values + for(var i in keys) + { + var k = keys[i]; + this.serializeBlankNode(s, mapped[k], mb, dir); + } + + // update least serialization if new one has been found + mb.serialize(this.subjects, this.edges); + if(s[dir] === null || + (_compareSerializations(mb.s, s[dir].s) <= 0 && + mb.s.length >= s[dir].s.length)) + { + s[dir] = { s: mb.s, m: mb.mapping }; + } } - - function parse_PathMod() { - var cacheKey = 'PathMod@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - if (input.substr(pos, 1) === "*") { - var result21 = "*"; - pos += 1; - } else { - var result21 = null; - if (reportMatchFailures) { - matchFailed("\"*\""); - } - } - if (result21 !== null) { - var result0 = result21; - } else { - if (input.substr(pos, 1) === "?") { - var result20 = "?"; - pos += 1; - } else { - var result20 = null; - if (reportMatchFailures) { - matchFailed("\"?\""); - } - } - if (result20 !== null) { - var result0 = result20; - } else { - if (input.substr(pos, 1) === "+") { - var result19 = "+"; - pos += 1; - } else { - var result19 = null; - if (reportMatchFailures) { - matchFailed("\"+\""); - } - } - if (result19 !== null) { - var result0 = result19; - } else { - var savedPos0 = pos; - if (input.substr(pos, 1) === "{") { - var result2 = "{"; - pos += 1; - } else { - var result2 = null; - if (reportMatchFailures) { - matchFailed("\"{\""); - } - } - if (result2 !== null) { - var savedPos2 = pos; - var result9 = parse_INTEGER(); - if (result9 !== null) { - var savedPos3 = pos; - if (input.substr(pos, 1) === ",") { - var result13 = ","; - pos += 1; - } else { - var result13 = null; - if (reportMatchFailures) { - matchFailed("\",\""); - } - } - if (result13 !== null) { - if (input.substr(pos, 1) === "}") { - var result18 = "}"; - pos += 1; - } else { - var result18 = null; - if (reportMatchFailures) { - matchFailed("\"}\""); - } - } - if (result18 !== null) { - var result14 = result18; - } else { - var savedPos4 = pos; - var result16 = parse_INTEGER(); - if (result16 !== null) { - if (input.substr(pos, 1) === "}") { - var result17 = "}"; - pos += 1; - } else { - var result17 = null; - if (reportMatchFailures) { - matchFailed("\"}\""); - } - } - if (result17 !== null) { - var result15 = [result16, result17]; - } else { - var result15 = null; - pos = savedPos4; - } - } else { - var result15 = null; - pos = savedPos4; - } - if (result15 !== null) { - var result14 = result15; - } else { - var result14 = null;; - }; - } - if (result14 !== null) { - var result12 = [result13, result14]; - } else { - var result12 = null; - pos = savedPos3; - } - } else { - var result12 = null; - pos = savedPos3; - } - if (result12 !== null) { - var result10 = result12; - } else { - if (input.substr(pos, 1) === "}") { - var result11 = "}"; - pos += 1; - } else { - var result11 = null; - if (reportMatchFailures) { - matchFailed("\"}\""); - } - } - if (result11 !== null) { - var result10 = result11; - } else { - var result10 = null;; - }; - } - if (result10 !== null) { - var result8 = [result9, result10]; - } else { - var result8 = null; - pos = savedPos2; - } - } else { - var result8 = null; - pos = savedPos2; - } - if (result8 !== null) { - var result3 = result8; - } else { - var savedPos1 = pos; - if (input.substr(pos, 1) === ",") { - var result5 = ","; - pos += 1; - } else { - var result5 = null; - if (reportMatchFailures) { - matchFailed("\",\""); - } - } - if (result5 !== null) { - var result6 = parse_INTEGER(); - if (result6 !== null) { - if (input.substr(pos, 1) === "}") { - var result7 = "}"; - pos += 1; - } else { - var result7 = null; - if (reportMatchFailures) { - matchFailed("\"}\""); - } - } - if (result7 !== null) { - var result4 = [result5, result6, result7]; - } else { - var result4 = null; - pos = savedPos1; - } - } else { - var result4 = null; - pos = savedPos1; - } - } else { - var result4 = null; - pos = savedPos1; - } - if (result4 !== null) { - var result3 = result4; - } else { - var result3 = null;; - }; - } - if (result3 !== null) { - var result1 = [result2, result3]; - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - if (result1 !== null) { - var result0 = result1; - } else { - var result0 = null;; - }; - }; - }; - } - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("[82] PathMod"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_PathPrimary() { - var cacheKey = 'PathPrimary@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var result9 = parse_IRIref(); - if (result9 !== null) { - var result0 = result9; - } else { - if (input.substr(pos, 1) === "a") { - var result8 = "a"; - pos += 1; - } else { - var result8 = null; - if (reportMatchFailures) { - matchFailed("\"a\""); - } - } - if (result8 !== null) { - var result0 = result8; - } else { - var savedPos1 = pos; - if (input.substr(pos, 1) === "!") { - var result6 = "!"; - pos += 1; - } else { - var result6 = null; - if (reportMatchFailures) { - matchFailed("\"!\""); - } - } - if (result6 !== null) { - var result7 = parse_PathNegatedPropertySet(); - if (result7 !== null) { - var result5 = [result6, result7]; - } else { - var result5 = null; - pos = savedPos1; - } - } else { - var result5 = null; - pos = savedPos1; - } - if (result5 !== null) { - var result0 = result5; - } else { - var savedPos0 = pos; - if (input.substr(pos, 1) === "(") { - var result2 = "("; - pos += 1; - } else { - var result2 = null; - if (reportMatchFailures) { - matchFailed("\"(\""); - } - } - if (result2 !== null) { - var result3 = parse_PathAlternative(); - if (result3 !== null) { - if (input.substr(pos, 1) === ")") { - var result4 = ")"; - pos += 1; - } else { - var result4 = null; - if (reportMatchFailures) { - matchFailed("\")\""); - } - } - if (result4 !== null) { - var result1 = [result2, result3, result4]; - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - if (result1 !== null) { - var result0 = result1; - } else { - var result0 = null;; - }; - }; - }; - } - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("[83] PathPrimary"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_PathNegatedPropertySet() { - var cacheKey = 'PathNegatedPropertySet@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - - var result11 = parse_PathOneInPropertySet(); - if (result11 !== null) { - var result0 = result11; - } else { - var savedPos0 = pos; - if (input.substr(pos, 1) === "(") { - var result2 = "("; - pos += 1; - } else { - var result2 = null; - if (reportMatchFailures) { - matchFailed("\"(\""); - } - } - if (result2 !== null) { - var savedPos1 = pos; - var result6 = parse_PathOneInPropertySet(); - if (result6 !== null) { - var result7 = []; - var savedPos2 = pos; - if (input.substr(pos, 1) === "|") { - var result9 = "|"; - pos += 1; - } else { - var result9 = null; - if (reportMatchFailures) { - matchFailed("\"|\""); - } - } - if (result9 !== null) { - var result10 = parse_PathOneInPropertySet(); - if (result10 !== null) { - var result8 = [result9, result10]; - } else { - var result8 = null; - pos = savedPos2; - } - } else { - var result8 = null; - pos = savedPos2; - } - while (result8 !== null) { - result7.push(result8); - var savedPos2 = pos; - if (input.substr(pos, 1) === "|") { - var result9 = "|"; - pos += 1; - } else { - var result9 = null; - if (reportMatchFailures) { - matchFailed("\"|\""); - } - } - if (result9 !== null) { - var result10 = parse_PathOneInPropertySet(); - if (result10 !== null) { - var result8 = [result9, result10]; - } else { - var result8 = null; - pos = savedPos2; - } - } else { - var result8 = null; - pos = savedPos2; - } - } - if (result7 !== null) { - var result5 = [result6, result7]; - } else { - var result5 = null; - pos = savedPos1; - } - } else { - var result5 = null; - pos = savedPos1; - } - var result3 = result5 !== null ? result5 : ''; - if (result3 !== null) { - if (input.substr(pos, 1) === ")") { - var result4 = ")"; - pos += 1; - } else { - var result4 = null; - if (reportMatchFailures) { - matchFailed("\")\""); - } - } - if (result4 !== null) { - var result1 = [result2, result3, result4]; - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - if (result1 !== null) { - var result0 = result1; - } else { - var result0 = null;; - }; - } - - - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_PathOneInPropertySet() { - var cacheKey = 'PathOneInPropertySet@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var result7 = parse_IRIref(); - if (result7 !== null) { - var result0 = result7; - } else { - if (input.substr(pos, 1) === "a") { - var result6 = "a"; - pos += 1; - } else { - var result6 = null; - if (reportMatchFailures) { - matchFailed("\"a\""); - } - } - if (result6 !== null) { - var result0 = result6; - } else { - var savedPos0 = pos; - if (input.substr(pos, 1) === "^") { - var result2 = "^"; - pos += 1; - } else { - var result2 = null; - if (reportMatchFailures) { - matchFailed("\"^\""); - } - } - if (result2 !== null) { - var result5 = parse_IRIref(); - if (result5 !== null) { - var result3 = result5; - } else { - if (input.substr(pos, 1) === "a") { - var result4 = "a"; - pos += 1; - } else { - var result4 = null; - if (reportMatchFailures) { - matchFailed("\"a\""); - } - } - if (result4 !== null) { - var result3 = result4; - } else { - var result3 = null;; - }; - } - if (result3 !== null) { - var result1 = [result2, result3]; - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - if (result1 !== null) { - var result0 = result1; - } else { - var result0 = null;; - }; - }; - } - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("[85] PathOneInPropertySet"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_TriplesNode() { - var cacheKey = 'TriplesNode@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var result3 = parse_Collection(); - var result2 = result3 !== null - ? (function(c) { - triplesContext = []; - chainSubject = []; - - var triple = null; - - // catch NIL - /* - if(c.length == 1 && c[0].token && c[0].token === 'nil') { - GlobalBlankNodeCounter++; - return {token: "triplesnodecollection", - triplesContext:[{subject: {token:'blank', label:("_:"+GlobalBlankNodeCounter)}, - predicate:{token:'uri', prefix:null, suffix:null, value:'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest'}, - object: {token:'blank', label:("_:"+(GlobalBlankNodeCounter+1))}}], - chainSubject:{token:'blank', label:("_:"+GlobalBlankNodeCounter)}}; - - } - */ - - // other cases - for(var i=0; i 0) { - return {token:'literal', value:s.value, lang:e.slice(1), type:null} - } else { - if(typeof(e) === "object") { - e.shift(); // remove the '^^' char - return {token:'literal', value:s.value, lang:null, type:e[0] } - } else { - return { token:'literal', value:s.value, lang:null, type:null } - } - } - })(result1[0], result1[1]) - : null; - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("[112] RDFLiteral"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_NumericLiteral() { - var cacheKey = 'NumericLiteral@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var result3 = parse_NumericLiteralUnsigned(); - if (result3 !== null) { - var result0 = result3; - } else { - var result2 = parse_NumericLiteralPositive(); - if (result2 !== null) { - var result0 = result2; - } else { - var result1 = parse_NumericLiteralNegative(); - if (result1 !== null) { - var result0 = result1; - } else { - var result0 = null;; - }; - }; - } - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("[113] NumericLiteral"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_NumericLiteralUnsigned() { - var cacheKey = 'NumericLiteralUnsigned@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var result3 = parse_DOUBLE(); - if (result3 !== null) { - var result0 = result3; - } else { - var result2 = parse_DECIMAL(); - if (result2 !== null) { - var result0 = result2; - } else { - var result1 = parse_INTEGER(); - if (result1 !== null) { - var result0 = result1; - } else { - var result0 = null;; - }; - }; - } - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("[114] NumericLiteralUnsigned"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_NumericLiteralPositive() { - var cacheKey = 'NumericLiteralPositive@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var result3 = parse_DOUBLE_POSITIVE(); - if (result3 !== null) { - var result0 = result3; - } else { - var result2 = parse_DECIMAL_POSITIVE(); - if (result2 !== null) { - var result0 = result2; - } else { - var result1 = parse_INTEGER_POSITIVE(); - if (result1 !== null) { - var result0 = result1; - } else { - var result0 = null;; - }; - }; - } - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("[115] NumericLiteralPositive"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_NumericLiteralNegative() { - var cacheKey = 'NumericLiteralNegative@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var result3 = parse_DOUBLE_NEGATIVE(); - if (result3 !== null) { - var result0 = result3; - } else { - var result2 = parse_DECIMAL_NEGATIVE(); - if (result2 !== null) { - var result0 = result2; - } else { - var result1 = parse_INTEGER_NEGATIVE(); - if (result1 !== null) { - var result0 = result1; - } else { - var result0 = null;; - }; - }; - } - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("[116] NumericLiteralNegative"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_BooleanLiteral() { - var cacheKey = 'BooleanLiteral@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - if (input.substr(pos, 4) === "true") { - var result4 = "true"; - pos += 4; - } else { - var result4 = null; - if (reportMatchFailures) { - matchFailed("\"true\""); - } - } - var result3 = result4 !== null - ? (function() { - lit = {}; - lit.token = "literal"; - lit.lang = null; - lit.type = "http://www.w3.org/2001/XMLSchema#boolean"; - lit.value = true; - return lit; - })() - : null; - if (result3 !== null) { - var result0 = result3; - } else { - if (input.substr(pos, 5) === "false") { - var result2 = "false"; - pos += 5; - } else { - var result2 = null; - if (reportMatchFailures) { - matchFailed("\"false\""); - } - } - var result1 = result2 !== null - ? (function() { - lit = {}; - lit.token = "literal"; - lit.lang = null; - lit.type = "http://www.w3.org/2001/XMLSchema#boolean"; - lit.value = false; - return lit; - })() - : null; - if (result1 !== null) { - var result0 = result1; - } else { - var result0 = null;; - }; - } - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("[117] BooleanLiteral"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_String() { - var cacheKey = 'String@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var result8 = parse_STRING_LITERAL_LONG1(); - var result7 = result8 !== null - ? (function(s) { return {token:'string', value:s} })(result8) - : null; - if (result7 !== null) { - var result0 = result7; - } else { - var result6 = parse_STRING_LITERAL_LONG2(); - var result5 = result6 !== null - ? (function(s) { return {token:'string', value:s} })(result6) - : null; - if (result5 !== null) { - var result0 = result5; - } else { - var result4 = parse_STRING_LITERAL1(); - var result3 = result4 !== null - ? (function(s) { return {token:'string', value:s} })(result4) - : null; - if (result3 !== null) { - var result0 = result3; - } else { - var result2 = parse_STRING_LITERAL2(); - var result1 = result2 !== null - ? (function(s) { return {token:'string', value:s} })(result2) - : null; - if (result1 !== null) { - var result0 = result1; - } else { - var result0 = null;; - }; - }; - }; - } - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("[118] String"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_IRIref() { - var cacheKey = 'IRIref@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var result4 = parse_IRI_REF(); - var result3 = result4 !== null - ? (function(iri) { return {token: 'uri', prefix:null, suffix:null, value:iri} })(result4) - : null; - if (result3 !== null) { - var result0 = result3; - } else { - var result2 = parse_PrefixedName(); - var result1 = result2 !== null - ? (function(p) { return p })(result2) - : null; - if (result1 !== null) { - var result0 = result1; - } else { - var result0 = null;; - }; - } - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("[119] IRIref"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_PrefixedName() { - var cacheKey = 'PrefixedName@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var result4 = parse_PNAME_LN(); - var result3 = result4 !== null - ? (function(p) { return {token: 'uri', prefix:p[0], suffix:p[1], value:null } })(result4) - : null; - if (result3 !== null) { - var result0 = result3; - } else { - var result2 = parse_PNAME_NS(); - var result1 = result2 !== null - ? (function(p) { return {token: 'uri', prefix:p, suffix:'', value:null } })(result2) - : null; - if (result1 !== null) { - var result0 = result1; - } else { - var result0 = null;; - }; - } - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("[120] PrefixedName"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_BlankNode() { - var cacheKey = 'BlankNode@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var result4 = parse_BLANK_NODE_LABEL(); - var result3 = result4 !== null - ? (function(l) { return {token:'blank', label:l}})(result4) - : null; - if (result3 !== null) { - var result0 = result3; - } else { - var result2 = parse_ANON(); - var result1 = result2 !== null - ? (function() { GlobalBlankNodeCounter++; return {token:'blank', label:''+GlobalBlankNodeCounter} })() - : null; - if (result1 !== null) { - var result0 = result1; - } else { - var result0 = null;; - }; - } - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("[121] BlankNode"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_IRI_REF() { - var cacheKey = 'IRI_REF@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var savedPos0 = pos; - if (input.substr(pos, 1) === "<") { - var result2 = "<"; - pos += 1; - } else { - var result2 = null; - if (reportMatchFailures) { - matchFailed("\"<\""); - } - } - if (result2 !== null) { - var result3 = []; - if (input.substr(pos).match(/^[^<>"{} | ^\\]/) !== null) { - var result5 = input.charAt(pos); - pos++; - } else { - var result5 = null; - if (reportMatchFailures) { - matchFailed("[^<>\"{} | ^\\\\]"); - } - } - while (result5 !== null) { - result3.push(result5); - if (input.substr(pos).match(/^[^<>"{} | ^\\]/) !== null) { - var result5 = input.charAt(pos); - pos++; - } else { - var result5 = null; - if (reportMatchFailures) { - matchFailed("[^<>\"{} | ^\\\\]"); - } - } - } - if (result3 !== null) { - if (input.substr(pos, 1) === ">") { - var result4 = ">"; - pos += 1; - } else { - var result4 = null; - if (reportMatchFailures) { - matchFailed("\">\""); - } - } - if (result4 !== null) { - var result1 = [result2, result3, result4]; - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - var result0 = result1 !== null - ? (function(iri_ref) { return iri_ref.join('') })(result1[1]) - : null; - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("[122] IRI_REF"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_PNAME_NS() { - var cacheKey = 'PNAME_NS@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var savedPos0 = pos; - var result4 = parse_PN_PREFIX(); - var result2 = result4 !== null ? result4 : ''; - if (result2 !== null) { - if (input.substr(pos, 1) === ":") { - var result3 = ":"; - pos += 1; - } else { - var result3 = null; - if (reportMatchFailures) { - matchFailed("\":\""); - } - } - if (result3 !== null) { - var result1 = [result2, result3]; - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - var result0 = result1 !== null - ? (function(p) { return p })(result1[0]) - : null; - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("[123] PNAME_NS"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_PNAME_LN() { - var cacheKey = 'PNAME_LN@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var savedPos0 = pos; - var result2 = parse_PNAME_NS(); - if (result2 !== null) { - var result3 = parse_PN_LOCAL(); - if (result3 !== null) { - var result1 = [result2, result3]; - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - var result0 = result1 !== null - ? (function(p, s) { return [p, s] })(result1[0], result1[1]) - : null; - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("[124] PNAME_LN"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_BLANK_NODE_LABEL() { - var cacheKey = 'BLANK_NODE_LABEL@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var savedPos0 = pos; - if (input.substr(pos, 2) === "_:") { - var result2 = "_:"; - pos += 2; - } else { - var result2 = null; - if (reportMatchFailures) { - matchFailed("\"_:\""); - } - } - if (result2 !== null) { - var result3 = parse_PN_LOCAL(); - if (result3 !== null) { - var result1 = [result2, result3]; - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - var result0 = result1 !== null - ? (function(l) { return l })(result1[1]) - : null; - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("[125] BLANK_NODE_LABEL"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_VAR1() { - var cacheKey = 'VAR1@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var savedPos0 = pos; - if (input.substr(pos, 1) === "?") { - var result2 = "?"; - pos += 1; - } else { - var result2 = null; - if (reportMatchFailures) { - matchFailed("\"?\""); - } - } - if (result2 !== null) { - var result3 = parse_VARNAME(); - if (result3 !== null) { - var result1 = [result2, result3]; - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - var result0 = result1 !== null - ? (function(v) { return v })(result1[1]) - : null; - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("[126] VAR1"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_VAR2() { - var cacheKey = 'VAR2@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var savedPos0 = pos; - if (input.substr(pos, 1) === "$") { - var result2 = "$"; - pos += 1; - } else { - var result2 = null; - if (reportMatchFailures) { - matchFailed("\"$\""); - } - } - if (result2 !== null) { - var result3 = parse_VARNAME(); - if (result3 !== null) { - var result1 = [result2, result3]; - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - var result0 = result1 !== null - ? (function(v) { return v })(result1[1]) - : null; - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("[127] VAR2"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_LANGTAG() { - var cacheKey = 'LANGTAG@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var savedPos0 = pos; - if (input.substr(pos, 1) === "@") { - var result2 = "@"; - pos += 1; - } else { - var result2 = null; - if (reportMatchFailures) { - matchFailed("\"@\""); - } - } - if (result2 !== null) { - if (input.substr(pos).match(/^[a-zA-Z]/) !== null) { - var result9 = input.charAt(pos); - pos++; - } else { - var result9 = null; - if (reportMatchFailures) { - matchFailed("[a-zA-Z]"); - } - } - if (result9 !== null) { - var result3 = []; - while (result9 !== null) { - result3.push(result9); - if (input.substr(pos).match(/^[a-zA-Z]/) !== null) { - var result9 = input.charAt(pos); - pos++; - } else { - var result9 = null; - if (reportMatchFailures) { - matchFailed("[a-zA-Z]"); - } - } - } - } else { - var result3 = null; - } - if (result3 !== null) { - var result4 = []; - var savedPos1 = pos; - if (input.substr(pos, 1) === "-") { - var result6 = "-"; - pos += 1; - } else { - var result6 = null; - if (reportMatchFailures) { - matchFailed("\"-\""); - } - } - if (result6 !== null) { - if (input.substr(pos).match(/^[a-zA-Z0-9]/) !== null) { - var result8 = input.charAt(pos); - pos++; - } else { - var result8 = null; - if (reportMatchFailures) { - matchFailed("[a-zA-Z0-9]"); - } - } - if (result8 !== null) { - var result7 = []; - while (result8 !== null) { - result7.push(result8); - if (input.substr(pos).match(/^[a-zA-Z0-9]/) !== null) { - var result8 = input.charAt(pos); - pos++; - } else { - var result8 = null; - if (reportMatchFailures) { - matchFailed("[a-zA-Z0-9]"); - } - } - } - } else { - var result7 = null; - } - if (result7 !== null) { - var result5 = [result6, result7]; - } else { - var result5 = null; - pos = savedPos1; - } - } else { - var result5 = null; - pos = savedPos1; - } - while (result5 !== null) { - result4.push(result5); - var savedPos1 = pos; - if (input.substr(pos, 1) === "-") { - var result6 = "-"; - pos += 1; - } else { - var result6 = null; - if (reportMatchFailures) { - matchFailed("\"-\""); - } - } - if (result6 !== null) { - if (input.substr(pos).match(/^[a-zA-Z0-9]/) !== null) { - var result8 = input.charAt(pos); - pos++; - } else { - var result8 = null; - if (reportMatchFailures) { - matchFailed("[a-zA-Z0-9]"); - } - } - if (result8 !== null) { - var result7 = []; - while (result8 !== null) { - result7.push(result8); - if (input.substr(pos).match(/^[a-zA-Z0-9]/) !== null) { - var result8 = input.charAt(pos); - pos++; - } else { - var result8 = null; - if (reportMatchFailures) { - matchFailed("[a-zA-Z0-9]"); - } - } - } - } else { - var result7 = null; - } - if (result7 !== null) { - var result5 = [result6, result7]; - } else { - var result5 = null; - pos = savedPos1; - } - } else { - var result5 = null; - pos = savedPos1; - } - } - if (result4 !== null) { - var result1 = [result2, result3, result4]; - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - var result0 = result1 !== null - ? (function(a, b) { - - if(b.length===0) { - return ("@"+a.join('')).toLowerCase(); - } else { - return ("@"+a.join('')+"-"+b[0][1].join('')).toLowerCase(); - } - })(result1[1], result1[2]) - : null; - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("[128] LANGTAG"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_INTEGER() { - var cacheKey = 'INTEGER@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - if (input.substr(pos).match(/^[0-9]/) !== null) { - var result2 = input.charAt(pos); - pos++; - } else { - var result2 = null; - if (reportMatchFailures) { - matchFailed("[0-9]"); - } - } - if (result2 !== null) { - var result1 = []; - while (result2 !== null) { - result1.push(result2); - if (input.substr(pos).match(/^[0-9]/) !== null) { - var result2 = input.charAt(pos); - pos++; - } else { - var result2 = null; - if (reportMatchFailures) { - matchFailed("[0-9]"); - } - } - } - } else { - var result1 = null; - } - var result0 = result1 !== null - ? (function(d) { - lit = {}; - lit.token = "literal"; - lit.lang = null; - lit.type = "http://www.w3.org/2001/XMLSchema#integer"; - lit.value = flattenString(d); - return lit; - })(result1) - : null; - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("[129] INTEGER"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_DECIMAL() { - var cacheKey = 'DECIMAL@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var savedPos1 = pos; - if (input.substr(pos).match(/^[0-9]/) !== null) { - var result12 = input.charAt(pos); - pos++; - } else { - var result12 = null; - if (reportMatchFailures) { - matchFailed("[0-9]"); - } - } - if (result12 !== null) { - var result8 = []; - while (result12 !== null) { - result8.push(result12); - if (input.substr(pos).match(/^[0-9]/) !== null) { - var result12 = input.charAt(pos); - pos++; - } else { - var result12 = null; - if (reportMatchFailures) { - matchFailed("[0-9]"); - } - } - } - } else { - var result8 = null; - } - if (result8 !== null) { - if (input.substr(pos, 1) === ".") { - var result9 = "."; - pos += 1; - } else { - var result9 = null; - if (reportMatchFailures) { - matchFailed("\".\""); - } - } - if (result9 !== null) { - var result10 = []; - if (input.substr(pos).match(/^[0-9]/) !== null) { - var result11 = input.charAt(pos); - pos++; - } else { - var result11 = null; - if (reportMatchFailures) { - matchFailed("[0-9]"); - } - } - while (result11 !== null) { - result10.push(result11); - if (input.substr(pos).match(/^[0-9]/) !== null) { - var result11 = input.charAt(pos); - pos++; - } else { - var result11 = null; - if (reportMatchFailures) { - matchFailed("[0-9]"); - } - } - } - if (result10 !== null) { - var result7 = [result8, result9, result10]; - } else { - var result7 = null; - pos = savedPos1; - } - } else { - var result7 = null; - pos = savedPos1; - } - } else { - var result7 = null; - pos = savedPos1; - } - var result6 = result7 !== null - ? (function(a, b, c) { - - lit = {}; - lit.token = "literal"; - lit.lang = null; - lit.type = "http://www.w3.org/2001/XMLSchema#decimal"; - lit.value = flattenString([a,b,c]); - return lit; - })(result7[0], result7[1], result7[2]) - : null; - if (result6 !== null) { - var result0 = result6; - } else { - var savedPos0 = pos; - if (input.substr(pos, 1) === ".") { - var result3 = "."; - pos += 1; - } else { - var result3 = null; - if (reportMatchFailures) { - matchFailed("\".\""); - } - } - if (result3 !== null) { - if (input.substr(pos).match(/^[0-9]/) !== null) { - var result5 = input.charAt(pos); - pos++; - } else { - var result5 = null; - if (reportMatchFailures) { - matchFailed("[0-9]"); - } - } - if (result5 !== null) { - var result4 = []; - while (result5 !== null) { - result4.push(result5); - if (input.substr(pos).match(/^[0-9]/) !== null) { - var result5 = input.charAt(pos); - pos++; - } else { - var result5 = null; - if (reportMatchFailures) { - matchFailed("[0-9]"); - } - } - } - } else { - var result4 = null; - } - if (result4 !== null) { - var result2 = [result3, result4]; - } else { - var result2 = null; - pos = savedPos0; - } - } else { - var result2 = null; - pos = savedPos0; - } - var result1 = result2 !== null - ? (function(a, b) { - lit = {}; - lit.token = "literal"; - lit.lang = null; - lit.type = "http://www.w3.org/2001/XMLSchema#decimal"; - lit.value = flattenString([a,b]); - return lit; - })(result2[0], result2[1]) - : null; - if (result1 !== null) { - var result0 = result1; - } else { - var result0 = null;; - }; - } - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("[130] DECIMAL"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_DOUBLE() { - var cacheKey = 'DOUBLE@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var savedPos2 = pos; - if (input.substr(pos).match(/^[0-9]/) !== null) { - var result19 = input.charAt(pos); - pos++; - } else { - var result19 = null; - if (reportMatchFailures) { - matchFailed("[0-9]"); - } - } - if (result19 !== null) { - var result14 = []; - while (result19 !== null) { - result14.push(result19); - if (input.substr(pos).match(/^[0-9]/) !== null) { - var result19 = input.charAt(pos); - pos++; - } else { - var result19 = null; - if (reportMatchFailures) { - matchFailed("[0-9]"); - } - } - } - } else { - var result14 = null; - } - if (result14 !== null) { - if (input.substr(pos, 1) === ".") { - var result15 = "."; - pos += 1; - } else { - var result15 = null; - if (reportMatchFailures) { - matchFailed("\".\""); - } - } - if (result15 !== null) { - var result16 = []; - if (input.substr(pos).match(/^[0-9]/) !== null) { - var result18 = input.charAt(pos); - pos++; - } else { - var result18 = null; - if (reportMatchFailures) { - matchFailed("[0-9]"); - } - } - while (result18 !== null) { - result16.push(result18); - if (input.substr(pos).match(/^[0-9]/) !== null) { - var result18 = input.charAt(pos); - pos++; - } else { - var result18 = null; - if (reportMatchFailures) { - matchFailed("[0-9]"); - } - } - } - if (result16 !== null) { - var result17 = parse_EXPONENT(); - if (result17 !== null) { - var result13 = [result14, result15, result16, result17]; - } else { - var result13 = null; - pos = savedPos2; - } - } else { - var result13 = null; - pos = savedPos2; - } - } else { - var result13 = null; - pos = savedPos2; - } - } else { - var result13 = null; - pos = savedPos2; - } - var result12 = result13 !== null - ? (function(a, b, c, e) { - lit = {}; - lit.token = "literal"; - lit.lang = null; - lit.type = "http://www.w3.org/2001/XMLSchema#double"; - lit.value = flattenString([a,b,c,e]); - return lit; - })(result13[0], result13[1], result13[2], result13[3]) - : null; - if (result12 !== null) { - var result0 = result12; - } else { - var savedPos1 = pos; - if (input.substr(pos, 1) === ".") { - var result8 = "."; - pos += 1; - } else { - var result8 = null; - if (reportMatchFailures) { - matchFailed("\".\""); - } - } - if (result8 !== null) { - if (input.substr(pos).match(/^[0-9]/) !== null) { - var result11 = input.charAt(pos); - pos++; - } else { - var result11 = null; - if (reportMatchFailures) { - matchFailed("[0-9]"); - } - } - if (result11 !== null) { - var result9 = []; - while (result11 !== null) { - result9.push(result11); - if (input.substr(pos).match(/^[0-9]/) !== null) { - var result11 = input.charAt(pos); - pos++; - } else { - var result11 = null; - if (reportMatchFailures) { - matchFailed("[0-9]"); - } - } - } - } else { - var result9 = null; - } - if (result9 !== null) { - var result10 = parse_EXPONENT(); - if (result10 !== null) { - var result7 = [result8, result9, result10]; - } else { - var result7 = null; - pos = savedPos1; - } - } else { - var result7 = null; - pos = savedPos1; - } - } else { - var result7 = null; - pos = savedPos1; - } - var result6 = result7 !== null - ? (function(a, b, c) { - lit = {}; - lit.token = "literal"; - lit.lang = null; - lit.type = "http://www.w3.org/2001/XMLSchema#double"; - lit.value = flattenString([a,b,c]); - return lit; - })(result7[0], result7[1], result7[2]) - : null; - if (result6 !== null) { - var result0 = result6; - } else { - var savedPos0 = pos; - if (input.substr(pos).match(/^[0-9]/) !== null) { - var result5 = input.charAt(pos); - pos++; - } else { - var result5 = null; - if (reportMatchFailures) { - matchFailed("[0-9]"); - } - } - if (result5 !== null) { - var result3 = []; - while (result5 !== null) { - result3.push(result5); - if (input.substr(pos).match(/^[0-9]/) !== null) { - var result5 = input.charAt(pos); - pos++; - } else { - var result5 = null; - if (reportMatchFailures) { - matchFailed("[0-9]"); - } - } - } - } else { - var result3 = null; - } - if (result3 !== null) { - var result4 = parse_EXPONENT(); - if (result4 !== null) { - var result2 = [result3, result4]; - } else { - var result2 = null; - pos = savedPos0; - } - } else { - var result2 = null; - pos = savedPos0; - } - var result1 = result2 !== null - ? (function(a, b) { - lit = {}; - lit.token = "literal"; - lit.lang = null; - lit.type = "http://www.w3.org/2001/XMLSchema#double"; - lit.value = flattenString([a,b]); - return lit; - })(result2[0], result2[1]) - : null; - if (result1 !== null) { - var result0 = result1; - } else { - var result0 = null;; - }; - }; - } - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("[131] DOUBLE"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_INTEGER_POSITIVE() { - var cacheKey = 'INTEGER_POSITIVE@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var savedPos0 = pos; - if (input.substr(pos, 1) === "+") { - var result2 = "+"; - pos += 1; - } else { - var result2 = null; - if (reportMatchFailures) { - matchFailed("\"+\""); - } - } - if (result2 !== null) { - var result3 = parse_INTEGER(); - if (result3 !== null) { - var result1 = [result2, result3]; - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - var result0 = result1 !== null - ? (function(d) { d.value = "+"+d.value; return d; })(result1[1]) - : null; - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("[132] INTEGER_POSITIVE"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_DECIMAL_POSITIVE() { - var cacheKey = 'DECIMAL_POSITIVE@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var savedPos0 = pos; - if (input.substr(pos, 1) === "+") { - var result2 = "+"; - pos += 1; - } else { - var result2 = null; - if (reportMatchFailures) { - matchFailed("\"+\""); - } - } - if (result2 !== null) { - var result3 = parse_DECIMAL(); - if (result3 !== null) { - var result1 = [result2, result3]; - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - var result0 = result1 !== null - ? (function(d) { d.value = "+"+d.value; return d })(result1[1]) - : null; - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("[133] DECIMAL_POSITIVE"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_DOUBLE_POSITIVE() { - var cacheKey = 'DOUBLE_POSITIVE@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var savedPos0 = pos; - if (input.substr(pos, 1) === "+") { - var result2 = "+"; - pos += 1; - } else { - var result2 = null; - if (reportMatchFailures) { - matchFailed("\"+\""); - } - } - if (result2 !== null) { - var result3 = parse_DOUBLE(); - if (result3 !== null) { - var result1 = [result2, result3]; - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - var result0 = result1 !== null - ? (function(d) { d.value = "+"+d.value; return d })(result1[1]) - : null; - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("[134] DOUBLE_POSITIVE"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_INTEGER_NEGATIVE() { - var cacheKey = 'INTEGER_NEGATIVE@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var savedPos0 = pos; - if (input.substr(pos, 1) === "-") { - var result2 = "-"; - pos += 1; - } else { - var result2 = null; - if (reportMatchFailures) { - matchFailed("\"-\""); - } - } - if (result2 !== null) { - var result3 = parse_INTEGER(); - if (result3 !== null) { - var result1 = [result2, result3]; - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - var result0 = result1 !== null - ? (function(d) { d.value = "-"+d.value; return d; })(result1[1]) - : null; - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("[135] INTEGER_NEGATIVE"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_DECIMAL_NEGATIVE() { - var cacheKey = 'DECIMAL_NEGATIVE@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var savedPos0 = pos; - if (input.substr(pos, 1) === "-") { - var result2 = "-"; - pos += 1; - } else { - var result2 = null; - if (reportMatchFailures) { - matchFailed("\"-\""); - } - } - if (result2 !== null) { - var result3 = parse_DECIMAL(); - if (result3 !== null) { - var result1 = [result2, result3]; - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - var result0 = result1 !== null - ? (function(d) { d.value = "-"+d.value; return d; })(result1[1]) - : null; - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("[136] DECIMAL_NEGATIVE"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_DOUBLE_NEGATIVE() { - var cacheKey = 'DOUBLE_NEGATIVE@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var savedPos0 = pos; - if (input.substr(pos, 1) === "-") { - var result2 = "-"; - pos += 1; - } else { - var result2 = null; - if (reportMatchFailures) { - matchFailed("\"-\""); - } - } - if (result2 !== null) { - var result3 = parse_DOUBLE(); - if (result3 !== null) { - var result1 = [result2, result3]; - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - var result0 = result1 !== null - ? (function(d) { d.value = "-"+d.value; return d; })(result1[1]) - : null; - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("[137] DOUBLE_NEGATIVE"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_EXPONENT() { - var cacheKey = 'EXPONENT@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var savedPos0 = pos; - if (input.substr(pos).match(/^[eE]/) !== null) { - var result2 = input.charAt(pos); - pos++; - } else { - var result2 = null; - if (reportMatchFailures) { - matchFailed("[eE]"); - } - } - if (result2 !== null) { - if (input.substr(pos).match(/^[+\-]/) !== null) { - var result6 = input.charAt(pos); - pos++; - } else { - var result6 = null; - if (reportMatchFailures) { - matchFailed("[+\\-]"); - } - } - var result3 = result6 !== null ? result6 : ''; - if (result3 !== null) { - if (input.substr(pos).match(/^[0-9]/) !== null) { - var result5 = input.charAt(pos); - pos++; - } else { - var result5 = null; - if (reportMatchFailures) { - matchFailed("[0-9]"); - } - } - if (result5 !== null) { - var result4 = []; - while (result5 !== null) { - result4.push(result5); - if (input.substr(pos).match(/^[0-9]/) !== null) { - var result5 = input.charAt(pos); - pos++; - } else { - var result5 = null; - if (reportMatchFailures) { - matchFailed("[0-9]"); - } - } - } - } else { - var result4 = null; - } - if (result4 !== null) { - var result1 = [result2, result3, result4]; - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - var result0 = result1 !== null - ? (function(a, b, c) { return flattenString([a,b,c]) })(result1[0], result1[1], result1[2]) - : null; - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("[138] EXPONENT"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_STRING_LITERAL1() { - var cacheKey = 'STRING_LITERAL1@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var savedPos0 = pos; - if (input.substr(pos, 1) === "'") { - var result2 = "'"; - pos += 1; - } else { - var result2 = null; - if (reportMatchFailures) { - matchFailed("\"'\""); - } - } - if (result2 !== null) { - var result3 = []; - if (input.substr(pos).match(/^[^'\\\n\r]/) !== null) { - var result7 = input.charAt(pos); - pos++; - } else { - var result7 = null; - if (reportMatchFailures) { - matchFailed("[^'\\\\\\n\\r]"); - } - } - if (result7 !== null) { - var result5 = result7; - } else { - var result6 = parse_ECHAR(); - if (result6 !== null) { - var result5 = result6; - } else { - var result5 = null;; - }; - } - while (result5 !== null) { - result3.push(result5); - if (input.substr(pos).match(/^[^'\\\n\r]/) !== null) { - var result7 = input.charAt(pos); - pos++; - } else { - var result7 = null; - if (reportMatchFailures) { - matchFailed("[^'\\\\\\n\\r]"); - } - } - if (result7 !== null) { - var result5 = result7; - } else { - var result6 = parse_ECHAR(); - if (result6 !== null) { - var result5 = result6; - } else { - var result5 = null;; - }; - } - } - if (result3 !== null) { - if (input.substr(pos, 1) === "'") { - var result4 = "'"; - pos += 1; - } else { - var result4 = null; - if (reportMatchFailures) { - matchFailed("\"'\""); - } - } - if (result4 !== null) { - var result1 = [result2, result3, result4]; - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - var result0 = result1 !== null - ? (function(content) { return flattenString(content) })(result1[1]) - : null; - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("[139] STRING_LITERAL1"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_STRING_LITERAL2() { - var cacheKey = 'STRING_LITERAL2@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var savedPos0 = pos; - if (input.substr(pos, 1) === "\"") { - var result2 = "\""; - pos += 1; - } else { - var result2 = null; - if (reportMatchFailures) { - matchFailed("\"\\\"\""); - } - } - if (result2 !== null) { - var result3 = []; - if (input.substr(pos).match(/^[^"\\\n\r]/) !== null) { - var result7 = input.charAt(pos); - pos++; - } else { - var result7 = null; - if (reportMatchFailures) { - matchFailed("[^\"\\\\\\n\\r]"); - } - } - if (result7 !== null) { - var result5 = result7; - } else { - var result6 = parse_ECHAR(); - if (result6 !== null) { - var result5 = result6; - } else { - var result5 = null;; - }; - } - while (result5 !== null) { - result3.push(result5); - if (input.substr(pos).match(/^[^"\\\n\r]/) !== null) { - var result7 = input.charAt(pos); - pos++; - } else { - var result7 = null; - if (reportMatchFailures) { - matchFailed("[^\"\\\\\\n\\r]"); - } - } - if (result7 !== null) { - var result5 = result7; - } else { - var result6 = parse_ECHAR(); - if (result6 !== null) { - var result5 = result6; - } else { - var result5 = null;; - }; - } - } - if (result3 !== null) { - if (input.substr(pos, 1) === "\"") { - var result4 = "\""; - pos += 1; - } else { - var result4 = null; - if (reportMatchFailures) { - matchFailed("\"\\\"\""); - } - } - if (result4 !== null) { - var result1 = [result2, result3, result4]; - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - var result0 = result1 !== null - ? (function(content) { return flattenString(content) })(result1[1]) - : null; - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("[140] STRING_LITERAL2"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_STRING_LITERAL_LONG1() { - var cacheKey = 'STRING_LITERAL_LONG1@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var savedPos0 = pos; - if (input.substr(pos, 3) === "'''") { - var result2 = "'''"; - pos += 3; - } else { - var result2 = null; - if (reportMatchFailures) { - matchFailed("\"'''\""); - } - } - if (result2 !== null) { - var result3 = []; - if (input.substr(pos).match(/^[^'\\]/) !== null) { - var result7 = input.charAt(pos); - pos++; - } else { - var result7 = null; - if (reportMatchFailures) { - matchFailed("[^'\\\\]"); - } - } - if (result7 !== null) { - var result5 = result7; - } else { - var result6 = parse_ECHAR(); - if (result6 !== null) { - var result5 = result6; - } else { - var result5 = null;; - }; - } - while (result5 !== null) { - result3.push(result5); - if (input.substr(pos).match(/^[^'\\]/) !== null) { - var result7 = input.charAt(pos); - pos++; - } else { - var result7 = null; - if (reportMatchFailures) { - matchFailed("[^'\\\\]"); - } - } - if (result7 !== null) { - var result5 = result7; - } else { - var result6 = parse_ECHAR(); - if (result6 !== null) { - var result5 = result6; - } else { - var result5 = null;; - }; - } - } - if (result3 !== null) { - if (input.substr(pos, 3) === "'''") { - var result4 = "'''"; - pos += 3; - } else { - var result4 = null; - if (reportMatchFailures) { - matchFailed("\"'''\""); - } - } - if (result4 !== null) { - var result1 = [result2, result3, result4]; - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - var result0 = result1 !== null - ? (function(content) { return flattenString(content) })(result1[1]) - : null; - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("[141] STRING_LITERAL_LONG1"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_STRING_LITERAL_LONG2() { - var cacheKey = 'STRING_LITERAL_LONG2@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var savedPos0 = pos; - if (input.substr(pos, 3) === "\"\"\"") { - var result2 = "\"\"\""; - pos += 3; - } else { - var result2 = null; - if (reportMatchFailures) { - matchFailed("\"\\\"\\\"\\\"\""); - } - } - if (result2 !== null) { - var result3 = []; - if (input.substr(pos).match(/^[^"\\]/) !== null) { - var result7 = input.charAt(pos); - pos++; - } else { - var result7 = null; - if (reportMatchFailures) { - matchFailed("[^\"\\\\]"); - } - } - if (result7 !== null) { - var result5 = result7; - } else { - var result6 = parse_ECHAR(); - if (result6 !== null) { - var result5 = result6; - } else { - var result5 = null;; - }; - } - while (result5 !== null) { - result3.push(result5); - if (input.substr(pos).match(/^[^"\\]/) !== null) { - var result7 = input.charAt(pos); - pos++; - } else { - var result7 = null; - if (reportMatchFailures) { - matchFailed("[^\"\\\\]"); - } - } - if (result7 !== null) { - var result5 = result7; - } else { - var result6 = parse_ECHAR(); - if (result6 !== null) { - var result5 = result6; - } else { - var result5 = null;; - }; - } - } - if (result3 !== null) { - if (input.substr(pos, 3) === "\"\"\"") { - var result4 = "\"\"\""; - pos += 3; - } else { - var result4 = null; - if (reportMatchFailures) { - matchFailed("\"\\\"\\\"\\\"\""); - } - } - if (result4 !== null) { - var result1 = [result2, result3, result4]; - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - var result0 = result1 !== null - ? (function(content) { return flattenString(content) })(result1[1]) - : null; - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("[142] STRING_LITERAL_LONG2"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_ECHAR() { - var cacheKey = 'ECHAR@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var savedPos0 = pos; - if (input.substr(pos, 1) === "\\") { - var result1 = "\\"; - pos += 1; - } else { - var result1 = null; - if (reportMatchFailures) { - matchFailed("\"\\\\\""); - } - } - if (result1 !== null) { - if (input.substr(pos).match(/^[tbnrf"']/) !== null) { - var result2 = input.charAt(pos); - pos++; - } else { - var result2 = null; - if (reportMatchFailures) { - matchFailed("[tbnrf\"']"); - } - } - if (result2 !== null) { - var result0 = [result1, result2]; - } else { - var result0 = null; - pos = savedPos0; - } - } else { - var result0 = null; - pos = savedPos0; - } - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("[143] ECHAR"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_NIL() { - var cacheKey = 'NIL@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var savedPos0 = pos; - if (input.substr(pos, 1) === "(") { - var result2 = "("; - pos += 1; - } else { - var result2 = null; - if (reportMatchFailures) { - matchFailed("\"(\""); - } - } - if (result2 !== null) { - var result3 = []; - var result5 = parse_WS(); - while (result5 !== null) { - result3.push(result5); - var result5 = parse_WS(); - } - if (result3 !== null) { - if (input.substr(pos, 1) === ")") { - var result4 = ")"; - pos += 1; - } else { - var result4 = null; - if (reportMatchFailures) { - matchFailed("\")\""); - } - } - if (result4 !== null) { - var result1 = [result2, result3, result4]; - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - var result0 = result1 !== null - ? (function() { - - return {token: "triplesnodecollection", - triplesContext:[], - chainSubject:[{token:'uri', value:"http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"}]}; - })() - : null; - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("[144] NIL"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_WS() { - var cacheKey = 'WS@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - if (input.substr(pos).match(/^[ ]/) !== null) { - var result5 = input.charAt(pos); - pos++; - } else { - var result5 = null; - if (reportMatchFailures) { - matchFailed("[ ]"); - } - } - if (result5 !== null) { - var result0 = result5; - } else { - if (input.substr(pos).match(/^[ ]/) !== null) { - var result4 = input.charAt(pos); - pos++; - } else { - var result4 = null; - if (reportMatchFailures) { - matchFailed("[ ]"); - } - } - if (result4 !== null) { - var result0 = result4; - } else { - if (input.substr(pos).match(/^[\r]/) !== null) { - var result3 = input.charAt(pos); - pos++; - } else { - var result3 = null; - if (reportMatchFailures) { - matchFailed("[\\r]"); - } - } - if (result3 !== null) { - var result0 = result3; - } else { - if (input.substr(pos).match(/^[\n]/) !== null) { - var result2 = input.charAt(pos); - pos++; - } else { - var result2 = null; - if (reportMatchFailures) { - matchFailed("[\\n]"); - } - } - if (result2 !== null) { - var result0 = result2; - } else { - var result1 = parse_COMMENT(); - if (result1 !== null) { - var result0 = result1; - } else { - var result0 = null;; - }; - }; - }; - }; - } - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("[145] WS"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_COMMENT() { - var cacheKey = 'COMMENT@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var savedPos0 = pos; - if (input.substr(pos, 1) === "#") { - var result1 = "#"; - pos += 1; - } else { - var result1 = null; - if (reportMatchFailures) { - matchFailed("\"#\""); - } - } - if (result1 !== null) { - var result2 = []; - if (input.substr(pos).match(/^[^\n\r]/) !== null) { - var result3 = input.charAt(pos); - pos++; - } else { - var result3 = null; - if (reportMatchFailures) { - matchFailed("[^\\n\\r]"); - } - } - while (result3 !== null) { - result2.push(result3); - if (input.substr(pos).match(/^[^\n\r]/) !== null) { - var result3 = input.charAt(pos); - pos++; - } else { - var result3 = null; - if (reportMatchFailures) { - matchFailed("[^\\n\\r]"); - } - } - } - if (result2 !== null) { - var result0 = [result1, result2]; - } else { - var result0 = null; - pos = savedPos0; - } - } else { - var result0 = null; - pos = savedPos0; - } - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed(" COMMENT"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_ANON() { - var cacheKey = 'ANON@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var savedPos0 = pos; - if (input.substr(pos, 1) === "[") { - var result1 = "["; - pos += 1; - } else { - var result1 = null; - if (reportMatchFailures) { - matchFailed("\"[\""); - } - } - if (result1 !== null) { - var result2 = []; - var result4 = parse_WS(); - while (result4 !== null) { - result2.push(result4); - var result4 = parse_WS(); - } - if (result2 !== null) { - if (input.substr(pos, 1) === "]") { - var result3 = "]"; - pos += 1; - } else { - var result3 = null; - if (reportMatchFailures) { - matchFailed("\"]\""); - } - } - if (result3 !== null) { - var result0 = [result1, result2, result3]; - } else { - var result0 = null; - pos = savedPos0; - } - } else { - var result0 = null; - pos = savedPos0; - } - } else { - var result0 = null; - pos = savedPos0; - } - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("[146] ANON"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_PN_CHARS_BASE() { - var cacheKey = 'PN_CHARS_BASE@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - if (input.substr(pos).match(/^[A-Z]/) !== null) { - var result14 = input.charAt(pos); - pos++; - } else { - var result14 = null; - if (reportMatchFailures) { - matchFailed("[A-Z]"); - } - } - if (result14 !== null) { - var result0 = result14; - } else { - if (input.substr(pos).match(/^[a-z]/) !== null) { - var result13 = input.charAt(pos); - pos++; - } else { - var result13 = null; - if (reportMatchFailures) { - matchFailed("[a-z]"); - } - } - if (result13 !== null) { - var result0 = result13; - } else { - if (input.substr(pos).match(/^[\xC0-\xD6]/) !== null) { - var result12 = input.charAt(pos); - pos++; - } else { - var result12 = null; - if (reportMatchFailures) { - matchFailed("[\\xC0-\\xD6]"); - } - } - if (result12 !== null) { - var result0 = result12; - } else { - if (input.substr(pos).match(/^[\xD8-\xF6]/) !== null) { - var result11 = input.charAt(pos); - pos++; - } else { - var result11 = null; - if (reportMatchFailures) { - matchFailed("[\\xD8-\\xF6]"); - } - } - if (result11 !== null) { - var result0 = result11; - } else { - if (input.substr(pos).match(/^[\xF8-\u02FF]/) !== null) { - var result10 = input.charAt(pos); - pos++; - } else { - var result10 = null; - if (reportMatchFailures) { - matchFailed("[\\xF8-\\u02FF]"); - } - } - if (result10 !== null) { - var result0 = result10; - } else { - if (input.substr(pos).match(/^[\u0370-\u037D]/) !== null) { - var result9 = input.charAt(pos); - pos++; - } else { - var result9 = null; - if (reportMatchFailures) { - matchFailed("[\\u0370-\\u037D]"); - } - } - if (result9 !== null) { - var result0 = result9; - } else { - if (input.substr(pos).match(/^[\u037F-\u1FFF]/) !== null) { - var result8 = input.charAt(pos); - pos++; - } else { - var result8 = null; - if (reportMatchFailures) { - matchFailed("[\\u037F-\\u1FFF]"); - } - } - if (result8 !== null) { - var result0 = result8; - } else { - if (input.substr(pos).match(/^[\u200C-\u200D]/) !== null) { - var result7 = input.charAt(pos); - pos++; - } else { - var result7 = null; - if (reportMatchFailures) { - matchFailed("[\\u200C-\\u200D]"); - } - } - if (result7 !== null) { - var result0 = result7; - } else { - if (input.substr(pos).match(/^[\u2070-\u218F]/) !== null) { - var result6 = input.charAt(pos); - pos++; - } else { - var result6 = null; - if (reportMatchFailures) { - matchFailed("[\\u2070-\\u218F]"); - } - } - if (result6 !== null) { - var result0 = result6; - } else { - if (input.substr(pos).match(/^[\u2C00-\u2FEF]/) !== null) { - var result5 = input.charAt(pos); - pos++; - } else { - var result5 = null; - if (reportMatchFailures) { - matchFailed("[\\u2C00-\\u2FEF]"); - } - } - if (result5 !== null) { - var result0 = result5; - } else { - if (input.substr(pos).match(/^[\u3001-\uD7FF]/) !== null) { - var result4 = input.charAt(pos); - pos++; - } else { - var result4 = null; - if (reportMatchFailures) { - matchFailed("[\\u3001-\\uD7FF]"); - } - } - if (result4 !== null) { - var result0 = result4; - } else { - if (input.substr(pos).match(/^[\uF900-\uFDCF]/) !== null) { - var result3 = input.charAt(pos); - pos++; - } else { - var result3 = null; - if (reportMatchFailures) { - matchFailed("[\\uF900-\\uFDCF]"); - } - } - if (result3 !== null) { - var result0 = result3; - } else { - if (input.substr(pos).match(/^[\uFDF0-\uFFFD]/) !== null) { - var result2 = input.charAt(pos); - pos++; - } else { - var result2 = null; - if (reportMatchFailures) { - matchFailed("[\\uFDF0-\\uFFFD]"); - } - } - if (result2 !== null) { - var result0 = result2; - } else { - if (input.substr(pos).match(/^[\u1000-\uEFFF]/) !== null) { - var result1 = input.charAt(pos); - pos++; - } else { - var result1 = null; - if (reportMatchFailures) { - matchFailed("[\\u1000-\\uEFFF]"); - } - } - if (result1 !== null) { - var result0 = result1; - } else { - var result0 = null;; - }; - }; - }; - }; - }; - }; - }; - }; - }; - }; - }; - }; - }; - } - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("[147] PN_CHARS_BASE"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_PN_CHARS_U() { - var cacheKey = 'PN_CHARS_U@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var result2 = parse_PN_CHARS_BASE(); - if (result2 !== null) { - var result0 = result2; - } else { - if (input.substr(pos, 1) === "_") { - var result1 = "_"; - pos += 1; - } else { - var result1 = null; - if (reportMatchFailures) { - matchFailed("\"_\""); - } - } - if (result1 !== null) { - var result0 = result1; - } else { - var result0 = null;; - }; - } - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("[148] PN_CHARS_U"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_VARNAME() { - var cacheKey = 'VARNAME@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var savedPos0 = pos; - var result11 = parse_PN_CHARS_U(); - if (result11 !== null) { - var result2 = result11; - } else { - if (input.substr(pos).match(/^[0-9]/) !== null) { - var result10 = input.charAt(pos); - pos++; - } else { - var result10 = null; - if (reportMatchFailures) { - matchFailed("[0-9]"); - } - } - if (result10 !== null) { - var result2 = result10; - } else { - var result2 = null;; - }; - } - if (result2 !== null) { - var result3 = []; - var result9 = parse_PN_CHARS_U(); - if (result9 !== null) { - var result4 = result9; - } else { - if (input.substr(pos).match(/^[0-9]/) !== null) { - var result8 = input.charAt(pos); - pos++; - } else { - var result8 = null; - if (reportMatchFailures) { - matchFailed("[0-9]"); - } - } - if (result8 !== null) { - var result4 = result8; - } else { - if (input.substr(pos).match(/^[\xB7]/) !== null) { - var result7 = input.charAt(pos); - pos++; - } else { - var result7 = null; - if (reportMatchFailures) { - matchFailed("[\\xB7]"); - } - } - if (result7 !== null) { - var result4 = result7; - } else { - if (input.substr(pos).match(/^[\u0300-\u036F]/) !== null) { - var result6 = input.charAt(pos); - pos++; - } else { - var result6 = null; - if (reportMatchFailures) { - matchFailed("[\\u0300-\\u036F]"); - } - } - if (result6 !== null) { - var result4 = result6; - } else { - if (input.substr(pos).match(/^[\u203F-\u2040]/) !== null) { - var result5 = input.charAt(pos); - pos++; - } else { - var result5 = null; - if (reportMatchFailures) { - matchFailed("[\\u203F-\\u2040]"); - } - } - if (result5 !== null) { - var result4 = result5; - } else { - var result4 = null;; - }; - }; - }; - }; - } - while (result4 !== null) { - result3.push(result4); - var result9 = parse_PN_CHARS_U(); - if (result9 !== null) { - var result4 = result9; - } else { - if (input.substr(pos).match(/^[0-9]/) !== null) { - var result8 = input.charAt(pos); - pos++; - } else { - var result8 = null; - if (reportMatchFailures) { - matchFailed("[0-9]"); - } - } - if (result8 !== null) { - var result4 = result8; - } else { - if (input.substr(pos).match(/^[\xB7]/) !== null) { - var result7 = input.charAt(pos); - pos++; - } else { - var result7 = null; - if (reportMatchFailures) { - matchFailed("[\\xB7]"); - } - } - if (result7 !== null) { - var result4 = result7; - } else { - if (input.substr(pos).match(/^[\u0300-\u036F]/) !== null) { - var result6 = input.charAt(pos); - pos++; - } else { - var result6 = null; - if (reportMatchFailures) { - matchFailed("[\\u0300-\\u036F]"); - } - } - if (result6 !== null) { - var result4 = result6; - } else { - if (input.substr(pos).match(/^[\u203F-\u2040]/) !== null) { - var result5 = input.charAt(pos); - pos++; - } else { - var result5 = null; - if (reportMatchFailures) { - matchFailed("[\\u203F-\\u2040]"); - } - } - if (result5 !== null) { - var result4 = result5; - } else { - var result4 = null;; - }; - }; - }; - }; - } - } - if (result3 !== null) { - var result1 = [result2, result3]; - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - var result0 = result1 !== null - ? (function(init, rpart) { return init+rpart.join('') })(result1[0], result1[1]) - : null; - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("[149] VARNAME"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_PN_CHARS() { - var cacheKey = 'PN_CHARS@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var result6 = parse_PN_CHARS_U(); - if (result6 !== null) { - var result0 = result6; - } else { - if (input.substr(pos, 1) === "-") { - var result5 = "-"; - pos += 1; - } else { - var result5 = null; - if (reportMatchFailures) { - matchFailed("\"-\""); - } - } - if (result5 !== null) { - var result0 = result5; - } else { - if (input.substr(pos).match(/^[0-9]/) !== null) { - var result4 = input.charAt(pos); - pos++; - } else { - var result4 = null; - if (reportMatchFailures) { - matchFailed("[0-9]"); - } - } - if (result4 !== null) { - var result0 = result4; - } else { - if (input.substr(pos).match(/^[\xB7]/) !== null) { - var result3 = input.charAt(pos); - pos++; - } else { - var result3 = null; - if (reportMatchFailures) { - matchFailed("[\\xB7]"); - } - } - if (result3 !== null) { - var result0 = result3; - } else { - if (input.substr(pos).match(/^[\u0300-\u036F]/) !== null) { - var result2 = input.charAt(pos); - pos++; - } else { - var result2 = null; - if (reportMatchFailures) { - matchFailed("[\\u0300-\\u036F]"); - } - } - if (result2 !== null) { - var result0 = result2; - } else { - if (input.substr(pos).match(/^[\u203F-\u2040]/) !== null) { - var result1 = input.charAt(pos); - pos++; - } else { - var result1 = null; - if (reportMatchFailures) { - matchFailed("[\\u203F-\\u2040]"); - } - } - if (result1 !== null) { - var result0 = result1; - } else { - var result0 = null;; - }; - }; - }; - }; - }; - } - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("[150] PN_CHARS"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_PN_PREFIX() { - var cacheKey = 'PN_PREFIX@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var savedPos0 = pos; - var result2 = parse_PN_CHARS_BASE(); - if (result2 !== null) { - var result3 = []; - var result6 = parse_PN_CHARS(); - if (result6 !== null) { - var result4 = result6; - } else { - if (input.substr(pos, 1) === ".") { - var result5 = "."; - pos += 1; - } else { - var result5 = null; - if (reportMatchFailures) { - matchFailed("\".\""); - } - } - if (result5 !== null) { - var result4 = result5; - } else { - var result4 = null;; - }; - } - while (result4 !== null) { - result3.push(result4); - var result6 = parse_PN_CHARS(); - if (result6 !== null) { - var result4 = result6; - } else { - if (input.substr(pos, 1) === ".") { - var result5 = "."; - pos += 1; - } else { - var result5 = null; - if (reportMatchFailures) { - matchFailed("\".\""); - } - } - if (result5 !== null) { - var result4 = result5; - } else { - var result4 = null;; - }; - } - } - if (result3 !== null) { - var result1 = [result2, result3]; - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - var result0 = result1 !== null - ? (function(base, rest) { if(rest[rest.length-1] == '.'){ - throw new Error("Wrong PN_PREFIX, cannot finish with '.'") - } else { - return base + rest.join(''); - }})(result1[0], result1[1]) - : null; - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("[151] PN_PREFIX"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_PN_LOCAL() { - var cacheKey = 'PN_LOCAL@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var savedPos0 = pos; - var result8 = parse_PN_CHARS_U(); - if (result8 !== null) { - var result2 = result8; - } else { - if (input.substr(pos).match(/^[0-9]/) !== null) { - var result7 = input.charAt(pos); - pos++; - } else { - var result7 = null; - if (reportMatchFailures) { - matchFailed("[0-9]"); - } - } - if (result7 !== null) { - var result2 = result7; - } else { - var result2 = null;; - }; - } - if (result2 !== null) { - var result3 = []; - var result6 = parse_PN_CHARS(); - if (result6 !== null) { - var result4 = result6; - } else { - if (input.substr(pos, 1) === ".") { - var result5 = "."; - pos += 1; - } else { - var result5 = null; - if (reportMatchFailures) { - matchFailed("\".\""); - } - } - if (result5 !== null) { - var result4 = result5; - } else { - var result4 = null;; - }; - } - while (result4 !== null) { - result3.push(result4); - var result6 = parse_PN_CHARS(); - if (result6 !== null) { - var result4 = result6; - } else { - if (input.substr(pos, 1) === ".") { - var result5 = "."; - pos += 1; - } else { - var result5 = null; - if (reportMatchFailures) { - matchFailed("\".\""); - } - } - if (result5 !== null) { - var result4 = result5; - } else { - var result4 = null;; - }; - } - } - if (result3 !== null) { - var result1 = [result2, result3]; - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - var result0 = result1 !== null - ? (function(base, rest) { - return base + rest.join(''); - })(result1[0], result1[1]) - : null; - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("[152] PN_LOCAL"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function buildErrorMessage() { - function buildExpected(failuresExpected) { - failuresExpected.sort(); - - var lastFailure = null; - var failuresExpectedUnique = []; - for (var i = 0; i < failuresExpected.length; i++) { - if (failuresExpected[i] !== lastFailure) { - failuresExpectedUnique.push(failuresExpected[i]); - lastFailure = failuresExpected[i]; - } - } - - switch (failuresExpectedUnique.length) { - case 0: - return 'end of input'; - case 1: - return failuresExpectedUnique[0]; - default: - return failuresExpectedUnique.slice(0, failuresExpectedUnique.length - 1).join(', ') - + ' or ' - + failuresExpectedUnique[failuresExpectedUnique.length - 1]; - } - } - - var expected = buildExpected(rightmostMatchFailuresExpected); - var actualPos = Math.max(pos, rightmostMatchFailuresPos); - var actual = actualPos < input.length - ? quote(input.charAt(actualPos)) - : 'end of input'; - - return 'Expected ' + expected + ' but ' + actual + ' found.'; - } - - function computeErrorPosition() { - /* - * The first idea was to use |String.split| to break the input up to the - * error position along newlines and derive the line and column from - * there. However IE's |split| implementation is so broken that it was - * enough to prevent it. - */ - - var line = 1; - var column = 1; - var seenCR = false; - - for (var i = 0; i < rightmostMatchFailuresPos; i++) { - var ch = input.charAt(i); - if (ch === '\n') { - if (!seenCR) { line++; } - column = 1; - seenCR = false; - } else if (ch === '\r' | ch === '\u2028' || ch === '\u2029') { - line++; - column = 1; - seenCR = true; - } else { - column++; - seenCR = false; - } - } - - return { line: line, column: column }; - } - - - - var flattenString = function(arrs) { - - var acum =""; - - for(var i=0; i< arrs.length; i++) { - - if(typeof(arrs[i])==='string') { - - acum = acum + arrs[i]; - - } else { - - acum = acum + arrs[i].join(''); - - } - - } - - - - return acum; - - } - - - - - - var GlobalBlankNodeCounter = 0; - - - - var prefixes = {}; - - - - var registerPrefix = function(prefix, uri) { - - prefixes[prefix] = uri; - - } - - - - var registerDefaultPrefix = function(uri) { - - prefixes[null] = uri; - - } - - - - var result = parseFunctions[startRule](); - - /* - * The parser is now in one of the following three states: - * - * 1. The parser successfully parsed the whole input. - * - * - |result !== null| - * - |pos === input.length| - * - |rightmostMatchFailuresExpected| may or may not contain something - * - * 2. The parser successfully parsed only a part of the input. - * - * - |result !== null| - * - |pos < input.length| - * - |rightmostMatchFailuresExpected| may or may not contain something - * - * 3. The parser did not successfully parse any part of the input. - * - * - |result === null| - * - |pos === 0| - * - |rightmostMatchFailuresExpected| contains at least one failure - * - * All code following this comment (including called functions) must - * handle these states. - */ - if (result === null || pos !== input.length) { - var errorPosition = computeErrorPosition(); - throw new this.SyntaxError( - buildErrorMessage(), - errorPosition.line, - errorPosition.column - ); - } - - return result; - }, - - /* Returns the parser source code. */ - toSource: function() { return this._source; } - }; - - /* Thrown when a parser encounters a syntax error. */ - - result.SyntaxError = function(message, line, column) { - this.name = 'SyntaxError'; - this.message = message; - this.line = line; - this.column = column; - }; - - result.SyntaxError.prototype = Error.prototype; - - return result; -})(); - -TurtleParser.parser.parse = function(data, graph) { - var quads = []; - - var result = TurtleParser.parser.innerParse(data); - var namespaces = {}; - var env = {namespaces: namespaces, base:'', blankCounter: 0}; - - statementCounter = 0; - - for(var i=0; i - * W3C's note - */ -AbstractQueryTree.AbstractQueryTree = function(params) { -}; - -AbstractQueryTree.AbstractQueryTree.prototype.parseQueryString = function(query_string) { - var syntaxTree = SparqlParser.parser.parse(query_string); - return syntaxTree; -}; - -AbstractQueryTree.AbstractQueryTree.prototype.parseExecutableUnit = function(executableUnit) { - if(executableUnit.kind === 'select') { - return this.parseSelect(executableUnit); - } else if(executableUnit.kind === 'ask') { - return this.parseSelect(executableUnit); - } else if(executableUnit.kind === 'modify') { - return this.parseSelect(executableUnit); - } else if(executableUnit.kind === 'construct') { - return this.parseSelect(executableUnit); - } else if(executableUnit.kind === 'insertdata') { - return this.parseInsertData(executableUnit); - } else if(executableUnit.kind === 'deletedata') { - return this.parseInsertData(executableUnit); - } else if(executableUnit.kind === 'load') { - return executableUnit; - } else if(executableUnit.kind === 'clear') { - return executableUnit; - } else if(executableUnit.kind === 'drop') { - return executableUnit; - } else if(executableUnit.kind === 'create') { - return executableUnit; - } else { - throw new Error('unknown executable unit: ' + executableUnit.kind); - } -}; - -AbstractQueryTree.AbstractQueryTree.prototype.parseSelect = function(syntaxTree){ - - if(syntaxTree == null) { - console.log("error parsing query"); - return null; - } else { - var env = {}; - syntaxTree.pattern = this.build(syntaxTree.pattern, env); - return syntaxTree; - } -}; - -AbstractQueryTree.AbstractQueryTree.prototype.parseInsertData = function(syntaxTree){ - if(syntaxTree == null) { - console.log("error parsing query"); - return null; - } else { - return syntaxTree; - } -}; - -AbstractQueryTree.AbstractQueryTree.prototype.build = function(node, env) { - if(node.token === 'groupgraphpattern') { - return this._buildGroupGraphPattern(node, env); - } else if (node.token === 'basicgraphpattern') { - return { kind: 'BGP', - value: node.triplesContext }; - } else if (node.token === 'graphunionpattern') { - var a = this.build(node.value[0],env); - var b = this.build(node.value[1],env); - - return { kind: 'UNION', - value: [a,b] }; - } else if(node.token === 'graphgraphpattern') { - var c = this.build(node.value, env); - return { kind: 'GRAPH', - value: c, - graph: node.graph }; - } else { - throw new Error("not supported token in query:"+node.token); - } -}; - -AbstractQueryTree.AbstractQueryTree.prototype._buildGroupGraphPattern = function(node, env) { - var f = (node.filters || []); - var g = {kind: "EMPTY_PATTERN"}; - - for(var i=0; i rightmostMatchFailuresPos) { - rightmostMatchFailuresPos = pos; - rightmostMatchFailuresExpected = []; - } - - rightmostMatchFailuresExpected.push(failure); - } - - function parse_SPARQL() { - var cacheKey = 'SPARQL@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - - var result2 = parse_Query(); - if (result2 !== null) { - var result0 = result2; - } else { - var result1 = parse_Update(); - if (result1 !== null) { - var result0 = result1; - } else { - var result0 = null;; - }; - } - - - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_Query() { - var cacheKey = 'Query@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var savedPos0 = pos; - var result2 = parse_Prologue(); - if (result2 !== null) { - var result7 = parse_SelectQuery(); - if (result7 !== null) { - var result3 = result7; - } else { - var result6 = parse_ConstructQuery(); - if (result6 !== null) { - var result3 = result6; - } else { - var result5 = parse_DescribeQuery(); - if (result5 !== null) { - var result3 = result5; - } else { - var result4 = parse_AskQuery(); - if (result4 !== null) { - var result3 = result4; - } else { - var result3 = null;; - }; - }; - }; - } - if (result3 !== null) { - var result1 = [result2, result3]; - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - var result0 = result1 !== null - ? (function(p, q) { - return {token: 'query', - kind: 'query', - prologue: p, - units: [q]}; - })(result1[0], result1[1]) - : null; - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("[2] Query"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_Prologue() { - var cacheKey = 'Prologue@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var savedPos0 = pos; - var result7 = parse_BaseDecl(); - var result2 = result7 !== null ? result7 : ''; - if (result2 !== null) { - var result3 = []; - var result6 = parse_WS(); - while (result6 !== null) { - result3.push(result6); - var result6 = parse_WS(); - } - if (result3 !== null) { - var result4 = []; - var result5 = parse_PrefixDecl(); - while (result5 !== null) { - result4.push(result5); - var result5 = parse_PrefixDecl(); - } - if (result4 !== null) { - var result1 = [result2, result3, result4]; - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - var result0 = result1 !== null - ? (function(b, pfx) { - return { token: 'prologue', - base: b, - prefixes: pfx } - })(result1[0], result1[2]) - : null; - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("[3] Prologue"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_BaseDecl() { - var cacheKey = 'BaseDecl@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var savedPos0 = pos; - var result2 = []; - var result18 = parse_WS(); - while (result18 !== null) { - result2.push(result18); - var result18 = parse_WS(); - } - if (result2 !== null) { - if (input.substr(pos, 1) === "B") { - var result17 = "B"; - pos += 1; - } else { - var result17 = null; - if (reportMatchFailures) { - matchFailed("\"B\""); - } - } - if (result17 !== null) { - var result3 = result17; - } else { - if (input.substr(pos, 1) === "b") { - var result16 = "b"; - pos += 1; - } else { - var result16 = null; - if (reportMatchFailures) { - matchFailed("\"b\""); - } - } - if (result16 !== null) { - var result3 = result16; - } else { - var result3 = null;; - }; - } - if (result3 !== null) { - if (input.substr(pos, 1) === "A") { - var result15 = "A"; - pos += 1; - } else { - var result15 = null; - if (reportMatchFailures) { - matchFailed("\"A\""); - } - } - if (result15 !== null) { - var result4 = result15; - } else { - if (input.substr(pos, 1) === "a") { - var result14 = "a"; - pos += 1; - } else { - var result14 = null; - if (reportMatchFailures) { - matchFailed("\"a\""); - } - } - if (result14 !== null) { - var result4 = result14; - } else { - var result4 = null;; - }; - } - if (result4 !== null) { - if (input.substr(pos, 1) === "S") { - var result13 = "S"; - pos += 1; - } else { - var result13 = null; - if (reportMatchFailures) { - matchFailed("\"S\""); - } - } - if (result13 !== null) { - var result5 = result13; - } else { - if (input.substr(pos, 1) === "s") { - var result12 = "s"; - pos += 1; - } else { - var result12 = null; - if (reportMatchFailures) { - matchFailed("\"s\""); - } - } - if (result12 !== null) { - var result5 = result12; - } else { - var result5 = null;; - }; - } - if (result5 !== null) { - if (input.substr(pos, 1) === "E") { - var result11 = "E"; - pos += 1; - } else { - var result11 = null; - if (reportMatchFailures) { - matchFailed("\"E\""); - } - } - if (result11 !== null) { - var result6 = result11; - } else { - if (input.substr(pos, 1) === "e") { - var result10 = "e"; - pos += 1; - } else { - var result10 = null; - if (reportMatchFailures) { - matchFailed("\"e\""); - } - } - if (result10 !== null) { - var result6 = result10; - } else { - var result6 = null;; - }; - } - if (result6 !== null) { - var result7 = []; - var result9 = parse_WS(); - while (result9 !== null) { - result7.push(result9); - var result9 = parse_WS(); - } - if (result7 !== null) { - var result8 = parse_IRI_REF(); - if (result8 !== null) { - var result1 = [result2, result3, result4, result5, result6, result7, result8]; - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - var result0 = result1 !== null - ? (function(i) { - registerDefaultPrefix(i); - - base = {}; - base.token = 'base'; - base.value = i; - - return base; - })(result1[6]) - : null; - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("[4] BaseDecl"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_PrefixDecl() { - var cacheKey = 'PrefixDecl@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var savedPos0 = pos; - var result2 = []; - var result27 = parse_WS(); - while (result27 !== null) { - result2.push(result27); - var result27 = parse_WS(); - } - if (result2 !== null) { - if (input.substr(pos, 1) === "P") { - var result26 = "P"; - pos += 1; - } else { - var result26 = null; - if (reportMatchFailures) { - matchFailed("\"P\""); - } - } - if (result26 !== null) { - var result3 = result26; - } else { - if (input.substr(pos, 1) === "p") { - var result25 = "p"; - pos += 1; - } else { - var result25 = null; - if (reportMatchFailures) { - matchFailed("\"p\""); - } - } - if (result25 !== null) { - var result3 = result25; - } else { - var result3 = null;; - }; - } - if (result3 !== null) { - if (input.substr(pos, 1) === "R") { - var result24 = "R"; - pos += 1; - } else { - var result24 = null; - if (reportMatchFailures) { - matchFailed("\"R\""); - } - } - if (result24 !== null) { - var result4 = result24; - } else { - if (input.substr(pos, 1) === "r") { - var result23 = "r"; - pos += 1; - } else { - var result23 = null; - if (reportMatchFailures) { - matchFailed("\"r\""); - } - } - if (result23 !== null) { - var result4 = result23; - } else { - var result4 = null;; - }; - } - if (result4 !== null) { - if (input.substr(pos, 1) === "E") { - var result22 = "E"; - pos += 1; - } else { - var result22 = null; - if (reportMatchFailures) { - matchFailed("\"E\""); - } - } - if (result22 !== null) { - var result5 = result22; - } else { - if (input.substr(pos, 1) === "e") { - var result21 = "e"; - pos += 1; - } else { - var result21 = null; - if (reportMatchFailures) { - matchFailed("\"e\""); - } - } - if (result21 !== null) { - var result5 = result21; - } else { - var result5 = null;; - }; - } - if (result5 !== null) { - if (input.substr(pos, 1) === "F") { - var result20 = "F"; - pos += 1; - } else { - var result20 = null; - if (reportMatchFailures) { - matchFailed("\"F\""); - } - } - if (result20 !== null) { - var result6 = result20; - } else { - if (input.substr(pos, 1) === "f") { - var result19 = "f"; - pos += 1; - } else { - var result19 = null; - if (reportMatchFailures) { - matchFailed("\"f\""); - } - } - if (result19 !== null) { - var result6 = result19; - } else { - var result6 = null;; - }; - } - if (result6 !== null) { - if (input.substr(pos, 1) === "I") { - var result18 = "I"; - pos += 1; - } else { - var result18 = null; - if (reportMatchFailures) { - matchFailed("\"I\""); - } - } - if (result18 !== null) { - var result7 = result18; - } else { - if (input.substr(pos, 1) === "i") { - var result17 = "i"; - pos += 1; - } else { - var result17 = null; - if (reportMatchFailures) { - matchFailed("\"i\""); - } - } - if (result17 !== null) { - var result7 = result17; - } else { - var result7 = null;; - }; - } - if (result7 !== null) { - if (input.substr(pos, 1) === "X") { - var result16 = "X"; - pos += 1; - } else { - var result16 = null; - if (reportMatchFailures) { - matchFailed("\"X\""); - } - } - if (result16 !== null) { - var result8 = result16; - } else { - if (input.substr(pos, 1) === "x") { - var result15 = "x"; - pos += 1; - } else { - var result15 = null; - if (reportMatchFailures) { - matchFailed("\"x\""); - } - } - if (result15 !== null) { - var result8 = result15; - } else { - var result8 = null;; - }; - } - if (result8 !== null) { - var result9 = []; - var result14 = parse_WS(); - while (result14 !== null) { - result9.push(result14); - var result14 = parse_WS(); - } - if (result9 !== null) { - var result10 = parse_PNAME_NS(); - if (result10 !== null) { - var result11 = []; - var result13 = parse_WS(); - while (result13 !== null) { - result11.push(result13); - var result13 = parse_WS(); - } - if (result11 !== null) { - var result12 = parse_IRI_REF(); - if (result12 !== null) { - var result1 = [result2, result3, result4, result5, result6, result7, result8, result9, result10, result11, result12]; - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - var result0 = result1 !== null - ? (function(p, l) { - - registerPrefix(p,l); - - prefix = {}; - prefix.token = 'prefix'; - prefix.prefix = p; - prefix.local = l; - - return prefix; - })(result1[8], result1[10]) - : null; - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("[5] PrefixDecl"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_SelectQuery() { - var cacheKey = 'SelectQuery@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var savedPos0 = pos; - var result2 = parse_SelectClause(); - if (result2 !== null) { - var result3 = []; - var result15 = parse_WS(); - while (result15 !== null) { - result3.push(result15); - var result15 = parse_WS(); - } - if (result3 !== null) { - var result4 = []; - var result14 = parse_DatasetClause(); - while (result14 !== null) { - result4.push(result14); - var result14 = parse_DatasetClause(); - } - if (result4 !== null) { - var result5 = []; - var result13 = parse_WS(); - while (result13 !== null) { - result5.push(result13); - var result13 = parse_WS(); - } - if (result5 !== null) { - var result6 = parse_WhereClause(); - if (result6 !== null) { - var result7 = []; - var result12 = parse_WS(); - while (result12 !== null) { - result7.push(result12); - var result12 = parse_WS(); - } - if (result7 !== null) { - var result8 = parse_SolutionModifier(); - if (result8 !== null) { - var result9 = []; - var result11 = parse_WS(); - while (result11 !== null) { - result9.push(result11); - var result11 = parse_WS(); - } - if (result9 !== null) { - var result10 = parse_BindingsClause(); - if (result10 !== null) { - var result1 = [result2, result3, result4, result5, result6, result7, result8, result9, result10]; - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - var result0 = result1 !== null - ? (function(s, gs, w, sm) { - - var dataset = {'named':[], 'default':[]}; - for(var i=0; i b. + */ +Processor.prototype.deepCompareBlankNodes = function(a, b) +{ + var rval = 0; + + // compare IRIs + var iriA = a['@id']; + var iriB = b['@id']; + if(iriA === iriB) + { + rval = 0; + } + else + { + // do shallow compare first + rval = this.shallowCompareBlankNodes(a, b); + + // deep comparison is necessary + if(rval === 0) + { + // compare property edges and then reference edges + var dirs = ['props', 'refs']; + for(var i = 0; rval === 0 && i < dirs.length; ++i) + { + // recompute 'a' and 'b' serializations as necessary + var dir = dirs[i]; + var sA = this.serializations[iriA]; + var sB = this.serializations[iriB]; + if(sA[dir] === null) + { + var mb = new MappingBuilder(); + if(dir === 'refs') + { + // keep same mapping and count from 'props' serialization + mb.mapping = _clone(sA['props'].m); + mb.count = Object.keys(mb.mapping).length + 1; + } + this.serializeBlankNode(sA, iriA, mb, dir); + } + if(sB[dir] === null) + { + var mb = new MappingBuilder(); + if(dir === 'refs') + { + // keep same mapping and count from 'props' serialization + mb.mapping = _clone(sB['props'].m); + mb.count = Object.keys(mb.mapping).length + 1; + } + this.serializeBlankNode(sB, iriB, mb, dir); + } + + // compare serializations + rval = _compare(sA[dir].s, sB[dir].s); + } + } + } + + return rval; +}; + +/** + * Performs a shallow sort comparison on the given bnodes. + * + * @param a the first bnode. + * @param b the second bnode. + * + * @return -1 if a < b, 0 if a == b, 1 if a > b. + */ +Processor.prototype.shallowCompareBlankNodes = function(a, b) +{ + var rval = 0; + + /* ShallowSort Algorithm (when comparing two bnodes): + 1. Compare the number of properties. + 1.1. The bnode with fewer properties is first. + 2. Compare alphabetically sorted-properties. + 2.1. The bnode with the alphabetically-first property is first. + 3. For each property, compare object values. + 4. Compare the number of references. + 4.1. The bnode with fewer references is first. + 5. Compare sorted references. + 5.1. The bnode with the reference iri (vs. bnode) is first. + 5.2. The bnode with the alphabetically-first reference iri is first. + 5.3. The bnode with the alphabetically-first reference property is first. + */ + var pA = Object.keys(a); + var pB = Object.keys(b); + + // step #1 + rval = _compare(pA.length, pB.length); + + // step #2 + if(rval === 0) + { + rval = _compare(pA.sort(), pB.sort()); + } + + // step #3 + if(rval === 0) + { + rval = _compareBlankNodeObjects(a, b); + } + + // step #4 + if(rval === 0) + { + var edgesA = this.edges.refs[a['@id']].all; + var edgesB = this.edges.refs[b['@id']].all; + rval = _compare(edgesA.length, edgesB.length); + } + + // step #5 + if(rval === 0) + { + for(var i = 0; i < edgesA.length && rval === 0; ++i) + { + rval = this.compareEdges(edgesA[i], edgesB[i]); + } + } + + return rval; +}; + +/** + * Compares two edges. Edges with an IRI (vs. a bnode ID) come first, then + * alphabetically-first IRIs, then alphabetically-first properties. If a blank + * node has been canonically named, then blank nodes will be compared after + * properties (with a preference for canonically named over non-canonically + * named), otherwise they won't be. + * + * @param a the first edge. + * @param b the second edge. + * + * @return -1 if a < b, 0 if a == b, 1 if a > b. + */ +Processor.prototype.compareEdges = function(a, b) +{ + var rval = 0; + + var bnodeA = _isBlankNodeIri(a.s); + var bnodeB = _isBlankNodeIri(b.s); + var c14n = this.ng.c14n; + + // if not both bnodes, one that is a bnode is greater + if(bnodeA != bnodeB) + { + rval = bnodeA ? 1 : -1; + } + else + { + if(!bnodeA) + { + rval = _compare(a.s, b.s); + } + if(rval === 0) + { + rval = _compare(a.p, b.p); + } + + // do bnode IRI comparison if canonical naming has begun + if(rval === 0 && c14n !== null) + { + var c14nA = c14n.inNamespace(a.s); + var c14nB = c14n.inNamespace(b.s); + if(c14nA != c14nB) + { + rval = c14nA ? 1 : -1; + } + else if(c14nA) + { + rval = _compare(a.s, b.s); + } + } + } + + return rval; +}; + +/** + * Populates the given reference map with all of the subject edges in the + * graph. The references will be categorized by the direction of the edges, + * where 'props' is for properties and 'refs' is for references to a subject as + * an object. The edge direction categories for each IRI will be sorted into + * groups 'all' and 'bnodes'. + */ +Processor.prototype.collectEdges = function() +{ + var refs = this.edges.refs; + var props = this.edges.props; + + // collect all references and properties + for(var iri in this.subjects) + { + var subject = this.subjects[iri]; + for(var key in subject) + { + if(key !== '@id') + { + // normalize to array for single codepath + var object = subject[key]; + var tmp = (object.constructor !== Array) ? [object] : object; + for(var i in tmp) + { + var o = tmp[i]; + if(o.constructor === Object && '@id' in o && + o['@id'] in this.subjects) + { + var objIri = o['@id']; + + // map object to this subject + refs[objIri].all.push({ s: iri, p: key }); + + // map this subject to object + props[iri].all.push({ s: objIri, p: key }); + } + } + } + } + } + + // create sorted categories + var self = this; + for(var iri in refs) + { + refs[iri].all.sort(function(a, b) { return self.compareEdges(a, b); }); + refs[iri].bnodes = refs[iri].all.filter(function(edge) { + return _isBlankNodeIri(edge.s); + }); + } + for(var iri in props) + { + props[iri].all.sort(function(a, b) { return self.compareEdges(a, b); }); + props[iri].bnodes = props[iri].all.filter(function(edge) { + return _isBlankNodeIri(edge.s); + }); + } +}; + +/** + * Returns true if the given input is a subject and has one of the given types + * in the given frame. + * + * @param input the input. + * @param frame the frame with types to look for. + * + * @return true if the input has one of the given types. + */ +var _isType = function(input, frame) +{ + var rval = false; + + // check if type(s) are specified in frame and input + var type = '@type'; + if('@type' in frame && + input.constructor === Object && type in input) + { + var tmp = (input[type].constructor === Array) ? + input[type] : [input[type]]; + var types = (frame[type].constructor === Array) ? + frame[type] : [frame[type]]; + for(var t = 0; t < types.length && !rval; ++t) + { + type = types[t]; + for(var i in tmp) + { + if(tmp[i] === type) + { + rval = true; + break; + } + } + } + } + + return rval; +}; + +/** + * Returns true if the given input matches the given frame via duck-typing. + * + * @param input the input. + * @param frame the frame to check against. + * + * @return true if the input matches the frame. + */ +var _isDuckType = function(input, frame) +{ + var rval = false; + + // frame must not have a specific type + var type = '@type'; + if(!(type in frame)) + { + // get frame properties that must exist on input + var props = Object.keys(frame).filter(function(e) + { + // filter non-keywords + return e.indexOf('@') !== 0; + }); + if(props.length === 0) + { + // input always matches if there are no properties + rval = true; + } + // input must be a subject with all the given properties + else if(input.constructor === Object && '@id' in input) + { + rval = true; + for(var i in props) + { + if(!(props[i] in input)) + { + rval = false; + break; + } + } + } + } + + return rval; +}; + +/** + * Subframes a value. + * + * @param subjects a map of subjects in the graph. + * @param value the value to subframe. + * @param frame the frame to use. + * @param embeds a map of previously embedded subjects, used to prevent cycles. + * @param autoembed true if auto-embed is on, false if not. + * @param parent the parent object. + * @param parentKey the parent key. + * @param options the framing options. + * + * @return the framed input. + */ +var _subframe = function( + subjects, value, frame, embeds, autoembed, parent, parentKey, options) +{ + // get existing embed entry + var iri = value['@id']; + var embed = (iri in embeds) ? embeds[iri] : null; + + // determine if value should be embedded or referenced, + // embed is ON if: + // 1. The frame OR default option specifies @embed as ON, AND + // 2. There is no existing embed OR it is an autoembed, AND + // autoembed mode is off. + var embedOn = ( + (('@embed' in frame && frame['@embed']) || + (!('@embed' in frame) && options.defaults.embedOn)) && + (embed === null || (embed.autoembed && !autoembed))); + + if(!embedOn) + { + // not embedding, so only use subject IRI as reference + value = {'@id': value['@id']}; + } + else + { + // create new embed entry + if(embed === null) + { + embed = {}; + embeds[iri] = embed; + } + // replace the existing embed with a reference + else if(embed.parent !== null) + { + if(embed.parent[embed.key].constructor === Array) + { + // find and replace embed in array + var objs = embed.parent[embed.key]; + for(var i in objs) + { + if(objs[i].constructor === Object && '@id' in objs[i] && + objs[i]['@id'] === iri) + { + objs[i] = {'@id': value['@id']}; + break; + } + } + } + else + { + embed.parent[embed.key] = {'@id': value['@id']}; + } + + // recursively remove any dependent dangling embeds + var removeDependents = function(iri) + { + var iris = Object.keys(embeds); + for(var i in iris) + { + i = iris[i]; + if(i in embeds && embeds[i].parent !== null && + embeds[i].parent['@id'] === iri) + { + delete embeds[i]; + removeDependents(i); + } + } + }; + removeDependents(iri); + } + + // update embed entry + embed.autoembed = autoembed; + embed.parent = parent; + embed.key = parentKey; + + // check explicit flag + var explicitOn = ( + frame['@explicit'] === true || options.defaults.explicitOn); + if(explicitOn) + { + // remove keys from the value that aren't in the frame + for(key in value) + { + // do not remove @id or any frame key + if(key !== '@id' && !(key in frame)) + { + delete value[key]; + } + } + } + + // iterate over keys in value + var keys = Object.keys(value); + for(i in keys) + { + // skip keywords + var key = keys[i]; + if(key.indexOf('@') !== 0) + { + // get the subframe if available + if(key in frame) + { + var f = frame[key]; + var _autoembed = false; + } + // use a catch-all subframe to preserve data from graph + else + { + var f = (value[key].constructor === Array) ? [] : {}; + var _autoembed = true; + } + + // build input and do recursion + var v = value[key]; + var input = (v.constructor === Array) ? v : [v]; + for(var n in input) + { + // replace reference to subject w/embedded subject + if(input[n].constructor === Object && + '@id' in input[n] && + input[n]['@id'] in subjects) + { + input[n] = subjects[input[n]['@id']]; + } + } + value[key] = _frame( + subjects, input, f, embeds, _autoembed, value, key, options); + } + } + + // iterate over frame keys to add any missing values + for(key in frame) + { + // skip keywords and non-null keys in value + if(key.indexOf('@') !== 0 && (!(key in value) || value[key] === null)) + { + var f = frame[key]; + + // add empty array to value + if(f.constructor === Array) + { + value[key] = []; + } + // add default value to value + else + { + // use first subframe if frame is an array + if(f.constructor === Array) + { + f = (f.length > 0) ? f[0] : {}; + } + + // determine if omit default is on + var omitOn = ( + f['@omitDefault'] === true || options.defaults.omitDefaultOn); + if(!omitOn) + { + if('@default' in f) + { + // use specified default value + value[key] = f['@default']; + } + else + { + // built-in default value is: null + value[key] = null; + } + } + } + } + } + } + + return value; +}; + +/** + * Recursively frames the given input according to the given frame. + * + * @param subjects a map of subjects in the graph. + * @param input the input to frame. + * @param frame the frame to use. + * @param embeds a map of previously embedded subjects, used to prevent cycles. + * @param autoembed true if auto-embed is on, false if not. + * @param parent the parent object (for subframing), null for none. + * @param parentKey the parent key (for subframing), null for none. + * @param options the framing options. + * + * @return the framed input. + */ +var _frame = function( + subjects, input, frame, embeds, autoembed, parent, parentKey, options) +{ + var rval = null; + + // prepare output, set limit, get array of frames + var limit = -1; + var frames; + if(frame.constructor === Array) + { + rval = []; + frames = frame; + if(frames.length === 0) + { + frames.push({}); + } + } + else + { + frames = [frame]; + limit = 1; + } + + // iterate over frames adding input matches to list + var values = []; + for(var i = 0; i < frames.length && limit !== 0; ++i) + { + // get next frame + frame = frames[i]; + if(frame.constructor !== Object) + { + throw { + message: 'Invalid JSON-LD frame. ' + + 'Frame must be an object or an array.', + frame: frame + }; + } + + // create array of values for each frame + values[i] = []; + for(var n = 0; n < input.length && limit !== 0; ++n) + { + // add input to list if it matches frame specific type or duck-type + var next = input[n]; + if(_isType(next, frame) || _isDuckType(next, frame)) + { + values[i].push(next); + --limit; + } + } + } + + // for each matching value, add it to the output + for(var i1 in values) + { + for(var i2 in values[i1]) + { + frame = frames[i1]; + var value = values[i1][i2]; + + // if value is a subject, do subframing + if(_isSubject(value)) + { + value = _subframe( + subjects, value, frame, embeds, autoembed, + parent, parentKey, options); + } + + // add value to output + if(rval === null) + { + rval = value; + } + else + { + // determine if value is a reference to an embed + var isRef = (_isReference(value) && value['@id'] in embeds); + + // push any value that isn't a parentless reference + if(!(parent === null && isRef)) + { + rval.push(value); + } + } + } + } + + return rval; +}; + +/** + * Frames JSON-LD input. + * + * @param input the JSON-LD input. + * @param frame the frame to use. + * @param options framing options to use. + * + * @return the framed output. + */ +Processor.prototype.frame = function(input, frame, options) +{ + var rval; + + // normalize input + input = jsonld.normalize(input); + + // save frame context + var ctx = null; + if('@context' in frame) + { + ctx = _clone(frame['@context']); + + // remove context from frame + frame = jsonld.expand(frame); + } + else if(frame.constructor === Array) + { + // save first context in the array + if(frame.length > 0 && '@context' in frame[0]) + { + ctx = _clone(frame[0]['@context']); + } + + // expand all elements in the array + var tmp = []; + for(var i in frame) + { + tmp.push(jsonld.expand(frame[i])); + } + frame = tmp; + } + + // create framing options + // TODO: merge in options from function parameter + options = + { + defaults: + { + embedOn: true, + explicitOn: false, + omitDefaultOn: false + } + }; + + // build map of all subjects + var subjects = {}; + for(var i in input) + { + subjects[input[i]['@id']] = input[i]; + } + + // frame input + rval = _frame(subjects, input, frame, {}, false, null, null, options); + + // apply context + if(ctx !== null && rval !== null) + { + rval = jsonld.compact(ctx, rval); + } + + return rval; +}; + +})(); + + +// exports +var JSONLDParser = {}; + +JSONLDParser.parser = {}; +JSONLDParser.parser.parse = function(data, graph) { + if(typeof(data) === 'string') { + data = JSON.parse(data); + } + return jsonldParser.toTriples(data, graph); +}; + + +// end of ./src/js-communication/src/jsonld_parser.js +// exports +var RDFLoader = {}; + +// imports + +RDFLoader.RDFLoader = function(params) { + this.precedences = ["text/turtle", "text/n3", "application/json"]; + this.parsers = {"text/turtle": TurtleParser.parser, "text/n3":TurtleParser.parser, "application/json":JSONLDParser.parser}; + if(params != null) { + for(var mime in params["parsers"]) { + this.parsers[mime] = params["parsers"][mime]; + } + } + + if(params && params["precedences"] != null) { + this.precedences = params["precedences"]; + for(var mime in params["parsers"]) { + if(!Utils.include(this.precedences, mime)) { + this.precedences.push(mime); + } + } + } + + this.acceptHeaderValue = ""; + for(var i=0; i + * W3C's note + */ +AbstractQueryTree.AbstractQueryTree = function(params) { +}; + +AbstractQueryTree.AbstractQueryTree.prototype.parseQueryString = function(query_string) { + var syntaxTree = SparqlParser.parser.parse(query_string); + return syntaxTree; +}; + +AbstractQueryTree.AbstractQueryTree.prototype.parseExecutableUnit = function(executableUnit) { + if(executableUnit.kind === 'select') { + return this.parseSelect(executableUnit); + } else if(executableUnit.kind === 'ask') { + return this.parseSelect(executableUnit); + } else if(executableUnit.kind === 'modify') { + return this.parseSelect(executableUnit); + } else if(executableUnit.kind === 'construct') { + return this.parseSelect(executableUnit); + } else if(executableUnit.kind === 'insertdata') { + return this.parseInsertData(executableUnit); + } else if(executableUnit.kind === 'deletedata') { + return this.parseInsertData(executableUnit); + } else if(executableUnit.kind === 'load') { + return executableUnit; + } else if(executableUnit.kind === 'clear') { + return executableUnit; + } else if(executableUnit.kind === 'drop') { + return executableUnit; + } else if(executableUnit.kind === 'create') { + return executableUnit; + } else { + throw new Error('unknown executable unit: ' + executableUnit.kind); + } +}; + +AbstractQueryTree.AbstractQueryTree.prototype.parseSelect = function(syntaxTree){ + + if(syntaxTree == null) { + console.log("error parsing query"); + return null; + } else { + var env = { freshCounter: 0 }; + syntaxTree.pattern = this.build(syntaxTree.pattern, env); + return syntaxTree; + } +}; + +AbstractQueryTree.AbstractQueryTree.prototype.parseInsertData = function(syntaxTree){ + if(syntaxTree == null) { + console.log("error parsing query"); + return null; + } else { + return syntaxTree; + } +}; + +AbstractQueryTree.AbstractQueryTree.prototype.build = function(node, env) { + if(node.token === 'groupgraphpattern') { + return this._buildGroupGraphPattern(node, env); + } else if (node.token === 'basicgraphpattern') { + var bgp = { kind: 'BGP', + value: node.triplesContext }; + //console.log("pre1"); + bgp = AbstractQueryTree.translatePathExpressionsInBGP(bgp, env); + //console.log("translation"); + //console.log(sys.inspect(bgp,true,20)); + return bgp; + } else if (node.token === 'graphunionpattern') { + var a = this.build(node.value[0],env); + var b = this.build(node.value[1],env); + + return { kind: 'UNION', + value: [a,b] }; + } else if(node.token === 'graphgraphpattern') { + var c = this.build(node.value, env); + return { kind: 'GRAPH', + value: c, + graph: node.graph }; + } else { + throw new Error("not supported token in query:"+node.token); + } +}; + +AbstractQueryTree.translatePathExpressionsInBGP = function(bgp, env) { + var pathExpression,nextTriple,beforeToLink; + var before = [], rest, bottomJoin; + for(var i=0; i 0) { + bottomJoin = {kind: 'JOIN', + lvalue: {kind: 'BGP', value:before}, + rvalue: bgpTransformed}; + } else { + bottomJoin = bgpTransformed; + } + + + if(bgpTransformed.kind === 'ZERO_OR_MORE_PATH') { + if(bgpTransformed.y.token === 'var' && bgpTransformed.y.value.indexOf("fresh:")===0 && + bgpTransformed.x.token === 'var' && bgpTransformed.x.value.indexOf("fresh:")===0) { + //console.log("ADDING EXTRA PATTERN 1)"); + for(var j=0; j0) { + //console.log("(2a)") + var rvalueJoin = AbstractQueryTree.translatePathExpressionsInBGP({kind: 'BGP', value: rest}, env); + //console.log("got rvalue"); + if(optionalPattern != null) { + var optionals = before.concat([optionalPattern]).concat(rest); + return { kind: 'UNION', + value: [{ kind: 'JOIN', + lvalue: bottomJoin, + rvalue: rvalueJoin }, + {kind: 'BGP', + value: optionals}] }; + } else { + return { kind: 'JOIN', + lvalue: bottomJoin, + rvalue: rvalueJoin }; + } + } else { + //console.log("(2b)") + return bottomJoin; + } + + } else { + // @todo ???? + return bgpTransformed; + } + } else { + before.push(bgp.value[i]); + } + } + + //console.log("returning"); + bgp.value = before; + return bgp; +}; + + +AbstractQueryTree.translatePathExpression = function(pathExpression, env) { + // add support for different path patterns + if(pathExpression.predicate.kind === 'element') { + // simple paths, maybe modified + if(pathExpression.predicate.modifier === '+') { + pathExpression.predicate.modifier = null; + var expandedPath = AbstractQueryTree.translatePathExpression(pathExpression, env); + return {kind: 'ONE_OR_MORE_PATH', + path: expandedPath, + x: pathExpression.subject, + y: pathExpression.object}; + } else if(pathExpression.predicate.modifier === '*') { + pathExpression.predicate.modifier = null; + var expandedPath = AbstractQueryTree.translatePathExpression(pathExpression, env); + return {kind: 'ZERO_OR_MORE_PATH', + path: expandedPath, + x: pathExpression.subject, + y: pathExpression.object}; + } else { + pathExpression.predicate = pathExpression.predicate.value; + return {kind: 'BGP', value: [pathExpression]}; + } + } else if(pathExpression.predicate.kind === 'sequence') { + var currentSubject = pathExpression.subject; + var lastObject = pathExpression.object; + var currentGraph = pathExpression.graph; + var nextObject, chain; + var restTriples = []; + for(var i=0; i< pathExpression.predicate.value.length; i++) { + if(i!=pathExpression.predicate.value.length-1) { + nextObject = { + token: "var", + value: "fresh:"+env.freshCounter + }; + env.freshCounter++; + } else { + nextObject = lastObject; + } + + // @todo + // what if the predicate is a path with + // '*'? same fresh va in subject and object?? + chain = { + subject: currentSubject, + predicate: pathExpression.predicate.value[i], + object: nextObject + }; + + if(currentGraph != null) + chain.graph = Utils.clone(currentGraph); + + restTriples.push(chain); + + if(i!=pathExpression.predicate.value.length-1) + currentSubject = Utils.clone(nextObject);; + } + var bgp = {kind: 'BGP', value: restTriples}; + //console.log("BEFORE (1):"); + //console.log(bgp); + //console.log("--------------"); + return AbstractQueryTree.translatePathExpressionsInBGP(bgp, env); + } +}; + +AbstractQueryTree.AbstractQueryTree.prototype._buildGroupGraphPattern = function(node, env) { + var f = (node.filters || []); + var g = {kind: "EMPTY_PATTERN"}; + + for(var i=0; i rightmostMatchFailuresPos) { + rightmostMatchFailuresPos = pos; + rightmostMatchFailuresExpected = []; + } + + rightmostMatchFailuresExpected.push(failure); } - function parse_DescribeQuery() { - var cacheKey = 'DescribeQuery@' + pos; + function parse_DOCUMENT() { + var cacheKey = 'DOCUMENT@' + pos; var cachedResult = cache[cacheKey]; if (cachedResult) { pos = cachedResult.nextPos; return cachedResult.result; } - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var savedPos0 = pos; - if (input.substr(pos, 8) === "DESCRIBE") { - var result1 = "DESCRIBE"; - pos += 8; + + var result2 = parse_SPARQL(); + if (result2 !== null) { + var result0 = result2; } else { - var result1 = null; - if (reportMatchFailures) { - matchFailed("\"DESCRIBE\""); - } - } - if (result1 !== null) { - var result10 = parse_VarOrIRIref(); - if (result10 !== null) { - var result9 = []; - while (result10 !== null) { - result9.push(result10); - var result10 = parse_VarOrIRIref(); - } - } else { - var result9 = null; - } - if (result9 !== null) { - var result2 = result9; - } else { - if (input.substr(pos, 1) === "*") { - var result8 = "*"; - pos += 1; - } else { - var result8 = null; - if (reportMatchFailures) { - matchFailed("\"*\""); - } - } - if (result8 !== null) { - var result2 = result8; - } else { - var result2 = null;; - }; - } - if (result2 !== null) { - var result3 = []; - var result7 = parse_DatasetClause(); - while (result7 !== null) { - result3.push(result7); - var result7 = parse_DatasetClause(); - } - if (result3 !== null) { - var result6 = parse_WhereClause(); - var result4 = result6 !== null ? result6 : ''; - if (result4 !== null) { - var result5 = parse_SolutionModifier(); - if (result5 !== null) { - var result0 = [result1, result2, result3, result4, result5]; - } else { - var result0 = null; - pos = savedPos0; - } - } else { - var result0 = null; - pos = savedPos0; - } - } else { - var result0 = null; - pos = savedPos0; - } + var result1 = parse_TURTLE(); + if (result1 !== null) { + var result0 = result1; } else { - var result0 = null; - pos = savedPos0; - } - } else { - var result0 = null; - pos = savedPos0; - } - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("[10] DescribeQuery"); + var result0 = null;; + }; } + + cache[cacheKey] = { nextPos: pos, result: result0 @@ -11651,196 +6160,98 @@ SparqlParser.parser = (function(){ return result0; } - function parse_AskQuery() { - var cacheKey = 'AskQuery@' + pos; + function parse_SPARQL() { + var cacheKey = 'SPARQL@' + pos; var cachedResult = cache[cacheKey]; if (cachedResult) { pos = cachedResult.nextPos; return cachedResult.result; } - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var savedPos0 = pos; - var result2 = []; - var result19 = parse_WS(); - while (result19 !== null) { - result2.push(result19); - var result19 = parse_WS(); - } + + var result2 = parse_Query(); if (result2 !== null) { - if (input.substr(pos, 1) === "A") { - var result18 = "A"; - pos += 1; - } else { - var result18 = null; - if (reportMatchFailures) { - matchFailed("\"A\""); - } - } - if (result18 !== null) { - var result3 = result18; + var result0 = result2; + } else { + var result1 = parse_Update(); + if (result1 !== null) { + var result0 = result1; } else { - if (input.substr(pos, 1) === "a") { - var result17 = "a"; - pos += 1; - } else { - var result17 = null; - if (reportMatchFailures) { - matchFailed("\"a\""); - } - } - if (result17 !== null) { - var result3 = result17; - } else { - var result3 = null;; - }; - } - if (result3 !== null) { - if (input.substr(pos, 1) === "S") { - var result16 = "S"; - pos += 1; - } else { - var result16 = null; - if (reportMatchFailures) { - matchFailed("\"S\""); - } - } - if (result16 !== null) { - var result4 = result16; + var result0 = null;; + }; + } + + + + cache[cacheKey] = { + nextPos: pos, + result: result0 + }; + return result0; + } + + function parse_Query() { + var cacheKey = 'Query@' + pos; + var cachedResult = cache[cacheKey]; + if (cachedResult) { + pos = cachedResult.nextPos; + return cachedResult.result; + } + + var savedReportMatchFailures = reportMatchFailures; + reportMatchFailures = false; + var savedPos0 = pos; + var savedPos1 = pos; + var result3 = parse_Prologue(); + if (result3 !== null) { + var result8 = parse_SelectQuery(); + if (result8 !== null) { + var result4 = result8; + } else { + var result7 = parse_ConstructQuery(); + if (result7 !== null) { + var result4 = result7; } else { - if (input.substr(pos, 1) === "s") { - var result15 = "s"; - pos += 1; - } else { - var result15 = null; - if (reportMatchFailures) { - matchFailed("\"s\""); - } - } - if (result15 !== null) { - var result4 = result15; - } else { - var result4 = null;; - }; - } - if (result4 !== null) { - if (input.substr(pos, 1) === "K") { - var result14 = "K"; - pos += 1; - } else { - var result14 = null; - if (reportMatchFailures) { - matchFailed("\"K\""); - } - } - if (result14 !== null) { - var result5 = result14; + var result6 = parse_DescribeQuery(); + if (result6 !== null) { + var result4 = result6; } else { - if (input.substr(pos, 1) === "k") { - var result13 = "k"; - pos += 1; - } else { - var result13 = null; - if (reportMatchFailures) { - matchFailed("\"k\""); - } - } - if (result13 !== null) { - var result5 = result13; + var result5 = parse_AskQuery(); + if (result5 !== null) { + var result4 = result5; } else { - var result5 = null;; + var result4 = null;; }; - } - if (result5 !== null) { - var result6 = []; - var result12 = parse_WS(); - while (result12 !== null) { - result6.push(result12); - var result12 = parse_WS(); - } - if (result6 !== null) { - var result7 = []; - var result11 = parse_DatasetClause(); - while (result11 !== null) { - result7.push(result11); - var result11 = parse_DatasetClause(); - } - if (result7 !== null) { - var result8 = []; - var result10 = parse_WS(); - while (result10 !== null) { - result8.push(result10); - var result10 = parse_WS(); - } - if (result8 !== null) { - var result9 = parse_WhereClause(); - if (result9 !== null) { - var result1 = [result2, result3, result4, result5, result6, result7, result8, result9]; - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } + }; + }; + } + if (result4 !== null) { + var result1 = [result3, result4]; } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } - var result0 = result1 !== null - ? (function(gs, w) { - var dataset = {'named':[], 'default':[]}; - for(var i=0; i") { - var result21 = ">"; + var result22 = ">"; pos += 1; } else { - var result21 = null; + var result22 = null; if (reportMatchFailures) { matchFailed("\">\""); } } - if (result21 !== null) { - var result22 = []; - var result24 = parse_WS(); - while (result24 !== null) { - result22.push(result24); - var result24 = parse_WS(); + if (result22 !== null) { + var result23 = []; + var result25 = parse_WS(); + while (result25 !== null) { + result23.push(result25); + var result25 = parse_WS(); } - if (result22 !== null) { - var result23 = parse_AdditiveExpression(); - if (result23 !== null) { - var result19 = [result20, result21, result22, result23]; + if (result23 !== null) { + var result24 = parse_AdditiveExpression(); + if (result24 !== null) { + var result20 = [result21, result22, result23, result24]; } else { - var result19 = null; - pos = savedPos3; + var result20 = null; + pos = savedPos4; } } else { - var result19 = null; - pos = savedPos3; + var result20 = null; + pos = savedPos4; } } else { - var result19 = null; - pos = savedPos3; + var result20 = null; + pos = savedPos4; } } else { - var result19 = null; - pos = savedPos3; + var result20 = null; + pos = savedPos4; } - if (result19 !== null) { - var result4 = result19; + if (result20 !== null) { + var result5 = result20; } else { - var savedPos2 = pos; - var result13 = []; - var result18 = parse_WS(); - while (result18 !== null) { - result13.push(result18); - var result18 = parse_WS(); + var savedPos3 = pos; + var result14 = []; + var result19 = parse_WS(); + while (result19 !== null) { + result14.push(result19); + var result19 = parse_WS(); } - if (result13 !== null) { + if (result14 !== null) { if (input.substr(pos, 2) === "<=") { - var result14 = "<="; + var result15 = "<="; pos += 2; } else { - var result14 = null; + var result15 = null; if (reportMatchFailures) { matchFailed("\"<=\""); } } - if (result14 !== null) { - var result15 = []; - var result17 = parse_WS(); - while (result17 !== null) { - result15.push(result17); - var result17 = parse_WS(); + if (result15 !== null) { + var result16 = []; + var result18 = parse_WS(); + while (result18 !== null) { + result16.push(result18); + var result18 = parse_WS(); } - if (result15 !== null) { - var result16 = parse_AdditiveExpression(); - if (result16 !== null) { - var result12 = [result13, result14, result15, result16]; + if (result16 !== null) { + var result17 = parse_AdditiveExpression(); + if (result17 !== null) { + var result13 = [result14, result15, result16, result17]; } else { - var result12 = null; - pos = savedPos2; + var result13 = null; + pos = savedPos3; } } else { - var result12 = null; - pos = savedPos2; + var result13 = null; + pos = savedPos3; } - } else { - var result12 = null; - pos = savedPos2; + } else { + var result13 = null; + pos = savedPos3; } } else { - var result12 = null; - pos = savedPos2; + var result13 = null; + pos = savedPos3; } - if (result12 !== null) { - var result4 = result12; + if (result13 !== null) { + var result5 = result13; } else { - var savedPos1 = pos; - var result6 = []; - var result11 = parse_WS(); - while (result11 !== null) { - result6.push(result11); - var result11 = parse_WS(); + var savedPos2 = pos; + var result7 = []; + var result12 = parse_WS(); + while (result12 !== null) { + result7.push(result12); + var result12 = parse_WS(); } - if (result6 !== null) { + if (result7 !== null) { if (input.substr(pos, 2) === ">=") { - var result7 = ">="; + var result8 = ">="; pos += 2; } else { - var result7 = null; + var result8 = null; if (reportMatchFailures) { matchFailed("\">=\""); } } - if (result7 !== null) { - var result8 = []; - var result10 = parse_WS(); - while (result10 !== null) { - result8.push(result10); - var result10 = parse_WS(); + if (result8 !== null) { + var result9 = []; + var result11 = parse_WS(); + while (result11 !== null) { + result9.push(result11); + var result11 = parse_WS(); } - if (result8 !== null) { - var result9 = parse_AdditiveExpression(); - if (result9 !== null) { - var result5 = [result6, result7, result8, result9]; + if (result9 !== null) { + var result10 = parse_AdditiveExpression(); + if (result10 !== null) { + var result6 = [result7, result8, result9, result10]; } else { - var result5 = null; - pos = savedPos1; + var result6 = null; + pos = savedPos2; } } else { - var result5 = null; - pos = savedPos1; + var result6 = null; + pos = savedPos2; } } else { - var result5 = null; - pos = savedPos1; + var result6 = null; + pos = savedPos2; } } else { - var result5 = null; - pos = savedPos1; + var result6 = null; + pos = savedPos2; } - if (result5 !== null) { - var result4 = result5; + if (result6 !== null) { + var result5 = result6; } else { - var result4 = null;; + var result5 = null;; }; }; }; }; }; } - while (result4 !== null) { - result3.push(result4); - var savedPos6 = pos; - var result41 = []; - var result46 = parse_WS(); - while (result46 !== null) { - result41.push(result46); - var result46 = parse_WS(); + while (result5 !== null) { + result4.push(result5); + var savedPos7 = pos; + var result42 = []; + var result47 = parse_WS(); + while (result47 !== null) { + result42.push(result47); + var result47 = parse_WS(); } - if (result41 !== null) { + if (result42 !== null) { if (input.substr(pos, 1) === "=") { - var result42 = "="; + var result43 = "="; pos += 1; } else { - var result42 = null; + var result43 = null; if (reportMatchFailures) { matchFailed("\"=\""); } } - if (result42 !== null) { - var result43 = []; - var result45 = parse_WS(); - while (result45 !== null) { - result43.push(result45); - var result45 = parse_WS(); + if (result43 !== null) { + var result44 = []; + var result46 = parse_WS(); + while (result46 !== null) { + result44.push(result46); + var result46 = parse_WS(); } - if (result43 !== null) { - var result44 = parse_AdditiveExpression(); - if (result44 !== null) { - var result40 = [result41, result42, result43, result44]; + if (result44 !== null) { + var result45 = parse_AdditiveExpression(); + if (result45 !== null) { + var result41 = [result42, result43, result44, result45]; } else { - var result40 = null; - pos = savedPos6; + var result41 = null; + pos = savedPos7; } } else { - var result40 = null; - pos = savedPos6; + var result41 = null; + pos = savedPos7; } } else { - var result40 = null; - pos = savedPos6; + var result41 = null; + pos = savedPos7; } } else { - var result40 = null; - pos = savedPos6; + var result41 = null; + pos = savedPos7; } - if (result40 !== null) { - var result4 = result40; + if (result41 !== null) { + var result5 = result41; } else { - var savedPos5 = pos; - var result34 = []; - var result39 = parse_WS(); - while (result39 !== null) { - result34.push(result39); - var result39 = parse_WS(); + var savedPos6 = pos; + var result35 = []; + var result40 = parse_WS(); + while (result40 !== null) { + result35.push(result40); + var result40 = parse_WS(); } - if (result34 !== null) { + if (result35 !== null) { if (input.substr(pos, 2) === "!=") { - var result35 = "!="; + var result36 = "!="; pos += 2; } else { - var result35 = null; + var result36 = null; if (reportMatchFailures) { matchFailed("\"!=\""); } } - if (result35 !== null) { - var result36 = []; - var result38 = parse_WS(); - while (result38 !== null) { - result36.push(result38); - var result38 = parse_WS(); + if (result36 !== null) { + var result37 = []; + var result39 = parse_WS(); + while (result39 !== null) { + result37.push(result39); + var result39 = parse_WS(); } - if (result36 !== null) { - var result37 = parse_AdditiveExpression(); - if (result37 !== null) { - var result33 = [result34, result35, result36, result37]; + if (result37 !== null) { + var result38 = parse_AdditiveExpression(); + if (result38 !== null) { + var result34 = [result35, result36, result37, result38]; } else { - var result33 = null; - pos = savedPos5; + var result34 = null; + pos = savedPos6; } } else { - var result33 = null; - pos = savedPos5; + var result34 = null; + pos = savedPos6; } } else { - var result33 = null; - pos = savedPos5; + var result34 = null; + pos = savedPos6; } } else { - var result33 = null; - pos = savedPos5; + var result34 = null; + pos = savedPos6; } - if (result33 !== null) { - var result4 = result33; + if (result34 !== null) { + var result5 = result34; } else { - var savedPos4 = pos; - var result27 = []; - var result32 = parse_WS(); - while (result32 !== null) { - result27.push(result32); - var result32 = parse_WS(); + var savedPos5 = pos; + var result28 = []; + var result33 = parse_WS(); + while (result33 !== null) { + result28.push(result33); + var result33 = parse_WS(); } - if (result27 !== null) { + if (result28 !== null) { if (input.substr(pos, 1) === "<") { - var result28 = "<"; + var result29 = "<"; pos += 1; } else { - var result28 = null; + var result29 = null; if (reportMatchFailures) { matchFailed("\"<\""); } } - if (result28 !== null) { - var result29 = []; - var result31 = parse_WS(); - while (result31 !== null) { - result29.push(result31); - var result31 = parse_WS(); + if (result29 !== null) { + var result30 = []; + var result32 = parse_WS(); + while (result32 !== null) { + result30.push(result32); + var result32 = parse_WS(); } - if (result29 !== null) { - var result30 = parse_AdditiveExpression(); - if (result30 !== null) { - var result26 = [result27, result28, result29, result30]; + if (result30 !== null) { + var result31 = parse_AdditiveExpression(); + if (result31 !== null) { + var result27 = [result28, result29, result30, result31]; } else { - var result26 = null; - pos = savedPos4; + var result27 = null; + pos = savedPos5; } } else { - var result26 = null; - pos = savedPos4; + var result27 = null; + pos = savedPos5; } } else { - var result26 = null; - pos = savedPos4; + var result27 = null; + pos = savedPos5; } } else { - var result26 = null; - pos = savedPos4; + var result27 = null; + pos = savedPos5; } - if (result26 !== null) { - var result4 = result26; + if (result27 !== null) { + var result5 = result27; } else { - var savedPos3 = pos; - var result20 = []; - var result25 = parse_WS(); - while (result25 !== null) { - result20.push(result25); - var result25 = parse_WS(); + var savedPos4 = pos; + var result21 = []; + var result26 = parse_WS(); + while (result26 !== null) { + result21.push(result26); + var result26 = parse_WS(); } - if (result20 !== null) { + if (result21 !== null) { if (input.substr(pos, 1) === ">") { - var result21 = ">"; + var result22 = ">"; pos += 1; } else { - var result21 = null; + var result22 = null; if (reportMatchFailures) { matchFailed("\">\""); } } - if (result21 !== null) { - var result22 = []; - var result24 = parse_WS(); - while (result24 !== null) { - result22.push(result24); - var result24 = parse_WS(); + if (result22 !== null) { + var result23 = []; + var result25 = parse_WS(); + while (result25 !== null) { + result23.push(result25); + var result25 = parse_WS(); } - if (result22 !== null) { - var result23 = parse_AdditiveExpression(); - if (result23 !== null) { - var result19 = [result20, result21, result22, result23]; + if (result23 !== null) { + var result24 = parse_AdditiveExpression(); + if (result24 !== null) { + var result20 = [result21, result22, result23, result24]; } else { - var result19 = null; - pos = savedPos3; + var result20 = null; + pos = savedPos4; } } else { - var result19 = null; - pos = savedPos3; + var result20 = null; + pos = savedPos4; } } else { - var result19 = null; - pos = savedPos3; + var result20 = null; + pos = savedPos4; } } else { - var result19 = null; - pos = savedPos3; + var result20 = null; + pos = savedPos4; } - if (result19 !== null) { - var result4 = result19; + if (result20 !== null) { + var result5 = result20; } else { - var savedPos2 = pos; - var result13 = []; - var result18 = parse_WS(); - while (result18 !== null) { - result13.push(result18); - var result18 = parse_WS(); + var savedPos3 = pos; + var result14 = []; + var result19 = parse_WS(); + while (result19 !== null) { + result14.push(result19); + var result19 = parse_WS(); } - if (result13 !== null) { + if (result14 !== null) { if (input.substr(pos, 2) === "<=") { - var result14 = "<="; + var result15 = "<="; pos += 2; } else { - var result14 = null; + var result15 = null; if (reportMatchFailures) { matchFailed("\"<=\""); } } - if (result14 !== null) { - var result15 = []; - var result17 = parse_WS(); - while (result17 !== null) { - result15.push(result17); - var result17 = parse_WS(); + if (result15 !== null) { + var result16 = []; + var result18 = parse_WS(); + while (result18 !== null) { + result16.push(result18); + var result18 = parse_WS(); } - if (result15 !== null) { - var result16 = parse_AdditiveExpression(); - if (result16 !== null) { - var result12 = [result13, result14, result15, result16]; + if (result16 !== null) { + var result17 = parse_AdditiveExpression(); + if (result17 !== null) { + var result13 = [result14, result15, result16, result17]; } else { - var result12 = null; - pos = savedPos2; + var result13 = null; + pos = savedPos3; } } else { - var result12 = null; - pos = savedPos2; + var result13 = null; + pos = savedPos3; } } else { - var result12 = null; - pos = savedPos2; + var result13 = null; + pos = savedPos3; } } else { - var result12 = null; - pos = savedPos2; + var result13 = null; + pos = savedPos3; } - if (result12 !== null) { - var result4 = result12; + if (result13 !== null) { + var result5 = result13; } else { - var savedPos1 = pos; - var result6 = []; - var result11 = parse_WS(); - while (result11 !== null) { - result6.push(result11); - var result11 = parse_WS(); + var savedPos2 = pos; + var result7 = []; + var result12 = parse_WS(); + while (result12 !== null) { + result7.push(result12); + var result12 = parse_WS(); } - if (result6 !== null) { + if (result7 !== null) { if (input.substr(pos, 2) === ">=") { - var result7 = ">="; + var result8 = ">="; pos += 2; } else { - var result7 = null; + var result8 = null; if (reportMatchFailures) { matchFailed("\">=\""); } } - if (result7 !== null) { - var result8 = []; - var result10 = parse_WS(); - while (result10 !== null) { - result8.push(result10); - var result10 = parse_WS(); + if (result8 !== null) { + var result9 = []; + var result11 = parse_WS(); + while (result11 !== null) { + result9.push(result11); + var result11 = parse_WS(); } - if (result8 !== null) { - var result9 = parse_AdditiveExpression(); - if (result9 !== null) { - var result5 = [result6, result7, result8, result9]; + if (result9 !== null) { + var result10 = parse_AdditiveExpression(); + if (result10 !== null) { + var result6 = [result7, result8, result9, result10]; } else { - var result5 = null; - pos = savedPos1; + var result6 = null; + pos = savedPos2; } } else { - var result5 = null; - pos = savedPos1; + var result6 = null; + pos = savedPos2; } } else { - var result5 = null; - pos = savedPos1; + var result6 = null; + pos = savedPos2; } } else { - var result5 = null; - pos = savedPos1; + var result6 = null; + pos = savedPos2; } - if (result5 !== null) { - var result4 = result5; + if (result6 !== null) { + var result5 = result6; } else { - var result4 = null;; + var result5 = null;; }; }; }; @@ -25185,17 +18027,17 @@ SparqlParser.parser = (function(){ }; } } - if (result3 !== null) { - var result1 = [result2, result3]; + if (result4 !== null) { + var result1 = [result3, result4]; } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } - var result0 = result1 !== null + var result2 = result1 !== null ? (function(op1, op2) { if(op2.length === 0) { return op1; @@ -25211,6 +18053,12 @@ SparqlParser.parser = (function(){ } })(result1[0], result1[1]) : null; + if (result2 !== null) { + var result0 = result2; + } else { + var result0 = null; + pos = savedPos0; + } reportMatchFailures = savedReportMatchFailures; if (reportMatchFailures && result0 === null) { matchFailed("[99] RelationalExpression"); @@ -25234,467 +18082,468 @@ SparqlParser.parser = (function(){ var savedReportMatchFailures = reportMatchFailures; reportMatchFailures = false; var savedPos0 = pos; - var result2 = parse_MultiplicativeExpression(); - if (result2 !== null) { - var result3 = []; - var savedPos5 = pos; - var result33 = []; - var result38 = parse_WS(); - while (result38 !== null) { - result33.push(result38); - var result38 = parse_WS(); + var savedPos1 = pos; + var result3 = parse_MultiplicativeExpression(); + if (result3 !== null) { + var result4 = []; + var savedPos6 = pos; + var result34 = []; + var result39 = parse_WS(); + while (result39 !== null) { + result34.push(result39); + var result39 = parse_WS(); } - if (result33 !== null) { + if (result34 !== null) { if (input.substr(pos, 1) === "+") { - var result34 = "+"; + var result35 = "+"; pos += 1; } else { - var result34 = null; + var result35 = null; if (reportMatchFailures) { matchFailed("\"+\""); } } - if (result34 !== null) { - var result35 = []; - var result37 = parse_WS(); - while (result37 !== null) { - result35.push(result37); - var result37 = parse_WS(); + if (result35 !== null) { + var result36 = []; + var result38 = parse_WS(); + while (result38 !== null) { + result36.push(result38); + var result38 = parse_WS(); } - if (result35 !== null) { - var result36 = parse_MultiplicativeExpression(); - if (result36 !== null) { - var result32 = [result33, result34, result35, result36]; + if (result36 !== null) { + var result37 = parse_MultiplicativeExpression(); + if (result37 !== null) { + var result33 = [result34, result35, result36, result37]; } else { - var result32 = null; - pos = savedPos5; + var result33 = null; + pos = savedPos6; } } else { - var result32 = null; - pos = savedPos5; + var result33 = null; + pos = savedPos6; } } else { - var result32 = null; - pos = savedPos5; + var result33 = null; + pos = savedPos6; } } else { - var result32 = null; - pos = savedPos5; + var result33 = null; + pos = savedPos6; } - if (result32 !== null) { - var result4 = result32; + if (result33 !== null) { + var result5 = result33; } else { - var savedPos4 = pos; - var result26 = []; - var result31 = parse_WS(); - while (result31 !== null) { - result26.push(result31); - var result31 = parse_WS(); + var savedPos5 = pos; + var result27 = []; + var result32 = parse_WS(); + while (result32 !== null) { + result27.push(result32); + var result32 = parse_WS(); } - if (result26 !== null) { + if (result27 !== null) { if (input.substr(pos, 1) === "-") { - var result27 = "-"; + var result28 = "-"; pos += 1; } else { - var result27 = null; + var result28 = null; if (reportMatchFailures) { matchFailed("\"-\""); } } - if (result27 !== null) { - var result28 = []; - var result30 = parse_WS(); - while (result30 !== null) { - result28.push(result30); - var result30 = parse_WS(); + if (result28 !== null) { + var result29 = []; + var result31 = parse_WS(); + while (result31 !== null) { + result29.push(result31); + var result31 = parse_WS(); } - if (result28 !== null) { - var result29 = parse_MultiplicativeExpression(); - if (result29 !== null) { - var result25 = [result26, result27, result28, result29]; + if (result29 !== null) { + var result30 = parse_MultiplicativeExpression(); + if (result30 !== null) { + var result26 = [result27, result28, result29, result30]; } else { - var result25 = null; - pos = savedPos4; + var result26 = null; + pos = savedPos5; } - } else { - var result25 = null; - pos = savedPos4; + } else { + var result26 = null; + pos = savedPos5; } } else { - var result25 = null; - pos = savedPos4; + var result26 = null; + pos = savedPos5; } } else { - var result25 = null; - pos = savedPos4; + var result26 = null; + pos = savedPos5; } - if (result25 !== null) { - var result4 = result25; + if (result26 !== null) { + var result5 = result26; } else { - var savedPos1 = pos; - var result24 = parse_NumericLiteralNegative(); - if (result24 !== null) { - var result6 = result24; + var savedPos2 = pos; + var result25 = parse_NumericLiteralNegative(); + if (result25 !== null) { + var result7 = result25; } else { - var result23 = parse_NumericLiteralNegative(); - if (result23 !== null) { - var result6 = result23; + var result24 = parse_NumericLiteralNegative(); + if (result24 !== null) { + var result7 = result24; } else { - var result6 = null;; + var result7 = null;; }; } - if (result6 !== null) { - var savedPos3 = pos; - var result17 = []; - var result22 = parse_WS(); - while (result22 !== null) { - result17.push(result22); - var result22 = parse_WS(); + if (result7 !== null) { + var savedPos4 = pos; + var result18 = []; + var result23 = parse_WS(); + while (result23 !== null) { + result18.push(result23); + var result23 = parse_WS(); } - if (result17 !== null) { + if (result18 !== null) { if (input.substr(pos, 1) === "*") { - var result18 = "*"; + var result19 = "*"; pos += 1; } else { - var result18 = null; + var result19 = null; if (reportMatchFailures) { matchFailed("\"*\""); } } - if (result18 !== null) { - var result19 = []; - var result21 = parse_WS(); - while (result21 !== null) { - result19.push(result21); - var result21 = parse_WS(); + if (result19 !== null) { + var result20 = []; + var result22 = parse_WS(); + while (result22 !== null) { + result20.push(result22); + var result22 = parse_WS(); } - if (result19 !== null) { - var result20 = parse_UnaryExpression(); - if (result20 !== null) { - var result16 = [result17, result18, result19, result20]; + if (result20 !== null) { + var result21 = parse_UnaryExpression(); + if (result21 !== null) { + var result17 = [result18, result19, result20, result21]; } else { - var result16 = null; - pos = savedPos3; + var result17 = null; + pos = savedPos4; } } else { - var result16 = null; - pos = savedPos3; + var result17 = null; + pos = savedPos4; } } else { - var result16 = null; - pos = savedPos3; + var result17 = null; + pos = savedPos4; } } else { - var result16 = null; - pos = savedPos3; + var result17 = null; + pos = savedPos4; } - if (result16 !== null) { - var result8 = result16; + if (result17 !== null) { + var result9 = result17; } else { - var savedPos2 = pos; - var result10 = []; - var result15 = parse_WS(); - while (result15 !== null) { - result10.push(result15); - var result15 = parse_WS(); + var savedPos3 = pos; + var result11 = []; + var result16 = parse_WS(); + while (result16 !== null) { + result11.push(result16); + var result16 = parse_WS(); } - if (result10 !== null) { + if (result11 !== null) { if (input.substr(pos, 1) === "/") { - var result11 = "/"; + var result12 = "/"; pos += 1; } else { - var result11 = null; + var result12 = null; if (reportMatchFailures) { matchFailed("\"/\""); } } - if (result11 !== null) { - var result12 = []; - var result14 = parse_WS(); - while (result14 !== null) { - result12.push(result14); - var result14 = parse_WS(); + if (result12 !== null) { + var result13 = []; + var result15 = parse_WS(); + while (result15 !== null) { + result13.push(result15); + var result15 = parse_WS(); } - if (result12 !== null) { - var result13 = parse_UnaryExpression(); - if (result13 !== null) { - var result9 = [result10, result11, result12, result13]; + if (result13 !== null) { + var result14 = parse_UnaryExpression(); + if (result14 !== null) { + var result10 = [result11, result12, result13, result14]; } else { - var result9 = null; - pos = savedPos2; + var result10 = null; + pos = savedPos3; } } else { - var result9 = null; - pos = savedPos2; + var result10 = null; + pos = savedPos3; } } else { - var result9 = null; - pos = savedPos2; + var result10 = null; + pos = savedPos3; } } else { - var result9 = null; - pos = savedPos2; + var result10 = null; + pos = savedPos3; } - if (result9 !== null) { - var result8 = result9; + if (result10 !== null) { + var result9 = result10; } else { - var result8 = null;; + var result9 = null;; }; } - var result7 = result8 !== null ? result8 : ''; - if (result7 !== null) { - var result5 = [result6, result7]; + var result8 = result9 !== null ? result9 : ''; + if (result8 !== null) { + var result6 = [result7, result8]; } else { - var result5 = null; - pos = savedPos1; + var result6 = null; + pos = savedPos2; } } else { - var result5 = null; - pos = savedPos1; + var result6 = null; + pos = savedPos2; } - if (result5 !== null) { - var result4 = result5; + if (result6 !== null) { + var result5 = result6; } else { - var result4 = null;; + var result5 = null;; }; }; } - while (result4 !== null) { - result3.push(result4); - var savedPos5 = pos; - var result33 = []; - var result38 = parse_WS(); - while (result38 !== null) { - result33.push(result38); - var result38 = parse_WS(); + while (result5 !== null) { + result4.push(result5); + var savedPos6 = pos; + var result34 = []; + var result39 = parse_WS(); + while (result39 !== null) { + result34.push(result39); + var result39 = parse_WS(); } - if (result33 !== null) { + if (result34 !== null) { if (input.substr(pos, 1) === "+") { - var result34 = "+"; + var result35 = "+"; pos += 1; } else { - var result34 = null; + var result35 = null; if (reportMatchFailures) { matchFailed("\"+\""); } } - if (result34 !== null) { - var result35 = []; - var result37 = parse_WS(); - while (result37 !== null) { - result35.push(result37); - var result37 = parse_WS(); - } - if (result35 !== null) { - var result36 = parse_MultiplicativeExpression(); - if (result36 !== null) { - var result32 = [result33, result34, result35, result36]; + if (result35 !== null) { + var result36 = []; + var result38 = parse_WS(); + while (result38 !== null) { + result36.push(result38); + var result38 = parse_WS(); + } + if (result36 !== null) { + var result37 = parse_MultiplicativeExpression(); + if (result37 !== null) { + var result33 = [result34, result35, result36, result37]; } else { - var result32 = null; - pos = savedPos5; + var result33 = null; + pos = savedPos6; } } else { - var result32 = null; - pos = savedPos5; + var result33 = null; + pos = savedPos6; } } else { - var result32 = null; - pos = savedPos5; + var result33 = null; + pos = savedPos6; } } else { - var result32 = null; - pos = savedPos5; + var result33 = null; + pos = savedPos6; } - if (result32 !== null) { - var result4 = result32; + if (result33 !== null) { + var result5 = result33; } else { - var savedPos4 = pos; - var result26 = []; - var result31 = parse_WS(); - while (result31 !== null) { - result26.push(result31); - var result31 = parse_WS(); + var savedPos5 = pos; + var result27 = []; + var result32 = parse_WS(); + while (result32 !== null) { + result27.push(result32); + var result32 = parse_WS(); } - if (result26 !== null) { + if (result27 !== null) { if (input.substr(pos, 1) === "-") { - var result27 = "-"; + var result28 = "-"; pos += 1; } else { - var result27 = null; + var result28 = null; if (reportMatchFailures) { matchFailed("\"-\""); } } - if (result27 !== null) { - var result28 = []; - var result30 = parse_WS(); - while (result30 !== null) { - result28.push(result30); - var result30 = parse_WS(); + if (result28 !== null) { + var result29 = []; + var result31 = parse_WS(); + while (result31 !== null) { + result29.push(result31); + var result31 = parse_WS(); } - if (result28 !== null) { - var result29 = parse_MultiplicativeExpression(); - if (result29 !== null) { - var result25 = [result26, result27, result28, result29]; + if (result29 !== null) { + var result30 = parse_MultiplicativeExpression(); + if (result30 !== null) { + var result26 = [result27, result28, result29, result30]; } else { - var result25 = null; - pos = savedPos4; + var result26 = null; + pos = savedPos5; } } else { - var result25 = null; - pos = savedPos4; + var result26 = null; + pos = savedPos5; } } else { - var result25 = null; - pos = savedPos4; + var result26 = null; + pos = savedPos5; } } else { - var result25 = null; - pos = savedPos4; + var result26 = null; + pos = savedPos5; } - if (result25 !== null) { - var result4 = result25; + if (result26 !== null) { + var result5 = result26; } else { - var savedPos1 = pos; - var result24 = parse_NumericLiteralNegative(); - if (result24 !== null) { - var result6 = result24; + var savedPos2 = pos; + var result25 = parse_NumericLiteralNegative(); + if (result25 !== null) { + var result7 = result25; } else { - var result23 = parse_NumericLiteralNegative(); - if (result23 !== null) { - var result6 = result23; + var result24 = parse_NumericLiteralNegative(); + if (result24 !== null) { + var result7 = result24; } else { - var result6 = null;; + var result7 = null;; }; } - if (result6 !== null) { - var savedPos3 = pos; - var result17 = []; - var result22 = parse_WS(); - while (result22 !== null) { - result17.push(result22); - var result22 = parse_WS(); + if (result7 !== null) { + var savedPos4 = pos; + var result18 = []; + var result23 = parse_WS(); + while (result23 !== null) { + result18.push(result23); + var result23 = parse_WS(); } - if (result17 !== null) { + if (result18 !== null) { if (input.substr(pos, 1) === "*") { - var result18 = "*"; + var result19 = "*"; pos += 1; } else { - var result18 = null; + var result19 = null; if (reportMatchFailures) { matchFailed("\"*\""); } } - if (result18 !== null) { - var result19 = []; - var result21 = parse_WS(); - while (result21 !== null) { - result19.push(result21); - var result21 = parse_WS(); + if (result19 !== null) { + var result20 = []; + var result22 = parse_WS(); + while (result22 !== null) { + result20.push(result22); + var result22 = parse_WS(); } - if (result19 !== null) { - var result20 = parse_UnaryExpression(); - if (result20 !== null) { - var result16 = [result17, result18, result19, result20]; + if (result20 !== null) { + var result21 = parse_UnaryExpression(); + if (result21 !== null) { + var result17 = [result18, result19, result20, result21]; } else { - var result16 = null; - pos = savedPos3; + var result17 = null; + pos = savedPos4; } } else { - var result16 = null; - pos = savedPos3; + var result17 = null; + pos = savedPos4; } } else { - var result16 = null; - pos = savedPos3; + var result17 = null; + pos = savedPos4; } } else { - var result16 = null; - pos = savedPos3; + var result17 = null; + pos = savedPos4; } - if (result16 !== null) { - var result8 = result16; + if (result17 !== null) { + var result9 = result17; } else { - var savedPos2 = pos; - var result10 = []; - var result15 = parse_WS(); - while (result15 !== null) { - result10.push(result15); - var result15 = parse_WS(); + var savedPos3 = pos; + var result11 = []; + var result16 = parse_WS(); + while (result16 !== null) { + result11.push(result16); + var result16 = parse_WS(); } - if (result10 !== null) { + if (result11 !== null) { if (input.substr(pos, 1) === "/") { - var result11 = "/"; + var result12 = "/"; pos += 1; } else { - var result11 = null; + var result12 = null; if (reportMatchFailures) { matchFailed("\"/\""); } } - if (result11 !== null) { - var result12 = []; - var result14 = parse_WS(); - while (result14 !== null) { - result12.push(result14); - var result14 = parse_WS(); + if (result12 !== null) { + var result13 = []; + var result15 = parse_WS(); + while (result15 !== null) { + result13.push(result15); + var result15 = parse_WS(); } - if (result12 !== null) { - var result13 = parse_UnaryExpression(); - if (result13 !== null) { - var result9 = [result10, result11, result12, result13]; + if (result13 !== null) { + var result14 = parse_UnaryExpression(); + if (result14 !== null) { + var result10 = [result11, result12, result13, result14]; } else { - var result9 = null; - pos = savedPos2; + var result10 = null; + pos = savedPos3; } } else { - var result9 = null; - pos = savedPos2; + var result10 = null; + pos = savedPos3; } } else { - var result9 = null; - pos = savedPos2; + var result10 = null; + pos = savedPos3; } } else { - var result9 = null; - pos = savedPos2; + var result10 = null; + pos = savedPos3; } - if (result9 !== null) { - var result8 = result9; + if (result10 !== null) { + var result9 = result10; } else { - var result8 = null;; + var result9 = null;; }; } - var result7 = result8 !== null ? result8 : ''; - if (result7 !== null) { - var result5 = [result6, result7]; + var result8 = result9 !== null ? result9 : ''; + if (result8 !== null) { + var result6 = [result7, result8]; } else { - var result5 = null; - pos = savedPos1; + var result6 = null; + pos = savedPos2; } } else { - var result5 = null; - pos = savedPos1; + var result6 = null; + pos = savedPos2; } - if (result5 !== null) { - var result4 = result5; + if (result6 !== null) { + var result5 = result6; } else { - var result4 = null;; + var result5 = null;; }; }; } } - if (result3 !== null) { - var result1 = [result2, result3]; + if (result4 !== null) { + var result1 = [result3, result4]; } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } - var result0 = result1 !== null + var result2 = result1 !== null ? (function(op1, ops) { if(ops.length === 0) { return op1; @@ -25737,6 +18586,12 @@ SparqlParser.parser = (function(){ return ex; })(result1[0], result1[1]) : null; + if (result2 !== null) { + var result0 = result2; + } else { + var result0 = null; + pos = savedPos0; + } reportMatchFailures = savedReportMatchFailures; if (reportMatchFailures && result0 === null) { matchFailed("[101] AdditiveExpression"); @@ -25760,217 +18615,218 @@ SparqlParser.parser = (function(){ var savedReportMatchFailures = reportMatchFailures; reportMatchFailures = false; var savedPos0 = pos; - var result2 = parse_UnaryExpression(); - if (result2 !== null) { - var result3 = []; - var savedPos2 = pos; - var result13 = []; - var result18 = parse_WS(); - while (result18 !== null) { - result13.push(result18); - var result18 = parse_WS(); + var savedPos1 = pos; + var result3 = parse_UnaryExpression(); + if (result3 !== null) { + var result4 = []; + var savedPos3 = pos; + var result14 = []; + var result19 = parse_WS(); + while (result19 !== null) { + result14.push(result19); + var result19 = parse_WS(); } - if (result13 !== null) { + if (result14 !== null) { if (input.substr(pos, 1) === "*") { - var result14 = "*"; + var result15 = "*"; pos += 1; } else { - var result14 = null; + var result15 = null; if (reportMatchFailures) { matchFailed("\"*\""); } } - if (result14 !== null) { - var result15 = []; - var result17 = parse_WS(); - while (result17 !== null) { - result15.push(result17); - var result17 = parse_WS(); + if (result15 !== null) { + var result16 = []; + var result18 = parse_WS(); + while (result18 !== null) { + result16.push(result18); + var result18 = parse_WS(); } - if (result15 !== null) { - var result16 = parse_UnaryExpression(); - if (result16 !== null) { - var result12 = [result13, result14, result15, result16]; + if (result16 !== null) { + var result17 = parse_UnaryExpression(); + if (result17 !== null) { + var result13 = [result14, result15, result16, result17]; } else { - var result12 = null; - pos = savedPos2; + var result13 = null; + pos = savedPos3; } } else { - var result12 = null; - pos = savedPos2; + var result13 = null; + pos = savedPos3; } } else { - var result12 = null; - pos = savedPos2; + var result13 = null; + pos = savedPos3; } } else { - var result12 = null; - pos = savedPos2; + var result13 = null; + pos = savedPos3; } - if (result12 !== null) { - var result4 = result12; + if (result13 !== null) { + var result5 = result13; } else { - var savedPos1 = pos; - var result6 = []; - var result11 = parse_WS(); - while (result11 !== null) { - result6.push(result11); - var result11 = parse_WS(); + var savedPos2 = pos; + var result7 = []; + var result12 = parse_WS(); + while (result12 !== null) { + result7.push(result12); + var result12 = parse_WS(); } - if (result6 !== null) { + if (result7 !== null) { if (input.substr(pos, 1) === "/") { - var result7 = "/"; + var result8 = "/"; pos += 1; } else { - var result7 = null; + var result8 = null; if (reportMatchFailures) { matchFailed("\"/\""); } } - if (result7 !== null) { - var result8 = []; - var result10 = parse_WS(); - while (result10 !== null) { - result8.push(result10); - var result10 = parse_WS(); + if (result8 !== null) { + var result9 = []; + var result11 = parse_WS(); + while (result11 !== null) { + result9.push(result11); + var result11 = parse_WS(); } - if (result8 !== null) { - var result9 = parse_UnaryExpression(); - if (result9 !== null) { - var result5 = [result6, result7, result8, result9]; + if (result9 !== null) { + var result10 = parse_UnaryExpression(); + if (result10 !== null) { + var result6 = [result7, result8, result9, result10]; } else { - var result5 = null; - pos = savedPos1; + var result6 = null; + pos = savedPos2; } } else { - var result5 = null; - pos = savedPos1; + var result6 = null; + pos = savedPos2; } } else { - var result5 = null; - pos = savedPos1; + var result6 = null; + pos = savedPos2; } } else { - var result5 = null; - pos = savedPos1; + var result6 = null; + pos = savedPos2; } - if (result5 !== null) { - var result4 = result5; + if (result6 !== null) { + var result5 = result6; } else { - var result4 = null;; + var result5 = null;; }; } - while (result4 !== null) { - result3.push(result4); - var savedPos2 = pos; - var result13 = []; - var result18 = parse_WS(); - while (result18 !== null) { - result13.push(result18); - var result18 = parse_WS(); + while (result5 !== null) { + result4.push(result5); + var savedPos3 = pos; + var result14 = []; + var result19 = parse_WS(); + while (result19 !== null) { + result14.push(result19); + var result19 = parse_WS(); } - if (result13 !== null) { + if (result14 !== null) { if (input.substr(pos, 1) === "*") { - var result14 = "*"; + var result15 = "*"; pos += 1; } else { - var result14 = null; + var result15 = null; if (reportMatchFailures) { matchFailed("\"*\""); } } - if (result14 !== null) { - var result15 = []; - var result17 = parse_WS(); - while (result17 !== null) { - result15.push(result17); - var result17 = parse_WS(); + if (result15 !== null) { + var result16 = []; + var result18 = parse_WS(); + while (result18 !== null) { + result16.push(result18); + var result18 = parse_WS(); } - if (result15 !== null) { - var result16 = parse_UnaryExpression(); - if (result16 !== null) { - var result12 = [result13, result14, result15, result16]; + if (result16 !== null) { + var result17 = parse_UnaryExpression(); + if (result17 !== null) { + var result13 = [result14, result15, result16, result17]; } else { - var result12 = null; - pos = savedPos2; + var result13 = null; + pos = savedPos3; } } else { - var result12 = null; - pos = savedPos2; + var result13 = null; + pos = savedPos3; } } else { - var result12 = null; - pos = savedPos2; + var result13 = null; + pos = savedPos3; } } else { - var result12 = null; - pos = savedPos2; + var result13 = null; + pos = savedPos3; } - if (result12 !== null) { - var result4 = result12; + if (result13 !== null) { + var result5 = result13; } else { - var savedPos1 = pos; - var result6 = []; - var result11 = parse_WS(); - while (result11 !== null) { - result6.push(result11); - var result11 = parse_WS(); + var savedPos2 = pos; + var result7 = []; + var result12 = parse_WS(); + while (result12 !== null) { + result7.push(result12); + var result12 = parse_WS(); } - if (result6 !== null) { + if (result7 !== null) { if (input.substr(pos, 1) === "/") { - var result7 = "/"; + var result8 = "/"; pos += 1; } else { - var result7 = null; + var result8 = null; if (reportMatchFailures) { matchFailed("\"/\""); } } - if (result7 !== null) { - var result8 = []; - var result10 = parse_WS(); - while (result10 !== null) { - result8.push(result10); - var result10 = parse_WS(); + if (result8 !== null) { + var result9 = []; + var result11 = parse_WS(); + while (result11 !== null) { + result9.push(result11); + var result11 = parse_WS(); } - if (result8 !== null) { - var result9 = parse_UnaryExpression(); - if (result9 !== null) { - var result5 = [result6, result7, result8, result9]; + if (result9 !== null) { + var result10 = parse_UnaryExpression(); + if (result10 !== null) { + var result6 = [result7, result8, result9, result10]; } else { - var result5 = null; - pos = savedPos1; + var result6 = null; + pos = savedPos2; } } else { - var result5 = null; - pos = savedPos1; + var result6 = null; + pos = savedPos2; } } else { - var result5 = null; - pos = savedPos1; + var result6 = null; + pos = savedPos2; } } else { - var result5 = null; - pos = savedPos1; + var result6 = null; + pos = savedPos2; } - if (result5 !== null) { - var result4 = result5; + if (result6 !== null) { + var result5 = result6; } else { - var result4 = null;; + var result5 = null;; }; } } - if (result3 !== null) { - var result1 = [result2, result3]; + if (result4 !== null) { + var result1 = [result3, result4]; } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } - var result0 = result1 !== null + var result2 = result1 !== null ? (function(exp, exps) { if(exps.length === 0) { return exp; @@ -25992,6 +18848,12 @@ SparqlParser.parser = (function(){ return ex; })(result1[0], result1[1]) : null; + if (result2 !== null) { + var result0 = result2; + } else { + var result0 = null; + pos = savedPos0; + } reportMatchFailures = savedReportMatchFailures; if (reportMatchFailures && result0 === null) { matchFailed("[102] MultiplicativeExpression"); @@ -26014,40 +18876,41 @@ SparqlParser.parser = (function(){ var savedReportMatchFailures = reportMatchFailures; reportMatchFailures = false; - var savedPos2 = pos; + var savedPos4 = pos; + var savedPos5 = pos; if (input.substr(pos, 1) === "!") { - var result16 = "!"; + var result19 = "!"; pos += 1; } else { - var result16 = null; + var result19 = null; if (reportMatchFailures) { matchFailed("\"!\""); } } - if (result16 !== null) { - var result17 = []; - var result19 = parse_WS(); - while (result19 !== null) { - result17.push(result19); - var result19 = parse_WS(); + if (result19 !== null) { + var result20 = []; + var result22 = parse_WS(); + while (result22 !== null) { + result20.push(result22); + var result22 = parse_WS(); } - if (result17 !== null) { - var result18 = parse_PrimaryExpression(); - if (result18 !== null) { - var result15 = [result16, result17, result18]; + if (result20 !== null) { + var result21 = parse_PrimaryExpression(); + if (result21 !== null) { + var result17 = [result19, result20, result21]; } else { - var result15 = null; - pos = savedPos2; + var result17 = null; + pos = savedPos5; } } else { - var result15 = null; - pos = savedPos2; + var result17 = null; + pos = savedPos5; } } else { - var result15 = null; - pos = savedPos2; + var result17 = null; + pos = savedPos5; } - var result14 = result15 !== null + var result18 = result17 !== null ? (function(e) { var ex = {}; ex.token = 'expression'; @@ -26056,45 +18919,52 @@ SparqlParser.parser = (function(){ ex.expression = e; return ex; - })(result15[2]) + })(result17[2]) : null; - if (result14 !== null) { - var result0 = result14; + if (result18 !== null) { + var result16 = result18; } else { - var savedPos1 = pos; + var result16 = null; + pos = savedPos4; + } + if (result16 !== null) { + var result0 = result16; + } else { + var savedPos2 = pos; + var savedPos3 = pos; if (input.substr(pos, 1) === "+") { - var result10 = "+"; + var result12 = "+"; pos += 1; } else { - var result10 = null; + var result12 = null; if (reportMatchFailures) { matchFailed("\"+\""); } } - if (result10 !== null) { - var result11 = []; - var result13 = parse_WS(); - while (result13 !== null) { - result11.push(result13); - var result13 = parse_WS(); + if (result12 !== null) { + var result13 = []; + var result15 = parse_WS(); + while (result15 !== null) { + result13.push(result15); + var result15 = parse_WS(); } - if (result11 !== null) { - var result12 = parse_PrimaryExpression(); - if (result12 !== null) { - var result9 = [result10, result11, result12]; + if (result13 !== null) { + var result14 = parse_PrimaryExpression(); + if (result14 !== null) { + var result10 = [result12, result13, result14]; } else { - var result9 = null; - pos = savedPos1; + var result10 = null; + pos = savedPos3; } } else { - var result9 = null; - pos = savedPos1; + var result10 = null; + pos = savedPos3; } } else { - var result9 = null; - pos = savedPos1; + var result10 = null; + pos = savedPos3; } - var result8 = result9 !== null + var result11 = result10 !== null ? (function(v) { var ex = {}; ex.token = 'expression'; @@ -26103,45 +18973,52 @@ SparqlParser.parser = (function(){ ex.expression = v; return ex; - })(result9[2]) + })(result10[2]) : null; - if (result8 !== null) { - var result0 = result8; + if (result11 !== null) { + var result9 = result11; + } else { + var result9 = null; + pos = savedPos2; + } + if (result9 !== null) { + var result0 = result9; } else { var savedPos0 = pos; + var savedPos1 = pos; if (input.substr(pos, 1) === "-") { - var result4 = "-"; + var result5 = "-"; pos += 1; } else { - var result4 = null; + var result5 = null; if (reportMatchFailures) { matchFailed("\"-\""); } } - if (result4 !== null) { - var result5 = []; - var result7 = parse_WS(); - while (result7 !== null) { - result5.push(result7); - var result7 = parse_WS(); + if (result5 !== null) { + var result6 = []; + var result8 = parse_WS(); + while (result8 !== null) { + result6.push(result8); + var result8 = parse_WS(); } - if (result5 !== null) { - var result6 = parse_PrimaryExpression(); - if (result6 !== null) { - var result3 = [result4, result5, result6]; + if (result6 !== null) { + var result7 = parse_PrimaryExpression(); + if (result7 !== null) { + var result3 = [result5, result6, result7]; } else { var result3 = null; - pos = savedPos0; + pos = savedPos1; } } else { var result3 = null; - pos = savedPos0; + pos = savedPos1; } } else { var result3 = null; - pos = savedPos0; + pos = savedPos1; } - var result2 = result3 !== null + var result4 = result3 !== null ? (function(v) { var ex = {}; ex.token = 'expression'; @@ -26152,6 +19029,12 @@ SparqlParser.parser = (function(){ return ex; })(result3[2]) : null; + if (result4 !== null) { + var result2 = result4; + } else { + var result2 = null; + pos = savedPos0; + } if (result2 !== null) { var result0 = result2; } else { @@ -26186,20 +19069,21 @@ SparqlParser.parser = (function(){ var savedReportMatchFailures = reportMatchFailures; reportMatchFailures = false; - var result12 = parse_BrackettedExpression(); - if (result12 !== null) { - var result0 = result12; + var result16 = parse_BrackettedExpression(); + if (result16 !== null) { + var result0 = result16; } else { - var result11 = parse_BuiltInCall(); - if (result11 !== null) { - var result0 = result11; + var result15 = parse_BuiltInCall(); + if (result15 !== null) { + var result0 = result15; } else { - var result10 = parse_IRIrefOrFunction(); - if (result10 !== null) { - var result0 = result10; + var result14 = parse_IRIrefOrFunction(); + if (result14 !== null) { + var result0 = result14; } else { - var result9 = parse_RDFLiteral(); - var result8 = result9 !== null + var savedPos3 = pos; + var result12 = parse_RDFLiteral(); + var result13 = result12 !== null ? (function(v) { var ex = {}; ex.token = 'expression'; @@ -26208,13 +19092,20 @@ SparqlParser.parser = (function(){ ex.value = v; return ex; - })(result9) + })(result12) : null; - if (result8 !== null) { - var result0 = result8; + if (result13 !== null) { + var result11 = result13; + } else { + var result11 = null; + pos = savedPos3; + } + if (result11 !== null) { + var result0 = result11; } else { - var result7 = parse_NumericLiteral(); - var result6 = result7 !== null + var savedPos2 = pos; + var result9 = parse_NumericLiteral(); + var result10 = result9 !== null ? (function(v) { var ex = {}; ex.token = 'expression'; @@ -26223,13 +19114,20 @@ SparqlParser.parser = (function(){ ex.value = v; return ex; - })(result7) + })(result9) : null; - if (result6 !== null) { - var result0 = result6; + if (result10 !== null) { + var result8 = result10; + } else { + var result8 = null; + pos = savedPos2; + } + if (result8 !== null) { + var result0 = result8; } else { - var result5 = parse_BooleanLiteral(); - var result4 = result5 !== null + var savedPos1 = pos; + var result6 = parse_BooleanLiteral(); + var result7 = result6 !== null ? (function(v) { var ex = {}; ex.token = 'expression'; @@ -26238,17 +19136,24 @@ SparqlParser.parser = (function(){ ex.value = v; return ex; - })(result5) + })(result6) : null; - if (result4 !== null) { - var result0 = result4; + if (result7 !== null) { + var result5 = result7; + } else { + var result5 = null; + pos = savedPos1; + } + if (result5 !== null) { + var result0 = result5; } else { - var result3 = parse_Aggregate(); - if (result3 !== null) { - var result0 = result3; + var result4 = parse_Aggregate(); + if (result4 !== null) { + var result0 = result4; } else { + var savedPos0 = pos; var result2 = parse_Var(); - var result1 = result2 !== null + var result3 = result2 !== null ? (function(v) { var ex = {}; ex.token = 'expression'; @@ -26259,6 +19164,12 @@ SparqlParser.parser = (function(){ return ex; })(result2) : null; + if (result3 !== null) { + var result1 = result3; + } else { + var result1 = null; + pos = savedPos0; + } if (result1 !== null) { var result0 = result1; } else { @@ -26294,68 +19205,75 @@ SparqlParser.parser = (function(){ var savedReportMatchFailures = reportMatchFailures; reportMatchFailures = false; var savedPos0 = pos; + var savedPos1 = pos; if (input.substr(pos, 1) === "(") { - var result2 = "("; + var result3 = "("; pos += 1; } else { - var result2 = null; + var result3 = null; if (reportMatchFailures) { matchFailed("\"(\""); } } - if (result2 !== null) { - var result3 = []; - var result8 = parse_WS(); - while (result8 !== null) { - result3.push(result8); - var result8 = parse_WS(); + if (result3 !== null) { + var result4 = []; + var result9 = parse_WS(); + while (result9 !== null) { + result4.push(result9); + var result9 = parse_WS(); } - if (result3 !== null) { - var result4 = parse_ConditionalOrExpression(); - if (result4 !== null) { - var result5 = []; - var result7 = parse_WS(); - while (result7 !== null) { - result5.push(result7); - var result7 = parse_WS(); + if (result4 !== null) { + var result5 = parse_ConditionalOrExpression(); + if (result5 !== null) { + var result6 = []; + var result8 = parse_WS(); + while (result8 !== null) { + result6.push(result8); + var result8 = parse_WS(); } - if (result5 !== null) { + if (result6 !== null) { if (input.substr(pos, 1) === ")") { - var result6 = ")"; + var result7 = ")"; pos += 1; } else { - var result6 = null; + var result7 = null; if (reportMatchFailures) { matchFailed("\")\""); } } - if (result6 !== null) { - var result1 = [result2, result3, result4, result5, result6]; + if (result7 !== null) { + var result1 = [result3, result4, result5, result6, result7]; } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } - var result0 = result1 !== null + var result2 = result1 !== null ? (function(e) { return e; })(result1[2]) : null; + if (result2 !== null) { + var result0 = result2; + } else { + var result0 = null; + pos = savedPos0; + } reportMatchFailures = savedReportMatchFailures; if (reportMatchFailures && result0 === null) { matchFailed("[105] BrackettedExpression"); @@ -26378,172 +19296,109 @@ SparqlParser.parser = (function(){ var savedReportMatchFailures = reportMatchFailures; reportMatchFailures = false; - var savedPos15 = pos; - if (input.substr(pos, 1) === "S") { - var result272 = "S"; - pos += 1; + var savedPos27 = pos; + var savedPos28 = pos; + if (input.substr(pos, 3) === "STR") { + var result216 = "STR"; + pos += 3; } else { - var result272 = null; + var result216 = null; if (reportMatchFailures) { - matchFailed("\"S\""); + matchFailed("\"STR\""); } } - if (result272 !== null) { - var result255 = result272; + if (result216 !== null) { + var result205 = result216; } else { - if (input.substr(pos, 1) === "s") { - var result271 = "s"; - pos += 1; + if (input.substr(pos, 3) === "str") { + var result215 = "str"; + pos += 3; } else { - var result271 = null; + var result215 = null; if (reportMatchFailures) { - matchFailed("\"s\""); + matchFailed("\"str\""); } } - if (result271 !== null) { - var result255 = result271; + if (result215 !== null) { + var result205 = result215; } else { - var result255 = null;; + var result205 = null;; }; } - if (result255 !== null) { - if (input.substr(pos, 1) === "T") { - var result270 = "T"; - pos += 1; - } else { - var result270 = null; - if (reportMatchFailures) { - matchFailed("\"T\""); - } - } - if (result270 !== null) { - var result256 = result270; - } else { - if (input.substr(pos, 1) === "t") { - var result269 = "t"; - pos += 1; - } else { - var result269 = null; - if (reportMatchFailures) { - matchFailed("\"t\""); - } - } - if (result269 !== null) { - var result256 = result269; - } else { - var result256 = null;; - }; + if (result205 !== null) { + var result206 = []; + var result214 = parse_WS(); + while (result214 !== null) { + result206.push(result214); + var result214 = parse_WS(); } - if (result256 !== null) { - if (input.substr(pos, 1) === "R") { - var result268 = "R"; + if (result206 !== null) { + if (input.substr(pos, 1) === "(") { + var result207 = "("; pos += 1; } else { - var result268 = null; + var result207 = null; if (reportMatchFailures) { - matchFailed("\"R\""); - } - } - if (result268 !== null) { - var result257 = result268; - } else { - if (input.substr(pos, 1) === "r") { - var result267 = "r"; - pos += 1; - } else { - var result267 = null; - if (reportMatchFailures) { - matchFailed("\"r\""); - } + matchFailed("\"(\""); } - if (result267 !== null) { - var result257 = result267; - } else { - var result257 = null;; - }; } - if (result257 !== null) { - var result258 = []; - var result266 = parse_WS(); - while (result266 !== null) { - result258.push(result266); - var result266 = parse_WS(); + if (result207 !== null) { + var result208 = []; + var result213 = parse_WS(); + while (result213 !== null) { + result208.push(result213); + var result213 = parse_WS(); } - if (result258 !== null) { - if (input.substr(pos, 1) === "(") { - var result259 = "("; - pos += 1; - } else { - var result259 = null; - if (reportMatchFailures) { - matchFailed("\"(\""); - } - } - if (result259 !== null) { - var result260 = []; - var result265 = parse_WS(); - while (result265 !== null) { - result260.push(result265); - var result265 = parse_WS(); + if (result208 !== null) { + var result209 = parse_ConditionalOrExpression(); + if (result209 !== null) { + var result210 = []; + var result212 = parse_WS(); + while (result212 !== null) { + result210.push(result212); + var result212 = parse_WS(); } - if (result260 !== null) { - var result261 = parse_ConditionalOrExpression(); - if (result261 !== null) { - var result262 = []; - var result264 = parse_WS(); - while (result264 !== null) { - result262.push(result264); - var result264 = parse_WS(); - } - if (result262 !== null) { - if (input.substr(pos, 1) === ")") { - var result263 = ")"; - pos += 1; - } else { - var result263 = null; - if (reportMatchFailures) { - matchFailed("\")\""); - } - } - if (result263 !== null) { - var result254 = [result255, result256, result257, result258, result259, result260, result261, result262, result263]; - } else { - var result254 = null; - pos = savedPos15; - } - } else { - var result254 = null; - pos = savedPos15; + if (result210 !== null) { + if (input.substr(pos, 1) === ")") { + var result211 = ")"; + pos += 1; + } else { + var result211 = null; + if (reportMatchFailures) { + matchFailed("\")\""); } + } + if (result211 !== null) { + var result203 = [result205, result206, result207, result208, result209, result210, result211]; } else { - var result254 = null; - pos = savedPos15; + var result203 = null; + pos = savedPos28; } } else { - var result254 = null; - pos = savedPos15; + var result203 = null; + pos = savedPos28; } } else { - var result254 = null; - pos = savedPos15; + var result203 = null; + pos = savedPos28; } } else { - var result254 = null; - pos = savedPos15; + var result203 = null; + pos = savedPos28; } } else { - var result254 = null; - pos = savedPos15; + var result203 = null; + pos = savedPos28; } } else { - var result254 = null; - pos = savedPos15; + var result203 = null; + pos = savedPos28; } } else { - var result254 = null; - pos = savedPos15; + var result203 = null; + pos = savedPos28; } - var result253 = result254 !== null + var result204 = result203 !== null ? (function(e) { var ex = {}; ex.token = 'expression' @@ -26552,209 +19407,120 @@ SparqlParser.parser = (function(){ ex.args = [e] return ex; - })(result254[6]) + })(result203[4]) : null; - if (result253 !== null) { - var result0 = result253; + if (result204 !== null) { + var result202 = result204; } else { - var savedPos14 = pos; - if (input.substr(pos, 1) === "L") { - var result252 = "L"; - pos += 1; + var result202 = null; + pos = savedPos27; + } + if (result202 !== null) { + var result0 = result202; + } else { + var savedPos25 = pos; + var savedPos26 = pos; + if (input.substr(pos, 4) === "LANG") { + var result201 = "LANG"; + pos += 4; } else { - var result252 = null; + var result201 = null; if (reportMatchFailures) { - matchFailed("\"L\""); + matchFailed("\"LANG\""); } } - if (result252 !== null) { - var result232 = result252; + if (result201 !== null) { + var result190 = result201; } else { - if (input.substr(pos, 1) === "l") { - var result251 = "l"; - pos += 1; - } else { - var result251 = null; - if (reportMatchFailures) { - matchFailed("\"l\""); - } - } - if (result251 !== null) { - var result232 = result251; - } else { - var result232 = null;; - }; - } - if (result232 !== null) { - if (input.substr(pos, 1) === "A") { - var result250 = "A"; - pos += 1; + if (input.substr(pos, 4) === "lang") { + var result200 = "lang"; + pos += 4; } else { - var result250 = null; + var result200 = null; if (reportMatchFailures) { - matchFailed("\"A\""); + matchFailed("\"lang\""); } } - if (result250 !== null) { - var result233 = result250; + if (result200 !== null) { + var result190 = result200; } else { - if (input.substr(pos, 1) === "a") { - var result249 = "a"; - pos += 1; - } else { - var result249 = null; - if (reportMatchFailures) { - matchFailed("\"a\""); - } - } - if (result249 !== null) { - var result233 = result249; - } else { - var result233 = null;; - }; - } - if (result233 !== null) { - if (input.substr(pos, 1) === "N") { - var result248 = "N"; - pos += 1; - } else { - var result248 = null; - if (reportMatchFailures) { - matchFailed("\"N\""); - } - } - if (result248 !== null) { - var result234 = result248; - } else { - if (input.substr(pos, 1) === "n") { - var result247 = "n"; - pos += 1; - } else { - var result247 = null; - if (reportMatchFailures) { - matchFailed("\"n\""); - } - } - if (result247 !== null) { - var result234 = result247; - } else { - var result234 = null;; - }; - } - if (result234 !== null) { - if (input.substr(pos, 1) === "G") { - var result246 = "G"; - pos += 1; - } else { - var result246 = null; - if (reportMatchFailures) { - matchFailed("\"G\""); - } - } - if (result246 !== null) { - var result235 = result246; - } else { - if (input.substr(pos, 1) === "g") { - var result245 = "g"; - pos += 1; - } else { - var result245 = null; - if (reportMatchFailures) { - matchFailed("\"g\""); - } - } - if (result245 !== null) { - var result235 = result245; - } else { - var result235 = null;; - }; + var result190 = null;; + }; + } + if (result190 !== null) { + var result191 = []; + var result199 = parse_WS(); + while (result199 !== null) { + result191.push(result199); + var result199 = parse_WS(); + } + if (result191 !== null) { + if (input.substr(pos, 1) === "(") { + var result192 = "("; + pos += 1; + } else { + var result192 = null; + if (reportMatchFailures) { + matchFailed("\"(\""); } - if (result235 !== null) { - var result236 = []; - var result244 = parse_WS(); - while (result244 !== null) { - result236.push(result244); - var result244 = parse_WS(); - } - if (result236 !== null) { - if (input.substr(pos, 1) === "(") { - var result237 = "("; - pos += 1; - } else { - var result237 = null; - if (reportMatchFailures) { - matchFailed("\"(\""); - } - } - if (result237 !== null) { - var result238 = []; - var result243 = parse_WS(); - while (result243 !== null) { - result238.push(result243); - var result243 = parse_WS(); - } - if (result238 !== null) { - var result239 = parse_ConditionalOrExpression(); - if (result239 !== null) { - var result240 = []; - var result242 = parse_WS(); - while (result242 !== null) { - result240.push(result242); - var result242 = parse_WS(); - } - if (result240 !== null) { - if (input.substr(pos, 1) === ")") { - var result241 = ")"; - pos += 1; - } else { - var result241 = null; - if (reportMatchFailures) { - matchFailed("\")\""); - } - } - if (result241 !== null) { - var result231 = [result232, result233, result234, result235, result236, result237, result238, result239, result240, result241]; - } else { - var result231 = null; - pos = savedPos14; - } - } else { - var result231 = null; - pos = savedPos14; - } - } else { - var result231 = null; - pos = savedPos14; + } + if (result192 !== null) { + var result193 = []; + var result198 = parse_WS(); + while (result198 !== null) { + result193.push(result198); + var result198 = parse_WS(); + } + if (result193 !== null) { + var result194 = parse_ConditionalOrExpression(); + if (result194 !== null) { + var result195 = []; + var result197 = parse_WS(); + while (result197 !== null) { + result195.push(result197); + var result197 = parse_WS(); + } + if (result195 !== null) { + if (input.substr(pos, 1) === ")") { + var result196 = ")"; + pos += 1; + } else { + var result196 = null; + if (reportMatchFailures) { + matchFailed("\")\""); } + } + if (result196 !== null) { + var result188 = [result190, result191, result192, result193, result194, result195, result196]; } else { - var result231 = null; - pos = savedPos14; + var result188 = null; + pos = savedPos26; } } else { - var result231 = null; - pos = savedPos14; + var result188 = null; + pos = savedPos26; } } else { - var result231 = null; - pos = savedPos14; + var result188 = null; + pos = savedPos26; } } else { - var result231 = null; - pos = savedPos14; + var result188 = null; + pos = savedPos26; } } else { - var result231 = null; - pos = savedPos14; + var result188 = null; + pos = savedPos26; } } else { - var result231 = null; - pos = savedPos14; + var result188 = null; + pos = savedPos26; } } else { - var result231 = null; - pos = savedPos14; + var result188 = null; + pos = savedPos26; } - var result230 = result231 !== null + var result189 = result188 !== null ? (function(e) { var ex = {}; ex.token = 'expression' @@ -26763,137 +19529,144 @@ SparqlParser.parser = (function(){ ex.args = [e] return ex; - })(result231[7]) + })(result188[4]) : null; - if (result230 !== null) { - var result0 = result230; + if (result189 !== null) { + var result187 = result189; + } else { + var result187 = null; + pos = savedPos25; + } + if (result187 !== null) { + var result0 = result187; } else { - var savedPos13 = pos; + var savedPos23 = pos; + var savedPos24 = pos; if (input.substr(pos, 11) === "LANGMATCHES") { - var result214 = "LANGMATCHES"; + var result171 = "LANGMATCHES"; pos += 11; } else { - var result214 = null; + var result171 = null; if (reportMatchFailures) { matchFailed("\"LANGMATCHES\""); } } - if (result214 !== null) { - var result215 = []; - var result229 = parse_WS(); - while (result229 !== null) { - result215.push(result229); - var result229 = parse_WS(); + if (result171 !== null) { + var result172 = []; + var result186 = parse_WS(); + while (result186 !== null) { + result172.push(result186); + var result186 = parse_WS(); } - if (result215 !== null) { + if (result172 !== null) { if (input.substr(pos, 1) === "(") { - var result216 = "("; + var result173 = "("; pos += 1; } else { - var result216 = null; + var result173 = null; if (reportMatchFailures) { matchFailed("\"(\""); } } - if (result216 !== null) { - var result217 = []; - var result228 = parse_WS(); - while (result228 !== null) { - result217.push(result228); - var result228 = parse_WS(); - } - if (result217 !== null) { - var result218 = parse_ConditionalOrExpression(); - if (result218 !== null) { - var result219 = []; - var result227 = parse_WS(); - while (result227 !== null) { - result219.push(result227); - var result227 = parse_WS(); + if (result173 !== null) { + var result174 = []; + var result185 = parse_WS(); + while (result185 !== null) { + result174.push(result185); + var result185 = parse_WS(); + } + if (result174 !== null) { + var result175 = parse_ConditionalOrExpression(); + if (result175 !== null) { + var result176 = []; + var result184 = parse_WS(); + while (result184 !== null) { + result176.push(result184); + var result184 = parse_WS(); } - if (result219 !== null) { + if (result176 !== null) { if (input.substr(pos, 1) === ",") { - var result220 = ","; + var result177 = ","; pos += 1; } else { - var result220 = null; + var result177 = null; if (reportMatchFailures) { matchFailed("\",\""); } } - if (result220 !== null) { - var result221 = []; - var result226 = parse_WS(); - while (result226 !== null) { - result221.push(result226); - var result226 = parse_WS(); + if (result177 !== null) { + var result178 = []; + var result183 = parse_WS(); + while (result183 !== null) { + result178.push(result183); + var result183 = parse_WS(); } - if (result221 !== null) { - var result222 = parse_ConditionalOrExpression(); - if (result222 !== null) { - var result223 = []; - var result225 = parse_WS(); - while (result225 !== null) { - result223.push(result225); - var result225 = parse_WS(); + if (result178 !== null) { + var result179 = parse_ConditionalOrExpression(); + if (result179 !== null) { + var result180 = []; + var result182 = parse_WS(); + while (result182 !== null) { + result180.push(result182); + var result182 = parse_WS(); } - if (result223 !== null) { + if (result180 !== null) { if (input.substr(pos, 1) === ")") { - var result224 = ")"; + var result181 = ")"; pos += 1; } else { - var result224 = null; + var result181 = null; if (reportMatchFailures) { matchFailed("\")\""); } } - if (result224 !== null) { - var result213 = [result214, result215, result216, result217, result218, result219, result220, result221, result222, result223, result224]; + if (result181 !== null) { + var result169 = [result171, result172, result173, result174, result175, result176, result177, result178, result179, result180, result181]; } else { - var result213 = null; - pos = savedPos13; + var result169 = null; + pos = savedPos24; } } else { - var result213 = null; - pos = savedPos13; + var result169 = null; + pos = savedPos24; } } else { - var result213 = null; - pos = savedPos13; + var result169 = null; + pos = savedPos24; } } else { - var result213 = null; - pos = savedPos13; + var result169 = null; + pos = savedPos24; } } else { - var result213 = null; - pos = savedPos13; + var result169 = null; + pos = savedPos24; } } else { - var result213 = null; - pos = savedPos13; + var result169 = null; + pos = savedPos24; } } else { - var result213 = null; - pos = savedPos13; + var result169 = null; + pos = savedPos24; } } else { - var result213 = null; - pos = savedPos13; + var result169 = null; + pos = savedPos24; } } else { - var result213 = null; - pos = savedPos13; + var result169 = null; + pos = savedPos24; } } else { - var result213 = null; - pos = savedPos13; + var result169 = null; + pos = savedPos24; } } else { - var result213 = null; - pos = savedPos13; + var result169 = null; + pos = savedPos24; } - var result212 = result213 !== null + var result170 = result169 !== null ? (function(e1, e2) { var ex = {}; ex.token = 'expression' @@ -26902,337 +19675,120 @@ SparqlParser.parser = (function(){ ex.args = [e1,e2] return ex; - })(result213[4], result213[8]) + })(result169[4], result169[8]) : null; - if (result212 !== null) { - var result0 = result212; + if (result170 !== null) { + var result168 = result170; } else { - var savedPos12 = pos; - if (input.substr(pos, 1) === "D") { - var result211 = "D"; - pos += 1; + var result168 = null; + pos = savedPos23; + } + if (result168 !== null) { + var result0 = result168; + } else { + var savedPos21 = pos; + var savedPos22 = pos; + if (input.substr(pos, 8) === "DATATYPE") { + var result167 = "DATATYPE"; + pos += 8; } else { - var result211 = null; + var result167 = null; if (reportMatchFailures) { - matchFailed("\"D\""); + matchFailed("\"DATATYPE\""); } } - if (result211 !== null) { - var result179 = result211; + if (result167 !== null) { + var result156 = result167; } else { - if (input.substr(pos, 1) === "d") { - var result210 = "d"; - pos += 1; + if (input.substr(pos, 8) === "datatype") { + var result166 = "datatype"; + pos += 8; } else { - var result210 = null; + var result166 = null; if (reportMatchFailures) { - matchFailed("\"d\""); + matchFailed("\"datatype\""); } } - if (result210 !== null) { - var result179 = result210; + if (result166 !== null) { + var result156 = result166; } else { - var result179 = null;; + var result156 = null;; }; } - if (result179 !== null) { - if (input.substr(pos, 1) === "A") { - var result209 = "A"; - pos += 1; - } else { - var result209 = null; - if (reportMatchFailures) { - matchFailed("\"A\""); - } - } - if (result209 !== null) { - var result180 = result209; - } else { - if (input.substr(pos, 1) === "a") { - var result208 = "a"; - pos += 1; - } else { - var result208 = null; - if (reportMatchFailures) { - matchFailed("\"a\""); - } - } - if (result208 !== null) { - var result180 = result208; - } else { - var result180 = null;; - }; + if (result156 !== null) { + var result157 = []; + var result165 = parse_WS(); + while (result165 !== null) { + result157.push(result165); + var result165 = parse_WS(); } - if (result180 !== null) { - if (input.substr(pos, 1) === "T") { - var result207 = "T"; + if (result157 !== null) { + if (input.substr(pos, 1) === "(") { + var result158 = "("; pos += 1; } else { - var result207 = null; + var result158 = null; if (reportMatchFailures) { - matchFailed("\"T\""); - } - } - if (result207 !== null) { - var result181 = result207; - } else { - if (input.substr(pos, 1) === "t") { - var result206 = "t"; - pos += 1; - } else { - var result206 = null; - if (reportMatchFailures) { - matchFailed("\"t\""); - } + matchFailed("\"(\""); } - if (result206 !== null) { - var result181 = result206; - } else { - var result181 = null;; - }; } - if (result181 !== null) { - if (input.substr(pos, 1) === "A") { - var result205 = "A"; - pos += 1; - } else { - var result205 = null; - if (reportMatchFailures) { - matchFailed("\"A\""); - } - } - if (result205 !== null) { - var result182 = result205; - } else { - if (input.substr(pos, 1) === "a") { - var result204 = "a"; - pos += 1; - } else { - var result204 = null; - if (reportMatchFailures) { - matchFailed("\"a\""); - } - } - if (result204 !== null) { - var result182 = result204; - } else { - var result182 = null;; - }; + if (result158 !== null) { + var result159 = []; + var result164 = parse_WS(); + while (result164 !== null) { + result159.push(result164); + var result164 = parse_WS(); } - if (result182 !== null) { - if (input.substr(pos, 1) === "T") { - var result203 = "T"; - pos += 1; - } else { - var result203 = null; - if (reportMatchFailures) { - matchFailed("\"T\""); - } - } - if (result203 !== null) { - var result183 = result203; - } else { - if (input.substr(pos, 1) === "t") { - var result202 = "t"; - pos += 1; - } else { - var result202 = null; - if (reportMatchFailures) { - matchFailed("\"t\""); - } - } - if (result202 !== null) { - var result183 = result202; - } else { - var result183 = null;; - }; - } - if (result183 !== null) { - if (input.substr(pos, 1) === "Y") { - var result201 = "Y"; - pos += 1; - } else { - var result201 = null; - if (reportMatchFailures) { - matchFailed("\"Y\""); - } - } - if (result201 !== null) { - var result184 = result201; - } else { - if (input.substr(pos, 1) === "y") { - var result200 = "y"; - pos += 1; - } else { - var result200 = null; - if (reportMatchFailures) { - matchFailed("\"y\""); - } - } - if (result200 !== null) { - var result184 = result200; - } else { - var result184 = null;; - }; + if (result159 !== null) { + var result160 = parse_ConditionalOrExpression(); + if (result160 !== null) { + var result161 = []; + var result163 = parse_WS(); + while (result163 !== null) { + result161.push(result163); + var result163 = parse_WS(); } - if (result184 !== null) { - if (input.substr(pos, 1) === "P") { - var result199 = "P"; + if (result161 !== null) { + if (input.substr(pos, 1) === ")") { + var result162 = ")"; pos += 1; } else { - var result199 = null; + var result162 = null; if (reportMatchFailures) { - matchFailed("\"P\""); - } - } - if (result199 !== null) { - var result185 = result199; - } else { - if (input.substr(pos, 1) === "p") { - var result198 = "p"; - pos += 1; - } else { - var result198 = null; - if (reportMatchFailures) { - matchFailed("\"p\""); - } + matchFailed("\")\""); } - if (result198 !== null) { - var result185 = result198; - } else { - var result185 = null;; - }; } - if (result185 !== null) { - if (input.substr(pos, 1) === "E") { - var result197 = "E"; - pos += 1; - } else { - var result197 = null; - if (reportMatchFailures) { - matchFailed("\"E\""); - } - } - if (result197 !== null) { - var result186 = result197; - } else { - if (input.substr(pos, 1) === "e") { - var result196 = "e"; - pos += 1; - } else { - var result196 = null; - if (reportMatchFailures) { - matchFailed("\"e\""); - } - } - if (result196 !== null) { - var result186 = result196; - } else { - var result186 = null;; - }; - } - if (result186 !== null) { - var result187 = []; - var result195 = parse_WS(); - while (result195 !== null) { - result187.push(result195); - var result195 = parse_WS(); - } - if (result187 !== null) { - if (input.substr(pos, 1) === "(") { - var result188 = "("; - pos += 1; - } else { - var result188 = null; - if (reportMatchFailures) { - matchFailed("\"(\""); - } - } - if (result188 !== null) { - var result189 = []; - var result194 = parse_WS(); - while (result194 !== null) { - result189.push(result194); - var result194 = parse_WS(); - } - if (result189 !== null) { - var result190 = parse_ConditionalOrExpression(); - if (result190 !== null) { - var result191 = []; - var result193 = parse_WS(); - while (result193 !== null) { - result191.push(result193); - var result193 = parse_WS(); - } - if (result191 !== null) { - if (input.substr(pos, 1) === ")") { - var result192 = ")"; - pos += 1; - } else { - var result192 = null; - if (reportMatchFailures) { - matchFailed("\")\""); - } - } - if (result192 !== null) { - var result178 = [result179, result180, result181, result182, result183, result184, result185, result186, result187, result188, result189, result190, result191, result192]; - } else { - var result178 = null; - pos = savedPos12; - } - } else { - var result178 = null; - pos = savedPos12; - } - } else { - var result178 = null; - pos = savedPos12; - } - } else { - var result178 = null; - pos = savedPos12; - } - } else { - var result178 = null; - pos = savedPos12; - } - } else { - var result178 = null; - pos = savedPos12; - } - } else { - var result178 = null; - pos = savedPos12; - } + if (result162 !== null) { + var result154 = [result156, result157, result158, result159, result160, result161, result162]; } else { - var result178 = null; - pos = savedPos12; + var result154 = null; + pos = savedPos22; } } else { - var result178 = null; - pos = savedPos12; + var result154 = null; + pos = savedPos22; } } else { - var result178 = null; - pos = savedPos12; + var result154 = null; + pos = savedPos22; } } else { - var result178 = null; - pos = savedPos12; + var result154 = null; + pos = savedPos22; } } else { - var result178 = null; - pos = savedPos12; + var result154 = null; + pos = savedPos22; } } else { - var result178 = null; - pos = savedPos12; + var result154 = null; + pos = savedPos22; } } else { - var result178 = null; - pos = savedPos12; + var result154 = null; + pos = savedPos22; } - var result177 = result178 !== null + var result155 = result154 !== null ? (function(e) { var ex = {}; ex.token = 'expression' @@ -27241,95 +19797,102 @@ SparqlParser.parser = (function(){ ex.args = [e] return ex; - })(result178[11]) + })(result154[4]) : null; - if (result177 !== null) { - var result0 = result177; + if (result155 !== null) { + var result153 = result155; + } else { + var result153 = null; + pos = savedPos21; + } + if (result153 !== null) { + var result0 = result153; } else { - var savedPos11 = pos; + var savedPos19 = pos; + var savedPos20 = pos; if (input.substr(pos, 5) === "BOUND") { - var result167 = "BOUND"; + var result143 = "BOUND"; pos += 5; } else { - var result167 = null; + var result143 = null; if (reportMatchFailures) { matchFailed("\"BOUND\""); } } - if (result167 !== null) { - var result168 = []; - var result176 = parse_WS(); - while (result176 !== null) { - result168.push(result176); - var result176 = parse_WS(); + if (result143 !== null) { + var result144 = []; + var result152 = parse_WS(); + while (result152 !== null) { + result144.push(result152); + var result152 = parse_WS(); } - if (result168 !== null) { + if (result144 !== null) { if (input.substr(pos, 1) === "(") { - var result169 = "("; + var result145 = "("; pos += 1; } else { - var result169 = null; + var result145 = null; if (reportMatchFailures) { matchFailed("\"(\""); } } - if (result169 !== null) { - var result170 = []; - var result175 = parse_WS(); - while (result175 !== null) { - result170.push(result175); - var result175 = parse_WS(); + if (result145 !== null) { + var result146 = []; + var result151 = parse_WS(); + while (result151 !== null) { + result146.push(result151); + var result151 = parse_WS(); } - if (result170 !== null) { - var result171 = parse_Var(); - if (result171 !== null) { - var result172 = []; - var result174 = parse_WS(); - while (result174 !== null) { - result172.push(result174); - var result174 = parse_WS(); + if (result146 !== null) { + var result147 = parse_Var(); + if (result147 !== null) { + var result148 = []; + var result150 = parse_WS(); + while (result150 !== null) { + result148.push(result150); + var result150 = parse_WS(); } - if (result172 !== null) { + if (result148 !== null) { if (input.substr(pos, 1) === ")") { - var result173 = ")"; + var result149 = ")"; pos += 1; } else { - var result173 = null; + var result149 = null; if (reportMatchFailures) { matchFailed("\")\""); } } - if (result173 !== null) { - var result166 = [result167, result168, result169, result170, result171, result172, result173]; + if (result149 !== null) { + var result141 = [result143, result144, result145, result146, result147, result148, result149]; } else { - var result166 = null; - pos = savedPos11; + var result141 = null; + pos = savedPos20; } } else { - var result166 = null; - pos = savedPos11; + var result141 = null; + pos = savedPos20; } } else { - var result166 = null; - pos = savedPos11; + var result141 = null; + pos = savedPos20; } } else { - var result166 = null; - pos = savedPos11; + var result141 = null; + pos = savedPos20; } } else { - var result166 = null; - pos = savedPos11; + var result141 = null; + pos = savedPos20; } } else { - var result166 = null; - pos = savedPos11; + var result141 = null; + pos = savedPos20; } } else { - var result166 = null; - pos = savedPos11; + var result141 = null; + pos = savedPos20; } - var result165 = result166 !== null + var result142 = result141 !== null ? (function(v) { var ex = {}; ex.token = 'expression' @@ -27338,95 +19901,102 @@ SparqlParser.parser = (function(){ ex.args = [v] return ex; - })(result166[4]) + })(result141[4]) : null; - if (result165 !== null) { - var result0 = result165; + if (result142 !== null) { + var result140 = result142; + } else { + var result140 = null; + pos = savedPos19; + } + if (result140 !== null) { + var result0 = result140; } else { - var savedPos10 = pos; + var savedPos17 = pos; + var savedPos18 = pos; if (input.substr(pos, 3) === "IRI") { - var result155 = "IRI"; + var result130 = "IRI"; pos += 3; } else { - var result155 = null; + var result130 = null; if (reportMatchFailures) { matchFailed("\"IRI\""); } } - if (result155 !== null) { - var result156 = []; - var result164 = parse_WS(); - while (result164 !== null) { - result156.push(result164); - var result164 = parse_WS(); + if (result130 !== null) { + var result131 = []; + var result139 = parse_WS(); + while (result139 !== null) { + result131.push(result139); + var result139 = parse_WS(); } - if (result156 !== null) { + if (result131 !== null) { if (input.substr(pos, 1) === "(") { - var result157 = "("; + var result132 = "("; pos += 1; } else { - var result157 = null; + var result132 = null; if (reportMatchFailures) { matchFailed("\"(\""); } } - if (result157 !== null) { - var result158 = []; - var result163 = parse_WS(); - while (result163 !== null) { - result158.push(result163); - var result163 = parse_WS(); + if (result132 !== null) { + var result133 = []; + var result138 = parse_WS(); + while (result138 !== null) { + result133.push(result138); + var result138 = parse_WS(); } - if (result158 !== null) { - var result159 = parse_ConditionalOrExpression(); - if (result159 !== null) { - var result160 = []; - var result162 = parse_WS(); - while (result162 !== null) { - result160.push(result162); - var result162 = parse_WS(); + if (result133 !== null) { + var result134 = parse_ConditionalOrExpression(); + if (result134 !== null) { + var result135 = []; + var result137 = parse_WS(); + while (result137 !== null) { + result135.push(result137); + var result137 = parse_WS(); } - if (result160 !== null) { + if (result135 !== null) { if (input.substr(pos, 1) === ")") { - var result161 = ")"; + var result136 = ")"; pos += 1; } else { - var result161 = null; + var result136 = null; if (reportMatchFailures) { matchFailed("\")\""); } } - if (result161 !== null) { - var result154 = [result155, result156, result157, result158, result159, result160, result161]; + if (result136 !== null) { + var result128 = [result130, result131, result132, result133, result134, result135, result136]; } else { - var result154 = null; - pos = savedPos10; + var result128 = null; + pos = savedPos18; } } else { - var result154 = null; - pos = savedPos10; + var result128 = null; + pos = savedPos18; } } else { - var result154 = null; - pos = savedPos10; + var result128 = null; + pos = savedPos18; } } else { - var result154 = null; - pos = savedPos10; + var result128 = null; + pos = savedPos18; } } else { - var result154 = null; - pos = savedPos10; + var result128 = null; + pos = savedPos18; } } else { - var result154 = null; - pos = savedPos10; + var result128 = null; + pos = savedPos18; } } else { - var result154 = null; - pos = savedPos10; + var result128 = null; + pos = savedPos18; } - var result153 = result154 !== null + var result129 = result128 !== null ? (function(e) { var ex = {}; ex.token = 'expression'; @@ -27435,95 +20005,102 @@ SparqlParser.parser = (function(){ ex.args = [e]; return ex; - })(result154[4]) + })(result128[4]) : null; - if (result153 !== null) { - var result0 = result153; + if (result129 !== null) { + var result127 = result129; } else { - var savedPos9 = pos; + var result127 = null; + pos = savedPos17; + } + if (result127 !== null) { + var result0 = result127; + } else { + var savedPos15 = pos; + var savedPos16 = pos; if (input.substr(pos, 3) === "URI") { - var result143 = "URI"; + var result117 = "URI"; pos += 3; } else { - var result143 = null; + var result117 = null; if (reportMatchFailures) { matchFailed("\"URI\""); } } - if (result143 !== null) { - var result144 = []; - var result152 = parse_WS(); - while (result152 !== null) { - result144.push(result152); - var result152 = parse_WS(); + if (result117 !== null) { + var result118 = []; + var result126 = parse_WS(); + while (result126 !== null) { + result118.push(result126); + var result126 = parse_WS(); } - if (result144 !== null) { + if (result118 !== null) { if (input.substr(pos, 1) === "(") { - var result145 = "("; + var result119 = "("; pos += 1; } else { - var result145 = null; + var result119 = null; if (reportMatchFailures) { matchFailed("\"(\""); } } - if (result145 !== null) { - var result146 = []; - var result151 = parse_WS(); - while (result151 !== null) { - result146.push(result151); - var result151 = parse_WS(); + if (result119 !== null) { + var result120 = []; + var result125 = parse_WS(); + while (result125 !== null) { + result120.push(result125); + var result125 = parse_WS(); } - if (result146 !== null) { - var result147 = parse_ConditionalOrExpression(); - if (result147 !== null) { - var result148 = []; - var result150 = parse_WS(); - while (result150 !== null) { - result148.push(result150); - var result150 = parse_WS(); + if (result120 !== null) { + var result121 = parse_ConditionalOrExpression(); + if (result121 !== null) { + var result122 = []; + var result124 = parse_WS(); + while (result124 !== null) { + result122.push(result124); + var result124 = parse_WS(); } - if (result148 !== null) { + if (result122 !== null) { if (input.substr(pos, 1) === ")") { - var result149 = ")"; + var result123 = ")"; pos += 1; } else { - var result149 = null; + var result123 = null; if (reportMatchFailures) { matchFailed("\")\""); } } - if (result149 !== null) { - var result142 = [result143, result144, result145, result146, result147, result148, result149]; + if (result123 !== null) { + var result115 = [result117, result118, result119, result120, result121, result122, result123]; } else { - var result142 = null; - pos = savedPos9; + var result115 = null; + pos = savedPos16; } } else { - var result142 = null; - pos = savedPos9; + var result115 = null; + pos = savedPos16; } } else { - var result142 = null; - pos = savedPos9; + var result115 = null; + pos = savedPos16; } } else { - var result142 = null; - pos = savedPos9; + var result115 = null; + pos = savedPos16; } } else { - var result142 = null; - pos = savedPos9; + var result115 = null; + pos = savedPos16; } } else { - var result142 = null; - pos = savedPos9; + var result115 = null; + pos = savedPos16; } } else { - var result142 = null; - pos = savedPos9; + var result115 = null; + pos = savedPos16; } - var result141 = result142 !== null + var result116 = result115 !== null ? (function(e) { var ex = {}; ex.token = 'expression'; @@ -27532,112 +20109,119 @@ SparqlParser.parser = (function(){ ex.args = [e]; return ex; - })(result142[4]) + })(result115[4]) : null; - if (result141 !== null) { - var result0 = result141; + if (result116 !== null) { + var result114 = result116; + } else { + var result114 = null; + pos = savedPos15; + } + if (result114 !== null) { + var result0 = result114; } else { - var savedPos7 = pos; + var savedPos12 = pos; + var savedPos13 = pos; if (input.substr(pos, 5) === "BNODE") { - var result128 = "BNODE"; + var result101 = "BNODE"; pos += 5; } else { - var result128 = null; + var result101 = null; if (reportMatchFailures) { matchFailed("\"BNODE\""); } } - if (result128 !== null) { - var result129 = []; - var result140 = parse_WS(); - while (result140 !== null) { - result129.push(result140); - var result140 = parse_WS(); + if (result101 !== null) { + var result102 = []; + var result113 = parse_WS(); + while (result113 !== null) { + result102.push(result113); + var result113 = parse_WS(); } - if (result129 !== null) { - var savedPos8 = pos; + if (result102 !== null) { + var savedPos14 = pos; if (input.substr(pos, 1) === "(") { - var result133 = "("; + var result106 = "("; pos += 1; } else { - var result133 = null; + var result106 = null; if (reportMatchFailures) { matchFailed("\"(\""); } } - if (result133 !== null) { - var result134 = []; - var result139 = parse_WS(); - while (result139 !== null) { - result134.push(result139); - var result139 = parse_WS(); + if (result106 !== null) { + var result107 = []; + var result112 = parse_WS(); + while (result112 !== null) { + result107.push(result112); + var result112 = parse_WS(); } - if (result134 !== null) { - var result135 = parse_ConditionalOrExpression(); - if (result135 !== null) { - var result136 = []; - var result138 = parse_WS(); - while (result138 !== null) { - result136.push(result138); - var result138 = parse_WS(); + if (result107 !== null) { + var result108 = parse_ConditionalOrExpression(); + if (result108 !== null) { + var result109 = []; + var result111 = parse_WS(); + while (result111 !== null) { + result109.push(result111); + var result111 = parse_WS(); } - if (result136 !== null) { + if (result109 !== null) { if (input.substr(pos, 1) === ")") { - var result137 = ")"; + var result110 = ")"; pos += 1; } else { - var result137 = null; + var result110 = null; if (reportMatchFailures) { matchFailed("\")\""); } } - if (result137 !== null) { - var result132 = [result133, result134, result135, result136, result137]; + if (result110 !== null) { + var result105 = [result106, result107, result108, result109, result110]; } else { - var result132 = null; - pos = savedPos8; + var result105 = null; + pos = savedPos14; } } else { - var result132 = null; - pos = savedPos8; + var result105 = null; + pos = savedPos14; } } else { - var result132 = null; - pos = savedPos8; + var result105 = null; + pos = savedPos14; } } else { - var result132 = null; - pos = savedPos8; + var result105 = null; + pos = savedPos14; } } else { - var result132 = null; - pos = savedPos8; + var result105 = null; + pos = savedPos14; } - if (result132 !== null) { - var result130 = result132; + if (result105 !== null) { + var result103 = result105; } else { - var result131 = parse_NIL(); - if (result131 !== null) { - var result130 = result131; + var result104 = parse_NIL(); + if (result104 !== null) { + var result103 = result104; } else { - var result130 = null;; + var result103 = null;; }; } - if (result130 !== null) { - var result127 = [result128, result129, result130]; + if (result103 !== null) { + var result99 = [result101, result102, result103]; } else { - var result127 = null; - pos = savedPos7; + var result99 = null; + pos = savedPos13; } } else { - var result127 = null; - pos = savedPos7; + var result99 = null; + pos = savedPos13; } } else { - var result127 = null; - pos = savedPos7; + var result99 = null; + pos = savedPos13; } - var result126 = result127 !== null + var result100 = result99 !== null ? (function(arg) { var ex = {}; ex.token = 'expression'; @@ -27650,45 +20234,52 @@ SparqlParser.parser = (function(){ } return ex; - })(result127[2]) + })(result99[2]) : null; - if (result126 !== null) { - var result0 = result126; + if (result100 !== null) { + var result98 = result100; } else { - var savedPos6 = pos; + var result98 = null; + pos = savedPos12; + } + if (result98 !== null) { + var result0 = result98; + } else { + var savedPos10 = pos; + var savedPos11 = pos; if (input.substr(pos, 8) === "COALESCE") { - var result122 = "COALESCE"; + var result94 = "COALESCE"; pos += 8; } else { - var result122 = null; + var result94 = null; if (reportMatchFailures) { matchFailed("\"COALESCE\""); } } - if (result122 !== null) { - var result123 = []; - var result125 = parse_WS(); - while (result125 !== null) { - result123.push(result125); - var result125 = parse_WS(); + if (result94 !== null) { + var result95 = []; + var result97 = parse_WS(); + while (result97 !== null) { + result95.push(result97); + var result97 = parse_WS(); } - if (result123 !== null) { - var result124 = parse_ExpressionList(); - if (result124 !== null) { - var result121 = [result122, result123, result124]; + if (result95 !== null) { + var result96 = parse_ExpressionList(); + if (result96 !== null) { + var result92 = [result94, result95, result96]; } else { - var result121 = null; - pos = savedPos6; + var result92 = null; + pos = savedPos11; } } else { - var result121 = null; - pos = savedPos6; + var result92 = null; + pos = savedPos11; } } else { - var result121 = null; - pos = savedPos6; + var result92 = null; + pos = savedPos11; } - var result120 = result121 !== null + var result93 = result92 !== null ? (function(args) { var ex = {}; ex.token = 'expression'; @@ -27697,179 +20288,186 @@ SparqlParser.parser = (function(){ ex.args = args; return ex; - })(result121[2]) + })(result92[2]) : null; - if (result120 !== null) { - var result0 = result120; + if (result93 !== null) { + var result91 = result93; + } else { + var result91 = null; + pos = savedPos10; + } + if (result91 !== null) { + var result0 = result91; } else { - var savedPos5 = pos; + var savedPos8 = pos; + var savedPos9 = pos; if (input.substr(pos, 2) === "IF") { - var result98 = "IF"; + var result69 = "IF"; pos += 2; } else { - var result98 = null; + var result69 = null; if (reportMatchFailures) { matchFailed("\"IF\""); } } - if (result98 !== null) { - var result99 = []; - var result119 = parse_WS(); - while (result119 !== null) { - result99.push(result119); - var result119 = parse_WS(); + if (result69 !== null) { + var result70 = []; + var result90 = parse_WS(); + while (result90 !== null) { + result70.push(result90); + var result90 = parse_WS(); } - if (result99 !== null) { + if (result70 !== null) { if (input.substr(pos, 1) === "(") { - var result100 = "("; + var result71 = "("; pos += 1; } else { - var result100 = null; + var result71 = null; if (reportMatchFailures) { matchFailed("\"(\""); } } - if (result100 !== null) { - var result101 = []; - var result118 = parse_WS(); - while (result118 !== null) { - result101.push(result118); - var result118 = parse_WS(); + if (result71 !== null) { + var result72 = []; + var result89 = parse_WS(); + while (result89 !== null) { + result72.push(result89); + var result89 = parse_WS(); } - if (result101 !== null) { - var result102 = parse_ConditionalOrExpression(); - if (result102 !== null) { - var result103 = []; - var result117 = parse_WS(); - while (result117 !== null) { - result103.push(result117); - var result117 = parse_WS(); + if (result72 !== null) { + var result73 = parse_ConditionalOrExpression(); + if (result73 !== null) { + var result74 = []; + var result88 = parse_WS(); + while (result88 !== null) { + result74.push(result88); + var result88 = parse_WS(); } - if (result103 !== null) { + if (result74 !== null) { if (input.substr(pos, 1) === ",") { - var result104 = ","; + var result75 = ","; pos += 1; } else { - var result104 = null; + var result75 = null; if (reportMatchFailures) { matchFailed("\",\""); } } - if (result104 !== null) { - var result105 = []; - var result116 = parse_WS(); - while (result116 !== null) { - result105.push(result116); - var result116 = parse_WS(); + if (result75 !== null) { + var result76 = []; + var result87 = parse_WS(); + while (result87 !== null) { + result76.push(result87); + var result87 = parse_WS(); } - if (result105 !== null) { - var result106 = parse_ConditionalOrExpression(); - if (result106 !== null) { - var result107 = []; - var result115 = parse_WS(); - while (result115 !== null) { - result107.push(result115); - var result115 = parse_WS(); + if (result76 !== null) { + var result77 = parse_ConditionalOrExpression(); + if (result77 !== null) { + var result78 = []; + var result86 = parse_WS(); + while (result86 !== null) { + result78.push(result86); + var result86 = parse_WS(); } - if (result107 !== null) { + if (result78 !== null) { if (input.substr(pos, 1) === ",") { - var result108 = ","; + var result79 = ","; pos += 1; } else { - var result108 = null; + var result79 = null; if (reportMatchFailures) { matchFailed("\",\""); } } - if (result108 !== null) { - var result109 = []; - var result114 = parse_WS(); - while (result114 !== null) { - result109.push(result114); - var result114 = parse_WS(); + if (result79 !== null) { + var result80 = []; + var result85 = parse_WS(); + while (result85 !== null) { + result80.push(result85); + var result85 = parse_WS(); } - if (result109 !== null) { - var result110 = parse_ConditionalOrExpression(); - if (result110 !== null) { - var result111 = []; - var result113 = parse_WS(); - while (result113 !== null) { - result111.push(result113); - var result113 = parse_WS(); + if (result80 !== null) { + var result81 = parse_ConditionalOrExpression(); + if (result81 !== null) { + var result82 = []; + var result84 = parse_WS(); + while (result84 !== null) { + result82.push(result84); + var result84 = parse_WS(); } - if (result111 !== null) { + if (result82 !== null) { if (input.substr(pos, 1) === ")") { - var result112 = ")"; + var result83 = ")"; pos += 1; } else { - var result112 = null; + var result83 = null; if (reportMatchFailures) { matchFailed("\")\""); } } - if (result112 !== null) { - var result97 = [result98, result99, result100, result101, result102, result103, result104, result105, result106, result107, result108, result109, result110, result111, result112]; + if (result83 !== null) { + var result67 = [result69, result70, result71, result72, result73, result74, result75, result76, result77, result78, result79, result80, result81, result82, result83]; } else { - var result97 = null; - pos = savedPos5; + var result67 = null; + pos = savedPos9; } } else { - var result97 = null; - pos = savedPos5; + var result67 = null; + pos = savedPos9; } } else { - var result97 = null; - pos = savedPos5; + var result67 = null; + pos = savedPos9; } } else { - var result97 = null; - pos = savedPos5; + var result67 = null; + pos = savedPos9; } } else { - var result97 = null; - pos = savedPos5; + var result67 = null; + pos = savedPos9; } } else { - var result97 = null; - pos = savedPos5; + var result67 = null; + pos = savedPos9; } } else { - var result97 = null; - pos = savedPos5; + var result67 = null; + pos = savedPos9; } } else { - var result97 = null; - pos = savedPos5; + var result67 = null; + pos = savedPos9; } } else { - var result97 = null; - pos = savedPos5; + var result67 = null; + pos = savedPos9; } } else { - var result97 = null; - pos = savedPos5; + var result67 = null; + pos = savedPos9; } } else { - var result97 = null; - pos = savedPos5; + var result67 = null; + pos = savedPos9; } } else { - var result97 = null; - pos = savedPos5; + var result67 = null; + pos = savedPos9; } } else { - var result97 = null; - pos = savedPos5; + var result67 = null; + pos = savedPos9; } } else { - var result97 = null; - pos = savedPos5; + var result67 = null; + pos = savedPos9; } } else { - var result97 = null; - pos = savedPos5; + var result67 = null; + pos = savedPos9; } - var result96 = result97 !== null + var result68 = result67 !== null ? (function(test, trueCond, falseCond) { var ex = {}; ex.token = 'expression'; @@ -27878,95 +20476,102 @@ SparqlParser.parser = (function(){ ex.args = [test,trueCond,falseCond]; return ex; - })(result97[4], result97[8], result97[12]) + })(result67[4], result67[8], result67[12]) : null; - if (result96 !== null) { - var result0 = result96; + if (result68 !== null) { + var result66 = result68; + } else { + var result66 = null; + pos = savedPos8; + } + if (result66 !== null) { + var result0 = result66; } else { - var savedPos4 = pos; + var savedPos6 = pos; + var savedPos7 = pos; if (input.substr(pos, 9) === "ISLITERAL") { - var result86 = "ISLITERAL"; + var result56 = "ISLITERAL"; pos += 9; } else { - var result86 = null; + var result56 = null; if (reportMatchFailures) { matchFailed("\"ISLITERAL\""); } } - if (result86 !== null) { - var result87 = []; - var result95 = parse_WS(); - while (result95 !== null) { - result87.push(result95); - var result95 = parse_WS(); + if (result56 !== null) { + var result57 = []; + var result65 = parse_WS(); + while (result65 !== null) { + result57.push(result65); + var result65 = parse_WS(); } - if (result87 !== null) { + if (result57 !== null) { if (input.substr(pos, 1) === "(") { - var result88 = "("; + var result58 = "("; pos += 1; } else { - var result88 = null; + var result58 = null; if (reportMatchFailures) { matchFailed("\"(\""); } } - if (result88 !== null) { - var result89 = []; - var result94 = parse_WS(); - while (result94 !== null) { - result89.push(result94); - var result94 = parse_WS(); + if (result58 !== null) { + var result59 = []; + var result64 = parse_WS(); + while (result64 !== null) { + result59.push(result64); + var result64 = parse_WS(); } - if (result89 !== null) { - var result90 = parse_ConditionalOrExpression(); - if (result90 !== null) { - var result91 = []; - var result93 = parse_WS(); - while (result93 !== null) { - result91.push(result93); - var result93 = parse_WS(); + if (result59 !== null) { + var result60 = parse_ConditionalOrExpression(); + if (result60 !== null) { + var result61 = []; + var result63 = parse_WS(); + while (result63 !== null) { + result61.push(result63); + var result63 = parse_WS(); } - if (result91 !== null) { + if (result61 !== null) { if (input.substr(pos, 1) === ")") { - var result92 = ")"; + var result62 = ")"; pos += 1; } else { - var result92 = null; + var result62 = null; if (reportMatchFailures) { matchFailed("\")\""); } } - if (result92 !== null) { - var result85 = [result86, result87, result88, result89, result90, result91, result92]; + if (result62 !== null) { + var result54 = [result56, result57, result58, result59, result60, result61, result62]; } else { - var result85 = null; - pos = savedPos4; + var result54 = null; + pos = savedPos7; } } else { - var result85 = null; - pos = savedPos4; + var result54 = null; + pos = savedPos7; } } else { - var result85 = null; - pos = savedPos4; + var result54 = null; + pos = savedPos7; } } else { - var result85 = null; - pos = savedPos4; + var result54 = null; + pos = savedPos7; } } else { - var result85 = null; - pos = savedPos4; + var result54 = null; + pos = savedPos7; } } else { - var result85 = null; - pos = savedPos4; + var result54 = null; + pos = savedPos7; } } else { - var result85 = null; - pos = savedPos4; + var result54 = null; + pos = savedPos7; } - var result84 = result85 !== null + var result55 = result54 !== null ? (function(arg) { var ex = {}; ex.token = 'expression'; @@ -27975,95 +20580,102 @@ SparqlParser.parser = (function(){ ex.args = [arg]; return ex; - })(result85[4]) + })(result54[4]) : null; - if (result84 !== null) { - var result0 = result84; + if (result55 !== null) { + var result53 = result55; + } else { + var result53 = null; + pos = savedPos6; + } + if (result53 !== null) { + var result0 = result53; } else { - var savedPos3 = pos; + var savedPos4 = pos; + var savedPos5 = pos; if (input.substr(pos, 7) === "ISBLANK") { - var result74 = "ISBLANK"; + var result43 = "ISBLANK"; pos += 7; } else { - var result74 = null; + var result43 = null; if (reportMatchFailures) { matchFailed("\"ISBLANK\""); } } - if (result74 !== null) { - var result75 = []; - var result83 = parse_WS(); - while (result83 !== null) { - result75.push(result83); - var result83 = parse_WS(); + if (result43 !== null) { + var result44 = []; + var result52 = parse_WS(); + while (result52 !== null) { + result44.push(result52); + var result52 = parse_WS(); } - if (result75 !== null) { + if (result44 !== null) { if (input.substr(pos, 1) === "(") { - var result76 = "("; + var result45 = "("; pos += 1; } else { - var result76 = null; + var result45 = null; if (reportMatchFailures) { matchFailed("\"(\""); } } - if (result76 !== null) { - var result77 = []; - var result82 = parse_WS(); - while (result82 !== null) { - result77.push(result82); - var result82 = parse_WS(); + if (result45 !== null) { + var result46 = []; + var result51 = parse_WS(); + while (result51 !== null) { + result46.push(result51); + var result51 = parse_WS(); } - if (result77 !== null) { - var result78 = parse_ConditionalOrExpression(); - if (result78 !== null) { - var result79 = []; - var result81 = parse_WS(); - while (result81 !== null) { - result79.push(result81); - var result81 = parse_WS(); + if (result46 !== null) { + var result47 = parse_ConditionalOrExpression(); + if (result47 !== null) { + var result48 = []; + var result50 = parse_WS(); + while (result50 !== null) { + result48.push(result50); + var result50 = parse_WS(); } - if (result79 !== null) { + if (result48 !== null) { if (input.substr(pos, 1) === ")") { - var result80 = ")"; + var result49 = ")"; pos += 1; } else { - var result80 = null; + var result49 = null; if (reportMatchFailures) { matchFailed("\")\""); } } - if (result80 !== null) { - var result73 = [result74, result75, result76, result77, result78, result79, result80]; + if (result49 !== null) { + var result41 = [result43, result44, result45, result46, result47, result48, result49]; } else { - var result73 = null; - pos = savedPos3; + var result41 = null; + pos = savedPos5; } } else { - var result73 = null; - pos = savedPos3; + var result41 = null; + pos = savedPos5; } } else { - var result73 = null; - pos = savedPos3; + var result41 = null; + pos = savedPos5; } } else { - var result73 = null; - pos = savedPos3; + var result41 = null; + pos = savedPos5; } } else { - var result73 = null; - pos = savedPos3; + var result41 = null; + pos = savedPos5; } } else { - var result73 = null; - pos = savedPos3; + var result41 = null; + pos = savedPos5; } } else { - var result73 = null; - pos = savedPos3; + var result41 = null; + pos = savedPos5; } - var result72 = result73 !== null + var result42 = result41 !== null ? (function(arg) { var ex = {}; ex.token = 'expression'; @@ -28072,137 +20684,144 @@ SparqlParser.parser = (function(){ ex.args = [arg]; return ex; - })(result73[4]) + })(result41[4]) : null; - if (result72 !== null) { - var result0 = result72; + if (result42 !== null) { + var result40 = result42; + } else { + var result40 = null; + pos = savedPos4; + } + if (result40 !== null) { + var result0 = result40; } else { var savedPos2 = pos; + var savedPos3 = pos; if (input.substr(pos, 8) === "SAMETERM") { - var result56 = "SAMETERM"; + var result24 = "SAMETERM"; pos += 8; } else { - var result56 = null; + var result24 = null; if (reportMatchFailures) { matchFailed("\"SAMETERM\""); } } - if (result56 !== null) { - var result57 = []; - var result71 = parse_WS(); - while (result71 !== null) { - result57.push(result71); - var result71 = parse_WS(); + if (result24 !== null) { + var result25 = []; + var result39 = parse_WS(); + while (result39 !== null) { + result25.push(result39); + var result39 = parse_WS(); } - if (result57 !== null) { + if (result25 !== null) { if (input.substr(pos, 1) === "(") { - var result58 = "("; + var result26 = "("; pos += 1; } else { - var result58 = null; + var result26 = null; if (reportMatchFailures) { matchFailed("\"(\""); } } - if (result58 !== null) { - var result59 = []; - var result70 = parse_WS(); - while (result70 !== null) { - result59.push(result70); - var result70 = parse_WS(); + if (result26 !== null) { + var result27 = []; + var result38 = parse_WS(); + while (result38 !== null) { + result27.push(result38); + var result38 = parse_WS(); } - if (result59 !== null) { - var result60 = parse_ConditionalOrExpression(); - if (result60 !== null) { - var result61 = []; - var result69 = parse_WS(); - while (result69 !== null) { - result61.push(result69); - var result69 = parse_WS(); + if (result27 !== null) { + var result28 = parse_ConditionalOrExpression(); + if (result28 !== null) { + var result29 = []; + var result37 = parse_WS(); + while (result37 !== null) { + result29.push(result37); + var result37 = parse_WS(); } - if (result61 !== null) { + if (result29 !== null) { if (input.substr(pos, 1) === ",") { - var result62 = ","; + var result30 = ","; pos += 1; } else { - var result62 = null; + var result30 = null; if (reportMatchFailures) { matchFailed("\",\""); } } - if (result62 !== null) { - var result63 = []; - var result68 = parse_WS(); - while (result68 !== null) { - result63.push(result68); - var result68 = parse_WS(); + if (result30 !== null) { + var result31 = []; + var result36 = parse_WS(); + while (result36 !== null) { + result31.push(result36); + var result36 = parse_WS(); } - if (result63 !== null) { - var result64 = parse_ConditionalOrExpression(); - if (result64 !== null) { - var result65 = []; - var result67 = parse_WS(); - while (result67 !== null) { - result65.push(result67); - var result67 = parse_WS(); + if (result31 !== null) { + var result32 = parse_ConditionalOrExpression(); + if (result32 !== null) { + var result33 = []; + var result35 = parse_WS(); + while (result35 !== null) { + result33.push(result35); + var result35 = parse_WS(); } - if (result65 !== null) { + if (result33 !== null) { if (input.substr(pos, 1) === ")") { - var result66 = ")"; + var result34 = ")"; pos += 1; } else { - var result66 = null; + var result34 = null; if (reportMatchFailures) { matchFailed("\")\""); } } - if (result66 !== null) { - var result55 = [result56, result57, result58, result59, result60, result61, result62, result63, result64, result65, result66]; + if (result34 !== null) { + var result22 = [result24, result25, result26, result27, result28, result29, result30, result31, result32, result33, result34]; } else { - var result55 = null; - pos = savedPos2; + var result22 = null; + pos = savedPos3; } } else { - var result55 = null; - pos = savedPos2; + var result22 = null; + pos = savedPos3; } } else { - var result55 = null; - pos = savedPos2; + var result22 = null; + pos = savedPos3; } } else { - var result55 = null; - pos = savedPos2; + var result22 = null; + pos = savedPos3; } } else { - var result55 = null; - pos = savedPos2; + var result22 = null; + pos = savedPos3; } } else { - var result55 = null; - pos = savedPos2; + var result22 = null; + pos = savedPos3; } } else { - var result55 = null; - pos = savedPos2; + var result22 = null; + pos = savedPos3; } } else { - var result55 = null; - pos = savedPos2; + var result22 = null; + pos = savedPos3; } } else { - var result55 = null; - pos = savedPos2; + var result22 = null; + pos = savedPos3; } } else { - var result55 = null; - pos = savedPos2; + var result22 = null; + pos = savedPos3; } } else { - var result55 = null; - pos = savedPos2; + var result22 = null; + pos = savedPos3; } - var result54 = result55 !== null + var result23 = result22 !== null ? (function(e1, e2) { var ex = {}; ex.token = 'expression'; @@ -28210,241 +20829,146 @@ SparqlParser.parser = (function(){ ex.builtincall = 'sameterm'; ex.args = [e1, e2]; return ex; - })(result55[4], result55[8]) + })(result22[4], result22[8]) : null; - if (result54 !== null) { - var result0 = result54; + if (result23 !== null) { + var result21 = result23; + } else { + var result21 = null; + pos = savedPos2; + } + if (result21 !== null) { + var result0 = result21; } else { + var savedPos0 = pos; var savedPos1 = pos; - if (input.substr(pos, 1) === "I") { - var result53 = "I"; - pos += 1; + if (input.substr(pos, 5) === "ISURI") { + var result20 = "ISURI"; + pos += 5; } else { - var result53 = null; + var result20 = null; if (reportMatchFailures) { - matchFailed("\"I\""); + matchFailed("\"ISURI\""); } } - if (result53 !== null) { - var result30 = result53; + if (result20 !== null) { + var result7 = result20; } else { - if (input.substr(pos, 1) === "i") { - var result52 = "i"; - pos += 1; - } else { - var result52 = null; - if (reportMatchFailures) { - matchFailed("\"i\""); - } - } - if (result52 !== null) { - var result30 = result52; - } else { - var result30 = null;; - }; - } - if (result30 !== null) { - if (input.substr(pos, 1) === "S") { - var result51 = "S"; - pos += 1; + if (input.substr(pos, 5) === "isuri") { + var result19 = "isuri"; + pos += 5; } else { - var result51 = null; + var result19 = null; if (reportMatchFailures) { - matchFailed("\"S\""); + matchFailed("\"isuri\""); } } - if (result51 !== null) { - var result31 = result51; + if (result19 !== null) { + var result7 = result19; } else { - if (input.substr(pos, 1) === "s") { - var result50 = "s"; - pos += 1; - } else { - var result50 = null; - if (reportMatchFailures) { - matchFailed("\"s\""); - } - } - if (result50 !== null) { - var result31 = result50; - } else { - var result31 = null;; - }; - } - if (result31 !== null) { - if (input.substr(pos, 1) === "U") { - var result49 = "U"; - pos += 1; + if (input.substr(pos, 5) === "ISIRI") { + var result18 = "ISIRI"; + pos += 5; } else { - var result49 = null; + var result18 = null; if (reportMatchFailures) { - matchFailed("\"U\""); + matchFailed("\"ISIRI\""); } } - if (result49 !== null) { - var result32 = result49; + if (result18 !== null) { + var result7 = result18; } else { - if (input.substr(pos, 1) === "u") { - var result48 = "u"; - pos += 1; + if (input.substr(pos, 5) === "isiri") { + var result17 = "isiri"; + pos += 5; } else { - var result48 = null; + var result17 = null; if (reportMatchFailures) { - matchFailed("\"u\""); + matchFailed("\"isiri\""); } } - if (result48 !== null) { - var result32 = result48; + if (result17 !== null) { + var result7 = result17; } else { - var result32 = null;; + var result7 = null;; }; - } - if (result32 !== null) { - if (input.substr(pos, 1) === "R") { - var result47 = "R"; - pos += 1; - } else { - var result47 = null; - if (reportMatchFailures) { - matchFailed("\"R\""); - } + }; + }; + } + if (result7 !== null) { + var result8 = []; + var result16 = parse_WS(); + while (result16 !== null) { + result8.push(result16); + var result16 = parse_WS(); + } + if (result8 !== null) { + if (input.substr(pos, 1) === "(") { + var result9 = "("; + pos += 1; + } else { + var result9 = null; + if (reportMatchFailures) { + matchFailed("\"(\""); } - if (result47 !== null) { - var result33 = result47; - } else { - if (input.substr(pos, 1) === "r") { - var result46 = "r"; - pos += 1; - } else { - var result46 = null; - if (reportMatchFailures) { - matchFailed("\"r\""); - } - } - if (result46 !== null) { - var result33 = result46; - } else { - var result33 = null;; - }; + } + if (result9 !== null) { + var result10 = []; + var result15 = parse_WS(); + while (result15 !== null) { + result10.push(result15); + var result15 = parse_WS(); } - if (result33 !== null) { - if (input.substr(pos, 1) === "I") { - var result45 = "I"; - pos += 1; - } else { - var result45 = null; - if (reportMatchFailures) { - matchFailed("\"I\""); - } - } - if (result45 !== null) { - var result34 = result45; - } else { - if (input.substr(pos, 1) === "i") { - var result44 = "i"; - pos += 1; - } else { - var result44 = null; - if (reportMatchFailures) { - matchFailed("\"i\""); - } - } - if (result44 !== null) { - var result34 = result44; - } else { - var result34 = null;; - }; - } - if (result34 !== null) { - var result35 = []; - var result43 = parse_WS(); - while (result43 !== null) { - result35.push(result43); - var result43 = parse_WS(); + if (result10 !== null) { + var result11 = parse_ConditionalOrExpression(); + if (result11 !== null) { + var result12 = []; + var result14 = parse_WS(); + while (result14 !== null) { + result12.push(result14); + var result14 = parse_WS(); } - if (result35 !== null) { - if (input.substr(pos, 1) === "(") { - var result36 = "("; + if (result12 !== null) { + if (input.substr(pos, 1) === ")") { + var result13 = ")"; pos += 1; } else { - var result36 = null; + var result13 = null; if (reportMatchFailures) { - matchFailed("\"(\""); + matchFailed("\")\""); } } - if (result36 !== null) { - var result37 = []; - var result42 = parse_WS(); - while (result42 !== null) { - result37.push(result42); - var result42 = parse_WS(); - } - if (result37 !== null) { - var result38 = parse_ConditionalOrExpression(); - if (result38 !== null) { - var result39 = []; - var result41 = parse_WS(); - while (result41 !== null) { - result39.push(result41); - var result41 = parse_WS(); - } - if (result39 !== null) { - if (input.substr(pos, 1) === ")") { - var result40 = ")"; - pos += 1; - } else { - var result40 = null; - if (reportMatchFailures) { - matchFailed("\")\""); - } - } - if (result40 !== null) { - var result29 = [result30, result31, result32, result33, result34, result35, result36, result37, result38, result39, result40]; - } else { - var result29 = null; - pos = savedPos1; - } - } else { - var result29 = null; - pos = savedPos1; - } - } else { - var result29 = null; - pos = savedPos1; - } - } else { - var result29 = null; - pos = savedPos1; - } + if (result13 !== null) { + var result5 = [result7, result8, result9, result10, result11, result12, result13]; } else { - var result29 = null; + var result5 = null; pos = savedPos1; } } else { - var result29 = null; + var result5 = null; pos = savedPos1; } } else { - var result29 = null; + var result5 = null; pos = savedPos1; } } else { - var result29 = null; + var result5 = null; pos = savedPos1; } } else { - var result29 = null; + var result5 = null; pos = savedPos1; } } else { - var result29 = null; + var result5 = null; pos = savedPos1; } } else { - var result29 = null; + var result5 = null; pos = savedPos1; } - var result28 = result29 !== null + var result6 = result5 !== null ? (function(arg) { var ex = {}; ex.token = 'expression'; @@ -28453,259 +20977,31 @@ SparqlParser.parser = (function(){ ex.args = [arg]; return ex; - })(result29[8]) - : null; - if (result28 !== null) { - var result0 = result28; - } else { - var savedPos0 = pos; - if (input.substr(pos, 1) === "I") { - var result27 = "I"; - pos += 1; - } else { - var result27 = null; - if (reportMatchFailures) { - matchFailed("\"I\""); - } - } - if (result27 !== null) { - var result4 = result27; - } else { - if (input.substr(pos, 1) === "i") { - var result26 = "i"; - pos += 1; - } else { - var result26 = null; - if (reportMatchFailures) { - matchFailed("\"i\""); - } - } - if (result26 !== null) { - var result4 = result26; - } else { - var result4 = null;; - }; - } - if (result4 !== null) { - if (input.substr(pos, 1) === "S") { - var result25 = "S"; - pos += 1; - } else { - var result25 = null; - if (reportMatchFailures) { - matchFailed("\"S\""); - } - } - if (result25 !== null) { - var result5 = result25; - } else { - if (input.substr(pos, 1) === "s") { - var result24 = "s"; - pos += 1; - } else { - var result24 = null; - if (reportMatchFailures) { - matchFailed("\"s\""); - } - } - if (result24 !== null) { - var result5 = result24; - } else { - var result5 = null;; - }; - } - if (result5 !== null) { - if (input.substr(pos, 1) === "I") { - var result23 = "I"; - pos += 1; - } else { - var result23 = null; - if (reportMatchFailures) { - matchFailed("\"I\""); - } - } - if (result23 !== null) { - var result6 = result23; - } else { - if (input.substr(pos, 1) === "i") { - var result22 = "i"; - pos += 1; - } else { - var result22 = null; - if (reportMatchFailures) { - matchFailed("\"i\""); - } - } - if (result22 !== null) { - var result6 = result22; - } else { - var result6 = null;; - }; - } - if (result6 !== null) { - if (input.substr(pos, 1) === "R") { - var result21 = "R"; - pos += 1; - } else { - var result21 = null; - if (reportMatchFailures) { - matchFailed("\"R\""); - } - } - if (result21 !== null) { - var result7 = result21; - } else { - if (input.substr(pos, 1) === "r") { - var result20 = "r"; - pos += 1; - } else { - var result20 = null; - if (reportMatchFailures) { - matchFailed("\"r\""); - } - } - if (result20 !== null) { - var result7 = result20; - } else { - var result7 = null;; - }; - } - if (result7 !== null) { - if (input.substr(pos, 1) === "I") { - var result19 = "I"; - pos += 1; - } else { - var result19 = null; - if (reportMatchFailures) { - matchFailed("\"I\""); - } - } - if (result19 !== null) { - var result8 = result19; - } else { - if (input.substr(pos, 1) === "i") { - var result18 = "i"; - pos += 1; - } else { - var result18 = null; - if (reportMatchFailures) { - matchFailed("\"i\""); - } - } - if (result18 !== null) { - var result8 = result18; - } else { - var result8 = null;; - }; - } - if (result8 !== null) { - var result9 = []; - var result17 = parse_WS(); - while (result17 !== null) { - result9.push(result17); - var result17 = parse_WS(); - } - if (result9 !== null) { - if (input.substr(pos, 1) === "(") { - var result10 = "("; - pos += 1; - } else { - var result10 = null; - if (reportMatchFailures) { - matchFailed("\"(\""); - } - } - if (result10 !== null) { - var result11 = []; - var result16 = parse_WS(); - while (result16 !== null) { - result11.push(result16); - var result16 = parse_WS(); - } - if (result11 !== null) { - var result12 = parse_ConditionalOrExpression(); - if (result12 !== null) { - var result13 = []; - var result15 = parse_WS(); - while (result15 !== null) { - result13.push(result15); - var result15 = parse_WS(); - } - if (result13 !== null) { - if (input.substr(pos, 1) === ")") { - var result14 = ")"; - pos += 1; - } else { - var result14 = null; - if (reportMatchFailures) { - matchFailed("\")\""); - } - } - if (result14 !== null) { - var result3 = [result4, result5, result6, result7, result8, result9, result10, result11, result12, result13, result14]; - } else { - var result3 = null; - pos = savedPos0; - } - } else { - var result3 = null; - pos = savedPos0; - } - } else { - var result3 = null; - pos = savedPos0; - } - } else { - var result3 = null; - pos = savedPos0; - } - } else { - var result3 = null; - pos = savedPos0; - } - } else { - var result3 = null; - pos = savedPos0; - } - } else { - var result3 = null; - pos = savedPos0; - } - } else { - var result3 = null; - pos = savedPos0; - } - } else { - var result3 = null; - pos = savedPos0; - } - } else { - var result3 = null; - pos = savedPos0; - } - } else { - var result3 = null; - pos = savedPos0; - } - var result2 = result3 !== null - ? (function(arg) { - var ex = {}; - ex.token = 'expression'; - ex.expressionType = 'builtincall'; - ex.builtincall = 'isuri'; - ex.args = [arg]; - - return ex; - })(result3[8]) - : null; - if (result2 !== null) { - var result0 = result2; + })(result5[4]) + : null; + if (result6 !== null) { + var result4 = result6; + } else { + var result4 = null; + pos = savedPos0; + } + if (result4 !== null) { + var result0 = result4; + } else { + var result3 = parse_RegexExpression(); + if (result3 !== null) { + var result0 = result3; } else { - var result1 = parse_RegexExpression(); - if (result1 !== null) { - var result0 = result1; + var result2 = parse_ExistsFunc(); + if (result2 !== null) { + var result0 = result2; } else { - var result0 = null;; + var result1 = parse_NotExistsFunc(); + if (result1 !== null) { + var result0 = result1; + } else { + var result0 = null;; + }; }; }; }; @@ -28745,327 +21041,200 @@ SparqlParser.parser = (function(){ var savedReportMatchFailures = reportMatchFailures; reportMatchFailures = false; var savedPos0 = pos; - if (input.substr(pos, 1) === "R") { - var result39 = "R"; - pos += 1; + var savedPos1 = pos; + if (input.substr(pos, 5) === "REGEX") { + var result28 = "REGEX"; + pos += 5; } else { - var result39 = null; + var result28 = null; if (reportMatchFailures) { - matchFailed("\"R\""); + matchFailed("\"REGEX\""); } } - if (result39 !== null) { - var result2 = result39; + if (result28 !== null) { + var result3 = result28; } else { - if (input.substr(pos, 1) === "r") { - var result38 = "r"; - pos += 1; + if (input.substr(pos, 5) === "regex") { + var result27 = "regex"; + pos += 5; } else { - var result38 = null; + var result27 = null; if (reportMatchFailures) { - matchFailed("\"r\""); + matchFailed("\"regex\""); } } - if (result38 !== null) { - var result2 = result38; + if (result27 !== null) { + var result3 = result27; } else { - var result2 = null;; + var result3 = null;; }; } - if (result2 !== null) { - if (input.substr(pos, 1) === "E") { - var result37 = "E"; - pos += 1; - } else { - var result37 = null; - if (reportMatchFailures) { - matchFailed("\"E\""); - } - } - if (result37 !== null) { - var result3 = result37; - } else { - if (input.substr(pos, 1) === "e") { - var result36 = "e"; - pos += 1; - } else { - var result36 = null; - if (reportMatchFailures) { - matchFailed("\"e\""); - } - } - if (result36 !== null) { - var result3 = result36; - } else { - var result3 = null;; - }; + if (result3 !== null) { + var result4 = []; + var result26 = parse_WS(); + while (result26 !== null) { + result4.push(result26); + var result26 = parse_WS(); } - if (result3 !== null) { - if (input.substr(pos, 1) === "G") { - var result35 = "G"; + if (result4 !== null) { + if (input.substr(pos, 1) === "(") { + var result5 = "("; pos += 1; } else { - var result35 = null; + var result5 = null; if (reportMatchFailures) { - matchFailed("\"G\""); - } - } - if (result35 !== null) { - var result4 = result35; - } else { - if (input.substr(pos, 1) === "g") { - var result34 = "g"; - pos += 1; - } else { - var result34 = null; - if (reportMatchFailures) { - matchFailed("\"g\""); - } + matchFailed("\"(\""); } - if (result34 !== null) { - var result4 = result34; - } else { - var result4 = null;; - }; } - if (result4 !== null) { - if (input.substr(pos, 1) === "E") { - var result33 = "E"; - pos += 1; - } else { - var result33 = null; - if (reportMatchFailures) { - matchFailed("\"E\""); - } - } - if (result33 !== null) { - var result5 = result33; - } else { - if (input.substr(pos, 1) === "e") { - var result32 = "e"; - pos += 1; - } else { - var result32 = null; - if (reportMatchFailures) { - matchFailed("\"e\""); - } - } - if (result32 !== null) { - var result5 = result32; - } else { - var result5 = null;; - }; + if (result5 !== null) { + var result6 = []; + var result25 = parse_WS(); + while (result25 !== null) { + result6.push(result25); + var result25 = parse_WS(); } - if (result5 !== null) { - if (input.substr(pos, 1) === "X") { - var result31 = "X"; - pos += 1; - } else { - var result31 = null; - if (reportMatchFailures) { - matchFailed("\"X\""); - } - } - if (result31 !== null) { - var result6 = result31; - } else { - if (input.substr(pos, 1) === "x") { - var result30 = "x"; - pos += 1; - } else { - var result30 = null; - if (reportMatchFailures) { - matchFailed("\"x\""); - } - } - if (result30 !== null) { - var result6 = result30; - } else { - var result6 = null;; - }; - } - if (result6 !== null) { - var result7 = []; - var result29 = parse_WS(); - while (result29 !== null) { - result7.push(result29); - var result29 = parse_WS(); + if (result6 !== null) { + var result7 = parse_ConditionalOrExpression(); + if (result7 !== null) { + var result8 = []; + var result24 = parse_WS(); + while (result24 !== null) { + result8.push(result24); + var result24 = parse_WS(); } - if (result7 !== null) { - if (input.substr(pos, 1) === "(") { - var result8 = "("; + if (result8 !== null) { + if (input.substr(pos, 1) === ",") { + var result9 = ","; pos += 1; } else { - var result8 = null; + var result9 = null; if (reportMatchFailures) { - matchFailed("\"(\""); + matchFailed("\",\""); } } - if (result8 !== null) { - var result9 = []; - var result28 = parse_WS(); - while (result28 !== null) { - result9.push(result28); - var result28 = parse_WS(); + if (result9 !== null) { + var result10 = []; + var result23 = parse_WS(); + while (result23 !== null) { + result10.push(result23); + var result23 = parse_WS(); } - if (result9 !== null) { - var result10 = parse_ConditionalOrExpression(); - if (result10 !== null) { - var result11 = []; - var result27 = parse_WS(); - while (result27 !== null) { - result11.push(result27); - var result27 = parse_WS(); + if (result10 !== null) { + var result11 = parse_ConditionalOrExpression(); + if (result11 !== null) { + var result12 = []; + var result22 = parse_WS(); + while (result22 !== null) { + result12.push(result22); + var result22 = parse_WS(); } - if (result11 !== null) { + if (result12 !== null) { + var savedPos2 = pos; if (input.substr(pos, 1) === ",") { - var result12 = ","; + var result18 = ","; pos += 1; } else { - var result12 = null; + var result18 = null; if (reportMatchFailures) { matchFailed("\",\""); } } - if (result12 !== null) { - var result13 = []; - var result26 = parse_WS(); - while (result26 !== null) { - result13.push(result26); - var result26 = parse_WS(); + if (result18 !== null) { + var result19 = []; + var result21 = parse_WS(); + while (result21 !== null) { + result19.push(result21); + var result21 = parse_WS(); } - if (result13 !== null) { - var result14 = parse_ConditionalOrExpression(); - if (result14 !== null) { - var result15 = []; - var result25 = parse_WS(); - while (result25 !== null) { - result15.push(result25); - var result25 = parse_WS(); - } - if (result15 !== null) { - var savedPos1 = pos; - if (input.substr(pos, 1) === ",") { - var result21 = ","; - pos += 1; - } else { - var result21 = null; - if (reportMatchFailures) { - matchFailed("\",\""); - } - } - if (result21 !== null) { - var result22 = []; - var result24 = parse_WS(); - while (result24 !== null) { - result22.push(result24); - var result24 = parse_WS(); - } - if (result22 !== null) { - var result23 = parse_ConditionalOrExpression(); - if (result23 !== null) { - var result20 = [result21, result22, result23]; - } else { - var result20 = null; - pos = savedPos1; - } - } else { - var result20 = null; - pos = savedPos1; - } - } else { - var result20 = null; - pos = savedPos1; - } - var result16 = result20 !== null ? result20 : ''; - if (result16 !== null) { - var result17 = []; - var result19 = parse_WS(); - while (result19 !== null) { - result17.push(result19); - var result19 = parse_WS(); - } - if (result17 !== null) { - if (input.substr(pos, 1) === ")") { - var result18 = ")"; - pos += 1; - } else { - var result18 = null; - if (reportMatchFailures) { - matchFailed("\")\""); - } - } - if (result18 !== null) { - var result1 = [result2, result3, result4, result5, result6, result7, result8, result9, result10, result11, result12, result13, result14, result15, result16, result17, result18]; - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; + if (result19 !== null) { + var result20 = parse_ConditionalOrExpression(); + if (result20 !== null) { + var result17 = [result18, result19, result20]; + } else { + var result17 = null; + pos = savedPos2; + } + } else { + var result17 = null; + pos = savedPos2; + } + } else { + var result17 = null; + pos = savedPos2; + } + var result13 = result17 !== null ? result17 : ''; + if (result13 !== null) { + var result14 = []; + var result16 = parse_WS(); + while (result16 !== null) { + result14.push(result16); + var result16 = parse_WS(); + } + if (result14 !== null) { + if (input.substr(pos, 1) === ")") { + var result15 = ")"; + pos += 1; + } else { + var result15 = null; + if (reportMatchFailures) { + matchFailed("\")\""); } + } + if (result15 !== null) { + var result1 = [result3, result4, result5, result6, result7, result8, result9, result10, result11, result12, result13, result14, result15]; } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } - var result0 = result1 !== null + var result2 = result1 !== null ? (function(e1, e2, eo) { var regex = {}; regex.token = 'expression'; @@ -29075,8 +21244,14 @@ SparqlParser.parser = (function(){ regex.flags = eo[2]; return regex; - })(result1[8], result1[12], result1[14]) + })(result1[4], result1[8], result1[10]) : null; + if (result2 !== null) { + var result0 = result2; + } else { + var result0 = null; + pos = savedPos0; + } reportMatchFailures = savedReportMatchFailures; if (reportMatchFailures && result0 === null) { matchFailed("[107] RegexExpression"); @@ -29100,74 +21275,77 @@ SparqlParser.parser = (function(){ var savedReportMatchFailures = reportMatchFailures; reportMatchFailures = false; var savedPos0 = pos; + var savedPos1 = pos; if (input.substr(pos, 6) === "EXISTS") { - var result1 = "EXISTS"; + var result8 = "EXISTS"; pos += 6; } else { - var result1 = null; + var result8 = null; if (reportMatchFailures) { matchFailed("\"EXISTS\""); } } - if (result1 !== null) { - var result2 = parse_GroupGraphPattern(); - if (result2 !== null) { - var result0 = [result1, result2]; + if (result8 !== null) { + var result3 = result8; + } else { + if (input.substr(pos, 6) === "exists") { + var result7 = "exists"; + pos += 6; } else { - var result0 = null; - pos = savedPos0; + var result7 = null; + if (reportMatchFailures) { + matchFailed("\"exists\""); + } } - } else { - var result0 = null; - pos = savedPos0; - } - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("[108] ExistsFunc"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_NotExistsFunc() { - var cacheKey = 'NotExistsFunc@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; + if (result7 !== null) { + var result3 = result7; + } else { + var result3 = null;; + }; } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var savedPos0 = pos; - if (input.substr(pos, 10) === "NOT EXISTS") { - var result1 = "NOT EXISTS"; - pos += 10; - } else { - var result1 = null; - if (reportMatchFailures) { - matchFailed("\"NOT EXISTS\""); + if (result3 !== null) { + var result4 = []; + var result6 = parse_WS(); + while (result6 !== null) { + result4.push(result6); + var result6 = parse_WS(); } - } - if (result1 !== null) { - var result2 = parse_GroupGraphPattern(); - if (result2 !== null) { - var result0 = [result1, result2]; + if (result4 !== null) { + var result5 = parse_GroupGraphPattern(); + if (result5 !== null) { + var result1 = [result3, result4, result5]; + } else { + var result1 = null; + pos = savedPos1; + } } else { - var result0 = null; - pos = savedPos0; + var result1 = null; + pos = savedPos1; } + } else { + var result1 = null; + pos = savedPos1; + } + var result2 = result1 !== null + ? (function(ggp) { + var ex = {}; + ex.token = 'expression'; + ex.expressionType = 'builtincall'; + ex.builtincall = 'exists'; + ex.args = [ggp]; + + return ex; + })(result1[2]) + : null; + if (result2 !== null) { + var result0 = result2; } else { var result0 = null; pos = savedPos0; } reportMatchFailures = savedReportMatchFailures; if (reportMatchFailures && result0 === null) { - matchFailed("[109] NotExistsFunc"); + matchFailed("[108] ExistsFunc"); } cache[cacheKey] = { @@ -29177,8 +21355,8 @@ SparqlParser.parser = (function(){ return result0; } - function parse_Aggregate() { - var cacheKey = 'Aggregate@' + pos; + function parse_NotExistsFunc() { + var cacheKey = 'NotExistsFunc@' + pos; var cachedResult = cache[cacheKey]; if (cachedResult) { pos = cachedResult.nextPos; @@ -29187,1007 +21365,495 @@ SparqlParser.parser = (function(){ var savedReportMatchFailures = reportMatchFailures; reportMatchFailures = false; - var savedPos8 = pos; - if (input.substr(pos, 1) === "C") { - var result258 = "C"; - pos += 1; + var savedPos0 = pos; + var savedPos1 = pos; + if (input.substr(pos, 3) === "NOT") { + var result13 = "NOT"; + pos += 3; } else { - var result258 = null; + var result13 = null; if (reportMatchFailures) { - matchFailed("\"C\""); + matchFailed("\"NOT\""); } } - if (result258 !== null) { - var result203 = result258; + if (result13 !== null) { + var result3 = result13; } else { - if (input.substr(pos, 1) === "c") { - var result257 = "c"; - pos += 1; + if (input.substr(pos, 3) === "not") { + var result12 = "not"; + pos += 3; } else { - var result257 = null; + var result12 = null; if (reportMatchFailures) { - matchFailed("\"c\""); + matchFailed("\"not\""); } } - if (result257 !== null) { - var result203 = result257; + if (result12 !== null) { + var result3 = result12; } else { - var result203 = null;; + var result3 = null;; }; } - if (result203 !== null) { - if (input.substr(pos, 1) === "O") { - var result256 = "O"; - pos += 1; - } else { - var result256 = null; - if (reportMatchFailures) { - matchFailed("\"O\""); - } - } - if (result256 !== null) { - var result204 = result256; - } else { - if (input.substr(pos, 1) === "o") { - var result255 = "o"; - pos += 1; - } else { - var result255 = null; - if (reportMatchFailures) { - matchFailed("\"o\""); - } - } - if (result255 !== null) { - var result204 = result255; - } else { - var result204 = null;; - }; + if (result3 !== null) { + var result4 = []; + var result11 = parse_WS(); + while (result11 !== null) { + result4.push(result11); + var result11 = parse_WS(); } - if (result204 !== null) { - if (input.substr(pos, 1) === "U") { - var result254 = "U"; - pos += 1; + if (result4 !== null) { + if (input.substr(pos, 6) === "EXISTS") { + var result10 = "EXISTS"; + pos += 6; } else { - var result254 = null; + var result10 = null; if (reportMatchFailures) { - matchFailed("\"U\""); + matchFailed("\"EXISTS\""); } } - if (result254 !== null) { - var result205 = result254; + if (result10 !== null) { + var result5 = result10; } else { - if (input.substr(pos, 1) === "u") { - var result253 = "u"; - pos += 1; + if (input.substr(pos, 6) === "exists") { + var result9 = "exists"; + pos += 6; } else { - var result253 = null; + var result9 = null; if (reportMatchFailures) { - matchFailed("\"u\""); + matchFailed("\"exists\""); } } - if (result253 !== null) { - var result205 = result253; + if (result9 !== null) { + var result5 = result9; } else { - var result205 = null;; + var result5 = null;; }; } - if (result205 !== null) { - if (input.substr(pos, 1) === "N") { - var result252 = "N"; - pos += 1; - } else { - var result252 = null; - if (reportMatchFailures) { - matchFailed("\"N\""); - } - } - if (result252 !== null) { - var result206 = result252; - } else { - if (input.substr(pos, 1) === "n") { - var result251 = "n"; - pos += 1; - } else { - var result251 = null; - if (reportMatchFailures) { - matchFailed("\"n\""); - } - } - if (result251 !== null) { - var result206 = result251; - } else { - var result206 = null;; - }; - } - if (result206 !== null) { - if (input.substr(pos, 1) === "T") { - var result250 = "T"; - pos += 1; - } else { - var result250 = null; - if (reportMatchFailures) { - matchFailed("\"T\""); - } - } - if (result250 !== null) { - var result207 = result250; - } else { - if (input.substr(pos, 1) === "t") { - var result249 = "t"; - pos += 1; - } else { - var result249 = null; - if (reportMatchFailures) { - matchFailed("\"t\""); - } - } - if (result249 !== null) { - var result207 = result249; - } else { - var result207 = null;; - }; - } - if (result207 !== null) { - var result208 = []; - var result248 = parse_WS(); - while (result248 !== null) { - result208.push(result248); - var result248 = parse_WS(); - } - if (result208 !== null) { - if (input.substr(pos, 1) === "(") { - var result209 = "("; - pos += 1; - } else { - var result209 = null; - if (reportMatchFailures) { - matchFailed("\"(\""); - } - } - if (result209 !== null) { - var result210 = []; - var result247 = parse_WS(); - while (result247 !== null) { - result210.push(result247); - var result247 = parse_WS(); - } - if (result210 !== null) { - var savedPos9 = pos; - if (input.substr(pos, 1) === "D") { - var result246 = "D"; - pos += 1; - } else { - var result246 = null; - if (reportMatchFailures) { - matchFailed("\"D\""); - } - } - if (result246 !== null) { - var result223 = result246; - } else { - if (input.substr(pos, 1) === "d") { - var result245 = "d"; - pos += 1; - } else { - var result245 = null; - if (reportMatchFailures) { - matchFailed("\"d\""); - } - } - if (result245 !== null) { - var result223 = result245; - } else { - var result223 = null;; - }; - } - if (result223 !== null) { - if (input.substr(pos, 1) === "I") { - var result244 = "I"; - pos += 1; - } else { - var result244 = null; - if (reportMatchFailures) { - matchFailed("\"I\""); - } - } - if (result244 !== null) { - var result224 = result244; - } else { - if (input.substr(pos, 1) === "i") { - var result243 = "i"; - pos += 1; - } else { - var result243 = null; - if (reportMatchFailures) { - matchFailed("\"i\""); - } - } - if (result243 !== null) { - var result224 = result243; - } else { - var result224 = null;; - }; - } - if (result224 !== null) { - if (input.substr(pos, 1) === "S") { - var result242 = "S"; - pos += 1; - } else { - var result242 = null; - if (reportMatchFailures) { - matchFailed("\"S\""); - } - } - if (result242 !== null) { - var result225 = result242; - } else { - if (input.substr(pos, 1) === "s") { - var result241 = "s"; - pos += 1; - } else { - var result241 = null; - if (reportMatchFailures) { - matchFailed("\"s\""); - } - } - if (result241 !== null) { - var result225 = result241; - } else { - var result225 = null;; - }; - } - if (result225 !== null) { - if (input.substr(pos, 1) === "T") { - var result240 = "T"; - pos += 1; - } else { - var result240 = null; - if (reportMatchFailures) { - matchFailed("\"T\""); - } - } - if (result240 !== null) { - var result226 = result240; - } else { - if (input.substr(pos, 1) === "t") { - var result239 = "t"; - pos += 1; - } else { - var result239 = null; - if (reportMatchFailures) { - matchFailed("\"t\""); - } - } - if (result239 !== null) { - var result226 = result239; - } else { - var result226 = null;; - }; - } - if (result226 !== null) { - if (input.substr(pos, 1) === "I") { - var result238 = "I"; - pos += 1; - } else { - var result238 = null; - if (reportMatchFailures) { - matchFailed("\"I\""); - } - } - if (result238 !== null) { - var result227 = result238; - } else { - if (input.substr(pos, 1) === "i") { - var result237 = "i"; - pos += 1; - } else { - var result237 = null; - if (reportMatchFailures) { - matchFailed("\"i\""); - } - } - if (result237 !== null) { - var result227 = result237; - } else { - var result227 = null;; - }; - } - if (result227 !== null) { - if (input.substr(pos, 1) === "N") { - var result236 = "N"; - pos += 1; - } else { - var result236 = null; - if (reportMatchFailures) { - matchFailed("\"N\""); - } - } - if (result236 !== null) { - var result228 = result236; - } else { - if (input.substr(pos, 1) === "n") { - var result235 = "n"; - pos += 1; - } else { - var result235 = null; - if (reportMatchFailures) { - matchFailed("\"n\""); - } - } - if (result235 !== null) { - var result228 = result235; - } else { - var result228 = null;; - }; - } - if (result228 !== null) { - if (input.substr(pos, 1) === "C") { - var result234 = "C"; - pos += 1; - } else { - var result234 = null; - if (reportMatchFailures) { - matchFailed("\"C\""); - } - } - if (result234 !== null) { - var result229 = result234; - } else { - if (input.substr(pos, 1) === "c") { - var result233 = "c"; - pos += 1; - } else { - var result233 = null; - if (reportMatchFailures) { - matchFailed("\"c\""); - } - } - if (result233 !== null) { - var result229 = result233; - } else { - var result229 = null;; - }; - } - if (result229 !== null) { - if (input.substr(pos, 1) === "T") { - var result232 = "T"; - pos += 1; - } else { - var result232 = null; - if (reportMatchFailures) { - matchFailed("\"T\""); - } - } - if (result232 !== null) { - var result230 = result232; - } else { - if (input.substr(pos, 1) === "t") { - var result231 = "t"; - pos += 1; - } else { - var result231 = null; - if (reportMatchFailures) { - matchFailed("\"t\""); - } - } - if (result231 !== null) { - var result230 = result231; - } else { - var result230 = null;; - }; - } - if (result230 !== null) { - var result222 = [result223, result224, result225, result226, result227, result228, result229, result230]; - } else { - var result222 = null; - pos = savedPos9; - } - } else { - var result222 = null; - pos = savedPos9; - } - } else { - var result222 = null; - pos = savedPos9; - } - } else { - var result222 = null; - pos = savedPos9; - } - } else { - var result222 = null; - pos = savedPos9; - } - } else { - var result222 = null; - pos = savedPos9; - } - } else { - var result222 = null; - pos = savedPos9; - } - } else { - var result222 = null; - pos = savedPos9; - } - var result211 = result222 !== null ? result222 : ''; - if (result211 !== null) { - var result212 = []; - var result221 = parse_WS(); - while (result221 !== null) { - result212.push(result221); - var result221 = parse_WS(); - } - if (result212 !== null) { - if (input.substr(pos, 1) === "*") { - var result220 = "*"; - pos += 1; - } else { - var result220 = null; - if (reportMatchFailures) { - matchFailed("\"*\""); - } - } - if (result220 !== null) { - var result213 = result220; - } else { - var result219 = parse_ConditionalOrExpression(); - if (result219 !== null) { - var result213 = result219; - } else { - var result213 = null;; - }; - } - if (result213 !== null) { - var result214 = []; - var result218 = parse_WS(); - while (result218 !== null) { - result214.push(result218); - var result218 = parse_WS(); - } - if (result214 !== null) { - if (input.substr(pos, 1) === ")") { - var result215 = ")"; - pos += 1; - } else { - var result215 = null; - if (reportMatchFailures) { - matchFailed("\")\""); - } - } - if (result215 !== null) { - var result216 = []; - var result217 = parse_WS(); - while (result217 !== null) { - result216.push(result217); - var result217 = parse_WS(); - } - if (result216 !== null) { - var result202 = [result203, result204, result205, result206, result207, result208, result209, result210, result211, result212, result213, result214, result215, result216]; - } else { - var result202 = null; - pos = savedPos8; - } - } else { - var result202 = null; - pos = savedPos8; - } - } else { - var result202 = null; - pos = savedPos8; - } - } else { - var result202 = null; - pos = savedPos8; - } - } else { - var result202 = null; - pos = savedPos8; - } - } else { - var result202 = null; - pos = savedPos8; - } - } else { - var result202 = null; - pos = savedPos8; - } - } else { - var result202 = null; - pos = savedPos8; - } - } else { - var result202 = null; - pos = savedPos8; - } + if (result5 !== null) { + var result6 = []; + var result8 = parse_WS(); + while (result8 !== null) { + result6.push(result8); + var result8 = parse_WS(); + } + if (result6 !== null) { + var result7 = parse_GroupGraphPattern(); + if (result7 !== null) { + var result1 = [result3, result4, result5, result6, result7]; } else { - var result202 = null; - pos = savedPos8; + var result1 = null; + pos = savedPos1; } } else { - var result202 = null; - pos = savedPos8; + var result1 = null; + pos = savedPos1; } } else { - var result202 = null; - pos = savedPos8; + var result1 = null; + pos = savedPos1; } } else { - var result202 = null; - pos = savedPos8; + var result1 = null; + pos = savedPos1; } } else { - var result202 = null; - pos = savedPos8; + var result1 = null; + pos = savedPos1; } - var result201 = result202 !== null - ? (function(d, e) { - exp = {}; - exp.token = 'expression'; - exp.expressionType = 'aggregate'; - exp.aggregateType = 'count'; - exp.distinct = (d != "" ? 'DISTINCT' : d); - exp.expression = e; - - return exp; + var result2 = result1 !== null + ? (function(ggp) { + var ex = {}; + ex.token = 'expression'; + ex.expressionType = 'builtincall'; + ex.builtincall = 'notexists'; + ex.args = [ggp]; - })(result202[8], result202[10]) + return ex; + })(result1[4]) : null; - if (result201 !== null) { - var result0 = result201; + if (result2 !== null) { + var result0 = result2; } else { - var savedPos6 = pos; - if (input.substr(pos, 1) === "S") { - var result200 = "S"; - pos += 1; + var result0 = null; + pos = savedPos0; + } + reportMatchFailures = savedReportMatchFailures; + if (reportMatchFailures && result0 === null) { + matchFailed("[109] NotExistsFunc"); + } + + cache[cacheKey] = { + nextPos: pos, + result: result0 + }; + return result0; + } + + function parse_Aggregate() { + var cacheKey = 'Aggregate@' + pos; + var cachedResult = cache[cacheKey]; + if (cachedResult) { + pos = cachedResult.nextPos; + return cachedResult.result; + } + + var savedReportMatchFailures = reportMatchFailures; + reportMatchFailures = false; + var savedPos8 = pos; + var savedPos9 = pos; + if (input.substr(pos, 5) === "COUNT") { + var result117 = "COUNT"; + pos += 5; + } else { + var result117 = null; + if (reportMatchFailures) { + matchFailed("\"COUNT\""); + } + } + if (result117 !== null) { + var result96 = result117; + } else { + if (input.substr(pos, 5) === "count") { + var result116 = "count"; + pos += 5; } else { - var result200 = null; + var result116 = null; if (reportMatchFailures) { - matchFailed("\"S\""); + matchFailed("\"count\""); } } - if (result200 !== null) { - var result153 = result200; + if (result116 !== null) { + var result96 = result116; } else { - if (input.substr(pos, 1) === "s") { - var result199 = "s"; - pos += 1; - } else { - var result199 = null; - if (reportMatchFailures) { - matchFailed("\"s\""); - } - } - if (result199 !== null) { - var result153 = result199; - } else { - var result153 = null;; - }; + var result96 = null;; + }; + } + if (result96 !== null) { + var result97 = []; + var result115 = parse_WS(); + while (result115 !== null) { + result97.push(result115); + var result115 = parse_WS(); } - if (result153 !== null) { - if (input.substr(pos, 1) === "U") { - var result198 = "U"; + if (result97 !== null) { + if (input.substr(pos, 1) === "(") { + var result98 = "("; pos += 1; } else { - var result198 = null; + var result98 = null; if (reportMatchFailures) { - matchFailed("\"U\""); - } - } - if (result198 !== null) { - var result154 = result198; - } else { - if (input.substr(pos, 1) === "u") { - var result197 = "u"; - pos += 1; - } else { - var result197 = null; - if (reportMatchFailures) { - matchFailed("\"u\""); - } + matchFailed("\"(\""); } - if (result197 !== null) { - var result154 = result197; - } else { - var result154 = null;; - }; } - if (result154 !== null) { - if (input.substr(pos, 1) === "M") { - var result196 = "M"; - pos += 1; - } else { - var result196 = null; - if (reportMatchFailures) { - matchFailed("\"M\""); - } + if (result98 !== null) { + var result99 = []; + var result114 = parse_WS(); + while (result114 !== null) { + result99.push(result114); + var result114 = parse_WS(); } - if (result196 !== null) { - var result155 = result196; - } else { - if (input.substr(pos, 1) === "m") { - var result195 = "m"; - pos += 1; + if (result99 !== null) { + if (input.substr(pos, 8) === "DISTINCT") { + var result113 = "DISTINCT"; + pos += 8; } else { - var result195 = null; + var result113 = null; if (reportMatchFailures) { - matchFailed("\"m\""); + matchFailed("\"DISTINCT\""); } } - if (result195 !== null) { - var result155 = result195; + if (result113 !== null) { + var result111 = result113; } else { - var result155 = null;; - }; - } - if (result155 !== null) { - var result156 = []; - var result194 = parse_WS(); - while (result194 !== null) { - result156.push(result194); - var result194 = parse_WS(); - } - if (result156 !== null) { - if (input.substr(pos, 1) === "(") { - var result157 = "("; - pos += 1; + if (input.substr(pos, 8) === "distinct") { + var result112 = "distinct"; + pos += 8; } else { - var result157 = null; + var result112 = null; if (reportMatchFailures) { - matchFailed("\"(\""); + matchFailed("\"distinct\""); } } - if (result157 !== null) { - var result158 = []; - var result193 = parse_WS(); - while (result193 !== null) { - result158.push(result193); - var result193 = parse_WS(); + if (result112 !== null) { + var result111 = result112; + } else { + var result111 = null;; + }; + } + var result100 = result111 !== null ? result111 : ''; + if (result100 !== null) { + var result101 = []; + var result110 = parse_WS(); + while (result110 !== null) { + result101.push(result110); + var result110 = parse_WS(); + } + if (result101 !== null) { + if (input.substr(pos, 1) === "*") { + var result109 = "*"; + pos += 1; + } else { + var result109 = null; + if (reportMatchFailures) { + matchFailed("\"*\""); + } } - if (result158 !== null) { - var savedPos7 = pos; - if (input.substr(pos, 1) === "D") { - var result192 = "D"; - pos += 1; + if (result109 !== null) { + var result102 = result109; + } else { + var result108 = parse_ConditionalOrExpression(); + if (result108 !== null) { + var result102 = result108; } else { - var result192 = null; - if (reportMatchFailures) { - matchFailed("\"D\""); - } + var result102 = null;; + }; + } + if (result102 !== null) { + var result103 = []; + var result107 = parse_WS(); + while (result107 !== null) { + result103.push(result107); + var result107 = parse_WS(); } - if (result192 !== null) { - var result169 = result192; - } else { - if (input.substr(pos, 1) === "d") { - var result191 = "d"; + if (result103 !== null) { + if (input.substr(pos, 1) === ")") { + var result104 = ")"; pos += 1; } else { - var result191 = null; + var result104 = null; if (reportMatchFailures) { - matchFailed("\"d\""); + matchFailed("\")\""); } } - if (result191 !== null) { - var result169 = result191; - } else { - var result169 = null;; - }; - } - if (result169 !== null) { - if (input.substr(pos, 1) === "I") { - var result190 = "I"; - pos += 1; - } else { - var result190 = null; - if (reportMatchFailures) { - matchFailed("\"I\""); + if (result104 !== null) { + var result105 = []; + var result106 = parse_WS(); + while (result106 !== null) { + result105.push(result106); + var result106 = parse_WS(); } - } - if (result190 !== null) { - var result170 = result190; - } else { - if (input.substr(pos, 1) === "i") { - var result189 = "i"; - pos += 1; + if (result105 !== null) { + var result94 = [result96, result97, result98, result99, result100, result101, result102, result103, result104, result105]; } else { - var result189 = null; - if (reportMatchFailures) { - matchFailed("\"i\""); - } + var result94 = null; + pos = savedPos9; } - if (result189 !== null) { - var result170 = result189; - } else { - var result170 = null;; - }; + } else { + var result94 = null; + pos = savedPos9; } - if (result170 !== null) { - if (input.substr(pos, 1) === "S") { - var result188 = "S"; - pos += 1; - } else { - var result188 = null; - if (reportMatchFailures) { - matchFailed("\"S\""); - } - } - if (result188 !== null) { - var result171 = result188; - } else { - if (input.substr(pos, 1) === "s") { - var result187 = "s"; - pos += 1; - } else { - var result187 = null; - if (reportMatchFailures) { - matchFailed("\"s\""); - } - } - if (result187 !== null) { - var result171 = result187; - } else { - var result171 = null;; - }; - } - if (result171 !== null) { - if (input.substr(pos, 1) === "T") { - var result186 = "T"; - pos += 1; - } else { - var result186 = null; - if (reportMatchFailures) { - matchFailed("\"T\""); - } - } - if (result186 !== null) { - var result172 = result186; - } else { - if (input.substr(pos, 1) === "t") { - var result185 = "t"; - pos += 1; - } else { - var result185 = null; - if (reportMatchFailures) { - matchFailed("\"t\""); - } - } - if (result185 !== null) { - var result172 = result185; - } else { - var result172 = null;; - }; - } - if (result172 !== null) { - if (input.substr(pos, 1) === "I") { - var result184 = "I"; - pos += 1; - } else { - var result184 = null; - if (reportMatchFailures) { - matchFailed("\"I\""); - } - } - if (result184 !== null) { - var result173 = result184; - } else { - if (input.substr(pos, 1) === "i") { - var result183 = "i"; - pos += 1; - } else { - var result183 = null; - if (reportMatchFailures) { - matchFailed("\"i\""); - } - } - if (result183 !== null) { - var result173 = result183; - } else { - var result173 = null;; - }; - } - if (result173 !== null) { - if (input.substr(pos, 1) === "N") { - var result182 = "N"; - pos += 1; - } else { - var result182 = null; - if (reportMatchFailures) { - matchFailed("\"N\""); - } - } - if (result182 !== null) { - var result174 = result182; - } else { - if (input.substr(pos, 1) === "n") { - var result181 = "n"; - pos += 1; - } else { - var result181 = null; - if (reportMatchFailures) { - matchFailed("\"n\""); - } - } - if (result181 !== null) { - var result174 = result181; - } else { - var result174 = null;; - }; - } - if (result174 !== null) { - if (input.substr(pos, 1) === "C") { - var result180 = "C"; - pos += 1; - } else { - var result180 = null; - if (reportMatchFailures) { - matchFailed("\"C\""); - } - } - if (result180 !== null) { - var result175 = result180; - } else { - if (input.substr(pos, 1) === "c") { - var result179 = "c"; - pos += 1; - } else { - var result179 = null; - if (reportMatchFailures) { - matchFailed("\"c\""); - } - } - if (result179 !== null) { - var result175 = result179; - } else { - var result175 = null;; - }; - } - if (result175 !== null) { - if (input.substr(pos, 1) === "T") { - var result178 = "T"; - pos += 1; - } else { - var result178 = null; - if (reportMatchFailures) { - matchFailed("\"T\""); - } - } - if (result178 !== null) { - var result176 = result178; - } else { - if (input.substr(pos, 1) === "t") { - var result177 = "t"; - pos += 1; - } else { - var result177 = null; - if (reportMatchFailures) { - matchFailed("\"t\""); - } - } - if (result177 !== null) { - var result176 = result177; - } else { - var result176 = null;; - }; - } - if (result176 !== null) { - var result168 = [result169, result170, result171, result172, result173, result174, result175, result176]; - } else { - var result168 = null; - pos = savedPos7; - } - } else { - var result168 = null; - pos = savedPos7; - } - } else { - var result168 = null; - pos = savedPos7; - } - } else { - var result168 = null; - pos = savedPos7; - } + } else { + var result94 = null; + pos = savedPos9; + } + } else { + var result94 = null; + pos = savedPos9; + } + } else { + var result94 = null; + pos = savedPos9; + } + } else { + var result94 = null; + pos = savedPos9; + } + } else { + var result94 = null; + pos = savedPos9; + } + } else { + var result94 = null; + pos = savedPos9; + } + } else { + var result94 = null; + pos = savedPos9; + } + } else { + var result94 = null; + pos = savedPos9; + } + var result95 = result94 !== null + ? (function(d, e) { + exp = {}; + exp.token = 'expression'; + exp.expressionType = 'aggregate'; + exp.aggregateType = 'count'; + exp.distinct = (d != "" ? 'DISTINCT' : d); + exp.expression = e; + + return exp; + + })(result94[4], result94[6]) + : null; + if (result95 !== null) { + var result93 = result95; + } else { + var result93 = null; + pos = savedPos8; + } + if (result93 !== null) { + var result0 = result93; + } else { + var savedPos6 = pos; + var savedPos7 = pos; + if (input.substr(pos, 3) === "SUM") { + var result92 = "SUM"; + pos += 3; + } else { + var result92 = null; + if (reportMatchFailures) { + matchFailed("\"SUM\""); + } + } + if (result92 !== null) { + var result73 = result92; + } else { + if (input.substr(pos, 3) === "sum") { + var result91 = "sum"; + pos += 3; + } else { + var result91 = null; + if (reportMatchFailures) { + matchFailed("\"sum\""); + } + } + if (result91 !== null) { + var result73 = result91; + } else { + var result73 = null;; + }; + } + if (result73 !== null) { + var result74 = []; + var result90 = parse_WS(); + while (result90 !== null) { + result74.push(result90); + var result90 = parse_WS(); + } + if (result74 !== null) { + if (input.substr(pos, 1) === "(") { + var result75 = "("; + pos += 1; + } else { + var result75 = null; + if (reportMatchFailures) { + matchFailed("\"(\""); + } + } + if (result75 !== null) { + var result76 = []; + var result89 = parse_WS(); + while (result89 !== null) { + result76.push(result89); + var result89 = parse_WS(); + } + if (result76 !== null) { + if (input.substr(pos, 8) === "DISTINCT") { + var result88 = "DISTINCT"; + pos += 8; + } else { + var result88 = null; + if (reportMatchFailures) { + matchFailed("\"DISTINCT\""); + } + } + if (result88 !== null) { + var result86 = result88; + } else { + if (input.substr(pos, 8) === "distinct") { + var result87 = "distinct"; + pos += 8; + } else { + var result87 = null; + if (reportMatchFailures) { + matchFailed("\"distinct\""); + } + } + if (result87 !== null) { + var result86 = result87; + } else { + var result86 = null;; + }; + } + var result77 = result86 !== null ? result86 : ''; + if (result77 !== null) { + var result78 = []; + var result85 = parse_WS(); + while (result85 !== null) { + result78.push(result85); + var result85 = parse_WS(); + } + if (result78 !== null) { + var result79 = parse_ConditionalOrExpression(); + if (result79 !== null) { + var result80 = []; + var result84 = parse_WS(); + while (result84 !== null) { + result80.push(result84); + var result84 = parse_WS(); + } + if (result80 !== null) { + if (input.substr(pos, 1) === ")") { + var result81 = ")"; + pos += 1; + } else { + var result81 = null; + if (reportMatchFailures) { + matchFailed("\")\""); + } + } + if (result81 !== null) { + var result82 = []; + var result83 = parse_WS(); + while (result83 !== null) { + result82.push(result83); + var result83 = parse_WS(); + } + if (result82 !== null) { + var result71 = [result73, result74, result75, result76, result77, result78, result79, result80, result81, result82]; } else { - var result168 = null; + var result71 = null; pos = savedPos7; } } else { - var result168 = null; + var result71 = null; pos = savedPos7; } } else { - var result168 = null; + var result71 = null; pos = savedPos7; } } else { - var result168 = null; + var result71 = null; pos = savedPos7; } - var result159 = result168 !== null ? result168 : ''; - if (result159 !== null) { - var result160 = []; - var result167 = parse_WS(); - while (result167 !== null) { - result160.push(result167); - var result167 = parse_WS(); - } - if (result160 !== null) { - var result161 = parse_ConditionalOrExpression(); - if (result161 !== null) { - var result162 = []; - var result166 = parse_WS(); - while (result166 !== null) { - result162.push(result166); - var result166 = parse_WS(); - } - if (result162 !== null) { - if (input.substr(pos, 1) === ")") { - var result163 = ")"; - pos += 1; - } else { - var result163 = null; - if (reportMatchFailures) { - matchFailed("\")\""); - } - } - if (result163 !== null) { - var result164 = []; - var result165 = parse_WS(); - while (result165 !== null) { - result164.push(result165); - var result165 = parse_WS(); - } - if (result164 !== null) { - var result152 = [result153, result154, result155, result156, result157, result158, result159, result160, result161, result162, result163, result164]; - } else { - var result152 = null; - pos = savedPos6; - } - } else { - var result152 = null; - pos = savedPos6; - } - } else { - var result152 = null; - pos = savedPos6; - } - } else { - var result152 = null; - pos = savedPos6; - } - } else { - var result152 = null; - pos = savedPos6; - } - } else { - var result152 = null; - pos = savedPos6; - } } else { - var result152 = null; - pos = savedPos6; + var result71 = null; + pos = savedPos7; } } else { - var result152 = null; - pos = savedPos6; + var result71 = null; + pos = savedPos7; } } else { - var result152 = null; - pos = savedPos6; + var result71 = null; + pos = savedPos7; } } else { - var result152 = null; - pos = savedPos6; + var result71 = null; + pos = savedPos7; } } else { - var result152 = null; - pos = savedPos6; + var result71 = null; + pos = savedPos7; } } else { - var result152 = null; - pos = savedPos6; + var result71 = null; + pos = savedPos7; } - var result151 = result152 !== null + var result72 = result71 !== null ? (function(d, e) { exp = {}; exp.token = 'expression'; @@ -30198,463 +21864,175 @@ SparqlParser.parser = (function(){ return exp; - })(result152[6], result152[8]) + })(result71[4], result71[6]) : null; - if (result151 !== null) { - var result0 = result151; + if (result72 !== null) { + var result70 = result72; + } else { + var result70 = null; + pos = savedPos6; + } + if (result70 !== null) { + var result0 = result70; } else { var savedPos4 = pos; - if (input.substr(pos, 1) === "M") { - var result150 = "M"; - pos += 1; + var savedPos5 = pos; + if (input.substr(pos, 3) === "MIN") { + var result69 = "MIN"; + pos += 3; } else { - var result150 = null; + var result69 = null; if (reportMatchFailures) { - matchFailed("\"M\""); + matchFailed("\"MIN\""); } } - if (result150 !== null) { - var result103 = result150; + if (result69 !== null) { + var result50 = result69; } else { - if (input.substr(pos, 1) === "m") { - var result149 = "m"; - pos += 1; + if (input.substr(pos, 3) === "min") { + var result68 = "min"; + pos += 3; } else { - var result149 = null; + var result68 = null; if (reportMatchFailures) { - matchFailed("\"m\""); + matchFailed("\"min\""); } } - if (result149 !== null) { - var result103 = result149; + if (result68 !== null) { + var result50 = result68; } else { - var result103 = null;; + var result50 = null;; }; } - if (result103 !== null) { - if (input.substr(pos, 1) === "I") { - var result148 = "I"; - pos += 1; - } else { - var result148 = null; - if (reportMatchFailures) { - matchFailed("\"I\""); - } - } - if (result148 !== null) { - var result104 = result148; - } else { - if (input.substr(pos, 1) === "i") { - var result147 = "i"; - pos += 1; - } else { - var result147 = null; - if (reportMatchFailures) { - matchFailed("\"i\""); - } - } - if (result147 !== null) { - var result104 = result147; - } else { - var result104 = null;; - }; + if (result50 !== null) { + var result51 = []; + var result67 = parse_WS(); + while (result67 !== null) { + result51.push(result67); + var result67 = parse_WS(); } - if (result104 !== null) { - if (input.substr(pos, 1) === "N") { - var result146 = "N"; + if (result51 !== null) { + if (input.substr(pos, 1) === "(") { + var result52 = "("; pos += 1; } else { - var result146 = null; + var result52 = null; if (reportMatchFailures) { - matchFailed("\"N\""); - } - } - if (result146 !== null) { - var result105 = result146; - } else { - if (input.substr(pos, 1) === "n") { - var result145 = "n"; - pos += 1; - } else { - var result145 = null; - if (reportMatchFailures) { - matchFailed("\"n\""); - } + matchFailed("\"(\""); } - if (result145 !== null) { - var result105 = result145; - } else { - var result105 = null;; - }; } - if (result105 !== null) { - var result106 = []; - var result144 = parse_WS(); - while (result144 !== null) { - result106.push(result144); - var result144 = parse_WS(); + if (result52 !== null) { + var result53 = []; + var result66 = parse_WS(); + while (result66 !== null) { + result53.push(result66); + var result66 = parse_WS(); } - if (result106 !== null) { - if (input.substr(pos, 1) === "(") { - var result107 = "("; - pos += 1; + if (result53 !== null) { + if (input.substr(pos, 8) === "DISTINCT") { + var result65 = "DISTINCT"; + pos += 8; } else { - var result107 = null; + var result65 = null; if (reportMatchFailures) { - matchFailed("\"(\""); + matchFailed("\"DISTINCT\""); } } - if (result107 !== null) { - var result108 = []; - var result143 = parse_WS(); - while (result143 !== null) { - result108.push(result143); - var result143 = parse_WS(); - } - if (result108 !== null) { - var savedPos5 = pos; - if (input.substr(pos, 1) === "D") { - var result142 = "D"; - pos += 1; - } else { - var result142 = null; - if (reportMatchFailures) { - matchFailed("\"D\""); - } - } - if (result142 !== null) { - var result119 = result142; - } else { - if (input.substr(pos, 1) === "d") { - var result141 = "d"; - pos += 1; - } else { - var result141 = null; - if (reportMatchFailures) { - matchFailed("\"d\""); - } - } - if (result141 !== null) { - var result119 = result141; - } else { - var result119 = null;; - }; + if (result65 !== null) { + var result63 = result65; + } else { + if (input.substr(pos, 8) === "distinct") { + var result64 = "distinct"; + pos += 8; + } else { + var result64 = null; + if (reportMatchFailures) { + matchFailed("\"distinct\""); } - if (result119 !== null) { - if (input.substr(pos, 1) === "I") { - var result140 = "I"; - pos += 1; - } else { - var result140 = null; - if (reportMatchFailures) { - matchFailed("\"I\""); - } - } - if (result140 !== null) { - var result120 = result140; - } else { - if (input.substr(pos, 1) === "i") { - var result139 = "i"; - pos += 1; - } else { - var result139 = null; - if (reportMatchFailures) { - matchFailed("\"i\""); - } - } - if (result139 !== null) { - var result120 = result139; - } else { - var result120 = null;; - }; - } - if (result120 !== null) { - if (input.substr(pos, 1) === "S") { - var result138 = "S"; - pos += 1; - } else { - var result138 = null; - if (reportMatchFailures) { - matchFailed("\"S\""); - } - } - if (result138 !== null) { - var result121 = result138; - } else { - if (input.substr(pos, 1) === "s") { - var result137 = "s"; - pos += 1; - } else { - var result137 = null; - if (reportMatchFailures) { - matchFailed("\"s\""); - } - } - if (result137 !== null) { - var result121 = result137; - } else { - var result121 = null;; - }; - } - if (result121 !== null) { - if (input.substr(pos, 1) === "T") { - var result136 = "T"; - pos += 1; - } else { - var result136 = null; - if (reportMatchFailures) { - matchFailed("\"T\""); - } - } - if (result136 !== null) { - var result122 = result136; - } else { - if (input.substr(pos, 1) === "t") { - var result135 = "t"; - pos += 1; - } else { - var result135 = null; - if (reportMatchFailures) { - matchFailed("\"t\""); - } - } - if (result135 !== null) { - var result122 = result135; - } else { - var result122 = null;; - }; - } - if (result122 !== null) { - if (input.substr(pos, 1) === "I") { - var result134 = "I"; - pos += 1; - } else { - var result134 = null; - if (reportMatchFailures) { - matchFailed("\"I\""); - } - } - if (result134 !== null) { - var result123 = result134; - } else { - if (input.substr(pos, 1) === "i") { - var result133 = "i"; - pos += 1; - } else { - var result133 = null; - if (reportMatchFailures) { - matchFailed("\"i\""); - } - } - if (result133 !== null) { - var result123 = result133; - } else { - var result123 = null;; - }; - } - if (result123 !== null) { - if (input.substr(pos, 1) === "N") { - var result132 = "N"; - pos += 1; - } else { - var result132 = null; - if (reportMatchFailures) { - matchFailed("\"N\""); - } - } - if (result132 !== null) { - var result124 = result132; - } else { - if (input.substr(pos, 1) === "n") { - var result131 = "n"; - pos += 1; - } else { - var result131 = null; - if (reportMatchFailures) { - matchFailed("\"n\""); - } - } - if (result131 !== null) { - var result124 = result131; - } else { - var result124 = null;; - }; - } - if (result124 !== null) { - if (input.substr(pos, 1) === "C") { - var result130 = "C"; - pos += 1; - } else { - var result130 = null; - if (reportMatchFailures) { - matchFailed("\"C\""); - } - } - if (result130 !== null) { - var result125 = result130; - } else { - if (input.substr(pos, 1) === "c") { - var result129 = "c"; - pos += 1; - } else { - var result129 = null; - if (reportMatchFailures) { - matchFailed("\"c\""); - } - } - if (result129 !== null) { - var result125 = result129; - } else { - var result125 = null;; - }; - } - if (result125 !== null) { - if (input.substr(pos, 1) === "T") { - var result128 = "T"; - pos += 1; - } else { - var result128 = null; - if (reportMatchFailures) { - matchFailed("\"T\""); - } - } - if (result128 !== null) { - var result126 = result128; - } else { - if (input.substr(pos, 1) === "t") { - var result127 = "t"; - pos += 1; - } else { - var result127 = null; - if (reportMatchFailures) { - matchFailed("\"t\""); - } - } - if (result127 !== null) { - var result126 = result127; - } else { - var result126 = null;; - }; - } - if (result126 !== null) { - var result118 = [result119, result120, result121, result122, result123, result124, result125, result126]; - } else { - var result118 = null; - pos = savedPos5; - } - } else { - var result118 = null; - pos = savedPos5; - } - } else { - var result118 = null; - pos = savedPos5; - } - } else { - var result118 = null; - pos = savedPos5; - } + } + if (result64 !== null) { + var result63 = result64; + } else { + var result63 = null;; + }; + } + var result54 = result63 !== null ? result63 : ''; + if (result54 !== null) { + var result55 = []; + var result62 = parse_WS(); + while (result62 !== null) { + result55.push(result62); + var result62 = parse_WS(); + } + if (result55 !== null) { + var result56 = parse_ConditionalOrExpression(); + if (result56 !== null) { + var result57 = []; + var result61 = parse_WS(); + while (result61 !== null) { + result57.push(result61); + var result61 = parse_WS(); + } + if (result57 !== null) { + if (input.substr(pos, 1) === ")") { + var result58 = ")"; + pos += 1; + } else { + var result58 = null; + if (reportMatchFailures) { + matchFailed("\")\""); + } + } + if (result58 !== null) { + var result59 = []; + var result60 = parse_WS(); + while (result60 !== null) { + result59.push(result60); + var result60 = parse_WS(); + } + if (result59 !== null) { + var result48 = [result50, result51, result52, result53, result54, result55, result56, result57, result58, result59]; } else { - var result118 = null; + var result48 = null; pos = savedPos5; } } else { - var result118 = null; + var result48 = null; pos = savedPos5; } } else { - var result118 = null; + var result48 = null; pos = savedPos5; } } else { - var result118 = null; + var result48 = null; pos = savedPos5; } - var result109 = result118 !== null ? result118 : ''; - if (result109 !== null) { - var result110 = []; - var result117 = parse_WS(); - while (result117 !== null) { - result110.push(result117); - var result117 = parse_WS(); - } - if (result110 !== null) { - var result111 = parse_ConditionalOrExpression(); - if (result111 !== null) { - var result112 = []; - var result116 = parse_WS(); - while (result116 !== null) { - result112.push(result116); - var result116 = parse_WS(); - } - if (result112 !== null) { - if (input.substr(pos, 1) === ")") { - var result113 = ")"; - pos += 1; - } else { - var result113 = null; - if (reportMatchFailures) { - matchFailed("\")\""); - } - } - if (result113 !== null) { - var result114 = []; - var result115 = parse_WS(); - while (result115 !== null) { - result114.push(result115); - var result115 = parse_WS(); - } - if (result114 !== null) { - var result102 = [result103, result104, result105, result106, result107, result108, result109, result110, result111, result112, result113, result114]; - } else { - var result102 = null; - pos = savedPos4; - } - } else { - var result102 = null; - pos = savedPos4; - } - } else { - var result102 = null; - pos = savedPos4; - } - } else { - var result102 = null; - pos = savedPos4; - } - } else { - var result102 = null; - pos = savedPos4; - } - } else { - var result102 = null; - pos = savedPos4; - } } else { - var result102 = null; - pos = savedPos4; + var result48 = null; + pos = savedPos5; } } else { - var result102 = null; - pos = savedPos4; + var result48 = null; + pos = savedPos5; } } else { - var result102 = null; - pos = savedPos4; + var result48 = null; + pos = savedPos5; } } else { - var result102 = null; - pos = savedPos4; + var result48 = null; + pos = savedPos5; } } else { - var result102 = null; - pos = savedPos4; + var result48 = null; + pos = savedPos5; } } else { - var result102 = null; - pos = savedPos4; + var result48 = null; + pos = savedPos5; } - var result101 = result102 !== null + var result49 = result48 !== null ? (function(d, e) { exp = {}; exp.token = 'expression'; @@ -30665,463 +22043,175 @@ SparqlParser.parser = (function(){ return exp; - })(result102[6], result102[8]) + })(result48[4], result48[6]) : null; - if (result101 !== null) { - var result0 = result101; + if (result49 !== null) { + var result47 = result49; + } else { + var result47 = null; + pos = savedPos4; + } + if (result47 !== null) { + var result0 = result47; } else { var savedPos2 = pos; - if (input.substr(pos, 1) === "M") { - var result100 = "M"; - pos += 1; + var savedPos3 = pos; + if (input.substr(pos, 3) === "MAX") { + var result46 = "MAX"; + pos += 3; } else { - var result100 = null; + var result46 = null; if (reportMatchFailures) { - matchFailed("\"M\""); + matchFailed("\"MAX\""); } } - if (result100 !== null) { - var result53 = result100; + if (result46 !== null) { + var result27 = result46; } else { - if (input.substr(pos, 1) === "m") { - var result99 = "m"; - pos += 1; + if (input.substr(pos, 3) === "max") { + var result45 = "max"; + pos += 3; } else { - var result99 = null; + var result45 = null; if (reportMatchFailures) { - matchFailed("\"m\""); + matchFailed("\"max\""); } } - if (result99 !== null) { - var result53 = result99; + if (result45 !== null) { + var result27 = result45; } else { - var result53 = null;; + var result27 = null;; }; } - if (result53 !== null) { - if (input.substr(pos, 1) === "A") { - var result98 = "A"; - pos += 1; - } else { - var result98 = null; - if (reportMatchFailures) { - matchFailed("\"A\""); - } - } - if (result98 !== null) { - var result54 = result98; - } else { - if (input.substr(pos, 1) === "a") { - var result97 = "a"; - pos += 1; - } else { - var result97 = null; - if (reportMatchFailures) { - matchFailed("\"a\""); - } - } - if (result97 !== null) { - var result54 = result97; - } else { - var result54 = null;; - }; + if (result27 !== null) { + var result28 = []; + var result44 = parse_WS(); + while (result44 !== null) { + result28.push(result44); + var result44 = parse_WS(); } - if (result54 !== null) { - if (input.substr(pos, 1) === "X") { - var result96 = "X"; + if (result28 !== null) { + if (input.substr(pos, 1) === "(") { + var result29 = "("; pos += 1; } else { - var result96 = null; + var result29 = null; if (reportMatchFailures) { - matchFailed("\"X\""); - } - } - if (result96 !== null) { - var result55 = result96; - } else { - if (input.substr(pos, 1) === "x") { - var result95 = "x"; - pos += 1; - } else { - var result95 = null; - if (reportMatchFailures) { - matchFailed("\"x\""); - } + matchFailed("\"(\""); } - if (result95 !== null) { - var result55 = result95; - } else { - var result55 = null;; - }; } - if (result55 !== null) { - var result56 = []; - var result94 = parse_WS(); - while (result94 !== null) { - result56.push(result94); - var result94 = parse_WS(); + if (result29 !== null) { + var result30 = []; + var result43 = parse_WS(); + while (result43 !== null) { + result30.push(result43); + var result43 = parse_WS(); } - if (result56 !== null) { - if (input.substr(pos, 1) === "(") { - var result57 = "("; - pos += 1; + if (result30 !== null) { + if (input.substr(pos, 8) === "DISTINCT") { + var result42 = "DISTINCT"; + pos += 8; } else { - var result57 = null; + var result42 = null; if (reportMatchFailures) { - matchFailed("\"(\""); + matchFailed("\"DISTINCT\""); } } - if (result57 !== null) { - var result58 = []; - var result93 = parse_WS(); - while (result93 !== null) { - result58.push(result93); - var result93 = parse_WS(); - } - if (result58 !== null) { - var savedPos3 = pos; - if (input.substr(pos, 1) === "D") { - var result92 = "D"; - pos += 1; - } else { - var result92 = null; - if (reportMatchFailures) { - matchFailed("\"D\""); - } - } - if (result92 !== null) { - var result69 = result92; - } else { - if (input.substr(pos, 1) === "d") { - var result91 = "d"; - pos += 1; - } else { - var result91 = null; - if (reportMatchFailures) { - matchFailed("\"d\""); - } - } - if (result91 !== null) { - var result69 = result91; - } else { - var result69 = null;; - }; + if (result42 !== null) { + var result40 = result42; + } else { + if (input.substr(pos, 8) === "distinct") { + var result41 = "distinct"; + pos += 8; + } else { + var result41 = null; + if (reportMatchFailures) { + matchFailed("\"distinct\""); } - if (result69 !== null) { - if (input.substr(pos, 1) === "I") { - var result90 = "I"; - pos += 1; - } else { - var result90 = null; - if (reportMatchFailures) { - matchFailed("\"I\""); - } - } - if (result90 !== null) { - var result70 = result90; - } else { - if (input.substr(pos, 1) === "i") { - var result89 = "i"; - pos += 1; - } else { - var result89 = null; - if (reportMatchFailures) { - matchFailed("\"i\""); - } - } - if (result89 !== null) { - var result70 = result89; - } else { - var result70 = null;; - }; + } + if (result41 !== null) { + var result40 = result41; + } else { + var result40 = null;; + }; + } + var result31 = result40 !== null ? result40 : ''; + if (result31 !== null) { + var result32 = []; + var result39 = parse_WS(); + while (result39 !== null) { + result32.push(result39); + var result39 = parse_WS(); + } + if (result32 !== null) { + var result33 = parse_ConditionalOrExpression(); + if (result33 !== null) { + var result34 = []; + var result38 = parse_WS(); + while (result38 !== null) { + result34.push(result38); + var result38 = parse_WS(); } - if (result70 !== null) { - if (input.substr(pos, 1) === "S") { - var result88 = "S"; + if (result34 !== null) { + if (input.substr(pos, 1) === ")") { + var result35 = ")"; pos += 1; } else { - var result88 = null; + var result35 = null; if (reportMatchFailures) { - matchFailed("\"S\""); - } - } - if (result88 !== null) { - var result71 = result88; - } else { - if (input.substr(pos, 1) === "s") { - var result87 = "s"; - pos += 1; - } else { - var result87 = null; - if (reportMatchFailures) { - matchFailed("\"s\""); - } + matchFailed("\")\""); } - if (result87 !== null) { - var result71 = result87; - } else { - var result71 = null;; - }; } - if (result71 !== null) { - if (input.substr(pos, 1) === "T") { - var result86 = "T"; - pos += 1; - } else { - var result86 = null; - if (reportMatchFailures) { - matchFailed("\"T\""); - } - } - if (result86 !== null) { - var result72 = result86; - } else { - if (input.substr(pos, 1) === "t") { - var result85 = "t"; - pos += 1; - } else { - var result85 = null; - if (reportMatchFailures) { - matchFailed("\"t\""); - } - } - if (result85 !== null) { - var result72 = result85; - } else { - var result72 = null;; - }; + if (result35 !== null) { + var result36 = []; + var result37 = parse_WS(); + while (result37 !== null) { + result36.push(result37); + var result37 = parse_WS(); } - if (result72 !== null) { - if (input.substr(pos, 1) === "I") { - var result84 = "I"; - pos += 1; - } else { - var result84 = null; - if (reportMatchFailures) { - matchFailed("\"I\""); - } - } - if (result84 !== null) { - var result73 = result84; - } else { - if (input.substr(pos, 1) === "i") { - var result83 = "i"; - pos += 1; - } else { - var result83 = null; - if (reportMatchFailures) { - matchFailed("\"i\""); - } - } - if (result83 !== null) { - var result73 = result83; - } else { - var result73 = null;; - }; - } - if (result73 !== null) { - if (input.substr(pos, 1) === "N") { - var result82 = "N"; - pos += 1; - } else { - var result82 = null; - if (reportMatchFailures) { - matchFailed("\"N\""); - } - } - if (result82 !== null) { - var result74 = result82; - } else { - if (input.substr(pos, 1) === "n") { - var result81 = "n"; - pos += 1; - } else { - var result81 = null; - if (reportMatchFailures) { - matchFailed("\"n\""); - } - } - if (result81 !== null) { - var result74 = result81; - } else { - var result74 = null;; - }; - } - if (result74 !== null) { - if (input.substr(pos, 1) === "C") { - var result80 = "C"; - pos += 1; - } else { - var result80 = null; - if (reportMatchFailures) { - matchFailed("\"C\""); - } - } - if (result80 !== null) { - var result75 = result80; - } else { - if (input.substr(pos, 1) === "c") { - var result79 = "c"; - pos += 1; - } else { - var result79 = null; - if (reportMatchFailures) { - matchFailed("\"c\""); - } - } - if (result79 !== null) { - var result75 = result79; - } else { - var result75 = null;; - }; - } - if (result75 !== null) { - if (input.substr(pos, 1) === "T") { - var result78 = "T"; - pos += 1; - } else { - var result78 = null; - if (reportMatchFailures) { - matchFailed("\"T\""); - } - } - if (result78 !== null) { - var result76 = result78; - } else { - if (input.substr(pos, 1) === "t") { - var result77 = "t"; - pos += 1; - } else { - var result77 = null; - if (reportMatchFailures) { - matchFailed("\"t\""); - } - } - if (result77 !== null) { - var result76 = result77; - } else { - var result76 = null;; - }; - } - if (result76 !== null) { - var result68 = [result69, result70, result71, result72, result73, result74, result75, result76]; - } else { - var result68 = null; - pos = savedPos3; - } - } else { - var result68 = null; - pos = savedPos3; - } - } else { - var result68 = null; - pos = savedPos3; - } - } else { - var result68 = null; - pos = savedPos3; - } + if (result36 !== null) { + var result25 = [result27, result28, result29, result30, result31, result32, result33, result34, result35, result36]; } else { - var result68 = null; + var result25 = null; pos = savedPos3; } } else { - var result68 = null; + var result25 = null; pos = savedPos3; } } else { - var result68 = null; - pos = savedPos3; - } - } else { - var result68 = null; - pos = savedPos3; - } - var result59 = result68 !== null ? result68 : ''; - if (result59 !== null) { - var result60 = []; - var result67 = parse_WS(); - while (result67 !== null) { - result60.push(result67); - var result67 = parse_WS(); - } - if (result60 !== null) { - var result61 = parse_ConditionalOrExpression(); - if (result61 !== null) { - var result62 = []; - var result66 = parse_WS(); - while (result66 !== null) { - result62.push(result66); - var result66 = parse_WS(); - } - if (result62 !== null) { - if (input.substr(pos, 1) === ")") { - var result63 = ")"; - pos += 1; - } else { - var result63 = null; - if (reportMatchFailures) { - matchFailed("\")\""); - } - } - if (result63 !== null) { - var result64 = []; - var result65 = parse_WS(); - while (result65 !== null) { - result64.push(result65); - var result65 = parse_WS(); - } - if (result64 !== null) { - var result52 = [result53, result54, result55, result56, result57, result58, result59, result60, result61, result62, result63, result64]; - } else { - var result52 = null; - pos = savedPos2; - } - } else { - var result52 = null; - pos = savedPos2; - } - } else { - var result52 = null; - pos = savedPos2; - } - } else { - var result52 = null; - pos = savedPos2; - } - } else { - var result52 = null; - pos = savedPos2; + var result25 = null; + pos = savedPos3; } } else { - var result52 = null; - pos = savedPos2; + var result25 = null; + pos = savedPos3; } } else { - var result52 = null; - pos = savedPos2; + var result25 = null; + pos = savedPos3; } } else { - var result52 = null; - pos = savedPos2; + var result25 = null; + pos = savedPos3; } } else { - var result52 = null; - pos = savedPos2; + var result25 = null; + pos = savedPos3; } } else { - var result52 = null; - pos = savedPos2; + var result25 = null; + pos = savedPos3; } } else { - var result52 = null; - pos = savedPos2; + var result25 = null; + pos = savedPos3; } } else { - var result52 = null; - pos = savedPos2; + var result25 = null; + pos = savedPos3; } - var result51 = result52 !== null + var result26 = result25 !== null ? (function(d, e) { exp = {}; exp.token = 'expression' @@ -31132,463 +22222,175 @@ SparqlParser.parser = (function(){ return exp - })(result52[6], result52[8]) + })(result25[4], result25[6]) : null; - if (result51 !== null) { - var result0 = result51; + if (result26 !== null) { + var result24 = result26; + } else { + var result24 = null; + pos = savedPos2; + } + if (result24 !== null) { + var result0 = result24; } else { var savedPos0 = pos; - if (input.substr(pos, 1) === "A") { - var result50 = "A"; - pos += 1; + var savedPos1 = pos; + if (input.substr(pos, 3) === "AVG") { + var result23 = "AVG"; + pos += 3; } else { - var result50 = null; + var result23 = null; if (reportMatchFailures) { - matchFailed("\"A\""); + matchFailed("\"AVG\""); } } - if (result50 !== null) { - var result3 = result50; + if (result23 !== null) { + var result4 = result23; } else { - if (input.substr(pos, 1) === "a") { - var result49 = "a"; - pos += 1; + if (input.substr(pos, 3) === "avg") { + var result22 = "avg"; + pos += 3; } else { - var result49 = null; + var result22 = null; if (reportMatchFailures) { - matchFailed("\"a\""); + matchFailed("\"avg\""); } } - if (result49 !== null) { - var result3 = result49; + if (result22 !== null) { + var result4 = result22; } else { - var result3 = null;; + var result4 = null;; }; } - if (result3 !== null) { - if (input.substr(pos, 1) === "V") { - var result48 = "V"; - pos += 1; - } else { - var result48 = null; - if (reportMatchFailures) { - matchFailed("\"V\""); - } - } - if (result48 !== null) { - var result4 = result48; - } else { - if (input.substr(pos, 1) === "v") { - var result47 = "v"; - pos += 1; - } else { - var result47 = null; - if (reportMatchFailures) { - matchFailed("\"v\""); - } - } - if (result47 !== null) { - var result4 = result47; - } else { - var result4 = null;; - }; + if (result4 !== null) { + var result5 = []; + var result21 = parse_WS(); + while (result21 !== null) { + result5.push(result21); + var result21 = parse_WS(); } - if (result4 !== null) { - if (input.substr(pos, 1) === "G") { - var result46 = "G"; + if (result5 !== null) { + if (input.substr(pos, 1) === "(") { + var result6 = "("; pos += 1; } else { - var result46 = null; + var result6 = null; if (reportMatchFailures) { - matchFailed("\"G\""); - } - } - if (result46 !== null) { - var result5 = result46; - } else { - if (input.substr(pos, 1) === "g") { - var result45 = "g"; - pos += 1; - } else { - var result45 = null; - if (reportMatchFailures) { - matchFailed("\"g\""); - } + matchFailed("\"(\""); } - if (result45 !== null) { - var result5 = result45; - } else { - var result5 = null;; - }; } - if (result5 !== null) { - var result6 = []; - var result44 = parse_WS(); - while (result44 !== null) { - result6.push(result44); - var result44 = parse_WS(); + if (result6 !== null) { + var result7 = []; + var result20 = parse_WS(); + while (result20 !== null) { + result7.push(result20); + var result20 = parse_WS(); } - if (result6 !== null) { - if (input.substr(pos, 1) === "(") { - var result7 = "("; - pos += 1; + if (result7 !== null) { + if (input.substr(pos, 8) === "DISTINCT") { + var result19 = "DISTINCT"; + pos += 8; } else { - var result7 = null; + var result19 = null; if (reportMatchFailures) { - matchFailed("\"(\""); + matchFailed("\"DISTINCT\""); } } - if (result7 !== null) { - var result8 = []; - var result43 = parse_WS(); - while (result43 !== null) { - result8.push(result43); - var result43 = parse_WS(); - } - if (result8 !== null) { - var savedPos1 = pos; - if (input.substr(pos, 1) === "D") { - var result42 = "D"; - pos += 1; - } else { - var result42 = null; - if (reportMatchFailures) { - matchFailed("\"D\""); - } - } - if (result42 !== null) { - var result19 = result42; - } else { - if (input.substr(pos, 1) === "d") { - var result41 = "d"; - pos += 1; - } else { - var result41 = null; - if (reportMatchFailures) { - matchFailed("\"d\""); - } - } - if (result41 !== null) { - var result19 = result41; - } else { - var result19 = null;; - }; + if (result19 !== null) { + var result17 = result19; + } else { + if (input.substr(pos, 8) === "distinct") { + var result18 = "distinct"; + pos += 8; + } else { + var result18 = null; + if (reportMatchFailures) { + matchFailed("\"distinct\""); } - if (result19 !== null) { - if (input.substr(pos, 1) === "I") { - var result40 = "I"; - pos += 1; - } else { - var result40 = null; - if (reportMatchFailures) { - matchFailed("\"I\""); - } - } - if (result40 !== null) { - var result20 = result40; - } else { - if (input.substr(pos, 1) === "i") { - var result39 = "i"; - pos += 1; - } else { - var result39 = null; - if (reportMatchFailures) { - matchFailed("\"i\""); - } - } - if (result39 !== null) { - var result20 = result39; - } else { - var result20 = null;; - }; + } + if (result18 !== null) { + var result17 = result18; + } else { + var result17 = null;; + }; + } + var result8 = result17 !== null ? result17 : ''; + if (result8 !== null) { + var result9 = []; + var result16 = parse_WS(); + while (result16 !== null) { + result9.push(result16); + var result16 = parse_WS(); + } + if (result9 !== null) { + var result10 = parse_ConditionalOrExpression(); + if (result10 !== null) { + var result11 = []; + var result15 = parse_WS(); + while (result15 !== null) { + result11.push(result15); + var result15 = parse_WS(); } - if (result20 !== null) { - if (input.substr(pos, 1) === "S") { - var result38 = "S"; + if (result11 !== null) { + if (input.substr(pos, 1) === ")") { + var result12 = ")"; pos += 1; } else { - var result38 = null; + var result12 = null; if (reportMatchFailures) { - matchFailed("\"S\""); - } - } - if (result38 !== null) { - var result21 = result38; - } else { - if (input.substr(pos, 1) === "s") { - var result37 = "s"; - pos += 1; - } else { - var result37 = null; - if (reportMatchFailures) { - matchFailed("\"s\""); - } - } - if (result37 !== null) { - var result21 = result37; - } else { - var result21 = null;; - }; - } - if (result21 !== null) { - if (input.substr(pos, 1) === "T") { - var result36 = "T"; - pos += 1; - } else { - var result36 = null; - if (reportMatchFailures) { - matchFailed("\"T\""); - } - } - if (result36 !== null) { - var result22 = result36; - } else { - if (input.substr(pos, 1) === "t") { - var result35 = "t"; - pos += 1; - } else { - var result35 = null; - if (reportMatchFailures) { - matchFailed("\"t\""); - } - } - if (result35 !== null) { - var result22 = result35; - } else { - var result22 = null;; - }; - } - if (result22 !== null) { - if (input.substr(pos, 1) === "I") { - var result34 = "I"; - pos += 1; - } else { - var result34 = null; - if (reportMatchFailures) { - matchFailed("\"I\""); - } - } - if (result34 !== null) { - var result23 = result34; - } else { - if (input.substr(pos, 1) === "i") { - var result33 = "i"; - pos += 1; - } else { - var result33 = null; - if (reportMatchFailures) { - matchFailed("\"i\""); - } - } - if (result33 !== null) { - var result23 = result33; - } else { - var result23 = null;; - }; - } - if (result23 !== null) { - if (input.substr(pos, 1) === "N") { - var result32 = "N"; - pos += 1; - } else { - var result32 = null; - if (reportMatchFailures) { - matchFailed("\"N\""); - } - } - if (result32 !== null) { - var result24 = result32; - } else { - if (input.substr(pos, 1) === "n") { - var result31 = "n"; - pos += 1; - } else { - var result31 = null; - if (reportMatchFailures) { - matchFailed("\"n\""); - } - } - if (result31 !== null) { - var result24 = result31; - } else { - var result24 = null;; - }; - } - if (result24 !== null) { - if (input.substr(pos, 1) === "C") { - var result30 = "C"; - pos += 1; - } else { - var result30 = null; - if (reportMatchFailures) { - matchFailed("\"C\""); - } - } - if (result30 !== null) { - var result25 = result30; - } else { - if (input.substr(pos, 1) === "c") { - var result29 = "c"; - pos += 1; - } else { - var result29 = null; - if (reportMatchFailures) { - matchFailed("\"c\""); - } - } - if (result29 !== null) { - var result25 = result29; - } else { - var result25 = null;; - }; - } - if (result25 !== null) { - if (input.substr(pos, 1) === "T") { - var result28 = "T"; - pos += 1; - } else { - var result28 = null; - if (reportMatchFailures) { - matchFailed("\"T\""); - } - } - if (result28 !== null) { - var result26 = result28; - } else { - if (input.substr(pos, 1) === "t") { - var result27 = "t"; - pos += 1; - } else { - var result27 = null; - if (reportMatchFailures) { - matchFailed("\"t\""); - } - } - if (result27 !== null) { - var result26 = result27; - } else { - var result26 = null;; - }; - } - if (result26 !== null) { - var result18 = [result19, result20, result21, result22, result23, result24, result25, result26]; - } else { - var result18 = null; - pos = savedPos1; - } - } else { - var result18 = null; - pos = savedPos1; - } - } else { - var result18 = null; - pos = savedPos1; - } - } else { - var result18 = null; - pos = savedPos1; - } - } else { - var result18 = null; - pos = savedPos1; + matchFailed("\")\""); } - } else { - var result18 = null; - pos = savedPos1; } - } else { - var result18 = null; - pos = savedPos1; - } - } else { - var result18 = null; - pos = savedPos1; - } - var result9 = result18 !== null ? result18 : ''; - if (result9 !== null) { - var result10 = []; - var result17 = parse_WS(); - while (result17 !== null) { - result10.push(result17); - var result17 = parse_WS(); - } - if (result10 !== null) { - var result11 = parse_ConditionalOrExpression(); - if (result11 !== null) { - var result12 = []; - var result16 = parse_WS(); - while (result16 !== null) { - result12.push(result16); - var result16 = parse_WS(); + if (result12 !== null) { + var result13 = []; + var result14 = parse_WS(); + while (result14 !== null) { + result13.push(result14); + var result14 = parse_WS(); } - if (result12 !== null) { - if (input.substr(pos, 1) === ")") { - var result13 = ")"; - pos += 1; - } else { - var result13 = null; - if (reportMatchFailures) { - matchFailed("\")\""); - } - } - if (result13 !== null) { - var result14 = []; - var result15 = parse_WS(); - while (result15 !== null) { - result14.push(result15); - var result15 = parse_WS(); - } - if (result14 !== null) { - var result2 = [result3, result4, result5, result6, result7, result8, result9, result10, result11, result12, result13, result14]; - } else { - var result2 = null; - pos = savedPos0; - } - } else { - var result2 = null; - pos = savedPos0; - } + if (result13 !== null) { + var result2 = [result4, result5, result6, result7, result8, result9, result10, result11, result12, result13]; } else { var result2 = null; - pos = savedPos0; + pos = savedPos1; } } else { var result2 = null; - pos = savedPos0; + pos = savedPos1; } } else { var result2 = null; - pos = savedPos0; + pos = savedPos1; } } else { var result2 = null; - pos = savedPos0; + pos = savedPos1; } } else { var result2 = null; - pos = savedPos0; + pos = savedPos1; } } else { var result2 = null; - pos = savedPos0; + pos = savedPos1; } } else { var result2 = null; - pos = savedPos0; + pos = savedPos1; } } else { var result2 = null; - pos = savedPos0; + pos = savedPos1; } } else { var result2 = null; - pos = savedPos0; + pos = savedPos1; } } else { var result2 = null; - pos = savedPos0; + pos = savedPos1; } - var result1 = result2 !== null + var result3 = result2 !== null ? (function(d, e) { exp = {}; exp.token = 'expression' @@ -31599,8 +22401,14 @@ SparqlParser.parser = (function(){ return exp - })(result2[6], result2[8]) + })(result2[4], result2[6]) : null; + if (result3 !== null) { + var result1 = result3; + } else { + var result1 = null; + pos = savedPos0; + } if (result1 !== null) { var result0 = result1; } else { @@ -31633,21 +22441,22 @@ SparqlParser.parser = (function(){ var savedReportMatchFailures = reportMatchFailures; reportMatchFailures = false; var savedPos0 = pos; - var result2 = parse_IRIref(); - if (result2 !== null) { - var result4 = parse_ArgList(); - var result3 = result4 !== null ? result4 : ''; - if (result3 !== null) { - var result1 = [result2, result3]; + var savedPos1 = pos; + var result3 = parse_IRIref(); + if (result3 !== null) { + var result5 = parse_ArgList(); + var result4 = result5 !== null ? result5 : ''; + if (result4 !== null) { + var result1 = [result3, result4]; } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } - var result0 = result1 !== null + var result2 = result1 !== null ? (function(i, args) { var fcall = {}; fcall.token = "expression"; @@ -31658,6 +22467,12 @@ SparqlParser.parser = (function(){ return fcall; })(result1[0], result1[1]) : null; + if (result2 !== null) { + var result0 = result2; + } else { + var result0 = null; + pos = savedPos0; + } reportMatchFailures = savedReportMatchFailures; if (reportMatchFailures && result0 === null) { matchFailed("[117] IRIrefOrFunction"); @@ -31681,52 +22496,53 @@ SparqlParser.parser = (function(){ var savedReportMatchFailures = reportMatchFailures; reportMatchFailures = false; var savedPos0 = pos; - var result2 = parse_String(); - if (result2 !== null) { - var result8 = parse_LANGTAG(); - if (result8 !== null) { - var result4 = result8; + var savedPos1 = pos; + var result3 = parse_String(); + if (result3 !== null) { + var result9 = parse_LANGTAG(); + if (result9 !== null) { + var result5 = result9; } else { - var savedPos1 = pos; + var savedPos2 = pos; if (input.substr(pos, 2) === "^^") { - var result6 = "^^"; + var result7 = "^^"; pos += 2; } else { - var result6 = null; + var result7 = null; if (reportMatchFailures) { matchFailed("\"^^\""); } } - if (result6 !== null) { - var result7 = parse_IRIref(); - if (result7 !== null) { - var result5 = [result6, result7]; + if (result7 !== null) { + var result8 = parse_IRIref(); + if (result8 !== null) { + var result6 = [result7, result8]; } else { - var result5 = null; - pos = savedPos1; + var result6 = null; + pos = savedPos2; } } else { - var result5 = null; - pos = savedPos1; + var result6 = null; + pos = savedPos2; } - if (result5 !== null) { - var result4 = result5; + if (result6 !== null) { + var result5 = result6; } else { - var result4 = null;; + var result5 = null;; }; } - var result3 = result4 !== null ? result4 : ''; - if (result3 !== null) { - var result1 = [result2, result3]; + var result4 = result5 !== null ? result5 : ''; + if (result4 !== null) { + var result1 = [result3, result4]; } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } - var result0 = result1 !== null + var result2 = result1 !== null ? (function(s, e) { if(typeof(e) === "string" && e.length > 0) { return {token:'literal', value:s.value, lang:e.slice(1), type:null} @@ -31740,6 +22556,12 @@ SparqlParser.parser = (function(){ } })(result1[0], result1[1]) : null; + if (result2 !== null) { + var result0 = result2; + } else { + var result0 = null; + pos = savedPos0; + } reportMatchFailures = savedReportMatchFailures; if (reportMatchFailures && result0 === null) { matchFailed("[112] RDFLiteral"); @@ -31915,138 +22737,36 @@ SparqlParser.parser = (function(){ var savedReportMatchFailures = reportMatchFailures; reportMatchFailures = false; var savedPos1 = pos; - if (input.substr(pos, 1) === "T") { - var result31 = "T"; - pos += 1; + if (input.substr(pos, 4) === "TRUE") { + var result10 = "TRUE"; + pos += 4; } else { - var result31 = null; + var result10 = null; if (reportMatchFailures) { - matchFailed("\"T\""); + matchFailed("\"TRUE\""); } } - if (result31 !== null) { - var result20 = result31; + if (result10 !== null) { + var result7 = result10; } else { - if (input.substr(pos, 1) === "t") { - var result30 = "t"; - pos += 1; + if (input.substr(pos, 4) === "true") { + var result9 = "true"; + pos += 4; } else { - var result30 = null; + var result9 = null; if (reportMatchFailures) { - matchFailed("\"t\""); + matchFailed("\"true\""); } } - if (result30 !== null) { - var result20 = result30; + if (result9 !== null) { + var result7 = result9; } else { - var result20 = null;; + var result7 = null;; }; } - if (result20 !== null) { - if (input.substr(pos, 1) === "R") { - var result29 = "R"; - pos += 1; - } else { - var result29 = null; - if (reportMatchFailures) { - matchFailed("\"R\""); - } - } - if (result29 !== null) { - var result21 = result29; - } else { - if (input.substr(pos, 1) === "r") { - var result28 = "r"; - pos += 1; - } else { - var result28 = null; - if (reportMatchFailures) { - matchFailed("\"r\""); - } - } - if (result28 !== null) { - var result21 = result28; - } else { - var result21 = null;; - }; - } - if (result21 !== null) { - if (input.substr(pos, 1) === "U") { - var result27 = "U"; - pos += 1; - } else { - var result27 = null; - if (reportMatchFailures) { - matchFailed("\"U\""); - } - } - if (result27 !== null) { - var result22 = result27; - } else { - if (input.substr(pos, 1) === "u") { - var result26 = "u"; - pos += 1; - } else { - var result26 = null; - if (reportMatchFailures) { - matchFailed("\"u\""); - } - } - if (result26 !== null) { - var result22 = result26; - } else { - var result22 = null;; - }; - } - if (result22 !== null) { - if (input.substr(pos, 1) === "E") { - var result25 = "E"; - pos += 1; - } else { - var result25 = null; - if (reportMatchFailures) { - matchFailed("\"E\""); - } - } - if (result25 !== null) { - var result23 = result25; - } else { - if (input.substr(pos, 1) === "e") { - var result24 = "e"; - pos += 1; - } else { - var result24 = null; - if (reportMatchFailures) { - matchFailed("\"e\""); - } - } - if (result24 !== null) { - var result23 = result24; - } else { - var result23 = null;; - }; - } - if (result23 !== null) { - var result19 = [result20, result21, result22, result23]; - } else { - var result19 = null; - pos = savedPos1; - } - } else { - var result19 = null; - pos = savedPos1; - } - } else { - var result19 = null; - pos = savedPos1; - } - } else { - var result19 = null; - pos = savedPos1; - } - var result18 = result19 !== null + var result8 = result7 !== null ? (function() { - lit = {}; + var lit = {}; lit.token = "literal"; lit.lang = null; lit.type = "http://www.w3.org/2001/XMLSchema#boolean"; @@ -32054,174 +22774,46 @@ SparqlParser.parser = (function(){ return lit; })() : null; - if (result18 !== null) { - var result0 = result18; + if (result8 !== null) { + var result6 = result8; + } else { + var result6 = null; + pos = savedPos1; + } + if (result6 !== null) { + var result0 = result6; } else { var savedPos0 = pos; - if (input.substr(pos, 1) === "F") { - var result17 = "F"; - pos += 1; + if (input.substr(pos, 5) === "FALSE") { + var result5 = "FALSE"; + pos += 5; } else { - var result17 = null; + var result5 = null; if (reportMatchFailures) { - matchFailed("\"F\""); + matchFailed("\"FALSE\""); } } - if (result17 !== null) { - var result3 = result17; + if (result5 !== null) { + var result2 = result5; } else { - if (input.substr(pos, 1) === "f") { - var result16 = "f"; - pos += 1; - } else { - var result16 = null; - if (reportMatchFailures) { - matchFailed("\"f\""); - } - } - if (result16 !== null) { - var result3 = result16; - } else { - var result3 = null;; - }; - } - if (result3 !== null) { - if (input.substr(pos, 1) === "A") { - var result15 = "A"; - pos += 1; + if (input.substr(pos, 5) === "false") { + var result4 = "false"; + pos += 5; } else { - var result15 = null; + var result4 = null; if (reportMatchFailures) { - matchFailed("\"A\""); - } - } - if (result15 !== null) { - var result4 = result15; - } else { - if (input.substr(pos, 1) === "a") { - var result14 = "a"; - pos += 1; - } else { - var result14 = null; - if (reportMatchFailures) { - matchFailed("\"a\""); - } - } - if (result14 !== null) { - var result4 = result14; - } else { - var result4 = null;; - }; - } - if (result4 !== null) { - if (input.substr(pos, 1) === "L") { - var result13 = "L"; - pos += 1; - } else { - var result13 = null; - if (reportMatchFailures) { - matchFailed("\"L\""); - } - } - if (result13 !== null) { - var result5 = result13; - } else { - if (input.substr(pos, 1) === "l") { - var result12 = "l"; - pos += 1; - } else { - var result12 = null; - if (reportMatchFailures) { - matchFailed("\"l\""); - } - } - if (result12 !== null) { - var result5 = result12; - } else { - var result5 = null;; - }; - } - if (result5 !== null) { - if (input.substr(pos, 1) === "S") { - var result11 = "S"; - pos += 1; - } else { - var result11 = null; - if (reportMatchFailures) { - matchFailed("\"S\""); - } - } - if (result11 !== null) { - var result6 = result11; - } else { - if (input.substr(pos, 1) === "s") { - var result10 = "s"; - pos += 1; - } else { - var result10 = null; - if (reportMatchFailures) { - matchFailed("\"s\""); - } - } - if (result10 !== null) { - var result6 = result10; - } else { - var result6 = null;; - }; - } - if (result6 !== null) { - if (input.substr(pos, 1) === "E") { - var result9 = "E"; - pos += 1; - } else { - var result9 = null; - if (reportMatchFailures) { - matchFailed("\"E\""); - } - } - if (result9 !== null) { - var result7 = result9; - } else { - if (input.substr(pos, 1) === "e") { - var result8 = "e"; - pos += 1; - } else { - var result8 = null; - if (reportMatchFailures) { - matchFailed("\"e\""); - } - } - if (result8 !== null) { - var result7 = result8; - } else { - var result7 = null;; - }; - } - if (result7 !== null) { - var result2 = [result3, result4, result5, result6, result7]; - } else { - var result2 = null; - pos = savedPos0; - } - } else { - var result2 = null; - pos = savedPos0; - } - } else { - var result2 = null; - pos = savedPos0; + matchFailed("\"false\""); } - } else { - var result2 = null; - pos = savedPos0; } - } else { - var result2 = null; - pos = savedPos0; + if (result4 !== null) { + var result2 = result4; + } else { + var result2 = null;; + }; } - var result1 = result2 !== null + var result3 = result2 !== null ? (function() { - lit = {}; + var lit = {}; lit.token = "literal"; lit.lang = null; lit.type = "http://www.w3.org/2001/XMLSchema#boolean"; @@ -32229,6 +22821,12 @@ SparqlParser.parser = (function(){ return lit; })() : null; + if (result3 !== null) { + var result1 = result3; + } else { + var result1 = null; + pos = savedPos0; + } if (result1 !== null) { var result0 = result1; } else { @@ -32257,31 +22855,59 @@ SparqlParser.parser = (function(){ var savedReportMatchFailures = reportMatchFailures; reportMatchFailures = false; - var result8 = parse_STRING_LITERAL_LONG1(); - var result7 = result8 !== null - ? (function(s) { return {token:'string', value:s} })(result8) + var savedPos3 = pos; + var result11 = parse_STRING_LITERAL_LONG1(); + var result12 = result11 !== null + ? (function(s) { return {token:'string', value:s} })(result11) : null; - if (result7 !== null) { - var result0 = result7; + if (result12 !== null) { + var result10 = result12; + } else { + var result10 = null; + pos = savedPos3; + } + if (result10 !== null) { + var result0 = result10; } else { - var result6 = parse_STRING_LITERAL_LONG2(); - var result5 = result6 !== null - ? (function(s) { return {token:'string', value:s} })(result6) + var savedPos2 = pos; + var result8 = parse_STRING_LITERAL_LONG2(); + var result9 = result8 !== null + ? (function(s) { return {token:'string', value:s} })(result8) : null; - if (result5 !== null) { - var result0 = result5; + if (result9 !== null) { + var result7 = result9; + } else { + var result7 = null; + pos = savedPos2; + } + if (result7 !== null) { + var result0 = result7; } else { - var result4 = parse_STRING_LITERAL1(); - var result3 = result4 !== null - ? (function(s) { return {token:'string', value:s} })(result4) + var savedPos1 = pos; + var result5 = parse_STRING_LITERAL1(); + var result6 = result5 !== null + ? (function(s) { return {token:'string', value:s} })(result5) : null; - if (result3 !== null) { - var result0 = result3; + if (result6 !== null) { + var result4 = result6; + } else { + var result4 = null; + pos = savedPos1; + } + if (result4 !== null) { + var result0 = result4; } else { + var savedPos0 = pos; var result2 = parse_STRING_LITERAL2(); - var result1 = result2 !== null + var result3 = result2 !== null ? (function(s) { return {token:'string', value:s} })(result2) : null; + if (result3 !== null) { + var result1 = result3; + } else { + var result1 = null; + pos = savedPos0; + } if (result1 !== null) { var result0 = result1; } else { @@ -32312,17 +22938,31 @@ SparqlParser.parser = (function(){ var savedReportMatchFailures = reportMatchFailures; reportMatchFailures = false; - var result4 = parse_IRI_REF(); - var result3 = result4 !== null - ? (function(iri) { return {token: 'uri', prefix:null, suffix:null, value:iri} })(result4) + var savedPos1 = pos; + var result5 = parse_IRI_REF(); + var result6 = result5 !== null + ? (function(iri) { return {token: 'uri', prefix:null, suffix:null, value:iri} })(result5) : null; - if (result3 !== null) { - var result0 = result3; + if (result6 !== null) { + var result4 = result6; + } else { + var result4 = null; + pos = savedPos1; + } + if (result4 !== null) { + var result0 = result4; } else { + var savedPos0 = pos; var result2 = parse_PrefixedName(); - var result1 = result2 !== null + var result3 = result2 !== null ? (function(p) { return p })(result2) : null; + if (result3 !== null) { + var result1 = result3; + } else { + var result1 = null; + pos = savedPos0; + } if (result1 !== null) { var result0 = result1; } else { @@ -32351,17 +22991,31 @@ SparqlParser.parser = (function(){ var savedReportMatchFailures = reportMatchFailures; reportMatchFailures = false; - var result4 = parse_PNAME_LN(); - var result3 = result4 !== null - ? (function(p) { return {token: 'uri', prefix:p[0], suffix:p[1], value:null } })(result4) + var savedPos1 = pos; + var result5 = parse_PNAME_LN(); + var result6 = result5 !== null + ? (function(p) { return {token: 'uri', prefix:p[0], suffix:p[1], value:null } })(result5) : null; - if (result3 !== null) { - var result0 = result3; + if (result6 !== null) { + var result4 = result6; + } else { + var result4 = null; + pos = savedPos1; + } + if (result4 !== null) { + var result0 = result4; } else { + var savedPos0 = pos; var result2 = parse_PNAME_NS(); - var result1 = result2 !== null + var result3 = result2 !== null ? (function(p) { return {token: 'uri', prefix:p, suffix:'', value:null } })(result2) : null; + if (result3 !== null) { + var result1 = result3; + } else { + var result1 = null; + pos = savedPos0; + } if (result1 !== null) { var result0 = result1; } else { @@ -32390,17 +23044,31 @@ SparqlParser.parser = (function(){ var savedReportMatchFailures = reportMatchFailures; reportMatchFailures = false; - var result4 = parse_BLANK_NODE_LABEL(); - var result3 = result4 !== null - ? (function(l) { return {token:'blank', label:l}})(result4) + var savedPos1 = pos; + var result5 = parse_BLANK_NODE_LABEL(); + var result6 = result5 !== null + ? (function(l) { return {token:'blank', value:l}})(result5) : null; - if (result3 !== null) { - var result0 = result3; + if (result6 !== null) { + var result4 = result6; + } else { + var result4 = null; + pos = savedPos1; + } + if (result4 !== null) { + var result0 = result4; } else { + var savedPos0 = pos; var result2 = parse_ANON(); - var result1 = result2 !== null - ? (function() { GlobalBlankNodeCounter++; return {token:'blank', label:''+GlobalBlankNodeCounter} })() + var result3 = result2 !== null + ? (function() { GlobalBlankNodeCounter++; return {token:'blank', value:'_:'+GlobalBlankNodeCounter} })() : null; + if (result3 !== null) { + var result1 = result3; + } else { + var result1 = null; + pos = savedPos0; + } if (result1 !== null) { var result0 = result1; } else { @@ -32430,65 +23098,72 @@ SparqlParser.parser = (function(){ var savedReportMatchFailures = reportMatchFailures; reportMatchFailures = false; var savedPos0 = pos; + var savedPos1 = pos; if (input.substr(pos, 1) === "<") { - var result2 = "<"; + var result3 = "<"; pos += 1; } else { - var result2 = null; + var result3 = null; if (reportMatchFailures) { matchFailed("\"<\""); } } - if (result2 !== null) { - var result3 = []; - if (input.substr(pos).match(/^[^<>"{} | ^\\]/) !== null) { - var result5 = input.charAt(pos); + if (result3 !== null) { + var result4 = []; + if (input.substr(pos).match(/^[^<>"{}|^`\\]/) !== null) { + var result6 = input.charAt(pos); pos++; } else { - var result5 = null; + var result6 = null; if (reportMatchFailures) { - matchFailed("[^<>\"{} | ^\\\\]"); + matchFailed("[^<>\"{}|^`\\\\]"); } } - while (result5 !== null) { - result3.push(result5); - if (input.substr(pos).match(/^[^<>"{} | ^\\]/) !== null) { - var result5 = input.charAt(pos); + while (result6 !== null) { + result4.push(result6); + if (input.substr(pos).match(/^[^<>"{}|^`\\]/) !== null) { + var result6 = input.charAt(pos); pos++; } else { - var result5 = null; + var result6 = null; if (reportMatchFailures) { - matchFailed("[^<>\"{} | ^\\\\]"); + matchFailed("[^<>\"{}|^`\\\\]"); } } } - if (result3 !== null) { + if (result4 !== null) { if (input.substr(pos, 1) === ">") { - var result4 = ">"; + var result5 = ">"; pos += 1; } else { - var result4 = null; + var result5 = null; if (reportMatchFailures) { matchFailed("\">\""); } } - if (result4 !== null) { - var result1 = [result2, result3, result4]; + if (result5 !== null) { + var result1 = [result3, result4, result5]; } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } - var result0 = result1 !== null + var result2 = result1 !== null ? (function(iri_ref) { return iri_ref.join('') })(result1[1]) : null; + if (result2 !== null) { + var result0 = result2; + } else { + var result0 = null; + pos = savedPos0; + } reportMatchFailures = savedReportMatchFailures; if (reportMatchFailures && result0 === null) { matchFailed("[122] IRI_REF"); @@ -32512,31 +23187,38 @@ SparqlParser.parser = (function(){ var savedReportMatchFailures = reportMatchFailures; reportMatchFailures = false; var savedPos0 = pos; - var result4 = parse_PN_PREFIX(); - var result2 = result4 !== null ? result4 : ''; - if (result2 !== null) { + var savedPos1 = pos; + var result5 = parse_PN_PREFIX(); + var result3 = result5 !== null ? result5 : ''; + if (result3 !== null) { if (input.substr(pos, 1) === ":") { - var result3 = ":"; + var result4 = ":"; pos += 1; } else { - var result3 = null; + var result4 = null; if (reportMatchFailures) { matchFailed("\":\""); } } - if (result3 !== null) { - var result1 = [result2, result3]; + if (result4 !== null) { + var result1 = [result3, result4]; } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } - var result0 = result1 !== null + var result2 = result1 !== null ? (function(p) { return p })(result1[0]) : null; + if (result2 !== null) { + var result0 = result2; + } else { + var result0 = null; + pos = savedPos0; + } reportMatchFailures = savedReportMatchFailures; if (reportMatchFailures && result0 === null) { matchFailed("[123] PNAME_NS"); @@ -32560,22 +23242,29 @@ SparqlParser.parser = (function(){ var savedReportMatchFailures = reportMatchFailures; reportMatchFailures = false; var savedPos0 = pos; - var result2 = parse_PNAME_NS(); - if (result2 !== null) { - var result3 = parse_PN_LOCAL(); - if (result3 !== null) { - var result1 = [result2, result3]; + var savedPos1 = pos; + var result3 = parse_PNAME_NS(); + if (result3 !== null) { + var result4 = parse_PN_LOCAL(); + if (result4 !== null) { + var result1 = [result3, result4]; } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } - var result0 = result1 !== null + var result2 = result1 !== null ? (function(p, s) { return [p, s] })(result1[0], result1[1]) : null; + if (result2 !== null) { + var result0 = result2; + } else { + var result0 = null; + pos = savedPos0; + } reportMatchFailures = savedReportMatchFailures; if (reportMatchFailures && result0 === null) { matchFailed("[124] PNAME_LN"); @@ -32599,30 +23288,37 @@ SparqlParser.parser = (function(){ var savedReportMatchFailures = reportMatchFailures; reportMatchFailures = false; var savedPos0 = pos; + var savedPos1 = pos; if (input.substr(pos, 2) === "_:") { - var result2 = "_:"; + var result3 = "_:"; pos += 2; } else { - var result2 = null; + var result3 = null; if (reportMatchFailures) { matchFailed("\"_:\""); } } - if (result2 !== null) { - var result3 = parse_PN_LOCAL(); - if (result3 !== null) { - var result1 = [result2, result3]; + if (result3 !== null) { + var result4 = parse_PN_LOCAL(); + if (result4 !== null) { + var result1 = [result3, result4]; } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } - var result0 = result1 !== null + var result2 = result1 !== null ? (function(l) { return l })(result1[1]) : null; + if (result2 !== null) { + var result0 = result2; + } else { + var result0 = null; + pos = savedPos0; + } reportMatchFailures = savedReportMatchFailures; if (reportMatchFailures && result0 === null) { matchFailed("[125] BLANK_NODE_LABEL"); @@ -32646,30 +23342,37 @@ SparqlParser.parser = (function(){ var savedReportMatchFailures = reportMatchFailures; reportMatchFailures = false; var savedPos0 = pos; + var savedPos1 = pos; if (input.substr(pos, 1) === "?") { - var result2 = "?"; + var result3 = "?"; pos += 1; } else { - var result2 = null; + var result3 = null; if (reportMatchFailures) { matchFailed("\"?\""); } } - if (result2 !== null) { - var result3 = parse_VARNAME(); - if (result3 !== null) { - var result1 = [result2, result3]; + if (result3 !== null) { + var result4 = parse_VARNAME(); + if (result4 !== null) { + var result1 = [result3, result4]; } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } - var result0 = result1 !== null + var result2 = result1 !== null ? (function(v) { return v })(result1[1]) : null; + if (result2 !== null) { + var result0 = result2; + } else { + var result0 = null; + pos = savedPos0; + } reportMatchFailures = savedReportMatchFailures; if (reportMatchFailures && result0 === null) { matchFailed("[126] VAR1"); @@ -32693,30 +23396,37 @@ SparqlParser.parser = (function(){ var savedReportMatchFailures = reportMatchFailures; reportMatchFailures = false; var savedPos0 = pos; + var savedPos1 = pos; if (input.substr(pos, 1) === "$") { - var result2 = "$"; + var result3 = "$"; pos += 1; } else { - var result2 = null; + var result3 = null; if (reportMatchFailures) { matchFailed("\"$\""); } } - if (result2 !== null) { - var result3 = parse_VARNAME(); - if (result3 !== null) { - var result1 = [result2, result3]; + if (result3 !== null) { + var result4 = parse_VARNAME(); + if (result4 !== null) { + var result1 = [result3, result4]; } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } - var result0 = result1 !== null + var result2 = result1 !== null ? (function(v) { return v })(result1[1]) : null; + if (result2 !== null) { + var result0 = result2; + } else { + var result0 = null; + pos = savedPos0; + } reportMatchFailures = savedReportMatchFailures; if (reportMatchFailures && result0 === null) { matchFailed("[127] VAR2"); @@ -32740,156 +23450,157 @@ SparqlParser.parser = (function(){ var savedReportMatchFailures = reportMatchFailures; reportMatchFailures = false; var savedPos0 = pos; + var savedPos1 = pos; if (input.substr(pos, 1) === "@") { - var result2 = "@"; + var result3 = "@"; pos += 1; } else { - var result2 = null; + var result3 = null; if (reportMatchFailures) { matchFailed("\"@\""); } } - if (result2 !== null) { + if (result3 !== null) { if (input.substr(pos).match(/^[a-zA-Z]/) !== null) { - var result9 = input.charAt(pos); + var result10 = input.charAt(pos); pos++; } else { - var result9 = null; + var result10 = null; if (reportMatchFailures) { matchFailed("[a-zA-Z]"); } } - if (result9 !== null) { - var result3 = []; - while (result9 !== null) { - result3.push(result9); + if (result10 !== null) { + var result4 = []; + while (result10 !== null) { + result4.push(result10); if (input.substr(pos).match(/^[a-zA-Z]/) !== null) { - var result9 = input.charAt(pos); + var result10 = input.charAt(pos); pos++; } else { - var result9 = null; + var result10 = null; if (reportMatchFailures) { matchFailed("[a-zA-Z]"); } } } } else { - var result3 = null; + var result4 = null; } - if (result3 !== null) { - var result4 = []; - var savedPos1 = pos; + if (result4 !== null) { + var result5 = []; + var savedPos2 = pos; if (input.substr(pos, 1) === "-") { - var result6 = "-"; + var result7 = "-"; pos += 1; } else { - var result6 = null; + var result7 = null; if (reportMatchFailures) { matchFailed("\"-\""); } } - if (result6 !== null) { + if (result7 !== null) { if (input.substr(pos).match(/^[a-zA-Z0-9]/) !== null) { - var result8 = input.charAt(pos); + var result9 = input.charAt(pos); pos++; } else { - var result8 = null; + var result9 = null; if (reportMatchFailures) { matchFailed("[a-zA-Z0-9]"); } } - if (result8 !== null) { - var result7 = []; - while (result8 !== null) { - result7.push(result8); + if (result9 !== null) { + var result8 = []; + while (result9 !== null) { + result8.push(result9); if (input.substr(pos).match(/^[a-zA-Z0-9]/) !== null) { - var result8 = input.charAt(pos); + var result9 = input.charAt(pos); pos++; } else { - var result8 = null; + var result9 = null; if (reportMatchFailures) { matchFailed("[a-zA-Z0-9]"); } } } } else { - var result7 = null; + var result8 = null; } - if (result7 !== null) { - var result5 = [result6, result7]; + if (result8 !== null) { + var result6 = [result7, result8]; } else { - var result5 = null; - pos = savedPos1; + var result6 = null; + pos = savedPos2; } } else { - var result5 = null; - pos = savedPos1; + var result6 = null; + pos = savedPos2; } - while (result5 !== null) { - result4.push(result5); - var savedPos1 = pos; + while (result6 !== null) { + result5.push(result6); + var savedPos2 = pos; if (input.substr(pos, 1) === "-") { - var result6 = "-"; + var result7 = "-"; pos += 1; } else { - var result6 = null; + var result7 = null; if (reportMatchFailures) { matchFailed("\"-\""); } } - if (result6 !== null) { + if (result7 !== null) { if (input.substr(pos).match(/^[a-zA-Z0-9]/) !== null) { - var result8 = input.charAt(pos); + var result9 = input.charAt(pos); pos++; } else { - var result8 = null; + var result9 = null; if (reportMatchFailures) { matchFailed("[a-zA-Z0-9]"); } } - if (result8 !== null) { - var result7 = []; - while (result8 !== null) { - result7.push(result8); + if (result9 !== null) { + var result8 = []; + while (result9 !== null) { + result8.push(result9); if (input.substr(pos).match(/^[a-zA-Z0-9]/) !== null) { - var result8 = input.charAt(pos); + var result9 = input.charAt(pos); pos++; } else { - var result8 = null; + var result9 = null; if (reportMatchFailures) { matchFailed("[a-zA-Z0-9]"); } } } } else { - var result7 = null; + var result8 = null; } - if (result7 !== null) { - var result5 = [result6, result7]; + if (result8 !== null) { + var result6 = [result7, result8]; } else { - var result5 = null; - pos = savedPos1; + var result6 = null; + pos = savedPos2; } } else { - var result5 = null; - pos = savedPos1; + var result6 = null; + pos = savedPos2; } } - if (result4 !== null) { - var result1 = [result2, result3, result4]; + if (result5 !== null) { + var result1 = [result3, result4, result5]; } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } - var result0 = result1 !== null + var result2 = result1 !== null ? (function(a, b) { if(b.length===0) { @@ -32899,6 +23610,12 @@ SparqlParser.parser = (function(){ } })(result1[1], result1[2]) : null; + if (result2 !== null) { + var result0 = result2; + } else { + var result0 = null; + pos = savedPos0; + } reportMatchFailures = savedReportMatchFailures; if (reportMatchFailures && result0 === null) { matchFailed("[128] LANGTAG"); @@ -32921,24 +23638,25 @@ SparqlParser.parser = (function(){ var savedReportMatchFailures = reportMatchFailures; reportMatchFailures = false; + var savedPos0 = pos; if (input.substr(pos).match(/^[0-9]/) !== null) { - var result2 = input.charAt(pos); + var result3 = input.charAt(pos); pos++; } else { - var result2 = null; + var result3 = null; if (reportMatchFailures) { matchFailed("[0-9]"); } } - if (result2 !== null) { + if (result3 !== null) { var result1 = []; - while (result2 !== null) { - result1.push(result2); + while (result3 !== null) { + result1.push(result3); if (input.substr(pos).match(/^[0-9]/) !== null) { - var result2 = input.charAt(pos); + var result3 = input.charAt(pos); pos++; } else { - var result2 = null; + var result3 = null; if (reportMatchFailures) { matchFailed("[0-9]"); } @@ -32947,9 +23665,9 @@ SparqlParser.parser = (function(){ } else { var result1 = null; } - var result0 = result1 !== null + var result2 = result1 !== null ? (function(d) { - lit = {}; + var lit = {}; lit.token = "literal"; lit.lang = null; lit.type = "http://www.w3.org/2001/XMLSchema#integer"; @@ -32957,6 +23675,12 @@ SparqlParser.parser = (function(){ return lit; })(result1) : null; + if (result2 !== null) { + var result0 = result2; + } else { + var result0 = null; + pos = savedPos0; + } reportMatchFailures = savedReportMatchFailures; if (reportMatchFailures && result0 === null) { matchFailed("[129] INTEGER"); @@ -32979,144 +23703,152 @@ SparqlParser.parser = (function(){ var savedReportMatchFailures = reportMatchFailures; reportMatchFailures = false; - var savedPos1 = pos; + var savedPos2 = pos; + var savedPos3 = pos; if (input.substr(pos).match(/^[0-9]/) !== null) { - var result12 = input.charAt(pos); + var result14 = input.charAt(pos); pos++; } else { - var result12 = null; + var result14 = null; if (reportMatchFailures) { matchFailed("[0-9]"); } } - if (result12 !== null) { - var result8 = []; - while (result12 !== null) { - result8.push(result12); + if (result14 !== null) { + var result10 = []; + while (result14 !== null) { + result10.push(result14); if (input.substr(pos).match(/^[0-9]/) !== null) { - var result12 = input.charAt(pos); + var result14 = input.charAt(pos); pos++; } else { - var result12 = null; + var result14 = null; if (reportMatchFailures) { matchFailed("[0-9]"); } } } } else { - var result8 = null; + var result10 = null; } - if (result8 !== null) { + if (result10 !== null) { if (input.substr(pos, 1) === ".") { - var result9 = "."; + var result11 = "."; pos += 1; } else { - var result9 = null; + var result11 = null; if (reportMatchFailures) { matchFailed("\".\""); } } - if (result9 !== null) { - var result10 = []; + if (result11 !== null) { + var result12 = []; if (input.substr(pos).match(/^[0-9]/) !== null) { - var result11 = input.charAt(pos); + var result13 = input.charAt(pos); pos++; } else { - var result11 = null; + var result13 = null; if (reportMatchFailures) { matchFailed("[0-9]"); } } - while (result11 !== null) { - result10.push(result11); + while (result13 !== null) { + result12.push(result13); if (input.substr(pos).match(/^[0-9]/) !== null) { - var result11 = input.charAt(pos); + var result13 = input.charAt(pos); pos++; } else { - var result11 = null; + var result13 = null; if (reportMatchFailures) { matchFailed("[0-9]"); } } } - if (result10 !== null) { - var result7 = [result8, result9, result10]; + if (result12 !== null) { + var result8 = [result10, result11, result12]; } else { - var result7 = null; - pos = savedPos1; + var result8 = null; + pos = savedPos3; } } else { - var result7 = null; - pos = savedPos1; + var result8 = null; + pos = savedPos3; } } else { - var result7 = null; - pos = savedPos1; + var result8 = null; + pos = savedPos3; } - var result6 = result7 !== null + var result9 = result8 !== null ? (function(a, b, c) { - lit = {}; + var lit = {}; lit.token = "literal"; lit.lang = null; lit.type = "http://www.w3.org/2001/XMLSchema#decimal"; lit.value = flattenString([a,b,c]); return lit; - })(result7[0], result7[1], result7[2]) + })(result8[0], result8[1], result8[2]) : null; - if (result6 !== null) { - var result0 = result6; + if (result9 !== null) { + var result7 = result9; + } else { + var result7 = null; + pos = savedPos2; + } + if (result7 !== null) { + var result0 = result7; } else { var savedPos0 = pos; + var savedPos1 = pos; if (input.substr(pos, 1) === ".") { - var result3 = "."; + var result4 = "."; pos += 1; } else { - var result3 = null; + var result4 = null; if (reportMatchFailures) { matchFailed("\".\""); } } - if (result3 !== null) { + if (result4 !== null) { if (input.substr(pos).match(/^[0-9]/) !== null) { - var result5 = input.charAt(pos); + var result6 = input.charAt(pos); pos++; } else { - var result5 = null; + var result6 = null; if (reportMatchFailures) { matchFailed("[0-9]"); } } - if (result5 !== null) { - var result4 = []; - while (result5 !== null) { - result4.push(result5); + if (result6 !== null) { + var result5 = []; + while (result6 !== null) { + result5.push(result6); if (input.substr(pos).match(/^[0-9]/) !== null) { - var result5 = input.charAt(pos); + var result6 = input.charAt(pos); pos++; } else { - var result5 = null; + var result6 = null; if (reportMatchFailures) { matchFailed("[0-9]"); } } } } else { - var result4 = null; + var result5 = null; } - if (result4 !== null) { - var result2 = [result3, result4]; + if (result5 !== null) { + var result2 = [result4, result5]; } else { var result2 = null; - pos = savedPos0; + pos = savedPos1; } } else { var result2 = null; - pos = savedPos0; + pos = savedPos1; } - var result1 = result2 !== null + var result3 = result2 !== null ? (function(a, b) { - lit = {}; + var lit = {}; lit.token = "literal"; lit.lang = null; lit.type = "http://www.w3.org/2001/XMLSchema#decimal"; @@ -33124,6 +23856,12 @@ SparqlParser.parser = (function(){ return lit; })(result2[0], result2[1]) : null; + if (result3 !== null) { + var result1 = result3; + } else { + var result1 = null; + pos = savedPos0; + } if (result1 !== null) { var result0 = result1; } else { @@ -33152,207 +23890,222 @@ SparqlParser.parser = (function(){ var savedReportMatchFailures = reportMatchFailures; reportMatchFailures = false; - var savedPos2 = pos; + var savedPos4 = pos; + var savedPos5 = pos; if (input.substr(pos).match(/^[0-9]/) !== null) { - var result19 = input.charAt(pos); + var result22 = input.charAt(pos); pos++; } else { - var result19 = null; + var result22 = null; if (reportMatchFailures) { matchFailed("[0-9]"); } } - if (result19 !== null) { - var result14 = []; - while (result19 !== null) { - result14.push(result19); + if (result22 !== null) { + var result17 = []; + while (result22 !== null) { + result17.push(result22); if (input.substr(pos).match(/^[0-9]/) !== null) { - var result19 = input.charAt(pos); + var result22 = input.charAt(pos); pos++; } else { - var result19 = null; + var result22 = null; if (reportMatchFailures) { matchFailed("[0-9]"); } } } } else { - var result14 = null; + var result17 = null; } - if (result14 !== null) { + if (result17 !== null) { if (input.substr(pos, 1) === ".") { - var result15 = "."; + var result18 = "."; pos += 1; } else { - var result15 = null; + var result18 = null; if (reportMatchFailures) { matchFailed("\".\""); } } - if (result15 !== null) { - var result16 = []; + if (result18 !== null) { + var result19 = []; if (input.substr(pos).match(/^[0-9]/) !== null) { - var result18 = input.charAt(pos); + var result21 = input.charAt(pos); pos++; } else { - var result18 = null; + var result21 = null; if (reportMatchFailures) { matchFailed("[0-9]"); } } - while (result18 !== null) { - result16.push(result18); + while (result21 !== null) { + result19.push(result21); if (input.substr(pos).match(/^[0-9]/) !== null) { - var result18 = input.charAt(pos); + var result21 = input.charAt(pos); pos++; } else { - var result18 = null; + var result21 = null; if (reportMatchFailures) { matchFailed("[0-9]"); } } } - if (result16 !== null) { - var result17 = parse_EXPONENT(); - if (result17 !== null) { - var result13 = [result14, result15, result16, result17]; + if (result19 !== null) { + var result20 = parse_EXPONENT(); + if (result20 !== null) { + var result15 = [result17, result18, result19, result20]; } else { - var result13 = null; - pos = savedPos2; + var result15 = null; + pos = savedPos5; } } else { - var result13 = null; - pos = savedPos2; + var result15 = null; + pos = savedPos5; } } else { - var result13 = null; - pos = savedPos2; + var result15 = null; + pos = savedPos5; } } else { - var result13 = null; - pos = savedPos2; + var result15 = null; + pos = savedPos5; } - var result12 = result13 !== null + var result16 = result15 !== null ? (function(a, b, c, e) { - lit = {}; + var lit = {}; lit.token = "literal"; lit.lang = null; lit.type = "http://www.w3.org/2001/XMLSchema#double"; lit.value = flattenString([a,b,c,e]); return lit; - })(result13[0], result13[1], result13[2], result13[3]) + })(result15[0], result15[1], result15[2], result15[3]) : null; - if (result12 !== null) { - var result0 = result12; + if (result16 !== null) { + var result14 = result16; } else { - var savedPos1 = pos; + var result14 = null; + pos = savedPos4; + } + if (result14 !== null) { + var result0 = result14; + } else { + var savedPos2 = pos; + var savedPos3 = pos; if (input.substr(pos, 1) === ".") { - var result8 = "."; + var result10 = "."; pos += 1; } else { - var result8 = null; + var result10 = null; if (reportMatchFailures) { matchFailed("\".\""); } } - if (result8 !== null) { + if (result10 !== null) { if (input.substr(pos).match(/^[0-9]/) !== null) { - var result11 = input.charAt(pos); + var result13 = input.charAt(pos); pos++; } else { - var result11 = null; + var result13 = null; if (reportMatchFailures) { matchFailed("[0-9]"); } } - if (result11 !== null) { - var result9 = []; - while (result11 !== null) { - result9.push(result11); + if (result13 !== null) { + var result11 = []; + while (result13 !== null) { + result11.push(result13); if (input.substr(pos).match(/^[0-9]/) !== null) { - var result11 = input.charAt(pos); + var result13 = input.charAt(pos); pos++; } else { - var result11 = null; + var result13 = null; if (reportMatchFailures) { matchFailed("[0-9]"); } } } } else { - var result9 = null; + var result11 = null; } - if (result9 !== null) { - var result10 = parse_EXPONENT(); - if (result10 !== null) { - var result7 = [result8, result9, result10]; + if (result11 !== null) { + var result12 = parse_EXPONENT(); + if (result12 !== null) { + var result8 = [result10, result11, result12]; } else { - var result7 = null; - pos = savedPos1; + var result8 = null; + pos = savedPos3; } } else { - var result7 = null; - pos = savedPos1; + var result8 = null; + pos = savedPos3; } } else { - var result7 = null; - pos = savedPos1; + var result8 = null; + pos = savedPos3; } - var result6 = result7 !== null + var result9 = result8 !== null ? (function(a, b, c) { - lit = {}; + var lit = {}; lit.token = "literal"; lit.lang = null; lit.type = "http://www.w3.org/2001/XMLSchema#double"; lit.value = flattenString([a,b,c]); return lit; - })(result7[0], result7[1], result7[2]) + })(result8[0], result8[1], result8[2]) : null; - if (result6 !== null) { - var result0 = result6; + if (result9 !== null) { + var result7 = result9; + } else { + var result7 = null; + pos = savedPos2; + } + if (result7 !== null) { + var result0 = result7; } else { var savedPos0 = pos; + var savedPos1 = pos; if (input.substr(pos).match(/^[0-9]/) !== null) { - var result5 = input.charAt(pos); + var result6 = input.charAt(pos); pos++; } else { - var result5 = null; + var result6 = null; if (reportMatchFailures) { matchFailed("[0-9]"); } } - if (result5 !== null) { - var result3 = []; - while (result5 !== null) { - result3.push(result5); + if (result6 !== null) { + var result4 = []; + while (result6 !== null) { + result4.push(result6); if (input.substr(pos).match(/^[0-9]/) !== null) { - var result5 = input.charAt(pos); + var result6 = input.charAt(pos); pos++; } else { - var result5 = null; + var result6 = null; if (reportMatchFailures) { matchFailed("[0-9]"); } } } } else { - var result3 = null; + var result4 = null; } - if (result3 !== null) { - var result4 = parse_EXPONENT(); - if (result4 !== null) { - var result2 = [result3, result4]; + if (result4 !== null) { + var result5 = parse_EXPONENT(); + if (result5 !== null) { + var result2 = [result4, result5]; } else { var result2 = null; - pos = savedPos0; + pos = savedPos1; } } else { var result2 = null; - pos = savedPos0; + pos = savedPos1; } - var result1 = result2 !== null + var result3 = result2 !== null ? (function(a, b) { - lit = {}; + var lit = {}; lit.token = "literal"; lit.lang = null; lit.type = "http://www.w3.org/2001/XMLSchema#double"; @@ -33360,6 +24113,12 @@ SparqlParser.parser = (function(){ return lit; })(result2[0], result2[1]) : null; + if (result3 !== null) { + var result1 = result3; + } else { + var result1 = null; + pos = savedPos0; + } if (result1 !== null) { var result0 = result1; } else { @@ -33390,30 +24149,37 @@ SparqlParser.parser = (function(){ var savedReportMatchFailures = reportMatchFailures; reportMatchFailures = false; var savedPos0 = pos; + var savedPos1 = pos; if (input.substr(pos, 1) === "+") { - var result2 = "+"; + var result3 = "+"; pos += 1; } else { - var result2 = null; + var result3 = null; if (reportMatchFailures) { matchFailed("\"+\""); } } - if (result2 !== null) { - var result3 = parse_INTEGER(); - if (result3 !== null) { - var result1 = [result2, result3]; + if (result3 !== null) { + var result4 = parse_INTEGER(); + if (result4 !== null) { + var result1 = [result3, result4]; } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } - var result0 = result1 !== null + var result2 = result1 !== null ? (function(d) { d.value = "+"+d.value; return d; })(result1[1]) : null; + if (result2 !== null) { + var result0 = result2; + } else { + var result0 = null; + pos = savedPos0; + } reportMatchFailures = savedReportMatchFailures; if (reportMatchFailures && result0 === null) { matchFailed("[132] INTEGER_POSITIVE"); @@ -33437,30 +24203,37 @@ SparqlParser.parser = (function(){ var savedReportMatchFailures = reportMatchFailures; reportMatchFailures = false; var savedPos0 = pos; + var savedPos1 = pos; if (input.substr(pos, 1) === "+") { - var result2 = "+"; + var result3 = "+"; pos += 1; } else { - var result2 = null; + var result3 = null; if (reportMatchFailures) { matchFailed("\"+\""); } } - if (result2 !== null) { - var result3 = parse_DECIMAL(); - if (result3 !== null) { - var result1 = [result2, result3]; + if (result3 !== null) { + var result4 = parse_DECIMAL(); + if (result4 !== null) { + var result1 = [result3, result4]; } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } - var result0 = result1 !== null + var result2 = result1 !== null ? (function(d) { d.value = "+"+d.value; return d })(result1[1]) : null; + if (result2 !== null) { + var result0 = result2; + } else { + var result0 = null; + pos = savedPos0; + } reportMatchFailures = savedReportMatchFailures; if (reportMatchFailures && result0 === null) { matchFailed("[133] DECIMAL_POSITIVE"); @@ -33484,30 +24257,37 @@ SparqlParser.parser = (function(){ var savedReportMatchFailures = reportMatchFailures; reportMatchFailures = false; var savedPos0 = pos; + var savedPos1 = pos; if (input.substr(pos, 1) === "+") { - var result2 = "+"; + var result3 = "+"; pos += 1; } else { - var result2 = null; + var result3 = null; if (reportMatchFailures) { matchFailed("\"+\""); } } - if (result2 !== null) { - var result3 = parse_DOUBLE(); - if (result3 !== null) { - var result1 = [result2, result3]; + if (result3 !== null) { + var result4 = parse_DOUBLE(); + if (result4 !== null) { + var result1 = [result3, result4]; } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } - var result0 = result1 !== null + var result2 = result1 !== null ? (function(d) { d.value = "+"+d.value; return d })(result1[1]) : null; + if (result2 !== null) { + var result0 = result2; + } else { + var result0 = null; + pos = savedPos0; + } reportMatchFailures = savedReportMatchFailures; if (reportMatchFailures && result0 === null) { matchFailed("[134] DOUBLE_POSITIVE"); @@ -33531,30 +24311,37 @@ SparqlParser.parser = (function(){ var savedReportMatchFailures = reportMatchFailures; reportMatchFailures = false; var savedPos0 = pos; + var savedPos1 = pos; if (input.substr(pos, 1) === "-") { - var result2 = "-"; + var result3 = "-"; pos += 1; } else { - var result2 = null; + var result3 = null; if (reportMatchFailures) { matchFailed("\"-\""); } } - if (result2 !== null) { - var result3 = parse_INTEGER(); - if (result3 !== null) { - var result1 = [result2, result3]; + if (result3 !== null) { + var result4 = parse_INTEGER(); + if (result4 !== null) { + var result1 = [result3, result4]; } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } - var result0 = result1 !== null + var result2 = result1 !== null ? (function(d) { d.value = "-"+d.value; return d; })(result1[1]) : null; + if (result2 !== null) { + var result0 = result2; + } else { + var result0 = null; + pos = savedPos0; + } reportMatchFailures = savedReportMatchFailures; if (reportMatchFailures && result0 === null) { matchFailed("[135] INTEGER_NEGATIVE"); @@ -33578,30 +24365,37 @@ SparqlParser.parser = (function(){ var savedReportMatchFailures = reportMatchFailures; reportMatchFailures = false; var savedPos0 = pos; + var savedPos1 = pos; if (input.substr(pos, 1) === "-") { - var result2 = "-"; + var result3 = "-"; pos += 1; } else { - var result2 = null; + var result3 = null; if (reportMatchFailures) { matchFailed("\"-\""); } } - if (result2 !== null) { - var result3 = parse_DECIMAL(); - if (result3 !== null) { - var result1 = [result2, result3]; + if (result3 !== null) { + var result4 = parse_DECIMAL(); + if (result4 !== null) { + var result1 = [result3, result4]; } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } - var result0 = result1 !== null + var result2 = result1 !== null ? (function(d) { d.value = "-"+d.value; return d; })(result1[1]) : null; + if (result2 !== null) { + var result0 = result2; + } else { + var result0 = null; + pos = savedPos0; + } reportMatchFailures = savedReportMatchFailures; if (reportMatchFailures && result0 === null) { matchFailed("[136] DECIMAL_NEGATIVE"); @@ -33625,30 +24419,37 @@ SparqlParser.parser = (function(){ var savedReportMatchFailures = reportMatchFailures; reportMatchFailures = false; var savedPos0 = pos; + var savedPos1 = pos; if (input.substr(pos, 1) === "-") { - var result2 = "-"; + var result3 = "-"; pos += 1; } else { - var result2 = null; + var result3 = null; if (reportMatchFailures) { matchFailed("\"-\""); } } - if (result2 !== null) { - var result3 = parse_DOUBLE(); - if (result3 !== null) { - var result1 = [result2, result3]; + if (result3 !== null) { + var result4 = parse_DOUBLE(); + if (result4 !== null) { + var result1 = [result3, result4]; } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } - var result0 = result1 !== null + var result2 = result1 !== null ? (function(d) { d.value = "-"+d.value; return d; })(result1[1]) : null; + if (result2 !== null) { + var result0 = result2; + } else { + var result0 = null; + pos = savedPos0; + } reportMatchFailures = savedReportMatchFailures; if (reportMatchFailures && result0 === null) { matchFailed("[137] DOUBLE_NEGATIVE"); @@ -33672,70 +24473,77 @@ SparqlParser.parser = (function(){ var savedReportMatchFailures = reportMatchFailures; reportMatchFailures = false; var savedPos0 = pos; + var savedPos1 = pos; if (input.substr(pos).match(/^[eE]/) !== null) { - var result2 = input.charAt(pos); + var result3 = input.charAt(pos); pos++; } else { - var result2 = null; + var result3 = null; if (reportMatchFailures) { matchFailed("[eE]"); } } - if (result2 !== null) { + if (result3 !== null) { if (input.substr(pos).match(/^[+\-]/) !== null) { - var result6 = input.charAt(pos); + var result7 = input.charAt(pos); pos++; } else { - var result6 = null; + var result7 = null; if (reportMatchFailures) { matchFailed("[+\\-]"); } } - var result3 = result6 !== null ? result6 : ''; - if (result3 !== null) { + var result4 = result7 !== null ? result7 : ''; + if (result4 !== null) { if (input.substr(pos).match(/^[0-9]/) !== null) { - var result5 = input.charAt(pos); + var result6 = input.charAt(pos); pos++; } else { - var result5 = null; + var result6 = null; if (reportMatchFailures) { matchFailed("[0-9]"); } } - if (result5 !== null) { - var result4 = []; - while (result5 !== null) { - result4.push(result5); + if (result6 !== null) { + var result5 = []; + while (result6 !== null) { + result5.push(result6); if (input.substr(pos).match(/^[0-9]/) !== null) { - var result5 = input.charAt(pos); + var result6 = input.charAt(pos); pos++; } else { - var result5 = null; + var result6 = null; if (reportMatchFailures) { matchFailed("[0-9]"); } } } } else { - var result4 = null; + var result5 = null; } - if (result4 !== null) { - var result1 = [result2, result3, result4]; + if (result5 !== null) { + var result1 = [result3, result4, result5]; } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } - var result0 = result1 !== null + var result2 = result1 !== null ? (function(a, b, c) { return flattenString([a,b,c]) })(result1[0], result1[1], result1[2]) : null; + if (result2 !== null) { + var result0 = result2; + } else { + var result0 = null; + pos = savedPos0; + } reportMatchFailures = savedReportMatchFailures; if (reportMatchFailures && result0 === null) { matchFailed("[138] EXPONENT"); @@ -33759,85 +24567,92 @@ SparqlParser.parser = (function(){ var savedReportMatchFailures = reportMatchFailures; reportMatchFailures = false; var savedPos0 = pos; + var savedPos1 = pos; if (input.substr(pos, 1) === "'") { - var result2 = "'"; + var result3 = "'"; pos += 1; } else { - var result2 = null; + var result3 = null; if (reportMatchFailures) { matchFailed("\"'\""); } } - if (result2 !== null) { - var result3 = []; + if (result3 !== null) { + var result4 = []; if (input.substr(pos).match(/^[^'\\\n\r]/) !== null) { - var result7 = input.charAt(pos); + var result8 = input.charAt(pos); pos++; } else { - var result7 = null; + var result8 = null; if (reportMatchFailures) { matchFailed("[^'\\\\\\n\\r]"); } } - if (result7 !== null) { - var result5 = result7; + if (result8 !== null) { + var result6 = result8; } else { - var result6 = parse_ECHAR(); - if (result6 !== null) { - var result5 = result6; + var result7 = parse_ECHAR(); + if (result7 !== null) { + var result6 = result7; } else { - var result5 = null;; + var result6 = null;; }; } - while (result5 !== null) { - result3.push(result5); + while (result6 !== null) { + result4.push(result6); if (input.substr(pos).match(/^[^'\\\n\r]/) !== null) { - var result7 = input.charAt(pos); + var result8 = input.charAt(pos); pos++; } else { - var result7 = null; + var result8 = null; if (reportMatchFailures) { matchFailed("[^'\\\\\\n\\r]"); } } - if (result7 !== null) { - var result5 = result7; + if (result8 !== null) { + var result6 = result8; } else { - var result6 = parse_ECHAR(); - if (result6 !== null) { - var result5 = result6; + var result7 = parse_ECHAR(); + if (result7 !== null) { + var result6 = result7; } else { - var result5 = null;; + var result6 = null;; }; } } - if (result3 !== null) { + if (result4 !== null) { if (input.substr(pos, 1) === "'") { - var result4 = "'"; + var result5 = "'"; pos += 1; } else { - var result4 = null; + var result5 = null; if (reportMatchFailures) { matchFailed("\"'\""); } } - if (result4 !== null) { - var result1 = [result2, result3, result4]; + if (result5 !== null) { + var result1 = [result3, result4, result5]; } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } - var result0 = result1 !== null + var result2 = result1 !== null ? (function(content) { return flattenString(content) })(result1[1]) : null; + if (result2 !== null) { + var result0 = result2; + } else { + var result0 = null; + pos = savedPos0; + } reportMatchFailures = savedReportMatchFailures; if (reportMatchFailures && result0 === null) { matchFailed("[139] STRING_LITERAL1"); @@ -33861,85 +24676,92 @@ SparqlParser.parser = (function(){ var savedReportMatchFailures = reportMatchFailures; reportMatchFailures = false; var savedPos0 = pos; + var savedPos1 = pos; if (input.substr(pos, 1) === "\"") { - var result2 = "\""; + var result3 = "\""; pos += 1; } else { - var result2 = null; + var result3 = null; if (reportMatchFailures) { matchFailed("\"\\\"\""); } } - if (result2 !== null) { - var result3 = []; + if (result3 !== null) { + var result4 = []; if (input.substr(pos).match(/^[^"\\\n\r]/) !== null) { - var result7 = input.charAt(pos); + var result8 = input.charAt(pos); pos++; } else { - var result7 = null; + var result8 = null; if (reportMatchFailures) { matchFailed("[^\"\\\\\\n\\r]"); } } - if (result7 !== null) { - var result5 = result7; + if (result8 !== null) { + var result6 = result8; } else { - var result6 = parse_ECHAR(); - if (result6 !== null) { - var result5 = result6; + var result7 = parse_ECHAR(); + if (result7 !== null) { + var result6 = result7; } else { - var result5 = null;; + var result6 = null;; }; } - while (result5 !== null) { - result3.push(result5); + while (result6 !== null) { + result4.push(result6); if (input.substr(pos).match(/^[^"\\\n\r]/) !== null) { - var result7 = input.charAt(pos); + var result8 = input.charAt(pos); pos++; } else { - var result7 = null; + var result8 = null; if (reportMatchFailures) { matchFailed("[^\"\\\\\\n\\r]"); } } - if (result7 !== null) { - var result5 = result7; + if (result8 !== null) { + var result6 = result8; } else { - var result6 = parse_ECHAR(); - if (result6 !== null) { - var result5 = result6; + var result7 = parse_ECHAR(); + if (result7 !== null) { + var result6 = result7; } else { - var result5 = null;; + var result6 = null;; }; } } - if (result3 !== null) { + if (result4 !== null) { if (input.substr(pos, 1) === "\"") { - var result4 = "\""; + var result5 = "\""; pos += 1; } else { - var result4 = null; + var result5 = null; if (reportMatchFailures) { matchFailed("\"\\\"\""); } } - if (result4 !== null) { - var result1 = [result2, result3, result4]; + if (result5 !== null) { + var result1 = [result3, result4, result5]; } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } - var result0 = result1 !== null + var result2 = result1 !== null ? (function(content) { return flattenString(content) })(result1[1]) : null; + if (result2 !== null) { + var result0 = result2; + } else { + var result0 = null; + pos = savedPos0; + } reportMatchFailures = savedReportMatchFailures; if (reportMatchFailures && result0 === null) { matchFailed("[140] STRING_LITERAL2"); @@ -33963,85 +24785,92 @@ SparqlParser.parser = (function(){ var savedReportMatchFailures = reportMatchFailures; reportMatchFailures = false; var savedPos0 = pos; + var savedPos1 = pos; if (input.substr(pos, 3) === "'''") { - var result2 = "'''"; + var result3 = "'''"; pos += 3; } else { - var result2 = null; + var result3 = null; if (reportMatchFailures) { matchFailed("\"'''\""); } } - if (result2 !== null) { - var result3 = []; + if (result3 !== null) { + var result4 = []; if (input.substr(pos).match(/^[^'\\]/) !== null) { - var result7 = input.charAt(pos); + var result8 = input.charAt(pos); pos++; } else { - var result7 = null; + var result8 = null; if (reportMatchFailures) { matchFailed("[^'\\\\]"); } } - if (result7 !== null) { - var result5 = result7; + if (result8 !== null) { + var result6 = result8; } else { - var result6 = parse_ECHAR(); - if (result6 !== null) { - var result5 = result6; + var result7 = parse_ECHAR(); + if (result7 !== null) { + var result6 = result7; } else { - var result5 = null;; + var result6 = null;; }; } - while (result5 !== null) { - result3.push(result5); + while (result6 !== null) { + result4.push(result6); if (input.substr(pos).match(/^[^'\\]/) !== null) { - var result7 = input.charAt(pos); + var result8 = input.charAt(pos); pos++; } else { - var result7 = null; + var result8 = null; if (reportMatchFailures) { matchFailed("[^'\\\\]"); } } - if (result7 !== null) { - var result5 = result7; + if (result8 !== null) { + var result6 = result8; } else { - var result6 = parse_ECHAR(); - if (result6 !== null) { - var result5 = result6; + var result7 = parse_ECHAR(); + if (result7 !== null) { + var result6 = result7; } else { - var result5 = null;; + var result6 = null;; }; } } - if (result3 !== null) { + if (result4 !== null) { if (input.substr(pos, 3) === "'''") { - var result4 = "'''"; + var result5 = "'''"; pos += 3; } else { - var result4 = null; + var result5 = null; if (reportMatchFailures) { matchFailed("\"'''\""); } } - if (result4 !== null) { - var result1 = [result2, result3, result4]; + if (result5 !== null) { + var result1 = [result3, result4, result5]; } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } - var result0 = result1 !== null + var result2 = result1 !== null ? (function(content) { return flattenString(content) })(result1[1]) : null; + if (result2 !== null) { + var result0 = result2; + } else { + var result0 = null; + pos = savedPos0; + } reportMatchFailures = savedReportMatchFailures; if (reportMatchFailures && result0 === null) { matchFailed("[141] STRING_LITERAL_LONG1"); @@ -34065,85 +24894,92 @@ SparqlParser.parser = (function(){ var savedReportMatchFailures = reportMatchFailures; reportMatchFailures = false; var savedPos0 = pos; + var savedPos1 = pos; if (input.substr(pos, 3) === "\"\"\"") { - var result2 = "\"\"\""; + var result3 = "\"\"\""; pos += 3; } else { - var result2 = null; + var result3 = null; if (reportMatchFailures) { matchFailed("\"\\\"\\\"\\\"\""); } } - if (result2 !== null) { - var result3 = []; + if (result3 !== null) { + var result4 = []; if (input.substr(pos).match(/^[^"\\]/) !== null) { - var result7 = input.charAt(pos); + var result8 = input.charAt(pos); pos++; } else { - var result7 = null; + var result8 = null; if (reportMatchFailures) { matchFailed("[^\"\\\\]"); } } - if (result7 !== null) { - var result5 = result7; + if (result8 !== null) { + var result6 = result8; } else { - var result6 = parse_ECHAR(); - if (result6 !== null) { - var result5 = result6; + var result7 = parse_ECHAR(); + if (result7 !== null) { + var result6 = result7; } else { - var result5 = null;; + var result6 = null;; }; } - while (result5 !== null) { - result3.push(result5); + while (result6 !== null) { + result4.push(result6); if (input.substr(pos).match(/^[^"\\]/) !== null) { - var result7 = input.charAt(pos); + var result8 = input.charAt(pos); pos++; } else { - var result7 = null; + var result8 = null; if (reportMatchFailures) { matchFailed("[^\"\\\\]"); } } - if (result7 !== null) { - var result5 = result7; + if (result8 !== null) { + var result6 = result8; } else { - var result6 = parse_ECHAR(); - if (result6 !== null) { - var result5 = result6; + var result7 = parse_ECHAR(); + if (result7 !== null) { + var result6 = result7; } else { - var result5 = null;; + var result6 = null;; }; } } - if (result3 !== null) { + if (result4 !== null) { if (input.substr(pos, 3) === "\"\"\"") { - var result4 = "\"\"\""; + var result5 = "\"\"\""; pos += 3; } else { - var result4 = null; + var result5 = null; if (reportMatchFailures) { matchFailed("\"\\\"\\\"\\\"\""); } } - if (result4 !== null) { - var result1 = [result2, result3, result4]; + if (result5 !== null) { + var result1 = [result3, result4, result5]; } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } - var result0 = result1 !== null + var result2 = result1 !== null ? (function(content) { return flattenString(content) })(result1[1]) : null; + if (result2 !== null) { + var result0 = result2; + } else { + var result0 = null; + pos = savedPos0; + } reportMatchFailures = savedReportMatchFailures; if (reportMatchFailures && result0 === null) { matchFailed("[142] STRING_LITERAL_LONG2"); @@ -34219,47 +25055,48 @@ SparqlParser.parser = (function(){ var savedReportMatchFailures = reportMatchFailures; reportMatchFailures = false; var savedPos0 = pos; + var savedPos1 = pos; if (input.substr(pos, 1) === "(") { - var result2 = "("; + var result3 = "("; pos += 1; } else { - var result2 = null; + var result3 = null; if (reportMatchFailures) { matchFailed("\"(\""); } } - if (result2 !== null) { - var result3 = []; - var result5 = parse_WS(); - while (result5 !== null) { - result3.push(result5); - var result5 = parse_WS(); + if (result3 !== null) { + var result4 = []; + var result6 = parse_WS(); + while (result6 !== null) { + result4.push(result6); + var result6 = parse_WS(); } - if (result3 !== null) { + if (result4 !== null) { if (input.substr(pos, 1) === ")") { - var result4 = ")"; + var result5 = ")"; pos += 1; } else { - var result4 = null; + var result5 = null; if (reportMatchFailures) { matchFailed("\")\""); } } - if (result4 !== null) { - var result1 = [result2, result3, result4]; + if (result5 !== null) { + var result1 = [result3, result4, result5]; } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } - var result0 = result1 !== null + var result2 = result1 !== null ? (function() { return {token: "triplesnodecollection", @@ -34267,6 +25104,12 @@ SparqlParser.parser = (function(){ chainSubject:[{token:'uri', value:"http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"}]}; })() : null; + if (result2 !== null) { + var result0 = result2; + } else { + var result0 = null; + pos = savedPos0; + } reportMatchFailures = savedReportMatchFailures; if (reportMatchFailures && result0 === null) { matchFailed("[144] NIL"); @@ -34744,159 +25587,166 @@ SparqlParser.parser = (function(){ var savedReportMatchFailures = reportMatchFailures; reportMatchFailures = false; var savedPos0 = pos; - var result11 = parse_PN_CHARS_U(); - if (result11 !== null) { - var result2 = result11; + var savedPos1 = pos; + var result12 = parse_PN_CHARS_U(); + if (result12 !== null) { + var result3 = result12; } else { if (input.substr(pos).match(/^[0-9]/) !== null) { - var result10 = input.charAt(pos); + var result11 = input.charAt(pos); pos++; } else { - var result10 = null; + var result11 = null; if (reportMatchFailures) { matchFailed("[0-9]"); } } - if (result10 !== null) { - var result2 = result10; + if (result11 !== null) { + var result3 = result11; } else { - var result2 = null;; + var result3 = null;; }; } - if (result2 !== null) { - var result3 = []; - var result9 = parse_PN_CHARS_U(); - if (result9 !== null) { - var result4 = result9; + if (result3 !== null) { + var result4 = []; + var result10 = parse_PN_CHARS_U(); + if (result10 !== null) { + var result5 = result10; } else { if (input.substr(pos).match(/^[0-9]/) !== null) { - var result8 = input.charAt(pos); + var result9 = input.charAt(pos); pos++; } else { - var result8 = null; + var result9 = null; if (reportMatchFailures) { matchFailed("[0-9]"); } } - if (result8 !== null) { - var result4 = result8; + if (result9 !== null) { + var result5 = result9; } else { if (input.substr(pos).match(/^[\xB7]/) !== null) { - var result7 = input.charAt(pos); + var result8 = input.charAt(pos); pos++; } else { - var result7 = null; + var result8 = null; if (reportMatchFailures) { matchFailed("[\\xB7]"); } } - if (result7 !== null) { - var result4 = result7; + if (result8 !== null) { + var result5 = result8; } else { if (input.substr(pos).match(/^[\u0300-\u036F]/) !== null) { - var result6 = input.charAt(pos); + var result7 = input.charAt(pos); pos++; } else { - var result6 = null; + var result7 = null; if (reportMatchFailures) { matchFailed("[\\u0300-\\u036F]"); } } - if (result6 !== null) { - var result4 = result6; + if (result7 !== null) { + var result5 = result7; } else { if (input.substr(pos).match(/^[\u203F-\u2040]/) !== null) { - var result5 = input.charAt(pos); + var result6 = input.charAt(pos); pos++; } else { - var result5 = null; + var result6 = null; if (reportMatchFailures) { matchFailed("[\\u203F-\\u2040]"); } } - if (result5 !== null) { - var result4 = result5; + if (result6 !== null) { + var result5 = result6; } else { - var result4 = null;; + var result5 = null;; }; }; }; }; } - while (result4 !== null) { - result3.push(result4); - var result9 = parse_PN_CHARS_U(); - if (result9 !== null) { - var result4 = result9; + while (result5 !== null) { + result4.push(result5); + var result10 = parse_PN_CHARS_U(); + if (result10 !== null) { + var result5 = result10; } else { if (input.substr(pos).match(/^[0-9]/) !== null) { - var result8 = input.charAt(pos); + var result9 = input.charAt(pos); pos++; } else { - var result8 = null; + var result9 = null; if (reportMatchFailures) { matchFailed("[0-9]"); } } - if (result8 !== null) { - var result4 = result8; + if (result9 !== null) { + var result5 = result9; } else { if (input.substr(pos).match(/^[\xB7]/) !== null) { - var result7 = input.charAt(pos); + var result8 = input.charAt(pos); pos++; } else { - var result7 = null; + var result8 = null; if (reportMatchFailures) { matchFailed("[\\xB7]"); } } - if (result7 !== null) { - var result4 = result7; + if (result8 !== null) { + var result5 = result8; } else { if (input.substr(pos).match(/^[\u0300-\u036F]/) !== null) { - var result6 = input.charAt(pos); + var result7 = input.charAt(pos); pos++; } else { - var result6 = null; + var result7 = null; if (reportMatchFailures) { matchFailed("[\\u0300-\\u036F]"); } } - if (result6 !== null) { - var result4 = result6; + if (result7 !== null) { + var result5 = result7; } else { if (input.substr(pos).match(/^[\u203F-\u2040]/) !== null) { - var result5 = input.charAt(pos); + var result6 = input.charAt(pos); pos++; } else { - var result5 = null; + var result6 = null; if (reportMatchFailures) { matchFailed("[\\u203F-\\u2040]"); } } - if (result5 !== null) { - var result4 = result5; + if (result6 !== null) { + var result5 = result6; } else { - var result4 = null;; + var result5 = null;; }; }; }; }; } } - if (result3 !== null) { - var result1 = [result2, result3]; + if (result4 !== null) { + var result1 = [result3, result4]; } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } - var result0 = result1 !== null + var result2 = result1 !== null ? (function(init, rpart) { return init+rpart.join('') })(result1[0], result1[1]) : null; + if (result2 !== null) { + var result0 = result2; + } else { + var result0 = null; + pos = savedPos0; + } reportMatchFailures = savedReportMatchFailures; if (reportMatchFailures && result0 === null) { matchFailed("[149] VARNAME"); @@ -35013,67 +25863,74 @@ SparqlParser.parser = (function(){ var savedReportMatchFailures = reportMatchFailures; reportMatchFailures = false; var savedPos0 = pos; - var result2 = parse_PN_CHARS_BASE(); - if (result2 !== null) { - var result3 = []; - var result6 = parse_PN_CHARS(); - if (result6 !== null) { - var result4 = result6; + var savedPos1 = pos; + var result3 = parse_PN_CHARS_BASE(); + if (result3 !== null) { + var result4 = []; + var result7 = parse_PN_CHARS(); + if (result7 !== null) { + var result5 = result7; } else { if (input.substr(pos, 1) === ".") { - var result5 = "."; + var result6 = "."; pos += 1; } else { - var result5 = null; + var result6 = null; if (reportMatchFailures) { matchFailed("\".\""); } } - if (result5 !== null) { - var result4 = result5; + if (result6 !== null) { + var result5 = result6; } else { - var result4 = null;; + var result5 = null;; }; } - while (result4 !== null) { - result3.push(result4); - var result6 = parse_PN_CHARS(); - if (result6 !== null) { - var result4 = result6; + while (result5 !== null) { + result4.push(result5); + var result7 = parse_PN_CHARS(); + if (result7 !== null) { + var result5 = result7; } else { if (input.substr(pos, 1) === ".") { - var result5 = "."; + var result6 = "."; pos += 1; } else { - var result5 = null; + var result6 = null; if (reportMatchFailures) { matchFailed("\".\""); } } - if (result5 !== null) { - var result4 = result5; + if (result6 !== null) { + var result5 = result6; } else { - var result4 = null;; + var result5 = null;; }; } } - if (result3 !== null) { - var result1 = [result2, result3]; + if (result4 !== null) { + var result1 = [result3, result4]; } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } - var result0 = result1 !== null + var result2 = result1 !== null ? (function(base, rest) { if(rest[rest.length-1] == '.'){ throw new Error("Wrong PN_PREFIX, cannot finish with '.'") } else { return base + rest.join(''); }})(result1[0], result1[1]) : null; + if (result2 !== null) { + var result0 = result2; + } else { + var result0 = null; + pos = savedPos0; + } reportMatchFailures = savedReportMatchFailures; if (reportMatchFailures && result0 === null) { matchFailed("[151] PN_PREFIX"); @@ -35097,47 +25954,54 @@ SparqlParser.parser = (function(){ var savedReportMatchFailures = reportMatchFailures; reportMatchFailures = false; var savedPos0 = pos; - var result6 = parse_PN_CHARS_U(); - if (result6 !== null) { - var result2 = result6; + var savedPos1 = pos; + var result7 = parse_PN_CHARS_U(); + if (result7 !== null) { + var result3 = result7; } else { if (input.substr(pos).match(/^[0-9]/) !== null) { - var result5 = input.charAt(pos); + var result6 = input.charAt(pos); pos++; } else { - var result5 = null; + var result6 = null; if (reportMatchFailures) { matchFailed("[0-9]"); } } - if (result5 !== null) { - var result2 = result5; + if (result6 !== null) { + var result3 = result6; } else { - var result2 = null;; + var result3 = null;; }; } - if (result2 !== null) { - var result3 = []; - var result4 = parse_PN_CHARS(); - while (result4 !== null) { - result3.push(result4); - var result4 = parse_PN_CHARS(); + if (result3 !== null) { + var result4 = []; + var result5 = parse_PN_CHARS(); + while (result5 !== null) { + result4.push(result5); + var result5 = parse_PN_CHARS(); } - if (result3 !== null) { - var result1 = [result2, result3]; + if (result4 !== null) { + var result1 = [result3, result4]; } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } } else { var result1 = null; - pos = savedPos0; + pos = savedPos1; } - var result0 = result1 !== null + var result2 = result1 !== null ? (function(base, rest) { return base + rest.join(''); })(result1[0], result1[1]) : null; + if (result2 !== null) { + var result0 = result2; + } else { + var result0 = null; + pos = savedPos0; + } reportMatchFailures = savedReportMatchFailures; if (reportMatchFailures && result0 === null) { matchFailed("[152] PN_LOCAL"); @@ -35341,9 +26205,57 @@ SparqlParser.parser = (function(){ result.SyntaxError.prototype = Error.prototype; return result; -})(); +})(); +// end of ./src/js-sparql-parser/src/sparql_parser.js +// exports +var TurtleParser = {}; + +var statementCounter = 0; +var timer = new Date().getTime(); +var printTime = function() { + var newTimer = new Date().getTime(); + console.log("ellapsed: "+((newTimer-timer)/1000)+" secs"); + timer = newTimer; +}; + +// imports + +TurtleParser.combined_parser = SparqlParser.parser; + +TurtleParser.parser = {}; +TurtleParser.parser.parse = function(data, graph) { + var quads = []; + + var result = TurtleParser.combined_parser.parse(data); + var namespaces = {}; + var env = {namespaces: namespaces, base:'', blankCounter: 0}; + + statementCounter = 0; + + for(var i=0; i"; } return tmp; @@ -35935,8 +26854,8 @@ RDFJSInterface.buildRDFResource = function(value, bindings, engine, env) { }; RDFJSInterface.buildBlankNode = function(value, bindings, engine, env) { - if(value.value == null && value.label) { - value.value = value.label; + if(value.valuetmp != null) { + value.value = value.valuetmp; } if(value.value.indexOf("_:") === 0) { value.value = value.value.split("_:")[1]; @@ -35970,7 +26889,7 @@ var QueryFilters = {}; // imports -QueryFilters.checkFilters = function(pattern, bindings, nullifyErrors, queryEnv, queryEngine) { +QueryFilters.checkFilters = function(pattern, bindings, nullifyErrors, dataset, queryEnv, queryEngine) { var filters = pattern.filter; var nullified = []; @@ -35981,7 +26900,7 @@ QueryFilters.checkFilters = function(pattern, bindings, nullifyErrors, queryEnv, for(var i=0; i true/false/error var ebv = QueryFilters.ebv(ebv); @@ -36086,12 +27005,12 @@ QueryFilters.run = function(filterExpr, bindings, nullifyFilters, env, queryEngi return filteredBindings; }; -QueryFilters.collect = function(filterExpr, bindings, env, queryEngine, callback) { +QueryFilters.collect = function(filterExpr, bindings, dataset, env, queryEngine, callback) { var denormBindings = queryEngine.copyDenormalizedBindings(bindings, env.outCache); var filteredBindings = []; for(var i=0; i0 } } - return QueryPlan.buildBushyJoinTreeBranches(acum); + return 0; }; -// @todo -// remove recursion here -QueryPlan.buildBushyJoinTreeBranches = function(bindingsList) { - if(bindingsList.length === 1){ - return bindingsList[0]; - } else { - var pairs = Utils.partition(bindingsList,2); - var acum = []; - for(var i=0; i "+treeNode.i); + //console.log("** left:"); + //console.log(resultsLeft); + //console.log("** right:"); + //console.log(resultsRight); + //console.log("JOINING..."); + //console.log(resultsLeft); + //console.log(resultsRight); + //console.log("--------------"); + var bindings = QueryPlanDPSize.joinBindings2(treeNode.join, resultsLeft, resultsRight); + //var bindings = QueryPlanDPSize.joinBindings(resultsLeft, resultsRight); + //console.log(bindings); + return bindings; } else { - return QueryPlan.joinBindings(bindingsa,bindingsb); + return null; } } } }; -QueryPlan.executeAndBGP = function(bgpa, bgpb, dataset, queryEngine, queryEnv) { - if(bgpa==null) { - return QueryPlan.executeEmptyJoinBGP(bgpb, dataset, queryEngine, queryEnv); - } else if(bgpb==null) { - return QueryPlan.executeEmptyJoinBGP(bgpa, dataset, queryEngine, queryEnv); - } else { - var joinVars = QueryPlan.variablesIntersectionBGP(bgpa,bgpb); - if(joinVars.length === 0) { - // range a, range b -> cartesian product - return QueryPlan.executeCrossProductBGP(joinVars, bgpa, bgpb, dataset, queryEngine, queryEnv); - } else { - // join on intersection vars - return QueryPlan.executeJoinBGP(joinVars, bgpa, bgpb, dataset, queryEngine, queryEnv); + +//@modified dp +QueryPlanDPSize.executeAndBGPsDPSize = function(allBgps, dataset, queryEngine, env) { + var groups = QueryPlanDPSize.executeAndBGPsGroups(allBgps); + var groupResults = []; + for(var g=0; gplan.cost) { + maxPlan = plan; + } + } + + //console.log("BEST PLANS"); + //console.log(bestPlans); + + // dynamic programming -> build plans of increasing size + for(var s=2; s<=bgps.length; s++) { // size + //console.log("\n\n\n*********************ITERATION"); + //console.log(s); + for(var sl=1; sl currPlan.cost) { + if(maxSize === s) { + maxPlan = currPlan; + } + bestPlans[currPlan.i] = currPlan; + } + } + } + } + } + } + } } + + //console.log(sizes); + + //console.log("==== FOUND ==="); + //console.log(maxPlan); + groupResults.push(maxPlan); } -}; -QueryPlan.executeEmptyJoinBGP = function(bgp, dataset, queryEngine, queryEnv) { - return QueryPlan.executeBGPDatasets(bgp, dataset, queryEngine, queryEnv); -}; -QueryPlan.executeJoinBGP = function(joinVars, bgpa, bgpb, dataset, queryEngine, queryEnv) { - var bindingsa = QueryPlan.executeBGPDatasets(bgpa, dataset, queryEngine, queryEnv); - if(bindingsa!=null) { - var bindingsb = QueryPlan.executeBGPDatasets(bgpb, dataset, queryEngine, queryEnv); - if(bindingsb!=null) { - return QueryPlan.joinBindings(bindingsa, bindingsb); + // now execute the Bushy trees and perform + // cross products between groups + var acum = null; + + for(var g=0; g 0) { for(var i=0; i ?p ?o } WHERE { GRAPH <" + graphUri + "> { <" + uri + "> ?p ?o } }"; var that = this; var queryEnv = {blanks:{}, outCache:{}}; + this.engine.registerNsInEnvironment(null, queryEnv); var bindings = []; this.engine.execute(query, function(success, graph){ if(success) { @@ -39866,6 +31331,7 @@ Callbacks.CallbacksBackend.prototype.observeQuery = function(query, callback, en var patterns = this.aqt.collectBasicTriples(parsedTree); var that = this; var queryEnv = {blanks:{}, outCache:{}}; + this.engine.registerNsInEnvironment(null, queryEnv); var floop, pattern, quad, indexKey, indexOrder, index; var counter = this.queryCounter; @@ -39887,8 +31353,8 @@ Callbacks.CallbacksBackend.prototype.observeQuery = function(query, callback, en indexOrder = that.componentOrders[indexKey]; index = that.queriesIndexMap[indexKey]; - for(var i=0; i + *
+ * The first argument to this function is the URL/FS location + * of the store script. + *
+ *
+ * This parameter is mandatory in the browser. It is safe to + * ignore this parameter in Node.js. + *
+ *
+ * If support for web workers is not present, a regular + * store object will be initialized and returned. + *
+ *
+ * + * @param {String} [scriptPath] URL of the RDFStore script + * @param {Object[]} [args] Arguments to be passed to the store that will be created + * @param {Function} callback Callback function that will be invoked with an error flag and the connection/store object. + */ +Store.connect = function() { + var path, args, callback; + if(arguments.length == 1) { + path = __dirname; + args = {}; + callback = arguments[0]; + } if(arguments.length == 2) { + if(typeof(arguments[0]) === 'string') { + path = arguments[0]; + args = {}; + } else { + path = __dirname+"/index.js"; + args = arguments[0]; + } + callback = arguments[1]; + } else { + path = arguments[0]; + args = arguments[1]; + callback = arguments[2]; + } + try { + if(!!Worker) { + new RDFStoreClient.RDFStoreClient(path, args, function(success,connection) { + callback(success, connection); + }); + } else { + Store.create(args,function(connection){ + callback(false, connection); + }); + } + } catch(e) { + Store.create(args,function(connection){ + callback(false, connection); + }); + } +}; +/** + * Creates a new instance of the store. + * + * The function accepts two optional arguments. + *
+ * If only one argument is passed it must be a + * callback function that will be invoked when the + * store had been created.
+ *
+ * If two arguments are passed the first one must + * be a map of configuration parameters for the + * store, and the second one the callback function.
+ *
+ * Take a look at the Store constructor function for + * a detailed list of possible configuration parameters.
+ * + * @param {Object[]} [args] Arguments to be passed to the store that will be created + * @param {Function} [callback] Callback function that will be invoked with an error flag and the connection/store object. + */ Store.create = function(){ if(arguments.length == 1) { return new Store.Store(arguments[0]); @@ -40002,6 +32021,27 @@ Store.create = function(){ }; }; +/** + * Creates a new store.
+ *
+ * It accepts two optional arguments, a map of configuration + * options for the store and a callback function.
+ * + * @constructor + * @param {Function} [callback] Callback that will be invoked when the store has been created + * @param {Object} [params] + *
    + *
  • persistent: should the store use persistence?
  • + *
  • treeOrder: in versions of the store backed by the native indexing system, the order of the BTree indices
  • + *
  • name: when using persistence, the name for this store. In the MongoDB backed version, name of the DB used by the store. By default 'rdfstore_js' is used
  • + *
  • overwrite: clears the persistent storage
  • + *
  • maxCacheSize: if using persistence, maximum size of the index cache
  • + *
  • engine: the persistent storage to use, a value mongodb selects the MongoDB engine
  • + *
  • mongoDomain: when engine=mongodb, server domain name or IP address where the MongoDB server backing the store is running. By default '127.0.0.1' is used
  • + *
  • mongoPort: when engine=mongodb, port where the MongoDB server is running. By default 27017 is used
  • + *
  • mongoOptions: when engine=mongodb, additional options for the MongoDB driver. By default {} is used
  • + *
+ */ Store.Store = function(arg1, arg2) { var callback = null; var params = null; @@ -40022,43 +32062,77 @@ Store.Store = function(arg1, arg2) { params['treeOrder'] = 15; } - this.rdf = RDFJSInterface.rdf; this.functionMap = {}; var that = this; - new Lexicon.Lexicon(function(lexicon){ - new QuadBackend.QuadBackend(params, function(backend){ - params.backend = backend; - params.lexicon =lexicon; - that.engine = new QueryEngine.QueryEngine(params); - if(callback) { + if(params['engine']==='mongodb') { + this.isMongodb = true; + this.engine = new MongodbQueryEngine.MongodbQueryEngine(params); + this.engine.readConfiguration(function(){ + if(params['overwrite'] === true) { + that.engine.clean(function(){ + callback(that); + }); + } else { callback(that); } - }) - }); + }); + } else { + new Lexicon.Lexicon(function(lexicon){ + if(params['overwrite'] === true) { + // delete lexicon values + lexicon.clear(); + } + new QuadBackend.QuadBackend(params, function(backend){ + if(params['overwrite'] === true) { + // delete index values + backend.clear(); + } + params.backend = backend; + params.lexicon =lexicon; + that.engine = new QueryEngine.QueryEngine(params); + if(callback) { + callback(that); + } + }); + },params['name']); + } }; /** - * Executes a query in the store. - * There are two possible way of invoking this function, + * An instance of RDF JS Interface RDFEnvironment + * associated to this graph instance. + */ +Store.Store.prototype.rdf = RDFJSInterface.rdf; + +/** + * Executes a query in the store.
+ *
+ * There are two possible ways of invoking this function, * providing a pair of arrays of namespaces that will be * used to compute the union of the default and named * dataset, or without them. + *
+ *
* Both invocations receive as an optional last parameter * a callback function that will receive the return status * of the query and the results. - * - * @arguments: - * 1) - * - query - * - callback (optional) - * - * 2) - * - query - * - URIs default namespaces - * - URIs named namespaces - * - callback (optional) + *
+ *
+ * Results can have different formats: + *
    + *
  • SELECT queries: array of binding maps
  • + *
  • CONSTRUCT queries: RDF JS Interface Graph object
  • + *
  • ASK queries: JS boolean value
  • + *
  • LOAD/INSERT... queries: Number of triples modified/inserted
  • + *
+ * + * @arguments: + * @param {String} query + * @param {String} [defaultURIs] default namespaces + * @param {String} [namespacesURIs] named namespaces + * @param {Function} [callback] */ Store.Store.prototype.execute = function() { if(arguments.length === 3) { @@ -40077,7 +32151,7 @@ Store.Store.prototype.execute = function() { if(arguments.length === 1) { queryString = arguments[0]; - callback = function(){}; + var callback = function(){}; } else if(arguments.length === 2) { queryString = arguments[0]; callback = arguments [1]; @@ -40086,27 +32160,59 @@ Store.Store.prototype.execute = function() { } }; +/** + * A variation of the execute function that expects + * arguments containing values for the default and named + * graphs that will be used in the query. + * + * + * @arguments: + * @param {String} query + * @param {String} URIs default namespaces + * @param {String} URIs named namespaces + * @param {Function} [callback] + */ Store.Store.prototype.executeWithEnvironment = function() { - var queryString; - var callback; - var defaultGraphs; - var namedGraphs; + var queryString, defaultGraphs, namedGraphs; if(arguments.length === 3) { - queryString = arguments[0]; - callback = function(){}; + queryString = arguments[0]; + // JSDoc fails if this is pushed outside + var callback = function(){}; defaultGraphs = arguments[1]; - namedGraphs = arguments[2]; + namedGraphs = arguments[2]; } else if(arguments.length === 4) { - queryString = arguments[0]; - callback = arguments [3]; + queryString = arguments[0]; + var callback = arguments [3]; defaultGraphs = arguments[1]; - namedGraphs = arguments[2]; - + namedGraphs = arguments[2]; + } + var defaultGraphsNorm = []; + var namedGraphsNorm = []; + for(var i=0; i + *
+ * The function accepts as mandatory parameter a callback + * function that will receive the a success notification and the returned graph.
+ *
+ * Optionally, the URI of the graph can also be passed as + * the first argument. If no graph is specified, the + * default graph will be returned.
+ * + * @arguments + * @param {String} [graphURI] If this parameter is missing, the default graph will be returned + * @param {Functon} callback + */ Store.Store.prototype.graph = function() { var graphUri = null; var callback = null; @@ -40127,9 +32233,28 @@ Store.Store.prototype.graph = function() { this.engine.execute("CONSTRUCT { ?s ?p ?o } WHERE { GRAPH <" + graphUri + "> { ?s ?p ?o } }", callback); }; - +/** + * Retrieves all the quads belonging to a certain node + * in the store as a RDF JS Interface Graph object containing + * the collection of triples whose subject is the provided + * node URI.
+ *
+ * The function accepts as mandatory parameters the node URI and + * a callback unction that will receive a success notification and the returned node.
+ *
+ * Optionally, the URI of the graph where the node is contained + * can also be passed as the first argument.
+ *
+ * If no graph is specified, the node will be looked into the + * default graph.
+ * + * @arguments + * @param {String} nodeURI URI of the node to look for + * @param {String} [graphURI] If this parameter is missing, the node will be looked into the default graph + * @param {Functon} callback + */ Store.Store.prototype.node = function() { - var graphUri = null; + var graphUri = null; var callback = null; var nodeUri = null; if(arguments.length === 2) { @@ -40141,7 +32266,7 @@ Store.Store.prototype.node = function() { graphUri = arguments[1]; callback = arguments[2] || function(){}; } else { - throw("An optional graph URI and a callback function must be provided"); + throw("An optional graph URI, node URI and a callback function must be provided"); } if(this.rdf.resolve(graphUri) != null) { @@ -40155,6 +32280,30 @@ Store.Store.prototype.node = function() { this.engine.execute("CONSTRUCT { <" + nodeUri + "> ?p ?o } WHERE { GRAPH <" + graphUri + "> { <" + nodeUri + "> ?p ?o } }", callback); }; +/** + * Associates an event listener function to a node URI. Every time the collection + * of triples whose subject is the specified node URI changes, because an + * insertion or deletion, the provided callback function will be invoked + * receiving as a parameter a RDF JS Interface Graph object with the new + * collection of triples.
+ *
+ * The function accepts two mandatory arguments, the URI of the node to observe + * and the function that will receive the event notifications. An optional + * third parameter, consisting of a callback function, can be passed and will be invoked + * once the store had correctly configured the event listener.
+ *
+ * LOAD queries, batch loading data into the store, do not + * trigger events by default. If you wish to be notified + * by changes triggered by this kind of queries, invoke + * the *setBatchLoadEvents* function with a true argument.
+ *
+ * The event listener function can be removed using the stopObservingNode function. + * + * @arguments + * @param {String} nodeURI URI of the node to observe + * @param {Function} eventListener Function that will be notified with the events + * @param {Function} [callback] Function that will be invoked, once the event listener had been correctly set up. + */ Store.Store.prototype.startObservingNode = function() { var uri, graphUri, callback; @@ -40170,10 +32319,38 @@ Store.Store.prototype.startObservingNode = function() { } }; +/** + * Removes a callback function associated to a node.
+ * The event listener function object must be passed as an argument.
+ * + * @arguments + * @param {Function} eventListener The event listener function to remove, the same passed as an argument to startObservingNode + */ Store.Store.prototype.stopObservingNode = function(callback) { this.engine.callbacksBackend.stopObservingNode(callback); }; +/** + * Associates an event listener function to a SPARQL SELECT or + * CONSTRUCT query.
+ * Every time an update (insert, delete...) query modified the + * triples in the store in a way that modifies the output of the + * query, the event listener will be invoked with an updated + * result.
+ *
+ * LOAD queries, batch loading data into the store, do not + * trigger events by default. If you wish to be notified + * by changes triggered by this kind of queries, invoke + * the setBatchLoadEvents function with a true argument.
+ *
+ * The event listener function can be removed invoking the + * stopObservingQuery function. + * + * @arguments + * @param {String} query SELECT or CONSTRUCT SPARQL query + * @param {Function} eventListener the function that will receive the notifications + * @param {Function} [callback] optional function that will be invoked when the stored had set up the event listener function. + */ Store.Store.prototype.startObservingQuery = function() { var query = arguments[0]; var callback = arguments[1]; @@ -40185,10 +32362,40 @@ Store.Store.prototype.startObservingQuery = function() { } }; +/** + * Removes a callback function associated to a SPARQL query.
+ * The event listener function object must be passed as an argument. + * + * @arguments + * @param {Function} eventListener The event listener function to remove, the same passed as an argument to startObservingQuery + */ Store.Store.prototype.stopObservingQuery = function(query) { this.engine.callbacksBackend.stopObservingQuery(query); }; +/** + * Associates an event listener to a pattern expressed as the + * subject, predicate, object and graph string parameters passed + * to the function. To match any value in that position, a null + * value can be passed as an argument. e.g. subscribe(null, null, null, g, cb), + * will be notified with any change in the g graph.
+ * The graph component of the pattern does not support a null value.
+ *
+ * Results will be notified as an Array of RDF JS Interface + * Triple objects.
+ *
+ * LOAD queries, batch loading data into the store, do not + * trigger events by default. If you wish to be notified + * by changes triggered by this kind of queries, invoke + * the setBatchLoadEvents function with a true argument. + * + * @arguments + * @param {String} s subject or null for any subject + * @param {String} p predicate or null for any predicate + * @param {String} o object or null for any object + * @param {String} g graph or null for any graph + * @param {Function} event listener function that will be notified when a change occurs + */ Store.Store.prototype.subscribe = function(s, p, o, g, callback) { var adapterCb = function(event,triples){ var acum = []; @@ -40207,26 +32414,68 @@ Store.Store.prototype.subscribe = function(s, p, o, g, callback) { } callback(event,acum); - } + }; this.functionMap[callback] = adapterCb; this.engine.callbacksBackend.subscribe(s,p,o,g,adapterCb,function(){}); }; +/** + * Removes an event listener associated to a certain pattern. + * The function passed as an argument to subscribe must be + * passed as an argument. + * + * @arguments + * @param {Function} callback The event listener to be removed + */ Store.Store.prototype.unsubscribe = function(callback) { var adapterCb = this.functionMap[callback]; this.engine.callbacksBackend.unsubscribe(adapterCb); delete this.functionMap[callback]; }; +/** + * Register a combination of prefix and URI fragment in the default instance + * of the RDF JS Interface API RDFEnvironment object associated + * to the store and available through the storeInstance.rdf property. + * + * @arguments + * @param {String} prefix The prefix to be associated + * @param {String} URIFragment URI fragment the provided prefix will be resolved + */ Store.Store.prototype.setPrefix = function(prefix, uri) { - this.rdf.setPrefix(prefix, uri) + this.rdf.setPrefix(prefix, uri); }; +/** + * Defines the URI that will be used by default by the RDF JS Interface + * API RDFEnvironment object associated to the store and available + * through the storeInstance.rdf property. + * + * @arguments + * @param {String} URIFragment The URI fragment will be used by default + */ Store.Store.prototype.setDefaultPrefix = function(uri) { - this.rdf.setDefaultPrefix(uri) + this.rdf.setDefaultPrefix(uri); }; +/** + * Inserts a RDF JS Interface API Graph object into the store. + * The function receives a mandatory Graph object whose triples + * will be inserted. Optionally, a URI string for a graph and a + * callback function can be passed as arguments.
+ *
+ * If no graph URI is specified, triples will be inserted into the + * default graph.
+ *
+ * If the callback function is specified, it will be invoked when all the + * triples had been inserted into the store.
+ * + * @arguments + * @param {RDFJSInterface.Graph} triples a RDF JS Interface Graph object + * @param {String} [graphURI] URI of the graph where the triples will be inserted. If it is missing, triples will be inserted in the default graph + * @param {String} [callback] A callback function that will be invoked with a success notification and the number of triples inserted + */ Store.Store.prototype.insert = function() { var graph; var triples; @@ -40271,11 +32520,34 @@ Store.Store.prototype._nodeToQuery = function(term) { } else if(term.interfaceName === '') { return term.toString(); } else { + if(term.lang != null) { + return "\""+term.valueOf()+"\"@"+term.lang; + } else if(term.datatype != null) { + return "\""+term.valueOf()+"\"^^<"+term.datatype+">"; + } return term.toString(); } }; +/** + * Removes the triples in a RDF JS Interface API Graph object from the store. + * The function receives a mandatory Graph object whose triples + * will be removed. Optionally, a URI string for a graph and a + * callback function can be passed as arguments.
+ *
+ * If no graph URI is specified, triples will be removed from the + * default graph.
+ *
+ * If the callback function is specified, it will be invoked when all the + * triples had been removed from the store. + * + * @arguments + * @param {RDFJSInterface.Graph} triples a RDF JS Interface Graph object + * @param {String} [graphURI] URI of the graph where the triples will be removed from. If it is missing, triples will be removed from the default graph + * @param {String} [callback] A callback function that will be invoked with a success notification + */ Store.Store.prototype['delete'] = function() { + var graph; var triples; var callback; @@ -40308,11 +32580,27 @@ Store.Store.prototype['delete'] = function() { this.engine.execute(query, callback); }; +/** + * Removes all the triples stored in a graph. + * + * The URI of the graph and a callback function can be + * optinally passed as parameters.
+ *
+ * If no graph URI is specified, all triples in the + * default graph will be removed. + * + * @arguments + * @param {String} [graph] the URI of the graph the triples must be removed from + * @param {Function} [callback] a function that will be invoked with a success notification + */ Store.Store.prototype.clear = function() { var graph; var callback; - if(arguments.length === 1) { + if(arguments.length === 0) { + graph = this.rdf.createNamedNode(this.engine.lexicon.defaultGraphUri); + var callback= function(){}; + } else if(arguments.length === 1) { graph = this.rdf.createNamedNode(this.engine.lexicon.defaultGraphUri); callback= arguments[0] || function(){}; } else if(arguments.length === 2) { @@ -40326,7 +32614,70 @@ Store.Store.prototype.clear = function() { this.engine.execute(query, callback); }; +/** + * Boolean value determining if loading RDF must produce + * triple add events and fire callbacks.
+ * Default value is false. + * + * @arguments + * @param {boolean} mustFireEvents true/false value. + */ +Store.Store.prototype.setBatchLoadEvents = function(mustFireEvents){ + this.engine.eventsOnBatchLoad = mustFireEvents; +}; + +/** + * Registers a namespace prefix that will be automatically declared + * in all the queries.
+ *
+ * The prefix will also be inserte in the default RDFEnvironment object + * associated to the rdf property of the store instance. + * + * @arguments + * @param {String} ns the name space to be regsitered + * @param {String} prefix the URI fragment associated to the name space + */ +Store.Store.prototype.registerDefaultNamespace = function(ns, prefix) { + this.rdf.prefixes.set(ns,prefix); + this.engine.registerDefaultNamespace(ns,prefix); +}; + +/** + * Registers the default namespaces declared in the RDF JS Interfaces + * specification in the default Profile. + */ +Store.Store.prototype.registerDefaultProfileNamespaces = function() { + var defaultNsMap = this.rdf.prefixes.values(); + for (var p in defaultNsMap) { + this.registerDefaultNamespace(p,defaultNsMap[p]); + } +}; +/** + * Load triples into a graph in the store. Data can be passed directly to the method + * or a remote URI speifying where the data is located can be used.
+ *
+ * If the data is passed directly to the load function, the media type stating the format + * of the data must also be passed to the function.
+ *
+ * If an URI is passed as a parameter, the store will attempt to perform content negotiation + * with the remote server and get a representation for the RDF data matching one of the + * the RDF parsers registered in the store. In this case, the media type parameter must be + * set to the 'remote' value.
+ *
+ * An additional URI for the graph where the parsed data will be loaded and a callback function + * can be also passed as parameters. If no graph is specified, triples will be loaded in the + * default graph.
+ *
+ * By default loading data will not trigger notification through the events API. If events needs to + * be trigger, the functio setBatchLoadEvents must be invoked with a true parameter. + * + * @arguments + * @param {String} mediaType Media type (application/json, text/n3...) of the data to be parsed or the value 'remote' if a URI for the data is passed instead + * @param {String} data RDF data to be parsed and loaded or an URI where the data will be retrieved after performing content negotiation + * @param {String} [graph] Graph where the parsed triples will be inserted. If it is not specified, triples will be loaded in the default graph + * @param {Function} callback that will be invoked with a success notification and the number of triples loaded. + */ Store.Store.prototype.load = function(){ var mediaType; var data; @@ -40380,6 +32731,30 @@ Store.Store.prototype.load = function(){ } }; +/** + * Registers a new parser associated to the provided media type. If there is a parser already registered for + * that media type, the new parser will replace the old one.
+ *
+ * Parsers must implement a function *parse* accepting the data to be parsed as the + * first parameter and the destination graph URI as the second one. + * They must return an array of objects with properties: 'subject', 'predicate', 'object' + * and 'graph' containing lexical representations for these values: + *
+ *
    + *
  • {literal: '"literal"'}
  • + *
  • {literal: ''"literal"^^'}
  • + *
  • {literal: '"literal"@lang'}
  • + *
  • {uri: 'uri'}
  • + *
  • {blank: '_:label'}
  • + *
+ *
+ * The provided media type will be used to perform content negotiation when dealing with remote + * resources, or to select the parser in the load function. + * + * @arguments + * @param {String} mediaType the media type for this parser + * @param {String} parser an object containing the *parse* function with the parser logic + */ Store.Store.prototype.registerParser = function(mediaType, parser) { this.engine.rdfLoader.registerParser(mediaType,parser); }; @@ -40387,19 +32762,36 @@ Store.Store.prototype.registerParser = function(mediaType, parser) { /** * Returns the URI of all the graphs currently contained * in the store + * + * @arguments: + * @param {Function} callback function that will receive a success notification and the array of graph URIs */ Store.Store.prototype.registeredGraphs = function(callback) { - var graphs = this.engine.lexicon.registeredGraphs(true); - var acum = []; - for(var i=0; isetNetworkTransport function. */ Store.Store.prototype.getNetworkTransport = function() { return NetworkTransport; -} +}; /** - * Sets the network transport used by the store; + * Sets the network transport used by the store.
+ *
+ * Network transport consist of an object implementing the load + * function, receiving the URI to load, a string with the value + * of the HTTP 'Accept' header for the store registered parsers, + * a callback function where the retrieved data and the success notification + * must be returned.
+ *
+ * Different examples with implementations of different transports can be found + * in the source code of the store: + *
    + *
  • src/js-communication/src/tcp_transport.js
  • + *
  • src/js-communication/src/ajax_transport.js
  • + *
+ * @arguments + * @param networkTransportImpl object implementing the transport *load* function. */ Store.Store.prototype.setNetworkTransport = function(networkTransportImpl) { NetworkTransport = networkTransportImpl; -} +}; // end of ./src/js-store/src/store.js -window.rdfstore = Store; -})(window); +// imports + RDFStoreWorker = {}; + + RDFStoreWorker.observingCallbacks = {}; + + RDFStoreWorker.workerCallbacksCounter = 0; + RDFStoreWorker.workerCallbacks = {}; + RDFStoreWorker.registerCallback = function(cb) { + var nextId = ""+RDFStoreWorker.workerCallbacksCounter; + RDFStoreWorker.workerCallbacksCounter++; + RDFStoreWorker.workerCallbacks[nextId] = cb; + return nextId; + }; + + RDFStoreWorker.handleCreate = function(argsObject, cb) { + // redefine NetworkTransport + + if(typeof(NetworkTransport) != 'undefined' && NetworkTransport != null) { + NetworkTransport = { + load: function(uri, graph, callback) { + var cbId = RDFStoreWorker.registerCallback(function(results){ + callback.apply(callback,results); + }); + postMessage({'fn':'workerRequest:NetworkTransport:load','callback':cbId, 'arguments':[uri,graph]}); + }, + + loadFromFile: function(parser, graph, uri, callback) { + + } + } + } + + args = [argsObject]; + //console.log("in handling create"); + args.push(function(result){ + //console.log("created!!!"); + // Stores the store object in the worker + RDFStoreWorker.store = result; + //console.log("posting MESSAGE!"); + + postMessage({'callback':cb, 'result':'created', 'success':true}); + }); + //console.log("creating"); + Store.create.apply(Store,args) + }; + + RDFStoreWorker.receive = function(packet) { + var msg = packet.data || packet; + //console.log("RECEIVED..."); + if(msg.fn === 'workerRequestResponse') { + var cbId = msg.callback; + var callback = RDFStoreWorker.workerCallbacks[cbId]; + if(callback != null) { + delete RDFStoreWorker.workerCallbacks[cbId]; + callback(msg.results); + } + } else if(msg.fn === 'create' && msg.args !=null) { + //console.log("handling create"); + RDFStoreWorker.handleCreate(msg.args, msg.callback); + } else if(msg.fn === 'setBatchLoadEvents') { + RDFStoreWorker.store[msg.fn].apply(RDFStoreWorker.store, msg.args); + } else if(msg.fn === 'registerDefaultNamespace') { + RDFStoreWorker.store[msg.fn].apply(RDFStoreWorker.store, msg.args); + } else if(msg.fn === 'registerDefaultProfileNamespaces') { + RDFStoreWorker.store[msg.fn].apply(RDFStoreWorker.store, msg.args); + } else if((msg.fn === 'execute' || + msg.fn === 'executeWithEnvironment' || + msg.fn === 'graph'|| + msg.fn === 'node' || + msg.fn === 'clear' || + msg.fn === 'load') && msg.args != null) { + msg.args.push(function(success, result){ + //console.log("CALLBACK!"); + if(msg.callback!=null) { + postMessage({'callback':msg.callback, 'result':result, 'success':success}); + } + }); + try { + RDFStoreWorker.store[msg.fn].apply(RDFStoreWorker.store,msg.args); + } catch(e) { + console.log("Error executing method through connection"); + console.log(e); + } + } else if((msg.fn === 'insert'|| + msg.fn === 'delete') && msg.args != null) { + try { + msg.args.push(function(success, result){ + //console.log("CALLBACK!"); + if(msg.callback!=null) { + postMessage({'callback':msg.callback, 'result':result, 'success':success}); + } + }); + var triple; + var toWrap = msg.args[0]; + for(var i=0; i=0;d--){var i=!1,i=e==null?c[d]===b:e(c[d],b)===0;if(i===!0)return!0}return!1};w.remove=function(c,b){for(var e=[],d=0;dtb&&ta>tb-e?1:null):(da=w.parseISO8601(c),db=w.parseISO8601(b),ta=da.getTime(),tb=db.getTime(),e=50400,tatb&&ta+e>tb?1:null)};w.lexicalFormLiteral=function(c,b){var e=c.value,d=c.lang,i=c.type,h=null;e!=null&& -i!=null&&typeof i!="string"?(e=i.value,e!=null?h='"'+c.value+'"^^<'+e+">":(e=i.suffix,i=b.namespaces[i.prefix],c.type=i+e,h='"'+c.value+'"^^<'+i+e+">")):h=d==null&&i==null?'"'+e+'"':i==null?'"'+e+'"@'+d:'"'+c.value+'"^^<'+i+">";return h};w.lexicalFormBaseUri=function(c,b){var e=null;if(c.value==null){var d=c.suffix,i=b.namespaces[c.prefix];i!=null&&(e=i+d)}else e=c.value;if(e===null)return null;else e.indexOf(":")==-1&&(e=(b.base||"")+e);return e};w.lexicalFormTerm=function(c,b){if(c.token==="uri")return{uri:w.lexicalFormBaseUri(c, -b)};else if(c.token==="literal")return{literal:w.lexicalFormLiteral(c,b)};else if(c.token==="blank"){var e="_:"+b.blank;b.blank+=1;return{blank:e}}else callback(!1,"Token of kind "+c.token+" cannot transformed into its lexical form")};w.normalizeUnicodeLiterals=function(c){for(var b=c.match(/\\u[0-9abcdefABCDEF]{4,4}/g)||[],e={},d=0;dc?1:0},this.merger=null}};J.Tree.prototype._allocateNode= -function(){return new J.Node};J.Tree.prototype._diskWrite=function(){};J.Tree.prototype._diskRead=function(c){return c};J.Tree.prototype._diskDelete=function(){};J.Tree.prototype._updateRootNode=function(c){return c};J.Tree.prototype.search=function(c,b){for(var e=!0,d=this.root;e;){for(var i=0;ib+1;h--)c.children[h]=c.children[h-1];c.children[b+1]=d;for(h=c.numberActives;h>b;h--)c.keys[h]=c.keys[h-1];c.keys[b]=i;c.numberActives++;this._diskWrite(d);this._diskWrite(c);this._diskWrite(e)};J.Tree.prototype.insert=function(c,b){if(this.root.numberActives===2*this.order-1){var e=this._allocateNode();e.isLeaf=!1;e.level=this.root.level+1;e.numberActives=0;e.children[0]=this.root;this._splitChild(e,0,this.root);this.root=e;this._updateRootNode(this.root); -this._insertNonFull(e,c,b)}else this._insertNonFull(this.root,c,b)};J.Tree.prototype._insertNonFull=function(c,b,e){for(var d=c.numberActives-1;!c.isLeaf;){for(;d>=0&&this.comparator(b,c.keys[d].key)===-1;)d--;d++;var i=this._diskRead(c.children[d]);i.numberActives===2*this.order-1&&(this._splitChild(c,d,i),this.comparator(b,c.keys[d].key)===1&&d++);c=this._diskRead(c.children[d]);d=c.numberActives-1}for(;d>=0&&this.comparator(b,c.keys[d].key)===-1;)c.keys[d+1]=c.keys[d],d--;c.keys[d+1]={key:b,data:e}; -c.numberActives++;this._diskWrite(c)};J.Tree.prototype["delete"]=function(c){for(var b=this.root,e=null,d=!0,i=null,h=null,f=null,o=!0;o===!0;){for(o=!1;d===!0;){r=0;if(b.numberActives===0)return!1;for(;rthis.order-1?this._moveKey(e,r,-1):h!=null&&h.numberActives>this.order-1?this._moveKey(e,r,1):h!=null&&h.numberActives===this.order-1?b=this._mergeSiblings(e,r,-1):f!=null&&f.numberActives===this.order-1&&(b=this._mergeSiblings(e,r,1)))}}if(b.isLeaf&&b.numberActives>this.order-1)return this._deleteKeyFromNode(b,i),!0;if(b.isLeaf&& -b===this.root)return this._deleteKeyFromNode(b,i),!0;if(b.isLeaf===!1)if(e=r=null,(r=this._diskRead(b.children[i])).numberActives>this.order-1)c=this._getMaxKeyPos(r),c=c.node.keys[c.index],b.keys[i]=c,this._diskWrite(b),b=r,c=c.key,d=o=!0;else if((r=this._diskRead(b.children[i+1])).numberActives>this.order-1)c=this._getMinKeyPos(r),c=c.node.keys[c.index],b.keys[i]=c,this._diskWrite(b),b=r,c=c.key,d=o=!0;else if((r=this._diskRead(b.children[i])).numberActives===this.order-1&&(e=this._diskRead(b.children[i+ -1])).numberActives===this.order-1){d=this._mergeNodes(r,b.keys[i],e);b.children[i]=d;i++;for(var r=i;rthis.order-1&&d===!1&&this._deleteKeyFromNode(b,i);if(o===!1)return!0}};J.Tree.prototype._moveKey=function(c,b,e){e===1&&b--;var d=this._diskRead(c.children[b]),i=this._diskRead(c.children[b+ -1]);if(e==-1){d.keys[d.numberActives]=c.keys[b];d.children[d.numberActives+1]=i.children[0];i.children[0]=null;d.numberActives++;c.keys[b]=i.keys[0];for(e=1;e0;e--)i.children[e]=i.children[e-1],i.keys[e]=i.keys[e-1];i.keys[0]=null;i.children[0]=null;i.children[0]=d.children[d.numberActives]; -i.keys[0]=c.keys[b];i.numberActives++;d.children[d.numberActives]=null;c.keys[b]=d.keys[d.numberActives-1];d.keys[d.numberActives-1]=null;d.numberActives--}this._diskWrite(d);this._diskWrite(i);this._diskWrite(c)};J.Tree.prototype._mergeSiblings=function(c,b){var e,d,i;b===c.numberActives?(b--,d=this._diskRead(c.children[c.numberActives-1]),i=this._diskRead(c.children[c.numberActives])):(d=this._diskRead(c.children[b]),i=this._diskRead(c.children[b+1]));var h=this._allocateNode();h.isLeaf=d.isLeaf; -h.level=d.level;for(e=0;e key "+f.keys[o].key;c===!0&&console.log(u);b.push(u)}d.comparator(f.keys[o].key,v)===1&&(u=" !!! value min right "+v+" < key "+f.keys[o].key,c===!0&&console.log(u),b.push(u));i(f.keys[o].key);e.push(f.keys[o].key)}else{h===null?h=f.level:h!=f.level&&(u=" !!! Leaf node with wrong level value",c===!0&&console.log(u),b.push(u));for(o=0;o2*d.order- -1&&(c===!0&&(u=" !!!! MAX num keys restriction violated "),console.log(u),b.push(u)),f.numberActivesc[e])return 1}return 0};Q.Pattern=function(c){this.subject=c.subject;this.predicate=c.predicate;this.object=c.object;this.graph=c.graph;this.indexKey=[];this.keyComponents={};for(var b=[],e=[],c=["subject","predicate","object","graph"],d=0;dh)return 1}return 0},this.rangeComparator=function(b,c){for(var i=0;ic[h])return 1}return 0},b!=null&&b(this)}};w["extends"](J.Tree, -ba.Tree);ba.Tree.prototype.insert=function(c,b){J.Tree.prototype.insert.call(this,c,null);b&&b(!0);return!0};ba.Tree.prototype.search=function(c,b){var e=J.Tree.prototype.search.call(this,c,!0);b&&b(e);return e};ba.Tree.prototype.range=function(c,b){var e=this._rangeTraverse(this,this.root,c);b&&b(e);return e};ba.Tree.prototype._rangeTraverse=function(c,b,e){for(var e=e.key,d=[],i=[b],h;i.length>0;){b=i.shift();for(h=0;h")return e=c.substring(1,b-1),c=c.substring(b+3,c.length-1),{token:"literal",value:e,type:c};e=c.substring(1,c.length-1);return{token:"literal",value:e}};N.Lexicon.prototype.parseUri=function(c){return{token:"uri",value:c}};N.Lexicon.prototype.retrieve=function(c){try{if(c===this.defaultGraphOid)return{token:"uri",value:this.defaultGraphUri,prefix:null,suffix:null,defaultGraph:!0};else{var b=this.OIDToUri["u"+c];if(b)return this.parseUri(b); -else{var e=this.OIDToLiteral["l"+c];if(e)return this.parseLiteral(e);else if(this.OIDToBlank[""+c])return{token:"blank",value:"_:"+c};else throw"Null value for OID";}}}catch(d){throw console.log("error in lexicon retrieving OID:"),console.log(c),d.message&&console.log(d.message),d.stack&&console.log(d.stack),Error("Unknown retrieving OID in lexicon:"+c);}};N.Lexicon.prototype.unregister=function(c,b){try{return this.unregisterTerm(c.subject.token,b.subject),this.unregisterTerm(c.predicate.token,b.predicate), -this.unregisterTerm(c.object.token,b.object),c.graph!=null&&this.unregisterTerm(c.graph.token,b.graph),!0}catch(e){return console.log("Error unregistering quad"),console.log(e.message),!1}};N.Lexicon.prototype.unregisterTerm=function(c,b){if(c==="uri"){if(b!=this.defaultGraphOid){var e="u"+b,d=this.OIDToUri[e],i=this.uriToOID[d],h=i[1];if(""+i[0]===""+b)h===0?(delete this.OIDToUri[e],delete this.uriToOID[d],delete this.knownGraphs[b]):this.uriToOID[d]=[b,h-1];else throw"Not matching OID : "+b+" vs "+ -i[0];}}else if(c==="literal")if(this.oidCounter++,e="l"+b,d=this.OIDToLiteral[e],i=this.literalToOID[d],h=i[1],""+i[0]===""+b)h===0?(delete this.OIDToLiteral[e],delete this.literalToOID[d]):this.literalToOID[d]=[b,h-1];else throw"Not matching OID : "+b+" vs "+i[0];else c==="blank"&&delete this.OIDToBlank[""+b]};var ea={};ea.load=function(c,b,e){jQuery.ajax({url:c,headers:{Accepts:b},success:function(b,c,h){if((""+h.status)[0]=="2"){for(var c=h.getAllResponseHeaders().split("\n"),h={},f=0;fha&&(ha=j,Da=[]),Da.push(b))}function f(){var c="statement@"+j,e=x[c];if(e)return j=e.nextPos,e.result;for(var e=j,z=[],d=A();d!==null;)z.push(d),d=A();if(z!==null)if(d=o(),d!==null){for(var i=[],T=A();T!==null;)i.push(T),T=A();if(i!==null)if(b.substr(j,1)==="."?(T=".",j+=1):(T=null,q&&h('"."')),T!==null){for(var k=[], -r=A();r!==null;)k.push(r),r=A();k!==null?z=[z,d,i,T,k]:(z=null,j=e)}else z=null,j=e;else z=null,j=e}else z=null,j=e;else z=null,j=e;e=z!==null?z[1]:null;if(e===null){e=j;z=[];for(d=A();d!==null;)z.push(d),d=A();if(z!==null)if(d=u(),d!==null){i=[];for(T=A();T!==null;)i.push(T),T=A();i!==null?z=[z,d,i]:(z=null,j=e)}else z=null,j=e;else z=null,j=e;e=z!==null?z[1]:null;if(e===null){e=A();if(e!==null)for(z=[];e!==null;)z.push(e),e=A();else z=null;e=z!==null?z:null}}x[c]={nextPos:j,result:e};return e}function o(){var b= -"directive@"+j,h=x[b];if(h)return j=h.nextPos,h.result;h=v();h===null&&(h=r(),h=h!==null?h:null);x[b]={nextPos:j,result:h};return h}function r(){var c="base@"+j,e=x[c];if(e)return j=e.nextPos,e.result;for(var e=j,z=[],d=A();d!==null;)z.push(d),d=A();if(z!==null)if(b.substr(j,5)==="@base"?(d="@base",j+=5):(d=null,q&&h('"@base"')),d!==null){var i=A();if(i!==null)for(var f=[];i!==null;)f.push(i),i=A();else f=null;f!==null?(i=sa(),i!==null?z=[z,d,f,i]:(z=null,j=e)):(z=null,j=e)}else z=null,j=e;else z= -null,j=e;e=z!==null?function(b){base={token:"base"};base.value=b;return base}(z[3]):null;x[c]={nextPos:j,result:e};return e}function v(){var c="prefixID@"+j,e=x[c];if(e)return j=e.nextPos,e.result;for(var e=j,z=[],d=A();d!==null;)z.push(d),d=A();if(z!==null)if(b.substr(j,7)==="@prefix"?(d="@prefix",j+=7):(d=null,q&&h('"@prefix"')),d!==null){var i=A();if(i!==null)for(var f=[];i!==null;)f.push(i),i=A();else f=null;if(f!==null)if(i=Ea(),i=i!==null?i:"",i!==null){if(b.substr(j,1)===":"){var k=":";j+= -1}else k=null,q&&h('":"');if(k!==null){for(var o=[],r=A();r!==null;)o.push(r),r=A();o!==null?(r=sa(),r!==null?z=[z,d,f,i,k,o,r]:(z=null,j=e)):(z=null,j=e)}else z=null,j=e}else z=null,j=e;else z=null,j=e}else z=null,j=e;else z=null,j=e;e=z!==null?function(b,h){prefix={token:"prefix"};prefix.prefix=b;prefix.local=h;return prefix}(z[3],z[6]):null;x[c]={nextPos:j,result:e};return e}function u(){var c="TriplesBlock@"+j,e=x[c];if(e)return j=e.nextPos,e.result;e=q;q=!1;var z=j,d=w();if(d!==null){for(var i= -j,f=[],k=A();k!==null;)f.push(k),k=A();if(f!==null)if(b.substr(j,1)==="."?(k=".",j+=1):(k=null,q&&h('"."')),k!==null){var o=u(),o=o!==null?o:"";o!==null?f=[f,k,o]:(f=null,j=i)}else f=null,j=i;else f=null,j=i;i=f!==null?f:"";i!==null?d=[d,i]:(d=null,j=z)}else d=null,j=z;z=d!==null?function(b,h){var c=b.triplesContext;typeof h==="object"&&h.length!=null&&h[2].triplesContext!=null&&(c=c.concat(h[2].triplesContext));return{token:"triples",triplesContext:c}}(d[0],d[1]):null;(q=e)&&z===null&&h("[54] TriplesBlock"); -x[c]={nextPos:j,result:z};return z}function w(){var b="TriplesSameSubject@"+j,c=x[b];if(c)return j=c.nextPos,c.result;c=q;q=!1;for(var e=j,d=[],i=A();i!==null;)d.push(i),i=A();if(d!==null)if(i=Ka(),i!==null){for(var f=[],k=A();k!==null;)f.push(k),k=A();f!==null?(k=F(),k!==null?d=[d,i,f,k]:(d=null,j=e)):(d=null,j=e)}else d=null,j=e;else d=null,j=e;e=d!==null?function(b,h){var c=h.triplesContext;if(h.pairs)for(var e=0;e0?{token:"literal",value:b.value,lang:h.slice(1),type:null}:typeof h==="object"?(h.shift(),{token:"literal",value:b.value,lang:null,type:h[0]}):{token:"literal",value:b.value,lang:null,type:null}}(i[0],i[1]):null;(q=e)&&d===null&&h("[112] RDFLiteral");x[c]={nextPos:j,result:d};return d}function $a(){var b="NumericLiteral@"+j,c=x[b];if(c)return j=c.nextPos,c.result;c=q;q=!1;var e=eb();e===null&&(e=fb(),e===null&& -(e=gb(),e=e!==null?e:null));(q=c)&&e===null&&h("[113] NumericLiteral");x[b]={nextPos:j,result:e};return e}function eb(){var b="NumericLiteralUnsigned@"+j,c=x[b];if(c)return j=c.nextPos,c.result;c=q;q=!1;var e=Fa();e===null&&(e=R(),e===null&&(e=Y(),e=e!==null?e:null));(q=c)&&e===null&&h("[114] NumericLiteralUnsigned");x[b]={nextPos:j,result:e};return e}function fb(){var b="NumericLiteralPositive@"+j,c=x[b];if(c)return j=c.nextPos,c.result;c=q;q=!1;var e=hb();e===null&&(e=Qa(),e===null&&(e=va(),e=e!== -null?e:null));(q=c)&&e===null&&h("[115] NumericLiteralPositive");x[b]={nextPos:j,result:e};return e}function gb(){var b="NumericLiteralNegative@"+j,c=x[b];if(c)return j=c.nextPos,c.result;c=q;q=!1;var e=ib();e===null&&(e=jb(),e===null&&(e=kb(),e=e!==null?e:null));(q=c)&&e===null&&h("[116] NumericLiteralNegative");x[b]={nextPos:j,result:e};return e}function ab(){var c="BooleanLiteral@"+j,e=x[c];if(e)return j=e.nextPos,e.result;e=q;q=!1;if(b.substr(j,4)==="true"){var d="true";j+=4}else d=null,q&&h('"true"'); -d=d!==null?lit={token:"literal",lang:null,type:"http://www.w3.org/2001/XMLSchema#boolean",value:!0}:null;d===null&&(b.substr(j,5)==="false"?(d="false",j+=5):(d=null,q&&h('"false"')),d=d!==null?lit={token:"literal",lang:null,type:"http://www.w3.org/2001/XMLSchema#boolean",value:!1}:null,d=d!==null?d:null);(q=e)&&d===null&&h("[117] BooleanLiteral");x[c]={nextPos:j,result:d};return d}function cb(){var b="String@"+j,c=x[b];if(c)return j=c.nextPos,c.result;c=q;q=!1;var e=Ra(),e=e!==null?{token:"string", -value:e}:null;e===null&&(e=Sa(),e=e!==null?{token:"string",value:e}:null,e===null&&(e=lb(),e=e!==null?{token:"string",value:e}:null,e===null&&(e=wa(),e=e!==null?{token:"string",value:e}:null,e=e!==null?e:null)));(q=c)&&e===null&&h("[118] String");x[b]={nextPos:j,result:e};return e}function ma(){var b="IRIref@"+j,c=x[b];if(c)return j=c.nextPos,c.result;c=q;q=!1;var e=sa(),e=e!==null?{token:"uri",prefix:null,suffix:null,value:e}:null;e===null&&(e=mb(),e=e!==null?e:null,e=e!==null?e:null);(q=c)&&e=== -null&&h("[119] IRIref");x[b]={nextPos:j,result:e};return e}function mb(){var b="PrefixedName@"+j,c=x[b];if(c)return j=c.nextPos,c.result;c=q;q=!1;var e=Ta(),e=e!==null?{token:"uri",prefix:e[0],suffix:e[1],value:null}:null;e===null&&(e=xa(),e=e!==null?{token:"uri",prefix:e,suffix:"",value:null}:null,e=e!==null?e:null);(q=c)&&e===null&&h("[120] PrefixedName");x[b]={nextPos:j,result:e};return e}function Oa(){var b="BlankNode@"+j,c=x[b];if(c)return j=c.nextPos,c.result;c=q;q=!1;var e=Ua(),e=e!==null? -{token:"blank",label:e}:null;e===null&&(ya()!==null?(U++,e={token:"blank",label:""+U}):e=null,e=e!==null?e:null);(q=c)&&e===null&&h("[121] BlankNode");x[b]={nextPos:j,result:e};return e}function sa(){var c="IRI_REF@"+j,e=x[c];if(e)return j=e.nextPos,e.result;e=q;q=!1;var d=j;if(b.substr(j,1)==="<"){var i="<";j+=1}else i=null,q&&h('"<"');if(i!==null){var f=[];if(b.substr(j).match(/^[^<>"{} | ^\\]/)!==null){var k=b.charAt(j);j++}else k=null,q&&h('[^<>"{} | ^\\\\]');for(;k!==null;)f.push(k),b.substr(j).match(/^[^<>"{} | ^\\]/)!== -null?(k=b.charAt(j),j++):(k=null,q&&h('[^<>"{} | ^\\\\]'));f!==null?(b.substr(j,1)===">"?(k=">",j+=1):(k=null,q&&h('">"')),k!==null?i=[i,f,k]:(i=null,j=d)):(i=null,j=d)}else i=null,j=d;d=i!==null?i[1].join(""):null;(q=e)&&d===null&&h("[122] IRI_REF");x[c]={nextPos:j,result:d};return d}function xa(){var c="PNAME_NS@"+j,e=x[c];if(e)return j=e.nextPos,e.result;e=q;q=!1;var d=j,i=Ea(),i=i!==null?i:"";if(i!==null){if(b.substr(j,1)===":"){var f=":";j+=1}else f=null,q&&h('":"');f!==null?i=[i,f]:(i=null, -j=d)}else i=null,j=d;d=i!==null?i[0]:null;(q=e)&&d===null&&h("[123] PNAME_NS");x[c]={nextPos:j,result:d};return d}function Ta(){var b="PNAME_LN@"+j,c=x[b];if(c)return j=c.nextPos,c.result;c=q;q=!1;var e=j,d=xa();if(d!==null){var i=za();i!==null?d=[d,i]:(d=null,j=e)}else d=null,j=e;e=d!==null?[d[0],d[1]]:null;(q=c)&&e===null&&h("[124] PNAME_LN");x[b]={nextPos:j,result:e};return e}function Ua(){var c="BLANK_NODE_LABEL@"+j,e=x[c];if(e)return j=e.nextPos,e.result;e=q;q=!1;var d=j;if(b.substr(j,2)==="_:"){var i= -"_:";j+=2}else i=null,q&&h('"_:"');if(i!==null){var f=za();f!==null?i=[i,f]:(i=null,j=d)}else i=null,j=d;d=i!==null?i[1]:null;(q=e)&&d===null&&h("[125] BLANK_NODE_LABEL");x[c]={nextPos:j,result:d};return d}function Ma(){var c="VAR1@"+j,e=x[c];if(e)return j=e.nextPos,e.result;e=q;q=!1;var d=j;if(b.substr(j,1)==="?"){var i="?";j+=1}else i=null,q&&h('"?"');if(i!==null){var f=Aa();f!==null?i=[i,f]:(i=null,j=d)}else i=null,j=d;d=i!==null?i[1]:null;(q=e)&&d===null&&h("[126] VAR1");x[c]={nextPos:j,result:d}; -return d}function Na(){var c="VAR2@"+j,e=x[c];if(e)return j=e.nextPos,e.result;e=q;q=!1;var d=j;if(b.substr(j,1)==="$"){var i="$";j+=1}else i=null,q&&h('"$"');if(i!==null){var f=Aa();f!==null?i=[i,f]:(i=null,j=d)}else i=null,j=d;d=i!==null?i[1]:null;(q=e)&&d===null&&h("[127] VAR2");x[c]={nextPos:j,result:d};return d}function Pa(){var c="LANGTAG@"+j,e=x[c];if(e)return j=e.nextPos,e.result;e=q;q=!1;var d=j;if(b.substr(j,1)==="@"){var i="@";j+=1}else i=null,q&&h('"@"');if(i!==null){if(b.substr(j).match(/^[a-zA-Z]/)!== -null){var f=b.charAt(j);j++}else f=null,q&&h("[a-zA-Z]");if(f!==null)for(var k=[];f!==null;)k.push(f),b.substr(j).match(/^[a-zA-Z]/)!==null?(f=b.charAt(j),j++):(f=null,q&&h("[a-zA-Z]"));else k=null;if(k!==null){var f=[],o=j;if(b.substr(j,1)==="-"){var r="-";j+=1}else r=null,q&&h('"-"');if(r!==null){if(b.substr(j).match(/^[a-zA-Z0-9]/)!==null){var v=b.charAt(j);j++}else v=null,q&&h("[a-zA-Z0-9]");if(v!==null)for(var u=[];v!==null;)u.push(v),b.substr(j).match(/^[a-zA-Z0-9]/)!==null?(v=b.charAt(j),j++): -(v=null,q&&h("[a-zA-Z0-9]"));else u=null;u!==null?r=[r,u]:(r=null,j=o)}else r=null,j=o;for(;r!==null;)if(f.push(r),o=j,b.substr(j,1)==="-"?(r="-",j+=1):(r=null,q&&h('"-"')),r!==null){b.substr(j).match(/^[a-zA-Z0-9]/)!==null?(v=b.charAt(j),j++):(v=null,q&&h("[a-zA-Z0-9]"));if(v!==null)for(u=[];v!==null;)u.push(v),b.substr(j).match(/^[a-zA-Z0-9]/)!==null?(v=b.charAt(j),j++):(v=null,q&&h("[a-zA-Z0-9]"));else u=null;u!==null?r=[r,u]:(r=null,j=o)}else r=null,j=o;f!==null?i=[i,k,f]:(i=null,j=d)}else i= -null,j=d}else i=null,j=d;d=i!==null?i[2].length===0?("@"+i[1].join("")).toLowerCase():("@"+i[1].join("")+"-"+i[2][0][1].join("")).toLowerCase():null;(q=e)&&d===null&&h("[128] LANGTAG");x[c]={nextPos:j,result:d};return d}function Y(){var c="INTEGER@"+j,e=x[c];if(e)return j=e.nextPos,e.result;e=q;q=!1;if(b.substr(j).match(/^[0-9]/)!==null){var d=b.charAt(j);j++}else d=null,q&&h("[0-9]");if(d!==null)for(var i=[];d!==null;)i.push(d),b.substr(j).match(/^[0-9]/)!==null?(d=b.charAt(j),j++):(d=null,q&&h("[0-9]")); -else i=null;d=i!==null?function(b){lit={token:"literal",lang:null,type:"http://www.w3.org/2001/XMLSchema#integer"};lit.value=Z(b);return lit}(i):null;(q=e)&&d===null&&h("[129] INTEGER");x[c]={nextPos:j,result:d};return d}function R(){var c="DECIMAL@"+j,e=x[c];if(e)return j=e.nextPos,e.result;e=q;q=!1;var d=j;if(b.substr(j).match(/^[0-9]/)!==null){var i=b.charAt(j);j++}else i=null,q&&h("[0-9]");if(i!==null)for(var f=[];i!==null;)f.push(i),b.substr(j).match(/^[0-9]/)!==null?(i=b.charAt(j),j++):(i=null, -q&&h("[0-9]"));else f=null;if(f!==null)if(b.substr(j,1)==="."?(i=".",j+=1):(i=null,q&&h('"."')),i!==null){var k=[];if(b.substr(j).match(/^[0-9]/)!==null){var o=b.charAt(j);j++}else o=null,q&&h("[0-9]");for(;o!==null;)k.push(o),b.substr(j).match(/^[0-9]/)!==null?(o=b.charAt(j),j++):(o=null,q&&h("[0-9]"));k!==null?f=[f,i,k]:(f=null,j=d)}else f=null,j=d;else f=null,j=d;d=f!==null?function(b,c,h){lit={token:"literal",lang:null,type:"http://www.w3.org/2001/XMLSchema#decimal"};lit.value=Z([b,c,h]);return lit}(f[0], -f[1],f[2]):null;if(d===null){d=j;b.substr(j,1)==="."?(f=".",j+=1):(f=null,q&&h('"."'));if(f!==null){b.substr(j).match(/^[0-9]/)!==null?(i=b.charAt(j),j++):(i=null,q&&h("[0-9]"));if(i!==null)for(k=[];i!==null;)k.push(i),b.substr(j).match(/^[0-9]/)!==null?(i=b.charAt(j),j++):(i=null,q&&h("[0-9]"));else k=null;k!==null?f=[f,k]:(f=null,j=d)}else f=null,j=d;d=f!==null?function(b,c){lit={token:"literal",lang:null,type:"http://www.w3.org/2001/XMLSchema#decimal"};lit.value=Z([b,c]);return lit}(f[0],f[1]): -null;d=d!==null?d:null}(q=e)&&d===null&&h("[130] DECIMAL");x[c]={nextPos:j,result:d};return d}function Fa(){var c="DOUBLE@"+j,e=x[c];if(e)return j=e.nextPos,e.result;e=q;q=!1;var d=j;if(b.substr(j).match(/^[0-9]/)!==null){var i=b.charAt(j);j++}else i=null,q&&h("[0-9]");if(i!==null)for(var f=[];i!==null;)f.push(i),b.substr(j).match(/^[0-9]/)!==null?(i=b.charAt(j),j++):(i=null,q&&h("[0-9]"));else f=null;if(f!==null)if(b.substr(j,1)==="."?(i=".",j+=1):(i=null,q&&h('"."')),i!==null){var k=[];if(b.substr(j).match(/^[0-9]/)!== -null){var o=b.charAt(j);j++}else o=null,q&&h("[0-9]");for(;o!==null;)k.push(o),b.substr(j).match(/^[0-9]/)!==null?(o=b.charAt(j),j++):(o=null,q&&h("[0-9]"));k!==null?(o=Ga(),o!==null?f=[f,i,k,o]:(f=null,j=d)):(f=null,j=d)}else f=null,j=d;else f=null,j=d;d=f!==null?function(b,c,h,e){lit={token:"literal",lang:null,type:"http://www.w3.org/2001/XMLSchema#double"};lit.value=Z([b,c,h,e]);return lit}(f[0],f[1],f[2],f[3]):null;if(d===null){d=j;b.substr(j,1)==="."?(f=".",j+=1):(f=null,q&&h('"."'));if(f!== -null){b.substr(j).match(/^[0-9]/)!==null?(k=b.charAt(j),j++):(k=null,q&&h("[0-9]"));if(k!==null)for(i=[];k!==null;)i.push(k),b.substr(j).match(/^[0-9]/)!==null?(k=b.charAt(j),j++):(k=null,q&&h("[0-9]"));else i=null;i!==null?(k=Ga(),k!==null?f=[f,i,k]:(f=null,j=d)):(f=null,j=d)}else f=null,j=d;d=f!==null?function(b,c,h){lit={token:"literal",lang:null,type:"http://www.w3.org/2001/XMLSchema#double"};lit.value=Z([b,c,h]);return lit}(f[0],f[1],f[2]):null;if(d===null){d=j;b.substr(j).match(/^[0-9]/)!== -null?(i=b.charAt(j),j++):(i=null,q&&h("[0-9]"));if(i!==null)for(f=[];i!==null;)f.push(i),b.substr(j).match(/^[0-9]/)!==null?(i=b.charAt(j),j++):(i=null,q&&h("[0-9]"));else f=null;f!==null?(i=Ga(),i!==null?f=[f,i]:(f=null,j=d)):(f=null,j=d);d=f!==null?function(b,c){lit={token:"literal",lang:null,type:"http://www.w3.org/2001/XMLSchema#double"};lit.value=Z([b,c]);return lit}(f[0],f[1]):null;d=d!==null?d:null}}(q=e)&&d===null&&h("[131] DOUBLE");x[c]={nextPos:j,result:d};return d}function va(){var c="INTEGER_POSITIVE@"+ -j,e=x[c];if(e)return j=e.nextPos,e.result;e=q;q=!1;var d=j;if(b.substr(j,1)==="+"){var i="+";j+=1}else i=null,q&&h('"+"');if(i!==null){var f=Y();f!==null?i=[i,f]:(i=null,j=d)}else i=null,j=d;d=i!==null?function(b){b.value="+"+b.value;return b}(i[1]):null;(q=e)&&d===null&&h("[132] INTEGER_POSITIVE");x[c]={nextPos:j,result:d};return d}function Qa(){var c="DECIMAL_POSITIVE@"+j,e=x[c];if(e)return j=e.nextPos,e.result;e=q;q=!1;var d=j;if(b.substr(j,1)==="+"){var i="+";j+=1}else i=null,q&&h('"+"');if(i!== -null){var f=R();f!==null?i=[i,f]:(i=null,j=d)}else i=null,j=d;d=i!==null?function(b){b.value="+"+b.value;return b}(i[1]):null;(q=e)&&d===null&&h("[133] DECIMAL_POSITIVE");x[c]={nextPos:j,result:d};return d}function hb(){var c="DOUBLE_POSITIVE@"+j,e=x[c];if(e)return j=e.nextPos,e.result;e=q;q=!1;var d=j;if(b.substr(j,1)==="+"){var i="+";j+=1}else i=null,q&&h('"+"');if(i!==null){var f=Fa();f!==null?i=[i,f]:(i=null,j=d)}else i=null,j=d;d=i!==null?function(b){b.value="+"+b.value;return b}(i[1]):null; -(q=e)&&d===null&&h("[134] DOUBLE_POSITIVE");x[c]={nextPos:j,result:d};return d}function kb(){var c="INTEGER_NEGATIVE@"+j,e=x[c];if(e)return j=e.nextPos,e.result;e=q;q=!1;var d=j;if(b.substr(j,1)==="-"){var i="-";j+=1}else i=null,q&&h('"-"');if(i!==null){var f=Y();f!==null?i=[i,f]:(i=null,j=d)}else i=null,j=d;d=i!==null?function(b){b.value="-"+b.value;return b}(i[1]):null;(q=e)&&d===null&&h("[135] INTEGER_NEGATIVE");x[c]={nextPos:j,result:d};return d}function jb(){var c="DECIMAL_NEGATIVE@"+j,e=x[c]; -if(e)return j=e.nextPos,e.result;e=q;q=!1;var d=j;if(b.substr(j,1)==="-"){var i="-";j+=1}else i=null,q&&h('"-"');if(i!==null){var f=R();f!==null?i=[i,f]:(i=null,j=d)}else i=null,j=d;d=i!==null?function(b){b.value="-"+b.value;return b}(i[1]):null;(q=e)&&d===null&&h("[136] DECIMAL_NEGATIVE");x[c]={nextPos:j,result:d};return d}function ib(){var c="DOUBLE_NEGATIVE@"+j,e=x[c];if(e)return j=e.nextPos,e.result;e=q;q=!1;var d=j;if(b.substr(j,1)==="-"){var i="-";j+=1}else i=null,q&&h('"-"');if(i!==null){var f= -Fa();f!==null?i=[i,f]:(i=null,j=d)}else i=null,j=d;d=i!==null?function(b){b.value="-"+b.value;return b}(i[1]):null;(q=e)&&d===null&&h("[137] DOUBLE_NEGATIVE");x[c]={nextPos:j,result:d};return d}function Ga(){var c="EXPONENT@"+j,e=x[c];if(e)return j=e.nextPos,e.result;e=q;q=!1;var d=j;if(b.substr(j).match(/^[eE]/)!==null){var i=b.charAt(j);j++}else i=null,q&&h("[eE]");if(i!==null){if(b.substr(j).match(/^[+\-]/)!==null){var f=b.charAt(j);j++}else f=null,q&&h("[+\\-]");f=f!==null?f:"";if(f!==null){if(b.substr(j).match(/^[0-9]/)!== -null){var k=b.charAt(j);j++}else k=null,q&&h("[0-9]");if(k!==null)for(var o=[];k!==null;)o.push(k),b.substr(j).match(/^[0-9]/)!==null?(k=b.charAt(j),j++):(k=null,q&&h("[0-9]"));else o=null;o!==null?i=[i,f,o]:(i=null,j=d)}else i=null,j=d}else i=null,j=d;d=i!==null?Z([i[0],i[1],i[2]]):null;(q=e)&&d===null&&h("[138] EXPONENT");x[c]={nextPos:j,result:d};return d}function lb(){var c="STRING_LITERAL1@"+j,e=x[c];if(e)return j=e.nextPos,e.result;e=q;q=!1;var d=j;if(b.substr(j,1)==="'"){var i="'";j+=1}else i= -null,q&&h('"\'"');if(i!==null){var f=[];if(b.substr(j).match(/^[^'\\\n\r]/)!==null){var k=b.charAt(j);j++}else k=null,q&&h("[^'\\\\\\n\\r]");k===null&&(k=fa(),k=k!==null?k:null);for(;k!==null;)f.push(k),b.substr(j).match(/^[^'\\\n\r]/)!==null?(k=b.charAt(j),j++):(k=null,q&&h("[^'\\\\\\n\\r]")),k===null&&(k=fa(),k=k!==null?k:null);f!==null?(b.substr(j,1)==="'"?(k="'",j+=1):(k=null,q&&h('"\'"')),k!==null?i=[i,f,k]:(i=null,j=d)):(i=null,j=d)}else i=null,j=d;d=i!==null?Z(i[1]):null;(q=e)&&d===null&&h("[139] STRING_LITERAL1"); -x[c]={nextPos:j,result:d};return d}function wa(){var c="STRING_LITERAL2@"+j,e=x[c];if(e)return j=e.nextPos,e.result;e=q;q=!1;var d=j;if(b.substr(j,1)==='"'){var i='"';j+=1}else i=null,q&&h('"\\""');if(i!==null){var f=[];if(b.substr(j).match(/^[^"\\\n\r]/)!==null){var k=b.charAt(j);j++}else k=null,q&&h('[^"\\\\\\n\\r]');k===null&&(k=fa(),k=k!==null?k:null);for(;k!==null;)f.push(k),b.substr(j).match(/^[^"\\\n\r]/)!==null?(k=b.charAt(j),j++):(k=null,q&&h('[^"\\\\\\n\\r]')),k===null&&(k=fa(),k=k!==null? -k:null);f!==null?(b.substr(j,1)==='"'?(k='"',j+=1):(k=null,q&&h('"\\""')),k!==null?i=[i,f,k]:(i=null,j=d)):(i=null,j=d)}else i=null,j=d;d=i!==null?Z(i[1]):null;(q=e)&&d===null&&h("[140] STRING_LITERAL2");x[c]={nextPos:j,result:d};return d}function Ra(){var c="STRING_LITERAL_LONG1@"+j,e=x[c];if(e)return j=e.nextPos,e.result;e=q;q=!1;var d=j;if(b.substr(j,3)==="'''"){var i="'''";j+=3}else i=null,q&&h("\"'''\"");if(i!==null){var f=[];if(b.substr(j).match(/^[^'\\]/)!==null){var k=b.charAt(j);j++}else k= -null,q&&h("[^'\\\\]");k===null&&(k=fa(),k=k!==null?k:null);for(;k!==null;)f.push(k),b.substr(j).match(/^[^'\\]/)!==null?(k=b.charAt(j),j++):(k=null,q&&h("[^'\\\\]")),k===null&&(k=fa(),k=k!==null?k:null);f!==null?(b.substr(j,3)==="'''"?(k="'''",j+=3):(k=null,q&&h("\"'''\"")),k!==null?i=[i,f,k]:(i=null,j=d)):(i=null,j=d)}else i=null,j=d;d=i!==null?Z(i[1]):null;(q=e)&&d===null&&h("[141] STRING_LITERAL_LONG1");x[c]={nextPos:j,result:d};return d}function Sa(){var c="STRING_LITERAL_LONG2@"+j,e=x[c];if(e)return j= -e.nextPos,e.result;e=q;q=!1;var d=j;if(b.substr(j,3)==='"""'){var i='"""';j+=3}else i=null,q&&h('"\\"\\"\\""');if(i!==null){var f=[];if(b.substr(j).match(/^[^"\\]/)!==null){var k=b.charAt(j);j++}else k=null,q&&h('[^"\\\\]');k===null&&(k=fa(),k=k!==null?k:null);for(;k!==null;)f.push(k),b.substr(j).match(/^[^"\\]/)!==null?(k=b.charAt(j),j++):(k=null,q&&h('[^"\\\\]')),k===null&&(k=fa(),k=k!==null?k:null);f!==null?(b.substr(j,3)==='"""'?(k='"""',j+=3):(k=null,q&&h('"\\"\\"\\""')),k!==null?i=[i,f,k]:(i= -null,j=d)):(i=null,j=d)}else i=null,j=d;d=i!==null?Z(i[1]):null;(q=e)&&d===null&&h("[142] STRING_LITERAL_LONG2");x[c]={nextPos:j,result:d};return d}function fa(){var c="ECHAR@"+j,e=x[c];if(e)return j=e.nextPos,e.result;e=q;q=!1;var d=j;if(b.substr(j,1)==="\\"){var i="\\";j+=1}else i=null,q&&h('"\\\\"');if(i!==null){if(b.substr(j).match(/^[tbnrf"']/)!==null){var f=b.charAt(j);j++}else f=null,q&&h("[tbnrf\"']");f!==null?i=[i,f]:(i=null,j=d)}else i=null,j=d;(q=e)&&i===null&&h("[143] ECHAR");x[c]={nextPos:j, -result:i};return i}function bb(){var c="NIL@"+j,e=x[c];if(e)return j=e.nextPos,e.result;e=q;q=!1;var d=j;if(b.substr(j,1)==="("){var i="(";j+=1}else i=null,q&&h('"("');if(i!==null){for(var f=[],k=A();k!==null;)f.push(k),k=A();f!==null?(b.substr(j,1)===")"?(k=")",j+=1):(k=null,q&&h('")"')),k!==null?i=[i,f,k]:(i=null,j=d)):(i=null,j=d)}else i=null,j=d;d=i!==null?{token:"triplesnodecollection",triplesContext:[],chainSubject:[{token:"uri",value:"http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"}]}:null; -(q=e)&&d===null&&h("[144] NIL");x[c]={nextPos:j,result:d};return d}function A(){var c="WS@"+j,e=x[c];if(e)return j=e.nextPos,e.result;e=q;q=!1;if(b.substr(j).match(/^[ ]/)!==null){var d=b.charAt(j);j++}else d=null,q&&h("[ ]");d===null&&(b.substr(j).match(/^[\t]/)!==null?(d=b.charAt(j),j++):(d=null,q&&h("[\t]")),d===null&&(b.substr(j).match(/^[\r]/)!==null?(d=b.charAt(j),j++):(d=null,q&&h("[\\r]")),d===null&&(b.substr(j).match(/^[\n]/)!==null?(d=b.charAt(j),j++):(d=null,q&&h("[\\n]")),d===null&&(d= -Ha(),d=d!==null?d:null))));(q=e)&&d===null&&h("[145] WS");x[c]={nextPos:j,result:d};return d}function Ha(){var c="COMMENT@"+j,e=x[c];if(e)return j=e.nextPos,e.result;e=q;q=!1;var d=j;if(b.substr(j,1)==="#"){var i="#";j+=1}else i=null,q&&h('"#"');if(i!==null){var f=[];if(b.substr(j).match(/^[^\n\r]/)!==null){var k=b.charAt(j);j++}else k=null,q&&h("[^\\n\\r]");for(;k!==null;)f.push(k),b.substr(j).match(/^[^\n\r]/)!==null?(k=b.charAt(j),j++):(k=null,q&&h("[^\\n\\r]"));f!==null?i=[i,f]:(i=null,j=d)}else i= -null,j=d;(q=e)&&i===null&&h(" COMMENT");x[c]={nextPos:j,result:i};return i}function ya(){var c="ANON@"+j,e=x[c];if(e)return j=e.nextPos,e.result;e=q;q=!1;var d=j;if(b.substr(j,1)==="["){var i="[";j+=1}else i=null,q&&h('"["');if(i!==null){for(var f=[],k=A();k!==null;)f.push(k),k=A();f!==null?(b.substr(j,1)==="]"?(k="]",j+=1):(k=null,q&&h('"]"')),k!==null?i=[i,f,k]:(i=null,j=d)):(i=null,j=d)}else i=null,j=d;(q=e)&&i===null&&h("[146] ANON");x[c]={nextPos:j,result:i};return i}function Va(){var c="PN_CHARS_BASE@"+ -j,e=x[c];if(e)return j=e.nextPos,e.result;e=q;q=!1;if(b.substr(j).match(/^[A-Z]/)!==null){var d=b.charAt(j);j++}else d=null,q&&h("[A-Z]");d===null&&(b.substr(j).match(/^[a-z]/)!==null?(d=b.charAt(j),j++):(d=null,q&&h("[a-z]")),d===null&&(b.substr(j).match(/^[\xC0-\xD6]/)!==null?(d=b.charAt(j),j++):(d=null,q&&h("[\\xC0-\\xD6]")),d===null&&(b.substr(j).match(/^[\xD8-\xF6]/)!==null?(d=b.charAt(j),j++):(d=null,q&&h("[\\xD8-\\xF6]")),d===null&&(b.substr(j).match(/^[\xF8-\u02FF]/)!==null?(d=b.charAt(j), -j++):(d=null,q&&h("[\\xF8-\\u02FF]")),d===null&&(b.substr(j).match(/^[\u0370-\u037D]/)!==null?(d=b.charAt(j),j++):(d=null,q&&h("[\\u0370-\\u037D]")),d===null&&(b.substr(j).match(/^[\u037F-\u1FFF]/)!==null?(d=b.charAt(j),j++):(d=null,q&&h("[\\u037F-\\u1FFF]")),d===null&&(b.substr(j).match(/^[\u200C-\u200D]/)!==null?(d=b.charAt(j),j++):(d=null,q&&h("[\\u200C-\\u200D]")),d===null&&(b.substr(j).match(/^[\u2070-\u218F]/)!==null?(d=b.charAt(j),j++):(d=null,q&&h("[\\u2070-\\u218F]")),d===null&&(b.substr(j).match(/^[\u2C00-\u2FEF]/)!== -null?(d=b.charAt(j),j++):(d=null,q&&h("[\\u2C00-\\u2FEF]")),d===null&&(b.substr(j).match(/^[\u3001-\uD7FF]/)!==null?(d=b.charAt(j),j++):(d=null,q&&h("[\\u3001-\\uD7FF]")),d===null&&(b.substr(j).match(/^[\uF900-\uFDCF]/)!==null?(d=b.charAt(j),j++):(d=null,q&&h("[\\uF900-\\uFDCF]")),d===null&&(b.substr(j).match(/^[\uFDF0-\uFFFD]/)!==null?(d=b.charAt(j),j++):(d=null,q&&h("[\\uFDF0-\\uFFFD]")),d===null&&(b.substr(j).match(/^[\u1000-\uEFFF]/)!==null?(d=b.charAt(j),j++):(d=null,q&&h("[\\u1000-\\uEFFF]")), -d=d!==null?d:null)))))))))))));(q=e)&&d===null&&h("[147] PN_CHARS_BASE");x[c]={nextPos:j,result:d};return d}function $(){var c="PN_CHARS_U@"+j,e=x[c];if(e)return j=e.nextPos,e.result;e=q;q=!1;var d=Va();d===null&&(b.substr(j,1)==="_"?(d="_",j+=1):(d=null,q&&h('"_"')),d=d!==null?d:null);(q=e)&&d===null&&h("[148] PN_CHARS_U");x[c]={nextPos:j,result:d};return d}function Aa(){var c="VARNAME@"+j,e=x[c];if(e)return j=e.nextPos,e.result;e=q;q=!1;var d=j,i=$();i===null&&(b.substr(j).match(/^[0-9]/)!==null? -(i=b.charAt(j),j++):(i=null,q&&h("[0-9]")),i=i!==null?i:null);if(i!==null){var f=[],k=$();k===null&&(b.substr(j).match(/^[0-9]/)!==null?(k=b.charAt(j),j++):(k=null,q&&h("[0-9]")),k===null&&(b.substr(j).match(/^[\xB7]/)!==null?(k=b.charAt(j),j++):(k=null,q&&h("[\\xB7]")),k===null&&(b.substr(j).match(/^[\u0300-\u036F]/)!==null?(k=b.charAt(j),j++):(k=null,q&&h("[\\u0300-\\u036F]")),k===null&&(b.substr(j).match(/^[\u203F-\u2040]/)!==null?(k=b.charAt(j),j++):(k=null,q&&h("[\\u203F-\\u2040]")),k=k!==null? -k:null))));for(;k!==null;)f.push(k),k=$(),k===null&&(b.substr(j).match(/^[0-9]/)!==null?(k=b.charAt(j),j++):(k=null,q&&h("[0-9]")),k===null&&(b.substr(j).match(/^[\xB7]/)!==null?(k=b.charAt(j),j++):(k=null,q&&h("[\\xB7]")),k===null&&(b.substr(j).match(/^[\u0300-\u036F]/)!==null?(k=b.charAt(j),j++):(k=null,q&&h("[\\u0300-\\u036F]")),k===null&&(b.substr(j).match(/^[\u203F-\u2040]/)!==null?(k=b.charAt(j),j++):(k=null,q&&h("[\\u203F-\\u2040]")),k=k!==null?k:null))));f!==null?i=[i,f]:(i=null,j=d)}else i= -null,j=d;d=i!==null?i[0]+i[1].join(""):null;(q=e)&&d===null&&h("[149] VARNAME");x[c]={nextPos:j,result:d};return d}function oa(){var c="PN_CHARS@"+j,e=x[c];if(e)return j=e.nextPos,e.result;e=q;q=!1;var d=$();d===null&&(b.substr(j,1)==="-"?(d="-",j+=1):(d=null,q&&h('"-"')),d===null&&(b.substr(j).match(/^[0-9]/)!==null?(d=b.charAt(j),j++):(d=null,q&&h("[0-9]")),d===null&&(b.substr(j).match(/^[\xB7]/)!==null?(d=b.charAt(j),j++):(d=null,q&&h("[\\xB7]")),d===null&&(b.substr(j).match(/^[\u0300-\u036F]/)!== -null?(d=b.charAt(j),j++):(d=null,q&&h("[\\u0300-\\u036F]")),d===null&&(b.substr(j).match(/^[\u203F-\u2040]/)!==null?(d=b.charAt(j),j++):(d=null,q&&h("[\\u203F-\\u2040]")),d=d!==null?d:null)))));(q=e)&&d===null&&h("[150] PN_CHARS");x[c]={nextPos:j,result:d};return d}function Ea(){var c="PN_PREFIX@"+j,e=x[c];if(e)return j=e.nextPos,e.result;e=q;q=!1;var d=j,i=Va();if(i!==null){var f=[],k=oa();k===null&&(b.substr(j,1)==="."?(k=".",j+=1):(k=null,q&&h('"."')),k=k!==null?k:null);for(;k!==null;)f.push(k), -k=oa(),k===null&&(b.substr(j,1)==="."?(k=".",j+=1):(k=null,q&&h('"."')),k=k!==null?k:null);f!==null?i=[i,f]:(i=null,j=d)}else i=null,j=d;d=i!==null?function(b,c){if(c[c.length-1]==".")throw Error("Wrong PN_PREFIX, cannot finish with '.'");else return b+c.join("")}(i[0],i[1]):null;(q=e)&&d===null&&h("[151] PN_PREFIX");x[c]={nextPos:j,result:d};return d}function za(){var c="PN_LOCAL@"+j,e=x[c];if(e)return j=e.nextPos,e.result;e=q;q=!1;var d=j,i=$();i===null&&(b.substr(j).match(/^[0-9]/)!==null?(i=b.charAt(j), -j++):(i=null,q&&h("[0-9]")),i=i!==null?i:null);if(i!==null){var f=[],k=oa();k===null&&(b.substr(j,1)==="."?(k=".",j+=1):(k=null,q&&h('"."')),k=k!==null?k:null);for(;k!==null;)f.push(k),k=oa(),k===null&&(b.substr(j,1)==="."?(k=".",j+=1):(k=null,q&&h('"."')),k=k!==null?k:null);f!==null?i=[i,f]:(i=null,j=d)}else i=null,j=d;d=i!==null?i[0]+i[1].join(""):null;(q=e)&&d===null&&h("[152] PN_LOCAL");x[c]={nextPos:j,result:d};return d}function nb(){var c=function(b){b.sort();for(var c=null,h=[],e=0;epb&&(pb=a,Hb=[]),Hb.push(b))}function f(){var b="Query@"+a,c=y[b];if(c)return a=c.nextPos,c.result;c=m;m=!1;var n=a,g=o();if(g!==null){var e=u();e===null&&(e=D(),e===null&&(e=G(),e===null&&(e=H(),e=e!==null?e:null)));e!==null?g=[g,e]:(g=null,a=n)}else g= -null,a=n;n=g!==null?{token:"query",kind:"query",prologue:g[0],units:[g[1]]}:null;(m=c)&&n===null&&h("[2] Query");y[b]={nextPos:a,result:n};return n}function o(){var b="Prologue@"+a,c=y[b];if(c)return a=c.nextPos,c.result;c=m;m=!1;var n=a,g=r(),g=g!==null?g:"";if(g!==null){for(var e=[],d=t();d!==null;)e.push(d),d=t();if(e!==null){for(var d=[],i=v();i!==null;)d.push(i),i=v();d!==null?g=[g,e,d]:(g=null,a=n)}else g=null,a=n}else g=null,a=n;n=g!==null?{token:"prologue",base:g[0],prefixes:g[2]}:null;(m= -c)&&n===null&&h("[3] Prologue");y[b]={nextPos:a,result:n};return n}function r(){var c="BaseDecl@"+a,e=y[c];if(e)return a=e.nextPos,e.result;e=m;m=!1;for(var n=a,g=[],d=t();d!==null;)g.push(d),d=t();if(g!==null)if(b.substr(a,1)==="B"?(d="B",a+=1):(d=null,m&&h('"B"')),d===null&&(b.substr(a,1)==="b"?(d="b",a+=1):(d=null,m&&h('"b"')),d=d!==null?d:null),d!==null){if(b.substr(a,1)==="A"){var E="A";a+=1}else E=null,m&&h('"A"');E===null&&(b.substr(a,1)==="a"?(E="a",a+=1):(E=null,m&&h('"a"')),E=E!==null?E: -null);if(E!==null){if(b.substr(a,1)==="S"){var i="S";a+=1}else i=null,m&&h('"S"');i===null&&(b.substr(a,1)==="s"?(i="s",a+=1):(i=null,m&&h('"s"')),i=i!==null?i:null);if(i!==null){if(b.substr(a,1)==="E"){var B="E";a+=1}else B=null,m&&h('"E"');B===null&&(b.substr(a,1)==="e"?(B="e",a+=1):(B=null,m&&h('"e"')),B=B!==null?B:null);if(B!==null){for(var j=[],f=t();f!==null;)j.push(f),f=t();j!==null?(f=yb(),f!==null?g=[g,d,E,i,B,j,f]:(g=null,a=n)):(g=null,a=n)}else g=null,a=n}else g=null,a=n}else g=null,a= -n}else g=null,a=n;else g=null,a=n;n=g!==null?function(a){base={token:"base"};base.value=a;return base}(g[6]):null;(m=e)&&n===null&&h("[4] BaseDecl");y[c]={nextPos:a,result:n};return n}function v(){var c="PrefixDecl@"+a,e=y[c];if(e)return a=e.nextPos,e.result;e=m;m=!1;for(var n=a,g=[],d=t();d!==null;)g.push(d),d=t();if(g!==null)if(b.substr(a,1)==="P"?(d="P",a+=1):(d=null,m&&h('"P"')),d===null&&(b.substr(a,1)==="p"?(d="p",a+=1):(d=null,m&&h('"p"')),d=d!==null?d:null),d!==null){if(b.substr(a,1)==="R"){var E= -"R";a+=1}else E=null,m&&h('"R"');E===null&&(b.substr(a,1)==="r"?(E="r",a+=1):(E=null,m&&h('"r"')),E=E!==null?E:null);if(E!==null){if(b.substr(a,1)==="E"){var i="E";a+=1}else i=null,m&&h('"E"');i===null&&(b.substr(a,1)==="e"?(i="e",a+=1):(i=null,m&&h('"e"')),i=i!==null?i:null);if(i!==null){if(b.substr(a,1)==="F"){var B="F";a+=1}else B=null,m&&h('"F"');B===null&&(b.substr(a,1)==="f"?(B="f",a+=1):(B=null,m&&h('"f"')),B=B!==null?B:null);if(B!==null){if(b.substr(a,1)==="I"){var j="I";a+=1}else j=null, -m&&h('"I"');j===null&&(b.substr(a,1)==="i"?(j="i",a+=1):(j=null,m&&h('"i"')),j=j!==null?j:null);if(j!==null){if(b.substr(a,1)==="X"){var f="X";a+=1}else f=null,m&&h('"X"');f===null&&(b.substr(a,1)==="x"?(f="x",a+=1):(f=null,m&&h('"x"')),f=f!==null?f:null);if(f!==null){for(var k=[],C=t();C!==null;)k.push(C),C=t();if(k!==null)if(C=zb(),C!==null){for(var o=[],L=t();L!==null;)o.push(L),L=t();o!==null?(L=yb(),L!==null?g=[g,d,E,i,B,j,f,k,C,o,L]:(g=null,a=n)):(g=null,a=n)}else g=null,a=n;else g=null,a=n}else g= -null,a=n}else g=null,a=n}else g=null,a=n}else g=null,a=n}else g=null,a=n}else g=null,a=n;else g=null,a=n;n=g!==null?function(a,b){prefix={token:"prefix"};prefix.prefix=a;prefix.local=b;return prefix}(g[8],g[10]):null;(m=e)&&n===null&&h("[5] PrefixDecl");y[c]={nextPos:a,result:n};return n}function u(){var b="SelectQuery@"+a,c=y[b];if(c)return a=c.nextPos,c.result;c=m;m=!1;var n=a,g=F();if(g!==null){for(var e=[],d=t();d!==null;)e.push(d),d=t();if(e!==null){for(var d=[],i=P();i!==null;)d.push(i),i=P(); -if(d!==null){for(var i=[],B=t();B!==null;)i.push(B),B=t();if(i!==null)if(B=N(),B!==null){for(var j=[],f=t();f!==null;)j.push(f),f=t();if(j!==null)if(f=Q(),f!==null){for(var k=[],C=t();C!==null;)k.push(C),C=t();k!==null?(C=Ka(),C!==null?g=[g,e,d,i,B,j,f,k,C]:(g=null,a=n)):(g=null,a=n)}else g=null,a=n;else g=null,a=n}else g=null,a=n;else g=null,a=n}else g=null,a=n}else g=null,a=n}else g=null,a=n;n=g!==null?function(a,b,c,g){for(var h={named:[],"default":[]},n=0;n0&&b[0].length>0&&(c=c.concat(b[0][0].quadsContext),b[0][2]!=null&&b[0][2].triplesContext!=null))for(g=0;g0&&n.push({token:"basicgraphpattern",triplesContext:i});e=[]}n.push(c[g])}else c[g].token==="triplespattern"?e.push(c[g]):d.push(c[g]);if(e.length!=0||d.length!=0){i=[];for(h=0;h0&&n.push({token:"basicgraphpattern",triplesContext:i})}return{token:"groupgraphpattern",patterns:n,filters:d}}(g[0],g[2]):null;(m=e)&&n===null&&h("[51] GroupGraphPatternSub");y[c]={nextPos:a,result:n};return n}function va(){var c="TriplesBlock@"+a,e=y[c];if(e)return a=e.nextPos,e.result;e=m;m=!1;var n=a,g=Ha();if(g!==null){for(var d=a,i=[],j=t();j!==null;)i.push(j),j=t();if(i!==null)if(b.substr(a,1)==="."?(j=".",a+=1):(j=null,m&&h('"."')),j!==null){var f=va(),f=f!==null?f:"";f!==null?i= -[i,j,f]:(i=null,a=d)}else i=null,a=d;else i=null,a=d;d=i!==null?i:"";d!==null?g=[g,d]:(g=null,a=n)}else g=null,a=n;n=g!==null?function(a,b){var c=a.triplesContext;typeof b==="object"&&b.length!=null&&b[2].triplesContext!=null&&(c=c.concat(b[2].triplesContext));return{token:"triplespattern",triplesContext:c}}(g[0],g[1]):null;(m=e)&&n===null&&h("[54] TriplesBlock");y[c]={nextPos:a,result:n};return n}function Qa(){var b="GraphPatternNotTriples@"+a,c=y[b];if(c)return a=c.nextPos,c.result;c=m;m=!1;var n= -Ga();n===null&&(n=hb(),n===null&&(n=ib(),n===null&&(n=kb(),n===null&&(n=jb(),n===null&&(n=lb(),n=n!==null?n:null)))));(m=c)&&n===null&&h("[53] GraphPatternNotTriples");y[b]={nextPos:a,result:n};return n}function hb(){var c="OptionalGraphPattern@"+a,e=y[c];if(e)return a=e.nextPos,e.result;e=m;m=!1;for(var n=a,g=[],d=t();d!==null;)g.push(d),d=t();if(g!==null)if(b.substr(a,8)==="OPTIONAL"?(d="OPTIONAL",a+=8):(d=null,m&&h('"OPTIONAL"')),d!==null){for(var i=[],j=t();j!==null;)i.push(j),j=t();i!==null? -(j=R(),j!==null?g=[g,d,i,j]:(g=null,a=n)):(g=null,a=n)}else g=null,a=n;else g=null,a=n;n=g!==null?{token:"optionalgraphpattern",value:g[3]}:null;(m=e)&&n===null&&h("[54] OptionalGraphPattern");y[c]={nextPos:a,result:n};return n}function kb(){var c="GraphGraphPattern@"+a,e=y[c];if(e)return a=e.nextPos,e.result;e=m;m=!1;for(var n=a,g=[],d=t();d!==null;)g.push(d),d=t();if(g!==null)if(b.substr(a,5)==="GRAPH"?(d="GRAPH",a+=5):(d=null,m&&h('"GRAPH"')),d!==null){for(var i=[],j=t();j!==null;)i.push(j),j= -t();if(i!==null)if(j=Ca(),j!==null){for(var f=[],k=t();k!==null;)f.push(k),k=t();f!==null?(k=R(),k!==null?g=[g,d,i,j,f,k]:(g=null,a=n)):(g=null,a=n)}else g=null,a=n;else g=null,a=n}else g=null,a=n;else g=null,a=n;n=g!==null?function(a,b){for(var c=0;c"?(k=">",a+=1):(k=null,m&&h('">"')),k!==null){o=[];for(s=t();s!==null;)o.push(s), -s=t();o!==null?(s=X(),s!==null?f=[f,k,o,s]:(f=null,a=j)):(f=null,a=j)}else f=null,a=j;else f=null,a=j;if(f!==null)j=f;else{j=a;f=[];for(k=t();k!==null;)f.push(k),k=t();if(f!==null)if(b.substr(a,2)==="<="?(k="<=",a+=2):(k=null,m&&h('"<="')),k!==null){o=[];for(s=t();s!==null;)o.push(s),s=t();o!==null?(s=X(),s!==null?f=[f,k,o,s]:(f=null,a=j)):(f=null,a=j)}else f=null,a=j;else f=null,a=j;if(f!==null)j=f;else{j=a;f=[];for(k=t();k!==null;)f.push(k),k=t();if(f!==null)if(b.substr(a,2)===">="?(k=">=",a+=2): -(k=null,m&&h('">="')),k!==null){o=[];for(s=t();s!==null;)o.push(s),s=t();o!==null?(s=X(),s!==null?f=[f,k,o,s]:(f=null,a=j)):(f=null,a=j)}else f=null,a=j;else f=null,a=j;j=f!==null?f:null}}}}}for(;j!==null;){i.push(j);j=a;f=[];for(k=t();k!==null;)f.push(k),k=t();if(f!==null)if(b.substr(a,1)==="="?(k="=",a+=1):(k=null,m&&h('"="')),k!==null){o=[];for(s=t();s!==null;)o.push(s),s=t();o!==null?(s=X(),s!==null?f=[f,k,o,s]:(f=null,a=j)):(f=null,a=j)}else f=null,a=j;else f=null,a=j;if(f!==null)j=f;else{j= -a;f=[];for(k=t();k!==null;)f.push(k),k=t();if(f!==null)if(b.substr(a,2)==="!="?(k="!=",a+=2):(k=null,m&&h('"!="')),k!==null){o=[];for(s=t();s!==null;)o.push(s),s=t();o!==null?(s=X(),s!==null?f=[f,k,o,s]:(f=null,a=j)):(f=null,a=j)}else f=null,a=j;else f=null,a=j;if(f!==null)j=f;else{j=a;f=[];for(k=t();k!==null;)f.push(k),k=t();if(f!==null)if(b.substr(a,1)==="<"?(k="<",a+=1):(k=null,m&&h('"<"')),k!==null){o=[];for(s=t();s!==null;)o.push(s),s=t();o!==null?(s=X(),s!==null?f=[f,k,o,s]:(f=null,a=j)):(f= -null,a=j)}else f=null,a=j;else f=null,a=j;if(f!==null)j=f;else{j=a;f=[];for(k=t();k!==null;)f.push(k),k=t();if(f!==null)if(b.substr(a,1)===">"?(k=">",a+=1):(k=null,m&&h('">"')),k!==null){o=[];for(s=t();s!==null;)o.push(s),s=t();o!==null?(s=X(),s!==null?f=[f,k,o,s]:(f=null,a=j)):(f=null,a=j)}else f=null,a=j;else f=null,a=j;if(f!==null)j=f;else{j=a;f=[];for(k=t();k!==null;)f.push(k),k=t();if(f!==null)if(b.substr(a,2)==="<="?(k="<=",a+=2):(k=null,m&&h('"<="')),k!==null){o=[];for(s=t();s!==null;)o.push(s), -s=t();o!==null?(s=X(),s!==null?f=[f,k,o,s]:(f=null,a=j)):(f=null,a=j)}else f=null,a=j;else f=null,a=j;if(f!==null)j=f;else{j=a;f=[];for(k=t();k!==null;)f.push(k),k=t();if(f!==null)if(b.substr(a,2)===">="?(k=">=",a+=2):(k=null,m&&h('">="')),k!==null){o=[];for(s=t();s!==null;)o.push(s),s=t();o!==null?(s=X(),s!==null?f=[f,k,o,s]:(f=null,a=j)):(f=null,a=j)}else f=null,a=j;else f=null,a=j;j=f!==null?f:null}}}}}}i!==null?g=[g,i]:(g=null,a=d)}else g=null,a=d;d=g!==null?function(a,b){if(b.length===0)return a; -else{var c={expressionType:"relationalexpression"};c.operator=b[0][1];c.op1=a;c.op2=b[0][3];c.token="expression";return c}}(g[0],g[1]):null;(m=e)&&d===null&&h("[99] RelationalExpression");y[c]={nextPos:a,result:d};return d}function X(){var c="AdditiveExpression@"+a,e=y[c];if(e)return a=e.nextPos,e.result;e=m;m=!1;var d=a,g=Ja();if(g!==null){for(var i=[],f=a,j=[],k=t();k!==null;)j.push(k),k=t();if(j!==null)if(b.substr(a,1)==="+"?(k="+",a+=1):(k=null,m&&h('"+"')),k!==null){for(var o=[],s=t();s!==null;)o.push(s), -s=t();o!==null?(s=Ja(),s!==null?j=[j,k,o,s]:(j=null,a=f)):(j=null,a=f)}else j=null,a=f;else j=null,a=f;if(j!==null)f=j;else{f=a;j=[];for(k=t();k!==null;)j.push(k),k=t();if(j!==null)if(b.substr(a,1)==="-"?(k="-",a+=1):(k=null,m&&h('"-"')),k!==null){o=[];for(s=t();s!==null;)o.push(s),s=t();o!==null?(s=Ja(),s!==null?j=[j,k,o,s]:(j=null,a=f)):(j=null,a=f)}else j=null,a=f;else j=null,a=f;if(j!==null)f=j;else{f=a;j=La();j===null&&(j=La(),j=j!==null?j:null);if(j!==null){k=a;o=[];for(s=t();s!==null;)o.push(s), -s=t();if(o!==null)if(b.substr(a,1)==="*"?(s="*",a+=1):(s=null,m&&h('"*"')),s!==null){for(var q=[],r=t();r!==null;)q.push(r),r=t();q!==null?(r=ka(),r!==null?o=[o,s,q,r]:(o=null,a=k)):(o=null,a=k)}else o=null,a=k;else o=null,a=k;if(o!==null)k=o;else{k=a;o=[];for(s=t();s!==null;)o.push(s),s=t();if(o!==null)if(b.substr(a,1)==="/"?(s="/",a+=1):(s=null,m&&h('"/"')),s!==null){q=[];for(r=t();r!==null;)q.push(r),r=t();q!==null?(r=ka(),r!==null?o=[o,s,q,r]:(o=null,a=k)):(o=null,a=k)}else o=null,a=k;else o= -null,a=k;k=o!==null?o:null}k=k!==null?k:"";k!==null?j=[j,k]:(j=null,a=f)}else j=null,a=f;f=j!==null?j:null}}for(;f!==null;){i.push(f);f=a;j=[];for(k=t();k!==null;)j.push(k),k=t();if(j!==null)if(b.substr(a,1)==="+"?(k="+",a+=1):(k=null,m&&h('"+"')),k!==null){o=[];for(s=t();s!==null;)o.push(s),s=t();o!==null?(s=Ja(),s!==null?j=[j,k,o,s]:(j=null,a=f)):(j=null,a=f)}else j=null,a=f;else j=null,a=f;if(j!==null)f=j;else{f=a;j=[];for(k=t();k!==null;)j.push(k),k=t();if(j!==null)if(b.substr(a,1)==="-"?(k="-", -a+=1):(k=null,m&&h('"-"')),k!==null){o=[];for(s=t();s!==null;)o.push(s),s=t();o!==null?(s=Ja(),s!==null?j=[j,k,o,s]:(j=null,a=f)):(j=null,a=f)}else j=null,a=f;else j=null,a=f;if(j!==null)f=j;else{f=a;j=La();j===null&&(j=La(),j=j!==null?j:null);if(j!==null){k=a;o=[];for(s=t();s!==null;)o.push(s),s=t();if(o!==null)if(b.substr(a,1)==="*"?(s="*",a+=1):(s=null,m&&h('"*"')),s!==null){q=[];for(r=t();r!==null;)q.push(r),r=t();q!==null?(r=ka(),r!==null?o=[o,s,q,r]:(o=null,a=k)):(o=null,a=k)}else o=null,a= -k;else o=null,a=k;if(o!==null)k=o;else{k=a;o=[];for(s=t();s!==null;)o.push(s),s=t();if(o!==null)if(b.substr(a,1)==="/"?(s="/",a+=1):(s=null,m&&h('"/"')),s!==null){q=[];for(r=t();r!==null;)q.push(r),r=t();q!==null?(r=ka(),r!==null?o=[o,s,q,r]:(o=null,a=k)):(o=null,a=k)}else o=null,a=k;else o=null,a=k;k=o!==null?o:null}k=k!==null?k:"";k!==null?j=[j,k]:(j=null,a=f)}else j=null,a=f;f=j!==null?j:null}}}i!==null?g=[g,i]:(g=null,a=d)}else g=null,a=d;d=g!==null?function(a,b){if(b.length===0)return a;var c= -{token:"expression",expressionType:"additiveexpression"};c.summand=a;c.summands=[];for(var g=0;g0?{token:"literal",value:a.value,lang:b.slice(1),type:null}:typeof b==="object"?(b.shift(),{token:"literal",value:a.value,lang:null,type:b[0]}):{token:"literal",value:a.value,lang:null,type:null}}(g[0],g[1]):null;(m=e)&&d===null&&h("[112] RDFLiteral");y[c]={nextPos:a,result:d};return d}function wb(){var b="NumericLiteral@"+ -a,c=y[b];if(c)return a=c.nextPos,c.result;c=m;m=!1;var e=Pb();e===null&&(e=Qb(),e===null&&(e=La(),e=e!==null?e:null));(m=c)&&e===null&&h("[113] NumericLiteral");y[b]={nextPos:a,result:e};return e}function Pb(){var b="NumericLiteralUnsigned@"+a,c=y[b];if(c)return a=c.nextPos,c.result;c=m;m=!1;var e=Ab();e===null&&(e=Bb(),e===null&&(e=pa(),e=e!==null?e:null));(m=c)&&e===null&&h("[114] NumericLiteralUnsigned");y[b]={nextPos:a,result:e};return e}function Qb(){var b="NumericLiteralPositive@"+a,c=y[b]; -if(c)return a=c.nextPos,c.result;c=m;m=!1;var e=Yb();e===null&&(e=Zb(),e===null&&(e=$b(),e=e!==null?e:null));(m=c)&&e===null&&h("[115] NumericLiteralPositive");y[b]={nextPos:a,result:e};return e}function La(){var b="NumericLiteralNegative@"+a,c=y[b];if(c)return a=c.nextPos,c.result;c=m;m=!1;var e=ac();e===null&&(e=bc(),e===null&&(e=cc(),e=e!==null?e:null));(m=c)&&e===null&&h("[116] NumericLiteralNegative");y[b]={nextPos:a,result:e};return e}function xb(){var c="BooleanLiteral@"+a,e=y[c];if(e)return a= -e.nextPos,e.result;e=m;m=!1;var d=a;if(b.substr(a,1)==="T"){var g="T";a+=1}else g=null,m&&h('"T"');g===null&&(b.substr(a,1)==="t"?(g="t",a+=1):(g=null,m&&h('"t"')),g=g!==null?g:null);if(g!==null){if(b.substr(a,1)==="R"){var f="R";a+=1}else f=null,m&&h('"R"');f===null&&(b.substr(a,1)==="r"?(f="r",a+=1):(f=null,m&&h('"r"')),f=f!==null?f:null);if(f!==null){if(b.substr(a,1)==="U"){var i="U";a+=1}else i=null,m&&h('"U"');i===null&&(b.substr(a,1)==="u"?(i="u",a+=1):(i=null,m&&h('"u"')),i=i!==null?i:null); -if(i!==null){if(b.substr(a,1)==="E"){var j="E";a+=1}else j=null,m&&h('"E"');j===null&&(b.substr(a,1)==="e"?(j="e",a+=1):(j=null,m&&h('"e"')),j=j!==null?j:null);j!==null?g=[g,f,i,j]:(g=null,a=d)}else g=null,a=d}else g=null,a=d}else g=null,a=d;d=g!==null?lit={token:"literal",lang:null,type:"http://www.w3.org/2001/XMLSchema#boolean",value:!0}:null;if(d===null){d=a;b.substr(a,1)==="F"?(g="F",a+=1):(g=null,m&&h('"F"'));g===null&&(b.substr(a,1)==="f"?(g="f",a+=1):(g=null,m&&h('"f"')),g=g!==null?g:null); -if(g!==null)if(b.substr(a,1)==="A"?(f="A",a+=1):(f=null,m&&h('"A"')),f===null&&(b.substr(a,1)==="a"?(f="a",a+=1):(f=null,m&&h('"a"')),f=f!==null?f:null),f!==null)if(b.substr(a,1)==="L"?(i="L",a+=1):(i=null,m&&h('"L"')),i===null&&(b.substr(a,1)==="l"?(i="l",a+=1):(i=null,m&&h('"l"')),i=i!==null?i:null),i!==null)if(b.substr(a,1)==="S"?(j="S",a+=1):(j=null,m&&h('"S"')),j===null&&(b.substr(a,1)==="s"?(j="s",a+=1):(j=null,m&&h('"s"')),j=j!==null?j:null),j!==null){if(b.substr(a,1)==="E"){var k="E";a+=1}else k= -null,m&&h('"E"');k===null&&(b.substr(a,1)==="e"?(k="e",a+=1):(k=null,m&&h('"e"')),k=k!==null?k:null);k!==null?g=[g,f,i,j,k]:(g=null,a=d)}else g=null,a=d;else g=null,a=d;else g=null,a=d;else g=null,a=d;d=g!==null?lit={token:"literal",lang:null,type:"http://www.w3.org/2001/XMLSchema#boolean",value:!1}:null;d=d!==null?d:null}(m=e)&&d===null&&h("[117] BooleanLiteral");y[c]={nextPos:a,result:d};return d}function Wb(){var b="String@"+a,c=y[b];if(c)return a=c.nextPos,c.result;c=m;m=!1;var e=dc(),e=e!==null? -{token:"string",value:e}:null;e===null&&(e=ec(),e=e!==null?{token:"string",value:e}:null,e===null&&(e=fc(),e=e!==null?{token:"string",value:e}:null,e===null&&(e=gc(),e=e!==null?{token:"string",value:e}:null,e=e!==null?e:null)));(m=c)&&e===null&&h("[118] String");y[b]={nextPos:a,result:e};return e}function S(){var b="IRIref@"+a,c=y[b];if(c)return a=c.nextPos,c.result;c=m;m=!1;var e=yb(),e=e!==null?{token:"uri",prefix:null,suffix:null,value:e}:null;e===null&&(e=hc(),e=e!==null?e:null,e=e!==null?e:null); -(m=c)&&e===null&&h("[119] IRIref");y[b]={nextPos:a,result:e};return e}function hc(){var b="PrefixedName@"+a,c=y[b];if(c)return a=c.nextPos,c.result;c=m;m=!1;var e=ic(),e=e!==null?{token:"uri",prefix:e[0],suffix:e[1],value:null}:null;e===null&&(e=zb(),e=e!==null?{token:"uri",prefix:e,suffix:"",value:null}:null,e=e!==null?e:null);(m=c)&&e===null&&h("[120] PrefixedName");y[b]={nextPos:a,result:e};return e}function Vb(){var b="BlankNode@"+a,c=y[b];if(c)return a=c.nextPos,c.result;c=m;m=!1;var e=jc(), -e=e!==null?{token:"blank",label:e}:null;e===null&&(kc()!==null?(qa++,e={token:"blank",label:""+qa}):e=null,e=e!==null?e:null);(m=c)&&e===null&&h("[121] BlankNode");y[b]={nextPos:a,result:e};return e}function yb(){var c="IRI_REF@"+a,e=y[c];if(e)return a=e.nextPos,e.result;e=m;m=!1;var d=a;if(b.substr(a,1)==="<"){var g="<";a+=1}else g=null,m&&h('"<"');if(g!==null){var f=[];if(b.substr(a).match(/^[^<>"{} | ^\\]/)!==null){var i=b.charAt(a);a++}else i=null,m&&h('[^<>"{} | ^\\\\]');for(;i!==null;)f.push(i), -b.substr(a).match(/^[^<>"{} | ^\\]/)!==null?(i=b.charAt(a),a++):(i=null,m&&h('[^<>"{} | ^\\\\]'));f!==null?(b.substr(a,1)===">"?(i=">",a+=1):(i=null,m&&h('">"')),i!==null?g=[g,f,i]:(g=null,a=d)):(g=null,a=d)}else g=null,a=d;d=g!==null?g[1].join(""):null;(m=e)&&d===null&&h("[122] IRI_REF");y[c]={nextPos:a,result:d};return d}function zb(){var c="PNAME_NS@"+a,e=y[c];if(e)return a=e.nextPos,e.result;e=m;m=!1;var d=a,g=lc(),g=g!==null?g:"";if(g!==null){if(b.substr(a,1)===":"){var f=":";a+=1}else f=null, -m&&h('":"');f!==null?g=[g,f]:(g=null,a=d)}else g=null,a=d;d=g!==null?g[0]:null;(m=e)&&d===null&&h("[123] PNAME_NS");y[c]={nextPos:a,result:d};return d}function ic(){var b="PNAME_LN@"+a,c=y[b];if(c)return a=c.nextPos,c.result;c=m;m=!1;var e=a,d=zb();if(d!==null){var f=Ib();f!==null?d=[d,f]:(d=null,a=e)}else d=null,a=e;e=d!==null?[d[0],d[1]]:null;(m=c)&&e===null&&h("[124] PNAME_LN");y[b]={nextPos:a,result:e};return e}function jc(){var c="BLANK_NODE_LABEL@"+a,e=y[c];if(e)return a=e.nextPos,e.result; -e=m;m=!1;var d=a;if(b.substr(a,2)==="_:"){var g="_:";a+=2}else g=null,m&&h('"_:"');if(g!==null){var f=Ib();f!==null?g=[g,f]:(g=null,a=d)}else g=null,a=d;d=g!==null?g[1]:null;(m=e)&&d===null&&h("[125] BLANK_NODE_LABEL");y[c]={nextPos:a,result:d};return d}function Tb(){var c="VAR1@"+a,e=y[c];if(e)return a=e.nextPos,e.result;e=m;m=!1;var d=a;if(b.substr(a,1)==="?"){var g="?";a+=1}else g=null,m&&h('"?"');if(g!==null){var f=Jb();f!==null?g=[g,f]:(g=null,a=d)}else g=null,a=d;d=g!==null?g[1]:null;(m=e)&& -d===null&&h("[126] VAR1");y[c]={nextPos:a,result:d};return d}function Ub(){var c="VAR2@"+a,e=y[c];if(e)return a=e.nextPos,e.result;e=m;m=!1;var d=a;if(b.substr(a,1)==="$"){var g="$";a+=1}else g=null,m&&h('"$"');if(g!==null){var f=Jb();f!==null?g=[g,f]:(g=null,a=d)}else g=null,a=d;d=g!==null?g[1]:null;(m=e)&&d===null&&h("[127] VAR2");y[c]={nextPos:a,result:d};return d}function Xb(){var c="LANGTAG@"+a,e=y[c];if(e)return a=e.nextPos,e.result;e=m;m=!1;var d=a;if(b.substr(a,1)==="@"){var g="@";a+=1}else g= -null,m&&h('"@"');if(g!==null){if(b.substr(a).match(/^[a-zA-Z]/)!==null){var f=b.charAt(a);a++}else f=null,m&&h("[a-zA-Z]");if(f!==null)for(var i=[];f!==null;)i.push(f),b.substr(a).match(/^[a-zA-Z]/)!==null?(f=b.charAt(a),a++):(f=null,m&&h("[a-zA-Z]"));else i=null;if(i!==null){var f=[],j=a;if(b.substr(a,1)==="-"){var k="-";a+=1}else k=null,m&&h('"-"');if(k!==null){if(b.substr(a).match(/^[a-zA-Z0-9]/)!==null){var o=b.charAt(a);a++}else o=null,m&&h("[a-zA-Z0-9]");if(o!==null)for(var q=[];o!==null;)q.push(o), -b.substr(a).match(/^[a-zA-Z0-9]/)!==null?(o=b.charAt(a),a++):(o=null,m&&h("[a-zA-Z0-9]"));else q=null;q!==null?k=[k,q]:(k=null,a=j)}else k=null,a=j;for(;k!==null;)if(f.push(k),j=a,b.substr(a,1)==="-"?(k="-",a+=1):(k=null,m&&h('"-"')),k!==null){b.substr(a).match(/^[a-zA-Z0-9]/)!==null?(o=b.charAt(a),a++):(o=null,m&&h("[a-zA-Z0-9]"));if(o!==null)for(q=[];o!==null;)q.push(o),b.substr(a).match(/^[a-zA-Z0-9]/)!==null?(o=b.charAt(a),a++):(o=null,m&&h("[a-zA-Z0-9]"));else q=null;q!==null?k=[k,q]:(k=null, -a=j)}else k=null,a=j;f!==null?g=[g,i,f]:(g=null,a=d)}else g=null,a=d}else g=null,a=d;d=g!==null?g[2].length===0?("@"+g[1].join("")).toLowerCase():("@"+g[1].join("")+"-"+g[2][0][1].join("")).toLowerCase():null;(m=e)&&d===null&&h("[128] LANGTAG");y[c]={nextPos:a,result:d};return d}function pa(){var c="INTEGER@"+a,e=y[c];if(e)return a=e.nextPos,e.result;e=m;m=!1;if(b.substr(a).match(/^[0-9]/)!==null){var d=b.charAt(a);a++}else d=null,m&&h("[0-9]");if(d!==null)for(var g=[];d!==null;)g.push(d),b.substr(a).match(/^[0-9]/)!== -null?(d=b.charAt(a),a++):(d=null,m&&h("[0-9]"));else g=null;d=g!==null?function(a){lit={token:"literal",lang:null,type:"http://www.w3.org/2001/XMLSchema#integer"};lit.value=ja(a);return lit}(g):null;(m=e)&&d===null&&h("[129] INTEGER");y[c]={nextPos:a,result:d};return d}function Bb(){var c="DECIMAL@"+a,e=y[c];if(e)return a=e.nextPos,e.result;e=m;m=!1;var d=a;if(b.substr(a).match(/^[0-9]/)!==null){var g=b.charAt(a);a++}else g=null,m&&h("[0-9]");if(g!==null)for(var f=[];g!==null;)f.push(g),b.substr(a).match(/^[0-9]/)!== -null?(g=b.charAt(a),a++):(g=null,m&&h("[0-9]"));else f=null;if(f!==null)if(b.substr(a,1)==="."?(g=".",a+=1):(g=null,m&&h('"."')),g!==null){var i=[];if(b.substr(a).match(/^[0-9]/)!==null){var j=b.charAt(a);a++}else j=null,m&&h("[0-9]");for(;j!==null;)i.push(j),b.substr(a).match(/^[0-9]/)!==null?(j=b.charAt(a),a++):(j=null,m&&h("[0-9]"));i!==null?f=[f,g,i]:(f=null,a=d)}else f=null,a=d;else f=null,a=d;d=f!==null?function(a,b,c){lit={token:"literal",lang:null,type:"http://www.w3.org/2001/XMLSchema#decimal"}; -lit.value=ja([a,b,c]);return lit}(f[0],f[1],f[2]):null;if(d===null){d=a;b.substr(a,1)==="."?(f=".",a+=1):(f=null,m&&h('"."'));if(f!==null){b.substr(a).match(/^[0-9]/)!==null?(g=b.charAt(a),a++):(g=null,m&&h("[0-9]"));if(g!==null)for(i=[];g!==null;)i.push(g),b.substr(a).match(/^[0-9]/)!==null?(g=b.charAt(a),a++):(g=null,m&&h("[0-9]"));else i=null;i!==null?f=[f,i]:(f=null,a=d)}else f=null,a=d;d=f!==null?function(a,b){lit={token:"literal",lang:null,type:"http://www.w3.org/2001/XMLSchema#decimal"};lit.value= -ja([a,b]);return lit}(f[0],f[1]):null;d=d!==null?d:null}(m=e)&&d===null&&h("[130] DECIMAL");y[c]={nextPos:a,result:d};return d}function Ab(){var c="DOUBLE@"+a,e=y[c];if(e)return a=e.nextPos,e.result;e=m;m=!1;var d=a;if(b.substr(a).match(/^[0-9]/)!==null){var g=b.charAt(a);a++}else g=null,m&&h("[0-9]");if(g!==null)for(var f=[];g!==null;)f.push(g),b.substr(a).match(/^[0-9]/)!==null?(g=b.charAt(a),a++):(g=null,m&&h("[0-9]"));else f=null;if(f!==null)if(b.substr(a,1)==="."?(g=".",a+=1):(g=null,m&&h('"."')), -g!==null){var i=[];if(b.substr(a).match(/^[0-9]/)!==null){var j=b.charAt(a);a++}else j=null,m&&h("[0-9]");for(;j!==null;)i.push(j),b.substr(a).match(/^[0-9]/)!==null?(j=b.charAt(a),a++):(j=null,m&&h("[0-9]"));i!==null?(j=Cb(),j!==null?f=[f,g,i,j]:(f=null,a=d)):(f=null,a=d)}else f=null,a=d;else f=null,a=d;d=f!==null?function(a,b,c,e){lit={token:"literal",lang:null,type:"http://www.w3.org/2001/XMLSchema#double"};lit.value=ja([a,b,c,e]);return lit}(f[0],f[1],f[2],f[3]):null;if(d===null){d=a;b.substr(a, -1)==="."?(f=".",a+=1):(f=null,m&&h('"."'));if(f!==null){b.substr(a).match(/^[0-9]/)!==null?(i=b.charAt(a),a++):(i=null,m&&h("[0-9]"));if(i!==null)for(g=[];i!==null;)g.push(i),b.substr(a).match(/^[0-9]/)!==null?(i=b.charAt(a),a++):(i=null,m&&h("[0-9]"));else g=null;g!==null?(i=Cb(),i!==null?f=[f,g,i]:(f=null,a=d)):(f=null,a=d)}else f=null,a=d;d=f!==null?function(a,b,c){lit={token:"literal",lang:null,type:"http://www.w3.org/2001/XMLSchema#double"};lit.value=ja([a,b,c]);return lit}(f[0],f[1],f[2]):null; -if(d===null){d=a;b.substr(a).match(/^[0-9]/)!==null?(g=b.charAt(a),a++):(g=null,m&&h("[0-9]"));if(g!==null)for(f=[];g!==null;)f.push(g),b.substr(a).match(/^[0-9]/)!==null?(g=b.charAt(a),a++):(g=null,m&&h("[0-9]"));else f=null;f!==null?(g=Cb(),g!==null?f=[f,g]:(f=null,a=d)):(f=null,a=d);d=f!==null?function(a,b){lit={token:"literal",lang:null,type:"http://www.w3.org/2001/XMLSchema#double"};lit.value=ja([a,b]);return lit}(f[0],f[1]):null;d=d!==null?d:null}}(m=e)&&d===null&&h("[131] DOUBLE");y[c]={nextPos:a, -result:d};return d}function $b(){var c="INTEGER_POSITIVE@"+a,e=y[c];if(e)return a=e.nextPos,e.result;e=m;m=!1;var d=a;if(b.substr(a,1)==="+"){var g="+";a+=1}else g=null,m&&h('"+"');if(g!==null){var f=pa();f!==null?g=[g,f]:(g=null,a=d)}else g=null,a=d;d=g!==null?function(a){a.value="+"+a.value;return a}(g[1]):null;(m=e)&&d===null&&h("[132] INTEGER_POSITIVE");y[c]={nextPos:a,result:d};return d}function Zb(){var c="DECIMAL_POSITIVE@"+a,e=y[c];if(e)return a=e.nextPos,e.result;e=m;m=!1;var d=a;if(b.substr(a, -1)==="+"){var g="+";a+=1}else g=null,m&&h('"+"');if(g!==null){var f=Bb();f!==null?g=[g,f]:(g=null,a=d)}else g=null,a=d;d=g!==null?function(a){a.value="+"+a.value;return a}(g[1]):null;(m=e)&&d===null&&h("[133] DECIMAL_POSITIVE");y[c]={nextPos:a,result:d};return d}function Yb(){var c="DOUBLE_POSITIVE@"+a,e=y[c];if(e)return a=e.nextPos,e.result;e=m;m=!1;var d=a;if(b.substr(a,1)==="+"){var g="+";a+=1}else g=null,m&&h('"+"');if(g!==null){var f=Ab();f!==null?g=[g,f]:(g=null,a=d)}else g=null,a=d;d=g!==null? -function(a){a.value="+"+a.value;return a}(g[1]):null;(m=e)&&d===null&&h("[134] DOUBLE_POSITIVE");y[c]={nextPos:a,result:d};return d}function cc(){var c="INTEGER_NEGATIVE@"+a,e=y[c];if(e)return a=e.nextPos,e.result;e=m;m=!1;var d=a;if(b.substr(a,1)==="-"){var g="-";a+=1}else g=null,m&&h('"-"');if(g!==null){var f=pa();f!==null?g=[g,f]:(g=null,a=d)}else g=null,a=d;d=g!==null?function(a){a.value="-"+a.value;return a}(g[1]):null;(m=e)&&d===null&&h("[135] INTEGER_NEGATIVE");y[c]={nextPos:a,result:d};return d} -function bc(){var c="DECIMAL_NEGATIVE@"+a,e=y[c];if(e)return a=e.nextPos,e.result;e=m;m=!1;var d=a;if(b.substr(a,1)==="-"){var g="-";a+=1}else g=null,m&&h('"-"');if(g!==null){var f=Bb();f!==null?g=[g,f]:(g=null,a=d)}else g=null,a=d;d=g!==null?function(a){a.value="-"+a.value;return a}(g[1]):null;(m=e)&&d===null&&h("[136] DECIMAL_NEGATIVE");y[c]={nextPos:a,result:d};return d}function ac(){var c="DOUBLE_NEGATIVE@"+a,e=y[c];if(e)return a=e.nextPos,e.result;e=m;m=!1;var d=a;if(b.substr(a,1)==="-"){var g= -"-";a+=1}else g=null,m&&h('"-"');if(g!==null){var f=Ab();f!==null?g=[g,f]:(g=null,a=d)}else g=null,a=d;d=g!==null?function(a){a.value="-"+a.value;return a}(g[1]):null;(m=e)&&d===null&&h("[137] DOUBLE_NEGATIVE");y[c]={nextPos:a,result:d};return d}function Cb(){var c="EXPONENT@"+a,e=y[c];if(e)return a=e.nextPos,e.result;e=m;m=!1;var d=a;if(b.substr(a).match(/^[eE]/)!==null){var g=b.charAt(a);a++}else g=null,m&&h("[eE]");if(g!==null){if(b.substr(a).match(/^[+\-]/)!==null){var f=b.charAt(a);a++}else f= -null,m&&h("[+\\-]");f=f!==null?f:"";if(f!==null){if(b.substr(a).match(/^[0-9]/)!==null){var i=b.charAt(a);a++}else i=null,m&&h("[0-9]");if(i!==null)for(var j=[];i!==null;)j.push(i),b.substr(a).match(/^[0-9]/)!==null?(i=b.charAt(a),a++):(i=null,m&&h("[0-9]"));else j=null;j!==null?g=[g,f,j]:(g=null,a=d)}else g=null,a=d}else g=null,a=d;d=g!==null?ja([g[0],g[1],g[2]]):null;(m=e)&&d===null&&h("[138] EXPONENT");y[c]={nextPos:a,result:d};return d}function fc(){var c="STRING_LITERAL1@"+a,e=y[c];if(e)return a= -e.nextPos,e.result;e=m;m=!1;var d=a;if(b.substr(a,1)==="'"){var g="'";a+=1}else g=null,m&&h('"\'"');if(g!==null){var f=[];if(b.substr(a).match(/^[^'\\\n\r]/)!==null){var i=b.charAt(a);a++}else i=null,m&&h("[^'\\\\\\n\\r]");i===null&&(i=ra(),i=i!==null?i:null);for(;i!==null;)f.push(i),b.substr(a).match(/^[^'\\\n\r]/)!==null?(i=b.charAt(a),a++):(i=null,m&&h("[^'\\\\\\n\\r]")),i===null&&(i=ra(),i=i!==null?i:null);f!==null?(b.substr(a,1)==="'"?(i="'",a+=1):(i=null,m&&h('"\'"')),i!==null?g=[g,f,i]:(g= -null,a=d)):(g=null,a=d)}else g=null,a=d;d=g!==null?ja(g[1]):null;(m=e)&&d===null&&h("[139] STRING_LITERAL1");y[c]={nextPos:a,result:d};return d}function gc(){var c="STRING_LITERAL2@"+a,e=y[c];if(e)return a=e.nextPos,e.result;e=m;m=!1;var d=a;if(b.substr(a,1)==='"'){var g='"';a+=1}else g=null,m&&h('"\\""');if(g!==null){var f=[];if(b.substr(a).match(/^[^"\\\n\r]/)!==null){var i=b.charAt(a);a++}else i=null,m&&h('[^"\\\\\\n\\r]');i===null&&(i=ra(),i=i!==null?i:null);for(;i!==null;)f.push(i),b.substr(a).match(/^[^"\\\n\r]/)!== -null?(i=b.charAt(a),a++):(i=null,m&&h('[^"\\\\\\n\\r]')),i===null&&(i=ra(),i=i!==null?i:null);f!==null?(b.substr(a,1)==='"'?(i='"',a+=1):(i=null,m&&h('"\\""')),i!==null?g=[g,f,i]:(g=null,a=d)):(g=null,a=d)}else g=null,a=d;d=g!==null?ja(g[1]):null;(m=e)&&d===null&&h("[140] STRING_LITERAL2");y[c]={nextPos:a,result:d};return d}function dc(){var c="STRING_LITERAL_LONG1@"+a,e=y[c];if(e)return a=e.nextPos,e.result;e=m;m=!1;var d=a;if(b.substr(a,3)==="'''"){var g="'''";a+=3}else g=null,m&&h("\"'''\"");if(g!== -null){var f=[];if(b.substr(a).match(/^[^'\\]/)!==null){var i=b.charAt(a);a++}else i=null,m&&h("[^'\\\\]");i===null&&(i=ra(),i=i!==null?i:null);for(;i!==null;)f.push(i),b.substr(a).match(/^[^'\\]/)!==null?(i=b.charAt(a),a++):(i=null,m&&h("[^'\\\\]")),i===null&&(i=ra(),i=i!==null?i:null);f!==null?(b.substr(a,3)==="'''"?(i="'''",a+=3):(i=null,m&&h("\"'''\"")),i!==null?g=[g,f,i]:(g=null,a=d)):(g=null,a=d)}else g=null,a=d;d=g!==null?ja(g[1]):null;(m=e)&&d===null&&h("[141] STRING_LITERAL_LONG1");y[c]={nextPos:a, -result:d};return d}function ec(){var c="STRING_LITERAL_LONG2@"+a,e=y[c];if(e)return a=e.nextPos,e.result;e=m;m=!1;var d=a;if(b.substr(a,3)==='"""'){var g='"""';a+=3}else g=null,m&&h('"\\"\\"\\""');if(g!==null){var f=[];if(b.substr(a).match(/^[^"\\]/)!==null){var i=b.charAt(a);a++}else i=null,m&&h('[^"\\\\]');i===null&&(i=ra(),i=i!==null?i:null);for(;i!==null;)f.push(i),b.substr(a).match(/^[^"\\]/)!==null?(i=b.charAt(a),a++):(i=null,m&&h('[^"\\\\]')),i===null&&(i=ra(),i=i!==null?i:null);f!==null?(b.substr(a, -3)==='"""'?(i='"""',a+=3):(i=null,m&&h('"\\"\\"\\""')),i!==null?g=[g,f,i]:(g=null,a=d)):(g=null,a=d)}else g=null,a=d;d=g!==null?ja(g[1]):null;(m=e)&&d===null&&h("[142] STRING_LITERAL_LONG2");y[c]={nextPos:a,result:d};return d}function ra(){var c="ECHAR@"+a,e=y[c];if(e)return a=e.nextPos,e.result;e=m;m=!1;var d=a;if(b.substr(a,1)==="\\"){var g="\\";a+=1}else g=null,m&&h('"\\\\"');if(g!==null){if(b.substr(a).match(/^[tbnrf"']/)!==null){var f=b.charAt(a);a++}else f=null,m&&h("[tbnrf\"']");f!==null?g= -[g,f]:(g=null,a=d)}else g=null,a=d;(m=e)&&g===null&&h("[143] ECHAR");y[c]={nextPos:a,result:g};return g}function Ia(){var c="NIL@"+a,e=y[c];if(e)return a=e.nextPos,e.result;e=m;m=!1;var d=a;if(b.substr(a,1)==="("){var g="(";a+=1}else g=null,m&&h('"("');if(g!==null){for(var f=[],i=t();i!==null;)f.push(i),i=t();f!==null?(b.substr(a,1)===")"?(i=")",a+=1):(i=null,m&&h('")"')),i!==null?g=[g,f,i]:(g=null,a=d)):(g=null,a=d)}else g=null,a=d;d=g!==null?{token:"triplesnodecollection",triplesContext:[],chainSubject:[{token:"uri", -value:"http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"}]}:null;(m=e)&&d===null&&h("[144] NIL");y[c]={nextPos:a,result:d};return d}function t(){var c="WS@"+a,e=y[c];if(e)return a=e.nextPos,e.result;e=m;m=!1;if(b.substr(a).match(/^[ ]/)!==null){var d=b.charAt(a);a++}else d=null,m&&h("[ ]");d===null&&(b.substr(a).match(/^[\t]/)!==null?(d=b.charAt(a),a++):(d=null,m&&h("[\t]")),d===null&&(b.substr(a).match(/^[\r]/)!==null?(d=b.charAt(a),a++):(d=null,m&&h("[\\r]")),d===null&&(b.substr(a).match(/^[\n]/)!== -null?(d=b.charAt(a),a++):(d=null,m&&h("[\\n]")),d===null&&(d=mc(),d=d!==null?d:null))));(m=e)&&d===null&&h("[145] WS");y[c]={nextPos:a,result:d};return d}function mc(){var c="COMMENT@"+a,e=y[c];if(e)return a=e.nextPos,e.result;e=m;m=!1;var d=a;if(b.substr(a,1)==="#"){var g="#";a+=1}else g=null,m&&h('"#"');if(g!==null){var f=[];if(b.substr(a).match(/^[^\n\r]/)!==null){var i=b.charAt(a);a++}else i=null,m&&h("[^\\n\\r]");for(;i!==null;)f.push(i),b.substr(a).match(/^[^\n\r]/)!==null?(i=b.charAt(a),a++): -(i=null,m&&h("[^\\n\\r]"));f!==null?g=[g,f]:(g=null,a=d)}else g=null,a=d;(m=e)&&g===null&&h(" COMMENT");y[c]={nextPos:a,result:g};return g}function kc(){var c="ANON@"+a,e=y[c];if(e)return a=e.nextPos,e.result;e=m;m=!1;var d=a;if(b.substr(a,1)==="["){var g="[";a+=1}else g=null,m&&h('"["');if(g!==null){for(var f=[],i=t();i!==null;)f.push(i),i=t();f!==null?(b.substr(a,1)==="]"?(i="]",a+=1):(i=null,m&&h('"]"')),i!==null?g=[g,f,i]:(g=null,a=d)):(g=null,a=d)}else g=null,a=d;(m=e)&&g===null&&h("[146] ANON"); -y[c]={nextPos:a,result:g};return g}function Kb(){var c="PN_CHARS_BASE@"+a,e=y[c];if(e)return a=e.nextPos,e.result;e=m;m=!1;if(b.substr(a).match(/^[A-Z]/)!==null){var d=b.charAt(a);a++}else d=null,m&&h("[A-Z]");d===null&&(b.substr(a).match(/^[a-z]/)!==null?(d=b.charAt(a),a++):(d=null,m&&h("[a-z]")),d===null&&(b.substr(a).match(/^[\xC0-\xD6]/)!==null?(d=b.charAt(a),a++):(d=null,m&&h("[\\xC0-\\xD6]")),d===null&&(b.substr(a).match(/^[\xD8-\xF6]/)!==null?(d=b.charAt(a),a++):(d=null,m&&h("[\\xD8-\\xF6]")), -d===null&&(b.substr(a).match(/^[\xF8-\u02FF]/)!==null?(d=b.charAt(a),a++):(d=null,m&&h("[\\xF8-\\u02FF]")),d===null&&(b.substr(a).match(/^[\u0370-\u037D]/)!==null?(d=b.charAt(a),a++):(d=null,m&&h("[\\u0370-\\u037D]")),d===null&&(b.substr(a).match(/^[\u037F-\u1FFF]/)!==null?(d=b.charAt(a),a++):(d=null,m&&h("[\\u037F-\\u1FFF]")),d===null&&(b.substr(a).match(/^[\u200C-\u200D]/)!==null?(d=b.charAt(a),a++):(d=null,m&&h("[\\u200C-\\u200D]")),d===null&&(b.substr(a).match(/^[\u2070-\u218F]/)!==null?(d=b.charAt(a), -a++):(d=null,m&&h("[\\u2070-\\u218F]")),d===null&&(b.substr(a).match(/^[\u2C00-\u2FEF]/)!==null?(d=b.charAt(a),a++):(d=null,m&&h("[\\u2C00-\\u2FEF]")),d===null&&(b.substr(a).match(/^[\u3001-\uD7FF]/)!==null?(d=b.charAt(a),a++):(d=null,m&&h("[\\u3001-\\uD7FF]")),d===null&&(b.substr(a).match(/^[\uF900-\uFDCF]/)!==null?(d=b.charAt(a),a++):(d=null,m&&h("[\\uF900-\\uFDCF]")),d===null&&(b.substr(a).match(/^[\uFDF0-\uFFFD]/)!==null?(d=b.charAt(a),a++):(d=null,m&&h("[\\uFDF0-\\uFFFD]")),d===null&&(b.substr(a).match(/^[\u1000-\uEFFF]/)!== -null?(d=b.charAt(a),a++):(d=null,m&&h("[\\u1000-\\uEFFF]")),d=d!==null?d:null)))))))))))));(m=e)&&d===null&&h("[147] PN_CHARS_BASE");y[c]={nextPos:a,result:d};return d}function Xa(){var c="PN_CHARS_U@"+a,d=y[c];if(d)return a=d.nextPos,d.result;d=m;m=!1;var e=Kb();e===null&&(b.substr(a,1)==="_"?(e="_",a+=1):(e=null,m&&h('"_"')),e=e!==null?e:null);(m=d)&&e===null&&h("[148] PN_CHARS_U");y[c]={nextPos:a,result:e};return e}function Jb(){var c="VARNAME@"+a,d=y[c];if(d)return a=d.nextPos,d.result;d=m;m= -!1;var e=a,g=Xa();g===null&&(b.substr(a).match(/^[0-9]/)!==null?(g=b.charAt(a),a++):(g=null,m&&h("[0-9]")),g=g!==null?g:null);if(g!==null){var f=[],i=Xa();i===null&&(b.substr(a).match(/^[0-9]/)!==null?(i=b.charAt(a),a++):(i=null,m&&h("[0-9]")),i===null&&(b.substr(a).match(/^[\xB7]/)!==null?(i=b.charAt(a),a++):(i=null,m&&h("[\\xB7]")),i===null&&(b.substr(a).match(/^[\u0300-\u036F]/)!==null?(i=b.charAt(a),a++):(i=null,m&&h("[\\u0300-\\u036F]")),i===null&&(b.substr(a).match(/^[\u203F-\u2040]/)!==null? -(i=b.charAt(a),a++):(i=null,m&&h("[\\u203F-\\u2040]")),i=i!==null?i:null))));for(;i!==null;)f.push(i),i=Xa(),i===null&&(b.substr(a).match(/^[0-9]/)!==null?(i=b.charAt(a),a++):(i=null,m&&h("[0-9]")),i===null&&(b.substr(a).match(/^[\xB7]/)!==null?(i=b.charAt(a),a++):(i=null,m&&h("[\\xB7]")),i===null&&(b.substr(a).match(/^[\u0300-\u036F]/)!==null?(i=b.charAt(a),a++):(i=null,m&&h("[\\u0300-\\u036F]")),i===null&&(b.substr(a).match(/^[\u203F-\u2040]/)!==null?(i=b.charAt(a),a++):(i=null,m&&h("[\\u203F-\\u2040]")), -i=i!==null?i:null))));f!==null?g=[g,f]:(g=null,a=e)}else g=null,a=e;e=g!==null?g[0]+g[1].join(""):null;(m=d)&&e===null&&h("[149] VARNAME");y[c]={nextPos:a,result:e};return e}function qb(){var c="PN_CHARS@"+a,e=y[c];if(e)return a=e.nextPos,e.result;e=m;m=!1;var d=Xa();d===null&&(b.substr(a,1)==="-"?(d="-",a+=1):(d=null,m&&h('"-"')),d===null&&(b.substr(a).match(/^[0-9]/)!==null?(d=b.charAt(a),a++):(d=null,m&&h("[0-9]")),d===null&&(b.substr(a).match(/^[\xB7]/)!==null?(d=b.charAt(a),a++):(d=null,m&&h("[\\xB7]")), -d===null&&(b.substr(a).match(/^[\u0300-\u036F]/)!==null?(d=b.charAt(a),a++):(d=null,m&&h("[\\u0300-\\u036F]")),d===null&&(b.substr(a).match(/^[\u203F-\u2040]/)!==null?(d=b.charAt(a),a++):(d=null,m&&h("[\\u203F-\\u2040]")),d=d!==null?d:null)))));(m=e)&&d===null&&h("[150] PN_CHARS");y[c]={nextPos:a,result:d};return d}function lc(){var c="PN_PREFIX@"+a,d=y[c];if(d)return a=d.nextPos,d.result;d=m;m=!1;var e=a,g=Kb();if(g!==null){var i=[],f=qb();f===null&&(b.substr(a,1)==="."?(f=".",a+=1):(f=null,m&&h('"."')), -f=f!==null?f:null);for(;f!==null;)i.push(f),f=qb(),f===null&&(b.substr(a,1)==="."?(f=".",a+=1):(f=null,m&&h('"."')),f=f!==null?f:null);i!==null?g=[g,i]:(g=null,a=e)}else g=null,a=e;e=g!==null?function(a,b){if(b[b.length-1]==".")throw Error("Wrong PN_PREFIX, cannot finish with '.'");else return a+b.join("")}(g[0],g[1]):null;(m=d)&&e===null&&h("[151] PN_PREFIX");y[c]={nextPos:a,result:e};return e}function Ib(){var c="PN_LOCAL@"+a,d=y[c];if(d)return a=d.nextPos,d.result;d=m;m=!1;var e=a,g=Xa();g===null&& -(b.substr(a).match(/^[0-9]/)!==null?(g=b.charAt(a),a++):(g=null,m&&h("[0-9]")),g=g!==null?g:null);if(g!==null){for(var i=[],f=qb();f!==null;)i.push(f),f=qb();i!==null?g=[g,i]:(g=null,a=e)}else g=null,a=e;e=g!==null?g[0]+g[1].join(""):null;(m=d)&&e===null&&h("[152] PN_LOCAL");y[c]={nextPos:a,result:e};return e}function nc(){var c=function(a){a.sort();for(var b=null,c=[],d=0;d=0;h--){var k= +!1,k=f==null?a[h]===c:f(a[h],c)===0;if(k===!0)return!0}return!1};z.remove=function(a,c){for(var f=[],h=0;htb&&ta>tb-f?1:null):(da=z.parseISO8601(a),db=z.parseISO8601(c),ta=da.getTime(),tb=db.getTime(),f=50400,ta +tb&&ta+f>tb?1:null)};z.lexicalFormLiteral=function(a,c){var f=a.value,h=a.lang,k=a.type,j=null;if(f!=null&&k!=null&&typeof k!="string"){f=k.value;if(f==null)f=k.suffix,k=c.namespaces[k.prefix],a.type=k+f,f=k+f;j=f.indexOf("hexBinary")!=-1?'"'+a.value.toLowerCase()+'"^^<'+f+">":'"'+a.value+'"^^<'+f+">"}else j=h==null&&k==null?'"'+f+'"':k==null?'"'+f+'"@'+h:k.indexOf("hexBinary")!=-1?'"'+a.value.toLowerCase()+'"^^<'+k+">":'"'+a.value+'"^^<'+k+">";return j};z.lexicalFormBaseUri=function(a,c){var f=null; +if(a.value==null)var f=a.prefix,h=a.suffix,k=c.namespaces[f],f=k!=null?k+h:f+":"+h;else f=a.value;if(f===null)return null;else f.indexOf(":")==-1&&(f=(c.base||"")+f);return f};z.lexicalFormTerm=function(a,c){if(a.token==="uri")return{uri:z.lexicalFormBaseUri(a,c)};else if(a.token==="literal")return{literal:z.lexicalFormLiteral(a,c)};else if(a.token==="blank")return{blank:"_:"+a.value};else throw"Error, cannot get lexical form of unknown token: "+a.token;};z.normalizeUnicodeLiterals=function(a){for(var c= +a.match(/\\u[0-9abcdefABCDEF]{4,4}/g)||[],f={},h=0;hf?1:0},this.merger=null}};K.Tree.prototype._allocateNode=function(){return new K.Node};K.Tree.prototype._diskWrite=function(){};K.Tree.prototype._diskRead=function(a){return a};K.Tree.prototype._diskDelete=function(){};K.Tree.prototype._updateRootNode=function(a){return a};K.Tree.prototype.clear=function(){this.root=this._allocateNode(); +this.root.isLeaf=!0;this.root.level=0;this._updateRootNode(this.root)};K.Tree.prototype.search=function(a,c){for(var f=!0,h=this.root;f;){for(var k=0;kc+1;j--)a.children[j]=a.children[j-1];a.children[c+ +1]=h;for(j=a.numberActives;j>c;j--)a.keys[j]=a.keys[j-1];a.keys[c]=k;a.numberActives++;this._diskWrite(h);this._diskWrite(a);this._diskWrite(f)};K.Tree.prototype.insert=function(a,c){if(this.root.numberActives===2*this.order-1){var f=this._allocateNode();f.isLeaf=!1;f.level=this.root.level+1;f.numberActives=0;f.children[0]=this.root;this._splitChild(f,0,this.root);this.root=f;this._updateRootNode(this.root);this._insertNonFull(f,a,c)}else this._insertNonFull(this.root,a,c)};K.Tree.prototype._insertNonFull= +function(a,c,f){for(var h=a.numberActives-1;!a.isLeaf;){for(;h>=0&&this.comparator(c,a.keys[h].key)===-1;)h--;h++;var k=this._diskRead(a.children[h]);k.numberActives===2*this.order-1&&(this._splitChild(a,h,k),this.comparator(c,a.keys[h].key)===1&&h++);a=this._diskRead(a.children[h]);h=a.numberActives-1}for(;h>=0&&this.comparator(c,a.keys[h].key)===-1;)a.keys[h+1]=a.keys[h],h--;a.keys[h+1]={key:c,data:f};a.numberActives++;this._diskWrite(a)};K.Tree.prototype["delete"]=function(a){for(var c=this.root, +f=null,h=!0,k=null,j=null,i=null,g=!0;g===!0;){for(g=!1;h===!0;){s=0;if(c.numberActives===0)return!1;for(;sthis.order-1?this._moveKey(f,s,-1):j!=null&&j.numberActives>this.order-1?this._moveKey(f,s,1):j!=null&&j.numberActives===this.order-1?c=this._mergeSiblings(f,s,-1):i!=null&&i.numberActives===this.order-1&&(c=this._mergeSiblings(f,s,1)))}}if(c.isLeaf&&c.numberActives>this.order-1)return this._deleteKeyFromNode(c,k),!0;if(c.isLeaf&&c===this.root)return this._deleteKeyFromNode(c,k),!0;if(c.isLeaf===!1)if(f=s=null,(s=this._diskRead(c.children[k])).numberActives> +this.order-1)a=this._getMaxKeyPos(s),a=a.node.keys[a.index],c.keys[k]=a,this._diskWrite(c),c=s,a=a.key,h=g=!0;else if((s=this._diskRead(c.children[k+1])).numberActives>this.order-1)a=this._getMinKeyPos(s),a=a.node.keys[a.index],c.keys[k]=a,this._diskWrite(c),c=s,a=a.key,h=g=!0;else if((s=this._diskRead(c.children[k])).numberActives===this.order-1&&(f=this._diskRead(c.children[k+1])).numberActives===this.order-1){h=this._mergeNodes(s,c.keys[k],f);c.children[k]=h;k++;for(var s=k;sthis.order-1&&h===!1&&this._deleteKeyFromNode(c,k);if(g===!1)return!0}};K.Tree.prototype._moveKey=function(a,c,f){f===1&&c--;var h=this._diskRead(a.children[c]),k=this._diskRead(a.children[c+1]);if(f==-1){h.keys[h.numberActives]=a.keys[c];h.children[h.numberActives+1]=k.children[0];k.children[0]=null;h.numberActives++; +a.keys[c]=k.keys[0];for(f=1;f0;f--)k.children[f]=k.children[f-1],k.keys[f]=k.keys[f-1];k.keys[0]=null;k.children[0]=null;k.children[0]=h.children[h.numberActives];k.keys[0]=a.keys[c];k.numberActives++;h.children[h.numberActives]=null;a.keys[c]=h.keys[h.numberActives- +1];h.keys[h.numberActives-1]=null;h.numberActives--}this._diskWrite(h);this._diskWrite(k);this._diskWrite(a)};K.Tree.prototype._mergeSiblings=function(a,c){var f,h,k;c===a.numberActives?(c--,h=this._diskRead(a.children[a.numberActives-1]),k=this._diskRead(a.children[a.numberActives])):(h=this._diskRead(a.children[c]),k=this._diskRead(a.children[c+1]));var j=this._allocateNode();j.isLeaf=h.isLeaf;j.level=h.level;for(f=0;f key "+i.keys[g].key;a===!0&&console.log(u);c.push(u)}h.comparator(i.keys[g].key,v)=== +1&&(u=" !!! value min right "+v+" < key "+i.keys[g].key,a===!0&&console.log(u),c.push(u));k(i.keys[g].key);f.push(i.keys[g].key)}else{j===null?j=i.level:j!=i.level&&(u=" !!! Leaf node with wrong level value",a===!0&&console.log(u),c.push(u));for(g=0;g2*h.order-1&&(a===!0&&(u=" !!!! MAX num keys restriction violated "),console.log(u),c.push(u)),i.numberActivesa[f])return 1}return 0};T.Pattern=function(a){this.subject=a.subject;this.predicate=a.predicate;this.object= +a.object;this.graph=a.graph;this.indexKey=[];this.keyComponents={};for(var c=[],f=[],a=["subject","predicate","object","graph"],h=0;hj)return 1}return 0},this.rangeComparator=function(a,c){for(var k=0;kc[j])return 1}return 0},c!=null&&c(this)}};z["extends"](K.Tree,Y.Tree);Y.Tree.prototype.insert=function(a,c){K.Tree.prototype.insert.call(this,a,null);c&& +c(!0);return!0};Y.Tree.prototype.search=function(a,c){var f=K.Tree.prototype.search.call(this,a,!0);c&&c(f);return f};Y.Tree.prototype.range=function(a,c){var f=null,f=typeof this.root==="string"?this._rangeTraverse(this,this._diskRead(this.root),a):this._rangeTraverse(this,this.root,a);c&&c(f);return f};Y.Tree.prototype._rangeTraverse=function(a,c,f){for(var f=f.key,h=[],k=[c],j;k.length>0;){c=k.shift();for(j=0;j")return f=a.substring(1,c-1),a=a.substring(c+3,a.length-1),{token:"literal",value:f,type:a};f=a.substring(1,a.length-1);return{token:"literal",value:f}};H.Lexicon.prototype.parseUri=function(a){return{token:"uri",value:a}};H.Lexicon.prototype.retrieve=function(a){try{if(a===this.defaultGraphOid)return{token:"uri",value:this.defaultGraphUri,prefix:null,suffix:null,defaultGraph:!0};else{var c=this.OIDToUri["u"+ +a];if(c!=null)return this.parseUri(c);else{var f=this.OIDToLiteral["l"+a];if(f!=null)return this.parseLiteral(f);else if(this.OIDToBlank[""+a]!=null)return{token:"blank",value:"_:"+a};else throw"Null value for OID";}}}catch(h){throw console.log("error in lexicon retrieving OID:"),console.log(a),h.message||h.stack?(h.message&&console.log(h.message),h.stack&&console.log(h.stack)):console.log(h),Error("Unknown retrieving OID in lexicon:"+a);}};H.Lexicon.prototype.clear=function(){this.uriToOID={};this.OIDToUri= +{};this.literalToOID={};this.OIDToLiteral={};this.blankToOID={};this.OIDToBlank={}};H.Lexicon.prototype.unregister=function(a,c){try{return this.unregisterTerm(a.subject.token,c.subject),this.unregisterTerm(a.predicate.token,c.predicate),this.unregisterTerm(a.object.token,c.object),a.graph!=null&&this.unregisterTerm(a.graph.token,c.graph),!0}catch(f){return console.log("Error unregistering quad"),console.log(f.message),!1}};H.Lexicon.prototype.unregisterTerm=function(a,c){if(a==="uri"){if(c!=this.defaultGraphOid){var f= +"u"+c,h=this.OIDToUri[f],k=this.uriToOID[h],j=k[1];if(""+k[0]===""+c)j===0?(delete this.OIDToUri[f],delete this.uriToOID[h],delete this.knownGraphs[c]):this.uriToOID[h]=[c,j-1];else throw"Not matching OID : "+c+" vs "+k[0];}}else if(a==="literal")if(this.oidCounter++,f="l"+c,h=this.OIDToLiteral[f],k=this.literalToOID[h],j=k[1],""+k[0]===""+c)j===0?(delete this.OIDToLiteral[f],delete this.literalToOID[h]):this.literalToOID[h]=[c,j-1];else throw"Not matching OID : "+c+" vs "+k[0];else a==="blank"&& +delete this.OIDToBlank[""+c]};var P={};P.load=function(a,c,f){jQuery.ajax({url:a,headers:{Accept:c},success:function(a,c,j){if((""+j.status)[0]=="2"){for(var c=j.getAllResponseHeaders().split("\n"),j={},i=0;i>> +0;if(typeof a!="function")throw new TypeError;for(var h=[],i=0;i0&&h[0]!=="@"&&c===s(a,h)){f=h;j!==null&&(j[h]=i(a[h]));break}f===null&&c==="@type"&&(f=g(a)["@type"]);if(f===null)for(h in a)if(h.length>0&&h[0]!=="@"){var k=s(a,h);if(k!==null&&c.indexOf(k)===0&&c.length>k.length){f=h+":"+c.substr(k.length);j!==null&&(j[h]=i(a[h]));break}}f===null&&(f=c);return f},u=function(a,c,j){var f=c,h=g(a),k=c.indexOf(":"); +if(k!==-1)h=c.substr(0,k),h in a&&(f=s(a,h)+c.substr(k+1),j!==null&&(j[h]=i(a[h])));else if(c in a)f=s(a,c),j!==null&&(j[c]=i(a[c]));else for(var v in h)if(c===h[v]){f=v;break}return f},x=function(a){var c=!1;a!==null&&a.constructor===Object&&!("@literal"in a)&&(c=Object.keys(a).length>1||!("@id"in a));return c};c.normalize=function(a){return(new F).normalize(a)};c.expand=function(a){return(new F).expand({},null,a)};c.compact=function(a,j){var f=null;if(j!==null){var j=c.expand(j),h;j.constructor=== +Array?(f=[],h=j):h=[j];a.constructor===Array&&(a=c.mergeContexts({},a));for(var k in h){var g={},m=(new F).compact(i(a),null,h[k],g);if(Object.keys(g).length>0){var s=g,g={},v=Object.keys(s).sort(),u=void 0;for(u in v){var x=v[u];g[x]=s[x]}s=Object.keys(m);s.sort();s.unshift("@context");m["@context"]=g;var g={},z;for(z in s)v=s[z],g[v]=m[v];m=g}f===null?f=m:f.push(m)}}return f};c.mergeContexts=function(a,j){a.constructor===Array&&(a=c.mergeContexts({},a));var f=i(a);if(j.constructor===Array)for(var h in j)f= +c.mergeContexts(f,j[h]);else{for(var k in j)if(k.indexOf("@")!==0)for(var g in f)if(f[g]===j[k]){delete f[g];break}for(k in j)f[k]=i(j[k])}return f};c.expandTerm=u;c.compactIri=function(a,c){return v(a,c,null)};c.frame=function(a,c,j){return(new F).frame(a,c,j)};c.toTriples=function(a,j,f){var h=null,a=c.normalize(a),f=f||null;f===null&&(h=[],f=function(a,c,f){h.push({subject:z.lexicalFormTerm(a),predicate:z.lexicalFormTerm(c),object:z.lexicalFormTerm(f),graph:j})});var i=!1,k;for(k in a){var g=a[k], +m=g["@id"],m=m[0]=="_"?{token:"blank",value:m.split(":")[1]}:{token:"uri",value:m},s;for(s in g)if(s!=="@id"){var v=g[s];v.constructor!==Array&&(v=[v]);for(var u in v)if(i=v[u],s==="@type"?(s="http://www.w3.org/1999/02/22-rdf-syntax-ns#type",i={token:"uri",value:i}):typeof i==="string"?i={token:"literal",value:i}:i["@id"]!=null?i=i["@id"][0]=="_"?{token:"blank",value:i["@id"].split(":")[1]}:{token:"uri",value:i["@id"]}:i["@type"]!=null?i={token:"literal",value:i["@literal"],type:i["@type"]}:i["@language"]!= +null&&(i={token:"literal",value:i["@literal"],lang:i["@language"]}),i=f(m,{token:"uri",value:s},i)===!1)break;if(i)break}if(i)break}return h};c.resolve=function(a,c,j){var f={},h=function(a,c){if(a.constructor===Array)for(var j in a)h(a[j]);else if(a.constructor===Object)for(var i in a)if(i==="@context")if(a[i].constructor===Array){var k=a[i];for(j in k)k[j].constructor===String&&(c?k[j]=f[k[j]]:f[k[j]]={})}else a[i].constructor===String&&(c?a[i]=f[a[i]]:f[a[i]]={})};h(a,!1);var i=Object.keys(f).length, +k=null;if(i===0)j(a,k);else for(var g in f)c(g,function(c,m){--i;if(c===null)k=k||[],k.push({url:g,error:m});else try{f[g]=c.constructor===String?JSON.parse(c)["@context"]:c["@context"]}catch(s){k=k||[],k.push({url:g,error:s})}i===0&&(k===null&&h(a,!0),j(a,k))})};var F=function(){};F.prototype.compact=function(a,c,j,f){var h,s=g(a);if(j===null)h=null,this.getCoerceType(a,c,f);else if(j.constructor===Array){h=[];for(var u in j)h.push(this.compact(a,c,j[u],f))}else if(j.constructor===Object&&"@id"in +j&&j["@id"].constructor===Array)h={},h[s["@id"]]=this.compact(a,c,j["@id"],f);else if(x(j)){h={};for(var z in j)if(j[z]!=="@context"&&(s=v(a,z,f),s!==z||!(s in h)))h[s]=this.compact(a,z,j[z],f)}else{c=this.getCoerceType(a,c,f);u=null;j.constructor===Object?"@language"in j||(u="@type"in j?j["@type"]:"@id"in j?"@id":c):j.constructor===String&&(u=c);if(c===null&&(u===k["boolean"]||u===k.integer||u===k["double"]))c=u;if(c!==null)if(u===null)throw{message:"Cannot coerce type when a language is specified. The language information would be lost."}; +else if(u!==c)throw new Exception({message:"Cannot coerce type because the type does not match.",type:u,expected:c});else j.constructor===Object?"@id"in j?h=j["@id"]:"@literal"in j&&(h=j["@literal"]):h=j,c===k["boolean"]?h=h==="true"||h!=0:c===k["double"]?h=parseFloat(h):c===k.integer&&(h=parseInt(h));else if(j.constructor===Object)for(z in h={},j)h[s[z]]=j[z];else h=i(j);u==="@id"&&(h.constructor===Object?h[s["@id"]]=v(a,h[s["@id"]],f):h=v(a,h,f))}return h};F.prototype.expand=function(a,f,h){var s; +if(h===null)s=null;else if(f===null&&h.constructor===String)s=u(a,h,null);else if(h.constructor===Array){s=[];for(var v in h)s.push(this.expand(a,f,h[v]))}else if(h.constructor===Object){"@context"in h&&(a=c.mergeContexts(a,h["@context"]));s={};for(var x in h)x==="@embed"||x==="@explicit"||x==="@default"||x==="@omitDefault"?j(s,x,i(h[x])):x!=="@context"&&j(s,u(a,x,null),this.expand(a,x,h[x]))}else{v=this.getCoerceType(a,f,null);s=g(a);if(v===null&&(h.constructor===Number||h.constructor===Boolean))v= +h.constructor===Boolean?k["boolean"]:(""+h).indexOf(".")==-1?k.integer:k["double"];f===s["@id"]||f===s["@type"]?s=u(a,h,null):v!==null?(s={},v==="@id"?s["@id"]=u(a,h,null):(s["@type"]=v,v===k["double"]&&(h=h.toExponential(6).replace(/(e(?:\+|-))([0-9])$/,"$10$2")),s["@literal"]=""+h)):s=""+h}return s};F.prototype.normalize=function(a){var c=[];if(a!==null){this.ng={tmp:null,c14n:null};var j=this.expand(f,null,a);this.nameBlankNodes(j);a={};J(null,null,j,a);for(var h in a){var j=a[h],i={},k=Object.keys(j).sort(), +g;for(g in k){var m=k[g];i[m]=j[m]}c.push(i)}this.canonicalizeBlankNodes(c);c.sort(function(a,c){return N(a["@id"],c["@id"])})}return c};F.prototype.getCoerceType=function(a,c,j){var f=null,c=u(a,c,null);c==="@id"||c==="@type"?f="@id":(c=v(a,c,null),c in a&&a[c].constructor===Object&&"@type"in a[c]&&(f=u(a,a[c]["@type"],j),j!==null&&(j[c]=i(a[c]))));return f};var B=function(a){return a.indexOf("_:")===0},E=function(a){return a.constructor===Object&&"@id"in a&&B(a["@id"])},N=function(a,c){var j=0; +if(a.constructor===Array&&c.constructor===Array)for(var f=0;fc?1:0;return j},D=function(a,c,j){var f=0;j in a?f=j in c?N(a[j],c[j]):-1:j in c&&(f=1);return f},G=function(a,c){var j=0;a.constructor===String?j=c.constructor!==String?-1:N(a,c):c.constructor===String?j=1:(j=D(a,c,"@literal"),j===0&&("@literal"in a?(j=D(a,c,"@type"),j===0&&(j=D(a,c,"@language"))):j=N(a["@id"],c["@id"])));return j},C=function(a,c){var j=0,f;for(f in a)if(f!=="@id"){j= +N(a[f].constructor===Array?a[f].length:1,c[f].constructor===Array?c[f].length:1);if(j===0){var h=a[f],i=c[f];h.constructor!==Array&&(h=[h],i=[i]);h=h.filter(function(a){return!E(a)});i=i.filter(function(a){return!E(a)});j=N(h.length,i.length)}if(j===0){h.sort(G);i.sort(G);for(var k=0;k0),c||a.push(h)):a[c]=h)};F.prototype.nameBlankNodes= +function(a){var c=this.ng.tmp=K("tmp"),j={},f=[];L(a,j,f);for(var h in f)if(a=f[h],!("@id"in a)){for(;c.next()in j;);a["@id"]=c.current();j[c.current()]=a}};F.prototype.renameBlankNode=function(a,c){var j=a["@id"];a["@id"]=c;var f=this.subjects;f[c]=f[j];delete f[j];this.edges.refs[c]=this.edges.refs[j];this.edges.props[c]=this.edges.props[j];delete this.edges.refs[j];delete this.edges.props[j];var h=this.edges.refs[c].all,i;for(i in h){var k=h[i].s;k===j&&(k=c);var g=f[k],m=this.edges.props[k].all, +s;for(s in m)if(m[s].s===j){m[s].s=c;var k=m[s].p,k=g[k].constructor===Object?[g[k]]:g[k].constructor===Array?g[k]:[],v;for(v in k)k[v].constructor===Object&&"@id"in k[v]&&k[v]["@id"]===j&&(k[v]["@id"]=c)}}m=this.edges.props[c].all;for(i in m){var k=m[i].s,h=this.edges.refs[k].all,u;for(u in h)if(h[u].s===j)h[u].s=c}};F.prototype.canonicalizeBlankNodes=function(a){this.renamed={};this.mappings={};this.serializations={};var c=this.edges={refs:{},props:{}},j=this.subjects={},f=[],h;for(h in a){var i= +a[h]["@id"];j[i]=a[h];c.refs[i]={all:[],bnodes:[]};c.props[i]={all:[],bnodes:[]};B(i)&&f.push(a[h])}this.collectEdges();var a=this.ng.c14n=K("c14n"),k=this.ng.tmp;for(h in f){var g=f[h],i=g["@id"];if(a.inNamespace(i)){for(;k.next()in j;);this.renameBlankNode(g,k.current());i=g["@id"]}this.serializations[i]={props:null,refs:null}}for(var k=!0,m=this;f.length>0;){k&&(k=!1,f.sort(function(a,c){return m.deepCompareBlankNodes(a,c)}));var g=f.shift(),i=g["@id"],g=["props","refs"],s;for(s in g){var v=g[s]; +if(this.serializations[i][v]===null){var u={};u[i]="s1"}else u=this.serializations[i][v].m;var x=Object.keys(u);x.sort(function(a,c){return N(u[a],u[c])});var z=[];for(h in x){var F=x[h];!a.inNamespace(i)&&F in j&&(this.renameBlankNode(j[F],a.next()),z.push(F))}x=f;f=[];for(h in x){var F=x[h],O=F["@id"];if(!a.inNamespace(O)){for(var E in z)this.markSerializationDirty(O,z[E],v)&&(k=!0);f.push(F)}}}}for(var D in c.props)if(c.props[D].bnodes.length>0){var g=j[D],C;for(C in g)C.indexOf("@")!==0&&g[C].constructor=== +Array&&g[C].sort(G)}};MappingBuilder=function(){this.count=1;this.processed={};this.mapping={};this.adj={};this.keyStack=[{keys:["s1"],idx:0}];this.done={};this.s=""};MappingBuilder.prototype.copy=function(){var a=new MappingBuilder;a.count=this.count;a.processed=i(this.processed);a.mapping=i(this.mapping);a.adj=i(this.adj);a.keyStack=i(this.keyStack);a.done=i(this.done);a.s=this.s;return a};MappingBuilder.prototype.mapNode=function(a){a in this.mapping||(this.mapping[a]=a.indexOf("_:c14n")===0?"c"+ +a.substr(6):"s"+this.count++);return this.mapping[a]};MappingBuilder.prototype.serialize=function(a,c){if(this.keyStack.length>0)for(var j=this.keyStack.pop();j.idx";var v=k[s].constructor===Array?k[s]:[k[s]],u;for(u in v){var x=v[u];x.constructor=== +Object?"@id"in x?g+=B(x["@id"])?"_:":"<"+x["@id"]+">":(g+='"'+x["@literal"]+'"',"@type"in x?g+="^^<"+x["@type"]+">":"@language"in x&&(g+="@"+x["@language"])):g+='"'+x+'"'}}h+="["+g+"]";k=!0;h+="[";var i=c.refs[i].all,z;for(z in i)k?k=!1:h+="|",h+="<"+i[z].p+">",h+=B(i[z].s)?"_:":"<"+i[z].s+">";h+="]"}h+=f.k.join("");this.s+=h;this.keyStack.push({keys:f.k,idx:0});this.serialize(a,c)}}};F.prototype.markSerializationDirty=function(a,c,j){var f=!1,a=this.serializations[a];a[j]!==null&&c in a[j].m&&(a[j]= +null,f=!0);return f};var H=function(a,c){var j=0;return j=a.length==c.length?N(a,c):a.length>c.length?N(a.substr(0,c.length),c):N(a,c.substr(0,a.length))};F.prototype.serializeCombos=function(a,c,j,f,h,k,g){if(g.length>0){k=i(k);k[f.mapNode(g[0].s)]=g[0].s;for(var m=f.copy(),g=g.slice(1),s=Math.max(1,g.length),v=0;v=a[h].s.length)a[h]={s:f.s,m:f.mapping}}};F.prototype.serializeBlankNode=function(a,c,j,f){if(!(c in j.processed)){j.processed[c]=!0;var h=j.mapNode(c),i=j.copy(),k=this.edges[f][c].bnodes,g={},m=[],s;for(s in k)k[s].s in j.mapping?g[j.mapping[k[s].s]]=k[s].s:m.push(k[s]);k=Math.max(1,m.length);for(s=0;s0?k[0]:{}),k["@omitDefault"]===!0||g.defaults.omitDefaultOn||(c[z]="@default"in k?k["@default"]:null))}else c={"@id":c["@id"]};return c},aa=function(a,c,j,f,h,k,i,g){var m=null,s=-1,v;j.constructor===Array?(m=[],v=j,v.length===0&&v.push({})):(v=[j],s=1);for(var u=[],z=0;z0&&"@context"in j[0]&&(h=i(j[0]["@context"]));var f=[],k;for(k in j)f.push(c.expand(j[k]));j=f}var f={defaults:{embedOn:!0,explicitOn:!1,omitDefaultOn:!1}},g={};for(k in a)g[a[k]["@id"]]=a[k];a=aa(g,a,j,{},!1,null,null,f);h!==null&&a!==null&&(a=c.compact(h,a));return a}})();var xa={parser:{}};xa.parser.parse=function(a, +c){typeof a==="string"&&(a=JSON.parse(a));return va.toTriples(a,c)};var Z={RDFLoader:function(a){this.precedences=["text/turtle","text/n3","application/json"];this.parsers={"text/turtle":ba.parser,"text/n3":ba.parser,"application/json":xa.parser};if(a!=null)for(var c in a.parsers)this.parsers[c]=a.parsers[c];if(a&&a.precedences!=null)for(c in this.precedences=a.precedences,a.parsers)z.include(this.precedences,c)||this.precedences.push(c);this.acceptHeaderValue="";for(a=0;a0?{kind:"JOIN",lvalue:{kind:"BGP",value:h},rvalue:i}: +i;if(i.kind==="ZERO_OR_MORE_PATH")if(i.y.token==="var"&&i.y.value.indexOf("fresh:")===0&&i.x.token==="var"&&i.x.value.indexOf("fresh:")===0)for(var g=0;g0?(i=J.translatePathExpressionsInBGP({kind:"BGP",value:k},c),f!=null?(h=h.concat([f]).concat(k),{kind:"UNION",value:[{kind:"JOIN",lvalue:j,rvalue:i},{kind:"BGP",value:h}]}):{kind:"JOIN",lvalue:j,rvalue:i}):j}else return i}else h.push(a.value[j]);a.value=h;return a};J.translatePathExpression=function(a,c){if(a.predicate.kind==="element")if(a.predicate.modifier==="+"){a.predicate.modifier=null;var f=J.translatePathExpression(a,c);return{kind:"ONE_OR_MORE_PATH",path:f,x:a.subject, +y:a.object}}else return a.predicate.modifier==="*"?(a.predicate.modifier=null,f=J.translatePathExpression(a,c),{kind:"ZERO_OR_MORE_PATH",path:f,x:a.subject,y:a.object}):(a.predicate=a.predicate.value,{kind:"BGP",value:[a]});else if(a.predicate.kind==="sequence"){for(var f=a.subject,h=a.object,k=a.graph,j,i,g=[],s=0;sya&&(ya=b,$a=[]),$a.push(a))}function i(){var a="SPARQL@"+b,c=y[a];if(c)return b=c.nextPos,c.result;c=g();c===null&&(c=Ya(),c=c!==null?c:null);y[a]={nextPos:b,result:c};return c}function g(){var a="Query@"+b,c=y[a];if(c)return b=c.nextPos,c.result;c=n;n=!1;var f=b,d=b,e=s();if(e!==null){var h=D();h===null&&(h=K(),h===null&& +(h=L(),h===null&&(h=J(),h=h!==null?h:null)));h!==null?e=[e,h]:(e=null,b=d)}else e=null,b=d;d=e!==null?{token:"query",kind:"query",prologue:e[0],units:[e[1]]}:null;d===null&&(d=null,b=f);(n=c)&&d===null&&j("[2] Query");y[a]={nextPos:b,result:d};return d}function s(){var a="Prologue@"+b,c=y[a];if(c)return b=c.nextPos,c.result;c=n;n=!1;var f=b,d=b,e=v(),e=e!==null?e:"";if(e!==null){for(var h=[],r=q();r!==null;)h.push(r),r=q();if(h!==null){for(var r=[],w=u();w!==null;)r.push(w),w=u();r!==null?e=[e,h, +r]:(e=null,b=d)}else e=null,b=d}else e=null,b=d;d=e!==null?{token:"prologue",base:e[0],prefixes:e[2]}:null;d===null&&(d=null,b=f);(n=c)&&d===null&&j("[3] Prologue");y[a]={nextPos:b,result:d};return d}function v(){var f="BaseDecl@"+b,h=y[f];if(h)return b=h.nextPos,h.result;h=n;n=!1;for(var I=b,d=b,e=[],A=q();A!==null;)e.push(A),A=q();if(e!==null)if(a.substr(b,4)==="BASE"?(A="BASE",b+=4):(A=null,n&&j('"BASE"')),A===null&&(a.substr(b,4)==="base"?(A="base",b+=4):(A=null,n&&j('"base"')),A=A!==null?A:null), +A!==null){for(var r=[],w=q();w!==null;)r.push(w),w=q();r!==null?(w=na(),w!==null?e=[e,A,r,w]:(e=null,b=d)):(e=null,b=d)}else e=null,b=d;else e=null,b=d;d=e!==null?function(a){base={token:"base"};base.value=a;return base}(e[3]):null;d===null&&(d=null,b=I);(n=h)&&d===null&&j("[4] BaseDecl");y[f]={nextPos:b,result:d};return d}function u(){var f="PrefixDecl@"+b,h=y[f];if(h)return b=h.nextPos,h.result;h=n;n=!1;for(var I=b,d=b,e=[],A=q();A!==null;)e.push(A),A=q();if(e!==null)if(a.substr(b,6)==="PREFIX"? +(A="PREFIX",b+=6):(A=null,n&&j('"PREFIX"')),A===null&&(a.substr(b,6)==="prefix"?(A="prefix",b+=6):(A=null,n&&j('"prefix"')),A=A!==null?A:null),A!==null){for(var r=[],w=q();w!==null;)r.push(w),w=q();if(r!==null)if(w=Ea(),w!==null){for(var o=[],k=q();k!==null;)o.push(k),k=q();o!==null?(k=na(),k!==null?e=[e,A,r,w,o,k]:(e=null,b=d)):(e=null,b=d)}else e=null,b=d;else e=null,b=d}else e=null,b=d;else e=null,b=d;d=e!==null?function(a,b){prefix={token:"prefix"};prefix.prefix=a;prefix.local=b;return prefix}(e[3], +e[5]):null;d===null&&(d=null,b=I);(n=h)&&d===null&&j("[5] PrefixDecl");y[f]={nextPos:b,result:d};return d}function x(){var a="TURTLE@"+b,c=y[a];if(c)return b=c.nextPos,c.result;for(var c=b,j=[],d=z();d!==null;)j.push(d),d=z();j=j!==null?j:null;j===null&&(j=null,b=c);y[a]={nextPos:b,result:j};return j}function z(){var f="statement@"+b,h=y[f];if(h)return b=h.nextPos,h.result;for(var I=h=b,d=[],e=q();e!==null;)d.push(e),e=q();if(d!==null)if(e=B(),e!==null){for(var A=[],r=q();r!==null;)A.push(r),r=q(); +if(A!==null)if(a.substr(b,1)==="."?(r=".",b+=1):(r=null,n&&j('"."')),r!==null){for(var w=[],o=q();o!==null;)w.push(o),o=q();w!==null?d=[d,e,A,r,w]:(d=null,b=I)}else d=null,b=I;else d=null,b=I}else d=null,b=I;else d=null,b=I;I=d!==null?d[1]:null;I===null&&(I=null,b=h);if(I!==null)h=I;else{I=h=b;d=[];for(e=q();e!==null;)d.push(e),e=q();if(d!==null)if(e=oa(),e!==null){A=[];for(r=q();r!==null;)A.push(r),r=q();A!==null?d=[d,e,A]:(d=null,b=I)}else d=null,b=I;else d=null,b=I;I=d!==null?d[1]:null;I===null&& +(I=null,b=h);if(I!==null)h=I;else{h=q();if(h!==null)for(I=[];h!==null;)I.push(h),h=q();else I=null;h=I!==null?I:null}}y[f]={nextPos:b,result:h};return h}function B(){var a="directive@"+b,c=y[a];if(c)return b=c.nextPos,c.result;c=N();c===null&&(c=E(),c=c!==null?c:null);y[a]={nextPos:b,result:c};return c}function E(){var f="base@"+b,h=y[f];if(h)return b=h.nextPos,h.result;for(var I=h=b,d=[],e=q();e!==null;)d.push(e),e=q();if(d!==null)if(a.substr(b,5)==="@base"?(e="@base",b+=5):(e=null,n&&j('"@base"')), +e!==null){var A=q();if(A!==null)for(var r=[];A!==null;)r.push(A),A=q();else r=null;r!==null?(A=na(),A!==null?d=[d,e,r,A]:(d=null,b=I)):(d=null,b=I)}else d=null,b=I;else d=null,b=I;I=d!==null?function(a){base={token:"base"};base.value=a;return base}(d[3]):null;I===null&&(I=null,b=h);y[f]={nextPos:b,result:I};return I}function N(){var f="prefixID@"+b,h=y[f];if(h)return b=h.nextPos,h.result;for(var I=h=b,d=[],e=q();e!==null;)d.push(e),e=q();if(d!==null)if(a.substr(b,7)==="@prefix"?(e="@prefix",b+=7): +(e=null,n&&j('"@prefix"')),e!==null){var A=q();if(A!==null)for(var r=[];A!==null;)r.push(A),A=q();else r=null;if(r!==null)if(A=ab(),A=A!==null?A:"",A!==null){if(a.substr(b,1)===":"){var w=":";b+=1}else w=null,n&&j('":"');if(w!==null){for(var o=[],k=q();k!==null;)o.push(k),k=q();o!==null?(k=na(),k!==null?d=[d,e,r,A,w,o,k]:(d=null,b=I)):(d=null,b=I)}else d=null,b=I}else d=null,b=I;else d=null,b=I}else d=null,b=I;else d=null,b=I;I=d!==null?function(a,b){prefix={token:"prefix"};prefix.prefix=a;prefix.local= +b;return prefix}(d[3],d[6]):null;I===null&&(I=null,b=h);y[f]={nextPos:b,result:I};return I}function D(){var a="SelectQuery@"+b,c=y[a];if(c)return b=c.nextPos,c.result;c=n;n=!1;var f=b,d=b,e=G();if(e!==null){for(var h=[],r=q();r!==null;)h.push(r),r=q();if(h!==null){for(var r=[],w=H();w!==null;)r.push(w),w=H();if(r!==null){for(var w=[],o=q();o!==null;)w.push(o),o=q();if(w!==null)if(o=aa(),o!==null){for(var k=[],i=q();i!==null;)k.push(i),i=q();if(k!==null)if(i=V(),i!==null){for(var g=[],m=q();m!==null;)g.push(m), +m=q();g!==null?(m=xa(),m!==null?e=[e,h,r,w,o,k,i,g,m]:(e=null,b=d)):(e=null,b=d)}else e=null,b=d;else e=null,b=d}else e=null,b=d;else e=null,b=d}else e=null,b=d}else e=null,b=d}else e=null,b=d;d=e!==null?function(a,b,e,d){for(var c={named:[],"default":[]},j=0;j0&&b[0].length>0&&(e=e.concat(b[0][0].quadsContext),b[0][2]!=null&&b[0][2].triplesContext!=null))for(d=0;d0&&f.push({token:"basicgraphpattern",triplesContext:r});j=[]}f.push(e[d])}else e[d].token==="triplespattern"?j.push(e[d]):h.push(e[d]);if(j.length!=0||h.length!=0){r=[];for(c=0;c0&&f.push({token:"basicgraphpattern",triplesContext:r})}return{token:"groupgraphpattern",patterns:f,filters:h}}(e[0],e[2]):null;d===null&&(d=null,b=i);(n=h)&&d===null&&j("[51] GroupGraphPatternSub");y[f]={nextPos:b,result:d};return d}function oa(){var f="TriplesBlock@"+b,h=y[f];if(h)return b=h.nextPos,h.result;h=n;n=!1;var i=b,d=b,e=Ib();if(e!==null){for(var k=b,r=[],w=q();w!==null;)r.push(w),w=q();if(r!==null)if(a.substr(b,1)==="."?(w=".",b+=1):(w=null,n&&j('"."')),w!==null){var o=oa(), +o=o!==null?o:"";o!==null?r=[r,w,o]:(r=null,b=k)}else r=null,b=k;else r=null,b=k;k=r!==null?r:"";k!==null?e=[e,k]:(e=null,b=d)}else e=null,b=d;d=e!==null?function(a,b){var e=a.triplesContext;typeof b==="object"&&b.length!=null&&b[2].triplesContext!=null&&(e=e.concat(b[2].triplesContext));return{token:"triplespattern",triplesContext:e}}(e[0],e[1]):null;d===null&&(d=null,b=i);(n=h)&&d===null&&j("[54] TriplesBlock");y[f]={nextPos:b,result:d};return d}function kb(){var a="GraphPatternNotTriples@"+b,c= +y[a];if(c)return b=c.nextPos,c.result;c=n;n=!1;var f=Jb();f===null&&(f=Kb(),f===null&&(f=Lb(),f===null&&(f=Mb(),f===null&&(f=Nb(),f===null&&(f=Ob(),f=f!==null?f:null)))));(n=c)&&f===null&&j("[53] GraphPatternNotTriples");y[a]={nextPos:b,result:f};return f}function Kb(){var f="OptionalGraphPattern@"+b,h=y[f];if(h)return b=h.nextPos,h.result;h=n;n=!1;for(var k=b,d=b,e=[],i=q();i!==null;)e.push(i),i=q();if(e!==null)if(a.substr(b,8)==="OPTIONAL"?(i="OPTIONAL",b+=8):(i=null,n&&j('"OPTIONAL"')),i!==null){for(var r= +[],w=q();w!==null;)r.push(w),w=q();r!==null?(w=W(),w!==null?e=[e,i,r,w]:(e=null,b=d)):(e=null,b=d)}else e=null,b=d;else e=null,b=d;d=e!==null?{token:"optionalgraphpattern",value:e[3]}:null;d===null&&(d=null,b=k);(n=h)&&d===null&&j("[54] OptionalGraphPattern");y[f]={nextPos:b,result:d};return d}function Mb(){var f="GraphGraphPattern@"+b,h=y[f];if(h)return b=h.nextPos,h.result;h=n;n=!1;for(var i=b,d=b,e=[],k=q();k!==null;)e.push(k),k=q();if(e!==null)if(a.substr(b,5)==="GRAPH"?(k="GRAPH",b+=5):(k=null, +n&&j('"GRAPH"')),k===null&&(a.substr(b,5)==="graph"?(k="graph",b+=5):(k=null,n&&j('"graph"')),k=k!==null?k:null),k!==null){for(var r=[],w=q();w!==null;)r.push(w),w=q();if(r!==null)if(w=ka(),w!==null){for(var o=[],g=q();g!==null;)o.push(g),g=q();o!==null?(g=W(),g!==null?e=[e,k,r,w,o,g]:(e=null,b=d)):(e=null,b=d)}else e=null,b=d;else e=null,b=d}else e=null,b=d;else e=null,b=d;d=e!==null?function(a,b){for(var e=0;e"?(o=">",b+=1):(o=null,n&&j('">"')),o!==null){m=[];for(t=q();t!==null;)m.push(t),t=q();m!==null?(t=U(),t!==null?g=[g,o,m,t]:(g=null,b=r)):(g=null,b=r)}else g=null,b=r;else g=null,b=r;if(g!==null)r=g;else{r=b;g=[];for(o=q();o!==null;)g.push(o),o=q();if(g!==null)if(a.substr(b,2)==="<="?(o="<=",b+=2):(o=null,n&&j('"<="')),o!==null){m=[];for(t=q();t!==null;)m.push(t),t=q();m!==null?(t=U(),t!==null?g=[g,o,m,t]:(g=null,b=r)):(g=null,b=r)}else g=null,b=r;else g=null, +b=r;if(g!==null)r=g;else{r=b;g=[];for(o=q();o!==null;)g.push(o),o=q();if(g!==null)if(a.substr(b,2)===">="?(o=">=",b+=2):(o=null,n&&j('">="')),o!==null){m=[];for(t=q();t!==null;)m.push(t),t=q();m!==null?(t=U(),t!==null?g=[g,o,m,t]:(g=null,b=r)):(g=null,b=r)}else g=null,b=r;else g=null,b=r;r=g!==null?g:null}}}}}for(;r!==null;){k.push(r);r=b;g=[];for(o=q();o!==null;)g.push(o),o=q();if(g!==null)if(a.substr(b,1)==="="?(o="=",b+=1):(o=null,n&&j('"="')),o!==null){m=[];for(t=q();t!==null;)m.push(t),t=q(); +m!==null?(t=U(),t!==null?g=[g,o,m,t]:(g=null,b=r)):(g=null,b=r)}else g=null,b=r;else g=null,b=r;if(g!==null)r=g;else{r=b;g=[];for(o=q();o!==null;)g.push(o),o=q();if(g!==null)if(a.substr(b,2)==="!="?(o="!=",b+=2):(o=null,n&&j('"!="')),o!==null){m=[];for(t=q();t!==null;)m.push(t),t=q();m!==null?(t=U(),t!==null?g=[g,o,m,t]:(g=null,b=r)):(g=null,b=r)}else g=null,b=r;else g=null,b=r;if(g!==null)r=g;else{r=b;g=[];for(o=q();o!==null;)g.push(o),o=q();if(g!==null)if(a.substr(b,1)==="<"?(o="<",b+=1):(o=null, +n&&j('"<"')),o!==null){m=[];for(t=q();t!==null;)m.push(t),t=q();m!==null?(t=U(),t!==null?g=[g,o,m,t]:(g=null,b=r)):(g=null,b=r)}else g=null,b=r;else g=null,b=r;if(g!==null)r=g;else{r=b;g=[];for(o=q();o!==null;)g.push(o),o=q();if(g!==null)if(a.substr(b,1)===">"?(o=">",b+=1):(o=null,n&&j('">"')),o!==null){m=[];for(t=q();t!==null;)m.push(t),t=q();m!==null?(t=U(),t!==null?g=[g,o,m,t]:(g=null,b=r)):(g=null,b=r)}else g=null,b=r;else g=null,b=r;if(g!==null)r=g;else{r=b;g=[];for(o=q();o!==null;)g.push(o), +o=q();if(g!==null)if(a.substr(b,2)==="<="?(o="<=",b+=2):(o=null,n&&j('"<="')),o!==null){m=[];for(t=q();t!==null;)m.push(t),t=q();m!==null?(t=U(),t!==null?g=[g,o,m,t]:(g=null,b=r)):(g=null,b=r)}else g=null,b=r;else g=null,b=r;if(g!==null)r=g;else{r=b;g=[];for(o=q();o!==null;)g.push(o),o=q();if(g!==null)if(a.substr(b,2)===">="?(o=">=",b+=2):(o=null,n&&j('">="')),o!==null){m=[];for(t=q();t!==null;)m.push(t),t=q();m!==null?(t=U(),t!==null?g=[g,o,m,t]:(g=null,b=r)):(g=null,b=r)}else g=null,b=r;else g= +null,b=r;r=g!==null?g:null}}}}}}k!==null?e=[e,k]:(e=null,b=d)}else e=null,b=d;d=e!==null?function(a,b){if(b.length===0)return a;else{var d={expressionType:"relationalexpression"};d.operator=b[0][1];d.op1=a;d.op2=b[0][3];d.token="expression";return d}}(e[0],e[1]):null;d===null&&(d=null,b=i);(n=h)&&d===null&&j("[99] RelationalExpression");y[f]={nextPos:b,result:d};return d}function U(){var f="AdditiveExpression@"+b,h=y[f];if(h)return b=h.nextPos,h.result;h=n;n=!1;var i=b,d=b,e=ra();if(e!==null){for(var g= +[],k=b,m=[],o=q();o!==null;)m.push(o),o=q();if(m!==null)if(a.substr(b,1)==="+"?(o="+",b+=1):(o=null,n&&j('"+"')),o!==null){for(var s=[],t=q();t!==null;)s.push(t),t=q();s!==null?(t=ra(),t!==null?m=[m,o,s,t]:(m=null,b=k)):(m=null,b=k)}else m=null,b=k;else m=null,b=k;if(m!==null)k=m;else{k=b;m=[];for(o=q();o!==null;)m.push(o),o=q();if(m!==null)if(a.substr(b,1)==="-"?(o="-",b+=1):(o=null,n&&j('"-"')),o!==null){s=[];for(t=q();t!==null;)s.push(t),t=q();s!==null?(t=ra(),t!==null?m=[m,o,s,t]:(m=null,b=k)): +(m=null,b=k)}else m=null,b=k;else m=null,b=k;if(m!==null)k=m;else{k=b;m=sa();m===null&&(m=sa(),m=m!==null?m:null);if(m!==null){o=b;s=[];for(t=q();t!==null;)s.push(t),t=q();if(s!==null)if(a.substr(b,1)==="*"?(t="*",b+=1):(t=null,n&&j('"*"')),t!==null){for(var v=[],u=q();u!==null;)v.push(u),u=q();v!==null?(u=$(),u!==null?s=[s,t,v,u]:(s=null,b=o)):(s=null,b=o)}else s=null,b=o;else s=null,b=o;if(s!==null)o=s;else{o=b;s=[];for(t=q();t!==null;)s.push(t),t=q();if(s!==null)if(a.substr(b,1)==="/"?(t="/",b+= +1):(t=null,n&&j('"/"')),t!==null){v=[];for(u=q();u!==null;)v.push(u),u=q();v!==null?(u=$(),u!==null?s=[s,t,v,u]:(s=null,b=o)):(s=null,b=o)}else s=null,b=o;else s=null,b=o;o=s!==null?s:null}o=o!==null?o:"";o!==null?m=[m,o]:(m=null,b=k)}else m=null,b=k;k=m!==null?m:null}}for(;k!==null;){g.push(k);k=b;m=[];for(o=q();o!==null;)m.push(o),o=q();if(m!==null)if(a.substr(b,1)==="+"?(o="+",b+=1):(o=null,n&&j('"+"')),o!==null){s=[];for(t=q();t!==null;)s.push(t),t=q();s!==null?(t=ra(),t!==null?m=[m,o,s,t]:(m= +null,b=k)):(m=null,b=k)}else m=null,b=k;else m=null,b=k;if(m!==null)k=m;else{k=b;m=[];for(o=q();o!==null;)m.push(o),o=q();if(m!==null)if(a.substr(b,1)==="-"?(o="-",b+=1):(o=null,n&&j('"-"')),o!==null){s=[];for(t=q();t!==null;)s.push(t),t=q();s!==null?(t=ra(),t!==null?m=[m,o,s,t]:(m=null,b=k)):(m=null,b=k)}else m=null,b=k;else m=null,b=k;if(m!==null)k=m;else{k=b;m=sa();m===null&&(m=sa(),m=m!==null?m:null);if(m!==null){o=b;s=[];for(t=q();t!==null;)s.push(t),t=q();if(s!==null)if(a.substr(b,1)==="*"? +(t="*",b+=1):(t=null,n&&j('"*"')),t!==null){v=[];for(u=q();u!==null;)v.push(u),u=q();v!==null?(u=$(),u!==null?s=[s,t,v,u]:(s=null,b=o)):(s=null,b=o)}else s=null,b=o;else s=null,b=o;if(s!==null)o=s;else{o=b;s=[];for(t=q();t!==null;)s.push(t),t=q();if(s!==null)if(a.substr(b,1)==="/"?(t="/",b+=1):(t=null,n&&j('"/"')),t!==null){v=[];for(u=q();u!==null;)v.push(u),u=q();v!==null?(u=$(),u!==null?s=[s,t,v,u]:(s=null,b=o)):(s=null,b=o)}else s=null,b=o;else s=null,b=o;o=s!==null?s:null}o=o!==null?o:"";o!== +null?m=[m,o]:(m=null,b=k)}else m=null,b=k;k=m!==null?m:null}}}g!==null?e=[e,g]:(e=null,b=d)}else e=null,b=d;d=e!==null?function(a,b){if(b.length===0)return a;var d={token:"expression",expressionType:"additiveexpression"};d.summand=a;d.summands=[];for(var e=0;e0?{token:"literal",value:a.value,lang:b.slice(1),type:null}:typeof b==="object"?(b.shift(),{token:"literal",value:a.value,lang:null,type:b[0]}):{token:"literal",value:a.value,lang:null,type:null}}(e[0],e[1]):null;d===null&&(d=null,b=g);(n=h)&&d===null&&j("[112] RDFLiteral");y[f]={nextPos:b, +result:d};return d}function Ia(){var a="NumericLiteral@"+b,c=y[a];if(c)return b=c.nextPos,c.result;c=n;n=!1;var f=ic();f===null&&(f=jc(),f===null&&(f=sa(),f=f!==null?f:null));(n=c)&&f===null&&j("[113] NumericLiteral");y[a]={nextPos:b,result:f};return f}function ic(){var a="NumericLiteralUnsigned@"+b,c=y[a];if(c)return b=c.nextPos,c.result;c=n;n=!1;var f=Ta();f===null&&(f=Ua(),f===null&&(f=ca(),f=f!==null?f:null));(n=c)&&f===null&&j("[114] NumericLiteralUnsigned");y[a]={nextPos:b,result:f};return f} +function jc(){var a="NumericLiteralPositive@"+b,c=y[a];if(c)return b=c.nextPos,c.result;c=n;n=!1;var f=kc();f===null&&(f=lc(),f===null&&(f=mc(),f=f!==null?f:null));(n=c)&&f===null&&j("[115] NumericLiteralPositive");y[a]={nextPos:b,result:f};return f}function sa(){var a="NumericLiteralNegative@"+b,c=y[a];if(c)return b=c.nextPos,c.result;c=n;n=!1;var f=nc();f===null&&(f=oc(),f===null&&(f=pc(),f=f!==null?f:null));(n=c)&&f===null&&j("[116] NumericLiteralNegative");y[a]={nextPos:b,result:f};return f}function Ja(){var f= +"BooleanLiteral@"+b,h=y[f];if(h)return b=h.nextPos,h.result;h=n;n=!1;var g=b;if(a.substr(b,4)==="TRUE"){var d="TRUE";b+=4}else d=null,n&&j('"TRUE"');d===null&&(a.substr(b,4)==="true"?(d="true",b+=4):(d=null,n&&j('"true"')),d=d!==null?d:null);d=d!==null?{token:"literal",lang:null,type:"http://www.w3.org/2001/XMLSchema#boolean",value:!0}:null;d===null&&(d=null,b=g);d!==null?g=d:(g=b,a.substr(b,5)==="FALSE"?(d="FALSE",b+=5):(d=null,n&&j('"FALSE"')),d===null&&(a.substr(b,5)==="false"?(d="false",b+=5): +(d=null,n&&j('"false"')),d=d!==null?d:null),d=d!==null?{token:"literal",lang:null,type:"http://www.w3.org/2001/XMLSchema#boolean",value:!1}:null,d===null&&(d=null,b=g),g=d!==null?d:null);(n=h)&&g===null&&j("[117] BooleanLiteral");y[f]={nextPos:b,result:g};return g}function gc(){var a="String@"+b,c=y[a];if(c)return b=c.nextPos,c.result;c=n;n=!1;var f=b,d=qc(),d=d!==null?{token:"string",value:d}:null;d===null&&(d=null,b=f);d!==null?f=d:(f=b,d=rc(),d=d!==null?{token:"string",value:d}:null,d===null&& +(d=null,b=f),d!==null?f=d:(f=b,d=sc(),d=d!==null?{token:"string",value:d}:null,d===null&&(d=null,b=f),d!==null?f=d:(f=b,d=tc(),d=d!==null?{token:"string",value:d}:null,d===null&&(d=null,b=f),f=d!==null?d:null)));(n=c)&&f===null&&j("[118] String");y[a]={nextPos:b,result:f};return f}function R(){var a="IRIref@"+b,c=y[a];if(c)return b=c.nextPos,c.result;c=n;n=!1;var f=b,d=na(),d=d!==null?{token:"uri",prefix:null,suffix:null,value:d}:null;d===null&&(d=null,b=f);d!==null?f=d:(f=b,d=uc(),d=d!==null?d:null, +d===null&&(d=null,b=f),f=d!==null?d:null);(n=c)&&f===null&&j("[119] IRIref");y[a]={nextPos:b,result:f};return f}function uc(){var a="PrefixedName@"+b,c=y[a];if(c)return b=c.nextPos,c.result;c=n;n=!1;var f=b,d=vc(),d=d!==null?{token:"uri",prefix:d[0],suffix:d[1],value:null}:null;d===null&&(d=null,b=f);d!==null?f=d:(f=b,d=Ea(),d=d!==null?{token:"uri",prefix:d,suffix:"",value:null}:null,d===null&&(d=null,b=f),f=d!==null?d:null);(n=c)&&f===null&&j("[120] PrefixedName");y[a]={nextPos:b,result:f};return f} +function ac(){var a="BlankNode@"+b,c=y[a];if(c)return b=c.nextPos,c.result;c=n;n=!1;var f=b,d=wc(),d=d!==null?{token:"blank",value:d}:null;d===null&&(d=null,b=f);d!==null?f=d:(f=b,xc()!==null?(ea++,d={token:"blank",value:"_:"+ea}):d=null,d===null&&(d=null,b=f),f=d!==null?d:null);(n=c)&&f===null&&j("[121] BlankNode");y[a]={nextPos:b,result:f};return f}function na(){var f="IRI_REF@"+b,h=y[f];if(h)return b=h.nextPos,h.result;h=n;n=!1;var g=b,d=b;if(a.substr(b,1)==="<"){var e="<";b+=1}else e=null,n&& +j('"<"');if(e!==null){var k=[];if(a.substr(b).match(/^[^<>"{}|^`\\]/)!==null){var i=a.charAt(b);b++}else i=null,n&&j('[^<>"{}|^`\\\\]');for(;i!==null;)k.push(i),a.substr(b).match(/^[^<>"{}|^`\\]/)!==null?(i=a.charAt(b),b++):(i=null,n&&j('[^<>"{}|^`\\\\]'));k!==null?(a.substr(b,1)===">"?(i=">",b+=1):(i=null,n&&j('">"')),i!==null?e=[e,k,i]:(e=null,b=d)):(e=null,b=d)}else e=null,b=d;d=e!==null?e[1].join(""):null;d===null&&(d=null,b=g);(n=h)&&d===null&&j("[122] IRI_REF");y[f]={nextPos:b,result:d};return d} +function Ea(){var f="PNAME_NS@"+b,h=y[f];if(h)return b=h.nextPos,h.result;h=n;n=!1;var g=b,d=b,e=ab(),e=e!==null?e:"";if(e!==null){if(a.substr(b,1)===":"){var k=":";b+=1}else k=null,n&&j('":"');k!==null?e=[e,k]:(e=null,b=d)}else e=null,b=d;d=e!==null?e[0]:null;d===null&&(d=null,b=g);(n=h)&&d===null&&j("[123] PNAME_NS");y[f]={nextPos:b,result:d};return d}function vc(){var a="PNAME_LN@"+b,c=y[a];if(c)return b=c.nextPos,c.result;c=n;n=!1;var f=b,d=b,e=Ea();if(e!==null){var h=pb();h!==null?e=[e,h]:(e= +null,b=d)}else e=null,b=d;d=e!==null?[e[0],e[1]]:null;d===null&&(d=null,b=f);(n=c)&&d===null&&j("[124] PNAME_LN");y[a]={nextPos:b,result:d};return d}function wc(){var f="BLANK_NODE_LABEL@"+b,h=y[f];if(h)return b=h.nextPos,h.result;h=n;n=!1;var g=b,d=b;if(a.substr(b,2)==="_:"){var e="_:";b+=2}else e=null,n&&j('"_:"');if(e!==null){var k=pb();k!==null?e=[e,k]:(e=null,b=d)}else e=null,b=d;d=e!==null?e[1]:null;d===null&&(d=null,b=g);(n=h)&&d===null&&j("[125] BLANK_NODE_LABEL");y[f]={nextPos:b,result:d}; +return d}function Zb(){var f="VAR1@"+b,h=y[f];if(h)return b=h.nextPos,h.result;h=n;n=!1;var g=b,d=b;if(a.substr(b,1)==="?"){var e="?";b+=1}else e=null,n&&j('"?"');if(e!==null){var k=qb();k!==null?e=[e,k]:(e=null,b=d)}else e=null,b=d;d=e!==null?e[1]:null;d===null&&(d=null,b=g);(n=h)&&d===null&&j("[126] VAR1");y[f]={nextPos:b,result:d};return d}function $b(){var f="VAR2@"+b,h=y[f];if(h)return b=h.nextPos,h.result;h=n;n=!1;var g=b,d=b;if(a.substr(b,1)==="$"){var e="$";b+=1}else e=null,n&&j('"$"');if(e!== +null){var k=qb();k!==null?e=[e,k]:(e=null,b=d)}else e=null,b=d;d=e!==null?e[1]:null;d===null&&(d=null,b=g);(n=h)&&d===null&&j("[127] VAR2");y[f]={nextPos:b,result:d};return d}function hc(){var f="LANGTAG@"+b,h=y[f];if(h)return b=h.nextPos,h.result;h=n;n=!1;var g=b,d=b;if(a.substr(b,1)==="@"){var e="@";b+=1}else e=null,n&&j('"@"');if(e!==null){if(a.substr(b).match(/^[a-zA-Z]/)!==null){var k=a.charAt(b);b++}else k=null,n&&j("[a-zA-Z]");if(k!==null)for(var i=[];k!==null;)i.push(k),a.substr(b).match(/^[a-zA-Z]/)!== +null?(k=a.charAt(b),b++):(k=null,n&&j("[a-zA-Z]"));else i=null;if(i!==null){var k=[],m=b;if(a.substr(b,1)==="-"){var o="-";b+=1}else o=null,n&&j('"-"');if(o!==null){if(a.substr(b).match(/^[a-zA-Z0-9]/)!==null){var q=a.charAt(b);b++}else q=null,n&&j("[a-zA-Z0-9]");if(q!==null)for(var s=[];q!==null;)s.push(q),a.substr(b).match(/^[a-zA-Z0-9]/)!==null?(q=a.charAt(b),b++):(q=null,n&&j("[a-zA-Z0-9]"));else s=null;s!==null?o=[o,s]:(o=null,b=m)}else o=null,b=m;for(;o!==null;)if(k.push(o),m=b,a.substr(b,1)=== +"-"?(o="-",b+=1):(o=null,n&&j('"-"')),o!==null){a.substr(b).match(/^[a-zA-Z0-9]/)!==null?(q=a.charAt(b),b++):(q=null,n&&j("[a-zA-Z0-9]"));if(q!==null)for(s=[];q!==null;)s.push(q),a.substr(b).match(/^[a-zA-Z0-9]/)!==null?(q=a.charAt(b),b++):(q=null,n&&j("[a-zA-Z0-9]"));else s=null;s!==null?o=[o,s]:(o=null,b=m)}else o=null,b=m;k!==null?e=[e,i,k]:(e=null,b=d)}else e=null,b=d}else e=null,b=d;d=e!==null?e[2].length===0?("@"+e[1].join("")).toLowerCase():("@"+e[1].join("")+"-"+e[2][0][1].join("")).toLowerCase(): +null;d===null&&(d=null,b=g);(n=h)&&d===null&&j("[128] LANGTAG");y[f]={nextPos:b,result:d};return d}function ca(){var f="INTEGER@"+b,h=y[f];if(h)return b=h.nextPos,h.result;h=n;n=!1;var g=b;if(a.substr(b).match(/^[0-9]/)!==null){var d=a.charAt(b);b++}else d=null,n&&j("[0-9]");if(d!==null)for(var e=[];d!==null;)e.push(d),a.substr(b).match(/^[0-9]/)!==null?(d=a.charAt(b),b++):(d=null,n&&j("[0-9]"));else e=null;d=e!==null?function(a){var b={token:"literal",lang:null,type:"http://www.w3.org/2001/XMLSchema#integer"}; +b.value=X(a);return b}(e):null;d===null&&(d=null,b=g);(n=h)&&d===null&&j("[129] INTEGER");y[f]={nextPos:b,result:d};return d}function Ua(){var f="DECIMAL@"+b,h=y[f];if(h)return b=h.nextPos,h.result;h=n;n=!1;var g=b,d=b;if(a.substr(b).match(/^[0-9]/)!==null){var e=a.charAt(b);b++}else e=null,n&&j("[0-9]");if(e!==null)for(var k=[];e!==null;)k.push(e),a.substr(b).match(/^[0-9]/)!==null?(e=a.charAt(b),b++):(e=null,n&&j("[0-9]"));else k=null;if(k!==null)if(a.substr(b,1)==="."?(e=".",b+=1):(e=null,n&&j('"."')), +e!==null){var i=[];if(a.substr(b).match(/^[0-9]/)!==null){var m=a.charAt(b);b++}else m=null,n&&j("[0-9]");for(;m!==null;)i.push(m),a.substr(b).match(/^[0-9]/)!==null?(m=a.charAt(b),b++):(m=null,n&&j("[0-9]"));i!==null?k=[k,e,i]:(k=null,b=d)}else k=null,b=d;else k=null,b=d;d=k!==null?function(a,b,d){var c={token:"literal",lang:null,type:"http://www.w3.org/2001/XMLSchema#decimal"};c.value=X([a,b,d]);return c}(k[0],k[1],k[2]):null;d===null&&(d=null,b=g);if(d!==null)g=d;else{d=g=b;a.substr(b,1)==="."? +(k=".",b+=1):(k=null,n&&j('"."'));if(k!==null){a.substr(b).match(/^[0-9]/)!==null?(e=a.charAt(b),b++):(e=null,n&&j("[0-9]"));if(e!==null)for(i=[];e!==null;)i.push(e),a.substr(b).match(/^[0-9]/)!==null?(e=a.charAt(b),b++):(e=null,n&&j("[0-9]"));else i=null;i!==null?k=[k,i]:(k=null,b=d)}else k=null,b=d;d=k!==null?function(a,b){var d={token:"literal",lang:null,type:"http://www.w3.org/2001/XMLSchema#decimal"};d.value=X([a,b]);return d}(k[0],k[1]):null;d===null&&(d=null,b=g);g=d!==null?d:null}(n=h)&&g=== +null&&j("[130] DECIMAL");y[f]={nextPos:b,result:g};return g}function Ta(){var f="DOUBLE@"+b,h=y[f];if(h)return b=h.nextPos,h.result;h=n;n=!1;var g=b,d=b;if(a.substr(b).match(/^[0-9]/)!==null){var e=a.charAt(b);b++}else e=null,n&&j("[0-9]");if(e!==null)for(var k=[];e!==null;)k.push(e),a.substr(b).match(/^[0-9]/)!==null?(e=a.charAt(b),b++):(e=null,n&&j("[0-9]"));else k=null;if(k!==null)if(a.substr(b,1)==="."?(e=".",b+=1):(e=null,n&&j('"."')),e!==null){var i=[];if(a.substr(b).match(/^[0-9]/)!==null){var m= +a.charAt(b);b++}else m=null,n&&j("[0-9]");for(;m!==null;)i.push(m),a.substr(b).match(/^[0-9]/)!==null?(m=a.charAt(b),b++):(m=null,n&&j("[0-9]"));i!==null?(m=Va(),m!==null?k=[k,e,i,m]:(k=null,b=d)):(k=null,b=d)}else k=null,b=d;else k=null,b=d;d=k!==null?function(a,b,d,c){var e={token:"literal",lang:null,type:"http://www.w3.org/2001/XMLSchema#double"};e.value=X([a,b,d,c]);return e}(k[0],k[1],k[2],k[3]):null;d===null&&(d=null,b=g);if(d!==null)g=d;else{d=g=b;a.substr(b,1)==="."?(k=".",b+=1):(k=null,n&& +j('"."'));if(k!==null){a.substr(b).match(/^[0-9]/)!==null?(i=a.charAt(b),b++):(i=null,n&&j("[0-9]"));if(i!==null)for(e=[];i!==null;)e.push(i),a.substr(b).match(/^[0-9]/)!==null?(i=a.charAt(b),b++):(i=null,n&&j("[0-9]"));else e=null;e!==null?(i=Va(),i!==null?k=[k,e,i]:(k=null,b=d)):(k=null,b=d)}else k=null,b=d;d=k!==null?function(a,b,d){var c={token:"literal",lang:null,type:"http://www.w3.org/2001/XMLSchema#double"};c.value=X([a,b,d]);return c}(k[0],k[1],k[2]):null;d===null&&(d=null,b=g);if(d!==null)g= +d;else{d=g=b;a.substr(b).match(/^[0-9]/)!==null?(e=a.charAt(b),b++):(e=null,n&&j("[0-9]"));if(e!==null)for(k=[];e!==null;)k.push(e),a.substr(b).match(/^[0-9]/)!==null?(e=a.charAt(b),b++):(e=null,n&&j("[0-9]"));else k=null;k!==null?(e=Va(),e!==null?k=[k,e]:(k=null,b=d)):(k=null,b=d);d=k!==null?function(a,b){var d={token:"literal",lang:null,type:"http://www.w3.org/2001/XMLSchema#double"};d.value=X([a,b]);return d}(k[0],k[1]):null;d===null&&(d=null,b=g);g=d!==null?d:null}}(n=h)&&g===null&&j("[131] DOUBLE"); +y[f]={nextPos:b,result:g};return g}function mc(){var f="INTEGER_POSITIVE@"+b,h=y[f];if(h)return b=h.nextPos,h.result;h=n;n=!1;var k=b,d=b;if(a.substr(b,1)==="+"){var e="+";b+=1}else e=null,n&&j('"+"');if(e!==null){var g=ca();g!==null?e=[e,g]:(e=null,b=d)}else e=null,b=d;d=e!==null?function(a){a.value="+"+a.value;return a}(e[1]):null;d===null&&(d=null,b=k);(n=h)&&d===null&&j("[132] INTEGER_POSITIVE");y[f]={nextPos:b,result:d};return d}function lc(){var f="DECIMAL_POSITIVE@"+b,h=y[f];if(h)return b= +h.nextPos,h.result;h=n;n=!1;var k=b,d=b;if(a.substr(b,1)==="+"){var e="+";b+=1}else e=null,n&&j('"+"');if(e!==null){var g=Ua();g!==null?e=[e,g]:(e=null,b=d)}else e=null,b=d;d=e!==null?function(a){a.value="+"+a.value;return a}(e[1]):null;d===null&&(d=null,b=k);(n=h)&&d===null&&j("[133] DECIMAL_POSITIVE");y[f]={nextPos:b,result:d};return d}function kc(){var f="DOUBLE_POSITIVE@"+b,h=y[f];if(h)return b=h.nextPos,h.result;h=n;n=!1;var k=b,d=b;if(a.substr(b,1)==="+"){var e="+";b+=1}else e=null,n&&j('"+"'); +if(e!==null){var g=Ta();g!==null?e=[e,g]:(e=null,b=d)}else e=null,b=d;d=e!==null?function(a){a.value="+"+a.value;return a}(e[1]):null;d===null&&(d=null,b=k);(n=h)&&d===null&&j("[134] DOUBLE_POSITIVE");y[f]={nextPos:b,result:d};return d}function pc(){var f="INTEGER_NEGATIVE@"+b,h=y[f];if(h)return b=h.nextPos,h.result;h=n;n=!1;var k=b,d=b;if(a.substr(b,1)==="-"){var e="-";b+=1}else e=null,n&&j('"-"');if(e!==null){var g=ca();g!==null?e=[e,g]:(e=null,b=d)}else e=null,b=d;d=e!==null?function(a){a.value= +"-"+a.value;return a}(e[1]):null;d===null&&(d=null,b=k);(n=h)&&d===null&&j("[135] INTEGER_NEGATIVE");y[f]={nextPos:b,result:d};return d}function oc(){var f="DECIMAL_NEGATIVE@"+b,h=y[f];if(h)return b=h.nextPos,h.result;h=n;n=!1;var k=b,d=b;if(a.substr(b,1)==="-"){var e="-";b+=1}else e=null,n&&j('"-"');if(e!==null){var g=Ua();g!==null?e=[e,g]:(e=null,b=d)}else e=null,b=d;d=e!==null?function(a){a.value="-"+a.value;return a}(e[1]):null;d===null&&(d=null,b=k);(n=h)&&d===null&&j("[136] DECIMAL_NEGATIVE"); +y[f]={nextPos:b,result:d};return d}function nc(){var f="DOUBLE_NEGATIVE@"+b,h=y[f];if(h)return b=h.nextPos,h.result;h=n;n=!1;var k=b,d=b;if(a.substr(b,1)==="-"){var e="-";b+=1}else e=null,n&&j('"-"');if(e!==null){var g=Ta();g!==null?e=[e,g]:(e=null,b=d)}else e=null,b=d;d=e!==null?function(a){a.value="-"+a.value;return a}(e[1]):null;d===null&&(d=null,b=k);(n=h)&&d===null&&j("[137] DOUBLE_NEGATIVE");y[f]={nextPos:b,result:d};return d}function Va(){var f="EXPONENT@"+b,h=y[f];if(h)return b=h.nextPos, +h.result;h=n;n=!1;var k=b,d=b;if(a.substr(b).match(/^[eE]/)!==null){var e=a.charAt(b);b++}else e=null,n&&j("[eE]");if(e!==null){if(a.substr(b).match(/^[+\-]/)!==null){var g=a.charAt(b);b++}else g=null,n&&j("[+\\-]");g=g!==null?g:"";if(g!==null){if(a.substr(b).match(/^[0-9]/)!==null){var i=a.charAt(b);b++}else i=null,n&&j("[0-9]");if(i!==null)for(var m=[];i!==null;)m.push(i),a.substr(b).match(/^[0-9]/)!==null?(i=a.charAt(b),b++):(i=null,n&&j("[0-9]"));else m=null;m!==null?e=[e,g,m]:(e=null,b=d)}else e= +null,b=d}else e=null,b=d;d=e!==null?X([e[0],e[1],e[2]]):null;d===null&&(d=null,b=k);(n=h)&&d===null&&j("[138] EXPONENT");y[f]={nextPos:b,result:d};return d}function sc(){var f="STRING_LITERAL1@"+b,h=y[f];if(h)return b=h.nextPos,h.result;h=n;n=!1;var k=b,d=b;if(a.substr(b,1)==="'"){var e="'";b+=1}else e=null,n&&j('"\'"');if(e!==null){var g=[];if(a.substr(b).match(/^[^'\\\n\r]/)!==null){var i=a.charAt(b);b++}else i=null,n&&j("[^'\\\\\\n\\r]");i===null&&(i=fa(),i=i!==null?i:null);for(;i!==null;)g.push(i), +a.substr(b).match(/^[^'\\\n\r]/)!==null?(i=a.charAt(b),b++):(i=null,n&&j("[^'\\\\\\n\\r]")),i===null&&(i=fa(),i=i!==null?i:null);g!==null?(a.substr(b,1)==="'"?(i="'",b+=1):(i=null,n&&j('"\'"')),i!==null?e=[e,g,i]:(e=null,b=d)):(e=null,b=d)}else e=null,b=d;d=e!==null?X(e[1]):null;d===null&&(d=null,b=k);(n=h)&&d===null&&j("[139] STRING_LITERAL1");y[f]={nextPos:b,result:d};return d}function tc(){var f="STRING_LITERAL2@"+b,h=y[f];if(h)return b=h.nextPos,h.result;h=n;n=!1;var k=b,d=b;if(a.substr(b,1)=== +'"'){var e='"';b+=1}else e=null,n&&j('"\\""');if(e!==null){var g=[];if(a.substr(b).match(/^[^"\\\n\r]/)!==null){var i=a.charAt(b);b++}else i=null,n&&j('[^"\\\\\\n\\r]');i===null&&(i=fa(),i=i!==null?i:null);for(;i!==null;)g.push(i),a.substr(b).match(/^[^"\\\n\r]/)!==null?(i=a.charAt(b),b++):(i=null,n&&j('[^"\\\\\\n\\r]')),i===null&&(i=fa(),i=i!==null?i:null);g!==null?(a.substr(b,1)==='"'?(i='"',b+=1):(i=null,n&&j('"\\""')),i!==null?e=[e,g,i]:(e=null,b=d)):(e=null,b=d)}else e=null,b=d;d=e!==null?X(e[1]): +null;d===null&&(d=null,b=k);(n=h)&&d===null&&j("[140] STRING_LITERAL2");y[f]={nextPos:b,result:d};return d}function qc(){var f="STRING_LITERAL_LONG1@"+b,h=y[f];if(h)return b=h.nextPos,h.result;h=n;n=!1;var k=b,d=b;if(a.substr(b,3)==="'''"){var e="'''";b+=3}else e=null,n&&j("\"'''\"");if(e!==null){var g=[];if(a.substr(b).match(/^[^'\\]/)!==null){var i=a.charAt(b);b++}else i=null,n&&j("[^'\\\\]");i===null&&(i=fa(),i=i!==null?i:null);for(;i!==null;)g.push(i),a.substr(b).match(/^[^'\\]/)!==null?(i=a.charAt(b), +b++):(i=null,n&&j("[^'\\\\]")),i===null&&(i=fa(),i=i!==null?i:null);g!==null?(a.substr(b,3)==="'''"?(i="'''",b+=3):(i=null,n&&j("\"'''\"")),i!==null?e=[e,g,i]:(e=null,b=d)):(e=null,b=d)}else e=null,b=d;d=e!==null?X(e[1]):null;d===null&&(d=null,b=k);(n=h)&&d===null&&j("[141] STRING_LITERAL_LONG1");y[f]={nextPos:b,result:d};return d}function rc(){var f="STRING_LITERAL_LONG2@"+b,h=y[f];if(h)return b=h.nextPos,h.result;h=n;n=!1;var k=b,d=b;if(a.substr(b,3)==='"""'){var e='"""';b+=3}else e=null,n&&j('"\\"\\"\\""'); +if(e!==null){var g=[];if(a.substr(b).match(/^[^"\\]/)!==null){var i=a.charAt(b);b++}else i=null,n&&j('[^"\\\\]');i===null&&(i=fa(),i=i!==null?i:null);for(;i!==null;)g.push(i),a.substr(b).match(/^[^"\\]/)!==null?(i=a.charAt(b),b++):(i=null,n&&j('[^"\\\\]')),i===null&&(i=fa(),i=i!==null?i:null);g!==null?(a.substr(b,3)==='"""'?(i='"""',b+=3):(i=null,n&&j('"\\"\\"\\""')),i!==null?e=[e,g,i]:(e=null,b=d)):(e=null,b=d)}else e=null,b=d;d=e!==null?X(e[1]):null;d===null&&(d=null,b=k);(n=h)&&d===null&&j("[142] STRING_LITERAL_LONG2"); +y[f]={nextPos:b,result:d};return d}function fa(){var f="ECHAR@"+b,h=y[f];if(h)return b=h.nextPos,h.result;h=n;n=!1;var i=b;if(a.substr(b,1)==="\\"){var d="\\";b+=1}else d=null,n&&j('"\\\\"');if(d!==null){if(a.substr(b).match(/^[tbnrf"']/)!==null){var e=a.charAt(b);b++}else e=null,n&&j("[tbnrf\"']");e!==null?d=[d,e]:(d=null,b=i)}else d=null,b=i;(n=h)&&d===null&&j("[143] ECHAR");y[f]={nextPos:b,result:d};return d}function la(){var f="NIL@"+b,h=y[f];if(h)return b=h.nextPos,h.result;h=n;n=!1;var i=b, +d=b;if(a.substr(b,1)==="("){var e="(";b+=1}else e=null,n&&j('"("');if(e!==null){for(var k=[],g=q();g!==null;)k.push(g),g=q();k!==null?(a.substr(b,1)===")"?(g=")",b+=1):(g=null,n&&j('")"')),g!==null?e=[e,k,g]:(e=null,b=d)):(e=null,b=d)}else e=null,b=d;d=e!==null?{token:"triplesnodecollection",triplesContext:[],chainSubject:[{token:"uri",value:"http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"}]}:null;d===null&&(d=null,b=i);(n=h)&&d===null&&j("[144] NIL");y[f]={nextPos:b,result:d};return d}function q(){var f= +"WS@"+b,h=y[f];if(h)return b=h.nextPos,h.result;h=n;n=!1;if(a.substr(b).match(/^[ ]/)!==null){var i=a.charAt(b);b++}else i=null,n&&j("[ ]");i===null&&(a.substr(b).match(/^[\t]/)!==null?(i=a.charAt(b),b++):(i=null,n&&j("[\t]")),i===null&&(a.substr(b).match(/^[\r]/)!==null?(i=a.charAt(b),b++):(i=null,n&&j("[\\r]")),i===null&&(a.substr(b).match(/^[\n]/)!==null?(i=a.charAt(b),b++):(i=null,n&&j("[\\n]")),i===null&&(i=yc(),i=i!==null?i:null))));(n=h)&&i===null&&j("[145] WS");y[f]={nextPos:b,result:i};return i} +function yc(){var f="COMMENT@"+b,h=y[f];if(h)return b=h.nextPos,h.result;h=n;n=!1;var i=b;if(a.substr(b,1)==="#"){var d="#";b+=1}else d=null,n&&j('"#"');if(d!==null){var e=[];if(a.substr(b).match(/^[^\n\r]/)!==null){var g=a.charAt(b);b++}else g=null,n&&j("[^\\n\\r]");for(;g!==null;)e.push(g),a.substr(b).match(/^[^\n\r]/)!==null?(g=a.charAt(b),b++):(g=null,n&&j("[^\\n\\r]"));e!==null?d=[d,e]:(d=null,b=i)}else d=null,b=i;(n=h)&&d===null&&j(" COMMENT");y[f]={nextPos:b,result:d};return d}function xc(){var f= +"ANON@"+b,h=y[f];if(h)return b=h.nextPos,h.result;h=n;n=!1;var i=b;if(a.substr(b,1)==="["){var d="[";b+=1}else d=null,n&&j('"["');if(d!==null){for(var e=[],g=q();g!==null;)e.push(g),g=q();e!==null?(a.substr(b,1)==="]"?(g="]",b+=1):(g=null,n&&j('"]"')),g!==null?d=[d,e,g]:(d=null,b=i)):(d=null,b=i)}else d=null,b=i;(n=h)&&d===null&&j("[146] ANON");y[f]={nextPos:b,result:d};return d}function rb(){var f="PN_CHARS_BASE@"+b,h=y[f];if(h)return b=h.nextPos,h.result;h=n;n=!1;if(a.substr(b).match(/^[A-Z]/)!== +null){var i=a.charAt(b);b++}else i=null,n&&j("[A-Z]");i===null&&(a.substr(b).match(/^[a-z]/)!==null?(i=a.charAt(b),b++):(i=null,n&&j("[a-z]")),i===null&&(a.substr(b).match(/^[\xC0-\xD6]/)!==null?(i=a.charAt(b),b++):(i=null,n&&j("[\\xC0-\\xD6]")),i===null&&(a.substr(b).match(/^[\xD8-\xF6]/)!==null?(i=a.charAt(b),b++):(i=null,n&&j("[\\xD8-\\xF6]")),i===null&&(a.substr(b).match(/^[\xF8-\u02FF]/)!==null?(i=a.charAt(b),b++):(i=null,n&&j("[\\xF8-\\u02FF]")),i===null&&(a.substr(b).match(/^[\u0370-\u037D]/)!== +null?(i=a.charAt(b),b++):(i=null,n&&j("[\\u0370-\\u037D]")),i===null&&(a.substr(b).match(/^[\u037F-\u1FFF]/)!==null?(i=a.charAt(b),b++):(i=null,n&&j("[\\u037F-\\u1FFF]")),i===null&&(a.substr(b).match(/^[\u200C-\u200D]/)!==null?(i=a.charAt(b),b++):(i=null,n&&j("[\\u200C-\\u200D]")),i===null&&(a.substr(b).match(/^[\u2070-\u218F]/)!==null?(i=a.charAt(b),b++):(i=null,n&&j("[\\u2070-\\u218F]")),i===null&&(a.substr(b).match(/^[\u2C00-\u2FEF]/)!==null?(i=a.charAt(b),b++):(i=null,n&&j("[\\u2C00-\\u2FEF]")), +i===null&&(a.substr(b).match(/^[\u3001-\uD7FF]/)!==null?(i=a.charAt(b),b++):(i=null,n&&j("[\\u3001-\\uD7FF]")),i===null&&(a.substr(b).match(/^[\uF900-\uFDCF]/)!==null?(i=a.charAt(b),b++):(i=null,n&&j("[\\uF900-\\uFDCF]")),i===null&&(a.substr(b).match(/^[\uFDF0-\uFFFD]/)!==null?(i=a.charAt(b),b++):(i=null,n&&j("[\\uFDF0-\\uFFFD]")),i===null&&(a.substr(b).match(/^[\u1000-\uEFFF]/)!==null?(i=a.charAt(b),b++):(i=null,n&&j("[\\u1000-\\uEFFF]")),i=i!==null?i:null)))))))))))));(n=h)&&i===null&&j("[147] PN_CHARS_BASE"); +y[f]={nextPos:b,result:i};return i}function ua(){var f="PN_CHARS_U@"+b,h=y[f];if(h)return b=h.nextPos,h.result;h=n;n=!1;var i=rb();i===null&&(a.substr(b,1)==="_"?(i="_",b+=1):(i=null,n&&j('"_"')),i=i!==null?i:null);(n=h)&&i===null&&j("[148] PN_CHARS_U");y[f]={nextPos:b,result:i};return i}function qb(){var f="VARNAME@"+b,h=y[f];if(h)return b=h.nextPos,h.result;h=n;n=!1;var i=b,d=b,e=ua();e===null&&(a.substr(b).match(/^[0-9]/)!==null?(e=a.charAt(b),b++):(e=null,n&&j("[0-9]")),e=e!==null?e:null);if(e!== +null){var g=[],k=ua();k===null&&(a.substr(b).match(/^[0-9]/)!==null?(k=a.charAt(b),b++):(k=null,n&&j("[0-9]")),k===null&&(a.substr(b).match(/^[\xB7]/)!==null?(k=a.charAt(b),b++):(k=null,n&&j("[\\xB7]")),k===null&&(a.substr(b).match(/^[\u0300-\u036F]/)!==null?(k=a.charAt(b),b++):(k=null,n&&j("[\\u0300-\\u036F]")),k===null&&(a.substr(b).match(/^[\u203F-\u2040]/)!==null?(k=a.charAt(b),b++):(k=null,n&&j("[\\u203F-\\u2040]")),k=k!==null?k:null))));for(;k!==null;)g.push(k),k=ua(),k===null&&(a.substr(b).match(/^[0-9]/)!== +null?(k=a.charAt(b),b++):(k=null,n&&j("[0-9]")),k===null&&(a.substr(b).match(/^[\xB7]/)!==null?(k=a.charAt(b),b++):(k=null,n&&j("[\\xB7]")),k===null&&(a.substr(b).match(/^[\u0300-\u036F]/)!==null?(k=a.charAt(b),b++):(k=null,n&&j("[\\u0300-\\u036F]")),k===null&&(a.substr(b).match(/^[\u203F-\u2040]/)!==null?(k=a.charAt(b),b++):(k=null,n&&j("[\\u203F-\\u2040]")),k=k!==null?k:null))));g!==null?e=[e,g]:(e=null,b=d)}else e=null,b=d;d=e!==null?e[0]+e[1].join(""):null;d===null&&(d=null,b=i);(n=h)&&d===null&& +j("[149] VARNAME");y[f]={nextPos:b,result:d};return d}function Da(){var f="PN_CHARS@"+b,h=y[f];if(h)return b=h.nextPos,h.result;h=n;n=!1;var i=ua();i===null&&(a.substr(b,1)==="-"?(i="-",b+=1):(i=null,n&&j('"-"')),i===null&&(a.substr(b).match(/^[0-9]/)!==null?(i=a.charAt(b),b++):(i=null,n&&j("[0-9]")),i===null&&(a.substr(b).match(/^[\xB7]/)!==null?(i=a.charAt(b),b++):(i=null,n&&j("[\\xB7]")),i===null&&(a.substr(b).match(/^[\u0300-\u036F]/)!==null?(i=a.charAt(b),b++):(i=null,n&&j("[\\u0300-\\u036F]")), +i===null&&(a.substr(b).match(/^[\u203F-\u2040]/)!==null?(i=a.charAt(b),b++):(i=null,n&&j("[\\u203F-\\u2040]")),i=i!==null?i:null)))));(n=h)&&i===null&&j("[150] PN_CHARS");y[f]={nextPos:b,result:i};return i}function ab(){var f="PN_PREFIX@"+b,h=y[f];if(h)return b=h.nextPos,h.result;h=n;n=!1;var i=b,d=b,e=rb();if(e!==null){var k=[],g=Da();g===null&&(a.substr(b,1)==="."?(g=".",b+=1):(g=null,n&&j('"."')),g=g!==null?g:null);for(;g!==null;)k.push(g),g=Da(),g===null&&(a.substr(b,1)==="."?(g=".",b+=1):(g= +null,n&&j('"."')),g=g!==null?g:null);k!==null?e=[e,k]:(e=null,b=d)}else e=null,b=d;d=e!==null?function(a,b){if(b[b.length-1]==".")throw Error("Wrong PN_PREFIX, cannot finish with '.'");else return a+b.join("")}(e[0],e[1]):null;d===null&&(d=null,b=i);(n=h)&&d===null&&j("[151] PN_PREFIX");y[f]={nextPos:b,result:d};return d}function pb(){var f="PN_LOCAL@"+b,h=y[f];if(h)return b=h.nextPos,h.result;h=n;n=!1;var i=b,d=b,e=ua();e===null&&(a.substr(b).match(/^[0-9]/)!==null?(e=a.charAt(b),b++):(e=null,n&& +j("[0-9]")),e=e!==null?e:null);if(e!==null){for(var k=[],g=Da();g!==null;)k.push(g),g=Da();k!==null?e=[e,k]:(e=null,b=d)}else e=null,b=d;d=e!==null?e[0]+e[1].join(""):null;d===null&&(d=null,b=i);(n=h)&&d===null&&j("[152] PN_LOCAL");y[f]={nextPos:b,result:d};return d}function sb(){var f=function(a){a.sort();for(var b=null,c=[],f=0;f"};u.NamedNode.prototype.valueOf=function(){return this.nominalValue};u.Triple=function(c,b,e){this.subject=c;this.predicate=b;this.object=e};u.Triple.prototype.equals=function(c){return this.subject.equals(c.subject)&&this.predicate.equals(c.predicate)&&this.object.equals(c.object)}; -u.Triple.prototype.toString=function(){return this.subject.toNT()+" "+this.predicate.toNT()+" "+this.object.toNT()+" . \r\n"};u.Graph=function(){this.triples=[];this.duplicates={};this.actions=[]};u.Graph.prototype.add=function(c){for(var b=0;b")return f.runGtFunction(b,e,d);else if(c==="<=")return f.runLtEqFunction(b,e,d);else if(c===">=")return f.runGtEqFunction(b,e,d);else throw"Error applying relational filter, unknown operator";};f.effectiveTypeValue=function(c){if(c.token=="literal")if(c.type=="http://www.w3.org/2001/XMLSchema#integer")return c=parseInt(c.value);else if(c.type== -"http://www.w3.org/2001/XMLSchema#decimal")return c=parseFloat(c.value);else if(c.type=="http://www.w3.org/2001/XMLSchema#float")return c=parseFloat(c.value);else if(c.type=="http://www.w3.org/2001/XMLSchema#double")return c=parseFloat(c.value);else if(c.type=="http://www.w3.org/2001/XMLSchema#nonPositiveInteger")return c=parseFloat(c.value);else if(c.type=="http://www.w3.org/2001/XMLSchema#negativeInteger")return c=parseInt(c.value);else if(c.type=="http://www.w3.org/2001/XMLSchema#long")return c= -parseInt(c.value);else if(c.type=="http://www.w3.org/2001/XMLSchema#int")return c=parseInt(c.value);else if(c.type=="http://www.w3.org/2001/XMLSchema#short")return c=parseInt(c.value);else if(c.type=="http://www.w3.org/2001/XMLSchema#byte")return c=parseInt(c.value);else if(c.type=="http://www.w3.org/2001/XMLSchema#nonNegativeInteger")return c=parseInt(c.value);else if(c.type=="http://www.w3.org/2001/XMLSchema#unsignedLong")return c=parseInt(c.value);else if(c.type=="http://www.w3.org/2001/XMLSchema#unsignedInt")return c= -parseInt(c.value);else if(c.type=="http://www.w3.org/2001/XMLSchema#unsignedShort")return c=parseInt(c.value);else if(c.type=="http://www.w3.org/2001/XMLSchema#unsignedByte")return c=parseInt(c.value);else if(c.type=="http://www.w3.org/2001/XMLSchema#positiveInteger")return c=parseInt(c.value);else if(c.type=="http://www.w3.org/2001/XMLSchema#date"||c.type=="http://www.w3.org/2001/XMLSchema#dateTime")try{return w.parseISO8601(c.value)}catch(b){return null}else return c.type=="http://www.w3.org/2001/XMLSchema#boolean"? -c.value===!0||c.value==="true"||c.value==="1"||c.value===1||c.value===!0?!0:c.value===!1||c.value==="false"||c.value==="0"||c.value===0||c.value===!1?!1:void 0:c.type=="http://www.w3.org/2001/XMLSchema#string"?c.value===null||c.value===void 0?void 0:""+c.value:c.value;else throw console.log("not implemented yet"),"value not supported in operations yet";};f.runOrFunction=function(c,b,e,d){for(var i=null,h=0;hf.effectiveTypeValue(b));else if(f.isSimpleLiteral(c)&&f.isSimpleLiteral(b))return f.ebvBoolean(f.effectiveTypeValue(c)>f.effectiveTypeValue(b));else if(f.isXsdType("string",c)&&f.isXsdType("string",b))return f.ebvBoolean(f.effectiveTypeValue(c)>f.effectiveTypeValue(b));else if(f.isXsdType("boolean",c)&&f.isXsdType("boolean",b))return f.ebvBoolean(f.effectiveTypeValue(c)>f.effectiveTypeValue(b)); -else if((f.isXsdType("dateTime",c)||f.isXsdType("date",c))&&(f.isXsdType("dateTime",b)||f.isXsdType("date",b))){if(f.isXsdType("dateTime",c)&&f.isXsdType("date",b))return f.ebvFalse();if(f.isXsdType("date",c)&&f.isXsdType("dateTime",b))return f.ebvFalse();var e=w.compareDateComponents(c.value,b.value);return e!=null?e==1?f.ebvTrue():f.ebvFalse():f.ebvError()}else return f.ebvFalse()};f.runTotalGtFunction=function(c,b){return f.isEbvError(c)||f.isEbvError(b)?f.ebvError():f.isNumeric(c)&&f.isNumeric(b)|| -f.isSimpleLiteral(c)&&f.isSimpleLiteral(b)||f.isXsdType("string",c)&&f.isSimpleLiteral("string",b)||f.isXsdType("boolean",c)&&f.isSimpleLiteral("boolean",b)||f.isXsdType("dateTime",c)&&f.isSimpleLiteral("dateTime",b)?f.runGtFunction(c,b,[]):c.token&&c.token==="uri"&&b.token&&b.token==="uri"?f.ebvBoolean(c.value>b.value):c.token&&c.token==="literal"&&b.token&&b.token==="literal"?f.ebvBoolean(""+c.value+c.type+c.lang>""+b.value+b.type+b.lang):c.token&&c.token==="blank"&&b.token&&b.token==="blank"?f.ebvBoolean(c.value> -b.value):c.value&&b.value?f.ebvBoolean(c.value>b.value):f.ebvTrue()};f.runLtFunction=function(c,b){if(f.isEbvError(c)||f.isEbvError(b))return f.ebvError();if(f.isNumeric(c)&&f.isNumeric(b))return f.ebvBoolean(f.effectiveTypeValue(c)=f.effectiveTypeValue(b));else if(f.isSimpleLiteral(c)&&f.isSimpleLiteral(b))return f.ebvBoolean(f.effectiveTypeValue(c)>=f.effectiveTypeValue(b));else if(f.isXsdType("string",c)&&f.isXsdType("string",b))return f.ebvBoolean(f.effectiveTypeValue(c)>=f.effectiveTypeValue(b));else if(f.isXsdType("boolean",c)&&f.isXsdType("boolean",b))return f.ebvBoolean(f.effectiveTypeValue(c)>= -f.effectiveTypeValue(b));else if((f.isXsdType("dateTime",c)||f.isXsdType("date",c))&&(f.isXsdType("dateTime",b)||f.isXsdType("date",b))){if(f.isXsdType("dateTime",c)&&f.isXsdType("date",b))return f.ebvFalse();if(f.isXsdType("date",c)&&f.isXsdType("dateTime",b))return f.ebvFalse();var e=w.compareDateComponents(c.value,b.value);return e!=null?e!=-1?f.ebvTrue():f.ebvFalse():f.ebvError()}else return f.ebvFalse()};f.runLtEqFunction=function(c,b){if(f.isEbvError(c)||f.isEbvError(b))return f.ebvError(); -if(f.isNumeric(c)&&f.isNumeric(b))return f.ebvBoolean(f.effectiveTypeValue(c)<=f.effectiveTypeValue(b));else if(f.isSimpleLiteral(c)&&f.isSimpleLiteral(b))return f.ebvBoolean(f.effectiveTypeValue(c)<=f.effectiveTypeValue(b));else if(f.isXsdType("string",c)&&f.isXsdType("string",b))return f.ebvBoolean(f.effectiveTypeValue(c)<=f.effectiveTypeValue(b));else if(f.isXsdType("boolean",c)&&f.isXsdType("boolean",b))return f.ebvBoolean(f.effectiveTypeValue(c)<=f.effectiveTypeValue(b));else if((f.isXsdType("dateTime", -c)||f.isXsdType("date",c))&&(f.isXsdType("dateTime",b)||f.isXsdType("date",b))){if(f.isXsdType("dateTime",c)&&f.isXsdType("date",b))return f.ebvFalse();if(f.isXsdType("date",c)&&f.isXsdType("dateTime",b))return f.ebvFalse();var e=w.compareDateComponents(c.value,b.value);return e!=null?e!=1?f.ebvTrue():f.ebvFalse():f.ebvError()}else return f.ebvFalse()};f.runAddition=function(c,b,e,d,i){var h=f.runFilter(c,e,d,i);if(f.isEbvError(h))return f.ebvError();c=h;if(f.isNumeric(h)){for(h=0;h2)return f.ebvError();else if(h.value.split("-").length>2)return f.ebvError();else if(h.value.split("/").length>2)return f.ebvError();else if(h.value.split("+").length>2)return f.ebvError();if(c=="http://www.w3.org/2001/XMLSchema#decimal"&&(h.value.indexOf("e")!= --1||h.value.indexOf("E")!=-1))return f.ebvError();if(c=="http://www.w3.org/2001/XMLSchema#int"||c=="http://www.w3.org/2001/XMLSchema#integer")if(h.value.indexOf("e")!=-1||h.value.indexOf("E")!=-1||h.value.indexOf(".")!=-1)return f.ebvError();try{return h.value=parseInt(parseFloat(h.value)),isNaN(h.value)?f.ebvError():(h.type=c,h)}catch(o){return f.ebvError()}}else return f.ebvError();else return f.ebvError();else if(c=="http://www.w3.org/2001/XMLSchema#boolean")return h=h[0],h.token==="literal"&& -h.type==null?h.value==="true"||h.value==="1"?f.ebvTrue():h.value==="false"||h.value==="0"?f.ebvFalse():f.ebvError():h.token==="literal"?f.isEbvError(h)?h:f.ebvBoolean(h):f.ebvError();else if(c=="http://www.w3.org/2001/XMLSchema#string")if(h=h[0],h.token==="literal")if(h=f.normalizeLiteralDatatype(h,d,i),h.type=="http://www.w3.org/2001/XMLSchema#integer"||h.type=="http://www.w3.org/2001/XMLSchema#decimal"||h.type=="http://www.w3.org/2001/XMLSchema#double"||h.type=="http://www.w3.org/2001/XMLSchema#nonPositiveInteger"|| -h.type=="http://www.w3.org/2001/XMLSchema#negativeInteger"||h.type=="http://www.w3.org/2001/XMLSchema#long"||h.type=="http://www.w3.org/2001/XMLSchema#int"||h.type=="http://www.w3.org/2001/XMLSchema#short"||h.type=="http://www.w3.org/2001/XMLSchema#byte"||h.type=="http://www.w3.org/2001/XMLSchema#nonNegativeInteger"||h.type=="http://www.w3.org/2001/XMLSchema#unsignedLong"||h.type=="http://www.w3.org/2001/XMLSchema#unsignedInt"||h.type=="http://www.w3.org/2001/XMLSchema#unsignedShort"||h.type=="http://www.w3.org/2001/XMLSchema#unsignedByte"|| -h.type=="http://www.w3.org/2001/XMLSchema#positiveInteger"||h.type=="http://www.w3.org/2001/XMLSchema#float")return h.type=c,h.value=""+h.value,h;else if(h.type=="http://www.w3.org/2001/XMLSchema#string")return h;else if(h.type=="http://www.w3.org/2001/XMLSchema#boolean")return f.ebv(h)?(h.type=c,h.value="true"):(h.type=c,h.value="false"),h;else if(h.type=="http://www.w3.org/2001/XMLSchema#dateTime"||h.type=="http://www.w3.org/2001/XMLSchema#date"){h.type=c;if(typeof h.value!="string")h.value=w.iso8601(h.value); -return h}else return h.type==null?(h.value=""+h.value,h.type=c,h):f.ebvError();else return h.token==="uri"?{token:"literal",value:w.lexicalFormBaseUri(h,i),type:c,lang:null}:f.ebvError();else if(c=="http://www.w3.org/2001/XMLSchema#dateTime"||c=="http://www.w3.org/2001/XMLSchema#date")if(h=h[0],h.type=="http://www.w3.org/2001/XMLSchema#dateTime"||h.type=="http://www.w3.org/2001/XMLSchema#date")return h;else if(h.type=="http://www.w3.org/2001/XMLSchema#string"||h.type==null)try{return h.value=w.iso8601(w.parseStrictISO8601(h.value)), -h.type=c,h}catch(r){return f.ebvError()}else return f.ebvError();else if(c=="http://www.w3.org/2001/XMLSchema#float")if(h=h[0],h.token==="literal")if(h=f.normalizeLiteralDatatype(h,d,i),h.type=="http://www.w3.org/2001/XMLSchema#decimal"||h.type=="http://www.w3.org/2001/XMLSchema#int")return h.type=c,h.value=parseFloat(h.value),h;else if(h.type=="http://www.w3.org/2001/XMLSchema#boolean")return f.ebv(h)==!0?(h.type=c,h.value=1):(h.type=c,h.value=0),h;else if(h.type=="http://www.w3.org/2001/XMLSchema#float"|| -h.type=="http://www.w3.org/2001/XMLSchema#double")return h.type=c,h.value=parseFloat(h.value),h;else if(h.type=="http://www.w3.org/2001/XMLSchema#string")try{return h.value=parseFloat(h.value),isNaN(h.value)?f.ebvError():(h.type=c,h)}catch(v){return f.ebvError()}else if(h.type==null){if(h.value.split(".").length>2)return f.ebvError();else if(h.value.split("-").length>2)return f.ebvError();else if(h.value.split("/").length>2)return f.ebvError();else if(h.value.split("+").length>2)return f.ebvError(); -try{return h.value=parseFloat(h.value),isNaN(h.value)?f.ebvError():(h.type=c,h)}catch(u){return f.ebvError()}}else return f.ebvError();else return f.ebvError();else return f.ebvError()}};var F={orderJoins:function(c){return c},variablesInBGP:function(c){var b=c.variables;if(b)return b;var e=c.value||c,b=[];for(comp in e)e[comp]&&e[comp].token==="var"?b.push(e[comp].value):e[comp]&&e[comp].token==="blank"&&b.push("blank:"+e[comp].label);return c.variables=b},variablesIntersectionBGP:function(c,b){for(var e= -F.variablesInBGP(c).sort(),d=F.variablesInBGP(b).sort(),i=0,h=0,f=[];i0){for(var h=0;h0?b(!0,!0):b(!0,!1):b(!1,d):b(!1,d)});else if(o.kind==="construct")o.projection=[{token:"variable",kind:"*"}],h=this,this.executeSelect(o, -k,e,d,function(c,d){if(c)if(c)if(d=h.denormalizeBindingsList(d,k.outCache),d!=null){var e=new u.Graph;if(o.template==null)o.template={triplesContext:o.pattern};for(var f=1,i=0;i1&&k.length>1){var d=[],c={},o;for(o in h[0])c[o]=!0;for(o in k[0])c[o]!=!0&&d.push(o);acum=[];duplicates={};for(h=0;h { ?s ?p ?o } } WHERE { GRAPH <"+e+"> { ?s ?p ?o } }",function(d){h=!d;b(u,c)})},function(){e(!h)})}else e(!1,"Error deleting named graphs")}else c==="all"?(d=this,this.execute("CLEAR DEFAULT",function(b,c){b?d.execute("CLEAR NAMED", -e):e(!1,c)})):c.token=="uri"?(c=w.lexicalFormBaseUri(c,b),c!=null?this.execute("DELETE { GRAPH <"+c+"> { ?s ?p ?o } } WHERE { GRAPH <"+c+"> { ?s ?p ?o } }",e):e(!1,"wrong graph URI")):e(!1,"wrong graph URI")};G.QueryEngine.prototype.checkGroupSemantics=function(c,b){if(c==="singleGroup")return!0;for(var e={},d=0;d ?p ?o } WHERE { GRAPH <"+b+"> { <"+c+"> ?p ?o } }",function(b,r){if(b){var v=!1,w=function(b,c){if(b==="eventsFlushed"&&v)v=!1,e(r);else if(b!=="eventsFlushed"){v=!0;for(var d=0;d1)d=c,e=b;else throw"An optional argument map and a callback must be provided"; -d.treeOrder==null&&(d.treeOrder=15);this.rdf=u.rdf;this.functionMap={};var f=this;new N.Lexicon(function(b){new ca.QuadBackend(d,function(c){d.backend=c;d.lexicon=b;f.engine=new G.QueryEngine(d);e&&e(f)})})};K.Store.prototype.execute=function(){if(arguments.length===3)this.executeWithEnvironment(arguments[0],arguments[1],arguments[2]);else if(arguments.length===4)this.executeWithEnvironment(arguments[0],arguments[1],arguments[2],arguments[3]);else{var c,b;arguments.length===1?(c=arguments[0],b=function(){}): -arguments.length===2&&(c=arguments[0],b=arguments[1]);this.engine.execute(c,b)}};K.Store.prototype.executeWithEnvironment=function(){var c,b,e,d;arguments.length===3?(c=arguments[0],b=function(){},e=arguments[1],d=arguments[2]):arguments.length===4&&(c=arguments[0],b=arguments[3],e=arguments[1],d=arguments[2]);this.engine.execute(c,b,e,d)};K.Store.prototype.graph=function(){var c=null,b=null;if(arguments.length===1)b=arguments[0]||function(){},c=this.engine.lexicon.defaultGraphUri;else if(arguments.length=== -2)b=arguments[1]||function(){},c=arguments[0];else throw"An optional graph URI and a callback function must be provided";this.rdf.resolve(c)!=null&&(c=this.rdf.resolve(c));this.engine.execute("CONSTRUCT { ?s ?p ?o } WHERE { GRAPH <"+c+"> { ?s ?p ?o } }",b)};K.Store.prototype.node=function(){var c=null,b=null,e=null;if(arguments.length===2)e=arguments[0],b=arguments[1]||function(){},c=this.engine.lexicon.defaultGraphUri;else if(arguments.length===3)e=arguments[0],c=arguments[1],b=arguments[2]||function(){}; -else throw"An optional graph URI and a callback function must be provided";this.rdf.resolve(c)!=null&&(c=this.rdf.resolve(c));this.rdf.resolve(e)!=null&&(e=this.rdf.resolve(e));this.engine.execute("CONSTRUCT { <"+e+"> ?p ?o } WHERE { GRAPH <"+c+"> { <"+e+"> ?p ?o } }",b)};K.Store.prototype.startObservingNode=function(){var c,b,e;arguments.length===2?(c=arguments[0],e=arguments[1],this.engine.callbacksBackend.observeNode(c,e,function(){})):arguments.length===3&&(c=arguments[0],b=arguments[1],e=arguments[2], -this.engine.callbacksBackend.observeNode(c,b,e,function(){}))};K.Store.prototype.stopObservingNode=function(c){this.engine.callbacksBackend.stopObservingNode(c)};K.Store.prototype.startObservingQuery=function(c,b,e){e!=null?this.engine.callbacksBackend.observeQuery(c,b,e):this.engine.callbacksBackend.observeQuery(c,b,function(){})};K.Store.prototype.stopObservingQuery=function(c){this.engine.callbacksBackend.stopObservingQuery(c)};K.Store.prototype.subscribe=function(c,b,e,d,f){var h=function(b,c){for(var d= -[],e={blanks:{},outCache:{}},h=[],w=0;w":"<"+c.valueOf()+">"}else return c.toString()};K.Store.prototype["delete"]=function(){var c, -b,e;if(arguments.length===1)b=arguments[0];else if(arguments.length===2)c=this.rdf.createNamedNode(this.engine.lexicon.defaultGraphUri),b=arguments[0],e=arguments[1]||function(){};else if(arguments.length===3)b=arguments[0],c=this.rdf.createNamedNode(arguments[1]),e=arguments[2]||function(){};else throw"The triples to delete, an optional graph and callback must be provided";var d="",f=this;b.forEach(function(b){d=d+f._nodeToQuery(b.subject)+f._nodeToQuery(b.predicate)+f._nodeToQuery(b.object)+"."}); -d=c!=null?"DELETE DATA { GRAPH "+this._nodeToQuery(c)+" { "+d+" } }":"DELETE DATA { "+this._nodeToQuery(c)+" { "+d+" }";this.engine.execute(d,e)};K.Store.prototype.clear=function(){var c,b;if(arguments.length===1)c=this.rdf.createNamedNode(this.engine.lexicon.defaultGraphUri),b=arguments[0]||function(){};else if(arguments.length===2)c=this.rdf.createNamedNode(arguments[0]),b=arguments[1]||function(){};else throw"The optional graph and a callback must be provided";this.engine.execute("CLEAR GRAPH "+ -this._nodeToQuery(c),b)};K.Store.prototype.load=function(){var c,b,e,d;if(arguments.length===3)e=this.rdf.createNamedNode(this.engine.lexicon.defaultGraphUri),c=arguments[0],b=arguments[1],d=arguments[2]||function(){};else if(arguments.length===4)c=arguments[0],b=arguments[1],e=this.rdf.createNamedNode(arguments[2]),d=arguments[3]||function(){};else if(arguments.length===2)throw"The mediaType of the parser, the data a callback and an optional graph must be provided";if(c==="remote")b=this.rdf.createNamedNode(b), -this.engine.execute("LOAD <"+b.valueOf()+"> INTO GRAPH <"+e.valueOf()+">",d);else if(b&&typeof b==="string"&&b.indexOf("file://")===0){c=this.engine.rdfLoader.parsers[c];var f=this;this.engine.rdfLoader.loadFromFile(c,{token:"uri",value:e.valueOf()},b,function(b,c){b?f.engine.batchLoad(c,d):d(b,c)})}else c=this.engine.rdfLoader.parsers[c],f=this,this.engine.rdfLoader.tryToParse(c,{token:"uri",value:e.valueOf()},b,function(b,c){b?f.engine.batchLoad(c,d):d(b,c)})};K.Store.prototype.registerParser=function(c, -b){this.engine.rdfLoader.registerParser(c,b)};K.Store.prototype.registeredGraphs=function(c){for(var b=this.engine.lexicon.registeredGraphs(!0),e=[],d=0;d":"<"+c.valueOf()+">"}else return c.toString()};K.Store.prototype.getNetworkTransport=function(){return ea};K.Store.prototype.setNetworkTransport= -function(c){ea=c};window.rdfstore=K})(window); +sig:"http://purl.org/signature#",ccard:"http://purl.org/commerce/creditcard#"},UrisMap:function(){this.defaultNs="";this.interfaceProperties=["get","remove","set","setDefault","addAll","resolve","shrink"]}};x.UrisMap.prototype.values=function(){var a={},c;for(c in this)!z.include(this.interfaceProperties,c)&&typeof this[c]!=="function"&&c!=="defaultNs"&&c!=="interfaceProperties"&&(a[c]=this[c]);return a};x.UrisMap.prototype.get=function(a){if(a.indexOf(" ")!=-1)throw"Prefix must not contain any whitespaces"; +return this[a]};x.UrisMap.prototype.remove=function(a){if(a.indexOf(" ")!=-1)throw"Prefix must not contain any whitespaces";delete this[a];return null};x.UrisMap.prototype.set=function(a,c){if(a.indexOf(" ")!=-1)throw"Prefix must not contain any whitespaces";this[a]=c};x.UrisMap.prototype.setDefault=function(a){this.defaultNs=a};x.UrisMap.prototype.addAll=function(a,c){for(var f in a)z.include(this.interfaceProperties,f)||(this[f]!=null?c===!0&&(this[f]=a[f]):this[f]=a[f]);return this};x.UrisMap.prototype.resolve= +function(a){var c=a.split(":"),a=c[0],c=c[1];return a===""?this.defaultNs==null?null:this.defaultNs+c:this[a]!=null?this[a]+c:null};x.UrisMap.prototype.shrink=function(a){for(var c in this){var f=this[c];if(a.indexOf(f)===0&&f!==""&&c!="defaultNs")return a=a.split(f)[1],c+":"+a}return a};x.Profile=function(){this.prefixes=new x.UrisMap;this.terms=new x.UrisMap};x.Profile.prototype.importProfile=function(a,c){this.prefixes.addAll(a.prefixes,c);this.terms.addAll(a.terms,c)};x.Profile.prototype.resolve= +function(a){return a.indexOf(":")!=-1?this.prefixes.resolve(a):this.terms[a]!=null?this.terms.resolve(a):null};x.Profile.prototype.setDefaultPrefix=function(a){this.prefixes.setDefault(a)};x.Profile.prototype.setDefaultVocabulary=function(a){this.terms.setDefault(a)};x.Profile.prototype.setPrefix=function(a,c){this.prefixes.set(a,c)};x.Profile.prototype.setTerm=function(a,c){this.terms.set(a,c)};x.RDFEnvironment=function(){this.blankNodeCounter=0;var a=this;this.filters={s:function(a){return function(c){return c.subject.equals(a)}}, +p:function(a){return function(c){return c.predicate.equals(a)}},o:function(a){return function(c){return c.object.equals(a)}},sp:function(a,c){return function(g){return g.subject.equals(a)&&g.predicate.equals(c)}},so:function(a,c){return function(g){return g.subject.equals(a)&&g.object.equals(c)}},po:function(a,c){return function(g){return g.predicate.equals(a)&&g.object.equals(c)}},spo:function(a,c,g){return function(j){return j.subject.equals(a)&&j.predicate.equals(c)&&j.object.equals(g)}},describes:function(a){return function(c){return c.subject.equals(a)|| +c.object.equals(a)}},type:function(c){var h=a.resolve("rdf:type");return function(a){return a.predicate.equals(h)&&a.object.equals(c)}}};for(var c in x.defaultContext)this.prefixes.set(c,x.defaultContext[c])};z["extends"](x.Profile,x.RDFEnvironment);x.RDFEnvironment.prototype.createBlankNode=function(){var a=new x.BlankNode(this.blankNodeCounter);this.blankNodeCounter++;return a};x.RDFEnvironment.prototype.createNamedNode=function(a){var c=this.resolve(a);return c!=null?new x.NamedNode(c):new x.NamedNode(a)}; +x.RDFEnvironment.prototype.createLiteral=function(a,c,f){return f!=null?new x.Literal(a,c,f.toString()):new x.Literal(a,c,f)};x.RDFEnvironment.prototype.createTriple=function(a,c,f){return new x.Triple(a,c,f)};x.RDFEnvironment.prototype.createGraph=function(a){var c=new x.Graph;if(a!=null)for(var f=0;f";return a};x.Literal.prototype.toNT=function(){return this.toString()};x.Literal.prototype.valueOf=function(){return g.effectiveTypeValue({token:"literal", +type:this.type,value:this.nominalValue,language:this.language})};x.NamedNode=function(a){x.RDFNode.call(this,"NamedNode");this.nominalValue=a.value!=null?a.value:a};z["extends"](x.RDFNode,x.NamedNode);x.NamedNode.prototype.toString=function(){return this.nominalValue};x.NamedNode.prototype.toNT=function(){return"<"+this.toString()+">"};x.NamedNode.prototype.valueOf=function(){return this.nominalValue};x.Triple=function(a,c,f){this.subject=a;this.predicate=c;this.object=f};x.Triple.prototype.equals= +function(a){return this.subject.equals(a.subject)&&this.predicate.equals(a.predicate)&&this.object.equals(a.object)};x.Triple.prototype.toString=function(){return this.subject.toNT()+" "+this.predicate.toNT()+" "+this.object.toNT()+" . \r\n"};x.Graph=function(){this.triples=[];this.duplicates={};this.actions=[]};x.Graph.prototype.add=function(a){for(var c=0;c")return g.runGtFunction(c,f,h);else if(a==="<=")return g.runLtEqFunction(c,f,h);else if(a===">=")return g.runGtEqFunction(c,f,h);else throw"Error applying relational filter, unknown operator";};g.effectiveTypeValue= +function(a){if(a.token=="literal")if(a.type=="http://www.w3.org/2001/XMLSchema#integer")return a=parseInt(a.value);else if(a.type=="http://www.w3.org/2001/XMLSchema#decimal")return a=parseFloat(a.value);else if(a.type=="http://www.w3.org/2001/XMLSchema#float")return a=parseFloat(a.value);else if(a.type=="http://www.w3.org/2001/XMLSchema#double")return a=parseFloat(a.value);else if(a.type=="http://www.w3.org/2001/XMLSchema#nonPositiveInteger")return a=parseFloat(a.value);else if(a.type=="http://www.w3.org/2001/XMLSchema#negativeInteger")return a= +parseInt(a.value);else if(a.type=="http://www.w3.org/2001/XMLSchema#long")return a=parseInt(a.value);else if(a.type=="http://www.w3.org/2001/XMLSchema#int")return a=parseInt(a.value);else if(a.type=="http://www.w3.org/2001/XMLSchema#short")return a=parseInt(a.value);else if(a.type=="http://www.w3.org/2001/XMLSchema#byte")return a=parseInt(a.value);else if(a.type=="http://www.w3.org/2001/XMLSchema#nonNegativeInteger")return a=parseInt(a.value);else if(a.type=="http://www.w3.org/2001/XMLSchema#unsignedLong")return a= +parseInt(a.value);else if(a.type=="http://www.w3.org/2001/XMLSchema#unsignedInt")return a=parseInt(a.value);else if(a.type=="http://www.w3.org/2001/XMLSchema#unsignedShort")return a=parseInt(a.value);else if(a.type=="http://www.w3.org/2001/XMLSchema#unsignedByte")return a=parseInt(a.value);else if(a.type=="http://www.w3.org/2001/XMLSchema#positiveInteger")return a=parseInt(a.value);else if(a.type=="http://www.w3.org/2001/XMLSchema#date"||a.type=="http://www.w3.org/2001/XMLSchema#dateTime")try{return z.parseISO8601(a.value)}catch(c){return null}else return a.type== +"http://www.w3.org/2001/XMLSchema#boolean"?a.value===!0||a.value==="true"||a.value==="1"||a.value===1||a.value===!0?!0:a.value===!1||a.value==="false"||a.value==="0"||a.value===0||a.value===!1?!1:void 0:a.type=="http://www.w3.org/2001/XMLSchema#string"?a.value===null||a.value===void 0?void 0:""+a.value:a.value;else throw console.log("not implemented yet"),"value not supported in operations yet";};g.runOrFunction=function(a,c,f,h,k){for(var j=null,i=0;ig.effectiveTypeValue(c));else if(g.isSimpleLiteral(a)&&g.isSimpleLiteral(c))return g.ebvBoolean(g.effectiveTypeValue(a)>g.effectiveTypeValue(c));else if(g.isXsdType("string",a)&&g.isXsdType("string",c))return g.ebvBoolean(g.effectiveTypeValue(a)>g.effectiveTypeValue(c));else if(g.isXsdType("boolean",a)&&g.isXsdType("boolean", +c))return g.ebvBoolean(g.effectiveTypeValue(a)>g.effectiveTypeValue(c));else if((g.isXsdType("dateTime",a)||g.isXsdType("date",a))&&(g.isXsdType("dateTime",c)||g.isXsdType("date",c))){if(g.isXsdType("dateTime",a)&&g.isXsdType("date",c))return g.ebvFalse();if(g.isXsdType("date",a)&&g.isXsdType("dateTime",c))return g.ebvFalse();var f=z.compareDateComponents(a.value,c.value);return f!=null?f==1?g.ebvTrue():g.ebvFalse():g.ebvError()}else return g.ebvFalse()};g.runTotalGtFunction=function(a,c){return g.isEbvError(a)|| +g.isEbvError(c)?g.ebvError():g.isNumeric(a)&&g.isNumeric(c)||g.isSimpleLiteral(a)&&g.isSimpleLiteral(c)||g.isXsdType("string",a)&&g.isSimpleLiteral("string",c)||g.isXsdType("boolean",a)&&g.isSimpleLiteral("boolean",c)||g.isXsdType("dateTime",a)&&g.isSimpleLiteral("dateTime",c)?g.runGtFunction(a,c,[]):a.token&&a.token==="uri"&&c.token&&c.token==="uri"?g.ebvBoolean(a.value>c.value):a.token&&a.token==="literal"&&c.token&&c.token==="literal"?g.ebvBoolean(""+a.value+a.type+a.lang>""+c.value+c.type+c.lang): +a.token&&a.token==="blank"&&c.token&&c.token==="blank"?g.ebvBoolean(a.value>c.value):a.value&&c.value?g.ebvBoolean(a.value>c.value):g.ebvTrue()};g.runLtFunction=function(a,c){if(g.isEbvError(a)||g.isEbvError(c))return g.ebvError();if(g.isNumeric(a)&&g.isNumeric(c))return g.ebvBoolean(g.effectiveTypeValue(a)=g.effectiveTypeValue(c));else if(g.isSimpleLiteral(a)&&g.isSimpleLiteral(c))return g.ebvBoolean(g.effectiveTypeValue(a)>=g.effectiveTypeValue(c));else if(g.isXsdType("string",a)&&g.isXsdType("string",c))return g.ebvBoolean(g.effectiveTypeValue(a)>=g.effectiveTypeValue(c)); +else if(g.isXsdType("boolean",a)&&g.isXsdType("boolean",c))return g.ebvBoolean(g.effectiveTypeValue(a)>=g.effectiveTypeValue(c));else if((g.isXsdType("dateTime",a)||g.isXsdType("date",a))&&(g.isXsdType("dateTime",c)||g.isXsdType("date",c))){if(g.isXsdType("dateTime",a)&&g.isXsdType("date",c))return g.ebvFalse();if(g.isXsdType("date",a)&&g.isXsdType("dateTime",c))return g.ebvFalse();var f=z.compareDateComponents(a.value,c.value);return f!=null?f!=-1?g.ebvTrue():g.ebvFalse():g.ebvError()}else return g.ebvFalse()}; +g.runLtEqFunction=function(a,c){if(g.isEbvError(a)||g.isEbvError(c))return g.ebvError();if(g.isNumeric(a)&&g.isNumeric(c))return g.ebvBoolean(g.effectiveTypeValue(a)<=g.effectiveTypeValue(c));else if(g.isSimpleLiteral(a)&&g.isSimpleLiteral(c))return g.ebvBoolean(g.effectiveTypeValue(a)<=g.effectiveTypeValue(c));else if(g.isXsdType("string",a)&&g.isXsdType("string",c))return g.ebvBoolean(g.effectiveTypeValue(a)<=g.effectiveTypeValue(c));else if(g.isXsdType("boolean",a)&&g.isXsdType("boolean",c))return g.ebvBoolean(g.effectiveTypeValue(a)<= +g.effectiveTypeValue(c));else if((g.isXsdType("dateTime",a)||g.isXsdType("date",a))&&(g.isXsdType("dateTime",c)||g.isXsdType("date",c))){if(g.isXsdType("dateTime",a)&&g.isXsdType("date",c))return g.ebvFalse();if(g.isXsdType("date",a)&&g.isXsdType("dateTime",c))return g.ebvFalse();var f=z.compareDateComponents(a.value,c.value);return f!=null?f!=1?g.ebvTrue():g.ebvFalse():g.ebvError()}else return g.ebvFalse()};g.runAddition=function(a,c,f,h,k,j){var i=g.runFilter(a,f,h,k,j);if(g.isEbvError(i))return g.ebvError(); +a=i;if(g.isNumeric(i)){for(i=0;i2)return g.ebvError();else if(i.value.split("-").length>2)return g.ebvError();else if(i.value.split("/").length>2)return g.ebvError();else if(i.value.split("+").length>2)return g.ebvError();if(a=="http://www.w3.org/2001/XMLSchema#decimal"&&(i.value.indexOf("e")!=-1||i.value.indexOf("E")!=-1))return g.ebvError();if(a=="http://www.w3.org/2001/XMLSchema#int"||a=="http://www.w3.org/2001/XMLSchema#integer")if(i.value.indexOf("e")!= +-1||i.value.indexOf("E")!=-1||i.value.indexOf(".")!=-1)return g.ebvError();try{return i.value=parseInt(parseFloat(i.value)),isNaN(i.value)?g.ebvError():(i.type=a,i)}catch(s){return g.ebvError()}}else return g.ebvError();else return g.ebvError();else if(a=="http://www.w3.org/2001/XMLSchema#boolean")return i=i[0],i.token==="literal"&&i.type==null?i.value==="true"||i.value==="1"?g.ebvTrue():i.value==="false"||i.value==="0"?g.ebvFalse():g.ebvError():i.token==="literal"?g.isEbvError(i)?i:g.ebvBoolean(i): +g.ebvError();else if(a=="http://www.w3.org/2001/XMLSchema#string")if(i=i[0],i.token==="literal")if(i=g.normalizeLiteralDatatype(i,h,j),i.type=="http://www.w3.org/2001/XMLSchema#integer"||i.type=="http://www.w3.org/2001/XMLSchema#decimal"||i.type=="http://www.w3.org/2001/XMLSchema#double"||i.type=="http://www.w3.org/2001/XMLSchema#nonPositiveInteger"||i.type=="http://www.w3.org/2001/XMLSchema#negativeInteger"||i.type=="http://www.w3.org/2001/XMLSchema#long"||i.type=="http://www.w3.org/2001/XMLSchema#int"|| +i.type=="http://www.w3.org/2001/XMLSchema#short"||i.type=="http://www.w3.org/2001/XMLSchema#byte"||i.type=="http://www.w3.org/2001/XMLSchema#nonNegativeInteger"||i.type=="http://www.w3.org/2001/XMLSchema#unsignedLong"||i.type=="http://www.w3.org/2001/XMLSchema#unsignedInt"||i.type=="http://www.w3.org/2001/XMLSchema#unsignedShort"||i.type=="http://www.w3.org/2001/XMLSchema#unsignedByte"||i.type=="http://www.w3.org/2001/XMLSchema#positiveInteger"||i.type=="http://www.w3.org/2001/XMLSchema#float")return i.type= +a,i.value=""+i.value,i;else if(i.type=="http://www.w3.org/2001/XMLSchema#string")return i;else if(i.type=="http://www.w3.org/2001/XMLSchema#boolean")return g.ebv(i)?(i.type=a,i.value="true"):(i.type=a,i.value="false"),i;else if(i.type=="http://www.w3.org/2001/XMLSchema#dateTime"||i.type=="http://www.w3.org/2001/XMLSchema#date"){i.type=a;if(typeof i.value!="string")i.value=z.iso8601(i.value);return i}else return i.type==null?(i.value=""+i.value,i.type=a,i):g.ebvError();else return i.token==="uri"? +{token:"literal",value:z.lexicalFormBaseUri(i,j),type:a,lang:null}:g.ebvError();else if(a=="http://www.w3.org/2001/XMLSchema#dateTime"||a=="http://www.w3.org/2001/XMLSchema#date")if(i=i[0],i.type=="http://www.w3.org/2001/XMLSchema#dateTime"||i.type=="http://www.w3.org/2001/XMLSchema#date")return i;else if(i.type=="http://www.w3.org/2001/XMLSchema#string"||i.type==null)try{return i.value=z.iso8601(z.parseStrictISO8601(i.value)),i.type=a,i}catch(v){return g.ebvError()}else return g.ebvError();else if(a== +"http://www.w3.org/2001/XMLSchema#float")if(i=i[0],i.token==="literal")if(i=g.normalizeLiteralDatatype(i,h,j),i.type=="http://www.w3.org/2001/XMLSchema#decimal"||i.type=="http://www.w3.org/2001/XMLSchema#int")return i.type=a,i.value=parseFloat(i.value),i;else if(i.type=="http://www.w3.org/2001/XMLSchema#boolean")return g.ebv(i)==!0?(i.type=a,i.value=1):(i.type=a,i.value=0),i;else if(i.type=="http://www.w3.org/2001/XMLSchema#float"||i.type=="http://www.w3.org/2001/XMLSchema#double")return i.type=a, +i.value=parseFloat(i.value),i;else if(i.type=="http://www.w3.org/2001/XMLSchema#string")try{return i.value=parseFloat(i.value),isNaN(i.value)?g.ebvError():(i.type=a,i)}catch(u){return g.ebvError()}else if(i.type==null){if(i.value.split(".").length>2)return g.ebvError();else if(i.value.split("-").length>2)return g.ebvError();else if(i.value.split("/").length>2)return g.ebvError();else if(i.value.split("+").length>2)return g.ebvError();try{return i.value=parseFloat(i.value),isNaN(i.value)?g.ebvError(): +(i.type=a,i)}catch(x){return g.ebvError()}}else return g.ebvError();else return g.ebvError();else return g.ebvError()}};var E={variablesInBGP:function(a){var c=a.variables;if(c)return c;var f=a.value||a,c=[];for(comp in f)f[comp]&&f[comp].token==="var"?c.push(f[comp].value):f[comp]&&f[comp].token==="blank"&&c.push("blank:"+f[comp].value);return a.variables=c},connected:function(a,c){for(var f="/"+a.vars.join("/")+"/",h=0;hu.cost)x=u}for(var N=2;N<=i.length;N++)for(var G=1;GH.cost&&(u===N&&(x=H),m[H.i]=H)}}a.push(x)}J=null;for(j=0;j0){for(var i=0;i0?c(!0,!0):c(!0,!1):c(!1,f):c(!1,f)});else if(m.kind==="construct")m.projection=[{token:"variable",kind:"*"}],j=this,this.executeSelect(m,i,f,h,function(a,f){if(a)if(a)if(f=j.denormalizeBindingsList(f,i),f!=null){var h=new x.Graph;if(m.template==null)m.template={triplesContext:m.pattern};for(var g=1,k=[],z=0;z1&&i.length>1){var f=[],h={}, +m;for(m in j[0])h[m]=!0;for(m in i[0])h[m]!=!0&&f.push(m);j=[];i={};for(h=0;h { ?s ?p ?o } } WHERE { GRAPH <"+f+"> { ?s ?p ?o } }",function(f){j=!f;a(v,c)})},function(){f(!j)})}else f(!1,"Error deleting named graphs")}else a==="all"?(h=this,this.execute("CLEAR DEFAULT",function(a,c){a?h.execute("CLEAR NAMED",f):f(!1,c)})):a.token=="uri"?(a=z.lexicalFormBaseUri(a,c),a!=null?this.execute("DELETE { GRAPH <"+ +a+"> { ?s ?p ?o } } WHERE { GRAPH <"+a+"> { ?s ?p ?o } }",f):f(!1,"wrong graph URI")):f(!1,"wrong graph URI")};D.QueryEngine.prototype.checkGroupSemantics=function(a,c){if(a==="singleGroup")return!0;for(var f={},h=0;h ?p ?o } WHERE { GRAPH <"+c+"> { <"+a+"> ?p ?o } }";var g=this,j={blanks:{},outCache:{}};this.engine.registerNsInEnvironment(null,j);var i=[];this.engine.execute(c,function(c,s){if(c){var v=!1,u=function(a,c){if(a==="eventsFlushed"&& +v)v=!1,f(s);else if(a!=="eventsFlushed"){v=!0;for(var h=0;h1)g=a,f=c;else throw"An optional argument map and a callback must be provided";g.treeOrder==null&&(g.treeOrder=15);this.functionMap={};var k=this;g.engine==="mongodb"?(this.isMongodb=!0,this.engine=new sb.MongodbQueryEngine(g),this.engine.readConfiguration(function(){g.overwrite===!0?k.engine.clean(function(){f(k)}): +f(k)})):new H.Lexicon(function(a){g.overwrite===!0&&a.clear();new V.QuadBackend(g,function(c){g.overwrite===!0&&c.clear();g.backend=c;g.lexicon=a;k.engine=new D.QueryEngine(g);f&&f(k)})},g.name)};C.Store.prototype.rdf=x.rdf;C.Store.prototype.execute=function(){if(arguments.length===3)this.executeWithEnvironment(arguments[0],arguments[1],arguments[2]);else if(arguments.length===4)this.executeWithEnvironment(arguments[0],arguments[1],arguments[2],arguments[3]);else{var a,c;arguments.length===1?(a=arguments[0], +c=function(){}):arguments.length===2&&(a=arguments[0],c=arguments[1]);this.engine.execute(a,c)}};C.Store.prototype.executeWithEnvironment=function(){var a,c,f;if(arguments.length===3){a=arguments[0];var g=function(){};c=arguments[1];f=arguments[2]}else arguments.length===4&&(a=arguments[0],g=arguments[3],c=arguments[1],f=arguments[2]);for(var k=[],j=[],i=0;i { ?s ?p ?o } }",c)};C.Store.prototype.node=function(){var a=null,c=null,f=null;if(arguments.length===2)f=arguments[0], +c=arguments[1]||function(){},a=this.engine.lexicon.defaultGraphUri;else if(arguments.length===3)f=arguments[0],a=arguments[1],c=arguments[2]||function(){};else throw"An optional graph URI, node URI and a callback function must be provided";this.rdf.resolve(a)!=null&&(a=this.rdf.resolve(a));this.rdf.resolve(f)!=null&&(f=this.rdf.resolve(f));this.engine.execute("CONSTRUCT { <"+f+"> ?p ?o } WHERE { GRAPH <"+a+"> { <"+f+"> ?p ?o } }",c)};C.Store.prototype.startObservingNode=function(){var a,c,f;arguments.length=== +2?(a=arguments[0],f=arguments[1],this.engine.callbacksBackend.observeNode(a,f,function(){})):arguments.length===3&&(a=arguments[0],c=arguments[1],f=arguments[2],this.engine.callbacksBackend.observeNode(a,c,f,function(){}))};C.Store.prototype.stopObservingNode=function(a){this.engine.callbacksBackend.stopObservingNode(a)};C.Store.prototype.startObservingQuery=function(a,c,f){f!=null?this.engine.callbacksBackend.observeQuery(a,c,f):this.engine.callbacksBackend.observeQuery(a,c,function(){})};C.Store.prototype.stopObservingQuery= +function(a){this.engine.callbacksBackend.stopObservingQuery(a)};C.Store.prototype.subscribe=function(a,c,f,g,k){var j=function(a,c){for(var f=[],g={blanks:{},outCache:{}},h=[],j=0;j":"<"+a.valueOf()+">"}else{if(a.interfaceName!=="")if(a.lang!=null)return'"'+a.valueOf()+'"@'+a.lang;else if(a.datatype!=null)return'"'+a.valueOf()+'"^^<'+a.datatype+">";return a.toString()}};C.Store.prototype["delete"]=function(){var a,c,f;if(arguments.length===1)c=arguments[0];else if(arguments.length===2)a=this.rdf.createNamedNode(this.engine.lexicon.defaultGraphUri),c=arguments[0],f=arguments[1]||function(){};else if(arguments.length=== +3)c=arguments[0],a=this.rdf.createNamedNode(arguments[1]),f=arguments[2]||function(){};else throw"The triples to delete, an optional graph and callback must be provided";var g="",k=this;c.forEach(function(a){g=g+k._nodeToQuery(a.subject)+k._nodeToQuery(a.predicate)+k._nodeToQuery(a.object)+"."});g=a!=null?"DELETE DATA { GRAPH "+this._nodeToQuery(a)+" { "+g+" } }":"DELETE DATA { "+this._nodeToQuery(a)+" { "+g+" }";this.engine.execute(g,f)};C.Store.prototype.clear=function(){var a,c;if(arguments.length=== +0)a=this.rdf.createNamedNode(this.engine.lexicon.defaultGraphUri),c=function(){};else if(arguments.length===1)a=this.rdf.createNamedNode(this.engine.lexicon.defaultGraphUri),c=arguments[0]||function(){};else if(arguments.length===2)a=this.rdf.createNamedNode(arguments[0]),c=arguments[1]||function(){};else throw"The optional graph and a callback must be provided";this.engine.execute("CLEAR GRAPH "+this._nodeToQuery(a),c)};C.Store.prototype.setBatchLoadEvents=function(a){this.engine.eventsOnBatchLoad= +a};C.Store.prototype.registerDefaultNamespace=function(a,c){this.rdf.prefixes.set(a,c);this.engine.registerDefaultNamespace(a,c)};C.Store.prototype.registerDefaultProfileNamespaces=function(){var a=this.rdf.prefixes.values(),c;for(c in a)this.registerDefaultNamespace(c,a[c])};C.Store.prototype.load=function(){var a,c,f,g;if(arguments.length===3)f=this.rdf.createNamedNode(this.engine.lexicon.defaultGraphUri),a=arguments[0],c=arguments[1],g=arguments[2]||function(){};else if(arguments.length===4)a= +arguments[0],c=arguments[1],f=this.rdf.createNamedNode(arguments[2]),g=arguments[3]||function(){};else if(arguments.length===2)throw"The mediaType of the parser, the data a callback and an optional graph must be provided";if(a==="remote")c=this.rdf.createNamedNode(c),this.engine.execute("LOAD <"+c.valueOf()+"> INTO GRAPH <"+f.valueOf()+">",g);else if(c&&typeof c==="string"&&c.indexOf("file://")===0){a=this.engine.rdfLoader.parsers[a];var k=this;this.engine.rdfLoader.loadFromFile(a,{token:"uri",value:f.valueOf()}, +c,function(a,c){a?k.engine.batchLoad(c,g):g(a,c)})}else a=this.engine.rdfLoader.parsers[a],k=this,this.engine.rdfLoader.tryToParse(a,{token:"uri",value:f.valueOf()},c,function(a,c){a?k.engine.batchLoad(c,g):g(a,c)})};C.Store.prototype.registerParser=function(a,c){this.engine.rdfLoader.registerParser(a,c)};C.Store.prototype.registeredGraphs=function(a){if(this.isMongodb)this.engine.registeredGraphs(!0,function(c){for(var f=[],g=0;g":"<"+a.valueOf()+">"}else return a.toString()};C.Store.prototype.getNetworkTransport=function(){return P};C.Store.prototype.setNetworkTransport=function(a){P=a};RDFStoreWorker={observingCallbacks:{},workerCallbacksCounter:0,workerCallbacks:{}}; +RDFStoreWorker.registerCallback=function(a){var c=""+RDFStoreWorker.workerCallbacksCounter;RDFStoreWorker.workerCallbacksCounter++;RDFStoreWorker.workerCallbacks[c]=a;return c};RDFStoreWorker.handleCreate=function(a,c){typeof P!="undefined"&&P!=null&&(P={load:function(a,c,g){var j=RDFStoreWorker.registerCallback(function(a){g.apply(g,a)});postMessage({fn:"workerRequest:NetworkTransport:load",callback:j,arguments:[a,c]})},loadFromFile:function(){}});args=[a];args.push(function(a){RDFStoreWorker.store= +a;postMessage({callback:c,result:"created",success:!0})});C.create.apply(C,args)};RDFStoreWorker.receive=function(a){var c=a.data||a;if(c.fn==="workerRequestResponse"){var f=c.callback,g=RDFStoreWorker.workerCallbacks[f];g!=null&&(delete RDFStoreWorker.workerCallbacks[f],g(c.results))}else if(c.fn==="create"&&c.args!=null)RDFStoreWorker.handleCreate(c.args,c.callback);else if(c.fn==="setBatchLoadEvents")RDFStoreWorker.store[c.fn].apply(RDFStoreWorker.store,c.args);else if(c.fn==="registerDefaultNamespace")RDFStoreWorker.store[c.fn].apply(RDFStoreWorker.store, +c.args);else if(c.fn==="registerDefaultProfileNamespaces")RDFStoreWorker.store[c.fn].apply(RDFStoreWorker.store,c.args);else if((c.fn==="execute"||c.fn==="executeWithEnvironment"||c.fn==="graph"||c.fn==="node"||c.fn==="clear"||c.fn==="load")&&c.args!=null){c.args.push(function(a,f){c.callback!=null&&postMessage({callback:c.callback,result:f,success:a})});try{RDFStoreWorker.store[c.fn].apply(RDFStoreWorker.store,c.args)}catch(k){console.log("Error executing method through connection"),console.log(k)}}else if((c.fn=== +"insert"||c.fn==="delete")&&c.args!=null)try{c.args.push(function(a,f){c.callback!=null&&postMessage({callback:c.callback,result:f,success:a})});g=c.args[0];for(a=0;a "+uri); + var uri; - if(uri == null) { + if(relValue != null) { + uri = relValue(); + uri = sko.NTUri(uri); + sko.log("*** OBSERVABLE READING RELATED DEPENDING NODE ABOT ID:"+nextId+" URI -> "+uri); + } else { sko.log(" ** NEXT URI IS NULL, GEN BLANK LABEL"); uri = sko.nextBlankLabel(); } @@ -976,20 +977,72 @@ sko.Resource.storeObserver = function(skoResource) { node.forEach(function(triple){ if(triple.object.interfaceName === 'NamedNode') { sko.log(" "+triple.predicate.toNT()+" -> "+triple.object.toNT()); - newValues[triple.predicate.toNT()] = triple.object.toNT(); + + if(newValues[triple.predicate.toNT()] != null) { + if(newValues[triple.predicate.toNT()].constructor === Array) { + // more than one, added to array. + // @todo what if named nodes and literals are mixed? + newValues[triple.predicate.toNT()].push(triple.object.toNT()); + newValues[triple.predicate.toNT()].sort(); + } else { + newValues[triple.predicate.toNT()] = [newValues[triple.predicate.toNT()], triple.object.toNT()]; + } + + } else { + newValues[triple.predicate.toNT()] = triple.object.toNT(); + } } else { if(skoResource.defaultLanguage() != null) { if(newValues[triple.predicate.toNT()] == null || triple.object.language == skoResource.defaultLanguage()) { - sko.log(" "+triple.predicate.toNT()+" -> "+triple.object.valueOf()); - newValues[triple.predicate.toNT()] = triple.object.valueOf(); - newValuesLangs[triple.predicate.toNT()] = triple.object.language; + if(newValues[triple.predicate.toNT()] != null) { + if(newValues[triple.predicate.toNT()].constructor === Array) { + // more than one, added to array. + // The value in the array cannot have a null lang + // @todo what if named nodes and literals are mixed? + newValues[triple.predicate.toNT()].push(triple.object.valueOf()); + newValues[triple.predicate.toNT()].sort(); + } else { + if(newValuesLangs[triple.predicate.toNT()] != triple.object.language) { + // replace old value (no lang) by a new value with lang + newValues[triple.predicate.toNT()] = triple.object.valueOf(); + newValuesLangs[triple.predicate.toNT()] = triple.object.language; + } else { + // last value was a single value with the correct lang -> now is an array + newValues[triple.predicate.toNT()] = [newValues[triple.predicate.toNT()], triple.object.valueOf()]; + } + } + } else { + // set up a default value, with null or correct lang + sko.log(" "+triple.predicate.toNT()+" -> "+triple.object.valueOf()); + newValues[triple.predicate.toNT()] = triple.object.valueOf(); + newValuesLangs[triple.predicate.toNT()] = triple.object.language; + } } } else { - if(newValues[triple.predicate.toNT()] == null || triple.object.language == null) { - sko.log(" "+triple.predicate.toNT()+" -> "+triple.object.valueOf()); - newValues[triple.predicate.toNT()] = triple.object.valueOf(); - newValuesLangs[triple.predicate.toNT()] = triple.object.language; - } + if(newValues[triple.predicate.toNT()] == null || triple.object.language == null) { + if(newValues[triple.predicate.toNT()] != null) { + if(newValues[triple.predicate.toNT()].constructor === Array) { + // more than one, added to array. + // @todo what if named nodes and literals are mixed? + newValues[triple.predicate.toNT()].push(triple.object.valueOf()); + newValues[triple.predicate.toNT()].sort(); + } else { + if(newValuesLangs[triple.predicate.toNT()] != null) { + // replace old value (with lang) by a new value with no lang + newValues[triple.predicate.toNT()] = triple.object.valueOf(); + newValuesLangs[triple.predicate.toNT()] = triple.object.language; + } else { + // last value was a single value with the correct lang -> now is an array + newValues[triple.predicate.toNT()] = [newValues[triple.predicate.toNT()], triple.object.valueOf()]; + } + + } + } else { + sko.log(" "+triple.predicate.toNT()+" -> "+triple.object.valueOf()); + newValues[triple.predicate.toNT()] = triple.object.valueOf(); + newValuesLangs[triple.predicate.toNT()] = triple.object.language; + } + } } } }); @@ -1003,12 +1056,21 @@ sko.Resource.storeObserver = function(skoResource) { for(var p in skoResource.valuesMap) { if(newValues[p] != null) { newValueMap[p] = newValues[p]; - if(skoResource.valuesMap[p] !== newValues[p]) { - toUpdate.push(p); - if(newValuesLangs[p] != null || skoResource.literalLangs[p] != null) { - skoResource.literalLangs[p] = newValuesLangs[p]; + if(skoResource.valuesMap[p] && + skoResource.valuesMap[p].constructor === Array && + newValue[p].constructor === Array) { + if(skoResource.valuesMap[p].length != newValue[p].length) { + // @todo check also the individual URIS + toUpdate.push(p); + } + } else { + if(skoResource.valuesMap[p] !== newValues[p]) { + toUpdate.push(p); + if(newValuesLangs[p] != null || skoResource.literalLangs[p] != null) { + skoResource.literalLangs[p] = newValuesLangs[p]; + } } - } + } } else { toNullify.push(p); delete skoResource.literalLangs[p]; diff --git a/src/binding/bindingAttributeSyntax.js b/src/binding/bindingAttributeSyntax.js index 4486e2c..958d2a9 100755 --- a/src/binding/bindingAttributeSyntax.js +++ b/src/binding/bindingAttributeSyntax.js @@ -8,7 +8,13 @@ var json = " { " + ko.jsonExpressionRewriting.insertPropertyReaderWritersIntoJson(attributeText) + " } "; return ko.utils.evalWithinScope(json, viewModel === null ? window : viewModel, node); } catch (ex) { - throw new Error("Unable to parse binding attribute.\nMessage: " + ex + ";\nAttribute value: " + attributeText); + if(typeof(console) !== 'undefined') { + console.log("!!! ERROR"); + console.log(attributeText); + console.log(ex); + } + //@modified + //throw new Error("Unable to parse binding attribute.\nMessage: " + ex + ";\nAttribute value: " + attributeText); } } diff --git a/src/binding/defaultBindings.js b/src/binding/defaultBindings.js index d045367..b69d633 100755 --- a/src/binding/defaultBindings.js +++ b/src/binding/defaultBindings.js @@ -409,7 +409,12 @@ ko.bindingHandlers['attr'] = { if ((attrValue === false) || (attrValue === null) || (attrValue === undefined)) element.removeAttribute(attrName); else - element.setAttribute(attrName, attrValue.toString()); + // @modified + var actualValue = attrValue.toString(); + if(actualValue[0] === '<' && actualValue[actualValue.length-1] === '>') { + actualValue = actualValue.substring(1,actualValue.length-1); + } + element.setAttribute(attrName, actualValue); } } } diff --git a/src/binding/jsonExpressionRewriting.js b/src/binding/jsonExpressionRewriting.js index b5e5a24..24f6d61 100644 --- a/src/binding/jsonExpressionRewriting.js +++ b/src/binding/jsonExpressionRewriting.js @@ -109,6 +109,30 @@ ko.jsonExpressionRewriting = (function () { return jsonString; }, + //@modified + parseURIsInJSONString: function(jsonString) { + var re = /["']?(<|\[)[a-z:\/.#?&%]+(\]|>)['"]?/g; + var acum = ""; + var found = re.exec(jsonString); + while(found != null) { + if((found[0][0] === "'" || found[0][0] === '"') && + (found[0][found[0].length-1] === "'" || found[0][found[0].length-1] === '"')) { + var parts = jsonString.split(found[0]); + acum = acum + parts[0] + found[0]; + jsonString = parts[1]; + } else { + var w = found[0]; + var index = found.index; + var pref = jsonString.substring(0,index); + acum = pref+"sko.current().tryProperty('"+w+"')"; + jsonString= jsonString.substring(index+w.length); + } + found = re.exec(jsonString); + } + + return acum+jsonString; + }, + insertPropertyReaderWritersIntoJson: function (jsonString) { var parsed = ko.jsonExpressionRewriting.parseJson(jsonString); var propertyAccessorTokens = []; @@ -116,6 +140,8 @@ ko.jsonExpressionRewriting = (function () { var isFirst = true; for (var key in parsed) { var value = parsed[key]; + + value = this.parseURIsInJSONString(value); if (isWriteableValue(value)) { if (propertyAccessorTokens.length > 0) propertyAccessorTokens.push(", "); diff --git a/src/templating/templating.js b/src/templating/templating.js index 2e26b6c..d38f8ee 100644 --- a/src/templating/templating.js +++ b/src/templating/templating.js @@ -83,9 +83,24 @@ ko.renderTemplateForEach = function (template, arrayOrObservableArray, options, targetNode) { return new ko.dependentObservable(function () { var unwrappedArray = ko.utils.unwrapObservable(arrayOrObservableArray) || []; - if (typeof unwrappedArray.length == "undefined") // Coerce single value into array + + // @modified + if (unwrappedArray.constructor != Array) // Coerce single value into array unwrappedArray = [unwrappedArray]; + // @modified + // wrapping automatically non objects + for(var i=0; i elements which are not normally allowed to exist on their own. // If you've referenced jQuery we'll use that rather than duplicating its code. if (typeof jQuery != 'undefined') { - jQuery(node)['html'](html); + try { + jQuery(node)['html'](html); + } catch (x) { + jQuery(node)['html'](html.replace("<","<").replace(">",">")); + } } else { // ... otherwise, use KO's own parsing logic. var parsedNodes = ko.utils.parseHtmlFragment(html); diff --git a/tests/index.html b/tests/index.html index 893372e..d516dda 100644 --- a/tests/index.html +++ b/tests/index.html @@ -7,7 +7,7 @@ - + diff --git a/tests/tests.js b/tests/tests.js index 3c9abdd..41170c0 100644 --- a/tests/tests.js +++ b/tests/tests.js @@ -200,7 +200,6 @@ asyncTest('simple related',function(){ }); }); - asyncTest('related binding with model',function(){ var testData = "INSERT DATA { 'a resource' . \ .\ @@ -225,7 +224,6 @@ asyncTest('related binding with model',function(){ }); }); - asyncTest('changing subject of related',function(){ var testData = "INSERT DATA { 'a resource' . \ .\ @@ -476,7 +474,7 @@ asyncTest('generator where',function(){ asyncTest('testing simple binding with model and language',function(){ var testData = "INSERT DATA { 'a resource'@en .\ - 'un recurso'@es }"; + 'un recurso'@es }"; var viewModel = {'currentResource': ''}; jQuery(document).ready(function(){ @@ -713,4 +711,4 @@ asyncTest('testing bindings inside templates', function() { }); }); }); -}); +}); \ No newline at end of file