rdflib 2.2.22 → 2.2.23-6384f9a2

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