Skip to content

Feature/335 property path parser and ast - #463

Merged
abdessamad-abdoun merged 13 commits into
feature/corese-nextfrom
feature/335-property-path-parser-and-ast
Jul 15, 2026
Merged

Feature/335 property path parser and ast#463
abdessamad-abdoun merged 13 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
@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

github-actions Bot commented Jun 22, 2026

Copy link
Copy Markdown

Test Results

  433 files    433 suites   20s ⏱️
2 480 tests 2 480 ✅ 0 💤 0 ❌
2 494 runs  2 494 ✅ 0 💤 0 ❌

Results for commit 407fae3.

♻️ This comment has been updated with latest results.

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

@prbblrypier
prbblrypier force-pushed the feature/335-property-path-parser-and-ast branch from 523b180 to cb281a5 Compare July 8, 2026 14:23
prbblrypier and others added 11 commits July 8, 2026 16:46
…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>
…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>
@prbblrypier
prbblrypier force-pushed the feature/335-property-path-parser-and-ast branch from cb281a5 to e1a7107 Compare July 8, 2026 14:51
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Overall Project 50.36% -0.07% 🍏
Files changed 72.71% 🍏

File Coverage
PredicatePathAst.java 100% 🍏
AbstractAstVisitor.java 100% 🍏
TriplePatternAst.java 100% 🍏
NegatedPropertySetPathAst.java 96.15% -3.85% 🍏
CoreseAstQueryBuilder.java 90.14% -0.88% 🍏
WhereCompiler.java 85.05% 🍏
AlternativePathAst.java 83.33% -16.67% 🍏
SequencePathAst.java 83.33% -16.67% 🍏
SparqlAstBuilder.java 80.62% -5.83% 🍏
SparqlQueryAstBuilder.java 78.87% 🍏
VariableScopeAnalyzer.java 76.73% 🍏
OneOrMorePathAst.java 76.19% -23.81% 🍏
OptionalPathAst.java 76.19% -23.81% 🍏
InversePathAst.java 76.19% -23.81% 🍏
ZeroOrMorePathAst.java 76.19% -23.81% 🍏
BgpFeature.java 41.18% -16.91%
PathAst.java 0%

@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Overall Project 50.42% -0.06% 🍏
Files changed 78.78% 🍏

File Coverage
PredicatePathAst.java 100% 🍏
AbstractAstVisitor.java 100% 🍏
TriplePatternAst.java 100% 🍏
NegatedPropertySetPathAst.java 96.15% -3.85% 🍏
SparqlQueryAnalyzer.java 94.39% -1.87% 🍏
CoreseAstQueryBuilder.java 90.14% -0.88% 🍏
WhereCompiler.java 85.05% 🍏
AlternativePathAst.java 83.33% -16.67% 🍏
SequencePathAst.java 83.33% -16.67% 🍏
SparqlAstBuilder.java 81.89% -4.67% 🍏
SparqlQueryAstBuilder.java 78.87% 🍏
VariableScopeAnalyzer.java 76.73% 🍏
OneOrMorePathAst.java 76.19% -23.81% 🍏
OptionalPathAst.java 76.19% -23.81% 🍏
InversePathAst.java 76.19% -23.81% 🍏
ZeroOrMorePathAst.java 76.19% -23.81% 🍏
BgpFeature.java 41.18% -16.91%
PathAst.java 0%

@remiceres
remiceres self-requested a review July 9, 2026 15:32
@remiceres

Copy link
Copy Markdown
Contributor

Strengthened SPARQL property path parser/AST tests (precedence, inverse paths, negated sets) and updated NegatedPropertySetPathAst to reject nulls.

@github-actions

Copy link
Copy Markdown
Overall Project 50.46% -0.06% 🍏
Files changed 80.63% 🍏

File Coverage
PredicatePathAst.java 100% 🍏
AbstractAstVisitor.java 100% 🍏
TriplePatternAst.java 100% 🍏
WhereCompiler.java 97.51% 🍏
SparqlQueryAnalyzer.java 94.39% -1.87% 🍏
NegatedPropertySetPathAst.java 94.12% -5.88% 🍏
CoreseAstQueryBuilder.java 90.41% -0.85% 🍏
AlternativePathAst.java 83.33% -16.67% 🍏
SequencePathAst.java 83.33% -16.67% 🍏
SparqlAstBuilder.java 82.5% -4.05% 🍏
SparqlQueryAstBuilder.java 78.87% 🍏
VariableScopeAnalyzer.java 76.73% 🍏
OneOrMorePathAst.java 76.19% -23.81% 🍏
OptionalPathAst.java 76.19% -23.81% 🍏
InversePathAst.java 76.19% -23.81% 🍏
ZeroOrMorePathAst.java 76.19% -23.81% 🍏
BgpFeature.java 41.18% -16.91%
PathAst.java 0%

@abdessamad-abdoun
abdessamad-abdoun merged commit 16e214e into feature/corese-next Jul 15, 2026
2 checks passed
@remiceres
remiceres deleted the feature/335-property-path-parser-and-ast branch August 26, 2026 13:30
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

4 participants