Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> |
2 | <html> | |
3 | <head> | |
4 | <link rel="STYLESHEET" href="doc.css" type='text/css' /> | |
5 | <link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" /> | |
6 | <link rel='start' href='../index.html' title='Python Documentation Index' /> | |
7 | <link rel="first" href="doc.html" title='Documenting Python' /> | |
8 | <link rel='contents' href='contents.html' title="Contents" /> | |
9 | <link rel='last' href='about.html' title='About this document...' /> | |
10 | <link rel='help' href='about.html' title='About this document...' /> | |
11 | <link rel="next" href="gui-markup.html" /> | |
12 | <link rel="prev" href="indexing.html" /> | |
13 | <link rel="parent" href="special-constructs.html" /> | |
14 | <link rel="next" href="gui-markup.html" /> | |
15 | <meta name='aesop' content='information' /> | |
16 | <title>6.12 Grammar Production Displays </title> | |
17 | </head> | |
18 | <body> | |
19 | <DIV CLASS="navigation"> | |
20 | <div id='top-navigation-panel' xml:id='top-navigation-panel'> | |
21 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> | |
22 | <tr> | |
23 | <td class='online-navigation'><a rel="prev" title="6.11 Index-generating Markup" | |
24 | href="indexing.html"><img src='../icons/previous.png' | |
25 | border='0' height='32' alt='Previous Page' width='32' /></A></td> | |
26 | <td class='online-navigation'><a rel="parent" title="6 Special Markup Constructs" | |
27 | href="special-constructs.html"><img src='../icons/up.png' | |
28 | border='0' height='32' alt='Up One Level' width='32' /></A></td> | |
29 | <td class='online-navigation'><a rel="next" title="6.13 Graphical Interface Components" | |
30 | href="gui-markup.html"><img src='../icons/next.png' | |
31 | border='0' height='32' alt='Next Page' width='32' /></A></td> | |
32 | <td align="center" width="100%">Documenting Python</td> | |
33 | <td class='online-navigation'><a rel="contents" title="Table of Contents" | |
34 | href="contents.html"><img src='../icons/contents.png' | |
35 | border='0' height='32' alt='Contents' width='32' /></A></td> | |
36 | <td class='online-navigation'><img src='../icons/blank.png' | |
37 | border='0' height='32' alt='' width='32' /></td> | |
38 | <td class='online-navigation'><img src='../icons/blank.png' | |
39 | border='0' height='32' alt='' width='32' /></td> | |
40 | </tr></table> | |
41 | <div class='online-navigation'> | |
42 | <b class="navlabel">Previous:</b> | |
43 | <a class="sectref" rel="prev" href="indexing.html">6.11 Index-generating Markup</A> | |
44 | <b class="navlabel">Up:</b> | |
45 | <a class="sectref" rel="parent" href="special-constructs.html">6 Special Markup Constructs</A> | |
46 | <b class="navlabel">Next:</b> | |
47 | <a class="sectref" rel="next" href="gui-markup.html">6.13 Graphical Interface Components</A> | |
48 | </div> | |
49 | <hr /></div> | |
50 | </DIV> | |
51 | <!--End of Navigation Panel--> | |
52 | ||
53 | <H2><A NAME="SECTION0007120000000000000000"></A><A NAME="grammar-displays"></A> | |
54 | <BR> | |
55 | 6.12 Grammar Production Displays | |
56 | </H2> | |
57 | ||
58 | <P> | |
59 | Special markup is available for displaying the productions of a | |
60 | formal grammar. The markup is simple and does not attempt to | |
61 | model all aspects of BNF (or any derived forms), but provides | |
62 | enough to allow context-free grammars to be displayed in a way | |
63 | that causes uses of a symbol to be rendered as hyperlinks to the | |
64 | definition of the symbol. There is one environment and a pair of | |
65 | macros: | |
66 | ||
67 | <P> | |
68 | ||
69 | <dl class='envdesc'> | |
70 | <dt><tt>\begin{<b class='environment'>productionlist</b>}</tt> | |
71 | <tt>[</tt><var>language</var><tt>]</tt> | |
72 | <br /><tt>\end{<b class='environment'>productionlist</b>}</tt></dt> | |
73 | <dd> | |
74 | This environment is used to enclose a group of productions. The | |
75 | two macros are only defined within this environment. If a | |
76 | document describes more than one language, the optional parameter | |
77 | <var>language</var> should be used to distinguish productions between | |
78 | languages. The value of the parameter should be a short name | |
79 | that can be used as part of a filename; colons or other | |
80 | characters that can't be used in filename across platforms | |
81 | should be included. | |
82 | </dd></dl> | |
83 | ||
84 | <P> | |
85 | ||
86 | <dl class='macrodesc'> | |
87 | <dt><b><tt class='macro'>\production</tt></b> | |
88 | <tt>{</tt><var>name</var><tt>}</tt><tt>{</tt><var>definition</var><tt>}</tt></dt> | |
89 | <dd> | |
90 | A production rule in the grammar. The rule defines the symbol | |
91 | <var>name</var> to be <var>definition</var>. <var>name</var> should not | |
92 | contain any markup, and the use of hyphens in a document which | |
93 | supports more than one grammar is undefined. <var>definition</var> | |
94 | may contain <tt class='macro'>\token</tt> macros and any additional content | |
95 | needed to describe the grammatical model of <var>symbol</var>. Only | |
96 | one <tt class='macro'>\production</tt> may be used to define a symbol -- | |
97 | multiple definitions are not allowed. | |
98 | </dd></dl> | |
99 | ||
100 | <P> | |
101 | ||
102 | <dl class='macrodesc'> | |
103 | <dt><b><tt class='macro'>\token</tt></b> | |
104 | <tt>{</tt><var>name</var><tt>}</tt></dt> | |
105 | <dd> | |
106 | The name of a symbol defined by a <tt class='macro'>\production</tt> macro, used | |
107 | in the <var>definition</var> of a symbol. Where possible, this will | |
108 | be rendered as a hyperlink to the definition of the symbol | |
109 | <var>name</var>. | |
110 | </dd></dl> | |
111 | ||
112 | <P> | |
113 | Note that the entire grammar does not need to be defined in a | |
114 | single <tt class='environment'>\productionlist</tt> environment; any number of | |
115 | groupings may be used to describe the grammar. Every use of the | |
116 | <tt class='macro'>\token</tt> must correspond to a <tt class='macro'>\production</tt>. | |
117 | ||
118 | <P> | |
119 | The following is an example taken from the | |
120 | <em class="citetitle"><a | |
121 | href="../ref/identifiers.html" | |
122 | title="Python Reference Manual" | |
123 | >Python Reference Manual</a></em>: | |
124 | ||
125 | <P> | |
126 | <div class="verbatim"><pre> | |
127 | \begin{productionlist} | |
128 | \production{identifier} | |
129 | {(\token{letter}|"_") (\token{letter} | \token{digit} | "_")*} | |
130 | \production{letter} | |
131 | {\token{lowercase} | \token{uppercase}} | |
132 | \production{lowercase} | |
133 | {"a"..."z"} | |
134 | \production{uppercase} | |
135 | {"A"..."Z"} | |
136 | \production{digit} | |
137 | {"0"..."9"} | |
138 | \end{productionlist} | |
139 | </pre></div> | |
140 | ||
141 | <P> | |
142 | ||
143 | <DIV CLASS="navigation"> | |
144 | <div class='online-navigation'> | |
145 | <p></p><hr /> | |
146 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> | |
147 | <tr> | |
148 | <td class='online-navigation'><a rel="prev" title="6.11 Index-generating Markup" | |
149 | href="indexing.html"><img src='../icons/previous.png' | |
150 | border='0' height='32' alt='Previous Page' width='32' /></A></td> | |
151 | <td class='online-navigation'><a rel="parent" title="6 Special Markup Constructs" | |
152 | href="special-constructs.html"><img src='../icons/up.png' | |
153 | border='0' height='32' alt='Up One Level' width='32' /></A></td> | |
154 | <td class='online-navigation'><a rel="next" title="6.13 Graphical Interface Components" | |
155 | href="gui-markup.html"><img src='../icons/next.png' | |
156 | border='0' height='32' alt='Next Page' width='32' /></A></td> | |
157 | <td align="center" width="100%">Documenting Python</td> | |
158 | <td class='online-navigation'><a rel="contents" title="Table of Contents" | |
159 | href="contents.html"><img src='../icons/contents.png' | |
160 | border='0' height='32' alt='Contents' width='32' /></A></td> | |
161 | <td class='online-navigation'><img src='../icons/blank.png' | |
162 | border='0' height='32' alt='' width='32' /></td> | |
163 | <td class='online-navigation'><img src='../icons/blank.png' | |
164 | border='0' height='32' alt='' width='32' /></td> | |
165 | </tr></table> | |
166 | <div class='online-navigation'> | |
167 | <b class="navlabel">Previous:</b> | |
168 | <a class="sectref" rel="prev" href="indexing.html">6.11 Index-generating Markup</A> | |
169 | <b class="navlabel">Up:</b> | |
170 | <a class="sectref" rel="parent" href="special-constructs.html">6 Special Markup Constructs</A> | |
171 | <b class="navlabel">Next:</b> | |
172 | <a class="sectref" rel="next" href="gui-markup.html">6.13 Graphical Interface Components</A> | |
173 | </div> | |
174 | </div> | |
175 | <hr /> | |
176 | <span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span> | |
177 | </DIV> | |
178 | <!--End of Navigation Panel--> | |
179 | <ADDRESS> | |
180 | See <i><a href="about.html">About this document...</a></i> for information on suggesting changes. | |
181 | </ADDRESS> | |
182 | </BODY> | |
183 | </HTML> |