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

dot_parse don't support brackets #4

Open
GoogleCodeExporter opened this issue Apr 13, 2015 · 6 comments
Open

dot_parse don't support brackets #4

GoogleCodeExporter opened this issue Apr 13, 2015 · 6 comments

Comments

@GoogleCodeExporter
Copy link

GoogleCodeExporter commented Apr 13, 2015

This graph is parsed OK:

a -> b
a -> c

But this shortening don't work:

a -> {b, c}

Original issue reported on code.google.com by Paul.Colomiets@gmail.com on 14 Jan 2008 at 4:11

@GoogleCodeExporter
Copy link
Author

GoogleCodeExporter commented Apr 13, 2015

It will parse it ( in the latest tests it already does )

PS: The code is shaping up. It's taking forever to release the updated pydot
because I embarked on rewriting pydot's core aiming at increasing performance and supporting some advanced constructs/expressions that weren't supported before. And that took a bit of thinking plus extensive regression tests. It will eventually see the light of day.

Original comment by ero.carr...@gmail.com on 21 Jan 2008 at 1:59

@GoogleCodeExporter
Copy link
Author

GoogleCodeExporter commented Apr 13, 2015

Sorry it's my mistake, it parses comma not in same way as graphviz. But seems
that specification doesn't allow comma here. So following works:

a -> {b c}
a -> {b; c}

Sorry for the noise.

Original comment by Paul.Colomiets@gmail.com on 22 Jan 2008 at 6:48

@GoogleCodeExporter
Copy link
Author

GoogleCodeExporter commented Apr 13, 2015

Well, I'm here again :)

There are problems with parsing other way around:

{b; c} -> a

Error is:

TypeError: unsupported operand type(s) for +: 'Subgraph' and 'str'

BTW, I've not found any unittests here. Is this something you do in private
repository? I'd like to help with tests and maybe some code (although I'm not
familiar with pyparsing yet).

Original comment by Paul.Colomiets@gmail.com on 28 Jan 2008 at 7:39

@GoogleCodeExporter
Copy link
Author

GoogleCodeExporter commented Apr 13, 2015

Same with:

a -> b -> {c; d}

Original comment by Paul.Colomiets@gmail.com on 28 Jan 2008 at 7:50

@GoogleCodeExporter
Copy link
Author

GoogleCodeExporter commented Apr 13, 2015

All of those cases should be fixed in the ucoming 1.0.2. I've given the parsing code a good update.

Regarding the unittests, I've put some together for this latest version. I don't think I'll include them in the main release (loads of .dot files) but let me know if you want them.

Original comment by ero.carr...@gmail.com on 14 Feb 2008 at 10:06

  • Changed state: fixed

@peternowee
Copy link
Member

Of all the examples given in this thread, the only one I am still seeing a problem with is this one:

digraph G{
    a -> b -> {c; d}
}

Expected result, as when loaded directly by Graphviz:
mre81_pncp037_pydot-pydot-4 dot pdt-before-fix-gv

Actual result when first parsed by pydot, then sent to Graphviz:
mre81_pncp037_pydot-pydot-4 dot pdt-before-fix-pd-gv

The pydot parser only returns a -> b:

> dot_parser.py(548)parse_dot_data()
-> tokens = graphparser.parseString(s)
(Pdb) n
> dot_parser.py(549)parse_dot_data()
-> return list(tokens)
(Pdb) pp tokens
([<pydot.Dot object at 0x7f5b49cfaf98>], {})
(Pdb) pp tokens[0].obj_dict
{'attributes': {},
 'current_child_sequence': 2,
 'edges': {('a', 'b'): [{'attributes': {},
                         'parent_edge_list': None,
                         'parent_graph': <pydot.Dot object at 0x7f5b49cfaf98>,
                         'points': ('a', 'b'),
                         'sequence': 1,
                         'type': 'edge'}]},
 'name': 'G',
 'nodes': {},
 'parent_graph': <pydot.Dot object at 0x7f5b49cfaf98>,
 'simplify': False,
 'strict': False,
 'subgraphs': {},
 'suppress_disconnected': False,
 'type': 'digraph'}

However, a graph with a -> b -> c gets correctly parsed as a -> b; b -> c;. And a graph with a -> {b; c} also gets correctly parsed as a -> subgraph { b; c; } as well. It is just the mix of these two that does not work.

It is not easy to debug the parsing by stepping through the code. Instead, PyParsing has some special debugging functions. I do not know when I will get around to that, so anyone else feel free to pick this up.

Versions: pydot 1.4.1, pyparsing 2.4.7, python 3.7.3.

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

No branches or pull requests

3 participants