Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nimbleparse:Suggestions for outputting information #448

Open
liluyue opened this issue May 8, 2024 · 5 comments
Open

nimbleparse:Suggestions for outputting information #448

liluyue opened this issue May 8, 2024 · 5 comments

Comments

@liluyue
Copy link

liluyue commented May 8, 2024

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"]
}
@ratmice
Copy link
Collaborator

ratmice commented May 8, 2024

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.

@liluyue
Copy link
Author

liluyue commented May 8, 2024

I got the nimbleparse_lsp, should put it in the document, otherwise it's difficult to realize its existence

@ltratt
Copy link
Member

ltratt commented May 8, 2024

I like the idea of having a "grammar -> " tool. I vaguely envisaged nimbleparse as something very simple, but I guess it could grow things like dot output without imposing any complexity on other cases? If so, I'd be all for it!

@ratmice
Copy link
Collaborator

ratmice commented May 8, 2024

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.

@ltratt
Copy link
Member

ltratt commented May 9, 2024

Perhaps lrpar should gain a binary lrpar (as lrlex has a binary called lrlex) that does this? Or maybe even cfgrammar?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants