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