mermaid icon indicating copy to clipboard operation
mermaid copied to clipboard

[Feature request] New kind of graphic: production rules for grammars

Open afpineda opened this issue 3 years ago • 3 comments

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

afpineda avatar Jun 21 '21 15:06 afpineda

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.

xpe avatar Jul 12 '21 14:07 xpe

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

hikerpig avatar Feb 07 '22 05:02 hikerpig

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"

depascalis avatar Aug 11 '22 18:08 depascalis

Since there's a going discussion in #4252 proposing the same thing, I'll close this as duplicate.

Yokozuna59 avatar Jul 04 '23 16:07 Yokozuna59