5 ms·
For those that want to explore the grammars listed at https://github.com/tree-sitter/tree-sitter/wiki/List-of-parsers https://github.com/tree-sitter/tree-sitter
by mingodad 2y ago
For those that want to explore the grammars listed at https://github.com/tree-sitter/tree-sitter/wiki/List-of-parsers https://github.com/tree-sitter/tree-sitter/wiki/List-of-pars... in a more friendly railroad diagram format I made https://mingodad.github.io/plgh/json2ebnf.html https://mingodad.github.io/plgh/json2ebnf.html that reads the "src/grammar.json" and try it's best to generate an EBNF understood by (IPV6) https://www.bottlecaps.de/rr/ui https://www.bottlecaps.de/rr/ui or (IPV4) https://rr.red-dove.com/ui https://rr.red-dove.com/ui where we get a nice navigable railroad diagram (see https://github.com/GuntherRademacher/rr https://github.com/GuntherRademacher/rr for offline usage).
- yaantc 2y agoHi, in case you're not already aware of the name clash, there's already a `rr` in the programming world. It's "record and replay": https://rr-project.org/ https://rr-project.org/. Very different, but a very fine tool tool too.
- rafram 2y agoIt doesn’t seem like the rr that GP linked to is their own project, just something they’ve found useful. In any case, in the non-software world, “RR” stands for railroad, as it does in the name of that tool. You can’t own a common two-letter abbreviation.
- PROMISE_237 2y ago[dead]
- mickeyp 2y agoImpressive! The grammar.json file is just a little bit too underspecced to automate some things. Not to mention it's self-referential. How did you deal with extras and other 'specialisms' that are secretly hidden away in the C-level scanner and so on? I ask because I wrote Combobulate [1], a structured editing and movement tool for Emacs using TS. 1: https://github.com/mickeynp/combobulate https://github.com/mickeynp/combobulate
- mingodad 2y agoI simple ignore then as right now they doesn't seen relevant in most grammars to generate an usable railroad diagram.
- mingodad 2y agoAlso there was several requests to create a more formal grammar to describe the grammars but the tree-sitter developers doesn't like the idea and reject then. But some people did nice attempts like https://github.com/eatkins/tree-sitter-ebnf-generator https://github.com/eatkins/tree-sitter-ebnf-generator that I also adapted and exposed it here https://mingodad.github.io/lua-wasm-playground/ https://mingodad.github.io/lua-wasm-playground/ to allow play with it online (select "Tree-sitter-ebnf-generator" from examples then click "Run" to see a "grammar.js" generated from the content in "Input Text (arg[1])").
- mingodad 2y agoI've added more non trivial grammars Javascript, Java, Kotlin, PHP, C, CPP, Rust, Ruby, CSS, HTML, Python using a quickjs script to convert "src/grammar.json" to an EBNF understood by https://mingodad.github.io/lua-wasm-playground/ https://mingodad.github.io/lua-wasm-playground/ (the script is here https://github.com/mingodad/plgh/blob/main/json2ebnf-lua.js https://github.com/mingodad/plgh/blob/main/json2ebnf-lua.js).
- lukan 2y agoAwesome! Just yesterday I started some experiments in that direction, to visualize grammars, but now I can rather do something else ..