Reading EBNF grammars is not easy. Seeing it on a diagram makes things easier. http://bottlecaps.de/rr/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. A bit hard to understand: use this for reference, but not for learning 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: Tue Apr 2, 2013, 08:59 (UTC+03)
Preview:
Here’s a chunked diagram, which however is partial: Discussion whether there’s a chunked generator. Preview:
- 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:
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:
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: