In the dot format one can specify global graph data without wrapping it in a graph scope. Id like to be able to write:
graph { A -> subgraph { B C }
foo=bar
}
graph { A -> subgraph { B C }
graph[
foo=bar
]
}
In the dot format one can specify global graph data without wrapping it in a graph scope. Id like to be able to write:
graph { A -> subgraph { B C }
foo=bar
}
graph { A -> subgraph { B C }
graph[
foo=bar
]
}
Both are valid dot string and both are accepted by the parser. However, there is slight difference between both of them. In the first one, the foo=bar part is an ID '=' ID statement (a stmt in dot grammar), while in the second, the graph[foo=bar] part is an attribute statement (an attr_stmt in the grammar).
You can check both ASTs with the following:
usedot_parser::*;fn main(){letgraph_1=ast::Graph::try_from("graph { foo=bar }").unwrap();letgraph_2=ast::Graph::try_from("graph { graph[foo=bar] }").unwrap();println!("{:#?}",graph_1);println!("{:#?}",graph_2);}which outputs
Graph {
strict: false,
is_digraph: false,
name: None,
stmts: StmtList {
stmts: [
IDEq(
"foo",
"bar",
),
],
},
}
Graph {
strict: false,
is_digraph: false,
name: None,
stmts: StmtList {
stmts: [
AttrStmt(
Graph(
AttrList {
elems: [
AList {
elems: [
(
"foo",
"bar",
),
],
},
],
},
),
),
],
},
}
Note that, in canonical representation of graphs, the first one puts the equality in the ideqs field of the graph, while the second puts it in the attr field.
I see! Thanks for the explanation. Now on 0.6.0, I get an error parsing this graph:
dot_parser::ast::Graphs::try_from(r#"digraph{
edge [overall_factor=1]
A
}
"#).unwrap()however if it is a bare stmt:
dot_parser::ast::Graphs::try_from(r#"digraph{
overall_factor = 1
A
}
"#).unwrap()It does work. The error is
The Pair:
1
terminates early. Expected one of "ident1", "numeral", "quote", "html".
But 1 is a numeral. So this should be fine..
Hi,
sorry I though I would have time to tackle that today, but I was extra-busy. I'll see if I can deal with it this week.
The above commit should fix the issue. Could you confirm it works on your side before I push an updated version on crates.io ?
(And sorry for the delay)
It works on my side! Thanks for the update!
No due date set.
No dependencies set.
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?