]>
Commit | Line | Data |
---|---|---|
21f1b063 JD |
1 | <?xml version="1.0" encoding="UTF-8"?> |
2 | ||
3 | <!-- | |
4 | bison.xsl - common templates for Bison XSLT. | |
5 | Copyright (C) 2007 Free Software Foundation, Inc. | |
6 | ||
7 | This file is part of Bison, the GNU Compiler Compiler. | |
8 | ||
9 | This program is free software: you can redistribute it and/or modify | |
10 | it under the terms of the GNU General Public License as published by | |
11 | the Free Software Foundation, either version 3 of the License, or | |
12 | (at your option) any later version. | |
13 | ||
14 | This program is distributed in the hope that it will be useful, | |
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | GNU General Public License for more details. | |
18 | ||
19 | You should have received a copy of the GNU General Public License | |
20 | along with this program. If not, see <http://www.gnu.org/licenses/>. | |
21 | --> | |
22 | ||
23 | <xsl:stylesheet version="1.0" | |
24 | xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | |
25 | xmlns:bison="http://www.gnu.org/software/bison/"> | |
26 | ||
27 | <!-- For the specified state, output: #sr-conflicts,#rr-conflicts --> | |
28 | <xsl:template match="state" mode="bison:count-conflicts"> | |
29 | <xsl:variable name="transitions" select="actions/transitions"/> | |
30 | <xsl:variable name="reductions" select="actions/reductions"/> | |
31 | <xsl:variable | |
32 | name="terminals" | |
33 | select=" | |
34 | $transitions/transition[@type='shift']/@symbol | |
35 | | $reductions/reduction/@symbol | |
36 | " | |
37 | /> | |
38 | <xsl:variable name="conflict-data"> | |
39 | <xsl:for-each select="$terminals"> | |
40 | <xsl:variable name="name" select="."/> | |
41 | <xsl:if test="generate-id($terminals[. = $name][1]) = generate-id(.)"> | |
42 | <xsl:variable | |
43 | name="shift-count" | |
44 | select="count($transitions/transition[@symbol=$name])" | |
45 | /> | |
46 | <xsl:variable | |
47 | name="reduce-count" | |
48 | select="count($reductions/reduction[@symbol=$name])" | |
49 | /> | |
50 | <xsl:if test="$shift-count > 0 and $reduce-count > 0"> | |
51 | <xsl:text>s</xsl:text> | |
52 | </xsl:if> | |
53 | <xsl:if test="$reduce-count > 1"> | |
54 | <xsl:text>r</xsl:text> | |
55 | </xsl:if> | |
56 | </xsl:if> | |
57 | </xsl:for-each> | |
58 | </xsl:variable> | |
59 | <xsl:value-of select="string-length(translate($conflict-data, 'r', ''))"/> | |
60 | <xsl:text>,</xsl:text> | |
61 | <xsl:value-of select="string-length(translate($conflict-data, 's', ''))"/> | |
62 | </xsl:template> | |
63 | ||
64 | </xsl:stylesheet> |