rdflib 2.2.35 → 2.2.36

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 (90) hide show
  1. package/dist/rdflib.min.js +1 -1
  2. package/dist/rdflib.min.js.LICENSE.txt +0 -2
  3. package/dist/rdflib.min.js.map +1 -1
  4. package/esm/blank-node.js +57 -82
  5. package/esm/class-order.js +1 -1
  6. package/esm/collection.js +70 -103
  7. package/esm/default-graph.js +13 -30
  8. package/esm/empty.js +8 -23
  9. package/esm/factories/canonical-data-factory.js +33 -29
  10. package/esm/factories/extended-term-factory.js +18 -13
  11. package/esm/factories/factory-types.js +1 -1
  12. package/esm/factories/rdflib-data-factory.js +9 -11
  13. package/esm/fetcher.js +1366 -1651
  14. package/esm/formula.js +631 -736
  15. package/esm/index.js +31 -48
  16. package/esm/jsonldparser.js +19 -26
  17. package/esm/jsonparser.js +1 -1
  18. package/esm/lists.js +38 -86
  19. package/esm/literal.js +120 -154
  20. package/esm/log.js +7 -7
  21. package/esm/n3parser.js +1009 -1086
  22. package/esm/named-node.js +69 -96
  23. package/esm/namespace.js +2 -4
  24. package/esm/node-internal.js +73 -96
  25. package/esm/node.js +1 -1
  26. package/esm/parse.js +3 -3
  27. package/esm/patch-parser.js +1 -1
  28. package/esm/query.js +15 -16
  29. package/esm/rdfaparser.js +775 -841
  30. package/esm/rdfxmlparser.js +348 -364
  31. package/esm/serialize.js +2 -2
  32. package/esm/serializer.js +835 -877
  33. package/esm/statement.js +52 -71
  34. package/esm/store.js +853 -957
  35. package/esm/types.js +21 -21
  36. package/esm/update-manager.js +965 -1100
  37. package/esm/updates-via.js +104 -132
  38. package/esm/uri.js +3 -3
  39. package/esm/utils/default-graph-uri.js +2 -2
  40. package/esm/utils/terms.js +4 -5
  41. package/esm/utils-js.js +5 -5
  42. package/esm/utils.js +6 -6
  43. package/esm/variable.js +32 -55
  44. package/esm/xsd.js +2 -2
  45. package/lib/blank-node.js +57 -80
  46. package/lib/class-order.js +1 -1
  47. package/lib/collection.js +70 -101
  48. package/lib/default-graph.js +14 -29
  49. package/lib/empty.js +9 -22
  50. package/lib/factories/canonical-data-factory.js +35 -31
  51. package/lib/factories/extended-term-factory.js +18 -13
  52. package/lib/factories/factory-types.js +1 -1
  53. package/lib/factories/rdflib-data-factory.js +9 -11
  54. package/lib/fetcher.js +1375 -1654
  55. package/lib/formula.js +632 -735
  56. package/lib/index.js +80 -84
  57. package/lib/jsonldparser.js +21 -32
  58. package/lib/jsonparser.js +1 -1
  59. package/lib/lists.js +47 -87
  60. package/lib/literal.js +121 -153
  61. package/lib/log.js +7 -7
  62. package/lib/n3parser.js +1012 -1090
  63. package/lib/named-node.js +70 -95
  64. package/lib/namespace.js +2 -4
  65. package/lib/node-internal.js +73 -94
  66. package/lib/node.js +1 -1
  67. package/lib/parse.js +5 -6
  68. package/lib/patch-parser.js +1 -1
  69. package/lib/query.js +20 -18
  70. package/lib/rdfaparser.js +778 -843
  71. package/lib/rdfxmlparser.js +351 -365
  72. package/lib/serialize.js +2 -2
  73. package/lib/serializer.js +840 -880
  74. package/lib/statement.js +55 -73
  75. package/lib/store.js +860 -958
  76. package/lib/types.js +21 -21
  77. package/lib/update-manager.js +970 -1102
  78. package/lib/updates-via.js +107 -132
  79. package/lib/uri.js +3 -3
  80. package/lib/utils/default-graph-uri.js +2 -2
  81. package/lib/utils/terms.js +4 -6
  82. package/lib/utils-js.js +8 -9
  83. package/lib/utils.js +6 -6
  84. package/lib/variable.js +35 -57
  85. package/lib/xsd.js +2 -2
  86. package/package.json +2 -2
  87. package/src/n3parser.js +1 -1
  88. package/src/serializer.js +1 -1
  89. package/src/update-manager.ts +2 -1
  90. package/.babelrc +0 -20
package/lib/n3parser.js CHANGED
@@ -1,19 +1,14 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- var _typeof3 = require("@babel/runtime/helpers/typeof");
5
3
  Object.defineProperty(exports, "__esModule", {
6
4
  value: true
7
5
  });
8
6
  exports.default = exports.SinkParser = void 0;
9
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
10
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
11
- var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
12
7
  var Uri = _interopRequireWildcard(require("./uri"));
13
8
  var _utils = require("./utils");
14
9
  var _lists = require("./lists");
15
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
16
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof3(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
10
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
11
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
17
12
  /**
18
13
  *
19
14
  * UTF-8 data encode / decode
@@ -27,7 +22,7 @@ function hexify(str) {
27
22
  }
28
23
  var Utf8 = {
29
24
  // public method for url encoding
30
- encode: function encode(string) {
25
+ encode: function (string) {
31
26
  string = string.replace(/\r\n/g, "\n");
32
27
  var utftext = "";
33
28
  for (var n = 0; n < string.length; n++) {
@@ -46,7 +41,7 @@ var Utf8 = {
46
41
  return utftext;
47
42
  },
48
43
  // public method for url decoding
49
- decode: function decode(utftext) {
44
+ decode: function (utftext) {
50
45
  var string = "";
51
46
  var i = 0;
52
47
  while (i < utftext.length) {
@@ -73,26 +68,26 @@ var Logic_NS = "http://www.w3.org/2000/10/swap/log#";
73
68
 
74
69
  // pyjs seems to reference runtime library which I didn't find
75
70
 
76
- var pyjslib_Tuple = function pyjslib_Tuple(theList) {
71
+ var pyjslib_Tuple = function (theList) {
77
72
  return theList;
78
73
  };
79
- var pyjslib_List = function pyjslib_List(theList) {
74
+ var pyjslib_List = function (theList) {
80
75
  return theList;
81
76
  };
82
- var pyjslib_Dict = function pyjslib_Dict(listOfPairs) {
77
+ var pyjslib_Dict = function (listOfPairs) {
83
78
  if (listOfPairs.length > 0) throw "missing.js: oops nnonempty dict not imp";
84
79
  return [];
85
80
  };
86
- var pyjslib_len = function pyjslib_len(s) {
81
+ var pyjslib_len = function (s) {
87
82
  return s.length;
88
83
  };
89
- var pyjslib_slice = function pyjslib_slice(str, i, j) {
90
- if (typeof str.slice == 'undefined') throw '@@ mising.js: No .slice function for ' + str + ' of type ' + (0, _typeof2.default)(str);
84
+ var pyjslib_slice = function (str, i, j) {
85
+ if (typeof str.slice == 'undefined') throw '@@ mising.js: No .slice function for ' + str + ' of type ' + typeof str;
91
86
  if (typeof j == 'undefined' || j == null) return str.slice(i);
92
87
  return str.slice(i, j); // @ exactly the same spec?
93
88
  };
94
89
  var StopIteration = Error('dummy error stop iteration');
95
- var pyjslib_Iterator = function pyjslib_Iterator(theList) {
90
+ var pyjslib_Iterator = function (theList) {
96
91
  this.last = 0;
97
92
  this.li = theList;
98
93
  this.next = function () {
@@ -101,18 +96,18 @@ var pyjslib_Iterator = function pyjslib_Iterator(theList) {
101
96
  };
102
97
  return this;
103
98
  };
104
- var ord = function ord(str) {
99
+ var ord = function (str) {
105
100
  return str.charCodeAt(0);
106
101
  };
107
- var string_find = function string_find(str, s) {
102
+ var string_find = function (str, s) {
108
103
  return str.indexOf(s);
109
104
  };
110
- var assertFudge = function assertFudge(condition, desc) {
105
+ var assertFudge = function (condition, desc) {
111
106
  if (condition) return;
112
107
  if (desc) throw "python Assertion failed: " + desc;
113
108
  throw "(python) Assertion failed.";
114
109
  };
115
- var stringFromCharCode = function stringFromCharCode(uesc) {
110
+ var stringFromCharCode = function (uesc) {
116
111
  return String.fromCharCode(uesc);
117
112
  };
118
113
  String.prototype.encode = function (encoding) {
@@ -124,13 +119,13 @@ String.prototype.decode = function (encoding) {
124
119
  //return Utf8.decode(this);
125
120
  return this;
126
121
  };
127
- var uripath_join = function uripath_join(base, given) {
122
+ var uripath_join = function (base, given) {
128
123
  return Uri.join(given, base); // sad but true
129
124
  };
130
125
  var becauseSubexpression = null; // No reason needed
131
126
  var diag_tracking = 0;
132
127
  var diag_chatty_flag = 0;
133
- var diag_progress = function diag_progress(str) {/*$rdf.log.debug(str);*/};
128
+ var diag_progress = function (str) {/*$rdf.log.debug(str);*/};
134
129
 
135
130
  // why_BecauseOfData = function(doc, reason) { return doc };
136
131
 
@@ -195,7 +190,7 @@ var eol = new RegExp("^[ \\t]*(#[^\\n]*)?\\r?\\n", 'g');
195
190
  var eof = new RegExp("^[ \\t]*(#[^\\n]*)?$", 'g');
196
191
  var ws = new RegExp("^[ \\t]*", 'g');
197
192
  var signed_integer = new RegExp("^[-+]?[0-9]+", 'g');
198
- var number_syntax = new RegExp("^([-+]?[0-9]+)(\\.[0-9]+)?(e[-+]?[0-9]+)?", 'g');
193
+ var number_syntax = new RegExp("^([-+]?[0-9]+)(\\.[0-9]+)?([eE][-+]?[0-9]+)?", 'g');
199
194
  var datetime_syntax = new RegExp('^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9](T[0-9][0-9]:[0-9][0-9](:[0-9][0-9](\\.[0-9]*)?)?)?Z?');
200
195
  var digitstring = new RegExp("^[0-9]+", 'g');
201
196
  var interesting = new RegExp("[\\\\\\r\\n\\\"]", 'g');
@@ -204,9 +199,8 @@ function createSinkParser(store, openFormula, thisDoc, baseURI, genPrefix, metaU
204
199
  return new SinkParser(store, openFormula, thisDoc, baseURI, genPrefix, metaURI, flags, why);
205
200
  }
206
201
  var _default = exports.default = createSinkParser;
207
- var SinkParser = exports.SinkParser = /*#__PURE__*/function () {
208
- function SinkParser(store, openFormula, thisDoc, baseURI, genPrefix, metaURI, flags, why) {
209
- (0, _classCallCheck2.default)(this, SinkParser);
202
+ class SinkParser {
203
+ constructor(store, openFormula, thisDoc, baseURI, genPrefix, metaURI, flags, why) {
210
204
  if (typeof openFormula == 'undefined') openFormula = null;
211
205
  if (typeof thisDoc == 'undefined') thisDoc = "";
212
206
  if (typeof baseURI == 'undefined') baseURI = null;
@@ -275,1221 +269,1149 @@ var SinkParser = exports.SinkParser = /*#__PURE__*/function () {
275
269
  this._context = this._formula;
276
270
  this._parentContext = null;
277
271
  }
278
- return (0, _createClass2.default)(SinkParser, [{
279
- key: "here",
280
- value: function here(i) {
281
- return this._genPrefix + "_L" + this.lines + "C" + (i - this.startOfLine + 1);
282
- }
283
- }, {
284
- key: "formula",
285
- value: function formula() {
286
- return this._formula;
287
- }
288
- }, {
289
- key: "loadStream",
290
- value: function loadStream(stream) {
291
- return this.loadBuf(stream.read());
292
- }
293
- }, {
294
- key: "loadBuf",
295
- value: function loadBuf(buf) {
296
- /*
297
- Parses a buffer and returns its top level formula*/
272
+ here(i) {
273
+ return this._genPrefix + "_L" + this.lines + "C" + (i - this.startOfLine + 1);
274
+ }
275
+ formula() {
276
+ return this._formula;
277
+ }
278
+ loadStream(stream) {
279
+ return this.loadBuf(stream.read());
280
+ }
281
+ loadBuf(buf) {
282
+ /*
283
+ Parses a buffer and returns its top level formula*/
298
284
 
299
- this.startDoc();
300
- this.feed(buf);
301
- return this.endDoc();
302
- }
303
- }, {
304
- key: "feed",
305
- value: function feed(octets) {
306
- /*
307
- Feed an octet stream tothe parser
308
- if BadSyntax is raised, the string
309
- passed in the exception object is the
310
- remainder after any statements have been parsed.
311
- So if there is more data to feed to the
312
- parser, it should be straightforward to recover.*/
285
+ this.startDoc();
286
+ this.feed(buf);
287
+ return this.endDoc();
288
+ }
289
+ feed(octets) {
290
+ /*
291
+ Feed an octet stream tothe parser
292
+ if BadSyntax is raised, the string
293
+ passed in the exception object is the
294
+ remainder after any statements have been parsed.
295
+ So if there is more data to feed to the
296
+ parser, it should be straightforward to recover.*/
313
297
 
314
- var str = octets.decode("utf-8");
315
- var i = 0;
316
- while (i >= 0) {
317
- var j = this.skipSpace(str, i);
318
- if (j < 0) {
319
- return;
320
- }
321
- var i = this.directiveOrStatement(str, j);
322
- if (i < 0) {
323
- throw BadSyntax(this._thisDoc, this.lines, str, j, "expected directive or statement");
324
- }
298
+ var str = octets.decode("utf-8");
299
+ var i = 0;
300
+ while (i >= 0) {
301
+ var j = this.skipSpace(str, i);
302
+ if (j < 0) {
303
+ return;
325
304
  }
326
- }
327
- }, {
328
- key: "directiveOrStatement",
329
- value: function directiveOrStatement(str, h) {
330
- var i = this.skipSpace(str, h);
305
+ var i = this.directiveOrStatement(str, j);
331
306
  if (i < 0) {
332
- return i;
333
- }
334
- var j = this.directive(str, i);
335
- if (j >= 0) {
336
- return this.checkDot(str, j);
337
- }
338
- var j = this.statement(str, i);
339
- if (j >= 0) {
340
- return this.checkDot(str, j);
307
+ throw BadSyntax(this._thisDoc, this.lines, str, j, "expected directive or statement");
341
308
  }
342
- return j;
343
309
  }
344
- }, {
345
- key: "tok",
346
- value: function tok(_tok, str, i) {
347
- /*
348
- Check for keyword. Space must have been stripped on entry and
349
- we must not be at end of file.*/
350
- var whitespace = "\t\n\v\f\r ";
351
- if (str.slice(i, i + 1) == "@") {
352
- var i = i + 1;
353
- } else {
354
- if ((0, _utils.ArrayIndexOf)(this.keywords, _tok) < 0) {
355
- return -1;
356
- }
357
- }
358
- var k = i + pyjslib_len(_tok);
359
- if (str.slice(i, k) == _tok && _notQNameChars.indexOf(str.charAt(k)) >= 0) {
360
- return k;
361
- } else {
310
+ }
311
+ directiveOrStatement(str, h) {
312
+ var i = this.skipSpace(str, h);
313
+ if (i < 0) {
314
+ return i;
315
+ }
316
+ var j = this.directive(str, i);
317
+ if (j >= 0) {
318
+ return this.checkDot(str, j);
319
+ }
320
+ var j = this.statement(str, i);
321
+ if (j >= 0) {
322
+ return this.checkDot(str, j);
323
+ }
324
+ return j;
325
+ }
326
+ tok(tok, str, i) {
327
+ /*
328
+ Check for keyword. Space must have been stripped on entry and
329
+ we must not be at end of file.*/
330
+ var whitespace = "\t\n\v\f\r ";
331
+ if (str.slice(i, i + 1) == "@") {
332
+ var i = i + 1;
333
+ } else {
334
+ if ((0, _utils.ArrayIndexOf)(this.keywords, tok) < 0) {
362
335
  return -1;
363
336
  }
364
337
  }
365
- }, {
366
- key: "directive",
367
- value: function directive(str, i) {
368
- var j = this.skipSpace(str, i);
369
- if (j < 0) {
370
- return j;
371
- }
372
- var res = new pyjslib_List([]);
373
- var j = this.tok("bind", str, i);
374
- if (j > 0) {
375
- throw BadSyntax(this._thisDoc, this.lines, str, i, "keyword bind is obsolete: use @prefix");
338
+ var k = i + pyjslib_len(tok);
339
+ if (str.slice(i, k) == tok && _notQNameChars.indexOf(str.charAt(k)) >= 0) {
340
+ return k;
341
+ } else {
342
+ return -1;
343
+ }
344
+ }
345
+ directive(str, i) {
346
+ var j = this.skipSpace(str, i);
347
+ if (j < 0) {
348
+ return j;
349
+ }
350
+ var res = new pyjslib_List([]);
351
+ var j = this.tok("bind", str, i);
352
+ if (j > 0) {
353
+ throw BadSyntax(this._thisDoc, this.lines, str, i, "keyword bind is obsolete: use @prefix");
354
+ }
355
+ var j = this.tok("keywords", str, i);
356
+ if (j > 0) {
357
+ var i = this.commaSeparatedList(str, j, res, false);
358
+ if (i < 0) {
359
+ throw BadSyntax(this._thisDoc, this.lines, str, i, "'@keywords' needs comma separated list of words");
376
360
  }
377
- var j = this.tok("keywords", str, i);
378
- if (j > 0) {
379
- var i = this.commaSeparatedList(str, j, res, false);
380
- if (i < 0) {
381
- throw BadSyntax(this._thisDoc, this.lines, str, i, "'@keywords' needs comma separated list of words");
382
- }
383
- this.setKeywords(pyjslib_slice(res, null, null));
384
- if (diag_chatty_flag > 80) {
385
- diag_progress("Keywords ", this.keywords);
386
- }
387
- return i;
361
+ this.setKeywords(pyjslib_slice(res, null, null));
362
+ if (diag_chatty_flag > 80) {
363
+ diag_progress("Keywords ", this.keywords);
388
364
  }
389
- var j = this.tok("forAll", str, i);
390
- if (j > 0) {
391
- var i = this.commaSeparatedList(str, j, res, true);
392
- if (i < 0) {
393
- throw BadSyntax(this._thisDoc, this.lines, str, i, "Bad variable list after @forAll");
394
- }
395
- var __x = new pyjslib_Iterator(res);
396
- try {
397
- while (true) {
398
- var x = __x.next();
399
- if ((0, _utils.ArrayIndexOf)(this._variables, x) < 0 || (0, _utils.ArrayIndexOf)(this._parentVariables, x) >= 0) {
400
- this._variables[x] = this._context.newUniversal(x);
401
- }
402
- }
403
- } catch (e) {
404
- if (e != StopIteration) {
405
- throw e;
365
+ return i;
366
+ }
367
+ var j = this.tok("forAll", str, i);
368
+ if (j > 0) {
369
+ var i = this.commaSeparatedList(str, j, res, true);
370
+ if (i < 0) {
371
+ throw BadSyntax(this._thisDoc, this.lines, str, i, "Bad variable list after @forAll");
372
+ }
373
+ var __x = new pyjslib_Iterator(res);
374
+ try {
375
+ while (true) {
376
+ var x = __x.next();
377
+ if ((0, _utils.ArrayIndexOf)(this._variables, x) < 0 || (0, _utils.ArrayIndexOf)(this._parentVariables, x) >= 0) {
378
+ this._variables[x] = this._context.newUniversal(x);
406
379
  }
407
380
  }
408
- return i;
409
- }
410
- var j = this.tok("forSome", str, i);
411
- if (j > 0) {
412
- var i = this.commaSeparatedList(str, j, res, this.uri_ref2);
413
- if (i < 0) {
414
- throw BadSyntax(this._thisDoc, this.lines, str, i, "Bad variable list after @forSome");
415
- }
416
- var __x = new pyjslib_Iterator(res);
417
- try {
418
- while (true) {
419
- var x = __x.next();
420
- this._context.declareExistential(x);
421
- }
422
- } catch (e) {
423
- if (e != StopIteration) {
424
- throw e;
425
- }
381
+ } catch (e) {
382
+ if (e != StopIteration) {
383
+ throw e;
426
384
  }
427
- return i;
428
385
  }
429
- var j = this.tok("prefix", str, i);
430
- if (j >= 0) {
431
- var t = new pyjslib_List([]);
432
- var i = this.qname(str, j, t);
433
- if (i < 0) {
434
- throw BadSyntax(this._thisDoc, this.lines, str, j, "expected qname after @prefix");
435
- }
436
- var j = this.uri_ref2(str, i, t);
437
- if (j < 0) {
438
- throw BadSyntax(this._thisDoc, this.lines, str, i, "expected <uriref> after @prefix _qname_");
439
- }
440
- var ns = t[1].uri;
441
- if (this._baseURI) {
442
- var ns = uripath_join(this._baseURI, ns);
443
- } else {
444
- assertFudge(ns.indexOf(":") >= 0, "With no base URI, cannot handle relative URI for NS");
445
- }
446
- assertFudge(ns.indexOf(":") >= 0);
447
- this._bindings[t[0][0]] = ns;
448
- this.bind(t[0][0], hexify(ns));
449
- return j;
386
+ return i;
387
+ }
388
+ var j = this.tok("forSome", str, i);
389
+ if (j > 0) {
390
+ var i = this.commaSeparatedList(str, j, res, this.uri_ref2);
391
+ if (i < 0) {
392
+ throw BadSyntax(this._thisDoc, this.lines, str, i, "Bad variable list after @forSome");
450
393
  }
451
- var j = this.tok("base", str, i);
452
- if (j >= 0) {
453
- var t = new pyjslib_List([]);
454
- var i = this.uri_ref2(str, j, t);
455
- if (i < 0) {
456
- throw BadSyntax(this._thisDoc, this.lines, str, j, "expected <uri> after @base ");
394
+ var __x = new pyjslib_Iterator(res);
395
+ try {
396
+ while (true) {
397
+ var x = __x.next();
398
+ this._context.declareExistential(x);
457
399
  }
458
- var ns = t[0].uri;
459
- if (this._baseURI) {
460
- var ns = uripath_join(this._baseURI, ns);
461
- } else {
462
- throw BadSyntax(this._thisDoc, this.lines, str, j, "With no previous base URI, cannot use relative URI in @base <" + ns + ">");
400
+ } catch (e) {
401
+ if (e != StopIteration) {
402
+ throw e;
463
403
  }
464
- assertFudge(ns.indexOf(":") >= 0);
465
- this._baseURI = ns;
466
- return i;
467
- }
468
- return -1;
469
- }
470
- }, {
471
- key: "bind",
472
- value: function bind(qn, uri) {
473
- if (qn == "") {} else {
474
- this._store.setPrefixForURI(qn, uri);
475
404
  }
405
+ return i;
476
406
  }
477
- }, {
478
- key: "setKeywords",
479
- value: function setKeywords(k) {
480
- /*
481
- Takes a list of strings*/
482
-
483
- if (k == null) {
484
- this.keywordsSet = 0;
485
- } else {
486
- this.keywords = k;
487
- this.keywordsSet = 1;
488
- }
489
- }
490
- }, {
491
- key: "startDoc",
492
- value: function startDoc() {}
493
- }, {
494
- key: "endDoc",
495
- value: /* Signal end of document and stop parsing. returns formula */
496
- function endDoc() {
497
- if (this.hasNil && this._store.rdfFactory.supports["COLLECTIONS"]) {
498
- (0, _lists.convertFirstRestNil)(this._store, this.source);
499
- }
500
- return this._formula;
501
- }
502
- }, {
503
- key: "makeStatement",
504
- value: function makeStatement(quad) {
505
- quad[0].add(quad[2], quad[1], quad[3], this.source);
506
- if (quad[2].uri && quad[2].uri === RDF_nil_URI || quad[3].uri && quad[3].uri === RDF_nil_URI) {
507
- this.hasNil = true;
508
- }
509
- this.statementCount += 1;
510
- }
511
- }, {
512
- key: "statement",
513
- value: function statement(str, i) {
514
- var r = new pyjslib_List([]);
515
- var i = this.object(str, i, r);
407
+ var j = this.tok("prefix", str, i);
408
+ if (j >= 0) {
409
+ var t = new pyjslib_List([]);
410
+ var i = this.qname(str, j, t);
516
411
  if (i < 0) {
517
- return i;
412
+ throw BadSyntax(this._thisDoc, this.lines, str, j, "expected qname after @prefix");
518
413
  }
519
- var j = this.property_list(str, i, r[0]);
414
+ var j = this.uri_ref2(str, i, t);
520
415
  if (j < 0) {
521
- throw BadSyntax(this._thisDoc, this.lines, str, i, "expected propertylist");
416
+ throw BadSyntax(this._thisDoc, this.lines, str, i, "expected <uriref> after @prefix _qname_");
417
+ }
418
+ var ns = t[1].uri;
419
+ if (this._baseURI) {
420
+ var ns = uripath_join(this._baseURI, ns);
421
+ } else {
422
+ assertFudge(ns.indexOf(":") >= 0, "With no base URI, cannot handle relative URI for NS");
522
423
  }
424
+ assertFudge(ns.indexOf(":") >= 0);
425
+ this._bindings[t[0][0]] = ns;
426
+ this.bind(t[0][0], hexify(ns));
523
427
  return j;
524
428
  }
525
- }, {
526
- key: "subject",
527
- value: function subject(str, i, res) {
528
- return this.item(str, i, res);
529
- }
530
- }, {
531
- key: "verb",
532
- value: function verb(str, i, res) {
533
- /*
534
- has _prop_
535
- is _prop_ of
536
- a
537
- =
538
- _prop_
539
- >- prop ->
540
- <- prop -<
541
- _operator_*/
542
-
543
- var j = this.skipSpace(str, i);
544
- if (j < 0) {
545
- return j;
429
+ var j = this.tok("base", str, i);
430
+ if (j >= 0) {
431
+ var t = new pyjslib_List([]);
432
+ var i = this.uri_ref2(str, j, t);
433
+ if (i < 0) {
434
+ throw BadSyntax(this._thisDoc, this.lines, str, j, "expected <uri> after @base ");
546
435
  }
547
- var r = new pyjslib_List([]);
548
- var j = this.tok("has", str, i);
549
- if (j >= 0) {
550
- var i = this.prop(str, j, r);
551
- if (i < 0) {
552
- throw BadSyntax(this._thisDoc, this.lines, str, j, "expected property after 'has'");
553
- }
554
- res.push(new pyjslib_Tuple(["->", r[0]]));
555
- return i;
436
+ var ns = t[0].uri;
437
+ if (this._baseURI) {
438
+ var ns = uripath_join(this._baseURI, ns);
439
+ } else {
440
+ throw BadSyntax(this._thisDoc, this.lines, str, j, "With no previous base URI, cannot use relative URI in @base <" + ns + ">");
556
441
  }
557
- var j = this.tok("is", str, i);
558
- if (j >= 0) {
559
- var i = this.prop(str, j, r);
560
- if (i < 0) {
561
- throw BadSyntax(this._thisDoc, this.lines, str, j, "expected <property> after 'is'");
562
- }
563
- var j = this.skipSpace(str, i);
564
- if (j < 0) {
565
- throw BadSyntax(this._thisDoc, this.lines, str, i, "End of file found, expected property after 'is'");
566
- return j;
567
- }
568
- var i = j;
569
- var j = this.tok("of", str, i);
570
- if (j < 0) {
571
- throw BadSyntax(this._thisDoc, this.lines, str, i, "expected 'of' after 'is' <prop>");
572
- }
573
- res.push(new pyjslib_Tuple(["<-", r[0]]));
574
- return j;
442
+ assertFudge(ns.indexOf(":") >= 0);
443
+ this._baseURI = ns;
444
+ return i;
445
+ }
446
+ return -1;
447
+ }
448
+ bind(qn, uri) {
449
+ if (qn == "") {} else {
450
+ this._store.setPrefixForURI(qn, uri);
451
+ }
452
+ }
453
+ setKeywords(k) {
454
+ /*
455
+ Takes a list of strings*/
456
+
457
+ if (k == null) {
458
+ this.keywordsSet = 0;
459
+ } else {
460
+ this.keywords = k;
461
+ this.keywordsSet = 1;
462
+ }
463
+ }
464
+ startDoc() {}
465
+ /* Signal end of document and stop parsing. returns formula */
466
+ endDoc() {
467
+ if (this.hasNil && this._store.rdfFactory.supports["COLLECTIONS"]) {
468
+ (0, _lists.convertFirstRestNil)(this._store, this.source);
469
+ }
470
+ return this._formula;
471
+ }
472
+ makeStatement(quad) {
473
+ quad[0].add(quad[2], quad[1], quad[3], this.source);
474
+ if (quad[2].uri && quad[2].uri === RDF_nil_URI || quad[3].uri && quad[3].uri === RDF_nil_URI) {
475
+ this.hasNil = true;
476
+ }
477
+ this.statementCount += 1;
478
+ }
479
+ statement(str, i) {
480
+ var r = new pyjslib_List([]);
481
+ var i = this.object(str, i, r);
482
+ if (i < 0) {
483
+ return i;
484
+ }
485
+ var j = this.property_list(str, i, r[0]);
486
+ if (j < 0) {
487
+ throw BadSyntax(this._thisDoc, this.lines, str, i, "expected propertylist");
488
+ }
489
+ return j;
490
+ }
491
+ subject(str, i, res) {
492
+ return this.item(str, i, res);
493
+ }
494
+ verb(str, i, res) {
495
+ /*
496
+ has _prop_
497
+ is _prop_ of
498
+ a
499
+ =
500
+ _prop_
501
+ >- prop ->
502
+ <- prop -<
503
+ _operator_*/
504
+
505
+ var j = this.skipSpace(str, i);
506
+ if (j < 0) {
507
+ return j;
508
+ }
509
+ var r = new pyjslib_List([]);
510
+ var j = this.tok("has", str, i);
511
+ if (j >= 0) {
512
+ var i = this.prop(str, j, r);
513
+ if (i < 0) {
514
+ throw BadSyntax(this._thisDoc, this.lines, str, j, "expected property after 'has'");
575
515
  }
576
- var j = this.tok("a", str, i);
577
- if (j >= 0) {
578
- res.push(new pyjslib_Tuple(["->", this._store.sym(RDF_type_URI)]));
579
- return j;
516
+ res.push(new pyjslib_Tuple(["->", r[0]]));
517
+ return i;
518
+ }
519
+ var j = this.tok("is", str, i);
520
+ if (j >= 0) {
521
+ var i = this.prop(str, j, r);
522
+ if (i < 0) {
523
+ throw BadSyntax(this._thisDoc, this.lines, str, j, "expected <property> after 'is'");
580
524
  }
581
- if (str.slice(i, i + 2) == "<=") {
582
- res.push(new pyjslib_Tuple(["<-", this._store.sym(Logic_NS + "implies")]));
583
- return i + 2;
525
+ var j = this.skipSpace(str, i);
526
+ if (j < 0) {
527
+ throw BadSyntax(this._thisDoc, this.lines, str, i, "End of file found, expected property after 'is'");
528
+ return j;
584
529
  }
585
- if (str.slice(i, i + 1) == "=") {
586
- if (str.slice(i + 1, i + 2) == ">") {
587
- res.push(new pyjslib_Tuple(["->", this._store.sym(Logic_NS + "implies")]));
588
- return i + 2;
589
- }
590
- res.push(new pyjslib_Tuple(["->", this._store.sym(DAML_sameAs_URI)]));
591
- return i + 1;
530
+ var i = j;
531
+ var j = this.tok("of", str, i);
532
+ if (j < 0) {
533
+ throw BadSyntax(this._thisDoc, this.lines, str, i, "expected 'of' after 'is' <prop>");
592
534
  }
593
- if (str.slice(i, i + 2) == ":=") {
594
- res.push(new pyjslib_Tuple(["->", Logic_NS + "becomes"]));
535
+ res.push(new pyjslib_Tuple(["<-", r[0]]));
536
+ return j;
537
+ }
538
+ var j = this.tok("a", str, i);
539
+ if (j >= 0) {
540
+ res.push(new pyjslib_Tuple(["->", this._store.sym(RDF_type_URI)]));
541
+ return j;
542
+ }
543
+ if (str.slice(i, i + 2) == "<=") {
544
+ res.push(new pyjslib_Tuple(["<-", this._store.sym(Logic_NS + "implies")]));
545
+ return i + 2;
546
+ }
547
+ if (str.slice(i, i + 1) == "=") {
548
+ if (str.slice(i + 1, i + 2) == ">") {
549
+ res.push(new pyjslib_Tuple(["->", this._store.sym(Logic_NS + "implies")]));
595
550
  return i + 2;
596
551
  }
597
- var j = this.prop(str, i, r);
598
- if (j >= 0) {
599
- res.push(new pyjslib_Tuple(["->", r[0]]));
600
- return j;
601
- }
602
- if (str.slice(i, i + 2) == ">-" || str.slice(i, i + 2) == "<-") {
603
- throw BadSyntax(this._thisDoc, this.lines, str, j, ">- ... -> syntax is obsolete.");
604
- }
605
- return -1;
552
+ res.push(new pyjslib_Tuple(["->", this._store.sym(DAML_sameAs_URI)]));
553
+ return i + 1;
554
+ }
555
+ if (str.slice(i, i + 2) == ":=") {
556
+ res.push(new pyjslib_Tuple(["->", Logic_NS + "becomes"]));
557
+ return i + 2;
558
+ }
559
+ var j = this.prop(str, i, r);
560
+ if (j >= 0) {
561
+ res.push(new pyjslib_Tuple(["->", r[0]]));
562
+ return j;
563
+ }
564
+ if (str.slice(i, i + 2) == ">-" || str.slice(i, i + 2) == "<-") {
565
+ throw BadSyntax(this._thisDoc, this.lines, str, j, ">- ... -> syntax is obsolete.");
606
566
  }
607
- }, {
608
- key: "prop",
609
- value: function prop(str, i, res) {
610
- return this.item(str, i, res);
611
- }
612
- }, {
613
- key: "item",
614
- value: function item(str, i, res) {
615
- return this.path(str, i, res);
616
- }
617
- }, {
618
- key: "blankNode",
619
- value: function blankNode(uri) {
620
- return this._context.bnode(uri, this._reason2);
621
- }
622
- }, {
623
- key: "path",
624
- value: function path(str, i, res) {
625
- /*
626
- Parse the path production.
627
- */
567
+ return -1;
568
+ }
569
+ prop(str, i, res) {
570
+ return this.item(str, i, res);
571
+ }
572
+ item(str, i, res) {
573
+ return this.path(str, i, res);
574
+ }
575
+ blankNode(uri) {
576
+ return this._context.bnode(uri, this._reason2);
577
+ }
578
+ path(str, i, res) {
579
+ /*
580
+ Parse the path production.
581
+ */
628
582
 
629
- var j = this.nodeOrLiteral(str, i, res);
583
+ var j = this.nodeOrLiteral(str, i, res);
584
+ if (j < 0) {
585
+ return j;
586
+ }
587
+ while ("!^.".indexOf(str.slice(j, j + 1)) >= 0) {
588
+ var ch = str.slice(j, j + 1);
589
+ if (ch == ".") {
590
+ var ahead = str.slice(j + 1, j + 2);
591
+ if (!ahead || _notNameChars.indexOf(ahead) >= 0 && ":?<[{(".indexOf(ahead) < 0) {
592
+ break;
593
+ }
594
+ }
595
+ var subj = res.pop();
596
+ var obj = this.blankNode(this.here(j));
597
+ var j = this.node(str, j + 1, res);
630
598
  if (j < 0) {
631
- return j;
599
+ throw BadSyntax(this._thisDoc, this.lines, str, j, "EOF found in middle of path syntax");
632
600
  }
633
- while ("!^.".indexOf(str.slice(j, j + 1)) >= 0) {
634
- var ch = str.slice(j, j + 1);
635
- if (ch == ".") {
636
- var ahead = str.slice(j + 1, j + 2);
637
- if (!ahead || _notNameChars.indexOf(ahead) >= 0 && ":?<[{(".indexOf(ahead) < 0) {
638
- break;
639
- }
640
- }
641
- var subj = res.pop();
642
- var obj = this.blankNode(this.here(j));
643
- var j = this.node(str, j + 1, res);
644
- if (j < 0) {
645
- throw BadSyntax(this._thisDoc, this.lines, str, j, "EOF found in middle of path syntax");
646
- }
647
- var pred = res.pop();
648
- if (ch == "^") {
649
- this.makeStatement(new pyjslib_Tuple([this._context, pred, obj, subj]));
650
- } else {
651
- this.makeStatement(new pyjslib_Tuple([this._context, pred, subj, obj]));
652
- }
653
- res.push(obj);
601
+ var pred = res.pop();
602
+ if (ch == "^") {
603
+ this.makeStatement(new pyjslib_Tuple([this._context, pred, obj, subj]));
604
+ } else {
605
+ this.makeStatement(new pyjslib_Tuple([this._context, pred, subj, obj]));
654
606
  }
655
- return j;
607
+ res.push(obj);
656
608
  }
657
- }, {
658
- key: "anonymousNode",
659
- value: function anonymousNode(ln) {
660
- /*
661
- Remember or generate a term for one of these _: anonymous nodes*/
609
+ return j;
610
+ }
611
+ anonymousNode(ln) {
612
+ /*
613
+ Remember or generate a term for one of these _: anonymous nodes*/
662
614
 
663
- var term = this._anonymousNodes[ln];
664
- if (term) {
665
- return term;
666
- }
667
- var term = this._store.bnode(ln);
668
- // var term = this._store.bnode(this._context, this._reason2); eh?
669
- this._anonymousNodes[ln] = term;
615
+ var term = this._anonymousNodes[ln];
616
+ if (term) {
670
617
  return term;
671
618
  }
672
- }, {
673
- key: "node",
674
- value: function node(str, i, res, subjectAlready) {
675
- if (typeof subjectAlready == 'undefined') subjectAlready = null;
676
- /*
677
- Parse the <node> production.
678
- Space is now skipped once at the beginning
679
- instead of in multipe calls to self.skipSpace().
680
- */
619
+ var term = this._store.bnode(ln);
620
+ // var term = this._store.bnode(this._context, this._reason2); eh?
621
+ this._anonymousNodes[ln] = term;
622
+ return term;
623
+ }
624
+ node(str, i, res, subjectAlready) {
625
+ if (typeof subjectAlready == 'undefined') subjectAlready = null;
626
+ /*
627
+ Parse the <node> production.
628
+ Space is now skipped once at the beginning
629
+ instead of in multipe calls to self.skipSpace().
630
+ */
681
631
 
682
- var subj = subjectAlready;
683
- var j = this.skipSpace(str, i);
632
+ var subj = subjectAlready;
633
+ var j = this.skipSpace(str, i);
634
+ if (j < 0) {
635
+ return j;
636
+ }
637
+ var i = j;
638
+ var ch = str.slice(i, i + 1);
639
+ if (ch == "[") {
640
+ var bnodeID = this.here(i);
641
+ var j = this.skipSpace(str, i + 1);
684
642
  if (j < 0) {
685
- return j;
643
+ throw BadSyntax(this._thisDoc, this.lines, str, i, "EOF after '['");
686
644
  }
687
- var i = j;
688
- var ch = str.slice(i, i + 1);
689
- if (ch == "[") {
690
- var bnodeID = this.here(i);
691
- var j = this.skipSpace(str, i + 1);
692
- if (j < 0) {
693
- throw BadSyntax(this._thisDoc, this.lines, str, i, "EOF after '['");
694
- }
695
- if (str.slice(j, j + 1) == "=") {
696
- var i = j + 1;
697
- var objs = new pyjslib_List([]);
698
- var j = this.objectList(str, i, objs);
699
- if (j >= 0) {
700
- var subj = objs[0];
701
- if (pyjslib_len(objs) > 1) {
702
- var __obj = new pyjslib_Iterator(objs);
703
- try {
704
- while (true) {
705
- var obj = __obj.next();
706
- this.makeStatement(new pyjslib_Tuple([this._context, this._store.sym(DAML_sameAs_URI), subj, obj]));
707
- }
708
- } catch (e) {
709
- if (e != StopIteration) {
710
- throw e;
711
- }
645
+ if (str.slice(j, j + 1) == "=") {
646
+ var i = j + 1;
647
+ var objs = new pyjslib_List([]);
648
+ var j = this.objectList(str, i, objs);
649
+ if (j >= 0) {
650
+ var subj = objs[0];
651
+ if (pyjslib_len(objs) > 1) {
652
+ var __obj = new pyjslib_Iterator(objs);
653
+ try {
654
+ while (true) {
655
+ var obj = __obj.next();
656
+ this.makeStatement(new pyjslib_Tuple([this._context, this._store.sym(DAML_sameAs_URI), subj, obj]));
712
657
  }
713
- }
714
- var j = this.skipSpace(str, j);
715
- if (j < 0) {
716
- throw BadSyntax(this._thisDoc, this.lines, str, i, "EOF when objectList expected after [ = ");
717
- }
718
- if (str.slice(j, j + 1) == ";") {
719
- var j = j + 1;
720
- }
721
- } else {
722
- throw BadSyntax(this._thisDoc, this.lines, str, i, "objectList expected after [= ");
723
- }
724
- }
725
- if (subj == null) {
726
- var subj = this.blankNode(bnodeID);
727
- }
728
- var i = this.property_list(str, j, subj);
729
- if (i < 0) {
730
- throw BadSyntax(this._thisDoc, this.lines, str, j, "property_list expected");
731
- }
732
- var j = this.skipSpace(str, i);
733
- if (j < 0) {
734
- throw BadSyntax(this._thisDoc, this.lines, str, i, "EOF when ']' expected after [ <propertyList>");
735
- }
736
- if (str.slice(j, j + 1) != "]") {
737
- throw BadSyntax(this._thisDoc, this.lines, str, j, "']' expected");
738
- }
739
- res.push(subj);
740
- return j + 1;
741
- }
742
- if (ch == "{") {
743
- var ch2 = str.slice(i + 1, i + 2);
744
- if (ch2 == "$") {
745
- i += 1;
746
- var j = i + 1;
747
- var mylist = new pyjslib_List([]);
748
- var first_run = true;
749
- while (1) {
750
- var i = this.skipSpace(str, j);
751
- if (i < 0) {
752
- throw BadSyntax(this._thisDoc, this.lines, str, i, "needed '$}', found end.");
753
- }
754
- if (str.slice(i, i + 2) == "$}") {
755
- var j = i + 2;
756
- break;
757
- }
758
- if (!first_run) {
759
- if (str.slice(i, i + 1) == ",") {
760
- i += 1;
761
- } else {
762
- throw BadSyntax(this._thisDoc, this.lines, str, i, "expected: ','");
658
+ } catch (e) {
659
+ if (e != StopIteration) {
660
+ throw e;
763
661
  }
764
- } else {
765
- var first_run = false;
766
- }
767
- var item = new pyjslib_List([]);
768
- var j = this.item(str, i, item);
769
- if (j < 0) {
770
- throw BadSyntax(this._thisDoc, this.lines, str, i, "expected item in set or '$}'");
771
662
  }
772
- mylist.push(item[0]);
773
663
  }
774
- res.push(this._store.newSet(mylist, this._context));
775
- return j;
776
- } else {
777
- var j = i + 1;
778
- var oldParentContext = this._parentContext;
779
- this._parentContext = this._context;
780
- var parentAnonymousNodes = this._anonymousNodes;
781
- var grandParentVariables = this._parentVariables;
782
- this._parentVariables = this._variables;
783
- this._anonymousNodes = new pyjslib_Dict([]);
784
- this._variables = this._variables.slice();
785
- var reason2 = this._reason2;
786
- this._reason2 = becauseSubexpression;
787
- if (subj == null) {
788
- var subj = this._store.formula();
664
+ var j = this.skipSpace(str, j);
665
+ if (j < 0) {
666
+ throw BadSyntax(this._thisDoc, this.lines, str, i, "EOF when objectList expected after [ = ");
789
667
  }
790
- this._context = subj;
791
- while (1) {
792
- var i = this.skipSpace(str, j);
793
- if (i < 0) {
794
- throw BadSyntax(this._thisDoc, this.lines, str, i, "needed '}', found end.");
795
- }
796
- if (str.slice(i, i + 1) == "}") {
797
- var j = i + 1;
798
- break;
799
- }
800
- var j = this.directiveOrStatement(str, i);
801
- if (j < 0) {
802
- throw BadSyntax(this._thisDoc, this.lines, str, i, "expected statement or '}'");
803
- }
668
+ if (str.slice(j, j + 1) == ";") {
669
+ var j = j + 1;
804
670
  }
805
- this._anonymousNodes = parentAnonymousNodes;
806
- this._variables = this._parentVariables;
807
- this._parentVariables = grandParentVariables;
808
- this._context = this._parentContext;
809
- this._reason2 = reason2;
810
- this._parentContext = oldParentContext;
811
- res.push(subj.close());
812
- return j;
671
+ } else {
672
+ throw BadSyntax(this._thisDoc, this.lines, str, i, "objectList expected after [= ");
813
673
  }
814
674
  }
815
- if (ch == "(") {
816
- var thing_type = this._store.list;
817
- var ch2 = str.slice(i + 1, i + 2);
818
- if (ch2 == "$") {
819
- var thing_type = this._store.newSet;
820
- i += 1;
821
- }
675
+ if (subj == null) {
676
+ var subj = this.blankNode(bnodeID);
677
+ }
678
+ var i = this.property_list(str, j, subj);
679
+ if (i < 0) {
680
+ throw BadSyntax(this._thisDoc, this.lines, str, j, "property_list expected");
681
+ }
682
+ var j = this.skipSpace(str, i);
683
+ if (j < 0) {
684
+ throw BadSyntax(this._thisDoc, this.lines, str, i, "EOF when ']' expected after [ <propertyList>");
685
+ }
686
+ if (str.slice(j, j + 1) != "]") {
687
+ throw BadSyntax(this._thisDoc, this.lines, str, j, "']' expected");
688
+ }
689
+ res.push(subj);
690
+ return j + 1;
691
+ }
692
+ if (ch == "{") {
693
+ var ch2 = str.slice(i + 1, i + 2);
694
+ if (ch2 == "$") {
695
+ i += 1;
822
696
  var j = i + 1;
823
697
  var mylist = new pyjslib_List([]);
698
+ var first_run = true;
824
699
  while (1) {
825
700
  var i = this.skipSpace(str, j);
826
701
  if (i < 0) {
827
- throw BadSyntax(this._thisDoc, this.lines, str, i, "needed ')', found end.");
702
+ throw BadSyntax(this._thisDoc, this.lines, str, i, "needed '$}', found end.");
828
703
  }
829
- if (str.slice(i, i + 1) == ")") {
830
- var j = i + 1;
704
+ if (str.slice(i, i + 2) == "$}") {
705
+ var j = i + 2;
831
706
  break;
832
707
  }
708
+ if (!first_run) {
709
+ if (str.slice(i, i + 1) == ",") {
710
+ i += 1;
711
+ } else {
712
+ throw BadSyntax(this._thisDoc, this.lines, str, i, "expected: ','");
713
+ }
714
+ } else {
715
+ var first_run = false;
716
+ }
833
717
  var item = new pyjslib_List([]);
834
718
  var j = this.item(str, i, item);
835
719
  if (j < 0) {
836
- throw BadSyntax(this._thisDoc, this.lines, str, i, "expected item in list or ')'");
720
+ throw BadSyntax(this._thisDoc, this.lines, str, i, "expected item in set or '$}'");
837
721
  }
838
722
  mylist.push(item[0]);
839
723
  }
840
- res.push(thing_type(mylist, this._context));
841
- return j;
842
- }
843
- var j = this.tok("this", str, i);
844
- if (j >= 0) {
845
- throw BadSyntax(this._thisDoc, this.lines, str, i, "Keyword 'this' was ancient N3. Now use @forSome and @forAll keywords.");
846
- res.push(this._context);
847
- return j;
848
- }
849
- var j = this.tok("true", str, i);
850
- if (j >= 0) {
851
- res.push(true);
724
+ res.push(this._store.newSet(mylist, this._context));
852
725
  return j;
853
- }
854
- var j = this.tok("false", str, i);
855
- if (j >= 0) {
856
- res.push(false);
857
- return j;
858
- }
859
- if (subj == null) {
860
- var j = this.uri_ref2(str, i, res);
861
- if (j >= 0) {
862
- return j;
863
- }
864
- }
865
- return -1;
866
- }
867
- }, {
868
- key: "property_list",
869
- value: function property_list(str, i, subj) {
870
- /*
871
- Parse property list
872
- Leaves the terminating punctuation in the buffer
873
- */
874
-
875
- while (1) {
876
- var j = this.skipSpace(str, i);
877
- if (j < 0) {
878
- throw BadSyntax(this._thisDoc, this.lines, str, i, "EOF found when expected verb in property list");
879
- return j;
726
+ } else {
727
+ var j = i + 1;
728
+ var oldParentContext = this._parentContext;
729
+ this._parentContext = this._context;
730
+ var parentAnonymousNodes = this._anonymousNodes;
731
+ var grandParentVariables = this._parentVariables;
732
+ this._parentVariables = this._variables;
733
+ this._anonymousNodes = new pyjslib_Dict([]);
734
+ this._variables = this._variables.slice();
735
+ var reason2 = this._reason2;
736
+ this._reason2 = becauseSubexpression;
737
+ if (subj == null) {
738
+ var subj = this._store.formula();
880
739
  }
881
- if (str.slice(j, j + 2) == ":-") {
882
- var i = j + 2;
883
- var res = new pyjslib_List([]);
884
- var j = this.node(str, i, res, subj);
740
+ this._context = subj;
741
+ while (1) {
742
+ var i = this.skipSpace(str, j);
743
+ if (i < 0) {
744
+ throw BadSyntax(this._thisDoc, this.lines, str, i, "needed '}', found end.");
745
+ }
746
+ if (str.slice(i, i + 1) == "}") {
747
+ var j = i + 1;
748
+ break;
749
+ }
750
+ var j = this.directiveOrStatement(str, i);
885
751
  if (j < 0) {
886
- throw BadSyntax(this._thisDoc, this.lines, str, i, "bad {} or () or [] node after :- ");
752
+ throw BadSyntax(this._thisDoc, this.lines, str, i, "expected statement or '}'");
887
753
  }
888
- var i = j;
889
- continue;
890
754
  }
891
- var i = j;
892
- var v = new pyjslib_List([]);
893
- var j = this.verb(str, i, v);
894
- if (j <= 0) {
895
- return i;
896
- }
897
- var objs = new pyjslib_List([]);
898
- var i = this.objectList(str, j, objs);
755
+ this._anonymousNodes = parentAnonymousNodes;
756
+ this._variables = this._parentVariables;
757
+ this._parentVariables = grandParentVariables;
758
+ this._context = this._parentContext;
759
+ this._reason2 = reason2;
760
+ this._parentContext = oldParentContext;
761
+ res.push(subj.close());
762
+ return j;
763
+ }
764
+ }
765
+ if (ch == "(") {
766
+ var thing_type = this._store.list;
767
+ var ch2 = str.slice(i + 1, i + 2);
768
+ if (ch2 == "$") {
769
+ var thing_type = this._store.newSet;
770
+ i += 1;
771
+ }
772
+ var j = i + 1;
773
+ var mylist = new pyjslib_List([]);
774
+ while (1) {
775
+ var i = this.skipSpace(str, j);
899
776
  if (i < 0) {
900
- throw BadSyntax(this._thisDoc, this.lines, str, j, "objectList expected");
777
+ throw BadSyntax(this._thisDoc, this.lines, str, i, "needed ')', found end.");
901
778
  }
902
- var __obj = new pyjslib_Iterator(objs);
903
- try {
904
- while (true) {
905
- var obj = __obj.next();
906
- var pairFudge = v[0];
907
- var dir = pairFudge[0];
908
- var sym = pairFudge[1];
909
- if (dir == "->") {
910
- this.makeStatement(new pyjslib_Tuple([this._context, sym, subj, obj]));
911
- } else {
912
- this.makeStatement(new pyjslib_Tuple([this._context, sym, obj, subj]));
913
- }
914
- }
915
- } catch (e) {
916
- if (e != StopIteration) {
917
- throw e;
918
- }
779
+ if (str.slice(i, i + 1) == ")") {
780
+ var j = i + 1;
781
+ break;
919
782
  }
920
- var j = this.skipSpace(str, i);
783
+ var item = new pyjslib_List([]);
784
+ var j = this.item(str, i, item);
921
785
  if (j < 0) {
922
- throw BadSyntax(this._thisDoc, this.lines, str, j, "EOF found in list of objects");
923
- return j;
924
- }
925
- if (str.slice(i, i + 1) != ";") {
926
- return i;
786
+ throw BadSyntax(this._thisDoc, this.lines, str, i, "expected item in list or ')'");
927
787
  }
928
- var i = i + 1;
788
+ mylist.push(item[0]);
929
789
  }
790
+ res.push(thing_type(mylist, this._context));
791
+ return j;
930
792
  }
931
- }, {
932
- key: "commaSeparatedList",
933
- value: function commaSeparatedList(str, j, res, ofUris) {
934
- /*
935
- return value: -1 bad syntax; >1 new position in str
936
- res has things found appended
937
- Used to use a final value of the function to be called, e.g. this.bareWord
938
- but passing the function didn't work fo js converion pyjs
939
- */
940
-
941
- var i = this.skipSpace(str, j);
942
- if (i < 0) {
943
- throw BadSyntax(this._thisDoc, this.lines, str, i, "EOF found expecting comma sep list");
944
- return i;
945
- }
946
- if (str.charAt(i) == ".") {
793
+ var j = this.tok("this", str, i);
794
+ if (j >= 0) {
795
+ throw BadSyntax(this._thisDoc, this.lines, str, i, "Keyword 'this' was ancient N3. Now use @forSome and @forAll keywords.");
796
+ res.push(this._context);
797
+ return j;
798
+ }
799
+ var j = this.tok("true", str, i);
800
+ if (j >= 0) {
801
+ res.push(true);
802
+ return j;
803
+ }
804
+ var j = this.tok("false", str, i);
805
+ if (j >= 0) {
806
+ res.push(false);
807
+ return j;
808
+ }
809
+ if (subj == null) {
810
+ var j = this.uri_ref2(str, i, res);
811
+ if (j >= 0) {
947
812
  return j;
948
813
  }
949
- if (ofUris) {
950
- var i = this.uri_ref2(str, i, res);
951
- } else {
952
- var i = this.bareWord(str, i, res);
953
- }
954
- if (i < 0) {
955
- return -1;
814
+ }
815
+ return -1;
816
+ }
817
+ property_list(str, i, subj) {
818
+ /*
819
+ Parse property list
820
+ Leaves the terminating punctuation in the buffer
821
+ */
822
+
823
+ while (1) {
824
+ var j = this.skipSpace(str, i);
825
+ if (j < 0) {
826
+ throw BadSyntax(this._thisDoc, this.lines, str, i, "EOF found when expected verb in property list");
827
+ return j;
956
828
  }
957
- while (1) {
958
- var j = this.skipSpace(str, i);
829
+ if (str.slice(j, j + 2) == ":-") {
830
+ var i = j + 2;
831
+ var res = new pyjslib_List([]);
832
+ var j = this.node(str, i, res, subj);
959
833
  if (j < 0) {
960
- return j;
834
+ throw BadSyntax(this._thisDoc, this.lines, str, i, "bad {} or () or [] node after :- ");
961
835
  }
962
- var ch = str.slice(j, j + 1);
963
- if (ch != ",") {
964
- if (ch != ".") {
965
- return -1;
836
+ var i = j;
837
+ continue;
838
+ }
839
+ var i = j;
840
+ var v = new pyjslib_List([]);
841
+ var j = this.verb(str, i, v);
842
+ if (j <= 0) {
843
+ return i;
844
+ }
845
+ var objs = new pyjslib_List([]);
846
+ var i = this.objectList(str, j, objs);
847
+ if (i < 0) {
848
+ throw BadSyntax(this._thisDoc, this.lines, str, j, "objectList expected");
849
+ }
850
+ var __obj = new pyjslib_Iterator(objs);
851
+ try {
852
+ while (true) {
853
+ var obj = __obj.next();
854
+ var pairFudge = v[0];
855
+ var dir = pairFudge[0];
856
+ var sym = pairFudge[1];
857
+ if (dir == "->") {
858
+ this.makeStatement(new pyjslib_Tuple([this._context, sym, subj, obj]));
859
+ } else {
860
+ this.makeStatement(new pyjslib_Tuple([this._context, sym, obj, subj]));
966
861
  }
967
- return j;
968
862
  }
969
- if (ofUris) {
970
- var i = this.uri_ref2(str, j + 1, res);
971
- } else {
972
- var i = this.bareWord(str, j + 1, res);
973
- }
974
- if (i < 0) {
975
- throw BadSyntax(this._thisDoc, this.lines, str, i, "bad list content");
976
- return i;
863
+ } catch (e) {
864
+ if (e != StopIteration) {
865
+ throw e;
977
866
  }
978
867
  }
979
- }
980
- }, {
981
- key: "objectList",
982
- value: function objectList(str, i, res) {
983
- var i = this.object(str, i, res);
984
- if (i < 0) {
985
- return -1;
868
+ var j = this.skipSpace(str, i);
869
+ if (j < 0) {
870
+ throw BadSyntax(this._thisDoc, this.lines, str, j, "EOF found in list of objects");
871
+ return j;
986
872
  }
987
- while (1) {
988
- var j = this.skipSpace(str, i);
989
- if (j < 0) {
990
- throw BadSyntax(this._thisDoc, this.lines, str, j, "EOF found after object");
991
- return j;
992
- }
993
- if (str.slice(j, j + 1) != ",") {
994
- return j;
995
- }
996
- var i = this.object(str, j + 1, res);
997
- if (i < 0) {
998
- return i;
999
- }
873
+ if (str.slice(i, i + 1) != ";") {
874
+ return i;
1000
875
  }
876
+ var i = i + 1;
877
+ }
878
+ }
879
+ commaSeparatedList(str, j, res, ofUris) {
880
+ /*
881
+ return value: -1 bad syntax; >1 new position in str
882
+ res has things found appended
883
+ Used to use a final value of the function to be called, e.g. this.bareWord
884
+ but passing the function didn't work fo js converion pyjs
885
+ */
886
+
887
+ var i = this.skipSpace(str, j);
888
+ if (i < 0) {
889
+ throw BadSyntax(this._thisDoc, this.lines, str, i, "EOF found expecting comma sep list");
890
+ return i;
891
+ }
892
+ if (str.charAt(i) == ".") {
893
+ return j;
894
+ }
895
+ if (ofUris) {
896
+ var i = this.uri_ref2(str, i, res);
897
+ } else {
898
+ var i = this.bareWord(str, i, res);
899
+ }
900
+ if (i < 0) {
901
+ return -1;
1001
902
  }
1002
- }, {
1003
- key: "checkDot",
1004
- value: function checkDot(str, i) {
903
+ while (1) {
1005
904
  var j = this.skipSpace(str, i);
1006
905
  if (j < 0) {
1007
906
  return j;
1008
907
  }
1009
- if (str.slice(j, j + 1) == ".") {
1010
- return j + 1;
908
+ var ch = str.slice(j, j + 1);
909
+ if (ch != ",") {
910
+ if (ch != ".") {
911
+ return -1;
912
+ }
913
+ return j;
1011
914
  }
1012
- if (str.slice(j, j + 1) == "}") {
915
+ if (ofUris) {
916
+ var i = this.uri_ref2(str, j + 1, res);
917
+ } else {
918
+ var i = this.bareWord(str, j + 1, res);
919
+ }
920
+ if (i < 0) {
921
+ throw BadSyntax(this._thisDoc, this.lines, str, i, "bad list content");
922
+ return i;
923
+ }
924
+ }
925
+ }
926
+ objectList(str, i, res) {
927
+ var i = this.object(str, i, res);
928
+ if (i < 0) {
929
+ return -1;
930
+ }
931
+ while (1) {
932
+ var j = this.skipSpace(str, i);
933
+ if (j < 0) {
934
+ throw BadSyntax(this._thisDoc, this.lines, str, j, "EOF found after object");
1013
935
  return j;
1014
936
  }
1015
- if (str.slice(j, j + 1) == "]") {
937
+ if (str.slice(j, j + 1) != ",") {
1016
938
  return j;
1017
939
  }
1018
- throw BadSyntax(this._thisDoc, this.lines, str, j, "expected '.' or '}' or ']' at end of statement");
1019
- return i;
940
+ var i = this.object(str, j + 1, res);
941
+ if (i < 0) {
942
+ return i;
943
+ }
944
+ }
945
+ }
946
+ checkDot(str, i) {
947
+ var j = this.skipSpace(str, i);
948
+ if (j < 0) {
949
+ return j;
950
+ }
951
+ if (str.slice(j, j + 1) == ".") {
952
+ return j + 1;
953
+ }
954
+ if (str.slice(j, j + 1) == "}") {
955
+ return j;
956
+ }
957
+ if (str.slice(j, j + 1) == "]") {
958
+ return j;
1020
959
  }
1021
- }, {
1022
- key: "uri_ref2",
1023
- value: function uri_ref2(str, i, res) {
1024
- /*
1025
- Generate uri from n3 representation.
1026
- Note that the RDF convention of directly concatenating
1027
- NS and local name is now used though I prefer inserting a '#'
1028
- to make the namesapces look more like what XML folks expect.
1029
- */
960
+ throw BadSyntax(this._thisDoc, this.lines, str, j, "expected '.' or '}' or ']' at end of statement");
961
+ return i;
962
+ }
963
+ uri_ref2(str, i, res) {
964
+ /*
965
+ Generate uri from n3 representation.
966
+ Note that the RDF convention of directly concatenating
967
+ NS and local name is now used though I prefer inserting a '#'
968
+ to make the namesapces look more like what XML folks expect.
969
+ */
1030
970
 
1031
- var qn = new pyjslib_List([]);
1032
- var j = this.qname(str, i, qn);
1033
- if (j >= 0) {
1034
- var pairFudge = qn[0];
1035
- var pfx = pairFudge[0];
1036
- var ln = pairFudge[1];
1037
- if (pfx == null) {
1038
- assertFudge(0, "not used?");
1039
- var ns = this._baseURI + ADDED_HASH;
1040
- } else {
1041
- var ns = this._bindings[pfx];
1042
- if (!ns) {
1043
- if (pfx == "_") {
1044
- res.push(this.anonymousNode(ln));
1045
- return j;
1046
- }
1047
- throw BadSyntax(this._thisDoc, this.lines, str, i, "Prefix " + pfx + " not bound.");
971
+ var qn = new pyjslib_List([]);
972
+ var j = this.qname(str, i, qn);
973
+ if (j >= 0) {
974
+ var pairFudge = qn[0];
975
+ var pfx = pairFudge[0];
976
+ var ln = pairFudge[1];
977
+ if (pfx == null) {
978
+ assertFudge(0, "not used?");
979
+ var ns = this._baseURI + ADDED_HASH;
980
+ } else {
981
+ var ns = this._bindings[pfx];
982
+ if (!ns) {
983
+ if (pfx == "_") {
984
+ res.push(this.anonymousNode(ln));
985
+ return j;
1048
986
  }
987
+ throw BadSyntax(this._thisDoc, this.lines, str, i, "Prefix " + pfx + " not bound.");
1049
988
  }
1050
- var symb = this._store.sym(ns + ln);
1051
- if ((0, _utils.ArrayIndexOf)(this._variables, symb) >= 0) {
1052
- res.push(this._variables[symb]);
1053
- } else {
1054
- res.push(symb);
1055
- }
1056
- return j;
1057
989
  }
1058
- var i = this.skipSpace(str, i);
1059
- if (i < 0) {
1060
- return -1;
990
+ var symb = this._store.sym(ns + ln);
991
+ if ((0, _utils.ArrayIndexOf)(this._variables, symb) >= 0) {
992
+ res.push(this._variables[symb]);
993
+ } else {
994
+ res.push(symb);
1061
995
  }
1062
- if (str.charAt(i) == "?") {
1063
- var v = new pyjslib_List([]);
1064
- var j = this.variable(str, i, v);
1065
- if (j > 0) {
1066
- res.push(v[0]);
1067
- return j;
996
+ return j;
997
+ }
998
+ var i = this.skipSpace(str, i);
999
+ if (i < 0) {
1000
+ return -1;
1001
+ }
1002
+ if (str.charAt(i) == "?") {
1003
+ var v = new pyjslib_List([]);
1004
+ var j = this.variable(str, i, v);
1005
+ if (j > 0) {
1006
+ res.push(v[0]);
1007
+ return j;
1008
+ }
1009
+ return -1;
1010
+ } else if (str.charAt(i) == "<") {
1011
+ var i = i + 1;
1012
+ var st = i;
1013
+ while (i < pyjslib_len(str)) {
1014
+ if (str.charAt(i) == ">") {
1015
+ var uref = str.slice(st, i);
1016
+ if (this._baseURI) {
1017
+ var uref = uripath_join(this._baseURI, uref);
1018
+ } else {
1019
+ assertFudge(uref.indexOf(":") >= 0, "With no base URI, cannot deal with relative URIs");
1020
+ }
1021
+ if (str.slice(i - 1, i) == "#" && !(pyjslib_slice(uref, -1, null) == "#")) {
1022
+ var uref = uref + "#";
1023
+ }
1024
+ var symb = this._store.sym(uref);
1025
+ if ((0, _utils.ArrayIndexOf)(this._variables, symb) >= 0) {
1026
+ res.push(this._variables[symb]);
1027
+ } else {
1028
+ res.push(symb);
1029
+ }
1030
+ return i + 1;
1068
1031
  }
1069
- return -1;
1070
- } else if (str.charAt(i) == "<") {
1071
1032
  var i = i + 1;
1072
- var st = i;
1073
- while (i < pyjslib_len(str)) {
1074
- if (str.charAt(i) == ">") {
1075
- var uref = str.slice(st, i);
1076
- if (this._baseURI) {
1077
- var uref = uripath_join(this._baseURI, uref);
1078
- } else {
1079
- assertFudge(uref.indexOf(":") >= 0, "With no base URI, cannot deal with relative URIs");
1080
- }
1081
- if (str.slice(i - 1, i) == "#" && !(pyjslib_slice(uref, -1, null) == "#")) {
1082
- var uref = uref + "#";
1033
+ }
1034
+ throw BadSyntax(this._thisDoc, this.lines, str, j, "unterminated URI reference");
1035
+ } else if (this.keywordsSet) {
1036
+ var v = new pyjslib_List([]);
1037
+ var j = this.bareWord(str, i, v);
1038
+ if (j < 0) {
1039
+ return -1;
1040
+ }
1041
+ if ((0, _utils.ArrayIndexOf)(this.keywords, v[0]) >= 0) {
1042
+ throw BadSyntax(this._thisDoc, this.lines, str, i, "Keyword \"" + v[0] + "\" not allowed here.");
1043
+ }
1044
+ res.push(this._store.sym(this._bindings[""] + v[0]));
1045
+ return j;
1046
+ } else {
1047
+ return -1;
1048
+ }
1049
+ }
1050
+ skipSpace(str, i) {
1051
+ /*
1052
+ Skip white space, newlines and comments.
1053
+ return -1 if EOF, else position of first non-ws character*/
1054
+
1055
+ var whitespace = ' \n\r\t\f\x0b\xa0\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u2028\u2029\u3000';
1056
+ for (var j = i ? i : 0; j < str.length; j++) {
1057
+ var ch = str.charAt(j);
1058
+ // console.log(" skipspace j= "+j + " i= " + i + " n= " + str.length);
1059
+ // console.log(" skipspace ch <" + ch + ">");
1060
+ if (whitespace.indexOf(ch) < 0) {
1061
+ //not ws
1062
+ // console.log(" skipspace 2 ch <" + ch + ">");
1063
+ if (str.charAt(j) === '#') {
1064
+ for (;; j++) {
1065
+ // console.log(" skipspace2 j= "+j + " i= " + i + " n= " + str.length);
1066
+ if (j === str.length) {
1067
+ return -1; // EOF
1083
1068
  }
1084
- var symb = this._store.sym(uref);
1085
- if ((0, _utils.ArrayIndexOf)(this._variables, symb) >= 0) {
1086
- res.push(this._variables[symb]);
1087
- } else {
1088
- res.push(symb);
1069
+ if (str.charAt(j) === '\n') {
1070
+ this.lines = this.lines + 1;
1071
+ break;
1089
1072
  }
1090
- return i + 1;
1091
1073
  }
1092
- var i = i + 1;
1093
- }
1094
- throw BadSyntax(this._thisDoc, this.lines, str, j, "unterminated URI reference");
1095
- } else if (this.keywordsSet) {
1096
- var v = new pyjslib_List([]);
1097
- var j = this.bareWord(str, i, v);
1098
- if (j < 0) {
1099
- return -1;
1100
- }
1101
- if ((0, _utils.ArrayIndexOf)(this.keywords, v[0]) >= 0) {
1102
- throw BadSyntax(this._thisDoc, this.lines, str, i, "Keyword \"" + v[0] + "\" not allowed here.");
1074
+ ;
1075
+ } else {
1076
+ // Not hash - something interesting
1077
+ // console.log(" skipspace 3 ch <" + ch + ">");
1078
+ return j;
1103
1079
  }
1104
- res.push(this._store.sym(this._bindings[""] + v[0]));
1105
- return j;
1106
1080
  } else {
1107
- return -1;
1081
+ // Whitespace
1082
+ // console.log(" skipspace 5 ch <" + ch + ">");
1083
+ if (str.charAt(j) === '\n') {
1084
+ this.lines = this.lines + 1;
1085
+ }
1108
1086
  }
1087
+ } // next j
1088
+ return -1; // EOF
1089
+ }
1090
+ variable(str, i, res) {
1091
+ /*
1092
+ ?abc -> variable(:abc)
1093
+ */
1094
+
1095
+ var j = this.skipSpace(str, i);
1096
+ if (j < 0) {
1097
+ return -1;
1098
+ }
1099
+ if (str.slice(j, j + 1) != "?") {
1100
+ return -1;
1101
+ }
1102
+ var j = j + 1;
1103
+ var i = j;
1104
+ if ("0123456789-".indexOf(str.charAt(j)) >= 0) {
1105
+ throw BadSyntax(this._thisDoc, this.lines, str, j, "Varible name can't start with '" + str.charAt(j) + "s'");
1106
+ return -1;
1107
+ }
1108
+ while (i < pyjslib_len(str) && _notNameChars.indexOf(str.charAt(i)) < 0) {
1109
+ var i = i + 1;
1110
+ }
1111
+ if (this._parentContext == null) {
1112
+ throw BadSyntax(this._thisDoc, this.lines, str, j, "Can't use ?xxx syntax for variable in outermost level: " + str.slice(j - 1, i));
1109
1113
  }
1110
- }, {
1111
- key: "skipSpace",
1112
- value: function skipSpace(str, i) {
1113
- /*
1114
- Skip white space, newlines and comments.
1115
- return -1 if EOF, else position of first non-ws character*/
1114
+ res.push(this._store.variable(str.slice(j, i)));
1115
+ return i;
1116
+ }
1117
+ bareWord(str, i, res) {
1118
+ /*
1119
+ abc -> :abc
1120
+ */
1116
1121
 
1117
- var whitespace = " \n\r\t\f\x0B\xA0\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u200B\u2028\u2029\u3000";
1118
- for (var j = i ? i : 0; j < str.length; j++) {
1119
- var ch = str.charAt(j);
1120
- // console.log(" skipspace j= "+j + " i= " + i + " n= " + str.length);
1121
- // console.log(" skipspace ch <" + ch + ">");
1122
- if (whitespace.indexOf(ch) < 0) {
1123
- //not ws
1124
- // console.log(" skipspace 2 ch <" + ch + ">");
1125
- if (str.charAt(j) === '#') {
1126
- for (;; j++) {
1127
- // console.log(" skipspace2 j= "+j + " i= " + i + " n= " + str.length);
1128
- if (j === str.length) {
1129
- return -1; // EOF
1130
- }
1131
- if (str.charAt(j) === '\n') {
1132
- this.lines = this.lines + 1;
1133
- break;
1134
- }
1135
- }
1136
- ;
1137
- } else {
1138
- // Not hash - something interesting
1139
- // console.log(" skipspace 3 ch <" + ch + ">");
1140
- return j;
1141
- }
1122
+ var j = this.skipSpace(str, i);
1123
+ if (j < 0) {
1124
+ return -1;
1125
+ }
1126
+ var ch = str.charAt(j);
1127
+ if ("0123456789-".indexOf(ch) >= 0) {
1128
+ return -1;
1129
+ }
1130
+ if (_notNameChars.indexOf(ch) >= 0) {
1131
+ return -1;
1132
+ }
1133
+ var i = j;
1134
+ while (i < pyjslib_len(str) && _notNameChars.indexOf(str.charAt(i)) < 0) {
1135
+ var i = i + 1;
1136
+ }
1137
+ res.push(str.slice(j, i));
1138
+ return i;
1139
+ }
1140
+ qname(str, i, res) {
1141
+ /*
1142
+ xyz:def -> ('xyz', 'def')
1143
+ If not in keywords and keywordsSet: def -> ('', 'def')
1144
+ :def -> ('', 'def')
1145
+ */
1146
+
1147
+ var i = this.skipSpace(str, i);
1148
+ if (i < 0) {
1149
+ return -1;
1150
+ }
1151
+ var c = str.charAt(i);
1152
+ if ("0123456789-+".indexOf(c) >= 0) {
1153
+ return -1;
1154
+ }
1155
+ if (_notNameChars.indexOf(c) < 0) {
1156
+ var ln = c;
1157
+ var i = i + 1;
1158
+ while (i < pyjslib_len(str)) {
1159
+ var c = str.charAt(i);
1160
+ if (_notNameChars.indexOf(c) < 0) {
1161
+ var ln = ln + c;
1162
+ var i = i + 1;
1142
1163
  } else {
1143
- // Whitespace
1144
- // console.log(" skipspace 5 ch <" + ch + ">");
1145
- if (str.charAt(j) === '\n') {
1146
- this.lines = this.lines + 1;
1147
- }
1164
+ break;
1148
1165
  }
1149
- } // next j
1150
- return -1; // EOF
1151
- }
1152
- }, {
1153
- key: "variable",
1154
- value: function variable(str, i, res) {
1155
- /*
1156
- ?abc -> variable(:abc)
1157
- */
1158
-
1159
- var j = this.skipSpace(str, i);
1160
- if (j < 0) {
1161
- return -1;
1162
1166
  }
1163
- if (str.slice(j, j + 1) != "?") {
1164
- return -1;
1165
- }
1166
- var j = j + 1;
1167
- var i = j;
1168
- if ("0123456789-".indexOf(str.charAt(j)) >= 0) {
1169
- throw BadSyntax(this._thisDoc, this.lines, str, j, "Varible name can't start with '" + str.charAt(j) + "s'");
1170
- return -1;
1171
- }
1172
- while (i < pyjslib_len(str) && _notNameChars.indexOf(str.charAt(i)) < 0) {
1173
- var i = i + 1;
1174
- }
1175
- if (this._parentContext == null) {
1176
- throw BadSyntax(this._thisDoc, this.lines, str, j, "Can't use ?xxx syntax for variable in outermost level: " + str.slice(j - 1, i));
1167
+ } else {
1168
+ var ln = "";
1169
+ }
1170
+ if (i < pyjslib_len(str) && str.charAt(i) == ":") {
1171
+ var pfx = ln;
1172
+ var i = i + 1;
1173
+ var ln = "";
1174
+ while (i < pyjslib_len(str)) {
1175
+ var c = str.charAt(i);
1176
+ if (_notNameChars.indexOf(c) < 0) {
1177
+ var ln = ln + c;
1178
+ var i = i + 1;
1179
+ } else {
1180
+ break;
1181
+ }
1177
1182
  }
1178
- res.push(this._store.variable(str.slice(j, i)));
1183
+ res.push(new pyjslib_Tuple([pfx, ln]));
1179
1184
  return i;
1185
+ } else {
1186
+ if (ln && this.keywordsSet && (0, _utils.ArrayIndexOf)(this.keywords, ln) < 0) {
1187
+ res.push(new pyjslib_Tuple(["", ln]));
1188
+ return i;
1189
+ }
1190
+ return -1;
1180
1191
  }
1181
- }, {
1182
- key: "bareWord",
1183
- value: function bareWord(str, i, res) {
1184
- /*
1185
- abc -> :abc
1186
- */
1187
-
1192
+ }
1193
+ object(str, i, res) {
1194
+ var j = this.subject(str, i, res);
1195
+ if (j >= 0) {
1196
+ return j;
1197
+ } else {
1188
1198
  var j = this.skipSpace(str, i);
1189
1199
  if (j < 0) {
1190
1200
  return -1;
1201
+ } else {
1202
+ var i = j;
1191
1203
  }
1192
- var ch = str.charAt(j);
1193
- if ("0123456789-".indexOf(ch) >= 0) {
1194
- return -1;
1195
- }
1196
- if (_notNameChars.indexOf(ch) >= 0) {
1204
+ var delim = null;
1205
+ let ch = str.charAt(i);
1206
+ if (ch == "\"" || ch == "'") {
1207
+ if (str.slice(i, i + 3 == ch + ch)) {
1208
+ delim = ch + ch + ch;
1209
+ } else {
1210
+ delim = ch;
1211
+ }
1212
+ var i = i + pyjslib_len(delim);
1213
+ var pairFudge = this.strconst(str, i, delim);
1214
+ var j = pairFudge[0];
1215
+ var s = pairFudge[1];
1216
+ res.push(this._store.literal(s));
1217
+ diag_progress("New string const ", s, j);
1218
+ return j;
1219
+ } else {
1197
1220
  return -1;
1198
1221
  }
1199
- var i = j;
1200
- while (i < pyjslib_len(str) && _notNameChars.indexOf(str.charAt(i)) < 0) {
1201
- var i = i + 1;
1202
- }
1203
- res.push(str.slice(j, i));
1204
- return i;
1205
1222
  }
1206
- }, {
1207
- key: "qname",
1208
- value: function qname(str, i, res) {
1209
- /*
1210
- xyz:def -> ('xyz', 'def')
1211
- If not in keywords and keywordsSet: def -> ('', 'def')
1212
- :def -> ('', 'def')
1213
- */
1214
-
1215
- var i = this.skipSpace(str, i);
1216
- if (i < 0) {
1217
- return -1;
1218
- }
1219
- var c = str.charAt(i);
1220
- if ("0123456789-+".indexOf(c) >= 0) {
1223
+ }
1224
+ nodeOrLiteral(str, i, res) {
1225
+ var j = this.node(str, i, res);
1226
+ if (j >= 0) {
1227
+ return j;
1228
+ } else {
1229
+ var j = this.skipSpace(str, i);
1230
+ if (j < 0) {
1221
1231
  return -1;
1222
- }
1223
- if (_notNameChars.indexOf(c) < 0) {
1224
- var ln = c;
1225
- var i = i + 1;
1226
- while (i < pyjslib_len(str)) {
1227
- var c = str.charAt(i);
1228
- if (_notNameChars.indexOf(c) < 0) {
1229
- var ln = ln + c;
1230
- var i = i + 1;
1231
- } else {
1232
- break;
1233
- }
1234
- }
1235
1232
  } else {
1236
- var ln = "";
1233
+ var i = j;
1237
1234
  }
1238
- if (i < pyjslib_len(str) && str.charAt(i) == ":") {
1239
- var pfx = ln;
1240
- var i = i + 1;
1241
- var ln = "";
1242
- while (i < pyjslib_len(str)) {
1243
- var c = str.charAt(i);
1244
- if (_notNameChars.indexOf(c) < 0) {
1245
- var ln = ln + c;
1246
- var i = i + 1;
1235
+ var ch = str.charAt(i);
1236
+ if ("-+0987654321".indexOf(ch) >= 0) {
1237
+ datetime_syntax.lastIndex = 0;
1238
+ var m = datetime_syntax.exec(str.slice(i));
1239
+ if (m != null) {
1240
+ // j = ( i + datetime_syntax.lastIndex ) ;
1241
+ var val = m[0];
1242
+ j = i + val.length;
1243
+ if (val.indexOf("T") >= 0) {
1244
+ res.push(this._store.literal(val, this._store.sym(DATETIME_DATATYPE)));
1247
1245
  } else {
1248
- break;
1246
+ res.push(this._store.literal(val, this._store.sym(DATE_DATATYPE)));
1249
1247
  }
1250
- }
1251
- res.push(new pyjslib_Tuple([pfx, ln]));
1252
- return i;
1253
- } else {
1254
- if (ln && this.keywordsSet && (0, _utils.ArrayIndexOf)(this.keywords, ln) < 0) {
1255
- res.push(new pyjslib_Tuple(["", ln]));
1256
- return i;
1257
- }
1258
- return -1;
1259
- }
1260
- }
1261
- }, {
1262
- key: "object",
1263
- value: function object(str, i, res) {
1264
- var j = this.subject(str, i, res);
1265
- if (j >= 0) {
1266
- return j;
1267
- } else {
1268
- var j = this.skipSpace(str, i);
1269
- if (j < 0) {
1270
- return -1;
1271
1248
  } else {
1272
- var i = j;
1273
- }
1274
- var delim = null;
1275
- var ch = str.charAt(i);
1276
- if (ch == "\"" || ch == "'") {
1277
- if (str.slice(i, i + 3 == ch + ch)) {
1278
- delim = ch + ch + ch;
1249
+ number_syntax.lastIndex = 0;
1250
+ var m = number_syntax.exec(str.slice(i));
1251
+ if (m == null) {
1252
+ throw BadSyntax(this._thisDoc, this.lines, str, i, "Bad number or date syntax");
1253
+ }
1254
+ j = i + number_syntax.lastIndex;
1255
+ var val = str.slice(i, j);
1256
+ if (val.indexOf("e") >= 0) {
1257
+ res.push(this._store.literal(parseFloat(val), this._store.sym(FLOAT_DATATYPE)));
1258
+ } else if (str.slice(i, j).indexOf(".") >= 0) {
1259
+ res.push(this._store.literal(parseFloat(val), this._store.sym(DECIMAL_DATATYPE)));
1279
1260
  } else {
1280
- delim = ch;
1261
+ res.push(this._store.literal(parseInt(val), this._store.sym(INTEGER_DATATYPE)));
1281
1262
  }
1282
- var i = i + pyjslib_len(delim);
1283
- var pairFudge = this.strconst(str, i, delim);
1284
- var j = pairFudge[0];
1285
- var s = pairFudge[1];
1286
- res.push(this._store.literal(s));
1287
- diag_progress("New string const ", s, j);
1288
- return j;
1289
- } else {
1290
- return -1;
1291
1263
  }
1264
+ ;
1265
+ return j; // Where we have got up to
1292
1266
  }
1293
- }
1294
- }, {
1295
- key: "nodeOrLiteral",
1296
- value: function nodeOrLiteral(str, i, res) {
1297
- var j = this.node(str, i, res);
1298
- if (j >= 0) {
1299
- return j;
1300
- } else {
1301
- var j = this.skipSpace(str, i);
1302
- if (j < 0) {
1303
- return -1;
1267
+ if (str.charAt(i) == "\"") {
1268
+ if (str.slice(i, i + 3) == "\"\"\"") {
1269
+ var delim = "\"\"\"";
1304
1270
  } else {
1305
- var i = j;
1306
- }
1307
- var ch = str.charAt(i);
1308
- if ("-+0987654321".indexOf(ch) >= 0) {
1309
- datetime_syntax.lastIndex = 0;
1310
- var m = datetime_syntax.exec(str.slice(i));
1311
- if (m != null) {
1312
- // j = ( i + datetime_syntax.lastIndex ) ;
1313
- var val = m[0];
1314
- j = i + val.length;
1315
- if (val.indexOf("T") >= 0) {
1316
- res.push(this._store.literal(val, this._store.sym(DATETIME_DATATYPE)));
1317
- } else {
1318
- res.push(this._store.literal(val, this._store.sym(DATE_DATATYPE)));
1319
- }
1320
- } else {
1321
- number_syntax.lastIndex = 0;
1322
- var m = number_syntax.exec(str.slice(i));
1323
- if (m == null) {
1324
- throw BadSyntax(this._thisDoc, this.lines, str, i, "Bad number or date syntax");
1325
- }
1326
- j = i + number_syntax.lastIndex;
1327
- var val = str.slice(i, j);
1328
- if (val.indexOf("e") >= 0) {
1329
- res.push(this._store.literal(parseFloat(val), this._store.sym(FLOAT_DATATYPE)));
1330
- } else if (str.slice(i, j).indexOf(".") >= 0) {
1331
- res.push(this._store.literal(parseFloat(val), this._store.sym(DECIMAL_DATATYPE)));
1332
- } else {
1333
- res.push(this._store.literal(parseInt(val), this._store.sym(INTEGER_DATATYPE)));
1334
- }
1271
+ var delim = "\"";
1272
+ }
1273
+ var i = i + pyjslib_len(delim);
1274
+ var dt = null;
1275
+ var pairFudge = this.strconst(str, i, delim);
1276
+ var j = pairFudge[0];
1277
+ var s = pairFudge[1];
1278
+ var lang = null;
1279
+ if (str.slice(j, j + 1) == "@") {
1280
+ langcode.lastIndex = 0;
1281
+ var m = langcode.exec(str.slice(j + 1));
1282
+ if (m == null) {
1283
+ throw BadSyntax(this._thisDoc, startline, str, i, "Bad language code syntax on string literal, after @");
1335
1284
  }
1336
- ;
1337
- return j; // Where we have got up to
1285
+ var i = langcode.lastIndex + j + 1;
1286
+ var lang = str.slice(j + 1, i);
1287
+ var j = i;
1338
1288
  }
1339
- if (str.charAt(i) == "\"") {
1340
- if (str.slice(i, i + 3) == "\"\"\"") {
1341
- var delim = "\"\"\"";
1342
- } else {
1343
- var delim = "\"";
1344
- }
1345
- var i = i + pyjslib_len(delim);
1346
- var dt = null;
1347
- var pairFudge = this.strconst(str, i, delim);
1348
- var j = pairFudge[0];
1349
- var s = pairFudge[1];
1350
- var lang = null;
1351
- if (str.slice(j, j + 1) == "@") {
1352
- langcode.lastIndex = 0;
1353
- var m = langcode.exec(str.slice(j + 1));
1354
- if (m == null) {
1355
- throw BadSyntax(this._thisDoc, startline, str, i, "Bad language code syntax on string literal, after @");
1356
- }
1357
- var i = langcode.lastIndex + j + 1;
1358
- var lang = str.slice(j + 1, i);
1359
- var j = i;
1360
- }
1361
- if (str.slice(j, j + 2) == "^^") {
1362
- var res2 = new pyjslib_List([]);
1363
- var j = this.uri_ref2(str, j + 2, res2);
1364
- var dt = res2[0];
1365
- }
1366
- res.push(this._store.literal(s, lang || dt));
1367
- return j;
1368
- } else {
1369
- return -1;
1289
+ if (str.slice(j, j + 2) == "^^") {
1290
+ var res2 = new pyjslib_List([]);
1291
+ var j = this.uri_ref2(str, j + 2, res2);
1292
+ var dt = res2[0];
1370
1293
  }
1294
+ res.push(this._store.literal(s, lang || dt));
1295
+ return j;
1296
+ } else {
1297
+ return -1;
1371
1298
  }
1372
1299
  }
1373
- }, {
1374
- key: "strconst",
1375
- value: function strconst(str, i, delim) {
1376
- /*
1377
- parse an N3 string constant delimited by delim.
1378
- return index, val
1379
- */
1300
+ }
1301
+ strconst(str, i, delim) {
1302
+ /*
1303
+ parse an N3 string constant delimited by delim.
1304
+ return index, val
1305
+ */
1380
1306
 
1381
- var j = i;
1382
- var ustr = "";
1383
- var startline = this.lines;
1384
- while (j < pyjslib_len(str)) {
1385
- var i = j + pyjslib_len(delim);
1386
- if (str.slice(j, i) == delim) {
1387
- return new pyjslib_Tuple([i, ustr]);
1388
- }
1389
- if (str.charAt(j) == "\"") {
1390
- var ustr = ustr + "\"";
1391
- var j = j + 1;
1392
- continue;
1307
+ var j = i;
1308
+ var ustr = "";
1309
+ var startline = this.lines;
1310
+ while (j < pyjslib_len(str)) {
1311
+ var i = j + pyjslib_len(delim);
1312
+ if (str.slice(j, i) == delim) {
1313
+ return new pyjslib_Tuple([i, ustr]);
1314
+ }
1315
+ if (str.charAt(j) == "\"") {
1316
+ var ustr = ustr + "\"";
1317
+ var j = j + 1;
1318
+ continue;
1319
+ }
1320
+ interesting.lastIndex = 0;
1321
+ var m = interesting.exec(str.slice(j));
1322
+ if (!m) {
1323
+ throw BadSyntax(this._thisDoc, startline, str, j, "Closing quote missing in string at ^ in " + str.slice(j - 20, j) + "^" + str.slice(j, j + 20));
1324
+ }
1325
+ var i = j + interesting.lastIndex - 1;
1326
+ var ustr = ustr + str.slice(j, i);
1327
+ var ch = str.charAt(i);
1328
+ if (ch == "\"") {
1329
+ var j = i;
1330
+ continue;
1331
+ } else if (ch == "\r") {
1332
+ var j = i + 1;
1333
+ continue;
1334
+ } else if (ch == "\n") {
1335
+ if (delim == "\"") {
1336
+ throw BadSyntax(this._thisDoc, startline, str, i, "newline found in string literal");
1393
1337
  }
1394
- interesting.lastIndex = 0;
1395
- var m = interesting.exec(str.slice(j));
1396
- if (!m) {
1397
- throw BadSyntax(this._thisDoc, startline, str, j, "Closing quote missing in string at ^ in " + str.slice(j - 20, j) + "^" + str.slice(j, j + 20));
1338
+ this.lines = this.lines + 1;
1339
+ var ustr = ustr + ch;
1340
+ var j = i + 1;
1341
+ this.previousLine = this.startOfLine;
1342
+ this.startOfLine = j;
1343
+ } else if (ch == "\\") {
1344
+ var j = i + 1;
1345
+ var ch = str.slice(j, j + 1);
1346
+ if (!ch) {
1347
+ throw BadSyntax(this._thisDoc, startline, str, i, "unterminated string literal (2)");
1398
1348
  }
1399
- var i = j + interesting.lastIndex - 1;
1400
- var ustr = ustr + str.slice(j, i);
1401
- var ch = str.charAt(i);
1402
- if (ch == "\"") {
1403
- var j = i;
1404
- continue;
1405
- } else if (ch == "\r") {
1406
- var j = i + 1;
1407
- continue;
1408
- } else if (ch == "\n") {
1409
- if (delim == "\"") {
1410
- throw BadSyntax(this._thisDoc, startline, str, i, "newline found in string literal");
1411
- }
1412
- this.lines = this.lines + 1;
1349
+ var k = string_find("abfrtvn\\\"", ch);
1350
+ if (k >= 0) {
1351
+ var uch = "\a\b\f\r\t\v\n\\\"".charAt(k);
1352
+ var ustr = ustr + uch;
1353
+ var j = j + 1;
1354
+ } else if (ch == "u") {
1355
+ var pairFudge = this.uEscape(str, j + 1, startline);
1356
+ var j = pairFudge[0];
1357
+ var ch = pairFudge[1];
1413
1358
  var ustr = ustr + ch;
1414
- var j = i + 1;
1415
- this.previousLine = this.startOfLine;
1416
- this.startOfLine = j;
1417
- } else if (ch == "\\") {
1418
- var j = i + 1;
1419
- var ch = str.slice(j, j + 1);
1420
- if (!ch) {
1421
- throw BadSyntax(this._thisDoc, startline, str, i, "unterminated string literal (2)");
1422
- }
1423
- var k = string_find("abfrtvn\\\"", ch);
1424
- if (k >= 0) {
1425
- var uch = "\a\b\f\r\t\v\n\\\"".charAt(k);
1426
- var ustr = ustr + uch;
1427
- var j = j + 1;
1428
- } else if (ch == "u") {
1429
- var pairFudge = this.uEscape(str, j + 1, startline);
1430
- var j = pairFudge[0];
1431
- var ch = pairFudge[1];
1432
- var ustr = ustr + ch;
1433
- } else if (ch == "U") {
1434
- var pairFudge = this.UEscape(str, j + 1, startline);
1435
- var j = pairFudge[0];
1436
- var ch = pairFudge[1];
1437
- var ustr = ustr + ch;
1438
- } else {
1439
- throw BadSyntax(this._thisDoc, this.lines, str, i, "bad escape");
1440
- }
1359
+ } else if (ch == "U") {
1360
+ var pairFudge = this.UEscape(str, j + 1, startline);
1361
+ var j = pairFudge[0];
1362
+ var ch = pairFudge[1];
1363
+ var ustr = ustr + ch;
1364
+ } else {
1365
+ throw BadSyntax(this._thisDoc, this.lines, str, i, "bad escape");
1441
1366
  }
1442
1367
  }
1443
- throw BadSyntax(this._thisDoc, this.lines, str, i, "unterminated string literal");
1444
- }
1445
- }, {
1446
- key: "uEscape",
1447
- value: function uEscape(str, i, startline) {
1448
- var j = i;
1449
- var count = 0;
1450
- var value = 0;
1451
- while (count < 4) {
1452
- var chFudge = str.slice(j, j + 1);
1453
- var ch = chFudge.toLowerCase();
1454
- var j = j + 1;
1455
- if (ch == "") {
1456
- throw BadSyntax(this._thisDoc, startline, str, i, "unterminated string literal(3)");
1457
- }
1458
- var k = string_find("0123456789abcdef", ch);
1459
- if (k < 0) {
1460
- throw BadSyntax(this._thisDoc, startline, str, i, "bad string literal hex escape");
1461
- }
1462
- var value = value * 16 + k;
1463
- var count = count + 1;
1464
- }
1465
- var uch = String.fromCharCode(value);
1466
- return new pyjslib_Tuple([j, uch]);
1467
- }
1468
- }, {
1469
- key: "UEscape",
1470
- value: function UEscape(str, i, startline) {
1471
- var j = i;
1472
- var count = 0;
1473
- var value = "\\U";
1474
- while (count < 8) {
1475
- var chFudge = str.slice(j, j + 1);
1476
- var ch = chFudge.toLowerCase();
1477
- var j = j + 1;
1478
- if (ch == "") {
1479
- throw BadSyntax(this._thisDoc, startline, str, i, "unterminated string literal(3)");
1480
- }
1481
- var k = string_find("0123456789abcdef", ch);
1482
- if (k < 0) {
1483
- throw BadSyntax(this._thisDoc, startline, str, i, "bad string literal hex escape");
1484
- }
1485
- var value = value + ch;
1486
- var count = count + 1;
1368
+ }
1369
+ throw BadSyntax(this._thisDoc, this.lines, str, i, "unterminated string literal");
1370
+ }
1371
+ uEscape(str, i, startline) {
1372
+ var j = i;
1373
+ var count = 0;
1374
+ var value = 0;
1375
+ while (count < 4) {
1376
+ var chFudge = str.slice(j, j + 1);
1377
+ var ch = chFudge.toLowerCase();
1378
+ var j = j + 1;
1379
+ if (ch == "") {
1380
+ throw BadSyntax(this._thisDoc, startline, str, i, "unterminated string literal(3)");
1487
1381
  }
1488
- var uch = stringFromCharCode("0x" + pyjslib_slice(value, 2, 10) - 0);
1489
- return new pyjslib_Tuple([j, uch]);
1382
+ var k = string_find("0123456789abcdef", ch);
1383
+ if (k < 0) {
1384
+ throw BadSyntax(this._thisDoc, startline, str, i, "bad string literal hex escape");
1385
+ }
1386
+ var value = value * 16 + k;
1387
+ var count = count + 1;
1490
1388
  }
1491
- }]);
1492
- }();
1389
+ var uch = String.fromCharCode(value);
1390
+ return new pyjslib_Tuple([j, uch]);
1391
+ }
1392
+ UEscape(str, i, startline) {
1393
+ var j = i;
1394
+ var count = 0;
1395
+ var value = "\\U";
1396
+ while (count < 8) {
1397
+ var chFudge = str.slice(j, j + 1);
1398
+ var ch = chFudge.toLowerCase();
1399
+ var j = j + 1;
1400
+ if (ch == "") {
1401
+ throw BadSyntax(this._thisDoc, startline, str, i, "unterminated string literal(3)");
1402
+ }
1403
+ var k = string_find("0123456789abcdef", ch);
1404
+ if (k < 0) {
1405
+ throw BadSyntax(this._thisDoc, startline, str, i, "bad string literal hex escape");
1406
+ }
1407
+ var value = value + ch;
1408
+ var count = count + 1;
1409
+ }
1410
+ var uch = stringFromCharCode("0x" + pyjslib_slice(value, 2, 10) - 0);
1411
+ return new pyjslib_Tuple([j, uch]);
1412
+ }
1413
+ }
1414
+ exports.SinkParser = SinkParser;
1493
1415
  function OLD_BadSyntax(uri, lines, str, i, why) {
1494
1416
  return new __OLD_BadSyntax(uri, lines, str, i, why);
1495
1417
  }
@@ -1519,9 +1441,9 @@ __OLD_BadSyntax.prototype.toString = function () {
1519
1441
  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]);
1520
1442
  };
1521
1443
  function BadSyntax(uri, lines, str, i, why) {
1522
- var lineNo = lines + 1;
1523
- var msg = "Line " + lineNo + " of <" + uri + ">: Bad syntax: " + why + "\nat: \"" + str.slice(i, i + 30) + "\"";
1524
- var e = new SyntaxError(msg, uri, lineNo);
1444
+ let lineNo = lines + 1;
1445
+ let msg = "Line " + lineNo + " of <" + uri + ">: Bad syntax: " + why + "\nat: \"" + str.slice(i, i + 30) + "\"";
1446
+ let e = new SyntaxError(msg, uri, lineNo);
1525
1447
  e.lineNo = lineNo;
1526
1448
  e.characterInFile = i;
1527
1449
  e.syntaxProblem = why;