rdfjs / N3.js

Lightning fast, spec-compatible, streaming RDF for JavaScript
http://rdf.js.org/N3.js/
Other
676 stars 127 forks source link

WIP: fix n3 paths #326

Closed jeswr closed 1 year ago

jeswr commented 1 year ago

This is a WIP PR to get N3.js to support all of the styles of paths used by EYE.

Complimentary to https://github.com/rdfjs/N3.js/pull/311/commits/2e655fba7fef05973102d45b8c352e662751cf72.

@josd are there any key test cases that you think are missing?

jeswr commented 1 year ago

Note to self: The following should be included in the N3Star tests:

    for (const [elem, value] of [['()', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'], [':joe', 'ex:joe'], ['<<:joe a :Person>>', '<<:joe a :Person>>']]) {
      it(`should parse a ^ path in a list as subject with path as subject - starting with ${elem}`,
          shouldParse(parser, '@prefix : <ex:>. @prefix fam: <f:>.' +
                              `(${elem}^fam:son <x> <y>) a :List.`,
                      ['_:b0', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type',  'ex:List'],
                      ['_:b0', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first', '_:b1'],
                      ['_:b0', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest',  '_:b2'],
                      ['_:b2', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first', 'x'],
                      ['_:b2', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest',  '_:b3'],
                      ['_:b3', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first', 'y'],
                      ['_:b3', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'],
                      ['_:b1', 'f:son', value]));

      it(`should parse a ^ path in a list as object with path as subject - starting with ${elem}`,
          shouldParse(parser, '@prefix : <ex:>. @prefix fam: <f:>.' +
                              `<l> <is> (${elem}^fam:son <x>  <y>).`,
                      ['l', 'is', '_:b0'],
                      ['_:b0', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first', '_:b1'],
                      ['_:b0', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest',  '_:b2'],
                      ['_:b2', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first', 'x'],
                      ['_:b2', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest',  '_:b3'],
                      ['_:b3', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first', 'y'],
                      ['_:b3', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'],
                      ['_:b1', 'f:son', value]));

      it(`should parse a ^ path in a single element list as subject with path as subject - starting with ${elem}`,
          shouldParse(parser, '@prefix : <ex:>. @prefix fam: <f:>.' +
                              `(${elem}^fam:son) a :List.`,
                      ['_:b0', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type',  'ex:List'],
                      ['_:b0', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first', '_:b1'],
                      ['_:b0', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'],
                      ['_:b1', 'f:son', value]));

      it(`should parse a ^ path in a single element list as object with path as subject - starting with ${elem}`,
          shouldParse(parser, '@prefix : <ex:>. @prefix fam: <f:>.' +
                              `<l> <is> (${elem}^fam:son).`,
                      ['l', 'is', '_:b0'],
                      ['_:b0', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first', '_:b1'],
                      ['_:b0', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'],
                      ['_:b1', 'f:son', value]));

      it(`should parse a ^ path in a list as subject with path as object - starting with ${elem}`,
          shouldParse(parser, '@prefix : <ex:>. @prefix fam: <f:>.' +
                              `(<x> <y> ${elem}^fam:son) a :List.`,
                      ['_:b0', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type',  'ex:List'],
                      ['_:b0', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first', 'x'],
                      ['_:b0', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest',  '_:b1'],
                      ['_:b1', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first', 'y'],
                      ['_:b1', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest',  '_:b2'],
                      ['_:b2', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first', '_:b3'],
                      ['_:b2', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'],
                      ['_:b3', 'f:son', value]));

      it(`should parse a ^ path in a list as object with path as object - starting with ${elem}`,
          shouldParse(parser, '@prefix : <ex:>. @prefix fam: <f:>.' +
                              `<l> <is> (<x>  <y> ${elem}^fam:son).`,
                      ['l', 'is', '_:b0'],
                      ['_:b0', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first', 'x'],
                      ['_:b0', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest',  '_:b1'],
                      ['_:b1', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first', 'y'],
                      ['_:b1', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest',  '_:b2'],
                      ['_:b2', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first', '_:b3'],
                      ['_:b2', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'],
                      ['_:b3', 'f:son', value]));

      it(`should parse a ! path in a list as subject with path as subject - starting with ${elem}`,
          shouldParse(parser, '@prefix : <ex:>. @prefix fam: <f:>.' +
                              `(${elem}!fam:son <x> <y>) a :List.`,
                      ['_:b0', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type',  'ex:List'],
                      ['_:b0', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first', '_:b1'],
                      ['_:b0', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest',  '_:b2'],
                      ['_:b2', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first', 'x'],
                      ['_:b2', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest',  '_:b3'],
                      ['_:b3', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first', 'y'],
                      ['_:b3', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'],
                      [value, 'f:son', '_:b1']));

      it(`should parse a ! path in a list as object with path as subject - starting with ${elem}`,
          shouldParse(parser, '@prefix : <ex:>. @prefix fam: <f:>.' +
                              `<l> <is> (${elem}!fam:son <x>  <y>).`,
                      ['l', 'is', '_:b0'],
                      ['_:b0', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first', '_:b1'],
                      ['_:b0', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest',  '_:b2'],
                      ['_:b2', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first', 'x'],
                      ['_:b2', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest',  '_:b3'],
                      ['_:b3', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first', 'y'],
                      ['_:b3', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'],
                      [value, 'f:son', '_:b1']));

      it(`should parse a ! path in a list as subject with path as subject - starting with ${elem}`,
          shouldParse(parser, '@prefix : <ex:>. @prefix fam: <f:>.' +
                              `(${elem}!fam:son) a :List.`,
                      ['_:b0', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type',  'ex:List'],
                      ['_:b0', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first', '_:b1'],
                      ['_:b0', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'],
                      [value, 'f:son', '_:b1']));

      it(`should parse a ! path in a list as object with path as subject - starting with ${elem}`,
          shouldParse(parser, '@prefix : <ex:>. @prefix fam: <f:>.' +
                              `<l> <is> (${elem}!fam:son).`,
                      ['l', 'is', '_:b0'],
                      ['_:b0', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first', '_:b1'],
                      ['_:b0', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'],
                      [value, 'f:son', '_:b1']));

      it(`should parse a ! path in a list as subject with path as object - starting with ${elem}`,
          shouldParse(parser, '@prefix : <ex:>. @prefix fam: <f:>.' +
                              `(<x> <y> ${elem}!fam:son) a :List.`,
                      ['_:b0', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type',  'ex:List'],
                      ['_:b0', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first', 'x'],
                      ['_:b0', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest',  '_:b1'],
                      ['_:b1', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first', 'y'],
                      ['_:b1', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest',  '_:b2'],
                      ['_:b2', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first', '_:b3'],
                      ['_:b2', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'],
                      [value, 'f:son', '_:b3']));

      it(`should parse a ! path in a list as object with path as object - starting with ${elem}`,
          shouldParse(parser, '@prefix : <ex:>. @prefix fam: <f:>.' +
                              `<l> <is> (<x>  <y> ${elem}!fam:son).`,
                      ['l', 'is', '_:b0'],
                      ['_:b0', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first', 'x'],
                      ['_:b0', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest',  '_:b1'],
                      ['_:b1', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first', 'y'],
                      ['_:b1', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest',  '_:b2'],
                      ['_:b2', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first', '_:b3'],
                      ['_:b2', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'],
                      [value, 'f:son', '_:b3']));

      it(`should parse a ^ path in a list as subject with path as subject - starting with ${elem}`,
          shouldParse(parser, '@prefix : <ex:>. @prefix fam: <f:>.' +
                              `((${elem}^fam:son) <x> <y>) a :List.`,
                      ['_:b0', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type',  'ex:List'],
                      ['_:b0', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first', '_:b1'],
                      ['_:b0', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest',  '_:b3'],
                      ['_:b3', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first', 'x'],
                      ['_:b3', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest',  '_:b4'],
                      ['_:b4', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first', 'y'],
                      ['_:b4', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'],
                      ['_:b1', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first', '_:b2'],
                      ['_:b1', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'],
                      ['_:b2', 'f:son', value]));

      it(`should parse a ^ path in a list as object with path as subject - starting with ${elem}`,
          shouldParse(parser, '@prefix : <ex:>. @prefix fam: <f:>.' +
                              `<l> <is> ((${elem}^fam:son) <x>  <y>).`,
                      ['l', 'is', '_:b0'],
                      ['_:b0', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first', '_:b1'],
                      ['_:b0', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest',  '_:b3'],
                      ['_:b3', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first', 'x'],
                      ['_:b3', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest',  '_:b4'],
                      ['_:b4', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first', 'y'],
                      ['_:b4', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'],
                      ['_:b1', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first', '_:b2'],
                      ['_:b1', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'],
                      ['_:b2', 'f:son', value]));

      it(`should parse a ^ path in a single element list as subject with path as subject - starting with ${elem}`,
          shouldParse(parser, '@prefix : <ex:>. @prefix fam: <f:>.' +
                              `((${elem}^fam:son)) a :List.`,
                      ['_:b0', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type',  'ex:List'],
                      ['_:b0', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first', '_:b1'],
                      ['_:b0', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'],
                      ['_:b1', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first', '_:b2'],
                      ['_:b1', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'],
                      ['_:b2', 'f:son', value]));

      it(`should parse a ^ path in a single element list as object with path as subject - starting with ${elem}`,
          shouldParse(parser, '@prefix : <ex:>. @prefix fam: <f:>.' +
                              `<l> <is> ((${elem}^fam:son)).`,
                      ['l', 'is', '_:b0'],
                      ['_:b0', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first', '_:b1'],
                      ['_:b0', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'],
                      ['_:b1', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first', '_:b2'],
                      ['_:b1', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'],
                      ['_:b2', 'f:son', value]));

      it(`should parse a ^ path in a list as subject with path as object - starting with ${elem}`,
          shouldParse(parser, '@prefix : <ex:>. @prefix fam: <f:>.' +
                              `(<x> <y> (${elem}^fam:son)) a :List.`,
                      ['_:b0', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type',  'ex:List'],
                      ['_:b0', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first', 'x'],
                      ['_:b0', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest',  '_:b1'],
                      ['_:b1', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first', 'y'],
                      ['_:b1', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest',  '_:b2'],
                      ['_:b2', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first', '_:b3'],
                      ['_:b2', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'],

                      ['_:b3', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first', '_:b4'],
                      ['_:b3', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'],

                      ['_:b4', 'f:son', value]));

      it(`should parse a ^ path in a list as object with path as object - starting with ${elem}`,
          shouldParse(parser, '@prefix : <ex:>. @prefix fam: <f:>.' +
                              `<l> <is> (<x>  <y> (${elem}^fam:son)).`,
                      ['l', 'is', '_:b0'],
                      ['_:b0', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first', 'x'],
                      ['_:b0', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest',  '_:b1'],
                      ['_:b1', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first', 'y'],
                      ['_:b1', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest',  '_:b2'],
                      ['_:b2', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first', '_:b3'],
                      ['_:b2', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'],

                      ['_:b3', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first', '_:b4'],
                      ['_:b3', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'],

                      ['_:b4', 'f:son', value]));

      it(`should parse a ! path in a list as subject with path as subject - starting with ${elem}`,
          shouldParse(parser, '@prefix : <ex:>. @prefix fam: <f:>.' +
                              `((${elem}!fam:son) <x> <y>) a :List.`,
                      ['_:b0', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type',  'ex:List'],
                      ['_:b0', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first', '_:b1'],
                      ['_:b0', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest',  '_:b3'],
                      ['_:b3', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first', 'x'],
                      ['_:b3', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest',  '_:b4'],
                      ['_:b4', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first', 'y'],
                      ['_:b4', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'],

                      ['_:b1', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first', '_:b2'],
                      ['_:b1', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'],

                      [value, 'f:son', '_:b2']));

      it(`should parse a ! path in a list as object with path as subject - starting with ${elem}`,
          shouldParse(parser, '@prefix : <ex:>. @prefix fam: <f:>.' +
                              `<l> <is> ((${elem}!fam:son) <x>  <y>).`,
                      ['l', 'is', '_:b0'],
                      ['_:b0', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first', '_:b1'],
                      ['_:b0', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest',  '_:b3'],
                      ['_:b3', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first', 'x'],
                      ['_:b3', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest',  '_:b4'],
                      ['_:b4', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first', 'y'],
                      ['_:b4', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'],

                      ['_:b1', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first', '_:b2'],
                      ['_:b1', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'],

                      [value, 'f:son', '_:b2']));

      it(`should parse a ! path in a list as subject with path as subject - starting with ${elem}`,
          shouldParse(parser, '@prefix : <ex:>. @prefix fam: <f:>.' +
                              `((${elem}!fam:son)) a :List.`,
                      ['_:b0', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type',  'ex:List'],
                      ['_:b0', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first', '_:b1'],
                      ['_:b0', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'],

                      ['_:b1', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first', '_:b2'],
                      ['_:b1', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'],

                      [value, 'f:son', '_:b2']));

      it(`should parse a ! path in a list as object with path as subject - starting with ${elem}`,
          shouldParse(parser, '@prefix : <ex:>. @prefix fam: <f:>.' +
                              `<l> <is> ((${elem}!fam:son)).`,
                      ['l', 'is', '_:b0'],
                      ['_:b0', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first', '_:b1'],
                      ['_:b0', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'],

                      ['_:b1', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first', '_:b2'],
                      ['_:b1', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'],

                      [value, 'f:son', '_:b2']));

      it(`should parse a ! path in a list as subject with path as object - starting with ${elem}`,
          shouldParse(parser, '@prefix : <ex:>. @prefix fam: <f:>.' +
                              `(<x> <y> (${elem}!fam:son)) a :List.`,
                      ['_:b0', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type',  'ex:List'],
                      ['_:b0', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first', 'x'],
                      ['_:b0', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest',  '_:b1'],
                      ['_:b1', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first', 'y'],
                      ['_:b1', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest',  '_:b2'],
                      ['_:b2', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first', '_:b3'],
                      ['_:b2', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'],
                      ['_:b3', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first', '_:b4'],
                      ['_:b3', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'],
                      [value, 'f:son', '_:b4']));

      it(`should parse a ! path in a list as object with path as object - starting with ${elem}`,
          shouldParse(parser, '@prefix : <ex:>. @prefix fam: <f:>.' +
                              `<l> <is> (<x>  <y> (${elem}!fam:son)).`,
                      ['l', 'is', '_:b0'],
                      ['_:b0', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first', 'x'],
                      ['_:b0', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest',  '_:b1'],
                      ['_:b1', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first', 'y'],
                      ['_:b1', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest',  '_:b2'],
                      ['_:b2', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first', '_:b3'],
                      ['_:b2', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'],
                      ['_:b3', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first', '_:b4'],
                      ['_:b3', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'],
                      [value, 'f:son', '_:b4']));
    }
jeswr commented 1 year ago

Closing in favour of #341 which now contains these changes.