n3 2.10.1 → 2.10.2

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
@@ -60,6 +60,8 @@ class N3Parser {
60
60
  });
61
61
  // Disable explicit quantifiers by default
62
62
  this._explicitQuantifiers = !!options.explicitQuantifiers;
63
+ // Disable formula-only blank node scoping by default
64
+ this._formulaScopedBlankNodes = !!options.formulaScopedBlankNodes;
63
65
  // Disable parsing of unsupported versions by default
64
66
  this._parseUnsupportedVersions = !!options.parseUnsupportedVersions;
65
67
  this._version = options.version;
@@ -128,11 +130,15 @@ class N3Parser {
128
130
  // Every new scope resets the predicate direction
129
131
  this._inversePredicate = false;
130
132
  this._expectOf = false;
131
- // In N3, blank nodes are scoped to a formula
132
- // (using a dot as separator, as a blank node label cannot start with it)
133
- this._prefixes._ = this._graph ? `${this._graph.value}.` : '.';
134
- // Quantifiers are scoped to a formula
135
- this._quantified = Object.create(this._quantified);
133
+ // In N3, blank nodes and quantifiers are scoped to a formula;
134
+ // with `formulaScopedBlankNodes`, lists and blank node property lists
135
+ // share the enclosing scope instead of rescoping
136
+ if (!this._formulaScopedBlankNodes || type === 'formula') {
137
+ // Label the scope with the enclosing formula's blank node
138
+ // (using a dot as separator, as a blank node label cannot start with it)
139
+ this._prefixes._ = this._graph ? `${this._graph.value}.` : '.';
140
+ this._quantified = Object.create(this._quantified);
141
+ }
136
142
  // A formula starts empty and must not inherit its parent's subject
137
143
  if (type === 'formula') {
138
144
  this._subject = null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n3",
3
- "version": "2.10.1",
3
+ "version": "2.10.2",
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
@@ -49,6 +49,8 @@ export default class N3Parser {
49
49
  this._lexer = options.lexer || new N3Lexer({ lineMode: isLineMode, n3: isN3, isImpliedBy: this._isImpliedBy });
50
50
  // Disable explicit quantifiers by default
51
51
  this._explicitQuantifiers = !!options.explicitQuantifiers;
52
+ // Disable formula-only blank node scoping by default
53
+ this._formulaScopedBlankNodes = !!options.formulaScopedBlankNodes;
52
54
  // Disable parsing of unsupported versions by default
53
55
  this._parseUnsupportedVersions = !!options.parseUnsupportedVersions;
54
56
  this._version = options.version;
@@ -111,11 +113,15 @@ export default class N3Parser {
111
113
  // Every new scope resets the predicate direction
112
114
  this._inversePredicate = false;
113
115
  this._expectOf = false;
114
- // In N3, blank nodes are scoped to a formula
115
- // (using a dot as separator, as a blank node label cannot start with it)
116
- this._prefixes._ = (this._graph ? `${this._graph.value}.` : '.');
117
- // Quantifiers are scoped to a formula
118
- this._quantified = Object.create(this._quantified);
116
+ // In N3, blank nodes and quantifiers are scoped to a formula;
117
+ // with `formulaScopedBlankNodes`, lists and blank node property lists
118
+ // share the enclosing scope instead of rescoping
119
+ if (!this._formulaScopedBlankNodes || type === 'formula') {
120
+ // Label the scope with the enclosing formula's blank node
121
+ // (using a dot as separator, as a blank node label cannot start with it)
122
+ this._prefixes._ = (this._graph ? `${this._graph.value}.` : '.');
123
+ this._quantified = Object.create(this._quantified);
124
+ }
119
125
  // A formula starts empty and must not inherit its parent's subject
120
126
  if (type === 'formula') {
121
127
  this._subject = null;