Reading EBNF grammars is not easy. Seeing it on a diagram makes things easier. https://rr.red-dove.com/ui is an excellent tool: it can scrape EBNF grammars from W3C specs, generates either a single XHTML with embedded SVG, or a zip with many PNGs, cross-links the definitions and usages.
- INCOMPLETE: ./ebnf2tdv.pl: convert ebnf to a list of node-node connections, for visualizing eg with d3
I use this quite often while writing SPARQL. It is bit hard to understand: use this for reference, but not for learning SPARQL.
SPARQL 1.1 is the current version of SPARQL.
- sparql11-grammar.xhtml: Cross-linked diagrams, one per production (173 total).
- sparql11-grammar.ebnf: EBNF rules extracted from the spec
- sparql11-grammar.txt: same thing but with production numbers
- extracted from: http://www.w3.org/TR/sparql11-query/
- version: http://www.w3.org/TR/2013/REC-sparql11-query-20130321/
- created on: Apr 2, 2013
Preview:
SPARQL 1.2 is the long-awaited update of SPARQL with SPARQL-star (reified triples and annotations). It’s still a work in progress.
- sparql12-grammar.xhtml: Cross-linked diagrams, one per production (190 total).
- sparql12-grammar.ebnf: EBNF rules extracted from the spec
- sparql12-grammar.txt: same thing but with production numbers
- extracted from: https://www.w3.org/TR/sparql12-query/
- version: https://www.w3.org/TR/2024/WD-sparql12-query-20240921/
- created on: Oct 9, 2024
Preview:
This is an older incarnation of SPARQL-star. You can ignore it.
- sparql-star-grammar.xhtml: Cross-linked diagrams, one per production (173 total).
- sparql-star-grammar.ebnf: EBNF rules extracted from the spec
- sparql-star-grammar.txt: same thing but with production numbers
- extracted from: https://www.w3.org/2021/12/rdf-star.html#sparql-star-ebnf
- version: 2021-12-17
Preview:
Here’s a chunked diagram, which however is partial: Discussion whether there’s a chunked generator. Preview:
SHACL Compact grammar
- shaclc-grammar.xhtml: Cross-linked diagrams, one per production (73 total)
- shaclc-grammar.ebnf: EBNF rules converted from the original ANTRL grammar
- Extracted from: https://w3c.github.io/shacl/shacl-compact-syntax/
Preview:
IMPORTANT: The SHACL CG is currently working on extending the SHACLC grammar with more features. You can see diagrams for 4 candidate grammars at https://github.com/VladimirAlexiev/shacl/tree/shaclc-grammars/shacl-compact-syntax/grammar#candidate-shacl-c-grammars
XSPARQL is a melding of XQuery and SPARQL. Its syntax is pretty large, so the diagrams help. https://github.com/VladimirAlexiev/xsparql/blob/master/doc/:
- grammar.xhtml: grammar diagram (XHTML+SVG, 950Kb)
- grammar-nonterminals.xhtml: non-terminal symbols only (800Kb)
- grammar.html: original grammar, shows additions with bold and deletions with strikethrough
- grammar.ebnf: EBNF (text) extracted from above, renamed eg TriplesSameSubject’ to TriplesSameSubject1 because the tool cannot handle ’ as identifier char
- grammar-nonterminals.ebnf: non-terminal symbols only
Preview: