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