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