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