grmtools
grmtools copied to clipboard
nimbleparse:Suggestions for outputting information
The nimbleparse outputting info format maybe add "dot" format for Display in the form of a graph using graphviz
For example:
digraph table{
label = "Stategraph"
node[shape="box"]
0[label=" 0\n ^ -> . Expr"]
1[label="1\nTerm -> Term . '/' Factor"]
2[label="2\nFactor -> '(' . Expr ')'"]
0 -> 1 [label="Term",decorate=false]
0 -> 2 [label = "(",decorate =false]
2 -> 1 [label="Term"]
}
This is something i've been curious about doing, but hasn't been a priority for me.
Somewhat related, nimbleparse_lsp can generate railroad diagrams, and display them within vscode, but there isn't any utility for writing that output to a file. It generates svg directly (using the railroad crate) rather than relying on an external tool like "dot" to avoid invoking binaries from within the editor, or bringing in the entire libgraphviz image generation stack, that code entails an additional dependency somewhere. railroad diagram generation code.
In theory we wouldn't need the additional dependency if we're just generating "dot" formatted text output though. But if it is something Laurence does want to include i'd be happy to put some effort towards it.
I got the nimbleparse_lsp, should put it in the document, otherwise it's difficult to realize its existence
I like the idea of having a "grammar ->
For railroad diagrams, it would basically be just option parsing affecting the main program, with an additional function where the added complexity can be isolated within it. I don't think dot support would differ from that.
I don't think it is certain that nimbleparse is the right tool/place for this feature though. The primary thing is nimbleparse requires input text, and a lex file, I'm uncertain if the lex file is absolutely necessary (it could perhaps be used to display regex beyond just symbols).
But for outputting diagrams actual input text seems like it should be entirely ignored/superfluous.
I would think that a tool for outputting grammar diagrams could get away with taking an output format, a yacc file + yacc format, perhaps even making the lex file optional, if it wants to include regex in some fashion.
So I do think there is a little bit of command line option awkwardness here.
Perhaps lrpar should gain a binary lrpar
(as lrlex
has a binary called lrlex
) that does this? Or maybe even cfgrammar?