Skip to content

add(feature): RDF1.2/SPARQL1.2 TripleTerm.#151

Open
lsvih wants to merge 3 commits into
pkumod:1.4from
lsvih:1.4
Open

add(feature): RDF1.2/SPARQL1.2 TripleTerm.#151
lsvih wants to merge 3 commits into
pkumod:1.4from
lsvih:1.4

Conversation

@lsvih

@lsvih lsvih commented Jun 26, 2026

Copy link
Copy Markdown
Member

No description provided.

@lsvih

lsvih commented Jun 26, 2026

Copy link
Copy Markdown
Member Author

Performance Impact:​ For workloads that do not involve tripleterms, there is theoretically virtually no impact.

Ongoing Effort:​ The SPARQL parser is currently handwritten in C++. I am currently attempting to refactor the parser using ANTLR4 grammar.

Comment thread src/Parser/SPARQL/SPARQL.g4 Outdated
var : VAR1 | VAR2 ;
graphTerm : iri | rDFLiteral | numericLiteral | booleanLiteral | blankNode | NIL ;
graphTerm : iri | rDFLiteral | numericLiteral | booleanLiteral | blankNode | NIL | tripleTerm ;
tripleTerm : TRIPLE_TERM_OPEN varOrTerm verb objectList TRIPLE_TERM_CLOSE ;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[Question] Does this incorporate the case with <<( ... )>> ? (e.g., when using BIND or querying with the rdf:reifies predicate)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Resolved in the latest commit

@param query the original query string.
@return the preprocessed query string with triple terms replaced by placeholders.
*/
std::string QueryParser::preprocessTripleTerms(const std::string &query)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[Question] Recalling the question in SPARQL.g4, is it possible to catch both cases (with and without parentheses) in the grammar so no manual parsing here is needed?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The problem is semantic, identical <<(...)>> needs different treatment depending on context:

  1. decomposition when it's a subject
  2. literal value when it's the object of rdf:reifies.

ANTLR grammar has no way to know which context it's in. That is why the preprocessor + addTriple split exists.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants