wolffd@0
|
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
|
wolffd@0
|
2 <!--
|
wolffd@0
|
3 This is a generated document. Do not edit.
|
wolffd@0
|
4 -->
|
wolffd@0
|
5 <HTML VERSION="2.0">
|
wolffd@0
|
6 <HEAD>
|
wolffd@0
|
7 <TITLE>The DOT Language</TITLE>
|
wolffd@0
|
8 </HEAD>
|
wolffd@0
|
9 <BODY BGCOLOR=white>
|
wolffd@0
|
10 <A NAME="top"></A>
|
wolffd@0
|
11 <H1 ALIGN=CENTER>The DOT Language</H1>
|
wolffd@0
|
12 <HR>
|
wolffd@0
|
13 The following is an abstract grammar defining the DOT language.
|
wolffd@0
|
14 Terminals are shown in bold font and nonterminals in italics.
|
wolffd@0
|
15 Literal characters are given in single quotes.
|
wolffd@0
|
16 Parentheses ( and ) indicate grouping when needed.
|
wolffd@0
|
17 Square brackets [ and ] enclose optional items.
|
wolffd@0
|
18 Vertical bars | separate alternatives.
|
wolffd@0
|
19 <TABLE>
|
wolffd@0
|
20 <TR>
|
wolffd@0
|
21 <TD ALIGN=RIGHT><I>graph</I></TD>
|
wolffd@0
|
22 <TD ALIGN=LEFT>:</TD>
|
wolffd@0
|
23 <TD ALIGN=LEFT>[ <B>strict</B> ] (<B>graph</B> | <B>digraph</B>) [ <I>ID</I> ] <B>'{'</B> <I>stmt_list</I> <B>'}'</B></TD>
|
wolffd@0
|
24 </TR>
|
wolffd@0
|
25 <TR>
|
wolffd@0
|
26 <TD ALIGN=RIGHT><I>stmt_list</I></TD>
|
wolffd@0
|
27 <TD ALIGN=LEFT>:</TD>
|
wolffd@0
|
28 <TD ALIGN=LEFT>[ <I>stmt</I> [ <B>';'</B> ] [ <I>stmt_list</I> ] ]</TD>
|
wolffd@0
|
29 </TR>
|
wolffd@0
|
30 <TR>
|
wolffd@0
|
31 <TD ALIGN=RIGHT><I>stmt</I></TD>
|
wolffd@0
|
32 <TD ALIGN=LEFT>:</TD>
|
wolffd@0
|
33 <TD ALIGN=LEFT><I>node_stmt</I></TD>
|
wolffd@0
|
34 </TR>
|
wolffd@0
|
35 <TR>
|
wolffd@0
|
36 <TD ALIGN=RIGHT></TD>
|
wolffd@0
|
37 <TD ALIGN=LEFT>|</TD>
|
wolffd@0
|
38 <TD ALIGN=LEFT><I>edge_stmt</I></TD>
|
wolffd@0
|
39 </TR>
|
wolffd@0
|
40 <TR>
|
wolffd@0
|
41 <TD ALIGN=RIGHT></TD>
|
wolffd@0
|
42 <TD ALIGN=LEFT>|</TD>
|
wolffd@0
|
43 <TD ALIGN=LEFT><I>attr_stmt</I></TD>
|
wolffd@0
|
44 </TR>
|
wolffd@0
|
45 <TR>
|
wolffd@0
|
46 <TD ALIGN=RIGHT></TD>
|
wolffd@0
|
47 <TD ALIGN=LEFT>|</TD>
|
wolffd@0
|
48 <TD ALIGN=LEFT><I>ID</I> <B>'='</B> <I>ID</I></TD>
|
wolffd@0
|
49 </TR>
|
wolffd@0
|
50 <TR>
|
wolffd@0
|
51 <TD ALIGN=RIGHT></TD>
|
wolffd@0
|
52 <TD ALIGN=LEFT>|</TD>
|
wolffd@0
|
53 <TD ALIGN=LEFT><I>subgraph</I></TD>
|
wolffd@0
|
54 </TR>
|
wolffd@0
|
55 <TR>
|
wolffd@0
|
56 <TD ALIGN=RIGHT><I>attr_stmt</I></TD>
|
wolffd@0
|
57 <TD ALIGN=LEFT>:</TD>
|
wolffd@0
|
58 <TD ALIGN=LEFT>(<B>graph</B> | <B>node</B> | <B>edge</B>) <I>attr_list</I></TD>
|
wolffd@0
|
59 </TR>
|
wolffd@0
|
60 <TR>
|
wolffd@0
|
61 <TD ALIGN=RIGHT><I>attr_list</I></TD>
|
wolffd@0
|
62 <TD ALIGN=LEFT>:</TD>
|
wolffd@0
|
63 <TD ALIGN=LEFT><B>'['</B> [ <I>a_list</I> ] <B>']'</B> [ <I>attr_list</I> ]</TD>
|
wolffd@0
|
64 </TR>
|
wolffd@0
|
65 <TR>
|
wolffd@0
|
66 <TD ALIGN=RIGHT><I>a_list</I></TD>
|
wolffd@0
|
67 <TD ALIGN=LEFT>:</TD>
|
wolffd@0
|
68 <TD ALIGN=LEFT><I>ID</I> [ <B>'='</B> <I>ID</I> ] [ <B>','</B> ] [ <I>a_list</I> ]</TD>
|
wolffd@0
|
69 </TR>
|
wolffd@0
|
70 <TR>
|
wolffd@0
|
71 <TD ALIGN=RIGHT><I>edge_stmt</I></TD>
|
wolffd@0
|
72 <TD ALIGN=LEFT>:</TD>
|
wolffd@0
|
73 <TD ALIGN=LEFT>(<I>node_id</I> | <I>subgraph</I>) <I>edgeRHS</I> [ <I>attr_list</I> ]</TD>
|
wolffd@0
|
74 </TR>
|
wolffd@0
|
75 <TR>
|
wolffd@0
|
76 <TD ALIGN=RIGHT><I>edgeRHS</I></TD>
|
wolffd@0
|
77 <TD ALIGN=LEFT>:</TD>
|
wolffd@0
|
78 <TD ALIGN=LEFT><I>edgeop</I> (<I>node_id</I> | <I>subgraph</I>) [ <I>edgeRHS</I> ]</TD>
|
wolffd@0
|
79 </TR>
|
wolffd@0
|
80 <TR>
|
wolffd@0
|
81 <TD ALIGN=RIGHT><I>node_stmt</I></TD>
|
wolffd@0
|
82 <TD ALIGN=LEFT>:</TD>
|
wolffd@0
|
83 <TD ALIGN=LEFT><I>node_id</I> [ <I>attr_list</I> ]</TD>
|
wolffd@0
|
84 </TR>
|
wolffd@0
|
85 <TR>
|
wolffd@0
|
86 <TD ALIGN=RIGHT><I>node_id</I></TD>
|
wolffd@0
|
87 <TD ALIGN=LEFT>:</TD>
|
wolffd@0
|
88 <TD ALIGN=LEFT><I>ID</I> [ <I>port</I> ]</TD>
|
wolffd@0
|
89 </TR>
|
wolffd@0
|
90 <TR>
|
wolffd@0
|
91 <TD ALIGN=RIGHT><I>port</I></TD>
|
wolffd@0
|
92 <TD ALIGN=LEFT>:</TD>
|
wolffd@0
|
93 <TD ALIGN=LEFT><B>':'</B> <I>ID</I> [ <B>':'</B> <I>compass_pt</I> ]</TD>
|
wolffd@0
|
94 </TR>
|
wolffd@0
|
95 <TR>
|
wolffd@0
|
96 <TD ALIGN=RIGHT></TD>
|
wolffd@0
|
97 <TD ALIGN=LEFT>|</TD>
|
wolffd@0
|
98 <TD ALIGN=LEFT><B>':'</B> <I>compass_pt</I></TD>
|
wolffd@0
|
99 </TR>
|
wolffd@0
|
100 <TR>
|
wolffd@0
|
101 <TD ALIGN=RIGHT><I>subgraph</I></TD>
|
wolffd@0
|
102 <TD ALIGN=LEFT>:</TD>
|
wolffd@0
|
103 <TD ALIGN=LEFT>[ <B>subgraph</B> [ <I>ID</I> ] ] <B>'{'</B> <I>stmt_list</I> <B>'}'</B></TD>
|
wolffd@0
|
104 </TR>
|
wolffd@0
|
105 <TR>
|
wolffd@0
|
106 <TD ALIGN=RIGHT><I>compass_pt</I></TD>
|
wolffd@0
|
107 <TD ALIGN=LEFT>:</TD>
|
wolffd@0
|
108 <TD ALIGN=LEFT>(<B>n</B> | <B>ne</B> | <B>e</B> | <B>se</B> | <B>s</B> | <B>sw</B> | <B>w</B> | <B>nw</B> | <B>c</B> | <B>_</B>)</TD>
|
wolffd@0
|
109 </TR>
|
wolffd@0
|
110 </TABLE>
|
wolffd@0
|
111 <P>
|
wolffd@0
|
112 The keywords <B>node</B>, <B>edge</B>, <B>graph</B>, <B>digraph</B>,
|
wolffd@0
|
113 <B>subgraph</B>, and <B>strict</B> are case-independent.
|
wolffd@0
|
114 Note also that the allowed compass point values are not keywords, so
|
wolffd@0
|
115 these strings can be used elsewhere as ordinary identifiers and, conversely,
|
wolffd@0
|
116 the parser will actually accept any identifier.
|
wolffd@0
|
117 <P>
|
wolffd@0
|
118 An <I>ID</I> is one of the following:
|
wolffd@0
|
119 <MENU>
|
wolffd@0
|
120 <LI> Any string of alphabetic (<TT>[a-zA-Z\200-\377]</TT>) characters, underscores (<TT>'_'</TT>) or
|
wolffd@0
|
121 digits (<TT>[0-9]</TT>), not beginning with a digit;
|
wolffd@0
|
122 <LI> a number [<tt>-</tt>]<sup>?</sup>(<tt>.</tt>[<tt>0</tt>-<tt>9</tt>]<sup>+</sup> | [<tt>0</tt>-<tt>9</tt>]<sup>+</sup>(<tt>.</tt>[<tt>0</tt>-<tt>9</tt>]<sup>*</sup>)<sup>?</sup> );
|
wolffd@0
|
123 <LI> any double-quoted string ("...") possibly containing escaped
|
wolffd@0
|
124 quotes (\")<SUP>1</SUP>;
|
wolffd@0
|
125 <LI> an <A NAME=html>HTML string</A> (<...>).
|
wolffd@0
|
126 </MENU>
|
wolffd@0
|
127 Note that in HTML strings, angle
|
wolffd@0
|
128 brackets must occur in matched pairs, and unescaped newlines are allowed.
|
wolffd@0
|
129 In addition, the content must be legal XML, so that the special XML
|
wolffd@0
|
130 escape sequences for ", &, <, and > may be necessary
|
wolffd@0
|
131 in order to embed these characters in attribute values or raw text.
|
wolffd@0
|
132 <P>
|
wolffd@0
|
133 Both quoted strings and HTML strings are scanned as a unit, so
|
wolffd@0
|
134 any embedded comments will be treated as part of the strings.
|
wolffd@0
|
135 <P>
|
wolffd@0
|
136 An <I>edgeop</I> is <TT>-></TT> in directed graphs and <TT>--</TT> in
|
wolffd@0
|
137 undirected graphs.
|
wolffd@0
|
138 <P>
|
wolffd@0
|
139 An <I>a_list</I> clause of the form <I>ID</I> is equivalent to
|
wolffd@0
|
140 <I>ID</I><TT>=true</TT>.
|
wolffd@0
|
141 <P>
|
wolffd@0
|
142 The language supports C++-style comments: <TT>/* */</TT> and <TT>//</TT>.
|
wolffd@0
|
143 In addition, a line beginning with a '#' character is considered a line
|
wolffd@0
|
144 output from a C preprocessor (e.g., # 34 to indicate line 34 ) and discarded.
|
wolffd@0
|
145 <P>
|
wolffd@0
|
146 Semicolons aid readability but are not required except in the rare case
|
wolffd@0
|
147 that a named subgraph with no body immediately preceeds an anonymous
|
wolffd@0
|
148 subgraph, since the precedence rules cause this sequence to be parsed as
|
wolffd@0
|
149 a subgraph with a heading and a body.
|
wolffd@0
|
150 Also, any amount of whitespace may be inserted between terminals.
|
wolffd@0
|
151 <P>
|
wolffd@0
|
152 As another aid for readability, dot allows single logical lines to
|
wolffd@0
|
153 span multiple physical lines using the standard C convention of a
|
wolffd@0
|
154 backslash immediately preceding a newline character. In addition,
|
wolffd@0
|
155 double-quoted strings can be concatenated using a '+' operator.
|
wolffd@0
|
156 As HTML strings can contain newline characters, they do not support the
|
wolffd@0
|
157 concatenation operator.
|
wolffd@0
|
158 <H2>Semantic Notes</H2>
|
wolffd@0
|
159 If a default attribute is
|
wolffd@0
|
160 defined using a <B>node</B>, <B>edge</B>, or <B>graph</B> statement,
|
wolffd@0
|
161 or by an attribute assignment not attached to a node or edge, any object of the
|
wolffd@0
|
162 appropriate type defined afterwards will inherit this attribute value.
|
wolffd@0
|
163 This holds until the default attribute is set to a new value, from which
|
wolffd@0
|
164 point the new value is used. Objects defined before a default attribute
|
wolffd@0
|
165 is set will have an empty string value attached to the attribute once
|
wolffd@0
|
166 the default attribute definition is made.
|
wolffd@0
|
167 <P>
|
wolffd@0
|
168 Note, in particular, that a subgraph receives the attribute settings of
|
wolffd@0
|
169 its parent graph at the time of its definition. This can be useful; for
|
wolffd@0
|
170 example, one can assign a font to the root graph and all subgraphs will
|
wolffd@0
|
171 also use the font. For some attributes, however, this property is
|
wolffd@0
|
172 undesirable. If one attaches a label to the root graph, it is probably
|
wolffd@0
|
173 not the desired effect to have the label used by all subgraphs. Rather
|
wolffd@0
|
174 than listing the graph attribute at the top of the graph, and the
|
wolffd@0
|
175 resetting the attribute as needed in the subgraphs, one can simple defer
|
wolffd@0
|
176 the attribute definition if the graph until the appropriate subgraphs
|
wolffd@0
|
177 have been defined.
|
wolffd@0
|
178 <P>
|
wolffd@0
|
179 If an edge belongs to a cluster, its endpoints belong to that cluster.
|
wolffd@0
|
180 Thus, where you put an edge can effect a layout, as clusters are sometimes
|
wolffd@0
|
181 laid out recursively.
|
wolffd@0
|
182 <H2>Character encodings</H2>
|
wolffd@0
|
183 The DOT language assumes at least the ascii character set.
|
wolffd@0
|
184 Quoted strings, both ordinary and HTML-like, may contain non-ascii characters.
|
wolffd@0
|
185 In most cases, these strings are uninterpreted: they simply serve as
|
wolffd@0
|
186 unique identifiers or values passed through untouched. Labels, however,
|
wolffd@0
|
187 are meant to be displayed, which requires that the software be able to
|
wolffd@0
|
188 compute the size of the text and determine the appropriate glyphs.
|
wolffd@0
|
189 For this, it needs to know what character encoding is used.
|
wolffd@0
|
190 <P>
|
wolffd@0
|
191 By default, DOT assumes the UTF-8 character encoding. It also accepts
|
wolffd@0
|
192 the Latin1 (ISO-8859-1) character set, assuming the input graph uses
|
wolffd@0
|
193 the <B><A HREF=attrs.html#a:charset>charset</A></B> attribute to
|
wolffd@0
|
194 specify this. For graphs using other
|
wolffd@0
|
195 character sets, there are usually programs, such as <TT>iconv</TT>, which
|
wolffd@0
|
196 will translate from one character set to another.
|
wolffd@0
|
197 <P>
|
wolffd@0
|
198 Another way to avoid non-ascii characters in labels is to use HTML entities
|
wolffd@0
|
199 for special characters. During label evaluation, these entities are
|
wolffd@0
|
200 translated into the underlying character. This
|
wolffd@0
|
201 <a HREF="http://www.graphviz.org/doc/char.html">
|
wolffd@0
|
202 table</a> shows the supported entities, with their Unicode value, a typical
|
wolffd@0
|
203 glyph, and the HTML entity name. Thus, to include a lower-case Greek beta
|
wolffd@0
|
204 into a string, one can use the ascii sequence <TT>&beta;</TT>.
|
wolffd@0
|
205 In general, one should only use entities that are allowed in the output
|
wolffd@0
|
206 character set, and for which there is a glyph in the font.
|
wolffd@0
|
207 <HR>
|
wolffd@0
|
208 <OL TYPE="1">
|
wolffd@0
|
209 <LI> In quoted strings in DOT, the only escaped character is double-quote
|
wolffd@0
|
210 ("). That is, in quoted strings, the dyad \" is converted to "; all other
|
wolffd@0
|
211 characters are left unchanged. In particular, \\ remains \\. Layout
|
wolffd@0
|
212 engines may apply additional escape sequences.
|
wolffd@0
|
213 </OL>
|
wolffd@0
|
214 </BODY>
|
wolffd@0
|
215 </HTML>
|