Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .changeset/sparql-1-2-syntax.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
"@matdata/yasqe": minor
---

Support SPARQL 1.2 syntax in the query editor, following the grammar of the [SPARQL 1.2 Query Language](https://www.w3.org/TR/sparql12-query/#sparqlGrammar) Working Draft of 21 September 2026. SPARQL 1.2 queries are now highlighted and syntax checked, including:

- the `VERSION` declaration
- triple terms `<<( :s :p :o )>>` in triple patterns, `VALUES` and expressions
- reified triples `<< :s :p :o ~ :reifier >>`, reifiers (`~`) and annotation blocks `{| ... |}`. Reifiers and annotations after a property path that is not a simple predicate are reported as errors.
- language tags with a base direction, such as `"hello"@en--ltr`
- the new functions `LANGDIR`, `STRLANGDIR`, `hasLANG`, `hasLANGDIR`, `isTRIPLE`, `TRIPLE`, `SUBJECT`, `PREDICATE` and `OBJECT`
- `!` applied to any unary expression, and aggregates wherever a built-in call is allowed

A blank node property list followed by a property path (`[ :p ?o ] :a/:b ?c`) is no longer reported as a syntax error.

Known incompatibility: a `<` comparison written without a space before a full IRI, such as `FILTER(?o<<http://example.org/a>)`, is now reported as a syntax error. SPARQL 1.2 reads `<<` as a single token (the longest match wins), so a SPARQL 1.2 parser rejects this query as well. Add a space to fix it: `FILTER(?o < <http://example.org/a>)`.
10 changes: 7 additions & 3 deletions packages/yasqe/grammar/README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
# Yet Another SPARQL Query Editor (YASQE) grammar

The grammar covers SPARQL 1.1 and SPARQL 1.2 (queries and updates).

## Prerequisites

- SWI Prolog
- SWI Prolog (`swipl` on the `PATH`)

## How to make modifications to grammar:

- Change the Extended Backus-Naur Form (EBNF) grammar in file
`sparql11-grammar.pl`. Do not change file `_tokenizer-table.js`.
- Run `./build.sh`.
`sparql-grammar.pl`. Do not change file `_tokenizer-table.js`.
- Run `./build.sh`. It regenerates `_tokenizer-table.js` and formats it with prettier.
Check its output for `LL(1) clash` messages: the grammar must stay LL(1).
- Finally, rebuild YASQE from the YASQE home directory by running `npm run build` (or `npm run dev` to test it locally).
- The grammar is tested by `test/unit/yasqe-sparql12-grammar-test.ts` (`npm run unit-test`).
Loading
Loading