{"version":3,"sources":["webpack:///./node_modules/n3/lib/N3Lexer.js","webpack:///./node_modules/n3/lib/N3Parser.js","webpack:///./node_modules/n3/lib/N3Util.js","webpack:///./node_modules/n3/lib/N3Writer.js","webpack:///./node_modules/n3/N3.js","webpack:///./node_modules/n3/lib/N3Store.js","webpack:///./node_modules/n3/lib/N3StreamParser.js","webpack:///./node_modules/n3/lib/N3StreamWriter.js"],"names":["fromCharCode","String","immediately","setImmediate","func","setTimeout","escapeSequence","escapeReplacements","illegalIriChars","N3Lexer","options","this","lineMode","_tripleQuotedString","_number","_boolean","self","_tokenize","tokenize","input","callback","error","token","test","type","_syntaxError","_n3Mode","n3","_comments","comments","prototype","_iri","_unescapedIri","_unescapedString","_singleQuotedString","_langcode","_prefix","_prefixed","_variable","_blank","_keyword","_sparqlKeyword","_shortPredicates","_newline","_comment","_whitespace","_endOfFile","_tokenizeToEnd","inputFinished","_input","outputComments","whiteSpaceMatch","comment","exec","line","_line","value","prefix","substr","length","unescaped","firstChar","match","matchLength","inconclusive","_prevTokenType","_unescape","reportSyntaxError","replace","split","toUpperCase","item","sequence","unicode4","unicode8","escapedChar","charCode","parseInt","isNaN","Error","replacement","issue","tokens","e","t","push","setEncoding","on","data","module","exports","RDF_PREFIX","RDF_NIL","RDF_FIRST","RDF_REST","absoluteIRI","schemeAuthority","dotSegments","blankNodePrefix","blankNodeCount","N3Parser","_contextStack","_graph","_setBase","documentIRI","format","toLowerCase","isTurtle","isTriG","isNTriples","isNQuads","isN3","isLineMode","_supportsNamedGraphs","_readPredicateOrNamedGraph","_readPredicate","_supportsQuads","_base","_resolveIRI","_error","_callback","noop","_subject","_blankNodePrefix","_lexer","lexer","_explicitQuantifiers","explicitQuantifiers","_resetBlankNodeIds","baseIRI","fragmentPos","indexOf","_basePath","_baseRoot","_baseScheme","_saveContext","graph","subject","predicate","object","n3Mode","inverse","_inversePredicate","blankPrefix","_prefixes","_","quantified","_quantified","Object","create","_restoreContext","context","pop","_predicate","_object","_readInTopContext","_sparqlStyle","_readPrefix","_readBaseIRI","_readSubject","_readNamedGraphLabel","_readEntity","quantifier","undefined","_readBlankNodeHead","_readListItem","_readPunctuation","_quantifiedPrefix","_readQuantifierList","_getPathReader","_readBlankNodeTail","_readObject","_readDataTypeOrLang","_getContextEndReader","_readGraph","_readBlankNodePunctuation","_triple","empty","_readPredicateAfterBlank","list","prevList","stack","parent","next","itemComplete","_readListItemDataTypeOrLang","_completeLiteral","listItem","suffix","_readCallback","_readFormulaTail","inversePredicate","_readQuadPunctuation","_readPrefixIRI","prefixIRI","_prefixCallback","_readDeclarationPunctuation","_readNamedGraphBlankLabel","entity","_readQuantifierPunctuation","afterPath","_afterPath","_readPath","_readForwardPath","_readBackwardPath","contextStack","message","iri","_removeDotSegments","result","i","pathStart","segmentStart","substring","lastIndexOf","parse","tripleCallback","prefixCallback","triples","every","N3Util","isIRI","isLiteral","isBlank","isDefaultGraph","inDefaultGraph","triple","getLiteralValue","literal","getLiteralType","Xsd","getLiteralLanguage","isPrefixedName","expandPrefixedName","prefixedName","prefixes","base","index","createIRI","createLiteral","modifier","isFinite","defaultPrefixes","processPrefix","cache","localName","addN3Util","toPrototype","name","applyToThis","f","a","N3LiteralMatcher","escape","escapeAll","N3Writer","outputStream","write","_outputStream","_endStream","end","output","chunk","encoding","done","_writeTriple","_writeTripleLine","_prefixIRIs","addPrefixes","characterReplacer","character","charCodeAt","toString","_write","string","_encodeIriOrBlankNode","_encodeObject","_encodePredicate","_encodeSubject","_prefixMatch","prefixMatch","_prefixRegex","_encodeLiteral","language","_blockedWrite","addTriple","addTriples","addPrefix","prefixIRIs","hasPrefixes","IRIlist","prefixList","RegExp","blank","child","children","contents","elements","Array","join","singleDone","require","Lexer","Parser","Writer","Store","StreamParser","StreamWriter","Util","keys","forEach","submodule","defineProperty","configurable","enumerable","get","N3Store","_size","_graphs","_id","_ids","_entities","_blankNodeIndex","isString","s","size","subjects","graphs","graphKey","subjectKey","predicateKey","_addToIndex","index0","key0","key1","key2","index1","index2","existed","_removeFromIndex","key","_findInIndex","name0","name1","name2","tmp","results","entityKeys","value0","entity0","value1","entity1","values","l","_countInIndex","count","graphItem","predicates","objects","freeze","ids","entities","changed","removeTriple","removeTriples","find","findByIRI","graphContents","subjectId","predicateId","objectId","quads","graphId","concat","apply","countByIRI","createBlankNode","suggestedName","Transform","util","N3StreamParser","call","decodeStrings","_readableState","objectMode","onData","onEnd","event","cb","emit","uri","_transform","_flush","inherits","N3StreamWriter","_writableState","writer"],"mappings":"gFAAA,YACA,IAAIA,EAAeC,OAAOD,aACtBE,EAAsC,mBAAjBC,EAA8BA,EACrC,SAASA,aAAaC,GAAQC,WAAWD,EAAM,IAI7DE,EAAiB,wDACjBC,EAAqB,CACvB,KAAM,KAAM,IAAK,IAAK,IAAK,IAC3B,EAAK,KAAM,EAAK,KAAM,EAAK,KAAM,EAAK,KAAM,EAAK,KACjD,EAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,EAAK,IAAK,IAAK,IACjE,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IACjE,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,KAE3CC,EAAkB,6BAGtB,SAASC,QAAQC,GACf,KAAMC,gBAAgBF,SACpB,OAAO,IAAIA,QAAQC,GAIrB,IAHAA,EAAUA,GAAW,IAGTE,SAAU,CAEpBD,KAAKE,oBAAsBF,KAAKG,QAAUH,KAAKI,SAAW,MAE1D,IAAIC,EAAOL,KACXA,KAAKM,UAAYN,KAAKO,SACtBP,KAAKO,SAAW,SAAUC,EAAOC,GAC/BT,KAAKM,UAAUE,GAAO,SAAUE,EAAOC,IAChCD,GAAS,kDAAkDE,KAAKD,EAAME,MACzEJ,GAAYA,EAASC,EAAOC,GAE5BF,GAAYA,EAASC,GAASL,EAAKS,aAAaH,EAAME,KAAMJ,EAAW,WAK/ET,KAAKe,SAAyB,I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,EAAQqC,EAAUC,GAAQoI,EAAO/G,UAAU3D,EAAQsC,IAC/E7P,KAAK6X,OAAS,SAAUhI,GAAQoI,EAAOxI,IAAII,IAE7CmH,EAAKc,SAASC,eAAgBhB,GAG9BjS,EAAOC,QAAUgT","file":"npm.n3-a4bbbc8e6fd01e67cac0.js","sourcesContent":["// **N3Lexer** tokenizes N3 documents.\nvar fromCharCode = String.fromCharCode;\nvar immediately = typeof setImmediate === 'function' ? setImmediate :\n function setImmediate(func) { setTimeout(func, 0); };\n\n// Regular expression and replacement string to escape N3 strings.\n// Note how we catch invalid unicode sequences separately (they will trigger an error).\nvar escapeSequence = /\\\\u([a-fA-F0-9]{4})|\\\\U([a-fA-F0-9]{8})|\\\\[uU]|\\\\(.)/g;\nvar escapeReplacements = {\n '\\\\': '\\\\', \"'\": \"'\", '\"': '\"',\n 'n': '\\n', 'r': '\\r', 't': '\\t', 'f': '\\f', 'b': '\\b',\n '_': '_', '~': '~', '.': '.', '-': '-', '!': '!', '$': '$', '&': '&',\n '(': '(', ')': ')', '*': '*', '+': '+', ',': ',', ';': ';', '=': '=',\n '/': '/', '?': '?', '#': '#', '@': '@', '%': '%',\n};\nvar illegalIriChars = /[\\x00-\\x20<>\\\\\"\\{\\}\\|\\^\\`]/;\n\n// ## Constructor\nfunction N3Lexer(options) {\n if (!(this instanceof N3Lexer))\n return new N3Lexer(options);\n options = options || {};\n\n // In line mode (N-Triples or N-Quads), only simple features may be parsed\n if (options.lineMode) {\n // Don't tokenize special literals\n this._tripleQuotedString = this._number = this._boolean = /$0^/;\n // Swap the tokenize method for a restricted version\n var self = this;\n this._tokenize = this.tokenize;\n this.tokenize = function (input, callback) {\n this._tokenize(input, function (error, token) {\n if (!error && /^(?:IRI|prefixed|literal|langcode|type|\\.|eof)$/.test(token.type))\n callback && callback(error, token);\n else\n callback && callback(error || self._syntaxError(token.type, callback = null));\n });\n };\n }\n // Enable N3 functionality by default\n this._n3Mode = options.n3 !== false;\n // Disable comment tokens by default\n this._comments = !!options.comments;\n}\n\nN3Lexer.prototype = {\n // ## Regular expressions\n // It's slightly faster to have these as properties than as in-scope variables\n\n _iri: /^<((?:[^ <>{}\\\\]|\\\\[uU])+)>[ \\t]*/, // IRI with escape sequences; needs sanity check after unescaping\n _unescapedIri: /^<([^\\x00-\\x20<>\\\\\"\\{\\}\\|\\^\\`]*)>[ \\t]*/, // IRI without escape sequences; no unescaping\n _unescapedString: /^\"[^\"\\\\]+\"(?=[^\"\\\\])/, // non-empty string without escape sequences\n _singleQuotedString: /^\"[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*\"(?=[^\"\\\\])|^'[^'\\\\]*(?:\\\\.[^'\\\\]*)*'(?=[^'\\\\])/,\n _tripleQuotedString: /^\"\"(\"[^\"\\\\]*(?:(?:\\\\.|\"(?!\"\"))[^\"\\\\]*)*\")\"\"|^''('[^'\\\\]*(?:(?:\\\\.|'(?!''))[^'\\\\]*)*')''/,\n _langcode: /^@([a-z]+(?:-[a-z0-9]+)*)(?=[^a-z0-9\\-])/i,\n _prefix: /^((?:[A-Za-z\\xc0-\\xd6\\xd8-\\xf6\\xf8-\\u02ff\\u0370-\\u037d\\u037f-\\u1fff\\u200c\\u200d\\u2070-\\u218f\\u2c00-\\u2fef\\u3001-\\ud7ff\\uf900-\\ufdcf\\ufdf0-\\ufffd]|[\\ud800-\\udb7f][\\udc00-\\udfff])(?:\\.?[\\-0-9A-Z_a-z\\xb7\\xc0-\\xd6\\xd8-\\xf6\\xf8-\\u037d\\u037f-\\u1fff\\u200c\\u200d\\u203f\\u2040\\u2070-\\u218f\\u2c00-\\u2fef\\u3001-\\ud7ff\\uf900-\\ufdcf\\ufdf0-\\ufffd]|[\\ud800-\\udb7f][\\udc00-\\udfff])*)?:(?=[#\\s<])/,\n _prefixed: /^((?:[A-Za-z\\xc0-\\xd6\\xd8-\\xf6\\xf8-\\u02ff\\u0370-\\u037d\\u037f-\\u1fff\\u200c\\u200d\\u2070-\\u218f\\u2c00-\\u2fef\\u3001-\\ud7ff\\uf900-\\ufdcf\\ufdf0-\\ufffd]|[\\ud800-\\udb7f][\\udc00-\\udfff])(?:\\.?[\\-0-9A-Z_a-z\\xb7\\xc0-\\xd6\\xd8-\\xf6\\xf8-\\u037d\\u037f-\\u1fff\\u200c\\u200d\\u203f\\u2040\\u2070-\\u218f\\u2c00-\\u2fef\\u3001-\\ud7ff\\uf900-\\ufdcf\\ufdf0-\\ufffd]|[\\ud800-\\udb7f][\\udc00-\\udfff])*)?:((?:(?:[0-:A-Z_a-z\\xc0-\\xd6\\xd8-\\xf6\\xf8-\\u02ff\\u0370-\\u037d\\u037f-\\u1fff\\u200c\\u200d\\u2070-\\u218f\\u2c00-\\u2fef\\u3001-\\ud7ff\\uf900-\\ufdcf\\ufdf0-\\ufffd]|[\\ud800-\\udb7f][\\udc00-\\udfff]|%[0-9a-fA-F]{2}|\\\\[!#-\\/;=?\\-@_~])(?:(?:[\\.\\-0-:A-Z_a-z\\xb7\\xc0-\\xd6\\xd8-\\xf6\\xf8-\\u037d\\u037f-\\u1fff\\u200c\\u200d\\u203f\\u2040\\u2070-\\u218f\\u2c00-\\u2fef\\u3001-\\ud7ff\\uf900-\\ufdcf\\ufdf0-\\ufffd]|[\\ud800-\\udb7f][\\udc00-\\udfff]|%[0-9a-fA-F]{2}|\\\\[!#-\\/;=?\\-@_~])*(?:[\\-0-:A-Z_a-z\\xb7\\xc0-\\xd6\\xd8-\\xf6\\xf8-\\u037d\\u037f-\\u1fff\\u200c\\u200d\\u203f\\u2040\\u2070-\\u218f\\u2c00-\\u2fef\\u3001-\\ud7ff\\uf900-\\ufdcf\\ufdf0-\\ufffd]|[\\ud800-\\udb7f][\\udc00-\\udfff]|%[0-9a-fA-F]{2}|\\\\[!#-\\/;=?\\-@_~]))?)?)(?:[ \\t]+|(?=\\.?[,;!\\^\\s#()\\[\\]\\{\\}\"'<]))/,\n _variable: /^\\?(?:(?:[A-Z_a-z\\xc0-\\xd6\\xd8-\\xf6\\xf8-\\u02ff\\u0370-\\u037d\\u037f-\\u1fff\\u200c\\u200d\\u2070-\\u218f\\u2c00-\\u2fef\\u3001-\\ud7ff\\uf900-\\ufdcf\\ufdf0-\\ufffd]|[\\ud800-\\udb7f][\\udc00-\\udfff])(?:[\\-0-:A-Z_a-z\\xb7\\xc0-\\xd6\\xd8-\\xf6\\xf8-\\u037d\\u037f-\\u1fff\\u200c\\u200d\\u203f\\u2040\\u2070-\\u218f\\u2c00-\\u2fef\\u3001-\\ud7ff\\uf900-\\ufdcf\\ufdf0-\\ufffd]|[\\ud800-\\udb7f][\\udc00-\\udfff])*)(?=[.,;!\\^\\s#()\\[\\]\\{\\}\"'<])/,\n _blank: /^_:((?:[0-9A-Z_a-z\\xc0-\\xd6\\xd8-\\xf6\\xf8-\\u02ff\\u0370-\\u037d\\u037f-\\u1fff\\u200c\\u200d\\u2070-\\u218f\\u2c00-\\u2fef\\u3001-\\ud7ff\\uf900-\\ufdcf\\ufdf0-\\ufffd]|[\\ud800-\\udb7f][\\udc00-\\udfff])(?:\\.?[\\-0-9A-Z_a-z\\xb7\\xc0-\\xd6\\xd8-\\xf6\\xf8-\\u037d\\u037f-\\u1fff\\u200c\\u200d\\u203f\\u2040\\u2070-\\u218f\\u2c00-\\u2fef\\u3001-\\ud7ff\\uf900-\\ufdcf\\ufdf0-\\ufffd]|[\\ud800-\\udb7f][\\udc00-\\udfff])*)(?:[ \\t]+|(?=\\.?[,;:\\s#()\\[\\]\\{\\}\"'<]))/,\n _number: /^[\\-+]?(?:\\d+\\.?\\d*([eE](?:[\\-\\+])?\\d+)|\\d*\\.?\\d+)(?=[.,;:\\s#()\\[\\]\\{\\}\"'<])/,\n _boolean: /^(?:true|false)(?=[.,;\\s#()\\[\\]\\{\\}\"'<])/,\n _keyword: /^@[a-z]+(?=[\\s#<])/i,\n _sparqlKeyword: /^(?:PREFIX|BASE|GRAPH)(?=[\\s#<])/i,\n _shortPredicates: /^a(?=\\s+|<)/,\n _newline: /^[ \\t]*(?:#[^\\n\\r]*)?(?:\\r\\n|\\n|\\r)[ \\t]*/,\n _comment: /#([^\\n\\r]*)/,\n _whitespace: /^[ \\t]+/,\n _endOfFile: /^(?:#[^\\n\\r]*)?$/,\n\n // ## Private methods\n\n // ### `_tokenizeToEnd` tokenizes as for as possible, emitting tokens through the callback\n _tokenizeToEnd: function (callback, inputFinished) {\n // Continue parsing as far as possible; the loop will return eventually\n var input = this._input, outputComments = this._comments;\n while (true) {\n // Count and skip whitespace lines\n var whiteSpaceMatch, comment;\n while (whiteSpaceMatch = this._newline.exec(input)) {\n // Try to find a comment\n if (outputComments && (comment = this._comment.exec(whiteSpaceMatch[0])))\n callback(null, { line: this._line, type: 'comment', value: comment[1], prefix: '' });\n // Advance the input\n input = input.substr(whiteSpaceMatch[0].length, input.length);\n this._line++;\n }\n // Skip whitespace on current line\n if (whiteSpaceMatch = this._whitespace.exec(input))\n input = input.substr(whiteSpaceMatch[0].length, input.length);\n\n // Stop for now if we're at the end\n if (this._endOfFile.test(input)) {\n // If the input is finished, emit EOF\n if (inputFinished) {\n // Try to find a final comment\n if (outputComments && (comment = this._comment.exec(input)))\n callback(null, { line: this._line, type: 'comment', value: comment[1], prefix: '' });\n callback(input = null, { line: this._line, type: 'eof', value: '', prefix: '' });\n }\n return this._input = input;\n }\n\n // Look for specific token types based on the first character\n var line = this._line, type = '', value = '', prefix = '',\n firstChar = input[0], match = null, matchLength = 0, unescaped, inconclusive = false;\n switch (firstChar) {\n case '^':\n // We need at least 3 tokens lookahead to distinguish ^^ and ^^pre:fixed\n if (input.length < 3)\n break;\n // Try to match a type\n else if (input[1] === '^') {\n this._prevTokenType = '^^';\n // Move to type IRI or prefixed name\n input = input.substr(2);\n if (input[0] !== '<') {\n inconclusive = true;\n break;\n }\n }\n // If no type, it must be a path expression\n else {\n if (this._n3Mode) {\n matchLength = 1;\n type = '^';\n }\n break;\n }\n // Fall through in case the type is an IRI\n case '<':\n // Try to find a full IRI without escape sequences\n if (match = this._unescapedIri.exec(input))\n type = 'IRI', value = match[1];\n // Try to find a full IRI with escape sequences\n else if (match = this._iri.exec(input)) {\n unescaped = this._unescape(match[1]);\n if (unescaped === null || illegalIriChars.test(unescaped))\n return reportSyntaxError(this);\n type = 'IRI', value = unescaped;\n }\n // Try to find a backwards implication arrow\n else if (this._n3Mode && input.length > 1 && input[1] === '=')\n type = 'inverse', matchLength = 2, value = 'http://www.w3.org/2000/10/swap/log#implies';\n break;\n\n case '_':\n // Try to find a blank node. Since it can contain (but not end with) a dot,\n // we always need a non-dot character before deciding it is a prefixed name.\n // Therefore, try inserting a space if we're at the end of the input.\n if ((match = this._blank.exec(input)) ||\n inputFinished && (match = this._blank.exec(input + ' ')))\n type = 'blank', prefix = '_', value = match[1];\n break;\n\n case '\"':\n case \"'\":\n // Try to find a non-empty double-quoted literal without escape sequences\n if (match = this._unescapedString.exec(input))\n type = 'literal', value = match[0];\n // Try to find any other literal wrapped in a pair of single or double quotes\n else if (match = this._singleQuotedString.exec(input)) {\n unescaped = this._unescape(match[0]);\n if (unescaped === null)\n return reportSyntaxError(this);\n type = 'literal', value = unescaped.replace(/^'|'$/g, '\"');\n }\n // Try to find a literal wrapped in three pairs of single or double quotes\n else if (match = this._tripleQuotedString.exec(input)) {\n unescaped = match[1] || match[2];\n // Count the newlines and advance line counter\n this._line += unescaped.split(/\\r\\n|\\r|\\n/).length - 1;\n unescaped = this._unescape(unescaped);\n if (unescaped === null)\n return reportSyntaxError(this);\n type = 'literal', value = unescaped.replace(/^'|'$/g, '\"');\n }\n break;\n\n case '?':\n // Try to find a variable\n if (this._n3Mode && (match = this._variable.exec(input)))\n type = 'var', value = match[0];\n break;\n\n case '@':\n // Try to find a language code\n if (this._prevTokenType === 'literal' && (match = this._langcode.exec(input)))\n type = 'langcode', value = match[1];\n // Try to find a keyword\n else if (match = this._keyword.exec(input))\n type = match[0];\n break;\n\n case '.':\n // Try to find a dot as punctuation\n if (input.length === 1 ? inputFinished : (input[1] < '0' || input[1] > '9')) {\n type = '.';\n matchLength = 1;\n break;\n }\n // Fall through to numerical case (could be a decimal dot)\n\n case '0':\n case '1':\n case '2':\n case '3':\n case '4':\n case '5':\n case '6':\n case '7':\n case '8':\n case '9':\n case '+':\n case '-':\n // Try to find a number\n if (match = this._number.exec(input)) {\n type = 'literal';\n value = '\"' + match[0] + '\"^^http://www.w3.org/2001/XMLSchema#' +\n (match[1] ? 'double' : (/^[+\\-]?\\d+$/.test(match[0]) ? 'integer' : 'decimal'));\n }\n break;\n\n case 'B':\n case 'b':\n case 'p':\n case 'P':\n case 'G':\n case 'g':\n // Try to find a SPARQL-style keyword\n if (match = this._sparqlKeyword.exec(input))\n type = match[0].toUpperCase();\n else\n inconclusive = true;\n break;\n\n case 'f':\n case 't':\n // Try to match a boolean\n if (match = this._boolean.exec(input))\n type = 'literal', value = '\"' + match[0] + '\"^^http://www.w3.org/2001/XMLSchema#boolean';\n else\n inconclusive = true;\n break;\n\n case 'a':\n // Try to find an abbreviated predicate\n if (match = this._shortPredicates.exec(input))\n type = 'abbreviation', value = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type';\n else\n inconclusive = true;\n break;\n\n case '=':\n // Try to find an implication arrow or equals sign\n if (this._n3Mode && input.length > 1) {\n type = 'abbreviation';\n if (input[1] !== '>')\n matchLength = 1, value = 'http://www.w3.org/2002/07/owl#sameAs';\n else\n matchLength = 2, value = 'http://www.w3.org/2000/10/swap/log#implies';\n }\n break;\n\n case '!':\n if (!this._n3Mode)\n break;\n case ',':\n case ';':\n case '[':\n case ']':\n case '(':\n case ')':\n case '{':\n case '}':\n // The next token is punctuation\n matchLength = 1;\n type = firstChar;\n break;\n\n default:\n inconclusive = true;\n }\n\n // Some first characters do not allow an immediate decision, so inspect more\n if (inconclusive) {\n // Try to find a prefix\n if ((this._prevTokenType === '@prefix' || this._prevTokenType === 'PREFIX') &&\n (match = this._prefix.exec(input)))\n type = 'prefix', value = match[1] || '';\n // Try to find a prefixed name. Since it can contain (but not end with) a dot,\n // we always need a non-dot character before deciding it is a prefixed name.\n // Therefore, try inserting a space if we're at the end of the input.\n else if ((match = this._prefixed.exec(input)) ||\n inputFinished && (match = this._prefixed.exec(input + ' ')))\n type = 'prefixed', prefix = match[1] || '', value = this._unescape(match[2]);\n }\n\n // A type token is special: it can only be emitted after an IRI or prefixed name is read\n if (this._prevTokenType === '^^') {\n switch (type) {\n case 'prefixed': type = 'type'; break;\n case 'IRI': type = 'typeIRI'; break;\n default: type = '';\n }\n }\n\n // What if nothing of the above was found?\n if (!type) {\n // We could be in streaming mode, and then we just wait for more input to arrive.\n // Otherwise, a syntax error has occurred in the input.\n // One exception: error on an unaccounted linebreak (= not inside a triple-quoted literal).\n if (inputFinished || (!/^'''|^\"\"\"/.test(input) && /\\n|\\r/.test(input)))\n return reportSyntaxError(this);\n else\n return this._input = input;\n }\n\n // Emit the parsed token\n callback(null, { line: line, type: type, value: value, prefix: prefix });\n this._prevTokenType = type;\n\n // Advance to next part to tokenize\n input = input.substr(matchLength || match[0].length, input.length);\n }\n\n // Signals the syntax error through the callback\n function reportSyntaxError(self) { callback(self._syntaxError(/^\\S*/.exec(input)[0])); }\n },\n\n // ### `_unescape` replaces N3 escape codes by their corresponding characters\n _unescape: function (item) {\n try {\n return item.replace(escapeSequence, function (sequence, unicode4, unicode8, escapedChar) {\n var charCode;\n if (unicode4) {\n charCode = parseInt(unicode4, 16);\n if (isNaN(charCode)) throw new Error(); // can never happen (regex), but helps performance\n return fromCharCode(charCode);\n }\n else if (unicode8) {\n charCode = parseInt(unicode8, 16);\n if (isNaN(charCode)) throw new Error(); // can never happen (regex), but helps performance\n if (charCode <= 0xFFFF) return fromCharCode(charCode);\n return fromCharCode(0xD800 + ((charCode -= 0x10000) / 0x400), 0xDC00 + (charCode & 0x3FF));\n }\n else {\n var replacement = escapeReplacements[escapedChar];\n if (!replacement)\n throw new Error();\n return replacement;\n }\n });\n }\n catch (error) { return null; }\n },\n\n // ### `_syntaxError` creates a syntax error for the given issue\n _syntaxError: function (issue) {\n this._input = null;\n return new Error('Unexpected \"' + issue + '\" on line ' + this._line + '.');\n },\n\n\n // ## Public methods\n\n // ### `tokenize` starts the transformation of an N3 document into an array of tokens.\n // The input can be a string or a stream.\n tokenize: function (input, callback) {\n var self = this;\n this._line = 1;\n\n // If the input is a string, continuously emit tokens through the callback until the end\n if (typeof input === 'string') {\n this._input = input;\n // If a callback was passed, asynchronously call it\n if (typeof callback === 'function')\n immediately(function () { self._tokenizeToEnd(callback, true); });\n // If no callback was passed, tokenize synchronously and return\n else {\n var tokens = [], error;\n this._tokenizeToEnd(function (e, t) { e ? (error = e) : tokens.push(t); }, true);\n if (error) throw error;\n return tokens;\n }\n }\n // Otherwise, the input must be a stream\n else {\n this._input = '';\n if (typeof input.setEncoding === 'function')\n input.setEncoding('utf8');\n // Adds the data chunk to the buffer and parses as far as possible\n input.on('data', function (data) {\n if (self._input !== null) {\n self._input += data;\n self._tokenizeToEnd(callback, false);\n }\n });\n // Parses until the end\n input.on('end', function () {\n if (self._input !== null)\n self._tokenizeToEnd(callback, true);\n });\n }\n },\n};\n\n// ## Exports\nmodule.exports = N3Lexer;\n","// **N3Parser** parses N3 documents.\nvar N3Lexer = require('./N3Lexer');\n\nvar RDF_PREFIX = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',\n RDF_NIL = RDF_PREFIX + 'nil',\n RDF_FIRST = RDF_PREFIX + 'first',\n RDF_REST = RDF_PREFIX + 'rest';\n\nvar QUANTIFIERS_GRAPH = 'urn:n3:quantifiers';\n\nvar absoluteIRI = /^[a-z][a-z0-9+.-]*:/i,\n schemeAuthority = /^(?:([a-z][a-z0-9+.-]*:))?(?:\\/\\/[^\\/]*)?/i,\n dotSegments = /(?:^|\\/)\\.\\.?(?:$|[\\/#?])/;\n\n// The next ID for new blank nodes\nvar blankNodePrefix = 0, blankNodeCount = 0;\n\n// ## Constructor\nfunction N3Parser(options) {\n if (!(this instanceof N3Parser))\n return new N3Parser(options);\n this._contextStack = [];\n this._graph = null;\n\n // Set the document IRI\n options = options || {};\n this._setBase(options.documentIRI);\n\n // Set supported features depending on the format\n var format = (typeof options.format === 'string') ?\n options.format.match(/\\w*$/)[0].toLowerCase() : '',\n isTurtle = format === 'turtle', isTriG = format === 'trig',\n isNTriples = /triple/.test(format), isNQuads = /quad/.test(format),\n isN3 = this._n3Mode = /n3/.test(format),\n isLineMode = isNTriples || isNQuads;\n if (!(this._supportsNamedGraphs = !(isTurtle || isN3)))\n this._readPredicateOrNamedGraph = this._readPredicate;\n this._supportsQuads = !(isTurtle || isTriG || isNTriples || isN3);\n // Disable relative IRIs in N-Triples or N-Quads mode\n if (isLineMode) {\n this._base = '';\n this._resolveIRI = function (token) {\n this._error('Disallowed relative IRI', token);\n return this._callback = noop, this._subject = null;\n };\n }\n this._blankNodePrefix = typeof options.blankNodePrefix !== 'string' ? '' :\n '_:' + options.blankNodePrefix.replace(/^_:/, '');\n this._lexer = options.lexer || new N3Lexer({ lineMode: isLineMode, n3: isN3 });\n // Disable explicit quantifiers by default\n this._explicitQuantifiers = !!options.explicitQuantifiers;\n}\n\n// ## Private class methods\n\n// ### `_resetBlankNodeIds` restarts blank node identification\nN3Parser._resetBlankNodeIds = function () {\n blankNodePrefix = blankNodeCount = 0;\n};\n\nN3Parser.prototype = {\n // ## Private methods\n\n // ### `_setBase` sets the base IRI to resolve relative IRIs\n _setBase: function (baseIRI) {\n if (!baseIRI)\n this._base = null;\n else {\n // Remove fragment if present\n var fragmentPos = baseIRI.indexOf('#');\n if (fragmentPos >= 0)\n baseIRI = baseIRI.substr(0, fragmentPos);\n // Set base IRI and its components\n this._base = baseIRI;\n this._basePath = baseIRI.indexOf('/') < 0 ? baseIRI :\n baseIRI.replace(/[^\\/?]*(?:\\?.*)?$/, '');\n baseIRI = baseIRI.match(schemeAuthority);\n this._baseRoot = baseIRI[0];\n this._baseScheme = baseIRI[1];\n }\n },\n\n // ### `_saveContext` stores the current parsing context\n // when entering a new scope (list, blank node, formula)\n _saveContext: function (type, graph, subject, predicate, object) {\n var n3Mode = this._n3Mode;\n this._contextStack.push({\n subject: subject, predicate: predicate, object: object,\n graph: graph, type: type,\n inverse: n3Mode ? this._inversePredicate : false,\n blankPrefix: n3Mode ? this._prefixes._ : '',\n quantified: n3Mode ? this._quantified : null,\n });\n // The settings below only apply to N3 streams\n if (n3Mode) {\n // Every new scope resets the predicate direction\n this._inversePredicate = false;\n // In N3, blank nodes are scoped to a formula\n // (using a dot as separator, as a blank node label cannot start with it)\n this._prefixes._ = this._graph + '.';\n // Quantifiers are scoped to a formula\n this._quantified = Object.create(this._quantified);\n }\n },\n\n // ### `_restoreContext` restores the parent context\n // when leaving a scope (list, blank node, formula)\n _restoreContext: function () {\n var context = this._contextStack.pop(), n3Mode = this._n3Mode;\n this._subject = context.subject;\n this._predicate = context.predicate;\n this._object = context.object;\n this._graph = context.graph;\n // The settings below only apply to N3 streams\n if (n3Mode) {\n this._inversePredicate = context.inverse;\n this._prefixes._ = context.blankPrefix;\n this._quantified = context.quantified;\n }\n },\n\n // ### `_readInTopContext` reads a token when in the top context\n _readInTopContext: function (token) {\n switch (token.type) {\n // If an EOF token arrives in the top context, signal that we're done\n case 'eof':\n if (this._graph !== null)\n return this._error('Unclosed graph', token);\n delete this._prefixes._;\n return this._callback(null, null, this._prefixes);\n // It could be a prefix declaration\n case 'PREFIX':\n this._sparqlStyle = true;\n case '@prefix':\n return this._readPrefix;\n // It could be a base declaration\n case 'BASE':\n this._sparqlStyle = true;\n case '@base':\n return this._readBaseIRI;\n // It could be a graph\n case '{':\n if (this._supportsNamedGraphs) {\n this._graph = '';\n this._subject = null;\n return this._readSubject;\n }\n case 'GRAPH':\n if (this._supportsNamedGraphs)\n return this._readNamedGraphLabel;\n // Otherwise, the next token must be a subject\n default:\n return this._readSubject(token);\n }\n },\n\n // ### `_readEntity` reads an IRI, prefixed name, blank node, or variable\n _readEntity: function (token, quantifier) {\n var value;\n switch (token.type) {\n // Read a relative or absolute IRI\n case 'IRI':\n case 'typeIRI':\n value = (this._base === null || absoluteIRI.test(token.value)) ?\n token.value : this._resolveIRI(token);\n break;\n // Read a blank node or prefixed name\n case 'type':\n case 'blank':\n case 'prefixed':\n var prefix = this._prefixes[token.prefix];\n if (prefix === undefined)\n return this._error('Undefined prefix \"' + token.prefix + ':\"', token);\n value = prefix + token.value;\n break;\n // Read a variable\n case 'var':\n return token.value;\n // Everything else is not an entity\n default:\n return this._error('Expected entity but got ' + token.type, token);\n }\n // In N3 mode, replace the entity if it is quantified\n if (!quantifier && this._n3Mode && (value in this._quantified))\n value = this._quantified[value];\n return value;\n },\n\n // ### `_readSubject` reads a triple's subject\n _readSubject: function (token) {\n this._predicate = null;\n switch (token.type) {\n case '[':\n // Start a new triple with a new blank node as subject\n this._saveContext('blank', this._graph,\n this._subject = '_:b' + blankNodeCount++, null, null);\n return this._readBlankNodeHead;\n case '(':\n // Start a new list\n this._saveContext('list', this._graph, RDF_NIL, null, null);\n this._subject = null;\n return this._readListItem;\n case '{':\n // Start a new formula\n if (!this._n3Mode)\n return this._error('Unexpected graph', token);\n this._saveContext('formula', this._graph,\n this._graph = '_:b' + blankNodeCount++, null, null);\n return this._readSubject;\n case '}':\n // No subject; the graph in which we are reading is closed instead\n return this._readPunctuation(token);\n case '@forSome':\n this._subject = null;\n this._predicate = 'http://www.w3.org/2000/10/swap/reify#forSome';\n this._quantifiedPrefix = '_:b';\n return this._readQuantifierList;\n case '@forAll':\n this._subject = null;\n this._predicate = 'http://www.w3.org/2000/10/swap/reify#forAll';\n this._quantifiedPrefix = '?b-';\n return this._readQuantifierList;\n default:\n // Read the subject entity\n if ((this._subject = this._readEntity(token)) === undefined)\n return;\n // In N3 mode, the subject might be a path\n if (this._n3Mode)\n return this._getPathReader(this._readPredicateOrNamedGraph);\n }\n\n // The next token must be a predicate,\n // or, if the subject was actually a graph IRI, a named graph\n return this._readPredicateOrNamedGraph;\n },\n\n // ### `_readPredicate` reads a triple's predicate\n _readPredicate: function (token) {\n var type = token.type;\n switch (type) {\n case 'inverse':\n this._inversePredicate = true;\n case 'abbreviation':\n this._predicate = token.value;\n break;\n case '.':\n case ']':\n case '}':\n // Expected predicate didn't come, must have been trailing semicolon\n if (this._predicate === null)\n return this._error('Unexpected ' + type, token);\n this._subject = null;\n return type === ']' ? this._readBlankNodeTail(token) : this._readPunctuation(token);\n case ';':\n // Extra semicolons can be safely ignored\n return this._readPredicate;\n case 'blank':\n if (!this._n3Mode)\n return this._error('Disallowed blank node as predicate', token);\n default:\n if ((this._predicate = this._readEntity(token)) === undefined)\n return;\n }\n // The next token must be an object\n return this._readObject;\n },\n\n // ### `_readObject` reads a triple's object\n _readObject: function (token) {\n switch (token.type) {\n case 'literal':\n this._object = token.value;\n return this._readDataTypeOrLang;\n case '[':\n // Start a new triple with a new blank node as subject\n this._saveContext('blank', this._graph, this._subject, this._predicate,\n this._subject = '_:b' + blankNodeCount++);\n return this._readBlankNodeHead;\n case '(':\n // Start a new list\n this._saveContext('list', this._graph, this._subject, this._predicate, RDF_NIL);\n this._subject = null;\n return this._readListItem;\n case '{':\n // Start a new formula\n if (!this._n3Mode)\n return this._error('Unexpected graph', token);\n this._saveContext('formula', this._graph, this._subject, this._predicate,\n this._graph = '_:b' + blankNodeCount++);\n return this._readSubject;\n default:\n // Read the object entity\n if ((this._object = this._readEntity(token)) === undefined)\n return;\n // In N3 mode, the object might be a path\n if (this._n3Mode)\n return this._getPathReader(this._getContextEndReader());\n }\n return this._getContextEndReader();\n },\n\n // ### `_readPredicateOrNamedGraph` reads a triple's predicate, or a named graph\n _readPredicateOrNamedGraph: function (token) {\n return token.type === '{' ? this._readGraph(token) : this._readPredicate(token);\n },\n\n // ### `_readGraph` reads a graph\n _readGraph: function (token) {\n if (token.type !== '{')\n return this._error('Expected graph but got ' + token.type, token);\n // The \"subject\" we read is actually the GRAPH's label\n this._graph = this._subject, this._subject = null;\n return this._readSubject;\n },\n\n // ### `_readBlankNodeHead` reads the head of a blank node\n _readBlankNodeHead: function (token) {\n if (token.type === ']') {\n this._subject = null;\n return this._readBlankNodeTail(token);\n }\n else {\n this._predicate = null;\n return this._readPredicate(token);\n }\n },\n\n // ### `_readBlankNodeTail` reads the end of a blank node\n _readBlankNodeTail: function (token) {\n if (token.type !== ']')\n return this._readBlankNodePunctuation(token);\n\n // Store blank node triple\n if (this._subject !== null)\n this._triple(this._subject, this._predicate, this._object, this._graph);\n\n // Restore the parent context containing this blank node\n var empty = this._predicate === null;\n this._restoreContext();\n // If the blank node was the subject, continue reading the predicate\n if (this._object === null)\n // If the blank node was empty, it could be a named graph label\n return empty ? this._readPredicateOrNamedGraph : this._readPredicateAfterBlank;\n // If the blank node was the object, restore previous context and read punctuation\n else\n return this._getContextEndReader();\n },\n\n // ### `_readPredicateAfterBlank` reads a predicate after an anonymous blank node\n _readPredicateAfterBlank: function (token) {\n // If a dot follows a blank node in top context, there is no predicate\n if (token.type === '.' && !this._contextStack.length) {\n this._subject = null; // cancel the current triple\n return this._readPunctuation(token);\n }\n return this._readPredicate(token);\n },\n\n // ### `_readListItem` reads items from a list\n _readListItem: function (token) {\n var item = null, // The item of the list\n list = null, // The list itself\n prevList = this._subject, // The previous list that contains this list\n stack = this._contextStack, // The stack of parent contexts\n parent = stack[stack.length - 1], // The parent containing the current list\n next = this._readListItem, // The next function to execute\n itemComplete = true; // Whether the item has been read fully\n\n switch (token.type) {\n case '[':\n // Stack the current list triple and start a new triple with a blank node as subject\n this._saveContext('blank', this._graph, list = '_:b' + blankNodeCount++,\n RDF_FIRST, this._subject = item = '_:b' + blankNodeCount++);\n next = this._readBlankNodeHead;\n break;\n case '(':\n // Stack the current list triple and start a new list\n this._saveContext('list', this._graph, list = '_:b' + blankNodeCount++,\n RDF_FIRST, RDF_NIL);\n this._subject = null;\n break;\n case ')':\n // Closing the list; restore the parent context\n this._restoreContext();\n // If this list is contained within a parent list, return the membership triple here.\n // This will be ` rdf:first .`.\n if (stack.length !== 0 && stack[stack.length - 1].type === 'list')\n this._triple(this._subject, this._predicate, this._object, this._graph);\n // Was this list the parent's subject?\n if (this._predicate === null) {\n // The next token is the predicate\n next = this._readPredicate;\n // No list tail if this was an empty list\n if (this._subject === RDF_NIL)\n return next;\n }\n // The list was in the parent context's object\n else {\n next = this._getContextEndReader();\n // No list tail if this was an empty list\n if (this._object === RDF_NIL)\n return next;\n }\n // Close the list by making the head nil\n list = RDF_NIL;\n break;\n case 'literal':\n item = token.value;\n itemComplete = false; // Can still have a datatype or language\n next = this._readListItemDataTypeOrLang;\n break;\n default:\n if ((item = this._readEntity(token)) === undefined)\n return;\n }\n\n // Create a new blank node if no item head was assigned yet\n if (list === null)\n this._subject = list = '_:b' + blankNodeCount++;\n\n // Is this the first element of the list?\n if (prevList === null) {\n // This list is either the subject or the object of its parent\n if (parent.predicate === null)\n parent.subject = list;\n else\n parent.object = list;\n }\n else {\n // Continue the previous list with the current list\n this._triple(prevList, RDF_REST, list, this._graph);\n }\n // Add the item's value\n if (item !== null) {\n // In N3 mode, the item might be a path\n if (this._n3Mode && (token.type === 'IRI' || token.type === 'prefixed')) {\n // Create a new context to add the item's path\n this._saveContext('item', this._graph, list, RDF_FIRST, item);\n this._subject = item, this._predicate = null;\n // _readPath will restore the context and output the item\n return this._getPathReader(this._readListItem);\n }\n // Output the item if it is complete\n if (itemComplete)\n this._triple(list, RDF_FIRST, item, this._graph);\n // Otherwise, save it for completion\n else\n this._object = item;\n }\n return next;\n },\n\n // ### `_readDataTypeOrLang` reads an _optional_ data type or language\n _readDataTypeOrLang: function (token) {\n return this._completeLiteral(token, false);\n },\n\n // ### `_readListItemDataTypeOrLang` reads an _optional_ data type or language in a list\n _readListItemDataTypeOrLang: function (token) {\n return this._completeLiteral(token, true);\n },\n\n // ### `_completeLiteral` completes the object with a data type or language\n _completeLiteral: function (token, listItem) {\n var suffix = false;\n switch (token.type) {\n // Add a \"^^type\" suffix for types (IRIs and blank nodes)\n case 'type':\n case 'typeIRI':\n suffix = true;\n this._object += '^^' + this._readEntity(token);\n break;\n // Add an \"@lang\" suffix for language tags\n case 'langcode':\n suffix = true;\n this._object += '@' + token.value.toLowerCase();\n break;\n }\n // If this literal was part of a list, write the item\n // (we could also check the context stack, but passing in a flag is faster)\n if (listItem)\n this._triple(this._subject, RDF_FIRST, this._object, this._graph);\n // Continue with the rest of the input\n if (suffix)\n return this._getContextEndReader();\n else {\n this._readCallback = this._getContextEndReader();\n return this._readCallback(token);\n }\n },\n\n // ### `_readFormulaTail` reads the end of a formula\n _readFormulaTail: function (token) {\n if (token.type !== '}')\n return this._readPunctuation(token);\n\n // Store the last triple of the formula\n if (this._subject !== null)\n this._triple(this._subject, this._predicate, this._object, this._graph);\n\n // Restore the parent context containing this formula\n this._restoreContext();\n // If the formula was the subject, continue reading the predicate.\n // If the formula was the object, read punctuation.\n return this._object === null ? this._readPredicate : this._getContextEndReader();\n },\n\n // ### `_readPunctuation` reads punctuation between triples or triple parts\n _readPunctuation: function (token) {\n var next, subject = this._subject, graph = this._graph,\n inversePredicate = this._inversePredicate;\n switch (token.type) {\n // A closing brace ends a graph\n case '}':\n if (this._graph === null)\n return this._error('Unexpected graph closing', token);\n if (this._n3Mode)\n return this._readFormulaTail(token);\n this._graph = null;\n // A dot just ends the statement, without sharing anything with the next\n case '.':\n this._subject = null;\n next = this._contextStack.length ? this._readSubject : this._readInTopContext;\n if (inversePredicate) this._inversePredicate = false;\n break;\n // Semicolon means the subject is shared; predicate and object are different\n case ';':\n next = this._readPredicate;\n break;\n // Comma means both the subject and predicate are shared; the object is different\n case ',':\n next = this._readObject;\n break;\n default:\n // An entity means this is a quad (only allowed if not already inside a graph)\n if (this._supportsQuads && this._graph === null && (graph = this._readEntity(token)) !== undefined) {\n next = this._readQuadPunctuation;\n break;\n }\n return this._error('Expected punctuation to follow \"' + this._object + '\"', token);\n }\n // A triple has been completed now, so return it\n if (subject !== null) {\n var predicate = this._predicate, object = this._object;\n if (!inversePredicate)\n this._triple(subject, predicate, object, graph);\n else\n this._triple(object, predicate, subject, graph);\n }\n return next;\n },\n\n // ### `_readBlankNodePunctuation` reads punctuation in a blank node\n _readBlankNodePunctuation: function (token) {\n var next;\n switch (token.type) {\n // Semicolon means the subject is shared; predicate and object are different\n case ';':\n next = this._readPredicate;\n break;\n // Comma means both the subject and predicate are shared; the object is different\n case ',':\n next = this._readObject;\n break;\n default:\n return this._error('Expected punctuation to follow \"' + this._object + '\"', token);\n }\n // A triple has been completed now, so return it\n this._triple(this._subject, this._predicate, this._object, this._graph);\n return next;\n },\n\n // ### `_readQuadPunctuation` reads punctuation after a quad\n _readQuadPunctuation: function (token) {\n if (token.type !== '.')\n return this._error('Expected dot to follow quad', token);\n return this._readInTopContext;\n },\n\n // ### `_readPrefix` reads the prefix of a prefix declaration\n _readPrefix: function (token) {\n if (token.type !== 'prefix')\n return this._error('Expected prefix to follow @prefix', token);\n this._prefix = token.value;\n return this._readPrefixIRI;\n },\n\n // ### `_readPrefixIRI` reads the IRI of a prefix declaration\n _readPrefixIRI: function (token) {\n if (token.type !== 'IRI')\n return this._error('Expected IRI to follow prefix \"' + this._prefix + ':\"', token);\n var prefixIRI = this._readEntity(token);\n this._prefixes[this._prefix] = prefixIRI;\n this._prefixCallback(this._prefix, prefixIRI);\n return this._readDeclarationPunctuation;\n },\n\n // ### `_readBaseIRI` reads the IRI of a base declaration\n _readBaseIRI: function (token) {\n if (token.type !== 'IRI')\n return this._error('Expected IRI to follow base declaration', token);\n this._setBase(this._base === null || absoluteIRI.test(token.value) ?\n token.value : this._resolveIRI(token));\n return this._readDeclarationPunctuation;\n },\n\n // ### `_readNamedGraphLabel` reads the label of a named graph\n _readNamedGraphLabel: function (token) {\n switch (token.type) {\n case 'IRI':\n case 'blank':\n case 'prefixed':\n return this._readSubject(token), this._readGraph;\n case '[':\n return this._readNamedGraphBlankLabel;\n default:\n return this._error('Invalid graph label', token);\n }\n },\n\n // ### `_readNamedGraphLabel` reads a blank node label of a named graph\n _readNamedGraphBlankLabel: function (token) {\n if (token.type !== ']')\n return this._error('Invalid graph label', token);\n this._subject = '_:b' + blankNodeCount++;\n return this._readGraph;\n },\n\n // ### `_readDeclarationPunctuation` reads the punctuation of a declaration\n _readDeclarationPunctuation: function (token) {\n // SPARQL-style declarations don't have punctuation\n if (this._sparqlStyle) {\n this._sparqlStyle = false;\n return this._readInTopContext(token);\n }\n\n if (token.type !== '.')\n return this._error('Expected declaration to end with a dot', token);\n return this._readInTopContext;\n },\n\n // Reads a list of quantified symbols from a @forSome or @forAll statement\n _readQuantifierList: function (token) {\n var entity;\n switch (token.type) {\n case 'IRI':\n case 'prefixed':\n if ((entity = this._readEntity(token, true)) !== undefined)\n break;\n default:\n return this._error('Unexpected ' + token.type, token);\n }\n // Without explicit quantifiers, map entities to a quantified entity\n if (!this._explicitQuantifiers)\n this._quantified[entity] = this._quantifiedPrefix + blankNodeCount++;\n // With explicit quantifiers, output the reified quantifier\n else {\n // If this is the first item, start a new quantifier list\n if (this._subject === null)\n this._triple(this._graph || '', this._predicate,\n this._subject = '_:b' + blankNodeCount++, QUANTIFIERS_GRAPH);\n // Otherwise, continue the previous list\n else\n this._triple(this._subject, RDF_REST,\n this._subject = '_:b' + blankNodeCount++, QUANTIFIERS_GRAPH);\n // Output the list item\n this._triple(this._subject, RDF_FIRST, entity, QUANTIFIERS_GRAPH);\n }\n return this._readQuantifierPunctuation;\n },\n\n // Reads punctuation from a @forSome or @forAll statement\n _readQuantifierPunctuation: function (token) {\n // Read more quantifiers\n if (token.type === ',')\n return this._readQuantifierList;\n // End of the quantifier list\n else {\n // With explicit quantifiers, close the quantifier list\n if (this._explicitQuantifiers) {\n this._triple(this._subject, RDF_REST, RDF_NIL, QUANTIFIERS_GRAPH);\n this._subject = null;\n }\n // Read a dot\n this._readCallback = this._getContextEndReader();\n return this._readCallback(token);\n }\n },\n\n // ### `_getPathReader` reads a potential path and then resumes with the given function\n _getPathReader: function (afterPath) {\n this._afterPath = afterPath;\n return this._readPath;\n },\n\n // ### `_readPath` reads a potential path\n _readPath: function (token) {\n switch (token.type) {\n // Forward path\n case '!': return this._readForwardPath;\n // Backward path\n case '^': return this._readBackwardPath;\n // Not a path; resume reading where we left off\n default:\n var stack = this._contextStack, parent = stack.length && stack[stack.length - 1];\n // If we were reading a list item, we still need to output it\n if (parent && parent.type === 'item') {\n // The list item is the remaining subejct after reading the path\n var item = this._subject;\n // Switch back to the context of the list\n this._restoreContext();\n // Output the list item\n this._triple(this._subject, RDF_FIRST, item, this._graph);\n }\n return this._afterPath(token);\n }\n },\n\n // ### `_readForwardPath` reads a '!' path\n _readForwardPath: function (token) {\n var subject, predicate, object = '_:b' + blankNodeCount++;\n // The next token is the predicate\n if ((predicate = this._readEntity(token)) === undefined)\n return;\n // If we were reading a subject, replace the subject by the path's object\n if (this._predicate === null)\n subject = this._subject, this._subject = object;\n // If we were reading an object, replace the subject by the path's object\n else\n subject = this._object, this._object = object;\n // Emit the path's current triple and read its next section\n this._triple(subject, predicate, object, this._graph);\n return this._readPath;\n },\n\n // ### `_readBackwardPath` reads a '^' path\n _readBackwardPath: function (token) {\n var subject = '_:b' + blankNodeCount++, predicate, object;\n // The next token is the predicate\n if ((predicate = this._readEntity(token)) === undefined)\n return;\n // If we were reading a subject, replace the subject by the path's subject\n if (this._predicate === null)\n object = this._subject, this._subject = subject;\n // If we were reading an object, replace the subject by the path's subject\n else\n object = this._object, this._object = subject;\n // Emit the path's current triple and read its next section\n this._triple(subject, predicate, object, this._graph);\n return this._readPath;\n },\n\n // ### `_getContextEndReader` gets the next reader function at the end of a context\n _getContextEndReader: function () {\n var contextStack = this._contextStack;\n if (!contextStack.length)\n return this._readPunctuation;\n\n switch (contextStack[contextStack.length - 1].type) {\n case 'blank':\n return this._readBlankNodeTail;\n case 'list':\n return this._readListItem;\n case 'formula':\n return this._readFormulaTail;\n }\n },\n\n // ### `_triple` emits a triple through the callback\n _triple: function (subject, predicate, object, graph) {\n this._callback(null,\n { subject: subject, predicate: predicate, object: object, graph: graph || '' });\n },\n\n // ### `_error` emits an error message through the callback\n _error: function (message, token) {\n this._callback(new Error(message + ' on line ' + token.line + '.'));\n },\n\n // ### `_resolveIRI` resolves a relative IRI token against the base path,\n // assuming that a base path has been set and that the IRI is indeed relative\n _resolveIRI: function (token) {\n var iri = token.value;\n switch (iri[0]) {\n // An empty relative IRI indicates the base IRI\n case undefined: return this._base;\n // Resolve relative fragment IRIs against the base IRI\n case '#': return this._base + iri;\n // Resolve relative query string IRIs by replacing the query string\n case '?': return this._base.replace(/(?:\\?.*)?$/, iri);\n // Resolve root-relative IRIs at the root of the base IRI\n case '/':\n // Resolve scheme-relative IRIs to the scheme\n return (iri[1] === '/' ? this._baseScheme : this._baseRoot) + this._removeDotSegments(iri);\n // Resolve all other IRIs at the base IRI's path\n default:\n return this._removeDotSegments(this._basePath + iri);\n }\n },\n\n // ### `_removeDotSegments` resolves './' and '../' path segments in an IRI as per RFC3986\n _removeDotSegments: function (iri) {\n // Don't modify the IRI if it does not contain any dot segments\n if (!dotSegments.test(iri))\n return iri;\n\n // Start with an imaginary slash before the IRI in order to resolve trailing './' and '../'\n var result = '', length = iri.length, i = -1, pathStart = -1, segmentStart = 0, next = '/';\n\n while (i < length) {\n switch (next) {\n // The path starts with the first slash after the authority\n case ':':\n if (pathStart < 0) {\n // Skip two slashes before the authority\n if (iri[++i] === '/' && iri[++i] === '/')\n // Skip to slash after the authority\n while ((pathStart = i + 1) < length && iri[pathStart] !== '/')\n i = pathStart;\n }\n break;\n // Don't modify a query string or fragment\n case '?':\n case '#':\n i = length;\n break;\n // Handle '/.' or '/..' path segments\n case '/':\n if (iri[i + 1] === '.') {\n next = iri[++i + 1];\n switch (next) {\n // Remove a '/.' segment\n case '/':\n result += iri.substring(segmentStart, i - 1);\n segmentStart = i + 1;\n break;\n // Remove a trailing '/.' segment\n case undefined:\n case '?':\n case '#':\n return result + iri.substring(segmentStart, i) + iri.substr(i + 1);\n // Remove a '/..' segment\n case '.':\n next = iri[++i + 1];\n if (next === undefined || next === '/' || next === '?' || next === '#') {\n result += iri.substring(segmentStart, i - 2);\n // Try to remove the parent path from result\n if ((segmentStart = result.lastIndexOf('/')) >= pathStart)\n result = result.substr(0, segmentStart);\n // Remove a trailing '/..' segment\n if (next !== '/')\n return result + '/' + iri.substr(i + 1);\n segmentStart = i + 1;\n }\n }\n }\n }\n next = iri[++i];\n }\n return result + iri.substring(segmentStart);\n },\n\n // ## Public methods\n\n // ### `parse` parses the N3 input and emits each parsed triple through the callback\n parse: function (input, tripleCallback, prefixCallback) {\n var self = this;\n // The read callback is the next function to be executed when a token arrives.\n // We start reading in the top context.\n this._readCallback = this._readInTopContext;\n this._sparqlStyle = false;\n this._prefixes = Object.create(null);\n this._prefixes._ = this._blankNodePrefix || '_:b' + blankNodePrefix++ + '_';\n this._prefixCallback = prefixCallback || noop;\n this._inversePredicate = false;\n this._quantified = Object.create(null);\n\n // Parse synchronously if no triple callback is given\n if (!tripleCallback) {\n var triples = [], error;\n this._callback = function (e, t) { e ? (error = e) : t && triples.push(t); };\n this._lexer.tokenize(input).every(function (token) {\n return self._readCallback = self._readCallback(token);\n });\n if (error) throw error;\n return triples;\n }\n\n // Parse asynchronously otherwise, executing the read callback when a token arrives\n this._callback = tripleCallback;\n this._lexer.tokenize(input, function (error, token) {\n if (error !== null)\n self._callback(error), self._callback = noop;\n else if (self._readCallback)\n self._readCallback = self._readCallback(token);\n });\n },\n};\n\n// The empty function\nfunction noop() {}\n\n// ## Exports\nmodule.exports = N3Parser;\n","// **N3Util** provides N3 utility functions.\n\nvar Xsd = 'http://www.w3.org/2001/XMLSchema#';\nvar XsdString = Xsd + 'string';\nvar XsdInteger = Xsd + 'integer';\nvar XsdDecimal = Xsd + 'decimal';\nvar XsdBoolean = Xsd + 'boolean';\nvar RdfLangString = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#langString';\n\nvar N3Util = {\n // Tests whether the given entity (triple object) represents an IRI in the N3 library\n isIRI: function (entity) {\n if (!entity)\n return entity;\n var firstChar = entity[0];\n return firstChar !== '\"' && firstChar !== '_';\n },\n\n // Tests whether the given entity (triple object) represents a literal in the N3 library\n isLiteral: function (entity) {\n return entity && entity[0] === '\"';\n },\n\n // Tests whether the given entity (triple object) represents a blank node in the N3 library\n isBlank: function (entity) {\n return entity && entity.substr(0, 2) === '_:';\n },\n\n // Tests whether the given entity represents the default graph\n isDefaultGraph: function (entity) {\n return !entity;\n },\n\n // Tests whether the given triple is in the default graph\n inDefaultGraph: function (triple) {\n return !triple.graph;\n },\n\n // Gets the string value of a literal in the N3 library\n getLiteralValue: function (literal) {\n var match = /^\"([^]*)\"/.exec(literal);\n if (!match)\n throw new Error(literal + ' is not a literal');\n return match[1];\n },\n\n // Gets the type of a literal in the N3 library\n getLiteralType: function (literal) {\n var match = /^\"[^]*\"(?:\\^\\^([^\"]+)|(@)[^@\"]+)?$/.exec(literal);\n if (!match)\n throw new Error(literal + ' is not a literal');\n return match[1] || (match[2] ? RdfLangString : XsdString);\n },\n\n // Gets the language of a literal in the N3 library\n getLiteralLanguage: function (literal) {\n var match = /^\"[^]*\"(?:@([^@\"]+)|\\^\\^[^\"]+)?$/.exec(literal);\n if (!match)\n throw new Error(literal + ' is not a literal');\n return match[1] ? match[1].toLowerCase() : '';\n },\n\n // Tests whether the given entity (triple object) represents a prefixed name\n isPrefixedName: function (entity) {\n return entity && /^[^:\\/\"']*:[^:\\/\"']+$/.test(entity);\n },\n\n // Expands the prefixed name to a full IRI (also when it occurs as a literal's type)\n expandPrefixedName: function (prefixedName, prefixes) {\n var match = /(?:^|\"\\^\\^)([^:\\/#\"'\\^_]*):[^\\/]*$/.exec(prefixedName), prefix, base, index;\n if (match)\n prefix = match[1], base = prefixes[prefix], index = match.index;\n if (base === undefined)\n return prefixedName;\n\n // The match index is non-zero when expanding a literal's type\n return index === 0 ? base + prefixedName.substr(prefix.length + 1)\n : prefixedName.substr(0, index + 3) +\n base + prefixedName.substr(index + prefix.length + 4);\n },\n\n // Creates an IRI in N3.js representation\n createIRI: function (iri) {\n return iri && iri[0] === '\"' ? N3Util.getLiteralValue(iri) : iri;\n },\n\n // Creates a literal in N3.js representation\n createLiteral: function (value, modifier) {\n if (!modifier) {\n switch (typeof value) {\n case 'boolean':\n modifier = XsdBoolean;\n break;\n case 'number':\n if (isFinite(value)) {\n modifier = value % 1 === 0 ? XsdInteger : XsdDecimal;\n break;\n }\n default:\n return '\"' + value + '\"';\n }\n }\n return '\"' + value +\n (/^[a-z]+(-[a-z0-9]+)*$/i.test(modifier) ? '\"@' + modifier.toLowerCase()\n : '\"^^' + modifier);\n },\n\n // Creates a function that prepends the given IRI to a local name\n prefix: function (iri) {\n return N3Util.prefixes({ '': iri })('');\n },\n\n // Creates a function that allows registering and expanding prefixes\n prefixes: function (defaultPrefixes) {\n // Add all of the default prefixes\n var prefixes = Object.create(null);\n for (var prefix in defaultPrefixes)\n processPrefix(prefix, defaultPrefixes[prefix]);\n\n // Registers a new prefix (if an IRI was specified)\n // or retrieves a function that expands an existing prefix (if no IRI was specified)\n function processPrefix(prefix, iri) {\n // Create a new prefix if an IRI is specified or the prefix doesn't exist\n if (iri || !(prefix in prefixes)) {\n var cache = Object.create(null);\n iri = iri || '';\n // Create a function that expands the prefix\n prefixes[prefix] = function (localName) {\n return cache[localName] || (cache[localName] = iri + localName);\n };\n }\n return prefixes[prefix];\n }\n return processPrefix;\n },\n};\n\n// Add the N3Util functions to the given object or its prototype\nfunction addN3Util(parent, toPrototype) {\n for (var name in N3Util)\n if (!toPrototype)\n parent[name] = N3Util[name];\n else\n parent.prototype[name] = applyToThis(N3Util[name]);\n\n return parent;\n}\n\n// Returns a function that applies `f` to the `this` object\nfunction applyToThis(f) {\n return function (a) { return f(this, a); };\n}\n\n// Expose N3Util, attaching all functions to it\nmodule.exports = addN3Util(addN3Util);\n","// **N3Writer** writes N3 documents.\n\n// Matches a literal as represented in memory by the N3 library\nvar N3LiteralMatcher = /^\"([^]*)\"(?:\\^\\^(.+)|@([\\-a-z]+))?$/i;\n\n// rdf:type predicate (for 'a' abbreviation)\nvar RDF_PREFIX = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',\n RDF_TYPE = RDF_PREFIX + 'type';\n\n// Characters in literals that require escaping\nvar escape = /[\"\\\\\\t\\n\\r\\b\\f\\u0000-\\u0019\\ud800-\\udbff]/,\n escapeAll = /[\"\\\\\\t\\n\\r\\b\\f\\u0000-\\u0019]|[\\ud800-\\udbff][\\udc00-\\udfff]/g,\n escapeReplacements = {\n '\\\\': '\\\\\\\\', '\"': '\\\\\"', '\\t': '\\\\t',\n '\\n': '\\\\n', '\\r': '\\\\r', '\\b': '\\\\b', '\\f': '\\\\f',\n };\n\n// ## Constructor\nfunction N3Writer(outputStream, options) {\n if (!(this instanceof N3Writer))\n return new N3Writer(outputStream, options);\n\n // Shift arguments if the first argument is not a stream\n if (outputStream && typeof outputStream.write !== 'function')\n options = outputStream, outputStream = null;\n options = options || {};\n\n // If no output stream given, send the output as string through the end callback\n if (!outputStream) {\n var output = '';\n this._outputStream = {\n write: function (chunk, encoding, done) { output += chunk; done && done(); },\n end: function (done) { done && done(null, output); },\n };\n this._endStream = true;\n }\n else {\n this._outputStream = outputStream;\n this._endStream = options.end === undefined ? true : !!options.end;\n }\n\n // Initialize writer, depending on the format\n this._subject = null;\n if (!(/triple|quad/i).test(options.format)) {\n this._graph = '';\n this._prefixIRIs = Object.create(null);\n options.prefixes && this.addPrefixes(options.prefixes);\n }\n else {\n this._writeTriple = this._writeTripleLine;\n }\n}\n\nN3Writer.prototype = {\n // ## Private methods\n\n // ### `_write` writes the argument to the output stream\n _write: function (string, callback) {\n this._outputStream.write(string, 'utf8', callback);\n },\n\n // ### `_writeTriple` writes the triple to the output stream\n _writeTriple: function (subject, predicate, object, graph, done) {\n try {\n // Write the graph's label if it has changed\n if (this._graph !== graph) {\n // Close the previous graph and start the new one\n this._write((this._subject === null ? '' : (this._graph ? '\\n}\\n' : '.\\n')) +\n (graph ? this._encodeIriOrBlankNode(graph) + ' {\\n' : ''));\n this._subject = null;\n // Don't treat identical blank nodes as repeating graphs\n this._graph = graph[0] !== '[' ? graph : ']';\n }\n // Don't repeat the subject if it's the same\n if (this._subject === subject) {\n // Don't repeat the predicate if it's the same\n if (this._predicate === predicate)\n this._write(', ' + this._encodeObject(object), done);\n // Same subject, different predicate\n else\n this._write(';\\n ' +\n this._encodePredicate(this._predicate = predicate) + ' ' +\n this._encodeObject(object), done);\n }\n // Different subject; write the whole triple\n else\n this._write((this._subject === null ? '' : '.\\n') +\n this._encodeSubject(this._subject = subject) + ' ' +\n this._encodePredicate(this._predicate = predicate) + ' ' +\n this._encodeObject(object), done);\n }\n catch (error) { done && done(error); }\n },\n\n // ### `_writeTripleLine` writes the triple or quad to the output stream as a single line\n _writeTripleLine: function (subject, predicate, object, graph, done) {\n // Don't use prefixes\n delete this._prefixMatch;\n // Write the triple\n try {\n this._write(this._encodeIriOrBlankNode(subject) + ' ' +\n this._encodeIriOrBlankNode(predicate) + ' ' +\n this._encodeObject(object) +\n (graph ? ' ' + this._encodeIriOrBlankNode(graph) + '.\\n' : '.\\n'), done);\n }\n catch (error) { done && done(error); }\n },\n\n // ### `_encodeIriOrBlankNode` represents an IRI or blank node\n _encodeIriOrBlankNode: function (entity) {\n // A blank node or list is represented as-is\n var firstChar = entity[0];\n if (firstChar === '[' || firstChar === '(' || firstChar === '_' && entity[1] === ':')\n return entity;\n // Escape special characters\n if (escape.test(entity))\n entity = entity.replace(escapeAll, characterReplacer);\n // Try to represent the IRI as prefixed name\n var prefixMatch = this._prefixRegex.exec(entity);\n return !prefixMatch ? '<' + entity + '>' :\n (!prefixMatch[1] ? entity : this._prefixIRIs[prefixMatch[1]] + prefixMatch[2]);\n },\n\n // ### `_encodeLiteral` represents a literal\n _encodeLiteral: function (value, type, language) {\n // Escape special characters\n if (escape.test(value))\n value = value.replace(escapeAll, characterReplacer);\n // Write the literal, possibly with type or language\n if (language)\n return '\"' + value + '\"@' + language;\n else if (type)\n return '\"' + value + '\"^^' + this._encodeIriOrBlankNode(type);\n else\n return '\"' + value + '\"';\n },\n\n // ### `_encodeSubject` represents a subject\n _encodeSubject: function (subject) {\n if (subject[0] === '\"')\n throw new Error('A literal as subject is not allowed: ' + subject);\n // Don't treat identical blank nodes as repeating subjects\n if (subject[0] === '[')\n this._subject = ']';\n return this._encodeIriOrBlankNode(subject);\n },\n\n // ### `_encodePredicate` represents a predicate\n _encodePredicate: function (predicate) {\n if (predicate[0] === '\"')\n throw new Error('A literal as predicate is not allowed: ' + predicate);\n return predicate === RDF_TYPE ? 'a' : this._encodeIriOrBlankNode(predicate);\n },\n\n // ### `_encodeObject` represents an object\n _encodeObject: function (object) {\n // Represent an IRI or blank node\n if (object[0] !== '\"')\n return this._encodeIriOrBlankNode(object);\n // Represent a literal\n var match = N3LiteralMatcher.exec(object);\n if (!match) throw new Error('Invalid literal: ' + object);\n return this._encodeLiteral(match[1], match[2], match[3]);\n },\n\n // ### `_blockedWrite` replaces `_write` after the writer has been closed\n _blockedWrite: function () {\n throw new Error('Cannot write because the writer has been closed.');\n },\n\n // ### `addTriple` adds the triple to the output stream\n addTriple: function (subject, predicate, object, graph, done) {\n // The triple was given as a triple object, so shift parameters\n if (object === undefined)\n this._writeTriple(subject.subject, subject.predicate, subject.object,\n subject.graph || '', predicate);\n // The optional `graph` parameter was not provided\n else if (typeof graph !== 'string')\n this._writeTriple(subject, predicate, object, '', graph);\n // The `graph` parameter was provided\n else\n this._writeTriple(subject, predicate, object, graph, done);\n },\n\n // ### `addTriples` adds the triples to the output stream\n addTriples: function (triples) {\n for (var i = 0; i < triples.length; i++)\n this.addTriple(triples[i]);\n },\n\n // ### `addPrefix` adds the prefix to the output stream\n addPrefix: function (prefix, iri, done) {\n var prefixes = {};\n prefixes[prefix] = iri;\n this.addPrefixes(prefixes, done);\n },\n\n // ### `addPrefixes` adds the prefixes to the output stream\n addPrefixes: function (prefixes, done) {\n // Add all useful prefixes\n var prefixIRIs = this._prefixIRIs, hasPrefixes = false;\n for (var prefix in prefixes) {\n // Verify whether the prefix can be used and does not exist yet\n var iri = prefixes[prefix];\n if (/[#\\/]$/.test(iri) && prefixIRIs[iri] !== (prefix += ':')) {\n hasPrefixes = true;\n prefixIRIs[iri] = prefix;\n // Finish a possible pending triple\n if (this._subject !== null) {\n this._write(this._graph ? '\\n}\\n' : '.\\n');\n this._subject = null, this._graph = '';\n }\n // Write prefix\n this._write('@prefix ' + prefix + ' <' + iri + '>.\\n');\n }\n }\n // Recreate the prefix matcher\n if (hasPrefixes) {\n var IRIlist = '', prefixList = '';\n for (var prefixIRI in prefixIRIs) {\n IRIlist += IRIlist ? '|' + prefixIRI : prefixIRI;\n prefixList += (prefixList ? '|' : '') + prefixIRIs[prefixIRI];\n }\n IRIlist = IRIlist.replace(/[\\]\\/\\(\\)\\*\\+\\?\\.\\\\\\$]/g, '\\\\$&');\n this._prefixRegex = new RegExp('^(?:' + prefixList + ')[^\\/]*$|' +\n '^(' + IRIlist + ')([a-zA-Z][\\\\-_a-zA-Z0-9]*)$');\n }\n // End a prefix block with a newline\n this._write(hasPrefixes ? '\\n' : '', done);\n },\n\n // ### `blank` creates a blank node with the given content\n blank: function (predicate, object) {\n var children = predicate, child, length;\n // Empty blank node\n if (predicate === undefined)\n children = [];\n // Blank node passed as blank(\"predicate\", \"object\")\n else if (typeof predicate === 'string')\n children = [{ predicate: predicate, object: object }];\n // Blank node passed as blank({ predicate: predicate, object: object })\n else if (!('length' in predicate))\n children = [predicate];\n\n switch (length = children.length) {\n // Generate an empty blank node\n case 0:\n return '[]';\n // Generate a non-nested one-triple blank node\n case 1:\n child = children[0];\n if (child.object[0] !== '[')\n return '[ ' + this._encodePredicate(child.predicate) + ' ' +\n this._encodeObject(child.object) + ' ]';\n // Generate a multi-triple or nested blank node\n default:\n var contents = '[';\n // Write all triples in order\n for (var i = 0; i < length; i++) {\n child = children[i];\n // Write only the object is the predicate is the same as the previous\n if (child.predicate === predicate)\n contents += ', ' + this._encodeObject(child.object);\n // Otherwise, write the predicate and the object\n else {\n contents += (i ? ';\\n ' : '\\n ') +\n this._encodePredicate(child.predicate) + ' ' +\n this._encodeObject(child.object);\n predicate = child.predicate;\n }\n }\n return contents + '\\n]';\n }\n },\n\n // ### `list` creates a list node with the given content\n list: function (elements) {\n var length = elements && elements.length || 0, contents = new Array(length);\n for (var i = 0; i < length; i++)\n contents[i] = this._encodeObject(elements[i]);\n return '(' + contents.join(' ') + ')';\n },\n\n // ### `_prefixRegex` matches a prefixed name or IRI that begins with one of the added prefixes\n _prefixRegex: /$0^/,\n\n // ### `end` signals the end of the output stream\n end: function (done) {\n // Finish a possible pending triple\n if (this._subject !== null) {\n this._write(this._graph ? '\\n}\\n' : '.\\n');\n this._subject = null;\n }\n // Disallow further writing\n this._write = this._blockedWrite;\n\n // Try to end the underlying stream, ensuring done is called exactly one time\n var singleDone = done && function (error, result) { singleDone = null, done(error, result); };\n if (this._endStream) {\n try { return this._outputStream.end(singleDone); }\n catch (error) { /* error closing stream */ }\n }\n singleDone && singleDone();\n },\n};\n\n// Replaces a character by its escaped version\nfunction characterReplacer(character) {\n // Replace a single character by its escaped version\n var result = escapeReplacements[character];\n if (result === undefined) {\n // Replace a single character with its 4-bit unicode escape sequence\n if (character.length === 1) {\n result = character.charCodeAt(0).toString(16);\n result = '\\\\u0000'.substr(0, 6 - result.length) + result;\n }\n // Replace a surrogate pair with its 8-bit unicode escape sequence\n else {\n result = ((character.charCodeAt(0) - 0xD800) * 0x400 +\n character.charCodeAt(1) + 0x2400).toString(16);\n result = '\\\\U00000000'.substr(0, 10 - result.length) + result;\n }\n }\n return result;\n}\n\n// ## Exports\nmodule.exports = N3Writer;\n","// Replace local require by a lazy loader\nvar globalRequire = require;\nrequire = function () {};\n\n// Expose submodules\nvar exports = module.exports = {\n Lexer: require('./lib/N3Lexer'),\n Parser: require('./lib/N3Parser'),\n Writer: require('./lib/N3Writer'),\n Store: require('./lib/N3Store'),\n StreamParser: require('./lib/N3StreamParser'),\n StreamWriter: require('./lib/N3StreamWriter'),\n Util: require('./lib/N3Util'),\n};\n\n// Load submodules on first access\nObject.keys(exports).forEach(function (submodule) {\n Object.defineProperty(exports, submodule, {\n configurable: true,\n enumerable: true,\n get: function () {\n delete exports[submodule];\n return exports[submodule] = globalRequire('./lib/N3' + submodule);\n },\n });\n});\n","// **N3Store** objects store N3 triples by graph in memory.\n\nvar expandPrefixedName = require('./N3Util').expandPrefixedName;\n\n// ## Constructor\nfunction N3Store(triples, options) {\n if (!(this instanceof N3Store))\n return new N3Store(triples, options);\n\n // The number of triples is initially zero\n this._size = 0;\n // `_graphs` contains subject, predicate, and object indexes per graph\n this._graphs = Object.create(null);\n // `_ids` maps entities such as `http://xmlns.com/foaf/0.1/name` to numbers,\n // saving memory by using only numbers as keys in `_graphs`\n this._id = 0;\n this._ids = Object.create(null);\n this._ids['><'] = 0; // dummy entry, so the first actual key is non-zero\n this._entities = Object.create(null); // inverse of `_ids`\n // `_blankNodeIndex` is the index of the last automatically named blank node\n this._blankNodeIndex = 0;\n\n // Shift parameters if `triples` is not given\n if (!options && triples && !triples[0])\n options = triples, triples = null;\n options = options || {};\n\n // Add triples and prefixes if passed\n this._prefixes = Object.create(null);\n if (options.prefixes)\n this.addPrefixes(options.prefixes);\n if (triples)\n this.addTriples(triples);\n}\n\nN3Store.prototype = {\n // ## Public properties\n\n // ### `size` returns the number of triples in the store\n get size() {\n // Return the triple count if if was cached\n var size = this._size;\n if (size !== null)\n return size;\n\n // Calculate the number of triples by counting to the deepest level\n var graphs = this._graphs, subjects, subject;\n for (var graphKey in graphs)\n for (var subjectKey in (subjects = graphs[graphKey].subjects))\n for (var predicateKey in (subject = subjects[subjectKey]))\n size += Object.keys(subject[predicateKey]).length;\n return this._size = size;\n },\n\n // ## Private methods\n\n // ### `_addToIndex` adds a triple to a three-layered index.\n // Returns if the index has changed, if the entry did not already exist.\n _addToIndex: function (index0, key0, key1, key2) {\n // Create layers as necessary\n var index1 = index0[key0] || (index0[key0] = {});\n var index2 = index1[key1] || (index1[key1] = {});\n // Setting the key to _any_ value signals the presence of the triple\n var existed = key2 in index2;\n if (!existed)\n index2[key2] = null;\n return !existed;\n },\n\n // ### `_removeFromIndex` removes a triple from a three-layered index\n _removeFromIndex: function (index0, key0, key1, key2) {\n // Remove the triple from the index\n var index1 = index0[key0], index2 = index1[key1], key;\n delete index2[key2];\n\n // Remove intermediary index layers if they are empty\n for (key in index2) return;\n delete index1[key1];\n for (key in index1) return;\n delete index0[key0];\n },\n\n // ### `_findInIndex` finds a set of triples in a three-layered index.\n // The index base is `index0` and the keys at each level are `key0`, `key1`, and `key2`.\n // Any of these keys can be undefined, which is interpreted as a wildcard.\n // `name0`, `name1`, and `name2` are the names of the keys at each level,\n // used when reconstructing the resulting triple\n // (for instance: _subject_, _predicate_, and _object_).\n // Finally, `graph` will be the graph of the created triples.\n _findInIndex: function (index0, key0, key1, key2, name0, name1, name2, graph) {\n var results = [], tmp, index1, index2, varCount = !key0 + !key1 + !key2,\n // depending on the number of variables, keys or reverse index are faster\n entityKeys = varCount > 1 ? Object.keys(this._ids) : this._entities;\n\n // If a key is specified, use only that part of index 0\n if (key0) (tmp = index0, index0 = {})[key0] = tmp[key0];\n for (var value0 in index0) {\n var entity0 = entityKeys[value0];\n\n if (index1 = index0[value0]) {\n // If a key is specified, use only that part of index 1\n if (key1) (tmp = index1, index1 = {})[key1] = tmp[key1];\n for (var value1 in index1) {\n var entity1 = entityKeys[value1];\n\n if (index2 = index1[value1]) {\n // If a key is specified, use only that part of index 2, if it exists\n var values = key2 ? (key2 in index2 ? [key2] : []) : Object.keys(index2);\n // Create triples for all items found in index 2\n for (var l = values.length - 1; l >= 0; l--) {\n var result = { subject: '', predicate: '', object: '', graph: graph };\n result[name0] = entity0;\n result[name1] = entity1;\n result[name2] = entityKeys[values[l]];\n results.push(result);\n }\n }\n }\n }\n }\n return results;\n },\n\n // ### `_countInIndex` counts matching triples in a three-layered index.\n // The index base is `index0` and the keys at each level are `key0`, `key1`, and `key2`.\n // Any of these keys can be undefined, which is interpreted as a wildcard.\n _countInIndex: function (index0, key0, key1, key2) {\n var count = 0, tmp, index1, index2;\n\n // If a key is specified, count only that part of index 0\n if (key0) (tmp = index0, index0 = {})[key0] = tmp[key0];\n for (var value0 in index0) {\n if (index1 = index0[value0]) {\n // If a key is specified, count only that part of index 1\n if (key1) (tmp = index1, index1 = {})[key1] = tmp[key1];\n for (var value1 in index1) {\n if (index2 = index1[value1]) {\n // If a key is specified, count the triple if it exists\n if (key2) (key2 in index2) && count++;\n // Otherwise, count all triples\n else count += Object.keys(index2).length;\n }\n }\n }\n }\n return count;\n },\n\n // ## Public methods\n\n // ### `addTriple` adds a new N3 triple to the store.\n // Returns if the triple index has changed, if the triple did not already exist.\n addTriple: function (subject, predicate, object, graph) {\n // Shift arguments if a triple object is given instead of components\n if (!predicate)\n graph = subject.graph, object = subject.object,\n predicate = subject.predicate, subject = subject.subject;\n\n // Find the graph that will contain the triple\n graph = graph || '';\n var graphItem = this._graphs[graph];\n // Create the graph if it doesn't exist yet\n if (!graphItem) {\n graphItem = this._graphs[graph] = { subjects: {}, predicates: {}, objects: {} };\n // Freezing a graph helps subsequent `add` performance,\n // and properties will never be modified anyway\n Object.freeze(graphItem);\n }\n\n // Since entities can often be long IRIs, we avoid storing them in every index.\n // Instead, we have a separate index that maps entities to numbers,\n // which are then used as keys in the other indexes.\n var ids = this._ids;\n var entities = this._entities;\n subject = ids[subject] || (ids[entities[++this._id] = subject] = this._id);\n predicate = ids[predicate] || (ids[entities[++this._id] = predicate] = this._id);\n object = ids[object] || (ids[entities[++this._id] = object] = this._id);\n\n var changed = this._addToIndex(graphItem.subjects, subject, predicate, object);\n this._addToIndex(graphItem.predicates, predicate, object, subject);\n this._addToIndex(graphItem.objects, object, subject, predicate);\n\n // The cached triple count is now invalid\n this._size = null;\n return changed;\n },\n\n // ### `addTriples` adds multiple N3 triples to the store\n addTriples: function (triples) {\n for (var i = triples.length - 1; i >= 0; i--)\n this.addTriple(triples[i]);\n },\n\n // ### `addPrefix` adds support for querying with the given prefix\n addPrefix: function (prefix, iri) {\n this._prefixes[prefix] = iri;\n },\n\n // ### `addPrefixes` adds support for querying with the given prefixes\n addPrefixes: function (prefixes) {\n for (var prefix in prefixes)\n this.addPrefix(prefix, prefixes[prefix]);\n },\n\n // ### `removeTriple` removes an N3 triple from the store if it exists\n removeTriple: function (subject, predicate, object, graph) {\n // Shift arguments if a triple object is given instead of components\n if (!predicate)\n graph = subject.graph, object = subject.object,\n predicate = subject.predicate, subject = subject.subject;\n graph = graph || '';\n\n // Find internal identifiers for all components\n var graphItem, ids = this._ids, graphs = this._graphs;\n if (!(subject = ids[subject])) return false;\n if (!(predicate = ids[predicate])) return false;\n if (!(object = ids[object])) return false;\n if (!(graphItem = graphs[graph])) return false;\n\n // Verify that the triple exists\n var subjects, predicates;\n if (!(subjects = graphItem.subjects[subject])) return false;\n if (!(predicates = subjects[predicate])) return false;\n if (!(object in predicates)) return false;\n\n // Remove it from all indexes\n this._removeFromIndex(graphItem.subjects, subject, predicate, object);\n this._removeFromIndex(graphItem.predicates, predicate, object, subject);\n this._removeFromIndex(graphItem.objects, object, subject, predicate);\n if (this._size !== null) this._size--;\n\n // Remove the graph if it is empty\n for (subject in graphItem.subjects) return true;\n delete graphs[graph];\n return true;\n },\n\n // ### `removeTriples` removes multiple N3 triples from the store\n removeTriples: function (triples) {\n for (var i = triples.length - 1; i >= 0; i--)\n this.removeTriple(triples[i]);\n },\n\n // ### `find` finds a set of triples matching a pattern, expanding prefixes as necessary.\n // Setting any field to `undefined` or `null` indicates a wildcard.\n find: function (subject, predicate, object, graph) {\n var prefixes = this._prefixes;\n return this.findByIRI(\n expandPrefixedName(subject, prefixes),\n expandPrefixedName(predicate, prefixes),\n expandPrefixedName(object, prefixes),\n expandPrefixedName(graph, prefixes)\n );\n },\n\n // ### `findByIRI` finds a set of triples matching a pattern.\n // Setting any field to `undefined` or `null` indicates a wildcard.\n findByIRI: function (subject, predicate, object, graph) {\n var quads = [], graphs = {}, graphContents,\n ids = this._ids, subjectId, predicateId, objectId;\n // Either loop over all graphs, or over just one selected graph\n if (!isString(graph))\n graphs = this._graphs;\n else\n graphs[graph] = this._graphs[graph];\n\n // Translate IRIs to internal index keys.\n // Optimization: if the entity doesn't exist, no triples with it exist.\n if (isString(subject) && !(subjectId = ids[subject])) return quads;\n if (isString(predicate) && !(predicateId = ids[predicate])) return quads;\n if (isString(object) && !(objectId = ids[object])) return quads;\n\n for (var graphId in graphs) {\n // Only if the specified graph contains triples, there can be results\n if (graphContents = graphs[graphId]) {\n // Choose the optimal index, based on what fields are present\n if (subjectId) {\n if (objectId)\n // If subject and object are given, the object index will be the fastest\n quads.push(this._findInIndex(graphContents.objects, objectId, subjectId, predicateId,\n 'object', 'subject', 'predicate', graphId));\n else\n // If only subject and possibly predicate are given, the subject index will be the fastest\n quads.push(this._findInIndex(graphContents.subjects, subjectId, predicateId, null,\n 'subject', 'predicate', 'object', graphId));\n }\n else if (predicateId)\n // If only predicate and possibly object are given, the predicate index will be the fastest\n quads.push(this._findInIndex(graphContents.predicates, predicateId, objectId, null,\n 'predicate', 'object', 'subject', graphId));\n else if (objectId)\n // If only object is given, the object index will be the fastest\n quads.push(this._findInIndex(graphContents.objects, objectId, null, null,\n 'object', 'subject', 'predicate', graphId));\n else\n // If nothing is given, iterate subjects and predicates first\n quads.push(this._findInIndex(graphContents.subjects, null, null, null,\n 'subject', 'predicate', 'object', graphId));\n }\n }\n return quads.length === 1 ? quads[0] : quads.concat.apply([], quads);\n },\n\n // ### `count` returns the number of triples matching a pattern, expanding prefixes as necessary.\n // Setting any field to `undefined` or `null` indicates a wildcard.\n count: function (subject, predicate, object, graph) {\n var prefixes = this._prefixes;\n return this.countByIRI(\n expandPrefixedName(subject, prefixes),\n expandPrefixedName(predicate, prefixes),\n expandPrefixedName(object, prefixes),\n expandPrefixedName(graph, prefixes)\n );\n },\n\n // ### `countByIRI` returns the number of triples matching a pattern.\n // Setting any field to `undefined` or `null` indicates a wildcard.\n countByIRI: function (subject, predicate, object, graph) {\n var count = 0, graphs = {}, graphContents,\n ids = this._ids, subjectId, predicateId, objectId;\n // Either loop over all graphs, or over just one selected graph\n if (!isString(graph))\n graphs = this._graphs;\n else\n graphs[graph] = this._graphs[graph];\n\n // Translate IRIs to internal index keys.\n // Optimization: if the entity doesn't exist, no triples with it exist.\n if (isString(subject) && !(subjectId = ids[subject])) return 0;\n if (isString(predicate) && !(predicateId = ids[predicate])) return 0;\n if (isString(object) && !(objectId = ids[object])) return 0;\n\n for (var graphId in graphs) {\n // Only if the specified graph contains triples, there can be results\n if (graphContents = graphs[graphId]) {\n // Choose the optimal index, based on what fields are present\n if (subject) {\n if (object)\n // If subject and object are given, the object index will be the fastest\n count += this._countInIndex(graphContents.objects, objectId, subjectId, predicateId);\n else\n // If only subject and possibly predicate are given, the subject index will be the fastest\n count += this._countInIndex(graphContents.subjects, subjectId, predicateId, objectId);\n }\n else if (predicate) {\n // If only predicate and possibly object are given, the predicate index will be the fastest\n count += this._countInIndex(graphContents.predicates, predicateId, objectId, subjectId);\n }\n else {\n // If only object is possibly given, the object index will be the fastest\n count += this._countInIndex(graphContents.objects, objectId, subjectId, predicateId);\n }\n }\n }\n return count;\n },\n\n // ### `createBlankNode` creates a new blank node, returning its name\n createBlankNode: function (suggestedName) {\n var name, index;\n // Generate a name based on the suggested name\n if (suggestedName) {\n name = suggestedName = '_:' + suggestedName, index = 1;\n while (this._ids[name])\n name = suggestedName + index++;\n }\n // Generate a generic blank node name\n else {\n do { name = '_:b' + this._blankNodeIndex++; }\n while (this._ids[name]);\n }\n // Add the blank node to the entities, avoiding the generation of duplicates\n this._ids[name] = ++this._id;\n this._entities[this._id] = name;\n return name;\n },\n};\n\n// Determines whether the argument is a string\nfunction isString(s) {\n return typeof s === 'string' || s instanceof String;\n}\n\n// ## Exports\nmodule.exports = N3Store;\n","// **N3StreamParser** parses an N3 stream into a triple stream.\nvar Transform = require('stream').Transform,\n util = require('util'),\n N3Parser = require('./N3Parser.js');\n\n// ## Constructor\nfunction N3StreamParser(options) {\n if (!(this instanceof N3StreamParser))\n return new N3StreamParser(options);\n\n // Initialize Transform base class\n Transform.call(this, { decodeStrings: true });\n this._readableState.objectMode = true;\n\n // Set up parser\n var self = this, parser = new N3Parser(options), onData, onEnd;\n parser.parse(\n // Pass dummy stream to obtain `data` and `end` callbacks\n { on: function (event, cb) { event === 'data' ? (onData = cb) : (onEnd = cb); } },\n // Handle triples by pushing them down the pipeline\n function (error, t) { error && self.emit('error', error) || t && self.push(t); },\n // Emit prefixes through the `prefix` event\n function (prefix, uri) { self.emit('prefix', prefix, uri); });\n\n // Implement Transform methods through parser callbacks\n this._transform = function (chunk, encoding, done) { onData(chunk); done(); };\n this._flush = function (done) { onEnd(); done(); };\n}\nutil.inherits(N3StreamParser, Transform);\n\n// ## Exports\nmodule.exports = N3StreamParser;\n","// **N3StreamWriter** serializes a triple stream into an N3 stream.\nvar Transform = require('stream').Transform,\n util = require('util'),\n N3Writer = require('./N3Writer.js');\n\n// ## Constructor\nfunction N3StreamWriter(options) {\n if (!(this instanceof N3StreamWriter))\n return new N3StreamWriter(options);\n\n // Initialize Transform base class\n Transform.call(this, { encoding: 'utf8' });\n this._writableState.objectMode = true;\n\n // Set up writer with a dummy stream object\n var self = this;\n var writer = new N3Writer({\n write: function (chunk, encoding, callback) { self.push(chunk); callback && callback(); },\n end: function (callback) { self.push(null); callback && callback(); },\n }, options);\n\n // Implement Transform methods on top of writer\n this._transform = function (triple, encoding, done) { writer.addTriple(triple, done); };\n this._flush = function (done) { writer.end(done); };\n}\nutil.inherits(N3StreamWriter, Transform);\n\n// ## Exports\nmodule.exports = N3StreamWriter;\n"],"sourceRoot":""}