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