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