rdflib 2.2.9 → 2.2.10-4fa7e876

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