mermaid
mermaid copied to clipboard
[Feature request] New kind of graphic: production rules for grammars
Request
Add a new kind of graphic to mermaid-js: a graphical representation of production rules for syntax grammars
Motivation
Grammars are used in some IT projects and proper documentation is a must.
Suggested output
Take a look at the graphical representation of the production rules of SQLite, for example: https://sqlite.org/lang_select.html
See also: https://en.wikipedia.org/wiki/Syntax_diagram
Syntax diagrams (or railroad diagrams) are a way to represent a context-free grammar. They represent a graphical alternative to Backus–Naur form, EBNF, Augmented Backus–Naur form, and other text-based grammars as metalanguages.
I use nearley.js as a parser generator, it can generate proper railroad diagarm, I think it is a good reference https://nearley.js.org/docs/tooling#nearley-railroad-automagical-railroad-diagrams .
Also it would be great if we can parse valid .ebnf
file rather than '.ne' file, for the former one is more general, not bound to one specific implementation.
An interesting project I found today https://github.com/jamespwilliams/ebnf-shipping-forecast
Support for EBNF would be epic, especially in a place like GitHub (GitHub supports Mermaid). Imagine if repos on GitHub had railroads in their documentation for language grammars etc.
Btw, the title could be more clear, like "Support for EBNF Grammar Production Rules"
Since there's a going discussion in #4252 proposing the same thing, I'll close this as duplicate.