UNPKG

perfectkb-yate

Version:

Yet Another Turtle Editor, forked from YASQE

1,446 lines (1,338 loc) 244 kB
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.YATE = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){ "use strict"; /* jQuery deparam is an extraction of the deparam method from Ben Alman's jQuery BBQ http://benalman.com/projects/jquery-bbq-plugin/ */ var $ = (function(){try{return require('jquery')}catch(e){return window.jQuery}})(); $.deparam = function(params, coerce) { var obj = {}, coerce_types = { true: !0, false: !1, null: null }; // Iterate over all name=value pairs. $.each(params.replace(/\+/g, " ").split("&"), function(j, v) { var param = v.split("="), key = decodeURIComponent(param[0]), val, cur = obj, i = 0, // If key is more complex than 'foo', like 'a[]' or 'a[b][c]', split it // into its component parts. keys = key.split("]["), keys_last = keys.length - 1; // If the first keys part contains [ and the last ends with ], then [] // are correctly balanced. if (/\[/.test(keys[0]) && /\]$/.test(keys[keys_last])) { // Remove the trailing ] from the last keys part. keys[keys_last] = keys[keys_last].replace(/\]$/, ""); // Split first keys part into two parts on the [ and add them back onto // the beginning of the keys array. keys = keys.shift().split("[").concat(keys); keys_last = keys.length - 1; } else { // Basic 'foo' style key. keys_last = 0; } // Are we dealing with a name=value pair, or just a name? if (param.length === 2) { val = decodeURIComponent(param[1]); // Coerce values. if (coerce) { val = val && !isNaN(val) ? +val // number : val === "undefined" ? undefined // undefined : coerce_types[val] !== undefined ? coerce_types[val] // true, false, null : val; // string } if (keys_last) { // Complex key, build deep object structure based on a few rules: // * The 'cur' pointer starts at the object top-level. // * [] = array push (n is set to array length), [n] = array if n is // numeric, otherwise object. // * If at the last keys part, set the value. // * For each keys part, if the current level is undefined create an // object or array based on the type of the next keys part. // * Move the 'cur' pointer to the next level. // * Rinse & repeat. for (; i <= keys_last; i++) { key = keys[i] === "" ? cur.length : keys[i]; cur = cur[key] = i < keys_last ? cur[key] || (keys[i + 1] && isNaN(keys[i + 1]) ? {} : []) : val; } } else { // Simple key, even simpler rules, since only scalars and shallow // arrays are allowed. if ($.isArray(obj[key])) { // val is already an array, so push on the next value. obj[key].push(val); } else if (obj[key] !== undefined) { // val isn't an array, but since a second value has been specified, // convert val into an array. obj[key] = [obj[key], val]; } else { // val is a scalar. obj[key] = val; } } } else if (key) { // No value was defined, so set something meaningful. obj[key] = coerce ? undefined : ""; } }); return obj; }; },{"jquery":undefined}],2:[function(require,module,exports){ module.exports = {table: { "*[,,object]" : { ",": ["[,,object]","*[,,object]"], ";": [], "]": [], ".": []}, "*[;,?[verb,objectList]]" : { ";": ["[;,?[verb,objectList]]","*[;,?[verb,objectList]]"], "]": [], ".": []}, "*object" : { "IRI_REF": ["object","*object"], "BLANK_NODE_LABEL": ["object","*object"], "ANON": ["object","*object"], "NIL": ["object","*object"], "(": ["object","*object"], "[": ["object","*object"], "PNAME_LN": ["object","*object"], "PNAME_NS": ["object","*object"], "INTEGER": ["object","*object"], "DECIMAL": ["object","*object"], "DOUBLE": ["object","*object"], "true": ["object","*object"], "false": ["object","*object"], "STRING_LITERAL_QUOTE": ["object","*object"], "STRING_LITERAL_SINGLE_QUOTE": ["object","*object"], "STRING_LITERAL_LONG_SINGLE_QUOTE": ["object","*object"], "STRING_LITERAL_LONG_QUOTE": ["object","*object"], ")": []}, "*statement" : { "@prefix": ["statement","*statement"], "@base": ["statement","*statement"], "PREFIX": ["statement","*statement"], "BASE": ["statement","*statement"], "[": ["statement","*statement"], "IRI_REF": ["statement","*statement"], "BLANK_NODE_LABEL": ["statement","*statement"], "ANON": ["statement","*statement"], "NIL": ["statement","*statement"], "(": ["statement","*statement"], "PNAME_LN": ["statement","*statement"], "PNAME_NS": ["statement","*statement"], "$": []}, "?[verb,objectList]" : { "a": ["[verb,objectList]"], "IRI_REF": ["[verb,objectList]"], "PNAME_LN": ["[verb,objectList]"], "PNAME_NS": ["[verb,objectList]"], ";": [], "]": [], ".": []}, "?or([LANGTAG,[^^,iri]])" : { "LANGTAG": ["or([LANGTAG,[^^,iri]])"], "^^": ["or([LANGTAG,[^^,iri]])"], ";": [], ",": [], "IRI_REF": [], "BLANK_NODE_LABEL": [], "ANON": [], "NIL": [], "(": [], "[": [], "PNAME_LN": [], "PNAME_NS": [], "INTEGER": [], "DECIMAL": [], "DOUBLE": [], "true": [], "false": [], "STRING_LITERAL_QUOTE": [], "STRING_LITERAL_SINGLE_QUOTE": [], "STRING_LITERAL_LONG_SINGLE_QUOTE": [], "STRING_LITERAL_LONG_QUOTE": [], "]": [], ")": [], ".": []}, "?predicateObjectList" : { "a": ["predicateObjectList"], "IRI_REF": ["predicateObjectList"], "PNAME_LN": ["predicateObjectList"], "PNAME_NS": ["predicateObjectList"], ".": []}, "[,,object]" : { ",": [",","object"]}, "[;,?[verb,objectList]]" : { ";": [";","?[verb,objectList]"]}, "[^^,iri]" : { "^^": ["^^","iri"]}, "[blankNodePropertyList,?predicateObjectList]" : { "[": ["blankNodePropertyList","?predicateObjectList"]}, "[storeProperty,a]" : { "a": ["storeProperty","a"]}, "[storeProperty,predicate]" : { "IRI_REF": ["storeProperty","predicate"], "PNAME_LN": ["storeProperty","predicate"], "PNAME_NS": ["storeProperty","predicate"]}, "[subject,predicateObjectList]" : { "IRI_REF": ["subject","predicateObjectList"], "BLANK_NODE_LABEL": ["subject","predicateObjectList"], "ANON": ["subject","predicateObjectList"], "NIL": ["subject","predicateObjectList"], "(": ["subject","predicateObjectList"], "PNAME_LN": ["subject","predicateObjectList"], "PNAME_NS": ["subject","predicateObjectList"]}, "[triples,.]" : { "[": ["triples","."], "IRI_REF": ["triples","."], "BLANK_NODE_LABEL": ["triples","."], "ANON": ["triples","."], "NIL": ["triples","."], "(": ["triples","."], "PNAME_LN": ["triples","."], "PNAME_NS": ["triples","."]}, "[verb,objectList]" : { "a": ["verb","objectList"], "IRI_REF": ["verb","objectList"], "PNAME_LN": ["verb","objectList"], "PNAME_NS": ["verb","objectList"]}, "base" : { "@base": ["@base","IRI_REF","."]}, "blankNode" : { "BLANK_NODE_LABEL": ["or([BLANK_NODE_LABEL,ANON])"], "ANON": ["or([BLANK_NODE_LABEL,ANON])"]}, "blankNodePropertyList" : { "[": ["[","predicateObjectList","]"]}, "booleanLiteral" : { "true": ["or([true,false])"], "false": ["or([true,false])"]}, "collection" : { "NIL": ["NIL"], "(": ["(","*object",")"]}, "directive" : { "@prefix": ["or([prefixID,base,sparqlPrefix,sparqlBase])"], "@base": ["or([prefixID,base,sparqlPrefix,sparqlBase])"], "PREFIX": ["or([prefixID,base,sparqlPrefix,sparqlBase])"], "BASE": ["or([prefixID,base,sparqlPrefix,sparqlBase])"]}, "iri" : { "IRI_REF": ["or([IRI_REF,prefixedName])"], "PNAME_LN": ["or([IRI_REF,prefixedName])"], "PNAME_NS": ["or([IRI_REF,prefixedName])"]}, "literal" : { "INTEGER": ["or([rdfLiteral,numericLiteral,booleanLiteral])"], "DECIMAL": ["or([rdfLiteral,numericLiteral,booleanLiteral])"], "DOUBLE": ["or([rdfLiteral,numericLiteral,booleanLiteral])"], "true": ["or([rdfLiteral,numericLiteral,booleanLiteral])"], "false": ["or([rdfLiteral,numericLiteral,booleanLiteral])"], "STRING_LITERAL_QUOTE": ["or([rdfLiteral,numericLiteral,booleanLiteral])"], "STRING_LITERAL_SINGLE_QUOTE": ["or([rdfLiteral,numericLiteral,booleanLiteral])"], "STRING_LITERAL_LONG_SINGLE_QUOTE": ["or([rdfLiteral,numericLiteral,booleanLiteral])"], "STRING_LITERAL_LONG_QUOTE": ["or([rdfLiteral,numericLiteral,booleanLiteral])"]}, "numericLiteral" : { "INTEGER": ["or([INTEGER,DECIMAL,DOUBLE])"], "DECIMAL": ["or([INTEGER,DECIMAL,DOUBLE])"], "DOUBLE": ["or([INTEGER,DECIMAL,DOUBLE])"]}, "object" : { "IRI_REF": ["or([iri,blankNode,collection,blankNodePropertyList,literal])"], "BLANK_NODE_LABEL": ["or([iri,blankNode,collection,blankNodePropertyList,literal])"], "ANON": ["or([iri,blankNode,collection,blankNodePropertyList,literal])"], "NIL": ["or([iri,blankNode,collection,blankNodePropertyList,literal])"], "(": ["or([iri,blankNode,collection,blankNodePropertyList,literal])"], "[": ["or([iri,blankNode,collection,blankNodePropertyList,literal])"], "PNAME_LN": ["or([iri,blankNode,collection,blankNodePropertyList,literal])"], "PNAME_NS": ["or([iri,blankNode,collection,blankNodePropertyList,literal])"], "INTEGER": ["or([iri,blankNode,collection,blankNodePropertyList,literal])"], "DECIMAL": ["or([iri,blankNode,collection,blankNodePropertyList,literal])"], "DOUBLE": ["or([iri,blankNode,collection,blankNodePropertyList,literal])"], "true": ["or([iri,blankNode,collection,blankNodePropertyList,literal])"], "false": ["or([iri,blankNode,collection,blankNodePropertyList,literal])"], "STRING_LITERAL_QUOTE": ["or([iri,blankNode,collection,blankNodePropertyList,literal])"], "STRING_LITERAL_SINGLE_QUOTE": ["or([iri,blankNode,collection,blankNodePropertyList,literal])"], "STRING_LITERAL_LONG_SINGLE_QUOTE": ["or([iri,blankNode,collection,blankNodePropertyList,literal])"], "STRING_LITERAL_LONG_QUOTE": ["or([iri,blankNode,collection,blankNodePropertyList,literal])"]}, "objectList" : { "IRI_REF": ["object","*[,,object]"], "BLANK_NODE_LABEL": ["object","*[,,object]"], "ANON": ["object","*[,,object]"], "NIL": ["object","*[,,object]"], "(": ["object","*[,,object]"], "[": ["object","*[,,object]"], "PNAME_LN": ["object","*[,,object]"], "PNAME_NS": ["object","*[,,object]"], "INTEGER": ["object","*[,,object]"], "DECIMAL": ["object","*[,,object]"], "DOUBLE": ["object","*[,,object]"], "true": ["object","*[,,object]"], "false": ["object","*[,,object]"], "STRING_LITERAL_QUOTE": ["object","*[,,object]"], "STRING_LITERAL_SINGLE_QUOTE": ["object","*[,,object]"], "STRING_LITERAL_LONG_SINGLE_QUOTE": ["object","*[,,object]"], "STRING_LITERAL_LONG_QUOTE": ["object","*[,,object]"]}, "or([BLANK_NODE_LABEL,ANON])" : { "BLANK_NODE_LABEL": ["BLANK_NODE_LABEL"], "ANON": ["ANON"]}, "or([INTEGER,DECIMAL,DOUBLE])" : { "INTEGER": ["INTEGER"], "DECIMAL": ["DECIMAL"], "DOUBLE": ["DOUBLE"]}, "or([IRI_REF,prefixedName])" : { "IRI_REF": ["IRI_REF"], "PNAME_LN": ["prefixedName"], "PNAME_NS": ["prefixedName"]}, "or([LANGTAG,[^^,iri]])" : { "LANGTAG": ["LANGTAG"], "^^": ["[^^,iri]"]}, "or([PNAME_LN,PNAME_NS])" : { "PNAME_LN": ["PNAME_LN"], "PNAME_NS": ["PNAME_NS"]}, "or([[storeProperty,predicate],[storeProperty,a]])" : { "IRI_REF": ["[storeProperty,predicate]"], "PNAME_LN": ["[storeProperty,predicate]"], "PNAME_NS": ["[storeProperty,predicate]"], "a": ["[storeProperty,a]"]}, "or([[subject,predicateObjectList],[blankNodePropertyList,?predicateObjectList]])" : { "IRI_REF": ["[subject,predicateObjectList]"], "BLANK_NODE_LABEL": ["[subject,predicateObjectList]"], "ANON": ["[subject,predicateObjectList]"], "NIL": ["[subject,predicateObjectList]"], "(": ["[subject,predicateObjectList]"], "PNAME_LN": ["[subject,predicateObjectList]"], "PNAME_NS": ["[subject,predicateObjectList]"], "[": ["[blankNodePropertyList,?predicateObjectList]"]}, "or([directive,[triples,.]])" : { "@prefix": ["directive"], "@base": ["directive"], "PREFIX": ["directive"], "BASE": ["directive"], "[": ["[triples,.]"], "IRI_REF": ["[triples,.]"], "BLANK_NODE_LABEL": ["[triples,.]"], "ANON": ["[triples,.]"], "NIL": ["[triples,.]"], "(": ["[triples,.]"], "PNAME_LN": ["[triples,.]"], "PNAME_NS": ["[triples,.]"]}, "or([iri,blankNode,collection,blankNodePropertyList,literal])" : { "IRI_REF": ["iri"], "PNAME_LN": ["iri"], "PNAME_NS": ["iri"], "BLANK_NODE_LABEL": ["blankNode"], "ANON": ["blankNode"], "NIL": ["collection"], "(": ["collection"], "[": ["blankNodePropertyList"], "INTEGER": ["literal"], "DECIMAL": ["literal"], "DOUBLE": ["literal"], "true": ["literal"], "false": ["literal"], "STRING_LITERAL_QUOTE": ["literal"], "STRING_LITERAL_SINGLE_QUOTE": ["literal"], "STRING_LITERAL_LONG_SINGLE_QUOTE": ["literal"], "STRING_LITERAL_LONG_QUOTE": ["literal"]}, "or([iri,blankNode,collection])" : { "IRI_REF": ["iri"], "PNAME_LN": ["iri"], "PNAME_NS": ["iri"], "BLANK_NODE_LABEL": ["blankNode"], "ANON": ["blankNode"], "NIL": ["collection"], "(": ["collection"]}, "or([prefixID,base,sparqlPrefix,sparqlBase])" : { "@prefix": ["prefixID"], "@base": ["base"], "PREFIX": ["sparqlPrefix"], "BASE": ["sparqlBase"]}, "or([rdfLiteral,numericLiteral,booleanLiteral])" : { "STRING_LITERAL_QUOTE": ["rdfLiteral"], "STRING_LITERAL_SINGLE_QUOTE": ["rdfLiteral"], "STRING_LITERAL_LONG_SINGLE_QUOTE": ["rdfLiteral"], "STRING_LITERAL_LONG_QUOTE": ["rdfLiteral"], "INTEGER": ["numericLiteral"], "DECIMAL": ["numericLiteral"], "DOUBLE": ["numericLiteral"], "true": ["booleanLiteral"], "false": ["booleanLiteral"]}, "or([true,false])" : { "true": ["true"], "false": ["false"]}, "predicate" : { "IRI_REF": ["iri"], "PNAME_LN": ["iri"], "PNAME_NS": ["iri"]}, "predicateObjectList" : { "a": ["verb","objectList","*[;,?[verb,objectList]]"], "IRI_REF": ["verb","objectList","*[;,?[verb,objectList]]"], "PNAME_LN": ["verb","objectList","*[;,?[verb,objectList]]"], "PNAME_NS": ["verb","objectList","*[;,?[verb,objectList]]"]}, "prefixID" : { "@prefix": ["@prefix","PNAME_NS","IRI_REF","."]}, "prefixedName" : { "PNAME_LN": ["or([PNAME_LN,PNAME_NS])"], "PNAME_NS": ["or([PNAME_LN,PNAME_NS])"]}, "rdfLiteral" : { "STRING_LITERAL_QUOTE": ["string","?or([LANGTAG,[^^,iri]])"], "STRING_LITERAL_SINGLE_QUOTE": ["string","?or([LANGTAG,[^^,iri]])"], "STRING_LITERAL_LONG_SINGLE_QUOTE": ["string","?or([LANGTAG,[^^,iri]])"], "STRING_LITERAL_LONG_QUOTE": ["string","?or([LANGTAG,[^^,iri]])"]}, "sparqlBase" : { "BASE": ["BASE","IRI_REF"]}, "sparqlPrefix" : { "PREFIX": ["PREFIX","PNAME_NS","IRI_REF"]}, "statement" : { "@prefix": ["or([directive,[triples,.]])"], "@base": ["or([directive,[triples,.]])"], "PREFIX": ["or([directive,[triples,.]])"], "BASE": ["or([directive,[triples,.]])"], "[": ["or([directive,[triples,.]])"], "IRI_REF": ["or([directive,[triples,.]])"], "BLANK_NODE_LABEL": ["or([directive,[triples,.]])"], "ANON": ["or([directive,[triples,.]])"], "NIL": ["or([directive,[triples,.]])"], "(": ["or([directive,[triples,.]])"], "PNAME_LN": ["or([directive,[triples,.]])"], "PNAME_NS": ["or([directive,[triples,.]])"]}, "storeProperty" : { "IRI_REF": [], "PNAME_LN": [], "PNAME_NS": [], "a": []}, "string" : { "STRING_LITERAL_QUOTE": ["STRING_LITERAL_QUOTE"], "STRING_LITERAL_SINGLE_QUOTE": ["STRING_LITERAL_SINGLE_QUOTE"], "STRING_LITERAL_LONG_SINGLE_QUOTE": ["STRING_LITERAL_LONG_SINGLE_QUOTE"], "STRING_LITERAL_LONG_QUOTE": ["STRING_LITERAL_LONG_QUOTE"]}, "subject" : { "IRI_REF": ["or([iri,blankNode,collection])"], "BLANK_NODE_LABEL": ["or([iri,blankNode,collection])"], "ANON": ["or([iri,blankNode,collection])"], "NIL": ["or([iri,blankNode,collection])"], "(": ["or([iri,blankNode,collection])"], "PNAME_LN": ["or([iri,blankNode,collection])"], "PNAME_NS": ["or([iri,blankNode,collection])"]}, "triples" : { "[": ["or([[subject,predicateObjectList],[blankNodePropertyList,?predicateObjectList]])"], "IRI_REF": ["or([[subject,predicateObjectList],[blankNodePropertyList,?predicateObjectList]])"], "BLANK_NODE_LABEL": ["or([[subject,predicateObjectList],[blankNodePropertyList,?predicateObjectList]])"], "ANON": ["or([[subject,predicateObjectList],[blankNodePropertyList,?predicateObjectList]])"], "NIL": ["or([[subject,predicateObjectList],[blankNodePropertyList,?predicateObjectList]])"], "(": ["or([[subject,predicateObjectList],[blankNodePropertyList,?predicateObjectList]])"], "PNAME_LN": ["or([[subject,predicateObjectList],[blankNodePropertyList,?predicateObjectList]])"], "PNAME_NS": ["or([[subject,predicateObjectList],[blankNodePropertyList,?predicateObjectList]])"]}, "turtleDoc" : { "$": ["*statement","$"], "@prefix": ["*statement","$"], "@base": ["*statement","$"], "PREFIX": ["*statement","$"], "BASE": ["*statement","$"], "[": ["*statement","$"], "IRI_REF": ["*statement","$"], "BLANK_NODE_LABEL": ["*statement","$"], "ANON": ["*statement","$"], "NIL": ["*statement","$"], "(": ["*statement","$"], "PNAME_LN": ["*statement","$"], "PNAME_NS": ["*statement","$"]}, "verb" : { "a": ["or([[storeProperty,predicate],[storeProperty,a]])"], "IRI_REF": ["or([[storeProperty,predicate],[storeProperty,a]])"], "PNAME_LN": ["or([[storeProperty,predicate],[storeProperty,a]])"], "PNAME_NS": ["or([[storeProperty,predicate],[storeProperty,a]])"]} }, keywords:/^(BASE|PREFIX)/i , punct:/^(a|\.|,|\(|\)|;|\[|\]|\^\^)/ , startSymbol:"turtleDoc", acceptEmpty:true, } },{}],3:[function(require,module,exports){ "use strict"; var CodeMirror = (function(){try{return require('codemirror')}catch(e){return window.CodeMirror}})(); CodeMirror.defineMode("rdf11turtle", function(config, parserConfig) { var indentUnit = config.indentUnit; var grammar = require("./_tokenizer-table.js"); var ll1_table = grammar.table; var IRI_REF = '<[^<>"`\|\{\}\^\\\x00-\x20]*>'; /* * PN_CHARS_BASE = * '[A-Z]|[a-z]|[\\u00C0-\\u00D6]|[\\u00D8-\\u00F6]|[\\u00F8-\\u02FF]|[\\u0370-\\u037D]|[\\u037F-\\u1FFF]|[\\u200C-\\u200D]|[\\u2070-\\u218F]|[\\u2C00-\\u2FEF]|[\\u3001-\\uD7FF]|[\\uF900-\\uFDCF]|[\\uFDF0-\\uFFFD]|[\\u10000-\\uEFFFF]'; */ var PN_CHARS_BASE = "[A-Za-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD]"; var PN_CHARS_U = PN_CHARS_BASE + "|_"; var PN_CHARS = "(" + PN_CHARS_U + "|-|[0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040])"; var VARNAME = "(" + PN_CHARS_U + "|[0-9])" + "(" + PN_CHARS_U + "|[0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040])*"; var VAR1 = "\\?" + VARNAME; var VAR2 = "\\$" + VARNAME; var PN_PREFIX = "(" + PN_CHARS_BASE + ")(((" + PN_CHARS + ")|\\.)*(" + PN_CHARS + "))?"; var HEX = "[0-9A-Fa-f]"; var PERCENT = "(%" + HEX + HEX + ")"; var PN_LOCAL_ESC = "(\\\\[_~\\.\\-!\\$&'\\(\\)\\*\\+,;=/\\?#@%])"; var PLX = "(" + PERCENT + "|" + PN_LOCAL_ESC + ")"; var PN_LOCAL = "(" + PN_CHARS_U + "|:|[0-9]|" + PLX + ")((" + PN_CHARS + "|\\.|:|" + PLX + ")*(" + PN_CHARS + "|:|" + PLX + "))?"; var BLANK_NODE_LABEL = "_:(" + PN_CHARS_U + "|[0-9])((" + PN_CHARS + "|\\.)*" + PN_CHARS + ")?"; var PNAME_NS = "(" + PN_PREFIX + ")?:"; var PNAME_LN = PNAME_NS + PN_LOCAL; var LANGTAG = "@[a-zA-Z]+(-[a-zA-Z0-9]+)*"; var EXPONENT = "[eE][\\+-]?[0-9]+"; var INTEGER = "[-\\+]?[0-9]+"; var DECIMAL = "[-\\+]?(([0-9]+\\.[0-9]*)|(\\.[0-9]+))"; var DOUBLE = "[-\\+]?(([0-9]+\\.[0-9]*" + EXPONENT + ")|" + "(\\.[0-9]+" + EXPONENT + ")|" + "([0-9]+" + EXPONENT + "))"; var ECHAR = "\\\\[tbnrf\\\\\"']"; //IMPORTANT: this unicode rule is not in the official grammar. //Reason: https://github.com/YASGUI/YASQE/issues/49 //unicode escape sequences (which the sparql spec considers part of the pre-processing of sparql queries) //are marked as invalid. We have little choice (other than adding a layer of complixity) than to modify the grammar accordingly //however, for now only allow these escape sequences in literals (where actually, this should be allows in e.g. prefixes as well) var hex4 = HEX + "{4}"; var unicode = "(\\\\u" + hex4 + "|\\\\U00(10|0" + HEX + ")" + hex4 + ")"; var LINE_BREAK = "\n"; var STRING_LITERAL_SINGLE_QUOTE = "'(([^\\x27\\x5C\\x0A\\x0D])|" + ECHAR + "|" + unicode + ")*'"; var STRING_LITERAL_QUOTE = '"(([^\\x22\\x5C\\x0A\\x0D])|' + ECHAR + "|" + unicode + ')*"'; var STRING_LITERAL_LONG = { SINGLE_QUOTE: { CAT: "STRING_LITERAL_LONG_SINGLE_QUOTE", QUOTES: "'''", CONTENTS: "(('|'')?([^'\\\\]|" + ECHAR + "|" + unicode + "))*" }, QUOTE: { CAT: "STRING_LITERAL_LONG_QUOTE", QUOTES: '"""', CONTENTS: '(("|"")?([^"\\\\]|' + ECHAR + "|" + unicode + "))*" } }; for (var key in STRING_LITERAL_LONG) { STRING_LITERAL_LONG[key].COMPLETE = STRING_LITERAL_LONG[key].QUOTES + STRING_LITERAL_LONG[key].CONTENTS + STRING_LITERAL_LONG[key].QUOTES; } // var STRING_LITERAL_LONG_QUOTES = { // "STRING_LITERAL_LONG_QUOTES1": "'''", // "STRING_LITERAL_LONG_QUOTES2": '"""', // } // var STRING_LITERAL_LONG_CONTENTS = { // "STRING_LITERAL_LONG_QUOTES1": "(('|'')?([^'\\\\]|"+ECHAR+"|"+unicode+"))*", // "STRING_LITERAL_LONG_QUOTES2": '(("|"")?([^"\\\\]|'+ECHAR+'|'+unicode+'))*' // }; // var STRING_LITERAL_LONG1 = STRING_LITERAL_LONG['SINGLE'].QUOTES + STRING_LITERAL_LONG['SINGLE'].CONTENTS + STRING_LITERAL_LONG['SINGLE'].QUOTES; // var STRING_LITERAL_LONG2 = STRING_LITERAL_LONG['DOUBLE'].QUOTES + STRING_LITERAL_LONG['DOUBLE'].CONTENTS + STRING_LITERAL_LONG['DOUBLE'].QUOTES; // var stringLiteralLongContentTerminals = {}; // for (var key in STRING_LITERAL_LONG) { // stringLiteralLongContentTerminals[key] = { // name: key, // regex:new RegExp("^"+STRING_LITERAL_LONG_CONTENTS[key]), // style:"string" // }; // } //some regular expressions not used in regular terminals, because this is used accross lines var stringLiteralLongRegex = {}; for (var key in STRING_LITERAL_LONG) { stringLiteralLongRegex[key] = { complete: { name: "STRING_LITERAL_LONG_" + key, regex: new RegExp("^" + STRING_LITERAL_LONG[key].COMPLETE), style: "string" }, contents: { name: "STRING_LITERAL_LONG_" + key, regex: new RegExp("^" + STRING_LITERAL_LONG[key].CONTENTS), style: "string" }, closing: { name: "STRING_LITERAL_LONG_" + key, regex: new RegExp("^" + STRING_LITERAL_LONG[key].CONTENTS + STRING_LITERAL_LONG[key].QUOTES), style: "string" }, quotes: { name: "STRING_LITERAL_LONG_QUOTES_" + key, regex: new RegExp("^" + STRING_LITERAL_LONG[key].QUOTES), style: "string" } }; } var WS = "[\\x20\\x09\\x0D\\x0A]"; // Careful! Code mirror feeds one line at a time with no \n // ... but otherwise comment is terminated by \n var COMMENT = "#([^\\n\\r]*[\\n\\r]|[^\\n\\r]*$)"; var WS_OR_COMMENT_STAR = "(" + WS + "|(" + COMMENT + "))*"; var NIL = "\\(" + WS_OR_COMMENT_STAR + "\\)"; var ANON = "\\[" + WS_OR_COMMENT_STAR + "\\]"; var terminals = [ { name: "WS", regex: new RegExp("^" + WS + "+"), style: "ws" }, { name: "COMMENT", regex: new RegExp("^" + COMMENT), style: "comment" }, { name: "true", regex: new RegExp("^true", "i"), style: "keyword" }, { name: "false", regex: new RegExp("^false", "i"), style: "keyword" }, { name: "IRI_REF", regex: new RegExp("^" + IRI_REF), style: "variable-3" }, { name: "VAR1", regex: new RegExp("^" + VAR1), style: "atom" }, { name: "VAR2", regex: new RegExp("^" + VAR2), style: "atom" }, { name: "@prefix", regex: new RegExp("^@prefix", "i"), style: "keyword" }, { name: "@base", regex: new RegExp("^@base", "i"), style: "keyword" }, { name: "LANGTAG", regex: new RegExp("^" + LANGTAG), style: "meta" }, { name: "DOUBLE", regex: new RegExp("^" + DOUBLE), style: "number" }, { name: "DECIMAL", regex: new RegExp("^" + DECIMAL), style: "number" }, { name: "INTEGER", regex: new RegExp("^" + INTEGER), style: "number" }, { name: "STRING_LITERAL_SINGLE_QUOTE", regex: new RegExp("^" + STRING_LITERAL_SINGLE_QUOTE), style: "string" }, { name: "STRING_LITERAL_QUOTE", regex: new RegExp("^" + STRING_LITERAL_QUOTE), style: "string" }, // Enclosed comments won't be highlighted { name: "NIL", regex: new RegExp("^" + NIL), style: "punc" }, // Enclosed comments won't be highlighted { name: "ANON", regex: new RegExp("^" + ANON), style: "punc" }, { name: "PNAME_LN", regex: new RegExp("^" + PNAME_LN), style: "string-2" }, { name: "PNAME_NS", regex: new RegExp("^" + PNAME_NS), style: "string-2" }, { name: "BLANK_NODE_LABEL", regex: new RegExp("^" + BLANK_NODE_LABEL), style: "string-2" } ]; function getPossibles(symbol) { var possibles = [], possiblesOb = ll1_table[symbol]; if (possiblesOb != undefined) { for (var property in possiblesOb) { possibles.push(property.toString()); } } else { possibles.push(symbol); } return possibles; } function tokenBase(stream, state) { function nextToken() { var consumed = null; if (state.inLiteral) { var closingQuotes = false; //multi-line literal. try to parse contents. consumed = stream.match(stringLiteralLongRegex[state.inLiteral].contents.regex, true, false); if (consumed && consumed[0].length == 0) { //try seeing whether we can consume closing quotes, to avoid stopping consumed = stream.match(stringLiteralLongRegex[state.inLiteral].closing.regex, true, false); closingQuotes = true; } if (consumed && consumed[0].length > 0) { //some string content here. var returnObj = { quotePos: closingQuotes ? "end" : "content", cat: STRING_LITERAL_LONG[state.inLiteral].CAT, style: stringLiteralLongRegex[state.inLiteral].complete.style, text: consumed[0], start: stream.start }; if (closingQuotes) state.inLiteral = false; return returnObj; } } //Multiline literals for (var quoteType in stringLiteralLongRegex) { consumed = stream.match(stringLiteralLongRegex[quoteType].quotes.regex, true, false); if (consumed) { var quotePos; if (state.inLiteral) { //end of literal. everything is fine state.inLiteral = false; quotePos = "end"; } else { state.inLiteral = quoteType; quotePos = "start"; } return { cat: STRING_LITERAL_LONG[quoteType].CAT, style: stringLiteralLongRegex[quoteType].quotes.style, text: consumed[0], quotePos: quotePos, start: stream.start }; } } // Tokens defined by individual regular expressions for (var i = 0; i < terminals.length; ++i) { consumed = stream.match(terminals[i].regex, true, false); if (consumed) { return { cat: terminals[i].name, style: terminals[i].style, text: consumed[0], start: stream.start }; } } // Keywords consumed = stream.match(grammar.keywords, true, false); if (consumed) return { cat: stream.current().toUpperCase(), style: "keyword", text: consumed[0], start: stream.start }; // Punctuation consumed = stream.match(grammar.punct, true, false); if (consumed) return { cat: stream.current(), style: "punc", text: consumed[0], start: stream.start }; // Token is invalid // better consume something anyway, or else we're stuck consumed = stream.match(/^.[A-Za-z0-9]*/, true, false); return { cat: "<invalid_token>", style: "error", text: consumed[0], start: stream.start }; } function recordFailurePos() { // tokenOb.style= "sp-invalid"; var col = stream.column(); state.errorStartPos = col; state.errorEndPos = col + tokenOb.text.length; } // Some fake non-terminals are just there to have side-effect on state function setSideConditions(topSymbol) { if (topSymbol === "prefixID" || topSymbol === "sparqlPrefix") { state.inPrefixDecl = true; } else { state.inPrefixDecl = false; } if (topSymbol === "storeProperty") { state.storeProperty = true; } } // CodeMirror works with one line at a time, // but newline should behave like whitespace // - i.e. a definite break between tokens (for autocompleter) if (stream.pos == 0) state.possibleCurrent = state.possibleNext; var tokenOb = nextToken(); if (tokenOb.cat == "<invalid_token>") { // set error state, and if (state.OK == true) { state.OK = false; recordFailurePos(); } state.complete = false; // alert("Invalid:"+tokenOb.text); return tokenOb.style; } if (tokenOb.cat == "WS" || tokenOb.cat == "COMMENT" || (tokenOb.quotePos && tokenOb.quotePos != "end")) { state.possibleCurrent = state.possibleNext; return tokenOb.style; } // Otherwise, run the parser until the token is digested // or failure var finished = false; var topSymbol; var token = tokenOb.cat; if (!tokenOb.quotePos || tokenOb.quotePos == "end") { // Incremental LL1 parse while (state.stack.length > 0 && token && state.OK && !finished) { topSymbol = state.stack.pop(); if (topSymbol === 'var' && tokenOb.text) state.variables[tokenOb.text] = tokenOb.text; if (!ll1_table[topSymbol]) { // Top symbol is a terminal if (topSymbol == token) { if (state.inPrefixDecl) { if (topSymbol === "PNAME_NS" && tokenOb.text.length > 0) { state.currentPnameNs = tokenOb.text.slice(0, -1); } else if (state.currentPnameNs !== undefined && tokenOb.text.length > 2) { state.prefixes[state.currentPnameNs] = tokenOb.text.slice(1, -1); //reset current pname ns state.currentPnameNs = undefined; } } // Matching terminals // - consume token from input stream finished = true; // Check whether $ (end of input token) is poss next // for everything on stack var allNillable = true; for (var sp = state.stack.length; sp > 0; --sp) { var item = ll1_table[state.stack[sp - 1]]; if (!item || !item["$"]) allNillable = false; } state.complete = allNillable; if (state.storeProperty && token.cat != "punc") { state.lastProperty = tokenOb.text; state.storeProperty = false; } //check whether a used prefix is actually defined if (!state.inPrefixDecl && (token === "PNAME_NS" || token === "PNAME_LN")) { var colonIndex = tokenOb.text.indexOf(":"); if (colonIndex >= 0) { var prefNs = tokenOb.text.slice(0, colonIndex); //avoid warnings for missing bif prefixes (yuck, virtuoso-specific) if (!state.prefixes[prefNs] && ["bif", "xsd", "sql"].indexOf(prefNs) < 0) { state.OK = false; recordFailurePos(); state.errorMsg = "Prefix '" + prefNs + "' is not defined"; } } } } else { state.OK = false; state.complete = false; recordFailurePos(); } } else { // topSymbol is nonterminal // - see if there is an entry for topSymbol // and nextToken in table var nextSymbols = ll1_table[topSymbol][token]; if (nextSymbols !== undefined) { // Match - copy RHS of rule to stack for (var i = nextSymbols.length - 1; i >= 0; --i) { state.stack.push(nextSymbols[i]); } // Peform any non-grammatical side-effects setSideConditions(topSymbol); } else { // No match in table - fail state.OK = false; state.complete = false; recordFailurePos(); state.stack.push(topSymbol); // Shove topSymbol back on stack } } } } if (!finished && state.OK) { state.OK = false; state.complete = false; recordFailurePos(); } if (state.possibleCurrent.indexOf("a") >= 0) { state.lastPredicateOffset = tokenOb.start; } state.possibleCurrent = state.possibleNext; state.possibleNext = getPossibles(state.stack[state.stack.length - 1]); return tokenOb.style; } var indentTop = { "*[,, object]": 3, "*[(,),object]": 3, object: 2, objectList: 2, storeProperty: 2, predicateObjectList: 1, "?[verb,objectList]": 1 }; var indentTable = { "}": 1, "]": 1, ")": 1, "{": -1, "(": -1, "[": -1 // "*[;,?[or([verbPath,verbSimple]),objectList]]": 1, }; function indent(state, textAfter) { //just avoid we don't indent multi-line literals if (state.inLiteral) return 0; if (state.stack.length && state.stack[state.stack.length - 1] == "?[verb,objectList]") { //we are after a semi-colon. I.e., nicely align this line with predicate position of previous line return state.lastPredicateOffset; } else { var n = 0; // indent level var i = state.stack.length - 1; if (/^[\}\]\)]/.test(textAfter)) { // Skip stack items until after matching bracket var closeBracket = textAfter.substr(0, 1); for (; i >= 0; --i) { if (state.stack[i] == closeBracket) { --i; break; } } } else { // Consider nullable non-terminals if at top of stack var dn = indentTop[state.stack[i]]; if (dn) { n += dn; --i; } } for (; i >= 0; --i) { var dn = indentTable[state.stack[i]]; if (dn) { n += dn; } } return n * config.indentUnit; } } return { token: tokenBase, startState: function(base) { return { tokenize: tokenBase, OK: true, complete: grammar.acceptEmpty, errorStartPos: null, errorEndPos: null, possibleCurrent: getPossibles(grammar.startSymbol), possibleNext: getPossibles(grammar.startSymbol), storeProperty: false, lastProperty: "", inLiteral: false, stack: [grammar.startSymbol], lastPredicateOffset: config.indentUnit, prefixes: {}, variables: {} }; }, indent: indent, electricChars: "}])" }; }); CodeMirror.defineMIME("text/turtle", "rdf11turtle"); },{"./_tokenizer-table.js":2,"codemirror":undefined}],4:[function(require,module,exports){ /* * TRIE implementation in Javascript * Copyright (c) 2010 Saurabh Odhyan | http://odhyan.com * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * Date: Nov 7, 2010 */ /* * A trie, or prefix tree, is a multi-way tree structure useful for storing strings over an alphabet. * It has been used to store large dictionaries of English (say) words in spell-checking programs * and in natural-language "understanding" programs. * @see http://en.wikipedia.org/wiki/Trie * @see http://www.csse.monash.edu.au/~lloyd/tildeAlgDS/Tree/Trie/ /* * @class Trie * @constructor */ var Trie = module.exports = function() { this.words = 0; this.prefixes = 0; this.children = []; }; Trie.prototype = { /* * Insert a word into the dictionary. * Recursively traverse through the trie nodes, and create new node if does not already exist. * * @method insert * @param {String} str Word to insert in the dictionary * @param {Integer} pos Current index of the string to be inserted * @return {Void} */ insert: function(str, pos) { if (str.length == 0) { //blank string cannot be inserted return; } var T = this, k, child; if (pos === undefined) { pos = 0; } if (pos === str.length) { T.words++; return; } T.prefixes++; k = str[pos]; if (T.children[k] === undefined) { //if node for this char doesn't exist, create one T.children[k] = new Trie(); } child = T.children[k]; child.insert(str, pos + 1); }, /* * Remove a word from the dictionary. * * @method remove * @param {String} str Word to be removed * @param {Integer} pos Current index of the string to be removed * @return {Void} */ remove: function(str, pos) { if (str.length == 0) { return; } var T = this, k, child; if (pos === undefined) { pos = 0; } if (T === undefined) { return; } if (pos === str.length) { T.words--; return; } T.prefixes--; k = str[pos]; child = T.children[k]; child.remove(str, pos + 1); }, /* * Update an existing word in the dictionary. * This method removes the old word from the dictionary and inserts the new word. * * @method update * @param {String} strOld The old word to be replaced * @param {String} strNew The new word to be inserted * @return {Void} */ update: function(strOld, strNew) { if (strOld.length == 0 || strNew.length == 0) { return; } this.remove(strOld); this.insert(strNew); }, /* * Count the number of times a given word has been inserted into the dictionary * * @method countWord * @param {String} str Word to get count of * @param {Integer} pos Current index of the given word * @return {Integer} The number of times a given word exists in the dictionary */ countWord: function(str, pos) { if (str.length == 0) { return 0; } var T = this, k, child, ret = 0; if (pos === undefined) { pos = 0; } if (pos === str.length) { return T.words; } k = str[pos]; child = T.children[k]; if (child !== undefined) { //node exists ret = child.countWord(str, pos + 1); } return ret; }, /* * Count the number of times a given prefix exists in the dictionary * * @method countPrefix * @param {String} str Prefix to get count of * @param {Integer} pos Current index of the given prefix * @return {Integer} The number of times a given prefix exists in the dictionary */ countPrefix: function(str, pos) { if (str.length == 0) { return 0; } var T = this, k, child, ret = 0; if (pos === undefined) { pos = 0; } if (pos === str.length) { return T.prefixes; } var k = str[pos]; child = T.children[k]; if (child !== undefined) { //node exists ret = child.countPrefix(str, pos + 1); } return ret; }, /* * Find a word in the dictionary * * @method find * @param {String} str The word to find in the dictionary * @return {Boolean} True if the word exists in the dictionary, else false */ find: function(str) { if (str.length == 0) { return false; } if (this.countWord(str) > 0) { return true; } else { return false; } }, /* * Get all words in the dictionary * * @method getAllWords * @param {String} str Prefix of current word * @return {Array} Array of words in the dictionary */ getAllWords: function(str) { var T = this, k, child, ret = []; if (str === undefined) { str = ""; } if (T === undefined) { return []; } if (T.words > 0) { ret.push(str); } for (k in T.children) { if (T.children.hasOwnProperty(k)) { child = T.children[k]; ret = ret.concat(child.getAllWords(str + k)); } } return ret; }, /* * Autocomplete a given prefix * * @method autoComplete * @param {String} str Prefix to be completed based on dictionary entries * @param {Integer} pos Current index of the prefix * @return {Array} Array of possible suggestions */ autoComplete: function(str, pos) { var T = this, k, child; if (str.length == 0) { if (pos === undefined) { return T.getAllWords(str); } else { return []; } } if (pos === undefined) { pos = 0; } k = str[pos]; child = T.children[k]; if (child === undefined) { //node doesn't exist return []; } if (pos === str.length - 1) { return child.getAllWords(str); } return child.autoComplete(str, pos + 1); } }; },{}],5:[function(require,module,exports){ (function (global, factory) { if (typeof define === "function" && define.amd) { define(['module', 'select'], factory); } else if (typeof exports !== "undefined") { factory(module, require('select')); } else { var mod = { exports: {} }; factory(mod, global.select); global.clipboardAction = mod.exports; } })(this, function (module, _select) { 'use strict'; var _select2 = _interopRequireDefault(_select); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var ClipboardAction = function () { /** * @param {Object} options */ function ClipboardAction(options) { _classCallCheck(this, ClipboardAction); this.resolveOptions(options); this.initSelection(); } /** * Defines base properties passed from constructor. * @param {Object} options */ _createClass(ClipboardAction, [{ key: 'resolveOptions', value: function resolveOptions() { var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; this.action = options.action; this.container = options.container; this.emitter = options.emitter; this.target = options.target; this.text = options.text; this.trigger = options.trigger; this.selectedText = ''; } }, { key: 'initSelection', value: function initSelection() { if (this.text) { this.selectFake(); } else if (this.target) { this.selectTarget(); } } }, { key: 'selectFake', value: function selectFake() { var _this = this; var isRTL = document.documentElement.getAttribute('dir') == 'rtl'; this.removeFake(); this.fakeHandlerCallback = function () { return _this.removeFake(); }; this.fakeHandler = this.container.addEventListener('click', this.fakeHandlerCallback) || true; this.fakeElem = document.createElement('textarea'); // Prevent zooming on iOS this.fakeElem.style.fontSize = '12pt'; // Reset box model this.fakeElem.style.border = '0'; this.fakeElem.style.padding = '0'; this.fakeElem.style.margin = '0'; // Move element out of screen horizontally this.fakeElem.style.position = 'absolute'; this.fakeElem.style[isRTL ? 'right' : 'left'] = '-9999px'; // Move element to the same position vertically var yPosition = window.pageYOffset || document.documentElement.scrollTop; this.fakeElem.style.top = yPosition + 'px'; this.fakeElem.setAttribute('readonly', ''); this.fakeElem.value = this.text; this.container.appendChild(this.fakeElem); this.selectedText = (0, _select2.default)(this.fakeElem); this.copyText(); } }, { key: 'removeFake', value: function removeFake() { if (this.fakeHandler) { this.container