Repository navigation
Follow the SPARQL grammar when looking for an undeclared prefix - #26
Merged
Merged
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
The prefix scanner misses undeclared prefixes in compact embedded triples and falsely reports prefixes inside digit-led unterminated IRIs, masking the parser’s diagnostic.
2 open issues
What changed in this PR
Refines the undeclared-prefix diagnostics introduced in #24 by aligning the fallback scanner more closely with SPARQL grammar, reducing misleading errors on unusual input.
Changes:
- Updates handling of comments, names, variables, language tags, and blank node labels.
- Preserves parser errors when an apparent IRI is unterminated.
- Adds Ruby regression tests for unusual token boundaries and Unicode names.
| File | Description |
|---|---|
| test/test_query.rb | Adds regression cases for corrected prefix detection and parser-error preservation. |
| ext/oxigraph/src/prefix.rs | Refines scanner character rules, token boundaries, and unterminated-input handling. |
Review effort: Balanced
nertzy
force-pushed
the
prefix-scan-grammar
branch
from
November 17, 2026 05:27
bafbe51 to
41e8a1e
Compare
The scan that names an undeclared prefix disagreed with the grammar on unusual text, and then blamed a prefix that was declared or was no prefix at all. A comment now ends at a carriage return as well as a line feed, and may sit between PREFIX and the prefix it declares. A variable name no longer takes in a hyphen, a blank node label keeps its inner dots, and a name may hold the combining marks and other characters the grammar allows. A "<" is a comparison, the start of an embedded triple, or the start of an IRI, and only a parse can tell which. The scan steps over a "<" only when an IRI opens there and closes; any other "<" ends it, and the parser's own message stays. So a prefix is named when it comes before the first comparison or embedded triple, and the README says so.
nertzy
force-pushed
the
prefix-scan-grammar
branch
from
November 17, 2026 15:27
41e8a1e to
4457d35
Compare
This was referenced Nov 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

The scan that names an undeclared prefix (#24) disagreed with the SPARQL grammar on unusual text. In those cases the error blamed a prefix that was declared, or something that was not a prefix at all, which is worse than the parser's own message. This makes the scan's tokens follow the terminals of the grammar the parser uses, and ends the scan where it would have to guess.
What changes
PREFIXlinePREFIXand the prefix it declares<urn:foourn:?o-ex:a:ex:_:b.PREFIXPREFIXas a declaration<comparison, such as?o < 18or?s < ex:a<< ?s ?p ex:a >>One trade-off
A
<is a comparison, the start of an embedded triple, or the start of an IRI, and only a parse can tell which. The scan steps over a<only when an IRI opens there and closes. Any other<ends it.So a prefix is named when it comes before the first comparison or embedded triple. After that the parser's own message stays, which is vaguer and not wrong. The README says so.
An earlier version of this pull request tried to tell the three apart from the characters around the
<. Review kept finding text that fooled it, so that logic is gone.Known limit
A
<followed by a>with no white space between them still reads as an IRI. A comparison written without spaces can match that by accident, as inFILTER(?a<'x>ex:p'). The scan then reads the rest of the string as query text and namesex:. This is unchanged frommain.Each case started from a failing test. The comments this answers are on #24, which merged before they were addressed, and on this pull request.