feat(parser): support N3 IRI property lists - #695
Conversation
|
LGTM - just awaiting copilot comment |
There was a problem hiding this comment.
Pull request overview
Adds support for the N3 iriPropertyList ([id <iri> ...]) construct so that the supplied IRI replaces the provisional blank node in the enclosing subject/predicate/object context before emitting the property list’s triples. This aligns N3.js parsing behavior with the W3C N3 parser manifest cases referenced in #689 (and improves the suite results referenced in #640).
Changes:
- Extend the parser to recognize
idimmediately after[and replace the property list’s placeholder blank node with the supplied IRI before reading predicates. - Extend the lexer to tokenize
idas a dedicated token in N3 mode only, including when split across stream chunks, while preservingid:pas a normal prefixed name. - Add positive and negative Jest coverage for IRI property list parsing/tokenization behavior.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| test/N3Parser-test.js | Adds parse/negative tests for IRI property lists in subject/object/predicate positions, including nesting and invalid forms. |
| test/N3Lexer-test.js | Adds tokenization tests for id in N3 mode (including chunk boundaries) and ensures id:p remains a prefixed name. |
| src/N3Parser.js | Implements IRI property list ID handling by swapping the placeholder blank node with the provided IRI and enforcing predicate presence after the ID. |
| src/N3Lexer.js | Introduces an N3-only id token via a new regex + switch branch, including stream-friendly behavior. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
ef3b61b to
31a0a14
Compare
|
🎉 This PR is included in version 2.5.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Implements the current N3
iriPropertyListproduction used by the W3C parser manifest:The supplied IRI replaces the provisional blank node in the enclosing subject, predicate, or object context before properties are emitted. Nested IRI property lists therefore preserve both inner and outer references. The parser requires an actual IRI after
id, requires a predicate-object list, and keeps the suite's illegal-semicolon, multiple-ID, and blank-node-ID cases negative.The lexer recognizes
idonly in N3 mode, waits across stream chunks, and preservesid:pas a normal prefixed name.This makes all five positive IRI-property-list cases in #640 pass.
Tests: full Jest suite (6,825 tests, 100% coverage); ESLint; W3C parser manifest improves from 173/222 to 178/222 on this branch alone.
Closes #689