Skip to content

Feature/335 property path parser and ast#463

Open
prbblrypier wants to merge 6 commits into
feature/corese-nextfrom
feature/335-property-path-parser-and-ast
Open

Feature/335 property path parser and ast#463
prbblrypier wants to merge 6 commits into
feature/corese-nextfrom
feature/335-property-path-parser-and-ast

Conversation

@prbblrypier

Copy link
Copy Markdown
Contributor

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

@prbblrypier prbblrypier added the Refactoring Issue created during the 2025 refactoring effort label Jun 17, 2026
@prbblrypier prbblrypier linked an issue Jun 17, 2026 that may be closed by this pull request
prbblrypier and others added 6 commits June 22, 2026 11:27
…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>
@MaillPierre MaillPierre force-pushed the feature/335-property-path-parser-and-ast branch from 2890f06 to 523b180 Compare June 22, 2026 11:36
@MaillPierre

Copy link
Copy Markdown
Contributor

I did a rebase and added the visitor pattern to the new asts

@MaillPierre MaillPierre removed their request for review June 22, 2026 11:36
* Creates a fresh anonymous blank node label for expanded BGP triples.
*/
public TermAst newAnonymousBlankNode() {
return iri("_:b" + anonymousBlankNodeCounter++);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use fr.inria.corese.core.next.data.impl.io.common.IOConstants#BLANK_NODE_PREFIX in case we want to config it later

@github-actions

Copy link
Copy Markdown
Overall Project 49.2% -0.05% 🍏
Files changed 79.83% 🍏

File Coverage
PathAst.java 100% 🍏
PredicatePathAst.java 100% 🍏
TriplePatternAst.java 100% 🍏
NegatedPropertySetPathAst.java 96.55% -3.45% 🍏
AbstractAstVisitor.java 91.3% 🍏
AlternativePathAst.java 86.11% -13.89% 🍏
SequencePathAst.java 86.11% -13.89% 🍏
SparqlAstBuilder.java 81.69% -4.56% 🍏
OneOrMorePathAst.java 79.17% -20.83% 🍏
OptionalPathAst.java 79.17% -20.83% 🍏
InversePathAst.java 79.17% -20.83% 🍏
ZeroOrMorePathAst.java 79.17% -20.83% 🍏
SparqlQueryAstBuilder.java 78.87% 🍏
VariableScopeAnalyzer.java 76.73% 🍏
BgpFeature.java 57.35% -1.47% 🍏

@github-actions

Copy link
Copy Markdown

Test Results

  420 files    420 suites   22s ⏱️
2 355 tests 2 355 ✅ 0 💤 0 ❌
2 369 runs  2 369 ✅ 0 💤 0 ❌

Results for commit 523b180.

@remiceres remiceres left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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());
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Refactoring Issue created during the 2025 refactoring effort

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[SPARQL 1.1] - Parser and AST : Property Path

3 participants