]>
Commit | Line | Data |
---|---|---|
bbeff196 WP |
1 | <?xml version="1.0" encoding="UTF-8"?> |
2 | ||
3 | <!-- | |
4 | xml2html.xsl - transform Bison XML Report into XHTML. | |
5 | $Id$ | |
6 | ||
7 | Copyright (C) 2007 Free Software Foundation, Inc. | |
8 | ||
9 | This file is part of Bison, the GNU Compiler Compiler. | |
10 | ||
11 | This program is free software: you can redistribute it and/or modify | |
12 | it under the terms of the GNU General Public License as published by | |
13 | the Free Software Foundation, either version 3 of the License, or | |
14 | (at your option) any later version. | |
15 | ||
16 | This program is distributed in the hope that it will be useful, | |
17 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 | GNU General Public License for more details. | |
20 | ||
21 | You should have received a copy of the GNU General Public License | |
22 | along with this program. If not, see <http://www.gnu.org/licenses/>. | |
23 | ||
24 | Written by Wojciech Polak <polak@gnu.org>. | |
25 | --> | |
26 | ||
27 | <xsl:stylesheet version="1.0" | |
28 | xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | |
21f1b063 JD |
29 | xmlns="http://www.w3.org/1999/xhtml" |
30 | xmlns:bison="http://www.gnu.org/software/bison/"> | |
31 | ||
32 | <xsl:import href="bison.xsl"/> | |
bbeff196 WP |
33 | |
34 | <xsl:output method="xml" encoding="UTF-8" | |
35 | doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" | |
36 | doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" | |
37 | indent="yes"/> | |
38 | ||
39 | <xsl:template match="/"> | |
40 | <html> | |
41 | <head> | |
42 | <title>GNU Bison XML Automaton Report</title> | |
43 | <style type="text/css"><![CDATA[ | |
44 | body { | |
45 | font-family: "Nimbus Sans L", Arial, sans-serif; | |
46 | font-size: 9pt; | |
47 | } | |
48 | a:link { | |
49 | color: #1f00ff; | |
50 | text-decoration: none; | |
51 | } | |
52 | a:visited { | |
53 | color: #1f00ff; | |
54 | text-decoration: none; | |
55 | } | |
56 | a:hover { | |
57 | color: red; | |
58 | } | |
59 | #menu a { | |
60 | text-decoration: underline; | |
61 | } | |
62 | .i { | |
63 | font-style: italic; | |
64 | } | |
65 | .pre { | |
66 | font-family: monospace; | |
67 | white-space: pre; | |
68 | } | |
69 | ol.decimal { | |
70 | list-style-type: decimal; | |
71 | } | |
72 | ol.lower-alpha { | |
73 | list-style-type: lower-alpha; | |
74 | } | |
75 | .point { | |
76 | color: #cc0000; | |
77 | } | |
78 | #footer { | |
79 | margin-top: 3.5em; | |
80 | font-size: 7pt; | |
81 | } | |
82 | ]]></style> | |
83 | </head> | |
84 | <body> | |
85 | <xsl:apply-templates select="bison-xml-report"/> | |
86 | <xsl:text> </xsl:text> | |
87 | <div id="footer"><hr /> | |
88 | <a href="http://www.gnu.org/software/bison/" title="GNU Bison"> | |
89 | GNU Bison <xsl:value-of select="/bison-xml-report/@version"/></a> | |
90 | XML Automaton Report, written by | |
91 | <a href="http://www.gnu.org.ua/~polak/" title="Wojciech Polak">Wojciech Polak</a>. | |
92 | Copyright (C) 2007 Free Software Foundation, Inc.<br /> | |
93 | Verbatim copying and distribution of this entire page is permitted | |
94 | in any medium, provided this notice is preserved.</div> | |
95 | </body> | |
96 | </html> | |
97 | </xsl:template> | |
98 | ||
99 | <xsl:template match="bison-xml-report"> | |
100 | <h1>GNU Bison XML Automaton Report</h1> | |
101 | <p> | |
102 | input grammar: <span class="i"><xsl:value-of select="filename"/></span> | |
103 | </p> | |
104 | ||
105 | <xsl:text> </xsl:text> | |
106 | <h3>Table of Contents</h3> | |
107 | <ul id="menu"> | |
108 | <li> | |
109 | <a href="#reductions">Reductions</a> | |
110 | <ul class="lower-alpha"> | |
111 | <li><a href="#useless_nonterminals">Useless nonterminal symbols</a></li> | |
112 | <li><a href="#unused_terminals">Unused terminal symbols</a></li> | |
113 | <li><a href="#useless_rules">Useless rules</a></li> | |
114 | </ul> | |
115 | </li> | |
116 | <li><a href="#conflicts">Conflicts</a></li> | |
117 | <li> | |
118 | <a href="#grammar">Grammar</a> | |
119 | <ul class="lower-alpha"> | |
120 | <li><a href="#grammar">Itemset</a></li> | |
121 | <li><a href="#terminals">Terminal symbols</a></li> | |
122 | <li><a href="#nonterminals">Nonterminal symbols</a></li> | |
123 | </ul> | |
124 | </li> | |
125 | <li><a href="#automaton">Automaton</a></li> | |
126 | </ul> | |
127 | <xsl:apply-templates select="reductions"/> | |
128 | <xsl:apply-templates select="rules-never-reduced"/> | |
21f1b063 | 129 | <xsl:apply-templates select="automaton" mode="conflicts"/> |
bbeff196 WP |
130 | <xsl:apply-templates select="grammar"/> |
131 | <xsl:apply-templates select="automaton"/> | |
132 | </xsl:template> | |
133 | ||
134 | <xsl:template match="rules-never-reduced"> | |
135 | <xsl:if test="rule"> | |
136 | <h2> | |
137 | <a name="rules_never_reduced"/> | |
138 | <xsl:text> Rules never reduced</xsl:text> | |
139 | </h2> | |
140 | <xsl:text> </xsl:text> | |
141 | <p class="pre"> | |
142 | <xsl:apply-templates select="rule"> | |
143 | <xsl:with-param name="pad" select="'3'"/> | |
144 | </xsl:apply-templates> | |
145 | </p> | |
146 | <xsl:text> </xsl:text> | |
147 | </xsl:if> | |
148 | </xsl:template> | |
149 | ||
150 | <xsl:template match="reductions"> | |
151 | <h2> | |
152 | <a name="reductions"/> | |
153 | <xsl:text> Reductions</xsl:text> | |
154 | </h2> | |
155 | <xsl:apply-templates select="useless/nonterminals"/> | |
156 | <xsl:apply-templates select="unused/terminals"/> | |
157 | <xsl:apply-templates select="useless/rules"/> | |
158 | </xsl:template> | |
159 | ||
160 | <xsl:template match="useless/nonterminals"> | |
161 | <h3> | |
162 | <a name="useless_nonterminals"/> | |
163 | <xsl:text> Useless nonterminals</xsl:text> | |
164 | </h3> | |
165 | <xsl:text> </xsl:text> | |
166 | <xsl:if test="nonterminal"> | |
167 | <p class="pre"> | |
168 | <xsl:for-each select="nonterminal"> | |
169 | <xsl:text> </xsl:text> | |
170 | <xsl:value-of select="."/> | |
171 | <xsl:text> </xsl:text> | |
172 | </xsl:for-each> | |
173 | <xsl:text> </xsl:text> | |
174 | </p> | |
175 | </xsl:if> | |
176 | </xsl:template> | |
177 | ||
178 | <xsl:template match="useless/rules"> | |
179 | <h3> | |
180 | <a name="useless_rules"/> | |
181 | <xsl:text> Useless rules</xsl:text> | |
182 | </h3> | |
183 | <xsl:text> </xsl:text> | |
184 | <xsl:if test="rule"> | |
185 | <p class="pre"> | |
186 | <xsl:apply-templates select="rule"> | |
187 | <xsl:with-param name="pad" select="'3'"/> | |
188 | </xsl:apply-templates> | |
189 | <xsl:text> </xsl:text> | |
190 | </p> | |
191 | </xsl:if> | |
192 | </xsl:template> | |
193 | ||
194 | <xsl:template match="unused/terminals"> | |
195 | <h3> | |
196 | <a name="unused_terminals"/> | |
197 | <xsl:text> Terminals which are not used</xsl:text> | |
198 | </h3> | |
199 | <xsl:text> </xsl:text> | |
200 | <xsl:if test="terminal"> | |
201 | <p class="pre"> | |
202 | <xsl:for-each select="terminal"> | |
203 | <xsl:text> </xsl:text> | |
204 | <xsl:value-of select="."/> | |
205 | <xsl:text> </xsl:text> | |
206 | </xsl:for-each> | |
207 | <xsl:text> </xsl:text> | |
208 | </p> | |
209 | </xsl:if> | |
210 | </xsl:template> | |
211 | ||
21f1b063 | 212 | <xsl:template match="automaton" mode="conflicts"> |
bbeff196 WP |
213 | <h2> |
214 | <a name="conflicts"/> | |
215 | <xsl:text> Conflicts</xsl:text> | |
216 | </h2> | |
217 | <xsl:text> </xsl:text> | |
21f1b063 JD |
218 | <xsl:variable name="conflict-report"> |
219 | <xsl:apply-templates select="state" mode="conflicts"/> | |
220 | </xsl:variable> | |
221 | <xsl:if test="string-length($conflict-report) != 0"> | |
bbeff196 | 222 | <p class="pre"> |
21f1b063 | 223 | <xsl:copy-of select="$conflict-report"/> |
bbeff196 WP |
224 | <xsl:text> </xsl:text> |
225 | </p> | |
226 | </xsl:if> | |
227 | </xsl:template> | |
228 | ||
21f1b063 JD |
229 | <xsl:template match="state" mode="conflicts"> |
230 | <xsl:variable name="conflict-counts"> | |
231 | <xsl:apply-templates select="." mode="bison:count-conflicts" /> | |
232 | </xsl:variable> | |
233 | <xsl:variable | |
234 | name="sr-count" select="substring-before($conflict-counts, ',')" | |
235 | /> | |
236 | <xsl:variable | |
237 | name="rr-count" select="substring-after($conflict-counts, ',')" | |
238 | /> | |
239 | <xsl:if test="$sr-count > 0 or $rr-count > 0"> | |
240 | <a> | |
241 | <xsl:attribute name="href"> | |
242 | <xsl:value-of select="concat('#state_', @number)"/> | |
243 | </xsl:attribute> | |
244 | <xsl:value-of select="concat('State ', @number)"/> | |
245 | </a> | |
246 | <xsl:text> conflicts:</xsl:text> | |
247 | <xsl:if test="$sr-count > 0"> | |
248 | <xsl:value-of select="concat(' ', $sr-count, ' shift/reduce')"/> | |
249 | <xsl:if test="$rr-count > 0"> | |
250 | <xsl:value-of select="(',')"/> | |
251 | </xsl:if> | |
252 | </xsl:if> | |
253 | <xsl:if test="$rr-count > 0"> | |
254 | <xsl:value-of select="concat(' ', $rr-count, ' reduce/reduce')"/> | |
255 | </xsl:if> | |
256 | <xsl:value-of select="' '"/> | |
257 | </xsl:if> | |
bbeff196 WP |
258 | </xsl:template> |
259 | ||
260 | <xsl:template match="grammar"> | |
261 | <h2> | |
262 | <a name="grammar"/> | |
263 | <xsl:text> Grammar</xsl:text> | |
264 | </h2> | |
265 | <xsl:text> </xsl:text> | |
266 | <p class="pre"> | |
267 | <xsl:apply-templates select="rules/rule"> | |
268 | <xsl:with-param name="pad" select="'3'"/> | |
269 | </xsl:apply-templates> | |
270 | </p> | |
271 | <xsl:text> </xsl:text> | |
272 | <xsl:apply-templates select="terminals"/> | |
273 | <xsl:apply-templates select="nonterminals"/> | |
274 | </xsl:template> | |
275 | ||
276 | <xsl:template match="grammar/terminals"> | |
277 | <h3> | |
278 | <a name="terminals"/> | |
279 | <xsl:text> Terminals, with rules where they appear</xsl:text> | |
280 | </h3> | |
281 | <xsl:text> </xsl:text> | |
282 | <p class="pre"> | |
283 | <xsl:apply-templates select="terminal"/> | |
284 | </p> | |
285 | <xsl:text> </xsl:text> | |
286 | </xsl:template> | |
287 | ||
288 | <xsl:template match="grammar/nonterminals"> | |
289 | <h3> | |
290 | <a name="nonterminals"/> | |
291 | <xsl:text> Nonterminals, with rules where they appear</xsl:text> | |
292 | </h3> | |
293 | <xsl:text> </xsl:text> | |
294 | <p class="pre"> | |
295 | <xsl:apply-templates select="nonterminal"/> | |
296 | </p> | |
297 | </xsl:template> | |
298 | ||
299 | <xsl:template match="terminal"> | |
36c48187 WP |
300 | <b><xsl:value-of select="@name"/></b> |
301 | <xsl:value-of select="concat(' (', @number, ')')"/> | |
bbeff196 WP |
302 | <xsl:apply-templates select="rule"/> |
303 | <xsl:text> </xsl:text> | |
304 | </xsl:template> | |
305 | ||
306 | <xsl:template match="terminal/rule"> | |
307 | <xsl:text> </xsl:text> | |
308 | <a> | |
309 | <xsl:attribute name="href"> | |
310 | <xsl:value-of select="concat('#rule_', .)"/> | |
311 | </xsl:attribute> | |
312 | <xsl:value-of select="."/> | |
313 | </a> | |
314 | </xsl:template> | |
315 | ||
316 | <xsl:template match="nonterminal"> | |
36c48187 WP |
317 | <b><xsl:value-of select="@name"/></b> |
318 | <xsl:value-of select="concat(' (', @number, ')')"/> | |
bbeff196 WP |
319 | <xsl:text> </xsl:text> |
320 | <xsl:if test="left/rule"> | |
321 | <xsl:text>on left:</xsl:text> | |
322 | </xsl:if> | |
323 | <xsl:apply-templates select="left/rule"/> | |
324 | <xsl:if test="left/rule and right/rule"> | |
325 | <xsl:text> </xsl:text> | |
326 | </xsl:if> | |
327 | <xsl:if test="right/rule"> | |
328 | <xsl:text>on right:</xsl:text> | |
329 | </xsl:if> | |
330 | <xsl:apply-templates select="right/rule"/> | |
331 | <xsl:text> </xsl:text> | |
332 | </xsl:template> | |
333 | ||
334 | <xsl:template match="nonterminal/left/rule|nonterminal/right/rule"> | |
335 | <xsl:text> </xsl:text> | |
336 | <a> | |
337 | <xsl:attribute name="href"> | |
338 | <xsl:value-of select="concat('#rule_', .)"/> | |
339 | </xsl:attribute> | |
340 | <xsl:value-of select="."/> | |
341 | </a> | |
342 | </xsl:template> | |
343 | ||
344 | <xsl:template match="automaton"> | |
345 | <h2> | |
346 | <a name="automaton"/> | |
347 | <xsl:text> Automaton</xsl:text> | |
348 | </h2> | |
349 | <xsl:apply-templates select="state"> | |
350 | <xsl:with-param name="pad" select="'3'"/> | |
351 | </xsl:apply-templates> | |
352 | </xsl:template> | |
353 | ||
354 | <xsl:template match="automaton/state"> | |
355 | <xsl:param name="pad"/> | |
356 | <xsl:text> </xsl:text> | |
357 | <h3> | |
358 | <a> | |
359 | <xsl:attribute name="name"> | |
360 | <xsl:value-of select="concat('state_', @number)"/> | |
361 | </xsl:attribute> | |
362 | </a> | |
363 | <xsl:text>state </xsl:text> | |
364 | <xsl:value-of select="@number"/> | |
365 | </h3> | |
366 | <xsl:text> </xsl:text> | |
367 | <p class="pre"> | |
95134bc1 | 368 | <xsl:apply-templates select="itemset/item"> |
bbeff196 WP |
369 | <xsl:with-param name="pad" select="$pad"/> |
370 | </xsl:apply-templates> | |
371 | <xsl:apply-templates select="actions/transitions"> | |
372 | <xsl:with-param name="type" select="'shift'"/> | |
373 | </xsl:apply-templates> | |
374 | <xsl:apply-templates select="actions/errors"/> | |
375 | <xsl:apply-templates select="actions/reductions"/> | |
376 | <xsl:apply-templates select="actions/transitions"> | |
377 | <xsl:with-param name="type" select="'goto'"/> | |
378 | </xsl:apply-templates> | |
379 | <xsl:apply-templates select="solved-conflicts"/> | |
380 | </p> | |
381 | </xsl:template> | |
382 | ||
383 | <xsl:template match="actions/transitions"> | |
384 | <xsl:param name="type"/> | |
385 | <xsl:if test="transition[@type = $type]"> | |
386 | <xsl:text> </xsl:text> | |
387 | <xsl:apply-templates select="transition[@type = $type]"> | |
388 | <xsl:with-param name="pad"> | |
389 | <xsl:call-template name="max-width-symbol"> | |
390 | <xsl:with-param name="node" select="transition[@type = $type]"/> | |
391 | </xsl:call-template> | |
392 | </xsl:with-param> | |
393 | </xsl:apply-templates> | |
394 | </xsl:if> | |
395 | </xsl:template> | |
396 | ||
397 | <xsl:template match="actions/errors"> | |
398 | <xsl:if test="error"> | |
399 | <xsl:text> </xsl:text> | |
400 | <xsl:apply-templates select="error"> | |
401 | <xsl:with-param name="pad"> | |
402 | <xsl:call-template name="max-width-symbol"> | |
403 | <xsl:with-param name="node" select="error"/> | |
404 | </xsl:call-template> | |
405 | </xsl:with-param> | |
406 | </xsl:apply-templates> | |
407 | </xsl:if> | |
408 | </xsl:template> | |
409 | ||
410 | <xsl:template match="actions/reductions"> | |
411 | <xsl:if test="reduction"> | |
412 | <xsl:text> </xsl:text> | |
413 | <xsl:apply-templates select="reduction"> | |
414 | <xsl:with-param name="pad"> | |
415 | <xsl:call-template name="max-width-symbol"> | |
416 | <xsl:with-param name="node" select="reduction"/> | |
417 | </xsl:call-template> | |
418 | </xsl:with-param> | |
419 | </xsl:apply-templates> | |
420 | </xsl:if> | |
421 | </xsl:template> | |
422 | ||
95134bc1 WP |
423 | <xsl:template match="item"> |
424 | <xsl:param name="pad"/> | |
425 | <xsl:param name="prev-rule-number" | |
426 | select="preceding-sibling::item[1]/@rule-number"/> | |
427 | <xsl:apply-templates select="key('bison:ruleNumber', current()/@rule-number)"> | |
428 | <xsl:with-param name="itemset" select="'true'"/> | |
429 | <xsl:with-param name="pad" select="$pad"/> | |
430 | <xsl:with-param name="prev-lhs" | |
431 | select="key('bison:ruleNumber', $prev-rule-number)/lhs[text()]"/> | |
432 | <xsl:with-param name="point" select="@point"/> | |
433 | <xsl:with-param name="lookaheads"> | |
434 | <xsl:apply-templates select="lookaheads"/> | |
435 | </xsl:with-param> | |
436 | </xsl:apply-templates> | |
437 | </xsl:template> | |
438 | ||
bbeff196 | 439 | <xsl:template match="rule"> |
95134bc1 | 440 | <xsl:param name="itemset"/> |
bbeff196 | 441 | <xsl:param name="pad"/> |
95134bc1 WP |
442 | <xsl:param name="prev-lhs"/> |
443 | <xsl:param name="point"/> | |
444 | <xsl:param name="lookaheads"/> | |
445 | ||
446 | <xsl:if test="$itemset != 'true' | |
447 | and not(preceding-sibling::rule[1]/lhs[text()] = lhs[text()])"> | |
bbeff196 WP |
448 | <xsl:text> </xsl:text> |
449 | </xsl:if> | |
95134bc1 WP |
450 | |
451 | <xsl:if test="$itemset != 'true'"> | |
bbeff196 WP |
452 | <a> |
453 | <xsl:attribute name="name"> | |
454 | <xsl:value-of select="concat('rule_', @number)"/> | |
455 | </xsl:attribute> | |
456 | </a> | |
457 | </xsl:if> | |
458 | <xsl:text> </xsl:text> | |
95134bc1 | 459 | |
bbeff196 | 460 | <xsl:choose> |
95134bc1 | 461 | <xsl:when test="$itemset = 'true'"> |
bbeff196 WP |
462 | <a> |
463 | <xsl:attribute name="href"> | |
464 | <xsl:value-of select="concat('#rule_', @number)"/> | |
465 | </xsl:attribute> | |
466 | <xsl:call-template name="lpad"> | |
467 | <xsl:with-param name="str" select="string(@number)"/> | |
468 | <xsl:with-param name="pad" select="number($pad)"/> | |
469 | </xsl:call-template> | |
470 | </a> | |
471 | </xsl:when> | |
472 | <xsl:otherwise> | |
473 | <xsl:call-template name="lpad"> | |
474 | <xsl:with-param name="str" select="string(@number)"/> | |
475 | <xsl:with-param name="pad" select="number($pad)"/> | |
476 | </xsl:call-template> | |
477 | </xsl:otherwise> | |
478 | </xsl:choose> | |
479 | <xsl:text> </xsl:text> | |
95134bc1 WP |
480 | |
481 | <!-- LHS --> | |
bbeff196 | 482 | <xsl:choose> |
95134bc1 WP |
483 | <xsl:when test="$itemset != 'true' |
484 | and preceding-sibling::rule[1]/lhs[text()] = lhs[text()]"> | |
485 | <xsl:call-template name="lpad"> | |
486 | <xsl:with-param name="str" select="'|'"/> | |
487 | <xsl:with-param name="pad" select="number(string-length(lhs[text()])) + 2"/> | |
488 | </xsl:call-template> | |
489 | </xsl:when> | |
490 | <xsl:when test="$itemset = 'true' and $prev-lhs = lhs[text()]"> | |
bbeff196 WP |
491 | <xsl:call-template name="lpad"> |
492 | <xsl:with-param name="str" select="'|'"/> | |
493 | <xsl:with-param name="pad" select="number(string-length(lhs[text()])) + 2"/> | |
494 | </xsl:call-template> | |
495 | </xsl:when> | |
496 | <xsl:otherwise> | |
497 | <span class="i"> | |
498 | <xsl:value-of select="lhs"/> | |
499 | </span> | |
500 | <xsl:text> →</xsl:text> | |
501 | </xsl:otherwise> | |
502 | </xsl:choose> | |
95134bc1 WP |
503 | |
504 | <!-- RHS --> | |
505 | <xsl:for-each select="rhs/*"> | |
506 | <xsl:if test="position() = $point + 1"> | |
507 | <xsl:text> </xsl:text> | |
508 | <span class="point">.</span> | |
509 | </xsl:if> | |
510 | <xsl:if test="$itemset = 'true' and name(.) != 'empty'"> | |
511 | <xsl:apply-templates select="."/> | |
512 | </xsl:if> | |
513 | <xsl:if test="$itemset != 'true'"> | |
514 | <xsl:apply-templates select="."/> | |
515 | </xsl:if> | |
516 | <xsl:if test="position() = last() and position() = $point"> | |
517 | <xsl:text> </xsl:text> | |
518 | <span class="point">.</span> | |
519 | </xsl:if> | |
520 | </xsl:for-each> | |
521 | <xsl:if test="$lookaheads"> | |
522 | <xsl:value-of select="$lookaheads"/> | |
523 | </xsl:if> | |
524 | ||
bbeff196 WP |
525 | <xsl:text> </xsl:text> |
526 | </xsl:template> | |
527 | ||
528 | <xsl:template match="symbol"> | |
529 | <xsl:text> </xsl:text> | |
530 | <xsl:choose> | |
531 | <xsl:when test="@class = 'nonterminal'"> | |
532 | <span class="i"><xsl:value-of select="."/></span> | |
533 | </xsl:when> | |
534 | <xsl:otherwise> | |
535 | <b><xsl:value-of select="."/></b> | |
536 | </xsl:otherwise> | |
537 | </xsl:choose> | |
538 | </xsl:template> | |
539 | ||
bbeff196 WP |
540 | <xsl:template match="empty"> |
541 | <xsl:text> ε</xsl:text> | |
542 | </xsl:template> | |
543 | ||
544 | <xsl:template match="lookaheads"> | |
545 | <xsl:text> [</xsl:text> | |
546 | <xsl:apply-templates select="symbol"/> | |
547 | <xsl:text>]</xsl:text> | |
548 | </xsl:template> | |
549 | ||
550 | <xsl:template match="lookaheads/symbol"> | |
551 | <xsl:value-of select="."/> | |
552 | <xsl:if test="position() != last()"> | |
553 | <xsl:text>, </xsl:text> | |
554 | </xsl:if> | |
555 | </xsl:template> | |
556 | ||
557 | <xsl:template match="transition"> | |
558 | <xsl:param name="pad"/> | |
559 | <xsl:text> </xsl:text> | |
560 | <xsl:call-template name="rpad"> | |
561 | <xsl:with-param name="str" select="string(@symbol)"/> | |
562 | <xsl:with-param name="pad" select="number($pad) + 2"/> | |
563 | </xsl:call-template> | |
564 | <xsl:choose> | |
565 | <xsl:when test="@type = 'shift'"> | |
566 | <a> | |
567 | <xsl:attribute name="href"> | |
568 | <xsl:value-of select="concat('#state_', @state)"/> | |
569 | </xsl:attribute> | |
570 | <xsl:value-of select="concat('shift, and go to state ', @state)"/> | |
571 | </a> | |
572 | </xsl:when> | |
573 | <xsl:when test="@type = 'goto'"> | |
574 | <a> | |
575 | <xsl:attribute name="href"> | |
576 | <xsl:value-of select="concat('#state_', @state)"/> | |
577 | </xsl:attribute> | |
578 | <xsl:value-of select="concat('go to state ', @state)"/> | |
579 | </a> | |
580 | </xsl:when> | |
581 | </xsl:choose> | |
582 | <xsl:text> </xsl:text> | |
583 | </xsl:template> | |
584 | ||
585 | <xsl:template match="error"> | |
586 | <xsl:param name="pad"/> | |
587 | <xsl:text> </xsl:text> | |
588 | <xsl:call-template name="rpad"> | |
589 | <xsl:with-param name="str" select="string(@symbol)"/> | |
590 | <xsl:with-param name="pad" select="number($pad) + 2"/> | |
591 | </xsl:call-template> | |
592 | <xsl:text>error</xsl:text> | |
593 | <xsl:text> (</xsl:text> | |
594 | <xsl:value-of select="text()"/> | |
595 | <xsl:text>)</xsl:text> | |
596 | <xsl:text> </xsl:text> | |
597 | </xsl:template> | |
598 | ||
599 | <xsl:template match="reduction"> | |
600 | <xsl:param name="pad"/> | |
601 | <xsl:text> </xsl:text> | |
602 | <xsl:call-template name="rpad"> | |
603 | <xsl:with-param name="str" select="string(@symbol)"/> | |
604 | <xsl:with-param name="pad" select="number($pad) + 2"/> | |
605 | </xsl:call-template> | |
606 | <xsl:if test="@enabled = 'false'"> | |
607 | <xsl:text>[</xsl:text> | |
608 | </xsl:if> | |
609 | <xsl:choose> | |
610 | <xsl:when test="@rule = 'accept'"> | |
611 | <xsl:text>accept</xsl:text> | |
612 | </xsl:when> | |
613 | <xsl:otherwise> | |
614 | <a> | |
615 | <xsl:attribute name="href"> | |
616 | <xsl:value-of select="concat('#rule_', @rule)"/> | |
617 | </xsl:attribute> | |
618 | <xsl:value-of select="concat('reduce using rule ', @rule)"/> | |
619 | </a> | |
620 | <xsl:text> (</xsl:text> | |
621 | <xsl:value-of | |
95134bc1 | 622 | select="key('bison:ruleNumber', current()/@rule)/lhs[text()]"/> |
bbeff196 WP |
623 | <xsl:text>)</xsl:text> |
624 | </xsl:otherwise> | |
625 | </xsl:choose> | |
626 | <xsl:if test="@enabled = 'false'"> | |
627 | <xsl:text>]</xsl:text> | |
628 | </xsl:if> | |
629 | <xsl:text> </xsl:text> | |
630 | </xsl:template> | |
631 | ||
632 | <xsl:template match="solved-conflicts"> | |
633 | <xsl:if test="resolution"> | |
634 | <xsl:text> </xsl:text> | |
635 | <xsl:apply-templates select="resolution"/> | |
636 | </xsl:if> | |
637 | </xsl:template> | |
638 | ||
639 | <xsl:template match="resolution"> | |
640 | <xsl:text> Conflict between </xsl:text> | |
641 | <a> | |
642 | <xsl:attribute name="href"> | |
643 | <xsl:value-of select="concat('#rule_', @rule)"/> | |
644 | </xsl:attribute> | |
645 | <xsl:value-of select="concat('rule ',@rule)"/> | |
646 | </a> | |
647 | <xsl:text> and token </xsl:text> | |
648 | <xsl:value-of select="@symbol"/> | |
649 | <xsl:text> resolved as </xsl:text> | |
650 | <xsl:if test="@type = 'error'"> | |
651 | <xsl:text>an </xsl:text> | |
652 | </xsl:if> | |
653 | <xsl:value-of select="@type"/> | |
654 | <xsl:text> (</xsl:text> | |
655 | <xsl:value-of select="."/> | |
656 | <xsl:text>). </xsl:text> | |
657 | </xsl:template> | |
658 | ||
659 | <xsl:template name="max-width-symbol"> | |
660 | <xsl:param name="node"/> | |
661 | <xsl:variable name="longest"> | |
662 | <xsl:for-each select="$node"> | |
663 | <xsl:sort data-type="number" select="string-length(@symbol)" | |
664 | order="descending"/> | |
665 | <xsl:if test="position() = 1"> | |
666 | <xsl:value-of select="string-length(@symbol)"/> | |
667 | </xsl:if> | |
668 | </xsl:for-each> | |
669 | </xsl:variable> | |
670 | <xsl:value-of select="$longest"/> | |
671 | </xsl:template> | |
672 | ||
673 | <xsl:template name="lpad"> | |
674 | <xsl:param name="str" select="''"/> | |
675 | <xsl:param name="pad" select="0"/> | |
676 | <xsl:variable name="diff" select="$pad - string-length($str)" /> | |
677 | <xsl:choose> | |
678 | <xsl:when test="$diff < 0"> | |
679 | <xsl:value-of select="$str"/> | |
680 | </xsl:when> | |
681 | <xsl:otherwise> | |
682 | <xsl:call-template name="space"> | |
683 | <xsl:with-param name="repeat" select="$diff"/> | |
684 | </xsl:call-template> | |
685 | <xsl:value-of select="$str"/> | |
686 | </xsl:otherwise> | |
687 | </xsl:choose> | |
688 | </xsl:template> | |
689 | ||
690 | <xsl:template name="rpad"> | |
691 | <xsl:param name="str" select="''"/> | |
692 | <xsl:param name="pad" select="0"/> | |
693 | <xsl:variable name="diff" select="$pad - string-length($str)"/> | |
694 | <xsl:choose> | |
695 | <xsl:when test="$diff < 0"> | |
696 | <xsl:value-of select="$str"/> | |
697 | </xsl:when> | |
698 | <xsl:otherwise> | |
699 | <xsl:value-of select="$str"/> | |
700 | <xsl:call-template name="space"> | |
701 | <xsl:with-param name="repeat" select="$diff"/> | |
702 | </xsl:call-template> | |
703 | </xsl:otherwise> | |
704 | </xsl:choose> | |
705 | </xsl:template> | |
706 | ||
707 | <xsl:template name="space"> | |
708 | <xsl:param name="repeat">0</xsl:param> | |
709 | <xsl:param name="fill" select="' '"/> | |
710 | <xsl:if test="number($repeat) >= 1"> | |
711 | <xsl:call-template name="space"> | |
712 | <xsl:with-param name="repeat" select="$repeat - 1"/> | |
713 | <xsl:with-param name="fill" select="$fill"/> | |
714 | </xsl:call-template> | |
715 | <xsl:value-of select="$fill"/> | |
716 | </xsl:if> | |
717 | </xsl:template> | |
718 | ||
719 | </xsl:stylesheet> |