Towards tackling SPARQL heterogeneity through modular parsing

Jitse De Smet

Ruben Taelman

SEMANTiCS 2025 Developers Workshop supporting slides for our software talk, 03 September 2025

Towards tackling SPARQL heterogeneity through modular parsing

Ghent University โ€“ imec โ€“ IDLab, Belgium

Research Foundation - Flanders

© car: Richard Bronosky

Overview

Need for parser modularity

Lexer and Parser using Chevrotain

  1. Lexical Analysis (scanning): transform character stream into token stream.
  2. Syntax Analysis (parsing): transform token stream into abstract syntax tree.
  3. Semantic Analysis: validate constraints not enforced by grammar alone.
Chevrotain is a fast parser builder for TypeScript - not yet modular.

Constructing a simple lexer builder

© refactoring.guru

Define each grammar rule as an object

© refactoring.guru

Construct parser builder

© refactoring.guru

Interoperability & Reuse

We avoid big monolith using modular packaging
๐Ÿ†“ Using MIT software license
๐Ÿ“‘ Commit to documentation and issue tracking

Demo

  1. Add ADJUST
  2. Add Construct Quad
  3. Add full text search
  4. Drop complex optional
๐Ÿคน

Adjust

Builtin Adjust Query


SELECT ?s ?p (ADJUST(
    ?o,
    "-PT10H"^^<http://www.w3.org/2001/XMLSchema#dayTimeDuration>
) as ?adjusted) WHERE {
  ?s ?p ?o
}

Construct Quad

Construct Quad Query

CONSTRUCT WHERE { GRAPH <wow> { ?s ?p ?o } }

Text Search

Text Search Query

SELECT * WHERE {
  ?s ?p ?o OPTION (score ?sc)
}
DOCS(32) do not seem right as they do not enable the score example. I therefore tried to mimic it using my own interpretation.
SELECT * WHERE {
  ?s ?p ?o OPTION (score ?sc)
}

No Optional

Additional

Complete SPARQL flow

Future Work

© 2025 Jitse De Smet Creative Commons Attribution 4.0, unless otherwise indicated.

Source