eyeling 1.21.8 → 1.21.9

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.
@@ -11057,13 +11057,14 @@ ${triples.map((tr) => ` ${tripleToN3(tr, prefixes)}`).join('\n')}
11057
11057
  // Also strip an optional language tag from the lexical form:
11058
11058
  // "\"hello\"@en" -> "\"hello\""
11059
11059
  // "\"hello\"@en^^<...>" is rejected earlier in the parser.
11060
- const idx = lit.indexOf('^^');
11061
11060
  let lex = lit;
11062
11061
  let dt = null;
11063
11062
 
11064
- if (idx >= 0) {
11065
- lex = lit.slice(0, idx);
11066
- dt = lit.slice(idx + 2).trim();
11063
+ const re = /^(['"]{1,3})([\s\S]*?)\1\^\^(.+)$/;
11064
+ const match = lit.match(re);
11065
+ if (match) {
11066
+ lex = match[1] + match[2] + match[1];
11067
+ dt = match[3];
11067
11068
  if (dt.startsWith('<') && dt.endsWith('>')) {
11068
11069
  dt = dt.slice(1, -1);
11069
11070
  }
package/eyeling.js CHANGED
@@ -11028,13 +11028,14 @@ function literalParts(lit) {
11028
11028
  // Also strip an optional language tag from the lexical form:
11029
11029
  // "\"hello\"@en" -> "\"hello\""
11030
11030
  // "\"hello\"@en^^<...>" is rejected earlier in the parser.
11031
- const idx = lit.indexOf('^^');
11032
11031
  let lex = lit;
11033
11032
  let dt = null;
11034
11033
 
11035
- if (idx >= 0) {
11036
- lex = lit.slice(0, idx);
11037
- dt = lit.slice(idx + 2).trim();
11034
+ const re = /^(['"]{1,3})([\s\S]*?)\1\^\^(.+)$/;
11035
+ const match = lit.match(re);
11036
+ if (match) {
11037
+ lex = match[1] + match[2] + match[1];
11038
+ dt = match[3];
11038
11039
  if (dt.startsWith('<') && dt.endsWith('>')) {
11039
11040
  dt = dt.slice(1, -1);
11040
11041
  }
package/lib/prelude.js CHANGED
@@ -57,13 +57,14 @@ function literalParts(lit) {
57
57
  // Also strip an optional language tag from the lexical form:
58
58
  // "\"hello\"@en" -> "\"hello\""
59
59
  // "\"hello\"@en^^<...>" is rejected earlier in the parser.
60
- const idx = lit.indexOf('^^');
61
60
  let lex = lit;
62
61
  let dt = null;
63
62
 
64
- if (idx >= 0) {
65
- lex = lit.slice(0, idx);
66
- dt = lit.slice(idx + 2).trim();
63
+ const re = /^(['"]{1,3})([\s\S]*?)\1\^\^(.+)$/;
64
+ const match = lit.match(re);
65
+ if (match) {
66
+ lex = match[1] + match[2] + match[1];
67
+ dt = match[3];
67
68
  if (dt.startsWith('<') && dt.endsWith('>')) {
68
69
  dt = dt.slice(1, -1);
69
70
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eyeling",
3
- "version": "1.21.8",
3
+ "version": "1.21.9",
4
4
  "description": "A minimal Notation3 (N3) reasoner in JavaScript.",
5
5
  "main": "./index.js",
6
6
  "keywords": [
package/test/api.test.js CHANGED
@@ -258,6 +258,35 @@ ${U('c')} ${U('friend')} ${U('d')}.
258
258
  }
259
259
 
260
260
  const cases = [
261
+ {
262
+ name: '00 parsing untyped literal ^^',
263
+ opt: { proofComments: false },
264
+ input: `
265
+ @prefix : <http://example.org/> .
266
+ @prefix log: <http://www.w3.org/2000/10/swap/log#>.
267
+
268
+ { ?s :p ?o } => { ?s log:outputString ?o } .
269
+ :s :p "^^" .
270
+ `,
271
+ check(out) {
272
+ assert.equal(String(out).trimEnd(), '^^');
273
+ },
274
+ },
275
+ {
276
+ name: '00b parsing typed literal ^^',
277
+ opt: { proofComments: false },
278
+ input: `
279
+ @prefix : <http://example.org/> .
280
+ @prefix log: <http://www.w3.org/2000/10/swap/log#>.
281
+ @prefix xsd: <http://www.w3.org/2001/XMLSchema#>.
282
+
283
+ { ?s :p ?o } => { ?s log:outputString ?o } .
284
+ :s :p "^^"^^xsd:string .
285
+ `,
286
+ check(out) {
287
+ assert.equal(String(out).trimEnd(), '^^');
288
+ },
289
+ },
261
290
  {
262
291
  name: '01 forward rule: p -> q',
263
292
  opt: { proofComments: false },