n3 2.2.3 → 2.2.4

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/lib/N3Parser.js CHANGED
@@ -711,7 +711,7 @@ class N3Parser {
711
711
  if (!this._validAnnotation) return this._error('Annotation block can not be empty', token);
712
712
  this._subject = null;
713
713
  this._annotation = false;
714
- next = this._readPunctuation;
714
+ next = this._getContextEndReader();
715
715
  break;
716
716
  default:
717
717
  // An entity means this is a quad (only allowed if not already inside a graph)
@@ -745,9 +745,20 @@ class N3Parser {
745
745
  case ',':
746
746
  next = this._readObject;
747
747
  break;
748
+ // Annotation syntax applies to the quad just read, exactly as it does
749
+ // outside of a blank node property list. `|}` arrives here too, because
750
+ // the objects inside the annotation block are themselves read within the
751
+ // enclosing blank node context.
752
+ case '~':
753
+ case '{|':
754
+ case '|}':
755
+ return this._readPunctuation(token);
748
756
  default:
749
757
  return this._error(`Expected punctuation to follow "${this._object.id}"`, token);
750
758
  }
759
+ // An annotation block consumes the subject it annotates, so there is
760
+ // nothing left to share with a following predicate-object pair
761
+ if (this._subject === null) return this._error('Expected ] to follow annotation', token);
751
762
  // A quad has been completed now, so return it
752
763
  this._emit(this._subject, this._predicate, this._object, this._graph);
753
764
  return next;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n3",
3
- "version": "2.2.3",
3
+ "version": "2.2.4",
4
4
  "description": "Lightning fast, asynchronous, streaming Turtle / N3 / RDF library.",
5
5
  "author": "Ruben Verborgh <ruben.verborgh@gmail.com>",
6
6
  "keywords": [
package/src/N3Parser.js CHANGED
@@ -772,7 +772,7 @@ export default class N3Parser {
772
772
  return this._error('Annotation block can not be empty', token);
773
773
  this._subject = null;
774
774
  this._annotation = false;
775
- next = this._readPunctuation;
775
+ next = this._getContextEndReader();
776
776
  break;
777
777
  default:
778
778
  // An entity means this is a quad (only allowed if not already inside a graph)
@@ -808,9 +808,21 @@ export default class N3Parser {
808
808
  case ',':
809
809
  next = this._readObject;
810
810
  break;
811
+ // Annotation syntax applies to the quad just read, exactly as it does
812
+ // outside of a blank node property list. `|}` arrives here too, because
813
+ // the objects inside the annotation block are themselves read within the
814
+ // enclosing blank node context.
815
+ case '~':
816
+ case '{|':
817
+ case '|}':
818
+ return this._readPunctuation(token);
811
819
  default:
812
820
  return this._error(`Expected punctuation to follow "${this._object.id}"`, token);
813
821
  }
822
+ // An annotation block consumes the subject it annotates, so there is
823
+ // nothing left to share with a following predicate-object pair
824
+ if (this._subject === null)
825
+ return this._error('Expected ] to follow annotation', token);
814
826
  // A quad has been completed now, so return it
815
827
  this._emit(this._subject, this._predicate, this._object, this._graph);
816
828
  return next;