]> git.saurik.com Git - bison.git/blob - data/xslt/bison.xsl
30fb97e0152e2c1b71d01b5e6a46d29ef843feab
[bison.git] / data / xslt / bison.xsl
1 <?xml version="1.0" encoding="UTF-8"?>
2
3 <!--
4 bison.xsl - common templates for Bison XSLT.
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
25 <xsl:stylesheet version="1.0"
26 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
27 xmlns:bison="http://www.gnu.org/software/bison/">
28
29 <xsl:key
30 name="bison:symbolByName"
31 match="/bison-xml-report/grammar/nonterminals/nonterminal"
32 use="@name"
33 />
34 <xsl:key
35 name="bison:symbolByName"
36 match="/bison-xml-report/grammar/terminals/terminal"
37 use="@name"
38 />
39 <xsl:key
40 name="bison:ruleByNumber"
41 match="/bison-xml-report/grammar/rules/rule"
42 use="@number"
43 />
44 <xsl:key
45 name="bison:ruleByLhs"
46 match="/bison-xml-report/grammar/rules/rule[
47 @usefulness != 'useless-in-grammar']"
48 use="lhs"
49 />
50 <xsl:key
51 name="bison:ruleByRhs"
52 match="/bison-xml-report/grammar/rules/rule[
53 @usefulness != 'useless-in-grammar']"
54 use="rhs/symbol"
55 />
56
57 <!-- For the specified state, output: #sr-conflicts,#rr-conflicts -->
58 <xsl:template match="state" mode="bison:count-conflicts">
59 <xsl:variable name="transitions" select="actions/transitions"/>
60 <xsl:variable name="reductions" select="actions/reductions"/>
61 <xsl:variable
62 name="terminals"
63 select="
64 $transitions/transition[@type='shift']/@symbol
65 | $reductions/reduction/@symbol
66 "
67 />
68 <xsl:variable name="conflict-data">
69 <xsl:for-each select="$terminals">
70 <xsl:variable name="name" select="."/>
71 <xsl:if test="generate-id($terminals[. = $name][1]) = generate-id(.)">
72 <xsl:variable
73 name="shift-count"
74 select="count($transitions/transition[@symbol=$name])"
75 />
76 <xsl:variable
77 name="reduce-count"
78 select="count($reductions/reduction[@symbol=$name])"
79 />
80 <xsl:if test="$shift-count > 0 and $reduce-count > 0">
81 <xsl:text>s</xsl:text>
82 </xsl:if>
83 <xsl:if test="$reduce-count > 1">
84 <xsl:text>r</xsl:text>
85 </xsl:if>
86 </xsl:if>
87 </xsl:for-each>
88 </xsl:variable>
89 <xsl:value-of select="string-length(translate($conflict-data, 'r', ''))"/>
90 <xsl:text>,</xsl:text>
91 <xsl:value-of select="string-length(translate($conflict-data, 's', ''))"/>
92 </xsl:template>
93
94 </xsl:stylesheet>