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

Parser fails if .dot file has comments #250

Open
Podbrushkin opened this issue Aug 15, 2023 · 0 comments
Open

Parser fails if .dot file has comments #250

Podbrushkin opened this issue Aug 15, 2023 · 0 comments

Comments

@Podbrushkin
Copy link

If .dot file contains commented-out lines with #, it cannot be parsed, exception is being thrown:

guru.nidi.graphviz.parse.ParserException: Found unexpected character '#'
    at guru.nidi.graphviz.parse.Lexer.ident (Lexer.java:121)
    at guru.nidi.graphviz.parse.Lexer.numeralOrIdent (Lexer.java:98)
    at guru.nidi.graphviz.parse.Lexer.token (Lexer.java:55)
    at guru.nidi.graphviz.parse.ParserImpl.nextToken (ParserImpl.java:310)
    at guru.nidi.graphviz.parse.ParserImpl.assertToken (ParserImpl.java:321)
    at guru.nidi.graphviz.parse.ParserImpl.statementList (ParserImpl.java:77)
    at guru.nidi.graphviz.parse.ParserImpl.lambda$parse$0 (ParserImpl.java:66)
    at guru.nidi.graphviz.model.ThrowingFunction.applyNotThrowing (ThrowingFunction.java:24)
    at guru.nidi.graphviz.model.CreationContext.use (CreationContext.java:44)
    at guru.nidi.graphviz.model.CreationContext.use (CreationContext.java:38)
    at guru.nidi.graphviz.parse.ParserImpl.parse (ParserImpl.java:50)
    at guru.nidi.graphviz.parse.Parser.read (Parser.java:81)
    at guru.nidi.graphviz.parse.Parser.read (Parser.java:76)
    at myapp.GraphvizProcessor.parseDot (GraphvizProcessor.java:52)
    at myapp.GraphvizProcessor.main (GraphvizProcessor.java:43)
    at org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:279)
    at java.lang.Thread.run (Thread.java:1589)

Single-line comments # and block comments /* blabla */ are legal syntax of .dot files. I think library shouldn't fail when they are presented in provided file.

This is how I've used it:

private void parseDot(String dot, File dotDir) {
        try {
            // Graphviz.useEngine(new GraphvizCmdLineEngine());
            Graphviz.useEngine(new GraphvizV8Engine(), new GraphvizJdkEngine());
            MutableGraph g;
            g = new Parser().read(dot);
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

1 participant