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