kach / nearley

📜🔜🌲 Simple, fast, powerful parser toolkit for JavaScript.
https://nearley.js.org
MIT License
3.6k stars 232 forks source link

nearley-railroad feature request #530

Closed Floffah closed 4 years ago

Floffah commented 4 years ago

I would like there to be a -r or --recursive option so it will follow any includes and variables used from them to show a more in depth documentation with sections and a contents bit at the top.

If there is a way to output nearley grammar to json without compiling it to a js file i could write a library to do this

kach commented 4 years ago

@Floffah You should be able to write this library! The JS that nearley compiles to is just a small module that I think exposes all the information you need. Even better, feel free to modify nearley-railroad directly and send a PR — I'll merge it and then your changes will be built in for all nearley users. Railroad is one of my favorite features but not really used as much as I wish… :)

Floffah commented 4 years ago

I might even make a way to use templates like JSDoc. This is so cool and I am writing a large language and would definitely need this. I will start writing this!

Floffah commented 4 years ago

Do you possibly have a Discord where i could ask you questions?

And for anyone reading this, I can't get npm to install and build nearley's dependencies on windows or linux so you can find my progress here as a library: https://github.com/Floffah/better-nearley-railroad

However looking back i realise now that the main part of my library (looping function that generates an array of diagrams) is a singular function that only relies on the railroad-diagrams library and could be easily implemented somehow and from testing only takes less than 2 seconds to generate. I may start doing that once i iron out all of the bugs and make it recognize any type of compiled nearley grammar (but wont be able to test a merged version because i cant for the life of me get nearley dependencies to install)

kach commented 4 years ago

Unfortunately, I don't currently have the bandwidth to give on-line support, and it's been long enough that I won't really be that good of a resource anyway. But railroad.js should be pretty clear and self-explanatory.

Also, please keep in mind that I am much likelier to merge a small focused set of changes to railroad.js than a large full-scale project, especially one which introduces even more dependencies. That's not to discourage you from pursuing a large full-scale project (I'd be pleased to link to it from the documentation and all), but to help you decide ahead of time how you want to structure the project, depending on your goals.

Floffah commented 4 years ago

yea my library only introduces one new dependency (mustache, to generate a page based on a template) but i feel it would be easier to be its own library anyway because its turned into something that is a bit more complicated and not for someone who is just using it to test so no need to merge imo

kach commented 4 years ago

You may also be interested in #218 which I have personally been hoping someone will implement in a mergeable way!