*s1++ = '"', *s1 = 0;
}
+static void anonname(char* buf)
+{
+ static int anon_id = 0;
+
+ sprintf(buf,"_anonymous_%d",anon_id++);
+}
+
void D2Lbegin (char *name) {
+ char buf[BUFSIZ];
newgid = neweid = newnid = 0;
attrclass = GRAPH;
gmark = Mpushmark ((gstack->g = Ttable (12)));
Tinss (gstack->g, "type", Tstring (gtype));
+ if (!name) {
+ anonname(buf);
+ name = buf;
+ }
Tinss (gstack->g, "name", Tstring (name));
/* the dictionaries */
%token <i> T_node T_edge T_edgeop
%token <s> T_id
%type <o> node_name node_id subg_stmt
+%type <s> optgraphname
%left <i> T_subgraph /* to eliminate subgraph hdr shift/reduce conflict */
%left '{'
%%
-file: graph_type T_id
+file: graph_type optgraphname
{ D2Lbegin ($2); free ($2); }
'{' stmt_list '}'
{ D2Lend (); }
{ D2Labort (); }
;
+optgraphname: T_id {$$=$1;} | /* empty */ {$$=0;} ;
+
graph_type: T_graph /* safe to change graph type/name before contents appear */
{ gtype = "graph"; etype = "--"; }
| T_strict T_graph