]> git.saurik.com Git - bison.git/blob - data/xslt/xml2xhtml.xsl
In the XML output, list useless and unused symbols and rules with the
[bison.git] / data / xslt / xml2xhtml.xsl
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"
29 xmlns="http://www.w3.org/1999/xhtml"
30 xmlns:bison="http://www.gnu.org/software/bison/">
31
32 <xsl:import href="bison.xsl"/>
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>&#10;&#10;</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>&#10;&#10;</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="#nonterminals_useless_in_grammar">Nonterminals useless in grammar</a></li>
112 <li><a href="#terminals_unused_in_grammar">Terminals unused in grammar</a></li>
113 <li><a href="#rules_useless_in_grammar">Rules useless in grammar</a></li>
114 <xsl:if test="grammar/rules/rule[@usefulness='useless-in-parser']">
115 <li><a href="#rules_useless_in_parser">Rules useless in parser due to conflicts</a></li>
116 </xsl:if>
117 </ul>
118 </li>
119 <li><a href="#conflicts">Conflicts</a></li>
120 <li>
121 <a href="#grammar">Grammar</a>
122 <ul class="lower-alpha">
123 <li><a href="#grammar">Itemset</a></li>
124 <li><a href="#terminals">Terminal symbols</a></li>
125 <li><a href="#nonterminals">Nonterminal symbols</a></li>
126 </ul>
127 </li>
128 <li><a href="#automaton">Automaton</a></li>
129 </ul>
130 <xsl:apply-templates select="grammar" mode="reductions"/>
131 <xsl:apply-templates select="grammar" mode="useless-in-parser"/>
132 <xsl:apply-templates select="automaton" mode="conflicts"/>
133 <xsl:apply-templates select="grammar"/>
134 <xsl:apply-templates select="automaton"/>
135 </xsl:template>
136
137 <xsl:template match="grammar" mode="reductions">
138 <h2>
139 <a name="reductions"/>
140 <xsl:text> Reductions</xsl:text>
141 </h2>
142 <xsl:apply-templates select="nonterminals" mode="useless-in-grammar"/>
143 <xsl:apply-templates select="terminals" mode="unused-in-grammar"/>
144 <xsl:apply-templates select="rules" mode="useless-in-grammar"/>
145 </xsl:template>
146
147 <xsl:template match="nonterminals" mode="useless-in-grammar">
148 <h3>
149 <a name="nonterminals_useless_in_grammar"/>
150 <xsl:text> Nonterminals useless in grammar</xsl:text>
151 </h3>
152 <xsl:text>&#10;&#10;</xsl:text>
153 <xsl:if test="nonterminal[@usefulness='useless-in-grammar']">
154 <p class="pre">
155 <xsl:for-each select="nonterminal[@usefulness='useless-in-grammar']">
156 <xsl:text> </xsl:text>
157 <xsl:value-of select="@name"/>
158 <xsl:text>&#10;</xsl:text>
159 </xsl:for-each>
160 <xsl:text>&#10;&#10;</xsl:text>
161 </p>
162 </xsl:if>
163 </xsl:template>
164
165 <xsl:template match="terminals" mode="unused-in-grammar">
166 <h3>
167 <a name="terminals_unused_in_grammar"/>
168 <xsl:text> Terminals unused in grammar</xsl:text>
169 </h3>
170 <xsl:text>&#10;&#10;</xsl:text>
171 <xsl:if test="terminal[@usefulness='unused-in-grammar']">
172 <p class="pre">
173 <xsl:for-each select="terminal[@usefulness='unused-in-grammar']">
174 <xsl:sort select="@symbol-number" data-type="number"/>
175 <xsl:text> </xsl:text>
176 <xsl:value-of select="@name"/>
177 <xsl:text>&#10;</xsl:text>
178 </xsl:for-each>
179 <xsl:text>&#10;&#10;</xsl:text>
180 </p>
181 </xsl:if>
182 </xsl:template>
183
184 <xsl:template match="rules" mode="useless-in-grammar">
185 <h3>
186 <a name="rules_useless_in_grammar"/>
187 <xsl:text> Rules useless in grammar</xsl:text>
188 </h3>
189 <xsl:text>&#10;</xsl:text>
190 <xsl:variable name="set" select="rule[@usefulness='useless-in-grammar']"/>
191 <xsl:if test="$set">
192 <p class="pre">
193 <xsl:call-template name="style-rule-set">
194 <xsl:with-param name="rule-set" select="$set"/>
195 </xsl:call-template>
196 <xsl:text>&#10;&#10;</xsl:text>
197 </p>
198 </xsl:if>
199 </xsl:template>
200
201 <xsl:template match="grammar" mode="useless-in-parser">
202 <xsl:variable
203 name="set" select="rules/rule[@usefulness='useless-in-parser']"
204 />
205 <xsl:if test="$set">
206 <h2>
207 <a name="rules_useless_in_parser"/>
208 <xsl:text> Rules useless in parser due to conflicts</xsl:text>
209 </h2>
210 <xsl:text>&#10;</xsl:text>
211 <p class="pre">
212 <xsl:call-template name="style-rule-set">
213 <xsl:with-param name="rule-set" select="$set"/>
214 </xsl:call-template>
215 </p>
216 <xsl:text>&#10;&#10;</xsl:text>
217 </xsl:if>
218 </xsl:template>
219
220 <xsl:template match="grammar">
221 <h2>
222 <a name="grammar"/>
223 <xsl:text> Grammar</xsl:text>
224 </h2>
225 <xsl:text>&#10;</xsl:text>
226 <p class="pre">
227 <xsl:call-template name="style-rule-set">
228 <xsl:with-param
229 name="rule-set" select="rules/rule[@usefulness!='useless-in-grammar']"
230 />
231 </xsl:call-template>
232 </p>
233 <xsl:text>&#10;&#10;</xsl:text>
234 <xsl:apply-templates select="terminals"/>
235 <xsl:apply-templates select="nonterminals"/>
236 </xsl:template>
237
238 <xsl:template name="style-rule-set">
239 <xsl:param name="rule-set"/>
240 <xsl:for-each select="$rule-set">
241 <xsl:apply-templates select=".">
242 <xsl:with-param name="pad" select="'3'"/>
243 <xsl:with-param name="prev-lhs">
244 <xsl:if test="position()>1">
245 <xsl:variable name="position" select="position()"/>
246 <xsl:value-of select="$rule-set[$position - 1]/lhs"/>
247 </xsl:if>
248 </xsl:with-param>
249 </xsl:apply-templates>
250 </xsl:for-each>
251 </xsl:template>
252
253 <xsl:template match="automaton" mode="conflicts">
254 <h2>
255 <a name="conflicts"/>
256 <xsl:text> Conflicts</xsl:text>
257 </h2>
258 <xsl:text>&#10;&#10;</xsl:text>
259 <xsl:variable name="conflict-report">
260 <xsl:apply-templates select="state" mode="conflicts"/>
261 </xsl:variable>
262 <xsl:if test="string-length($conflict-report) != 0">
263 <p class="pre">
264 <xsl:copy-of select="$conflict-report"/>
265 <xsl:text>&#10;&#10;</xsl:text>
266 </p>
267 </xsl:if>
268 </xsl:template>
269
270 <xsl:template match="state" mode="conflicts">
271 <xsl:variable name="conflict-counts">
272 <xsl:apply-templates select="." mode="bison:count-conflicts" />
273 </xsl:variable>
274 <xsl:variable
275 name="sr-count" select="substring-before($conflict-counts, ',')"
276 />
277 <xsl:variable
278 name="rr-count" select="substring-after($conflict-counts, ',')"
279 />
280 <xsl:if test="$sr-count > 0 or $rr-count > 0">
281 <a>
282 <xsl:attribute name="href">
283 <xsl:value-of select="concat('#state_', @number)"/>
284 </xsl:attribute>
285 <xsl:value-of select="concat('State ', @number)"/>
286 </a>
287 <xsl:text> conflicts:</xsl:text>
288 <xsl:if test="$sr-count > 0">
289 <xsl:value-of select="concat(' ', $sr-count, ' shift/reduce')"/>
290 <xsl:if test="$rr-count > 0">
291 <xsl:value-of select="(',')"/>
292 </xsl:if>
293 </xsl:if>
294 <xsl:if test="$rr-count > 0">
295 <xsl:value-of select="concat(' ', $rr-count, ' reduce/reduce')"/>
296 </xsl:if>
297 <xsl:value-of select="'&#10;'"/>
298 </xsl:if>
299 </xsl:template>
300
301 <xsl:template match="grammar/terminals">
302 <h3>
303 <a name="terminals"/>
304 <xsl:text> Terminals, with rules where they appear</xsl:text>
305 </h3>
306 <xsl:text>&#10;&#10;</xsl:text>
307 <p class="pre">
308 <xsl:apply-templates select="terminal"/>
309 </p>
310 <xsl:text>&#10;&#10;</xsl:text>
311 </xsl:template>
312
313 <xsl:template match="grammar/nonterminals">
314 <h3>
315 <a name="nonterminals"/>
316 <xsl:text> Nonterminals, with rules where they appear</xsl:text>
317 </h3>
318 <xsl:text>&#10;&#10;</xsl:text>
319 <p class="pre">
320 <xsl:apply-templates
321 select="nonterminal[@usefulness!='useless-in-grammar']"
322 />
323 </p>
324 </xsl:template>
325
326 <xsl:template match="terminal">
327 <b><xsl:value-of select="@name"/></b>
328 <xsl:value-of select="concat(' (', @token-number, ')')"/>
329 <xsl:apply-templates select="rule"/>
330 <xsl:text>&#10;</xsl:text>
331 </xsl:template>
332
333 <xsl:template match="terminal/rule">
334 <xsl:text> </xsl:text>
335 <a>
336 <xsl:attribute name="href">
337 <xsl:value-of select="concat('#rule_', .)"/>
338 </xsl:attribute>
339 <xsl:value-of select="."/>
340 </a>
341 </xsl:template>
342
343 <xsl:template match="nonterminal">
344 <b><xsl:value-of select="@name"/></b>
345 <xsl:value-of select="concat(' (', @symbol-number, ')')"/>
346 <xsl:text>&#10; </xsl:text>
347 <xsl:if test="left/rule">
348 <xsl:text>on left:</xsl:text>
349 </xsl:if>
350 <xsl:apply-templates select="left/rule"/>
351 <xsl:if test="left/rule and right/rule">
352 <xsl:text>&#10; </xsl:text>
353 </xsl:if>
354 <xsl:if test="right/rule">
355 <xsl:text>on right:</xsl:text>
356 </xsl:if>
357 <xsl:apply-templates select="right/rule"/>
358 <xsl:text>&#10;</xsl:text>
359 </xsl:template>
360
361 <xsl:template match="nonterminal/left/rule|nonterminal/right/rule">
362 <xsl:text> </xsl:text>
363 <a>
364 <xsl:attribute name="href">
365 <xsl:value-of select="concat('#rule_', .)"/>
366 </xsl:attribute>
367 <xsl:value-of select="."/>
368 </a>
369 </xsl:template>
370
371 <xsl:template match="automaton">
372 <h2>
373 <a name="automaton"/>
374 <xsl:text> Automaton</xsl:text>
375 </h2>
376 <xsl:apply-templates select="state">
377 <xsl:with-param name="pad" select="'3'"/>
378 </xsl:apply-templates>
379 </xsl:template>
380
381 <xsl:template match="automaton/state">
382 <xsl:param name="pad"/>
383 <xsl:text>&#10;&#10;</xsl:text>
384 <h3>
385 <a>
386 <xsl:attribute name="name">
387 <xsl:value-of select="concat('state_', @number)"/>
388 </xsl:attribute>
389 </a>
390 <xsl:text>state </xsl:text>
391 <xsl:value-of select="@number"/>
392 </h3>
393 <xsl:text>&#10;&#10;</xsl:text>
394 <p class="pre">
395 <xsl:apply-templates select="itemset/item">
396 <xsl:with-param name="pad" select="$pad"/>
397 </xsl:apply-templates>
398 <xsl:apply-templates select="actions/transitions">
399 <xsl:with-param name="type" select="'shift'"/>
400 </xsl:apply-templates>
401 <xsl:apply-templates select="actions/errors"/>
402 <xsl:apply-templates select="actions/reductions"/>
403 <xsl:apply-templates select="actions/transitions">
404 <xsl:with-param name="type" select="'goto'"/>
405 </xsl:apply-templates>
406 <xsl:apply-templates select="solved-conflicts"/>
407 </p>
408 </xsl:template>
409
410 <xsl:template match="actions/transitions">
411 <xsl:param name="type"/>
412 <xsl:if test="transition[@type = $type]">
413 <xsl:text>&#10;</xsl:text>
414 <xsl:apply-templates select="transition[@type = $type]">
415 <xsl:with-param name="pad">
416 <xsl:call-template name="max-width-symbol">
417 <xsl:with-param name="node" select="transition[@type = $type]"/>
418 </xsl:call-template>
419 </xsl:with-param>
420 </xsl:apply-templates>
421 </xsl:if>
422 </xsl:template>
423
424 <xsl:template match="actions/errors">
425 <xsl:if test="error">
426 <xsl:text>&#10;</xsl:text>
427 <xsl:apply-templates select="error">
428 <xsl:with-param name="pad">
429 <xsl:call-template name="max-width-symbol">
430 <xsl:with-param name="node" select="error"/>
431 </xsl:call-template>
432 </xsl:with-param>
433 </xsl:apply-templates>
434 </xsl:if>
435 </xsl:template>
436
437 <xsl:template match="actions/reductions">
438 <xsl:if test="reduction">
439 <xsl:text>&#10;</xsl:text>
440 <xsl:apply-templates select="reduction">
441 <xsl:with-param name="pad">
442 <xsl:call-template name="max-width-symbol">
443 <xsl:with-param name="node" select="reduction"/>
444 </xsl:call-template>
445 </xsl:with-param>
446 </xsl:apply-templates>
447 </xsl:if>
448 </xsl:template>
449
450 <xsl:template match="item">
451 <xsl:param name="pad"/>
452 <xsl:param name="prev-rule-number"
453 select="preceding-sibling::item[1]/@rule-number"/>
454 <xsl:apply-templates select="key('bison:ruleNumber', current()/@rule-number)">
455 <xsl:with-param name="itemset" select="'true'"/>
456 <xsl:with-param name="pad" select="$pad"/>
457 <xsl:with-param name="prev-lhs"
458 select="key('bison:ruleNumber', $prev-rule-number)/lhs[text()]"/>
459 <xsl:with-param name="point" select="@point"/>
460 <xsl:with-param name="lookaheads">
461 <xsl:apply-templates select="lookaheads"/>
462 </xsl:with-param>
463 </xsl:apply-templates>
464 </xsl:template>
465
466 <xsl:template match="rule">
467 <xsl:param name="itemset"/>
468 <xsl:param name="pad"/>
469 <xsl:param name="prev-lhs"/>
470 <xsl:param name="point"/>
471 <xsl:param name="lookaheads"/>
472
473 <xsl:if test="$itemset != 'true' and not($prev-lhs = lhs[text()])">
474 <xsl:text>&#10;</xsl:text>
475 </xsl:if>
476
477 <xsl:if test="$itemset != 'true'">
478 <a>
479 <xsl:attribute name="name">
480 <xsl:value-of select="concat('rule_', @number)"/>
481 </xsl:attribute>
482 </a>
483 </xsl:if>
484 <xsl:text> </xsl:text>
485
486 <xsl:choose>
487 <xsl:when test="$itemset = 'true'">
488 <a>
489 <xsl:attribute name="href">
490 <xsl:value-of select="concat('#rule_', @number)"/>
491 </xsl:attribute>
492 <xsl:call-template name="lpad">
493 <xsl:with-param name="str" select="string(@number)"/>
494 <xsl:with-param name="pad" select="number($pad)"/>
495 </xsl:call-template>
496 </a>
497 </xsl:when>
498 <xsl:otherwise>
499 <xsl:call-template name="lpad">
500 <xsl:with-param name="str" select="string(@number)"/>
501 <xsl:with-param name="pad" select="number($pad)"/>
502 </xsl:call-template>
503 </xsl:otherwise>
504 </xsl:choose>
505 <xsl:text> </xsl:text>
506
507 <!-- LHS -->
508 <xsl:choose>
509 <xsl:when test="$itemset != 'true' and $prev-lhs = lhs[text()]">
510 <xsl:call-template name="lpad">
511 <xsl:with-param name="str" select="'|'"/>
512 <xsl:with-param name="pad" select="number(string-length(lhs[text()])) + 2"/>
513 </xsl:call-template>
514 </xsl:when>
515 <xsl:when test="$itemset = 'true' and $prev-lhs = lhs[text()]">
516 <xsl:call-template name="lpad">
517 <xsl:with-param name="str" select="'|'"/>
518 <xsl:with-param name="pad" select="number(string-length(lhs[text()])) + 2"/>
519 </xsl:call-template>
520 </xsl:when>
521 <xsl:otherwise>
522 <span class="i">
523 <xsl:value-of select="lhs"/>
524 </span>
525 <xsl:text> &#8594;</xsl:text>
526 </xsl:otherwise>
527 </xsl:choose>
528
529 <!-- RHS -->
530 <xsl:for-each select="rhs/*">
531 <xsl:if test="position() = $point + 1">
532 <xsl:text> </xsl:text>
533 <span class="point">.</span>
534 </xsl:if>
535 <xsl:if test="$itemset = 'true' and name(.) != 'empty'">
536 <xsl:apply-templates select="."/>
537 </xsl:if>
538 <xsl:if test="$itemset != 'true'">
539 <xsl:apply-templates select="."/>
540 </xsl:if>
541 <xsl:if test="position() = last() and position() = $point">
542 <xsl:text> </xsl:text>
543 <span class="point">.</span>
544 </xsl:if>
545 </xsl:for-each>
546 <xsl:if test="$lookaheads">
547 <xsl:value-of select="$lookaheads"/>
548 </xsl:if>
549
550 <xsl:text>&#10;</xsl:text>
551 </xsl:template>
552
553 <xsl:template match="symbol">
554 <xsl:text> </xsl:text>
555 <xsl:choose>
556 <xsl:when test="@class = 'nonterminal'">
557 <span class="i"><xsl:value-of select="."/></span>
558 </xsl:when>
559 <xsl:otherwise>
560 <b><xsl:value-of select="."/></b>
561 </xsl:otherwise>
562 </xsl:choose>
563 </xsl:template>
564
565 <xsl:template match="empty">
566 <xsl:text> &#949;</xsl:text>
567 </xsl:template>
568
569 <xsl:template match="lookaheads">
570 <xsl:text> [</xsl:text>
571 <xsl:apply-templates select="symbol"/>
572 <xsl:text>]</xsl:text>
573 </xsl:template>
574
575 <xsl:template match="lookaheads/symbol">
576 <xsl:value-of select="."/>
577 <xsl:if test="position() != last()">
578 <xsl:text>, </xsl:text>
579 </xsl:if>
580 </xsl:template>
581
582 <xsl:template match="transition">
583 <xsl:param name="pad"/>
584 <xsl:text> </xsl:text>
585 <xsl:call-template name="rpad">
586 <xsl:with-param name="str" select="string(@symbol)"/>
587 <xsl:with-param name="pad" select="number($pad) + 2"/>
588 </xsl:call-template>
589 <xsl:choose>
590 <xsl:when test="@type = 'shift'">
591 <a>
592 <xsl:attribute name="href">
593 <xsl:value-of select="concat('#state_', @state)"/>
594 </xsl:attribute>
595 <xsl:value-of select="concat('shift, and go to state ', @state)"/>
596 </a>
597 </xsl:when>
598 <xsl:when test="@type = 'goto'">
599 <a>
600 <xsl:attribute name="href">
601 <xsl:value-of select="concat('#state_', @state)"/>
602 </xsl:attribute>
603 <xsl:value-of select="concat('go to state ', @state)"/>
604 </a>
605 </xsl:when>
606 </xsl:choose>
607 <xsl:text>&#10;</xsl:text>
608 </xsl:template>
609
610 <xsl:template match="error">
611 <xsl:param name="pad"/>
612 <xsl:text> </xsl:text>
613 <xsl:call-template name="rpad">
614 <xsl:with-param name="str" select="string(@symbol)"/>
615 <xsl:with-param name="pad" select="number($pad) + 2"/>
616 </xsl:call-template>
617 <xsl:text>error</xsl:text>
618 <xsl:text> (</xsl:text>
619 <xsl:value-of select="text()"/>
620 <xsl:text>)</xsl:text>
621 <xsl:text>&#10;</xsl:text>
622 </xsl:template>
623
624 <xsl:template match="reduction">
625 <xsl:param name="pad"/>
626 <xsl:text> </xsl:text>
627 <xsl:call-template name="rpad">
628 <xsl:with-param name="str" select="string(@symbol)"/>
629 <xsl:with-param name="pad" select="number($pad) + 2"/>
630 </xsl:call-template>
631 <xsl:if test="@enabled = 'false'">
632 <xsl:text>[</xsl:text>
633 </xsl:if>
634 <xsl:choose>
635 <xsl:when test="@rule = 'accept'">
636 <xsl:text>accept</xsl:text>
637 </xsl:when>
638 <xsl:otherwise>
639 <a>
640 <xsl:attribute name="href">
641 <xsl:value-of select="concat('#rule_', @rule)"/>
642 </xsl:attribute>
643 <xsl:value-of select="concat('reduce using rule ', @rule)"/>
644 </a>
645 <xsl:text> (</xsl:text>
646 <xsl:value-of
647 select="key('bison:ruleNumber', current()/@rule)/lhs[text()]"/>
648 <xsl:text>)</xsl:text>
649 </xsl:otherwise>
650 </xsl:choose>
651 <xsl:if test="@enabled = 'false'">
652 <xsl:text>]</xsl:text>
653 </xsl:if>
654 <xsl:text>&#10;</xsl:text>
655 </xsl:template>
656
657 <xsl:template match="solved-conflicts">
658 <xsl:if test="resolution">
659 <xsl:text>&#10;</xsl:text>
660 <xsl:apply-templates select="resolution"/>
661 </xsl:if>
662 </xsl:template>
663
664 <xsl:template match="resolution">
665 <xsl:text> Conflict between </xsl:text>
666 <a>
667 <xsl:attribute name="href">
668 <xsl:value-of select="concat('#rule_', @rule)"/>
669 </xsl:attribute>
670 <xsl:value-of select="concat('rule ',@rule)"/>
671 </a>
672 <xsl:text> and token </xsl:text>
673 <xsl:value-of select="@symbol"/>
674 <xsl:text> resolved as </xsl:text>
675 <xsl:if test="@type = 'error'">
676 <xsl:text>an </xsl:text>
677 </xsl:if>
678 <xsl:value-of select="@type"/>
679 <xsl:text> (</xsl:text>
680 <xsl:value-of select="."/>
681 <xsl:text>).&#10;</xsl:text>
682 </xsl:template>
683
684 <xsl:template name="max-width-symbol">
685 <xsl:param name="node"/>
686 <xsl:variable name="longest">
687 <xsl:for-each select="$node">
688 <xsl:sort data-type="number" select="string-length(@symbol)"
689 order="descending"/>
690 <xsl:if test="position() = 1">
691 <xsl:value-of select="string-length(@symbol)"/>
692 </xsl:if>
693 </xsl:for-each>
694 </xsl:variable>
695 <xsl:value-of select="$longest"/>
696 </xsl:template>
697
698 <xsl:template name="lpad">
699 <xsl:param name="str" select="''"/>
700 <xsl:param name="pad" select="0"/>
701 <xsl:variable name="diff" select="$pad - string-length($str)" />
702 <xsl:choose>
703 <xsl:when test="$diff &lt; 0">
704 <xsl:value-of select="$str"/>
705 </xsl:when>
706 <xsl:otherwise>
707 <xsl:call-template name="space">
708 <xsl:with-param name="repeat" select="$diff"/>
709 </xsl:call-template>
710 <xsl:value-of select="$str"/>
711 </xsl:otherwise>
712 </xsl:choose>
713 </xsl:template>
714
715 <xsl:template name="rpad">
716 <xsl:param name="str" select="''"/>
717 <xsl:param name="pad" select="0"/>
718 <xsl:variable name="diff" select="$pad - string-length($str)"/>
719 <xsl:choose>
720 <xsl:when test="$diff &lt; 0">
721 <xsl:value-of select="$str"/>
722 </xsl:when>
723 <xsl:otherwise>
724 <xsl:value-of select="$str"/>
725 <xsl:call-template name="space">
726 <xsl:with-param name="repeat" select="$diff"/>
727 </xsl:call-template>
728 </xsl:otherwise>
729 </xsl:choose>
730 </xsl:template>
731
732 <xsl:template name="space">
733 <xsl:param name="repeat">0</xsl:param>
734 <xsl:param name="fill" select="' '"/>
735 <xsl:if test="number($repeat) &gt;= 1">
736 <xsl:call-template name="space">
737 <xsl:with-param name="repeat" select="$repeat - 1"/>
738 <xsl:with-param name="fill" select="$fill"/>
739 </xsl:call-template>
740 <xsl:value-of select="$fill"/>
741 </xsl:if>
742 </xsl:template>
743
744 </xsl:stylesheet>