Feature/335 property path parser and ast#463
Conversation
…loads Use PathAst as the predicate type in triple patterns, with TriplePatternAst.of for simple terms and addTriple overloads for path and term predicates. Extend VariableScopeAnalyzer and parser tests for PredicatePathAst wrapping. Co-authored-by: Cursor <cursoragent@cursor.com>
…uilder Walk path/* grammar rules into PathAst nodes and wire BgpFeature to addTriple with composed predicates. Add parser tests for sequence, alternative, modifiers, inverse, and negated property sets. Co-authored-by: Cursor <cursoragent@cursor.com>
2890f06 to
523b180
Compare
|
I did a rebase and added the visitor pattern to the new asts |
| * Creates a fresh anonymous blank node label for expanded BGP triples. | ||
| */ | ||
| public TermAst newAnonymousBlankNode() { | ||
| return iri("_:b" + anonymousBlankNodeCounter++); |
There was a problem hiding this comment.
Please use fr.inria.corese.core.next.data.impl.io.common.IOConstants#BLANK_NODE_PREFIX in case we want to config it later
|
Test Results 420 files 420 suites 22s ⏱️ Results for commit 523b180. |
remiceres
left a comment
There was a problem hiding this comment.
The first one only cleans up the style warnings reported by Sonar.
The second one updates the Gradle source set configuration. On my side, the generated ANTLR parser files were not visible in the project, so imports like fr.inria.corese.core.next.impl.parser.antlr.SparqlParser were not resolved correctly in the IDE. This change fixes that locally, but please verify that it also works correctly on your side.
| /** | ||
| * Creates a fresh anonymous blank node label for expanded BGP triples. | ||
| */ | ||
| public TermAst newAnonymousBlankNode() { |
There was a problem hiding this comment.
This generates fresh blank nodes with labels like _:b0. That can collide with user-written blank node labels and make two different nodes become equal in the AST.
@Test
void generatedBlankNodeShouldNotCollideWithUserBlankNodeLabel() {
SparqlParser parser = newParserDefault();
QueryAst ast = parser.parse("""
PREFIX ex: <http://example.org/>
SELECT * WHERE {
_:b0 ex:link [ ex:p ?o ] .
}
""");
BgpAst bgp = whereBgp(ast);
assertEquals(2, bgp.triples().size());
TriplePatternAst inner = bgp.triples().getFirst();
TriplePatternAst outer = bgp.triples().get(1);
assertInstanceOf(IriAst.class, outer.subject());
assertInstanceOf(IriAst.class, outer.object());
assertNotEquals(outer.subject(), outer.object());
assertNotEquals(outer.subject(), inner.subject());
}
Ajout du support des property paths SPARQL 1.1 dans le parser next.
Introduction des PathAst et fait porter le prédicat par PathAst dans TriplePatternAst
Mapping la grammaire ANTLR dans SparqlAstBuilder
Production des triples avec prédicats path dans BgpFeature.exitTriplesSameSubjectPath
et quelques corrections
fix build pour Gradle 9.1