rdflib 2.2.10 → 2.2.12-5f141ca2

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