n3 2.2.0 → 2.2.1
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/browser/n3.esm.min.js +5 -5
- package/browser/n3.min.js +1 -1
- package/lib/N3Parser.js +14 -2
- package/package.json +1 -1
- package/src/N3Parser.js +13 -2
package/lib/N3Parser.js
CHANGED
|
@@ -488,6 +488,11 @@ class N3Parser {
|
|
|
488
488
|
if (!this._n3Mode) return this._error('Unexpected graph', token);
|
|
489
489
|
this._saveContext('formula', this._graph, this._subject, this._predicate, this._graph = this._factory.blankNode());
|
|
490
490
|
return this._readSubject;
|
|
491
|
+
case '<<(':
|
|
492
|
+
this._saveContext('<<(', this._graph, null, null, null);
|
|
493
|
+
this._graph = null;
|
|
494
|
+
next = this._readSubject;
|
|
495
|
+
break;
|
|
491
496
|
case '<<':
|
|
492
497
|
this._saveContext('<<', this._graph, null, null, null);
|
|
493
498
|
this._graph = null;
|
|
@@ -500,8 +505,8 @@ class N3Parser {
|
|
|
500
505
|
// Create a new blank node if no item head was assigned yet
|
|
501
506
|
if (list === null) this._subject = list = this._factory.blankNode();
|
|
502
507
|
|
|
503
|
-
// When reading a reified triple, store the list as subject in the stack, as this will be overridden when reading the triple.
|
|
504
|
-
if (token.type === '<<') stack[stack.length - 1].subject = this._subject;
|
|
508
|
+
// When reading a reified triple or triple term, store the list as subject in the stack, as this will be overridden when reading the triple.
|
|
509
|
+
if (token.type === '<<' || token.type === '<<(') stack[stack.length - 1].subject = this._subject;
|
|
505
510
|
|
|
506
511
|
// Is this the first element of the list?
|
|
507
512
|
if (previousList === null) {
|
|
@@ -929,6 +934,13 @@ class N3Parser {
|
|
|
929
934
|
const quad = this._factory.quad(this._subject, this._predicate, this._object, this._graph || this.DEFAULTGRAPH);
|
|
930
935
|
this._restoreContext('<<(', token);
|
|
931
936
|
|
|
937
|
+
// If we're in a list, continue processing that list
|
|
938
|
+
const stack = this._contextStack,
|
|
939
|
+
parent = stack.length && stack[stack.length - 1];
|
|
940
|
+
if (parent && parent.type === 'list') {
|
|
941
|
+
this._emit(this._subject, this.RDF_FIRST, quad, this._graph);
|
|
942
|
+
return this._getContextEndReader();
|
|
943
|
+
}
|
|
932
944
|
// If the triple was the subject, continue by reading the predicate.
|
|
933
945
|
if (this._subject === null) {
|
|
934
946
|
this._subject = quad;
|
package/package.json
CHANGED
package/src/N3Parser.js
CHANGED
|
@@ -520,6 +520,11 @@ export default class N3Parser {
|
|
|
520
520
|
this._saveContext('formula', this._graph, this._subject, this._predicate,
|
|
521
521
|
this._graph = this._factory.blankNode());
|
|
522
522
|
return this._readSubject;
|
|
523
|
+
case '<<(':
|
|
524
|
+
this._saveContext('<<(', this._graph, null, null, null);
|
|
525
|
+
this._graph = null;
|
|
526
|
+
next = this._readSubject;
|
|
527
|
+
break;
|
|
523
528
|
case '<<':
|
|
524
529
|
this._saveContext('<<', this._graph, null, null, null);
|
|
525
530
|
this._graph = null;
|
|
@@ -534,8 +539,8 @@ export default class N3Parser {
|
|
|
534
539
|
if (list === null)
|
|
535
540
|
this._subject = list = this._factory.blankNode();
|
|
536
541
|
|
|
537
|
-
// When reading a reified triple, store the list as subject in the stack, as this will be overridden when reading the triple.
|
|
538
|
-
if (token.type === '<<')
|
|
542
|
+
// When reading a reified triple or triple term, store the list as subject in the stack, as this will be overridden when reading the triple.
|
|
543
|
+
if (token.type === '<<' || token.type === '<<(')
|
|
539
544
|
stack[stack.length - 1].subject = this._subject;
|
|
540
545
|
|
|
541
546
|
// Is this the first element of the list?
|
|
@@ -1012,6 +1017,12 @@ export default class N3Parser {
|
|
|
1012
1017
|
this._graph || this.DEFAULTGRAPH);
|
|
1013
1018
|
this._restoreContext('<<(', token);
|
|
1014
1019
|
|
|
1020
|
+
// If we're in a list, continue processing that list
|
|
1021
|
+
const stack = this._contextStack, parent = stack.length && stack[stack.length - 1];
|
|
1022
|
+
if (parent && parent.type === 'list') {
|
|
1023
|
+
this._emit(this._subject, this.RDF_FIRST, quad, this._graph);
|
|
1024
|
+
return this._getContextEndReader();
|
|
1025
|
+
}
|
|
1015
1026
|
// If the triple was the subject, continue by reading the predicate.
|
|
1016
1027
|
if (this._subject === null) {
|
|
1017
1028
|
this._subject = quad;
|