rdflib 2.2.21 → 2.2.22-0de51c50

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/dist/rdflib.min.js +1 -1
  2. package/dist/rdflib.min.js.LICENSE.txt +13 -1
  3. package/dist/rdflib.min.js.map +1 -1
  4. package/esm/blank-node.js +3 -27
  5. package/esm/collection.js +7 -29
  6. package/esm/default-graph.js +1 -15
  7. package/esm/empty.js +0 -13
  8. package/esm/factories/canonical-data-factory.js +5 -40
  9. package/esm/factories/extended-term-factory.js +0 -11
  10. package/esm/factories/factory-types.js +2 -1
  11. package/esm/factories/rdflib-data-factory.js +0 -8
  12. package/esm/fetcher.js +257 -481
  13. package/esm/formula.js +43 -142
  14. package/esm/index.js +19 -36
  15. package/esm/jsonldparser.js +20 -29
  16. package/esm/jsonparser.js +0 -7
  17. package/esm/lists.js +18 -33
  18. package/esm/literal.js +10 -42
  19. package/esm/n3parser.js +38 -351
  20. package/esm/named-node.js +8 -27
  21. package/esm/namespace.js +0 -1
  22. package/esm/node-internal.js +11 -24
  23. package/esm/node.js +1 -6
  24. package/esm/parse.js +10 -17
  25. package/esm/patch-parser.js +9 -29
  26. package/esm/query-to-sparql.js +0 -18
  27. package/esm/query.js +50 -133
  28. package/esm/rdfaparser.js +72 -210
  29. package/esm/rdfxmlparser.js +31 -128
  30. package/esm/serialize.js +8 -33
  31. package/esm/serializer.js +122 -286
  32. package/esm/sparql-to-query.js +44 -134
  33. package/esm/statement.js +8 -19
  34. package/esm/store.js +109 -280
  35. package/esm/types.js +3 -2
  36. package/esm/update-manager.js +110 -246
  37. package/esm/updates-via.js +0 -27
  38. package/esm/uri.js +6 -50
  39. package/esm/utils/default-graph-uri.js +1 -0
  40. package/esm/utils/termValue.js +0 -1
  41. package/esm/utils/terms.js +15 -16
  42. package/esm/utils-js.js +16 -57
  43. package/esm/utils.js +4 -15
  44. package/esm/variable.js +0 -20
  45. package/lib/blank-node.js +3 -28
  46. package/lib/class-order.js +0 -1
  47. package/lib/collection.js +7 -34
  48. package/lib/default-graph.js +0 -20
  49. package/lib/empty.js +0 -18
  50. package/lib/factories/canonical-data-factory.js +4 -51
  51. package/lib/factories/extended-term-factory.js +0 -18
  52. package/lib/factories/factory-types.d.ts +6 -6
  53. package/lib/factories/factory-types.js +0 -3
  54. package/lib/factories/rdflib-data-factory.js +0 -12
  55. package/lib/fetcher.d.ts +6 -6
  56. package/lib/fetcher.js +258 -470
  57. package/lib/formula.d.ts +1 -1
  58. package/lib/formula.js +43 -151
  59. package/lib/index.d.ts +1 -2
  60. package/lib/index.js +14 -82
  61. package/lib/jsonldparser.js +19 -33
  62. package/lib/jsonparser.js +0 -9
  63. package/lib/lists.js +14 -39
  64. package/lib/literal.js +10 -49
  65. package/lib/log.d.ts +0 -6
  66. package/lib/log.js +0 -1
  67. package/lib/n3parser.d.ts +1 -0
  68. package/lib/n3parser.js +39 -359
  69. package/lib/named-node.js +7 -35
  70. package/lib/namespace.js +0 -3
  71. package/lib/node-internal.js +11 -21
  72. package/lib/node.js +1 -11
  73. package/lib/parse.d.ts +1 -1
  74. package/lib/parse.js +8 -27
  75. package/lib/patch-parser.js +10 -33
  76. package/lib/query-to-sparql.js +0 -23
  77. package/lib/query.js +46 -152
  78. package/lib/rdfaparser.js +72 -220
  79. package/lib/rdfxmlparser.js +31 -132
  80. package/lib/serialize.d.ts +1 -1
  81. package/lib/serialize.js +8 -43
  82. package/lib/serializer.d.ts +1 -0
  83. package/lib/serializer.js +121 -297
  84. package/lib/sparql-to-query.js +42 -167
  85. package/lib/statement.js +8 -24
  86. package/lib/store.d.ts +2 -2
  87. package/lib/store.js +102 -282
  88. package/lib/tf-types.d.ts +4 -4
  89. package/lib/types.d.ts +8 -8
  90. package/lib/types.js +3 -3
  91. package/lib/update-manager.d.ts +2 -2
  92. package/lib/update-manager.js +110 -254
  93. package/lib/updates-via.js +0 -30
  94. package/lib/uri.js +5 -58
  95. package/lib/utils/default-graph-uri.js +1 -3
  96. package/lib/utils/termValue.js +0 -2
  97. package/lib/utils/terms.js +15 -34
  98. package/lib/utils-js.js +16 -80
  99. package/lib/utils.js +4 -21
  100. package/lib/variable.js +0 -25
  101. package/lib/xsd-internal.js +0 -3
  102. package/lib/xsd.js +0 -4
  103. package/package.json +40 -39
  104. package/src/fetcher.ts +2 -2
  105. package/src/index.ts +0 -2
  106. package/src/jsonldparser.js +13 -4
  107. package/src/n3parser.js +12 -4
  108. package/src/serialize.ts +4 -11
  109. package/src/serializer.js +24 -0
  110. package/src/update-manager.ts +18 -7
  111. package/changes.txt +0 -59
  112. package/esm/convert.js +0 -61
  113. package/lib/convert.d.ts +0 -2
  114. package/lib/convert.js +0 -77
  115. package/src/convert.js +0 -70
package/lib/n3parser.js CHANGED
@@ -1,48 +1,37 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  var _typeof3 = require("@babel/runtime/helpers/typeof");
6
-
7
5
  Object.defineProperty(exports, "__esModule", {
8
6
  value: true
9
7
  });
10
8
  exports.default = exports.SinkParser = void 0;
11
-
12
9
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
13
-
14
10
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
15
-
16
11
  var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
17
-
18
12
  var Uri = _interopRequireWildcard(require("./uri"));
19
-
20
13
  var _utils = require("./utils");
21
-
14
+ var _lists = require("./lists");
22
15
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
23
-
24
16
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof3(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
25
-
26
17
  /**
27
18
  *
28
19
  * UTF-8 data encode / decode
29
20
  * http://www.webtoolkit.info/
30
21
  *
31
22
  **/
23
+
32
24
  function hexify(str) {
33
25
  // also used in parser
34
26
  return encodeURI(str);
35
27
  }
36
-
37
28
  var Utf8 = {
38
29
  // public method for url encoding
39
30
  encode: function encode(string) {
40
31
  string = string.replace(/\r\n/g, "\n");
41
32
  var utftext = "";
42
-
43
33
  for (var n = 0; n < string.length; n++) {
44
34
  var c = string.charCodeAt(n);
45
-
46
35
  if (c < 128) {
47
36
  utftext += String.fromCharCode(c);
48
37
  } else if (c > 127 && c < 2048) {
@@ -54,17 +43,14 @@ var Utf8 = {
54
43
  utftext += String.fromCharCode(c & 63 | 128);
55
44
  }
56
45
  }
57
-
58
46
  return utftext;
59
47
  },
60
48
  // public method for url decoding
61
49
  decode: function decode(utftext) {
62
50
  var string = "";
63
51
  var i = 0;
64
-
65
52
  while (i < utftext.length) {
66
53
  var c = utftext.charCodeAt(i);
67
-
68
54
  if (c < 128) {
69
55
  string += String.fromCharCode(c);
70
56
  i++;
@@ -76,7 +62,6 @@ var Utf8 = {
76
62
  i += 3;
77
63
  }
78
64
  }
79
-
80
65
  return string;
81
66
  }
82
67
  }; // Things we need to define to make converted pythn code work in js
@@ -84,25 +69,23 @@ var Utf8 = {
84
69
 
85
70
  var RDFSink_forSomeSym = "http://www.w3.org/2000/10/swap/log#forSome";
86
71
  var RDFSink_forAllSym = "http://www.w3.org/2000/10/swap/log#forAll";
87
- var Logic_NS = "http://www.w3.org/2000/10/swap/log#"; // pyjs seems to reference runtime library which I didn't find
72
+ var Logic_NS = "http://www.w3.org/2000/10/swap/log#";
73
+
74
+ // pyjs seems to reference runtime library which I didn't find
88
75
 
89
76
  var pyjslib_Tuple = function pyjslib_Tuple(theList) {
90
77
  return theList;
91
78
  };
92
-
93
79
  var pyjslib_List = function pyjslib_List(theList) {
94
80
  return theList;
95
81
  };
96
-
97
82
  var pyjslib_Dict = function pyjslib_Dict(listOfPairs) {
98
83
  if (listOfPairs.length > 0) throw "missing.js: oops nnonempty dict not imp";
99
84
  return [];
100
85
  };
101
-
102
86
  var pyjslib_len = function pyjslib_len(s) {
103
87
  return s.length;
104
88
  };
105
-
106
89
  var pyjslib_slice = function pyjslib_slice(str, i, j) {
107
90
  if (typeof str.slice == 'undefined') throw '@@ mising.js: No .slice function for ' + str + ' of type ' + (0, _typeof2.default)(str);
108
91
  if (typeof j == 'undefined' || j == null) return str.slice(i);
@@ -110,64 +93,53 @@ var pyjslib_slice = function pyjslib_slice(str, i, j) {
110
93
  };
111
94
 
112
95
  var StopIteration = Error('dummy error stop iteration');
113
-
114
96
  var pyjslib_Iterator = function pyjslib_Iterator(theList) {
115
97
  this.last = 0;
116
98
  this.li = theList;
117
-
118
99
  this.next = function () {
119
100
  if (this.last == this.li.length) throw StopIteration;
120
101
  return this.li[this.last++];
121
102
  };
122
-
123
103
  return this;
124
104
  };
125
-
126
105
  var ord = function ord(str) {
127
106
  return str.charCodeAt(0);
128
107
  };
129
-
130
108
  var string_find = function string_find(str, s) {
131
109
  return str.indexOf(s);
132
110
  };
133
-
134
111
  var assertFudge = function assertFudge(condition, desc) {
135
112
  if (condition) return;
136
113
  if (desc) throw "python Assertion failed: " + desc;
137
114
  throw "(python) Assertion failed.";
138
115
  };
139
-
140
116
  var stringFromCharCode = function stringFromCharCode(uesc) {
141
117
  return String.fromCharCode(uesc);
142
118
  };
143
-
144
119
  String.prototype.encode = function (encoding) {
145
120
  if (encoding != 'utf-8') throw "UTF8_converter: can only do utf-8";
146
121
  return Utf8.encode(this);
147
122
  };
148
-
149
123
  String.prototype.decode = function (encoding) {
150
- if (encoding != 'utf-8') throw "UTF8_converter: can only do utf-8"; //return Utf8.decode(this);
151
-
124
+ if (encoding != 'utf-8') throw "UTF8_converter: can only do utf-8";
125
+ //return Utf8.decode(this);
152
126
  return this;
153
127
  };
154
-
155
128
  var uripath_join = function uripath_join(base, given) {
156
129
  return Uri.join(given, base); // sad but true
157
130
  };
158
131
 
159
132
  var becauseSubexpression = null; // No reason needed
160
-
161
133
  var diag_tracking = 0;
162
134
  var diag_chatty_flag = 0;
135
+ var diag_progress = function diag_progress(str) {/*$rdf.log.debug(str);*/};
163
136
 
164
- var diag_progress = function diag_progress(str) {
165
- /*$rdf.log.debug(str);*/
166
- }; // why_BecauseOfData = function(doc, reason) { return doc };
167
-
137
+ // why_BecauseOfData = function(doc, reason) { return doc };
168
138
 
169
139
  var RDF_type_URI = "http://www.w3.org/1999/02/22-rdf-syntax-ns#type";
140
+ var RDF_nil_URI = "http://www.w3.org/1999/02/22-rdf-syntax-ns#nil";
170
141
  var DAML_sameAs_URI = "http://www.w3.org/2002/07/owl#sameAs";
142
+
171
143
  /*
172
144
  function SyntaxError(details) {
173
145
  return new __SyntaxError(details);
@@ -177,6 +149,7 @@ function SyntaxError(details) {
177
149
  function __SyntaxError(details) {
178
150
  this.details = details;
179
151
  }
152
+
180
153
  /*
181
154
 
182
155
  $Id: n3parser.js 14561 2008-02-23 06:37:26Z kennyluck $
@@ -207,7 +180,6 @@ the module, including tests and test harness.
207
180
 
208
181
  */
209
182
 
210
-
211
183
  var ADDED_HASH = "#";
212
184
  var LOG_implies_URI = "http://www.w3.org/2000/10/swap/log#implies";
213
185
  var INTEGER_DATATYPE = "http://www.w3.org/2001/XMLSchema#integer";
@@ -218,9 +190,7 @@ var DATETIME_DATATYPE = "http://www.w3.org/2001/XMLSchema#dateTime";
218
190
  var BOOLEAN_DATATYPE = "http://www.w3.org/2001/XMLSchema#boolean";
219
191
  var option_noregen = 0;
220
192
  var _notQNameChars = "\t\r\n !\"#$%&'()*.,+/;<=>?@[\\]^`{|}~";
221
-
222
193
  var _notNameChars = _notQNameChars + ":";
223
-
224
194
  var _rdfns = "http://www.w3.org/1999/02/22-rdf-syntax-ns#";
225
195
  var N3CommentCharacter = "#";
226
196
  var eol = new RegExp("^[ \\t]*(#[^\\n]*)?\\r?\\n", 'g');
@@ -232,14 +202,11 @@ var datetime_syntax = new RegExp('^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9](T[
232
202
  var digitstring = new RegExp("^[0-9]+", 'g');
233
203
  var interesting = new RegExp("[\\\\\\r\\n\\\"]", 'g');
234
204
  var langcode = new RegExp("^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*", 'g');
235
-
236
205
  function createSinkParser(store, openFormula, thisDoc, baseURI, genPrefix, metaURI, flags, why) {
237
206
  return new SinkParser(store, openFormula, thisDoc, baseURI, genPrefix, metaURI, flags, why);
238
207
  }
239
-
240
208
  var _default = createSinkParser;
241
209
  exports.default = _default;
242
-
243
210
  var SinkParser = /*#__PURE__*/function () {
244
211
  function SinkParser(store, openFormula, thisDoc, baseURI, genPrefix, metaURI, flags, why) {
245
212
  (0, _classCallCheck2.default)(this, SinkParser);
@@ -256,22 +223,19 @@ var SinkParser = /*#__PURE__*/function () {
256
223
 
257
224
  this._bindings = new pyjslib_Dict([]);
258
225
  this._flags = flags;
259
-
260
226
  if (thisDoc != "") {
261
227
  assertFudge(thisDoc.indexOf(":") >= 0, "Document URI not absolute: " + thisDoc);
262
228
  this._bindings[""] = thisDoc + "#";
263
229
  }
264
-
265
230
  this._store = store;
266
-
267
231
  if (genPrefix) {
268
232
  store.setGenPrefix(genPrefix);
269
233
  }
270
-
271
234
  this._thisDoc = thisDoc;
272
235
  this.source = store.sym(thisDoc);
273
236
  this.lines = 0;
274
237
  this.statementCount = 0;
238
+ this.hasNil = false;
275
239
  this.startOfLine = 0;
276
240
  this.previousLine = 0;
277
241
  this._genPrefix = genPrefix;
@@ -282,11 +246,9 @@ var SinkParser = /*#__PURE__*/function () {
282
246
  this._parentVariables = new pyjslib_Dict([]);
283
247
  this._reason = why;
284
248
  this._reason2 = null;
285
-
286
249
  if (diag_tracking) {
287
250
  this._reason2 = why_BecauseOfData(store.sym(thisDoc), this._reason);
288
251
  }
289
-
290
252
  if (baseURI) {
291
253
  this._baseURI = baseURI;
292
254
  } else {
@@ -296,9 +258,7 @@ var SinkParser = /*#__PURE__*/function () {
296
258
  this._baseURI = null;
297
259
  }
298
260
  }
299
-
300
261
  assertFudge(!this._baseURI || this._baseURI.indexOf(":") >= 0);
301
-
302
262
  if (!this._genPrefix) {
303
263
  if (this._thisDoc) {
304
264
  this._genPrefix = this._thisDoc + "#_g";
@@ -306,7 +266,6 @@ var SinkParser = /*#__PURE__*/function () {
306
266
  this._genPrefix = RDFSink_uniqueURI();
307
267
  }
308
268
  }
309
-
310
269
  if (openFormula == null) {
311
270
  if (this._thisDoc) {
312
271
  this._formula = store.formula(thisDoc + "#_formula");
@@ -316,11 +275,9 @@ var SinkParser = /*#__PURE__*/function () {
316
275
  } else {
317
276
  this._formula = openFormula;
318
277
  }
319
-
320
278
  this._context = this._formula;
321
279
  this._parentContext = null;
322
280
  }
323
-
324
281
  (0, _createClass2.default)(SinkParser, [{
325
282
  key: "here",
326
283
  value: function here(i) {
@@ -341,6 +298,7 @@ var SinkParser = /*#__PURE__*/function () {
341
298
  value: function loadBuf(buf) {
342
299
  /*
343
300
  Parses a buffer and returns its top level formula*/
301
+
344
302
  this.startDoc();
345
303
  this.feed(buf);
346
304
  return this.endDoc();
@@ -355,18 +313,15 @@ var SinkParser = /*#__PURE__*/function () {
355
313
  remainder after any statements have been parsed.
356
314
  So if there is more data to feed to the
357
315
  parser, it should be straightforward to recover.*/
316
+
358
317
  var str = octets.decode("utf-8");
359
318
  var i = 0;
360
-
361
319
  while (i >= 0) {
362
320
  var j = this.skipSpace(str, i);
363
-
364
321
  if (j < 0) {
365
322
  return;
366
323
  }
367
-
368
324
  var i = this.directiveOrStatement(str, j);
369
-
370
325
  if (i < 0) {
371
326
  throw BadSyntax(this._thisDoc, this.lines, str, j, "expected directive or statement");
372
327
  }
@@ -376,23 +331,17 @@ var SinkParser = /*#__PURE__*/function () {
376
331
  key: "directiveOrStatement",
377
332
  value: function directiveOrStatement(str, h) {
378
333
  var i = this.skipSpace(str, h);
379
-
380
334
  if (i < 0) {
381
335
  return i;
382
336
  }
383
-
384
337
  var j = this.directive(str, i);
385
-
386
338
  if (j >= 0) {
387
339
  return this.checkDot(str, j);
388
340
  }
389
-
390
341
  var j = this.statement(str, i);
391
-
392
342
  if (j >= 0) {
393
343
  return this.checkDot(str, j);
394
344
  }
395
-
396
345
  return j;
397
346
  }
398
347
  }, {
@@ -402,7 +351,6 @@ var SinkParser = /*#__PURE__*/function () {
402
351
  Check for keyword. Space must have been stripped on entry and
403
352
  we must not be at end of file.*/
404
353
  var whitespace = "\t\n\v\f\r ";
405
-
406
354
  if (str.slice(i, i + 1) == "@") {
407
355
  var i = i + 1;
408
356
  } else {
@@ -410,9 +358,7 @@ var SinkParser = /*#__PURE__*/function () {
410
358
  return -1;
411
359
  }
412
360
  }
413
-
414
361
  var k = i + pyjslib_len(_tok);
415
-
416
362
  if (str.slice(i, k) == _tok && _notQNameChars.indexOf(str.charAt(k)) >= 0) {
417
363
  return k;
418
364
  } else {
@@ -423,51 +369,36 @@ var SinkParser = /*#__PURE__*/function () {
423
369
  key: "directive",
424
370
  value: function directive(str, i) {
425
371
  var j = this.skipSpace(str, i);
426
-
427
372
  if (j < 0) {
428
373
  return j;
429
374
  }
430
-
431
375
  var res = new pyjslib_List([]);
432
376
  var j = this.tok("bind", str, i);
433
-
434
377
  if (j > 0) {
435
378
  throw BadSyntax(this._thisDoc, this.lines, str, i, "keyword bind is obsolete: use @prefix");
436
379
  }
437
-
438
380
  var j = this.tok("keywords", str, i);
439
-
440
381
  if (j > 0) {
441
382
  var i = this.commaSeparatedList(str, j, res, false);
442
-
443
383
  if (i < 0) {
444
384
  throw BadSyntax(this._thisDoc, this.lines, str, i, "'@keywords' needs comma separated list of words");
445
385
  }
446
-
447
386
  this.setKeywords(pyjslib_slice(res, null, null));
448
-
449
387
  if (diag_chatty_flag > 80) {
450
388
  diag_progress("Keywords ", this.keywords);
451
389
  }
452
-
453
390
  return i;
454
391
  }
455
-
456
392
  var j = this.tok("forAll", str, i);
457
-
458
393
  if (j > 0) {
459
394
  var i = this.commaSeparatedList(str, j, res, true);
460
-
461
395
  if (i < 0) {
462
396
  throw BadSyntax(this._thisDoc, this.lines, str, i, "Bad variable list after @forAll");
463
397
  }
464
-
465
398
  var __x = new pyjslib_Iterator(res);
466
-
467
399
  try {
468
400
  while (true) {
469
401
  var x = __x.next();
470
-
471
402
  if ((0, _utils.ArrayIndexOf)(this._variables, x) < 0 || (0, _utils.ArrayIndexOf)(this._parentVariables, x) >= 0) {
472
403
  this._variables[x] = this._context.newUniversal(x);
473
404
  }
@@ -477,25 +408,18 @@ var SinkParser = /*#__PURE__*/function () {
477
408
  throw e;
478
409
  }
479
410
  }
480
-
481
411
  return i;
482
412
  }
483
-
484
413
  var j = this.tok("forSome", str, i);
485
-
486
414
  if (j > 0) {
487
415
  var i = this.commaSeparatedList(str, j, res, this.uri_ref2);
488
-
489
416
  if (i < 0) {
490
417
  throw BadSyntax(this._thisDoc, this.lines, str, i, "Bad variable list after @forSome");
491
418
  }
492
-
493
419
  var __x = new pyjslib_Iterator(res);
494
-
495
420
  try {
496
421
  while (true) {
497
422
  var x = __x.next();
498
-
499
423
  this._context.declareExistential(x);
500
424
  }
501
425
  } catch (e) {
@@ -503,63 +427,47 @@ var SinkParser = /*#__PURE__*/function () {
503
427
  throw e;
504
428
  }
505
429
  }
506
-
507
430
  return i;
508
431
  }
509
-
510
432
  var j = this.tok("prefix", str, i);
511
-
512
433
  if (j >= 0) {
513
434
  var t = new pyjslib_List([]);
514
435
  var i = this.qname(str, j, t);
515
-
516
436
  if (i < 0) {
517
437
  throw BadSyntax(this._thisDoc, this.lines, str, j, "expected qname after @prefix");
518
438
  }
519
-
520
439
  var j = this.uri_ref2(str, i, t);
521
-
522
440
  if (j < 0) {
523
441
  throw BadSyntax(this._thisDoc, this.lines, str, i, "expected <uriref> after @prefix _qname_");
524
442
  }
525
-
526
443
  var ns = t[1].uri;
527
-
528
444
  if (this._baseURI) {
529
445
  var ns = uripath_join(this._baseURI, ns);
530
446
  } else {
531
447
  assertFudge(ns.indexOf(":") >= 0, "With no base URI, cannot handle relative URI for NS");
532
448
  }
533
-
534
449
  assertFudge(ns.indexOf(":") >= 0);
535
450
  this._bindings[t[0][0]] = ns;
536
451
  this.bind(t[0][0], hexify(ns));
537
452
  return j;
538
453
  }
539
-
540
454
  var j = this.tok("base", str, i);
541
-
542
455
  if (j >= 0) {
543
456
  var t = new pyjslib_List([]);
544
457
  var i = this.uri_ref2(str, j, t);
545
-
546
458
  if (i < 0) {
547
459
  throw BadSyntax(this._thisDoc, this.lines, str, j, "expected <uri> after @base ");
548
460
  }
549
-
550
461
  var ns = t[0].uri;
551
-
552
462
  if (this._baseURI) {
553
463
  var ns = uripath_join(this._baseURI, ns);
554
464
  } else {
555
465
  throw BadSyntax(this._thisDoc, this.lines, str, j, "With no previous base URI, cannot use relative URI in @base <" + ns + ">");
556
466
  }
557
-
558
467
  assertFudge(ns.indexOf(":") >= 0);
559
468
  this._baseURI = ns;
560
469
  return i;
561
470
  }
562
-
563
471
  return -1;
564
472
  }
565
473
  }, {
@@ -574,6 +482,7 @@ var SinkParser = /*#__PURE__*/function () {
574
482
  value: function setKeywords(k) {
575
483
  /*
576
484
  Takes a list of strings*/
485
+
577
486
  if (k == null) {
578
487
  this.keywordsSet = 0;
579
488
  } else {
@@ -586,15 +495,20 @@ var SinkParser = /*#__PURE__*/function () {
586
495
  value: function startDoc() {}
587
496
  }, {
588
497
  key: "endDoc",
589
- value: function endDoc() {
590
- /*
591
- Signal end of document and stop parsing. returns formula*/
498
+ value: /* Signal end of document and stop parsing. returns formula */
499
+ function endDoc() {
500
+ if (this.hasNil && this._store.rdfFactory.supports["COLLECTIONS"]) {
501
+ (0, _lists.convertFirstRestNil)(this._store, this.source);
502
+ }
592
503
  return this._formula;
593
504
  }
594
505
  }, {
595
506
  key: "makeStatement",
596
507
  value: function makeStatement(quad) {
597
508
  quad[0].add(quad[2], quad[1], quad[3], this.source);
509
+ if (quad[2].uri && quad[2].uri === RDF_nil_URI || quad[3].uri && quad[3].uri === RDF_nil_URI) {
510
+ this.hasNil = true;
511
+ }
598
512
  this.statementCount += 1;
599
513
  }
600
514
  }, {
@@ -602,17 +516,13 @@ var SinkParser = /*#__PURE__*/function () {
602
516
  value: function statement(str, i) {
603
517
  var r = new pyjslib_List([]);
604
518
  var i = this.object(str, i, r);
605
-
606
519
  if (i < 0) {
607
520
  return i;
608
521
  }
609
-
610
522
  var j = this.property_list(str, i, r[0]);
611
-
612
523
  if (j < 0) {
613
524
  throw BadSyntax(this._thisDoc, this.lines, str, i, "expected propertylist");
614
525
  }
615
-
616
526
  return j;
617
527
  }
618
528
  }, {
@@ -632,91 +542,69 @@ var SinkParser = /*#__PURE__*/function () {
632
542
  >- prop ->
633
543
  <- prop -<
634
544
  _operator_*/
635
- var j = this.skipSpace(str, i);
636
545
 
546
+ var j = this.skipSpace(str, i);
637
547
  if (j < 0) {
638
548
  return j;
639
549
  }
640
-
641
550
  var r = new pyjslib_List([]);
642
551
  var j = this.tok("has", str, i);
643
-
644
552
  if (j >= 0) {
645
553
  var i = this.prop(str, j, r);
646
-
647
554
  if (i < 0) {
648
555
  throw BadSyntax(this._thisDoc, this.lines, str, j, "expected property after 'has'");
649
556
  }
650
-
651
557
  res.push(new pyjslib_Tuple(["->", r[0]]));
652
558
  return i;
653
559
  }
654
-
655
560
  var j = this.tok("is", str, i);
656
-
657
561
  if (j >= 0) {
658
562
  var i = this.prop(str, j, r);
659
-
660
563
  if (i < 0) {
661
564
  throw BadSyntax(this._thisDoc, this.lines, str, j, "expected <property> after 'is'");
662
565
  }
663
-
664
566
  var j = this.skipSpace(str, i);
665
-
666
567
  if (j < 0) {
667
568
  throw BadSyntax(this._thisDoc, this.lines, str, i, "End of file found, expected property after 'is'");
668
569
  return j;
669
570
  }
670
-
671
571
  var i = j;
672
572
  var j = this.tok("of", str, i);
673
-
674
573
  if (j < 0) {
675
574
  throw BadSyntax(this._thisDoc, this.lines, str, i, "expected 'of' after 'is' <prop>");
676
575
  }
677
-
678
576
  res.push(new pyjslib_Tuple(["<-", r[0]]));
679
577
  return j;
680
578
  }
681
-
682
579
  var j = this.tok("a", str, i);
683
-
684
580
  if (j >= 0) {
685
581
  res.push(new pyjslib_Tuple(["->", this._store.sym(RDF_type_URI)]));
686
582
  return j;
687
583
  }
688
-
689
584
  if (str.slice(i, i + 2) == "<=") {
690
585
  res.push(new pyjslib_Tuple(["<-", this._store.sym(Logic_NS + "implies")]));
691
586
  return i + 2;
692
587
  }
693
-
694
588
  if (str.slice(i, i + 1) == "=") {
695
589
  if (str.slice(i + 1, i + 2) == ">") {
696
590
  res.push(new pyjslib_Tuple(["->", this._store.sym(Logic_NS + "implies")]));
697
591
  return i + 2;
698
592
  }
699
-
700
593
  res.push(new pyjslib_Tuple(["->", this._store.sym(DAML_sameAs_URI)]));
701
594
  return i + 1;
702
595
  }
703
-
704
596
  if (str.slice(i, i + 2) == ":=") {
705
597
  res.push(new pyjslib_Tuple(["->", Logic_NS + "becomes"]));
706
598
  return i + 2;
707
599
  }
708
-
709
600
  var j = this.prop(str, i, r);
710
-
711
601
  if (j >= 0) {
712
602
  res.push(new pyjslib_Tuple(["->", r[0]]));
713
603
  return j;
714
604
  }
715
-
716
605
  if (str.slice(i, i + 2) == ">-" || str.slice(i, i + 2) == "<-") {
717
606
  throw BadSyntax(this._thisDoc, this.lines, str, j, ">- ... -> syntax is obsolete.");
718
607
  }
719
-
720
608
  return -1;
721
609
  }
722
610
  }, {
@@ -740,42 +628,33 @@ var SinkParser = /*#__PURE__*/function () {
740
628
  /*
741
629
  Parse the path production.
742
630
  */
743
- var j = this.nodeOrLiteral(str, i, res);
744
631
 
632
+ var j = this.nodeOrLiteral(str, i, res);
745
633
  if (j < 0) {
746
634
  return j;
747
635
  }
748
-
749
636
  while ("!^.".indexOf(str.slice(j, j + 1)) >= 0) {
750
637
  var ch = str.slice(j, j + 1);
751
-
752
638
  if (ch == ".") {
753
639
  var ahead = str.slice(j + 1, j + 2);
754
-
755
640
  if (!ahead || _notNameChars.indexOf(ahead) >= 0 && ":?<[{(".indexOf(ahead) < 0) {
756
641
  break;
757
642
  }
758
643
  }
759
-
760
644
  var subj = res.pop();
761
645
  var obj = this.blankNode(this.here(j));
762
646
  var j = this.node(str, j + 1, res);
763
-
764
647
  if (j < 0) {
765
648
  throw BadSyntax(this._thisDoc, this.lines, str, j, "EOF found in middle of path syntax");
766
649
  }
767
-
768
650
  var pred = res.pop();
769
-
770
651
  if (ch == "^") {
771
652
  this.makeStatement(new pyjslib_Tuple([this._context, pred, obj, subj]));
772
653
  } else {
773
654
  this.makeStatement(new pyjslib_Tuple([this._context, pred, subj, obj]));
774
655
  }
775
-
776
656
  res.push(obj);
777
657
  }
778
-
779
658
  return j;
780
659
  }
781
660
  }, {
@@ -783,15 +662,13 @@ var SinkParser = /*#__PURE__*/function () {
783
662
  value: function anonymousNode(ln) {
784
663
  /*
785
664
  Remember or generate a term for one of these _: anonymous nodes*/
786
- var term = this._anonymousNodes[ln];
787
665
 
666
+ var term = this._anonymousNodes[ln];
788
667
  if (term) {
789
668
  return term;
790
669
  }
791
-
792
- var term = this._store.bnode(ln); // var term = this._store.bnode(this._context, this._reason2); eh?
793
-
794
-
670
+ var term = this._store.bnode(ln);
671
+ // var term = this._store.bnode(this._context, this._reason2); eh?
795
672
  this._anonymousNodes[ln] = term;
796
673
  return term;
797
674
  }
@@ -807,37 +684,28 @@ var SinkParser = /*#__PURE__*/function () {
807
684
 
808
685
  var subj = subjectAlready;
809
686
  var j = this.skipSpace(str, i);
810
-
811
687
  if (j < 0) {
812
688
  return j;
813
689
  }
814
-
815
690
  var i = j;
816
691
  var ch = str.slice(i, i + 1);
817
-
818
692
  if (ch == "[") {
819
693
  var bnodeID = this.here(i);
820
694
  var j = this.skipSpace(str, i + 1);
821
-
822
695
  if (j < 0) {
823
696
  throw BadSyntax(this._thisDoc, this.lines, str, i, "EOF after '['");
824
697
  }
825
-
826
698
  if (str.slice(j, j + 1) == "=") {
827
699
  var i = j + 1;
828
700
  var objs = new pyjslib_List([]);
829
701
  var j = this.objectList(str, i, objs);
830
-
831
702
  if (j >= 0) {
832
703
  var subj = objs[0];
833
-
834
704
  if (pyjslib_len(objs) > 1) {
835
705
  var __obj = new pyjslib_Iterator(objs);
836
-
837
706
  try {
838
707
  while (true) {
839
708
  var obj = __obj.next();
840
-
841
709
  this.makeStatement(new pyjslib_Tuple([this._context, this._store.sym(DAML_sameAs_URI), subj, obj]));
842
710
  }
843
711
  } catch (e) {
@@ -846,13 +714,10 @@ var SinkParser = /*#__PURE__*/function () {
846
714
  }
847
715
  }
848
716
  }
849
-
850
717
  var j = this.skipSpace(str, j);
851
-
852
718
  if (j < 0) {
853
719
  throw BadSyntax(this._thisDoc, this.lines, str, i, "EOF when objectList expected after [ = ");
854
720
  }
855
-
856
721
  if (str.slice(j, j + 1) == ";") {
857
722
  var j = j + 1;
858
723
  }
@@ -860,52 +725,39 @@ var SinkParser = /*#__PURE__*/function () {
860
725
  throw BadSyntax(this._thisDoc, this.lines, str, i, "objectList expected after [= ");
861
726
  }
862
727
  }
863
-
864
728
  if (subj == null) {
865
729
  var subj = this.blankNode(bnodeID);
866
730
  }
867
-
868
731
  var i = this.property_list(str, j, subj);
869
-
870
732
  if (i < 0) {
871
733
  throw BadSyntax(this._thisDoc, this.lines, str, j, "property_list expected");
872
734
  }
873
-
874
735
  var j = this.skipSpace(str, i);
875
-
876
736
  if (j < 0) {
877
737
  throw BadSyntax(this._thisDoc, this.lines, str, i, "EOF when ']' expected after [ <propertyList>");
878
738
  }
879
-
880
739
  if (str.slice(j, j + 1) != "]") {
881
740
  throw BadSyntax(this._thisDoc, this.lines, str, j, "']' expected");
882
741
  }
883
-
884
742
  res.push(subj);
885
743
  return j + 1;
886
744
  }
887
-
888
745
  if (ch == "{") {
889
746
  var ch2 = str.slice(i + 1, i + 2);
890
-
891
747
  if (ch2 == "$") {
892
748
  i += 1;
893
749
  var j = i + 1;
894
750
  var mylist = new pyjslib_List([]);
895
751
  var first_run = true;
896
-
897
752
  while (1) {
898
753
  var i = this.skipSpace(str, j);
899
-
900
754
  if (i < 0) {
901
755
  throw BadSyntax(this._thisDoc, this.lines, str, i, "needed '$}', found end.");
902
756
  }
903
-
904
757
  if (str.slice(i, i + 2) == "$}") {
905
758
  var j = i + 2;
906
759
  break;
907
760
  }
908
-
909
761
  if (!first_run) {
910
762
  if (str.slice(i, i + 1) == ",") {
911
763
  i += 1;
@@ -915,17 +767,13 @@ var SinkParser = /*#__PURE__*/function () {
915
767
  } else {
916
768
  var first_run = false;
917
769
  }
918
-
919
770
  var item = new pyjslib_List([]);
920
771
  var j = this.item(str, i, item);
921
-
922
772
  if (j < 0) {
923
773
  throw BadSyntax(this._thisDoc, this.lines, str, i, "expected item in set or '$}'");
924
774
  }
925
-
926
775
  mylist.push(item[0]);
927
776
  }
928
-
929
777
  res.push(this._store.newSet(mylist, this._context));
930
778
  return j;
931
779
  } else {
@@ -939,32 +787,24 @@ var SinkParser = /*#__PURE__*/function () {
939
787
  this._variables = this._variables.slice();
940
788
  var reason2 = this._reason2;
941
789
  this._reason2 = becauseSubexpression;
942
-
943
790
  if (subj == null) {
944
791
  var subj = this._store.formula();
945
792
  }
946
-
947
793
  this._context = subj;
948
-
949
794
  while (1) {
950
795
  var i = this.skipSpace(str, j);
951
-
952
796
  if (i < 0) {
953
797
  throw BadSyntax(this._thisDoc, this.lines, str, i, "needed '}', found end.");
954
798
  }
955
-
956
799
  if (str.slice(i, i + 1) == "}") {
957
800
  var j = i + 1;
958
801
  break;
959
802
  }
960
-
961
803
  var j = this.directiveOrStatement(str, i);
962
-
963
804
  if (j < 0) {
964
805
  throw BadSyntax(this._thisDoc, this.lines, str, i, "expected statement or '}'");
965
806
  }
966
807
  }
967
-
968
808
  this._anonymousNodes = parentAnonymousNodes;
969
809
  this._variables = this._parentVariables;
970
810
  this._parentVariables = grandParentVariables;
@@ -975,75 +815,56 @@ var SinkParser = /*#__PURE__*/function () {
975
815
  return j;
976
816
  }
977
817
  }
978
-
979
818
  if (ch == "(") {
980
819
  var thing_type = this._store.list;
981
820
  var ch2 = str.slice(i + 1, i + 2);
982
-
983
821
  if (ch2 == "$") {
984
822
  var thing_type = this._store.newSet;
985
823
  i += 1;
986
824
  }
987
-
988
825
  var j = i + 1;
989
826
  var mylist = new pyjslib_List([]);
990
-
991
827
  while (1) {
992
828
  var i = this.skipSpace(str, j);
993
-
994
829
  if (i < 0) {
995
830
  throw BadSyntax(this._thisDoc, this.lines, str, i, "needed ')', found end.");
996
831
  }
997
-
998
832
  if (str.slice(i, i + 1) == ")") {
999
833
  var j = i + 1;
1000
834
  break;
1001
835
  }
1002
-
1003
836
  var item = new pyjslib_List([]);
1004
837
  var j = this.item(str, i, item);
1005
-
1006
838
  if (j < 0) {
1007
839
  throw BadSyntax(this._thisDoc, this.lines, str, i, "expected item in list or ')'");
1008
840
  }
1009
-
1010
841
  mylist.push(item[0]);
1011
842
  }
1012
-
1013
843
  res.push(thing_type(mylist, this._context));
1014
844
  return j;
1015
845
  }
1016
-
1017
846
  var j = this.tok("this", str, i);
1018
-
1019
847
  if (j >= 0) {
1020
848
  throw BadSyntax(this._thisDoc, this.lines, str, i, "Keyword 'this' was ancient N3. Now use @forSome and @forAll keywords.");
1021
849
  res.push(this._context);
1022
850
  return j;
1023
851
  }
1024
-
1025
852
  var j = this.tok("true", str, i);
1026
-
1027
853
  if (j >= 0) {
1028
854
  res.push(true);
1029
855
  return j;
1030
856
  }
1031
-
1032
857
  var j = this.tok("false", str, i);
1033
-
1034
858
  if (j >= 0) {
1035
859
  res.push(false);
1036
860
  return j;
1037
861
  }
1038
-
1039
862
  if (subj == null) {
1040
863
  var j = this.uri_ref2(str, i, res);
1041
-
1042
864
  if (j >= 0) {
1043
865
  return j;
1044
866
  }
1045
867
  }
1046
-
1047
868
  return -1;
1048
869
  }
1049
870
  }, {
@@ -1053,52 +874,41 @@ var SinkParser = /*#__PURE__*/function () {
1053
874
  Parse property list
1054
875
  Leaves the terminating punctuation in the buffer
1055
876
  */
877
+
1056
878
  while (1) {
1057
879
  var j = this.skipSpace(str, i);
1058
-
1059
880
  if (j < 0) {
1060
881
  throw BadSyntax(this._thisDoc, this.lines, str, i, "EOF found when expected verb in property list");
1061
882
  return j;
1062
883
  }
1063
-
1064
884
  if (str.slice(j, j + 2) == ":-") {
1065
885
  var i = j + 2;
1066
886
  var res = new pyjslib_List([]);
1067
887
  var j = this.node(str, i, res, subj);
1068
-
1069
888
  if (j < 0) {
1070
889
  throw BadSyntax(this._thisDoc, this.lines, str, i, "bad {} or () or [] node after :- ");
1071
890
  }
1072
-
1073
891
  var i = j;
1074
892
  continue;
1075
893
  }
1076
-
1077
894
  var i = j;
1078
895
  var v = new pyjslib_List([]);
1079
896
  var j = this.verb(str, i, v);
1080
-
1081
897
  if (j <= 0) {
1082
898
  return i;
1083
899
  }
1084
-
1085
900
  var objs = new pyjslib_List([]);
1086
901
  var i = this.objectList(str, j, objs);
1087
-
1088
902
  if (i < 0) {
1089
903
  throw BadSyntax(this._thisDoc, this.lines, str, j, "objectList expected");
1090
904
  }
1091
-
1092
905
  var __obj = new pyjslib_Iterator(objs);
1093
-
1094
906
  try {
1095
907
  while (true) {
1096
908
  var obj = __obj.next();
1097
-
1098
909
  var pairFudge = v[0];
1099
910
  var dir = pairFudge[0];
1100
911
  var sym = pairFudge[1];
1101
-
1102
912
  if (dir == "->") {
1103
913
  this.makeStatement(new pyjslib_Tuple([this._context, sym, subj, obj]));
1104
914
  } else {
@@ -1110,18 +920,14 @@ var SinkParser = /*#__PURE__*/function () {
1110
920
  throw e;
1111
921
  }
1112
922
  }
1113
-
1114
923
  var j = this.skipSpace(str, i);
1115
-
1116
924
  if (j < 0) {
1117
925
  throw BadSyntax(this._thisDoc, this.lines, str, j, "EOF found in list of objects");
1118
926
  return j;
1119
927
  }
1120
-
1121
928
  if (str.slice(i, i + 1) != ";") {
1122
929
  return i;
1123
930
  }
1124
-
1125
931
  var i = i + 1;
1126
932
  }
1127
933
  }
@@ -1134,50 +940,40 @@ var SinkParser = /*#__PURE__*/function () {
1134
940
  Used to use a final value of the function to be called, e.g. this.bareWord
1135
941
  but passing the function didn't work fo js converion pyjs
1136
942
  */
1137
- var i = this.skipSpace(str, j);
1138
943
 
944
+ var i = this.skipSpace(str, j);
1139
945
  if (i < 0) {
1140
946
  throw BadSyntax(this._thisDoc, this.lines, str, i, "EOF found expecting comma sep list");
1141
947
  return i;
1142
948
  }
1143
-
1144
949
  if (str.charAt(i) == ".") {
1145
950
  return j;
1146
951
  }
1147
-
1148
952
  if (ofUris) {
1149
953
  var i = this.uri_ref2(str, i, res);
1150
954
  } else {
1151
955
  var i = this.bareWord(str, i, res);
1152
956
  }
1153
-
1154
957
  if (i < 0) {
1155
958
  return -1;
1156
959
  }
1157
-
1158
960
  while (1) {
1159
961
  var j = this.skipSpace(str, i);
1160
-
1161
962
  if (j < 0) {
1162
963
  return j;
1163
964
  }
1164
-
1165
965
  var ch = str.slice(j, j + 1);
1166
-
1167
966
  if (ch != ",") {
1168
967
  if (ch != ".") {
1169
968
  return -1;
1170
969
  }
1171
-
1172
970
  return j;
1173
971
  }
1174
-
1175
972
  if (ofUris) {
1176
973
  var i = this.uri_ref2(str, j + 1, res);
1177
974
  } else {
1178
975
  var i = this.bareWord(str, j + 1, res);
1179
976
  }
1180
-
1181
977
  if (i < 0) {
1182
978
  throw BadSyntax(this._thisDoc, this.lines, str, i, "bad list content");
1183
979
  return i;
@@ -1188,25 +984,19 @@ var SinkParser = /*#__PURE__*/function () {
1188
984
  key: "objectList",
1189
985
  value: function objectList(str, i, res) {
1190
986
  var i = this.object(str, i, res);
1191
-
1192
987
  if (i < 0) {
1193
988
  return -1;
1194
989
  }
1195
-
1196
990
  while (1) {
1197
991
  var j = this.skipSpace(str, i);
1198
-
1199
992
  if (j < 0) {
1200
993
  throw BadSyntax(this._thisDoc, this.lines, str, j, "EOF found after object");
1201
994
  return j;
1202
995
  }
1203
-
1204
996
  if (str.slice(j, j + 1) != ",") {
1205
997
  return j;
1206
998
  }
1207
-
1208
999
  var i = this.object(str, j + 1, res);
1209
-
1210
1000
  if (i < 0) {
1211
1001
  return i;
1212
1002
  }
@@ -1216,23 +1006,18 @@ var SinkParser = /*#__PURE__*/function () {
1216
1006
  key: "checkDot",
1217
1007
  value: function checkDot(str, i) {
1218
1008
  var j = this.skipSpace(str, i);
1219
-
1220
1009
  if (j < 0) {
1221
1010
  return j;
1222
1011
  }
1223
-
1224
1012
  if (str.slice(j, j + 1) == ".") {
1225
1013
  return j + 1;
1226
1014
  }
1227
-
1228
1015
  if (str.slice(j, j + 1) == "}") {
1229
1016
  return j;
1230
1017
  }
1231
-
1232
1018
  if (str.slice(j, j + 1) == "]") {
1233
1019
  return j;
1234
1020
  }
1235
-
1236
1021
  throw BadSyntax(this._thisDoc, this.lines, str, j, "expected '.' or '}' or ']' at end of statement");
1237
1022
  return i;
1238
1023
  }
@@ -1245,102 +1030,80 @@ var SinkParser = /*#__PURE__*/function () {
1245
1030
  NS and local name is now used though I prefer inserting a '#'
1246
1031
  to make the namesapces look more like what XML folks expect.
1247
1032
  */
1033
+
1248
1034
  var qn = new pyjslib_List([]);
1249
1035
  var j = this.qname(str, i, qn);
1250
-
1251
1036
  if (j >= 0) {
1252
1037
  var pairFudge = qn[0];
1253
1038
  var pfx = pairFudge[0];
1254
1039
  var ln = pairFudge[1];
1255
-
1256
1040
  if (pfx == null) {
1257
1041
  assertFudge(0, "not used?");
1258
1042
  var ns = this._baseURI + ADDED_HASH;
1259
1043
  } else {
1260
1044
  var ns = this._bindings[pfx];
1261
-
1262
1045
  if (!ns) {
1263
1046
  if (pfx == "_") {
1264
1047
  res.push(this.anonymousNode(ln));
1265
1048
  return j;
1266
1049
  }
1267
-
1268
1050
  throw BadSyntax(this._thisDoc, this.lines, str, i, "Prefix " + pfx + " not bound.");
1269
1051
  }
1270
1052
  }
1271
-
1272
1053
  var symb = this._store.sym(ns + ln);
1273
-
1274
1054
  if ((0, _utils.ArrayIndexOf)(this._variables, symb) >= 0) {
1275
1055
  res.push(this._variables[symb]);
1276
1056
  } else {
1277
1057
  res.push(symb);
1278
1058
  }
1279
-
1280
1059
  return j;
1281
1060
  }
1282
-
1283
1061
  var i = this.skipSpace(str, i);
1284
-
1285
1062
  if (i < 0) {
1286
1063
  return -1;
1287
1064
  }
1288
-
1289
1065
  if (str.charAt(i) == "?") {
1290
1066
  var v = new pyjslib_List([]);
1291
1067
  var j = this.variable(str, i, v);
1292
-
1293
1068
  if (j > 0) {
1294
1069
  res.push(v[0]);
1295
1070
  return j;
1296
1071
  }
1297
-
1298
1072
  return -1;
1299
1073
  } else if (str.charAt(i) == "<") {
1300
1074
  var i = i + 1;
1301
1075
  var st = i;
1302
-
1303
1076
  while (i < pyjslib_len(str)) {
1304
1077
  if (str.charAt(i) == ">") {
1305
1078
  var uref = str.slice(st, i);
1306
-
1307
1079
  if (this._baseURI) {
1308
1080
  var uref = uripath_join(this._baseURI, uref);
1309
1081
  } else {
1310
1082
  assertFudge(uref.indexOf(":") >= 0, "With no base URI, cannot deal with relative URIs");
1311
1083
  }
1312
-
1313
1084
  if (str.slice(i - 1, i) == "#" && !(pyjslib_slice(uref, -1, null) == "#")) {
1314
1085
  var uref = uref + "#";
1315
1086
  }
1316
-
1317
1087
  var symb = this._store.sym(uref);
1318
-
1319
1088
  if ((0, _utils.ArrayIndexOf)(this._variables, symb) >= 0) {
1320
1089
  res.push(this._variables[symb]);
1321
1090
  } else {
1322
1091
  res.push(symb);
1323
1092
  }
1324
-
1325
1093
  return i + 1;
1326
1094
  }
1327
-
1328
1095
  var i = i + 1;
1329
1096
  }
1330
-
1331
1097
  throw BadSyntax(this._thisDoc, this.lines, str, j, "unterminated URI reference");
1332
1098
  } else if (this.keywordsSet) {
1333
1099
  var v = new pyjslib_List([]);
1334
1100
  var j = this.bareWord(str, i, v);
1335
-
1336
1101
  if (j < 0) {
1337
1102
  return -1;
1338
1103
  }
1339
-
1340
1104
  if ((0, _utils.ArrayIndexOf)(this.keywords, v[0]) >= 0) {
1341
1105
  throw BadSyntax(this._thisDoc, this.lines, str, i, "Keyword \"" + v[0] + "\" not allowed here.");
1342
1106
  }
1343
-
1344
1107
  res.push(this._store.sym(this._bindings[""] + v[0]));
1345
1108
  return j;
1346
1109
  } else {
@@ -1353,12 +1116,12 @@ var SinkParser = /*#__PURE__*/function () {
1353
1116
  /*
1354
1117
  Skip white space, newlines and comments.
1355
1118
  return -1 if EOF, else position of first non-ws character*/
1356
- var whitespace = " \n\r\t\f\x0B\xA0\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u200B\u2028\u2029\u3000";
1357
1119
 
1120
+ var whitespace = " \n\r\t\f\x0B\xA0\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u200B\u2028\u2029\u3000";
1358
1121
  for (var j = i ? i : 0; j < str.length; j++) {
1359
- var ch = str.charAt(j); // console.log(" skipspace j= "+j + " i= " + i + " n= " + str.length);
1122
+ var ch = str.charAt(j);
1123
+ // console.log(" skipspace j= "+j + " i= " + i + " n= " + str.length);
1360
1124
  // console.log(" skipspace ch <" + ch + ">");
1361
-
1362
1125
  if (whitespace.indexOf(ch) < 0) {
1363
1126
  //not ws
1364
1127
  // console.log(" skipspace 2 ch <" + ch + ">");
@@ -1374,7 +1137,6 @@ var SinkParser = /*#__PURE__*/function () {
1374
1137
  break;
1375
1138
  }
1376
1139
  }
1377
-
1378
1140
  ;
1379
1141
  } else {
1380
1142
  // Not hash - something interesting
@@ -1389,8 +1151,6 @@ var SinkParser = /*#__PURE__*/function () {
1389
1151
  }
1390
1152
  }
1391
1153
  } // next j
1392
-
1393
-
1394
1154
  return -1; // EOF
1395
1155
  }
1396
1156
  }, {
@@ -1399,32 +1159,26 @@ var SinkParser = /*#__PURE__*/function () {
1399
1159
  /*
1400
1160
  ?abc -> variable(:abc)
1401
1161
  */
1402
- var j = this.skipSpace(str, i);
1403
1162
 
1163
+ var j = this.skipSpace(str, i);
1404
1164
  if (j < 0) {
1405
1165
  return -1;
1406
1166
  }
1407
-
1408
1167
  if (str.slice(j, j + 1) != "?") {
1409
1168
  return -1;
1410
1169
  }
1411
-
1412
1170
  var j = j + 1;
1413
1171
  var i = j;
1414
-
1415
1172
  if ("0123456789-".indexOf(str.charAt(j)) >= 0) {
1416
1173
  throw BadSyntax(this._thisDoc, this.lines, str, j, "Varible name can't start with '" + str.charAt(j) + "s'");
1417
1174
  return -1;
1418
1175
  }
1419
-
1420
1176
  while (i < pyjslib_len(str) && _notNameChars.indexOf(str.charAt(i)) < 0) {
1421
1177
  var i = i + 1;
1422
1178
  }
1423
-
1424
1179
  if (this._parentContext == null) {
1425
1180
  throw BadSyntax(this._thisDoc, this.lines, str, j, "Can't use ?xxx syntax for variable in outermost level: " + str.slice(j - 1, i));
1426
1181
  }
1427
-
1428
1182
  res.push(this._store.variable(str.slice(j, i)));
1429
1183
  return i;
1430
1184
  }
@@ -1434,28 +1188,22 @@ var SinkParser = /*#__PURE__*/function () {
1434
1188
  /*
1435
1189
  abc -> :abc
1436
1190
  */
1437
- var j = this.skipSpace(str, i);
1438
1191
 
1192
+ var j = this.skipSpace(str, i);
1439
1193
  if (j < 0) {
1440
1194
  return -1;
1441
1195
  }
1442
-
1443
1196
  var ch = str.charAt(j);
1444
-
1445
1197
  if ("0123456789-".indexOf(ch) >= 0) {
1446
1198
  return -1;
1447
1199
  }
1448
-
1449
1200
  if (_notNameChars.indexOf(ch) >= 0) {
1450
1201
  return -1;
1451
1202
  }
1452
-
1453
1203
  var i = j;
1454
-
1455
1204
  while (i < pyjslib_len(str) && _notNameChars.indexOf(str.charAt(i)) < 0) {
1456
1205
  var i = i + 1;
1457
1206
  }
1458
-
1459
1207
  res.push(str.slice(j, i));
1460
1208
  return i;
1461
1209
  }
@@ -1467,25 +1215,20 @@ var SinkParser = /*#__PURE__*/function () {
1467
1215
  If not in keywords and keywordsSet: def -> ('', 'def')
1468
1216
  :def -> ('', 'def')
1469
1217
  */
1470
- var i = this.skipSpace(str, i);
1471
1218
 
1219
+ var i = this.skipSpace(str, i);
1472
1220
  if (i < 0) {
1473
1221
  return -1;
1474
1222
  }
1475
-
1476
1223
  var c = str.charAt(i);
1477
-
1478
1224
  if ("0123456789-+".indexOf(c) >= 0) {
1479
1225
  return -1;
1480
1226
  }
1481
-
1482
1227
  if (_notNameChars.indexOf(c) < 0) {
1483
1228
  var ln = c;
1484
1229
  var i = i + 1;
1485
-
1486
1230
  while (i < pyjslib_len(str)) {
1487
1231
  var c = str.charAt(i);
1488
-
1489
1232
  if (_notNameChars.indexOf(c) < 0) {
1490
1233
  var ln = ln + c;
1491
1234
  var i = i + 1;
@@ -1496,15 +1239,12 @@ var SinkParser = /*#__PURE__*/function () {
1496
1239
  } else {
1497
1240
  var ln = "";
1498
1241
  }
1499
-
1500
1242
  if (i < pyjslib_len(str) && str.charAt(i) == ":") {
1501
1243
  var pfx = ln;
1502
1244
  var i = i + 1;
1503
1245
  var ln = "";
1504
-
1505
1246
  while (i < pyjslib_len(str)) {
1506
1247
  var c = str.charAt(i);
1507
-
1508
1248
  if (_notNameChars.indexOf(c) < 0) {
1509
1249
  var ln = ln + c;
1510
1250
  var i = i + 1;
@@ -1512,7 +1252,6 @@ var SinkParser = /*#__PURE__*/function () {
1512
1252
  break;
1513
1253
  }
1514
1254
  }
1515
-
1516
1255
  res.push(new pyjslib_Tuple([pfx, ln]));
1517
1256
  return i;
1518
1257
  } else {
@@ -1520,7 +1259,6 @@ var SinkParser = /*#__PURE__*/function () {
1520
1259
  res.push(new pyjslib_Tuple(["", ln]));
1521
1260
  return i;
1522
1261
  }
1523
-
1524
1262
  return -1;
1525
1263
  }
1526
1264
  }
@@ -1528,28 +1266,23 @@ var SinkParser = /*#__PURE__*/function () {
1528
1266
  key: "object",
1529
1267
  value: function object(str, i, res) {
1530
1268
  var j = this.subject(str, i, res);
1531
-
1532
1269
  if (j >= 0) {
1533
1270
  return j;
1534
1271
  } else {
1535
1272
  var j = this.skipSpace(str, i);
1536
-
1537
1273
  if (j < 0) {
1538
1274
  return -1;
1539
1275
  } else {
1540
1276
  var i = j;
1541
1277
  }
1542
-
1543
1278
  var delim = null;
1544
1279
  var ch = str.charAt(i);
1545
-
1546
1280
  if (ch == "\"" || ch == "'") {
1547
1281
  if (str.slice(i, i + 3 == ch + ch)) {
1548
1282
  delim = ch + ch + ch;
1549
1283
  } else {
1550
1284
  delim = ch;
1551
1285
  }
1552
-
1553
1286
  var i = i + pyjslib_len(delim);
1554
1287
  var pairFudge = this.strconst(str, i, delim);
1555
1288
  var j = pairFudge[0];
@@ -1566,29 +1299,23 @@ var SinkParser = /*#__PURE__*/function () {
1566
1299
  key: "nodeOrLiteral",
1567
1300
  value: function nodeOrLiteral(str, i, res) {
1568
1301
  var j = this.node(str, i, res);
1569
-
1570
1302
  if (j >= 0) {
1571
1303
  return j;
1572
1304
  } else {
1573
1305
  var j = this.skipSpace(str, i);
1574
-
1575
1306
  if (j < 0) {
1576
1307
  return -1;
1577
1308
  } else {
1578
1309
  var i = j;
1579
1310
  }
1580
-
1581
1311
  var ch = str.charAt(i);
1582
-
1583
1312
  if ("-+0987654321".indexOf(ch) >= 0) {
1584
1313
  datetime_syntax.lastIndex = 0;
1585
1314
  var m = datetime_syntax.exec(str.slice(i));
1586
-
1587
1315
  if (m != null) {
1588
1316
  // j = ( i + datetime_syntax.lastIndex ) ;
1589
1317
  var val = m[0];
1590
1318
  j = i + val.length;
1591
-
1592
1319
  if (val.indexOf("T") >= 0) {
1593
1320
  res.push(this._store.literal(val, this._store.sym(DATETIME_DATATYPE)));
1594
1321
  } else {
@@ -1597,14 +1324,11 @@ var SinkParser = /*#__PURE__*/function () {
1597
1324
  } else {
1598
1325
  number_syntax.lastIndex = 0;
1599
1326
  var m = number_syntax.exec(str.slice(i));
1600
-
1601
1327
  if (m == null) {
1602
1328
  throw BadSyntax(this._thisDoc, this.lines, str, i, "Bad number or date syntax");
1603
1329
  }
1604
-
1605
1330
  j = i + number_syntax.lastIndex;
1606
1331
  var val = str.slice(i, j);
1607
-
1608
1332
  if (val.indexOf("e") >= 0) {
1609
1333
  res.push(this._store.literal(parseFloat(val), this._store.sym(FLOAT_DATATYPE)));
1610
1334
  } else if (str.slice(i, j).indexOf(".") >= 0) {
@@ -1613,7 +1337,6 @@ var SinkParser = /*#__PURE__*/function () {
1613
1337
  res.push(this._store.literal(parseInt(val), this._store.sym(INTEGER_DATATYPE)));
1614
1338
  }
1615
1339
  }
1616
-
1617
1340
  ;
1618
1341
  return j; // Where we have got up to
1619
1342
  }
@@ -1624,33 +1347,27 @@ var SinkParser = /*#__PURE__*/function () {
1624
1347
  } else {
1625
1348
  var delim = "\"";
1626
1349
  }
1627
-
1628
1350
  var i = i + pyjslib_len(delim);
1629
1351
  var dt = null;
1630
1352
  var pairFudge = this.strconst(str, i, delim);
1631
1353
  var j = pairFudge[0];
1632
1354
  var s = pairFudge[1];
1633
1355
  var lang = null;
1634
-
1635
1356
  if (str.slice(j, j + 1) == "@") {
1636
1357
  langcode.lastIndex = 0;
1637
1358
  var m = langcode.exec(str.slice(j + 1));
1638
-
1639
1359
  if (m == null) {
1640
1360
  throw BadSyntax(this._thisDoc, startline, str, i, "Bad language code syntax on string literal, after @");
1641
1361
  }
1642
-
1643
1362
  var i = langcode.lastIndex + j + 1;
1644
1363
  var lang = str.slice(j + 1, i);
1645
1364
  var j = i;
1646
1365
  }
1647
-
1648
1366
  if (str.slice(j, j + 2) == "^^") {
1649
1367
  var res2 = new pyjslib_List([]);
1650
1368
  var j = this.uri_ref2(str, j + 2, res2);
1651
1369
  var dt = res2[0];
1652
1370
  }
1653
-
1654
1371
  res.push(this._store.literal(s, lang || dt));
1655
1372
  return j;
1656
1373
  } else {
@@ -1665,34 +1382,28 @@ var SinkParser = /*#__PURE__*/function () {
1665
1382
  parse an N3 string constant delimited by delim.
1666
1383
  return index, val
1667
1384
  */
1385
+
1668
1386
  var j = i;
1669
1387
  var ustr = "";
1670
1388
  var startline = this.lines;
1671
-
1672
1389
  while (j < pyjslib_len(str)) {
1673
1390
  var i = j + pyjslib_len(delim);
1674
-
1675
1391
  if (str.slice(j, i) == delim) {
1676
1392
  return new pyjslib_Tuple([i, ustr]);
1677
1393
  }
1678
-
1679
1394
  if (str.charAt(j) == "\"") {
1680
1395
  var ustr = ustr + "\"";
1681
1396
  var j = j + 1;
1682
1397
  continue;
1683
1398
  }
1684
-
1685
1399
  interesting.lastIndex = 0;
1686
1400
  var m = interesting.exec(str.slice(j));
1687
-
1688
1401
  if (!m) {
1689
1402
  throw BadSyntax(this._thisDoc, startline, str, j, "Closing quote missing in string at ^ in " + str.slice(j - 20, j) + "^" + str.slice(j, j + 20));
1690
1403
  }
1691
-
1692
1404
  var i = j + interesting.lastIndex - 1;
1693
1405
  var ustr = ustr + str.slice(j, i);
1694
1406
  var ch = str.charAt(i);
1695
-
1696
1407
  if (ch == "\"") {
1697
1408
  var j = i;
1698
1409
  continue;
@@ -1703,7 +1414,6 @@ var SinkParser = /*#__PURE__*/function () {
1703
1414
  if (delim == "\"") {
1704
1415
  throw BadSyntax(this._thisDoc, startline, str, i, "newline found in string literal");
1705
1416
  }
1706
-
1707
1417
  this.lines = this.lines + 1;
1708
1418
  var ustr = ustr + ch;
1709
1419
  var j = i + 1;
@@ -1712,13 +1422,10 @@ var SinkParser = /*#__PURE__*/function () {
1712
1422
  } else if (ch == "\\") {
1713
1423
  var j = i + 1;
1714
1424
  var ch = str.slice(j, j + 1);
1715
-
1716
1425
  if (!ch) {
1717
1426
  throw BadSyntax(this._thisDoc, startline, str, i, "unterminated string literal (2)");
1718
1427
  }
1719
-
1720
1428
  var k = string_find("abfrtvn\\\"", ch);
1721
-
1722
1429
  if (k >= 0) {
1723
1430
  var uch = "\a\b\f\r\t\v\n\\\"".charAt(k);
1724
1431
  var ustr = ustr + uch;
@@ -1738,7 +1445,6 @@ var SinkParser = /*#__PURE__*/function () {
1738
1445
  }
1739
1446
  }
1740
1447
  }
1741
-
1742
1448
  throw BadSyntax(this._thisDoc, this.lines, str, i, "unterminated string literal");
1743
1449
  }
1744
1450
  }, {
@@ -1747,26 +1453,20 @@ var SinkParser = /*#__PURE__*/function () {
1747
1453
  var j = i;
1748
1454
  var count = 0;
1749
1455
  var value = 0;
1750
-
1751
1456
  while (count < 4) {
1752
1457
  var chFudge = str.slice(j, j + 1);
1753
1458
  var ch = chFudge.toLowerCase();
1754
1459
  var j = j + 1;
1755
-
1756
1460
  if (ch == "") {
1757
1461
  throw BadSyntax(this._thisDoc, startline, str, i, "unterminated string literal(3)");
1758
1462
  }
1759
-
1760
1463
  var k = string_find("0123456789abcdef", ch);
1761
-
1762
1464
  if (k < 0) {
1763
1465
  throw BadSyntax(this._thisDoc, startline, str, i, "bad string literal hex escape");
1764
1466
  }
1765
-
1766
1467
  var value = value * 16 + k;
1767
1468
  var count = count + 1;
1768
1469
  }
1769
-
1770
1470
  var uch = String.fromCharCode(value);
1771
1471
  return new pyjslib_Tuple([j, uch]);
1772
1472
  }
@@ -1776,39 +1476,30 @@ var SinkParser = /*#__PURE__*/function () {
1776
1476
  var j = i;
1777
1477
  var count = 0;
1778
1478
  var value = "\\U";
1779
-
1780
1479
  while (count < 8) {
1781
1480
  var chFudge = str.slice(j, j + 1);
1782
1481
  var ch = chFudge.toLowerCase();
1783
1482
  var j = j + 1;
1784
-
1785
1483
  if (ch == "") {
1786
1484
  throw BadSyntax(this._thisDoc, startline, str, i, "unterminated string literal(3)");
1787
1485
  }
1788
-
1789
1486
  var k = string_find("0123456789abcdef", ch);
1790
-
1791
1487
  if (k < 0) {
1792
1488
  throw BadSyntax(this._thisDoc, startline, str, i, "bad string literal hex escape");
1793
1489
  }
1794
-
1795
1490
  var value = value + ch;
1796
1491
  var count = count + 1;
1797
1492
  }
1798
-
1799
1493
  var uch = stringFromCharCode("0x" + pyjslib_slice(value, 2, 10) - 0);
1800
1494
  return new pyjslib_Tuple([j, uch]);
1801
1495
  }
1802
1496
  }]);
1803
1497
  return SinkParser;
1804
1498
  }();
1805
-
1806
1499
  exports.SinkParser = SinkParser;
1807
-
1808
1500
  function OLD_BadSyntax(uri, lines, str, i, why) {
1809
1501
  return new __OLD_BadSyntax(uri, lines, str, i, why);
1810
1502
  }
1811
-
1812
1503
  function __OLD_BadSyntax(uri, lines, str, i, why) {
1813
1504
  this._str = str.encode("utf-8");
1814
1505
  this._str = str;
@@ -1817,28 +1508,23 @@ function __OLD_BadSyntax(uri, lines, str, i, why) {
1817
1508
  this.lines = lines;
1818
1509
  this._uri = uri;
1819
1510
  }
1820
-
1821
1511
  __OLD_BadSyntax.prototype.toString = function () {
1822
1512
  var str = this._str;
1823
1513
  var i = this._i;
1824
1514
  var st = 0;
1825
-
1826
1515
  if (i > 60) {
1827
1516
  var pre = "...";
1828
1517
  var st = i - 60;
1829
1518
  } else {
1830
1519
  var pre = "";
1831
1520
  }
1832
-
1833
1521
  if (pyjslib_len(str) - i > 60) {
1834
1522
  var post = "...";
1835
1523
  } else {
1836
1524
  var post = "";
1837
1525
  }
1838
-
1839
1526
  return "Line %i of <%s>: Bad syntax (%s) at ^ in:\n\"%s%s^%s%s\"" % new pyjslib_Tuple([this.lines + 1, this._uri, this._why, pre, str.slice(st, i), str.slice(i, i + 60), post]);
1840
1527
  };
1841
-
1842
1528
  function BadSyntax(uri, lines, str, i, why) {
1843
1529
  var lineNo = lines + 1;
1844
1530
  var msg = "Line " + lineNo + " of <" + uri + ">: Bad syntax: " + why + "\nat: \"" + str.slice(i, i + 30) + "\"";
@@ -1848,16 +1534,12 @@ function BadSyntax(uri, lines, str, i, why) {
1848
1534
  e.syntaxProblem = why;
1849
1535
  return e;
1850
1536
  }
1851
-
1852
1537
  function stripCR(str) {
1853
1538
  var res = "";
1854
-
1855
1539
  var __ch = new pyjslib_Iterator(str);
1856
-
1857
1540
  try {
1858
1541
  while (true) {
1859
1542
  var ch = __ch.next();
1860
-
1861
1543
  if (ch != "\r") {
1862
1544
  var res = res + ch;
1863
1545
  }
@@ -1867,8 +1549,6 @@ function stripCR(str) {
1867
1549
  throw e;
1868
1550
  }
1869
1551
  }
1870
-
1871
1552
  return res;
1872
1553
  }
1873
-
1874
1554
  function dummyWrite(x) {}