I would like to find a tool that auto-generates syntax diagrams from a bison source file. Does anyone know of such a tool? This is a similar post but the answer left me with too many questions:
https://stackoverflow.com/questions/3141317/creating-diagram-of-grammar-bison
There is this tool: https://www.bottlecaps.de/rr/ui but it requires EBNF. To be fair, EBNF makes the grammar much clearer, since it allows the direct representations of sequences of items which would have to be inferred from a bison source file. I believe there are tools which will attempt to do this inference, too.
There's also this tool: https://github.com/tabatkins/railroad-diagrams , which requires you to supply what is, in effect, an AST of the grammar (ideally, converted as per the previous one.) This might be a better option, since you can easily produce an AST of a bison grammar using, well, bison :) and it should be easy to infer the sequence operators, or even to mark them.
There are probably other tools floating around as well, but I suspect they will all have similar issues. The two tools I listed at least look nice (imo) for grammars of a normal size. You can find more links on Wikipedia.
By the way, I suppose you know that recent bison version will produce DOT
files describing the parsing states? (Use the -g
option.) Those are of very little use for documenting grammars, and you need a lot of space if your grammar is anything approaching complicated, but they can also provide some useful information about the grammar.