mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
Make xml2dot.xsl and --graph produce the same output.
* data/xslt/xml2dot.xsl (xsl:template match="rule"): Use a ` ' instead of a `\n'. That is, don't add escapes yet or they'll be doubly escaped later. (xsl:template name="output-node"): Use the new escape template instead of the string-replace template directly. (xsl:template name="output-edge"): Likewise. (xsl:template name="escape"): New, escapes backslashes and newlines in addition to quotation marks. * src/graphviz.c (start_graph, output_node, output_edge): Add whitespace to output for legibility. Make xml2text.xsl and --report produce the same output, and remove the XML "conflicts" element since a conflict summary is easily extracted from the automaton. * data/xslt/bison.xsl: New. (xsl:template match="state" mode="bison:count-conflicts): New. * data/xslt/xml2text.xsl: Import bison.xsl. (xsl:template match="bison-xml-report"): Instead of styling the "conflicts" element, style the "automaton" element with mode "conflicts". Unlike the former, the latter lists S/R and R/R conflicts for a state on the same line. (xsl:template match="conflicts"): Remove. (xsl:template match="conflict"): Remove. (xsl:template match="terminal"): Line-wrap the list of rules in which the terminal is used. (xsl:template match="nonterminal"): Likewise for nonterminals. (xsl:template match="automaton" mode="conflicts"): New. (xsl:template match="state" mode="conflicts"): New. (xsl:template name="line-wrap"): New. (xsl:template name="ws-search"): New. * data/xslt/xml2xhtml.xsl: Import bison.xsl. (xsl:template match="bison-xml-report"): Instead of styling the "conflicts" element, style the "automaton" element with mode "conflicts." (xsl:template match="conflicts"): Remove. (xsl:template match="conflict"): Remove. (xsl:template match="automaton" mode="conflicts"): New. (xsl:template match="state" mode="conflicts): New. * src/conflicts.c (conflicts_output_xml): Remove. * src/conflicts.h (conflicts_output_xml): Remove prototype. * src/print-xml.c (print_xml): Don't invoke conflicts_output_xml. * src/print.c (print_grammar): Consistently wrap at the 66th column so the corresponding XSLT is easier. Also, never wrap between a word and the comma that follows it.
This commit is contained in:
48
ChangeLog
48
ChangeLog
@@ -1,3 +1,51 @@
|
||||
2007-10-09 Joel E. Denny <jdenny@ces.clemson.edu>
|
||||
|
||||
Make xml2dot.xsl and --graph produce the same output.
|
||||
* data/xslt/xml2dot.xsl (xsl:template match="rule"): Use a ` '
|
||||
instead of a `\n'. That is, don't add escapes yet or they'll be doubly
|
||||
escaped later.
|
||||
(xsl:template name="output-node"): Use the new escape template instead
|
||||
of the string-replace template directly.
|
||||
(xsl:template name="output-edge"): Likewise.
|
||||
(xsl:template name="escape"): New, escapes backslashes and newlines in
|
||||
addition to quotation marks.
|
||||
* src/graphviz.c (start_graph, output_node, output_edge): Add
|
||||
whitespace to output for legibility.
|
||||
|
||||
Make xml2text.xsl and --report produce the same output, and remove the
|
||||
XML "conflicts" element since a conflict summary is easily extracted
|
||||
from the automaton.
|
||||
* data/xslt/bison.xsl: New.
|
||||
(xsl:template match="state" mode="bison:count-conflicts): New.
|
||||
* data/xslt/xml2text.xsl: Import bison.xsl.
|
||||
(xsl:template match="bison-xml-report"): Instead of styling the
|
||||
"conflicts" element, style the "automaton" element with mode
|
||||
"conflicts". Unlike the former, the latter lists S/R and R/R
|
||||
conflicts for a state on the same line.
|
||||
(xsl:template match="conflicts"): Remove.
|
||||
(xsl:template match="conflict"): Remove.
|
||||
(xsl:template match="terminal"): Line-wrap the list of rules in which
|
||||
the terminal is used.
|
||||
(xsl:template match="nonterminal"): Likewise for nonterminals.
|
||||
(xsl:template match="automaton" mode="conflicts"): New.
|
||||
(xsl:template match="state" mode="conflicts"): New.
|
||||
(xsl:template name="line-wrap"): New.
|
||||
(xsl:template name="ws-search"): New.
|
||||
* data/xslt/xml2xhtml.xsl: Import bison.xsl.
|
||||
(xsl:template match="bison-xml-report"): Instead of styling the
|
||||
"conflicts" element, style the "automaton" element with mode
|
||||
"conflicts."
|
||||
(xsl:template match="conflicts"): Remove.
|
||||
(xsl:template match="conflict"): Remove.
|
||||
(xsl:template match="automaton" mode="conflicts"): New.
|
||||
(xsl:template match="state" mode="conflicts): New.
|
||||
* src/conflicts.c (conflicts_output_xml): Remove.
|
||||
* src/conflicts.h (conflicts_output_xml): Remove prototype.
|
||||
* src/print-xml.c (print_xml): Don't invoke conflicts_output_xml.
|
||||
* src/print.c (print_grammar): Consistently wrap at the 66th column so
|
||||
the corresponding XSLT is easier. Also, never wrap between a word and
|
||||
the comma that follows it.
|
||||
|
||||
2007-10-08 Joel E. Denny <jdenny@ces.clemson.edu>
|
||||
|
||||
Improve C++ namespace support. Discussed starting at
|
||||
|
||||
64
data/xslt/bison.xsl
Normal file
64
data/xslt/bison.xsl
Normal file
@@ -0,0 +1,64 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!--
|
||||
bison.xsl - common templates for Bison XSLT.
|
||||
Copyright (C) 2007 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of Bison, the GNU Compiler Compiler.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
|
||||
<xsl:stylesheet version="1.0"
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
xmlns:bison="http://www.gnu.org/software/bison/">
|
||||
|
||||
<!-- For the specified state, output: #sr-conflicts,#rr-conflicts -->
|
||||
<xsl:template match="state" mode="bison:count-conflicts">
|
||||
<xsl:variable name="transitions" select="actions/transitions"/>
|
||||
<xsl:variable name="reductions" select="actions/reductions"/>
|
||||
<xsl:variable
|
||||
name="terminals"
|
||||
select="
|
||||
$transitions/transition[@type='shift']/@symbol
|
||||
| $reductions/reduction/@symbol
|
||||
"
|
||||
/>
|
||||
<xsl:variable name="conflict-data">
|
||||
<xsl:for-each select="$terminals">
|
||||
<xsl:variable name="name" select="."/>
|
||||
<xsl:if test="generate-id($terminals[. = $name][1]) = generate-id(.)">
|
||||
<xsl:variable
|
||||
name="shift-count"
|
||||
select="count($transitions/transition[@symbol=$name])"
|
||||
/>
|
||||
<xsl:variable
|
||||
name="reduce-count"
|
||||
select="count($reductions/reduction[@symbol=$name])"
|
||||
/>
|
||||
<xsl:if test="$shift-count > 0 and $reduce-count > 0">
|
||||
<xsl:text>s</xsl:text>
|
||||
</xsl:if>
|
||||
<xsl:if test="$reduce-count > 1">
|
||||
<xsl:text>r</xsl:text>
|
||||
</xsl:if>
|
||||
</xsl:if>
|
||||
</xsl:for-each>
|
||||
</xsl:variable>
|
||||
<xsl:value-of select="string-length(translate($conflict-data, 'r', ''))"/>
|
||||
<xsl:text>,</xsl:text>
|
||||
<xsl:value-of select="string-length(translate($conflict-data, 's', ''))"/>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
||||
@@ -59,7 +59,7 @@
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="rule">
|
||||
<xsl:text>\n</xsl:text>
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:value-of select="lhs"/>
|
||||
<xsl:text> -></xsl:text>
|
||||
<xsl:apply-templates select="rhs/symbol|rhs/point|rhs/empty"/>
|
||||
@@ -123,10 +123,8 @@
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:value-of select="$number"/>
|
||||
<xsl:text> [label="</xsl:text>
|
||||
<xsl:call-template name="string-replace">
|
||||
<xsl:call-template name="escape">
|
||||
<xsl:with-param name="subject" select="$label"/>
|
||||
<xsl:with-param name="search" select="'"'"/>
|
||||
<xsl:with-param name="replace" select="'\"'"/>
|
||||
</xsl:call-template>
|
||||
<xsl:text>"] </xsl:text>
|
||||
</xsl:template>
|
||||
@@ -144,36 +142,55 @@
|
||||
<xsl:value-of select="$style"/>
|
||||
<xsl:if test="$label and $label != ''">
|
||||
<xsl:text> label="</xsl:text>
|
||||
<xsl:call-template name="string-replace">
|
||||
<xsl:call-template name="escape">
|
||||
<xsl:with-param name="subject" select="$label"/>
|
||||
<xsl:with-param name="search" select="'"'"/>
|
||||
<xsl:with-param name="replace" select="'\"'"/>
|
||||
</xsl:call-template>
|
||||
<xsl:text>"</xsl:text>
|
||||
</xsl:if>
|
||||
<xsl:text>] </xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="string-replace">
|
||||
<xsl:param name="subject"/>
|
||||
<xsl:param name="search"/>
|
||||
<xsl:param name="replace"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="contains($subject, $search)">
|
||||
<xsl:variable name="before" select="substring-before($subject, $search)"/>
|
||||
<xsl:variable name="after" select="substring-after($subject, $search)"/>
|
||||
<xsl:value-of select="$before"/>
|
||||
<xsl:value-of select="$replace"/>
|
||||
<xsl:call-template name="string-replace">
|
||||
<xsl:with-param name="subject" select="$after"/>
|
||||
<xsl:with-param name="search" select="$search"/>
|
||||
<xsl:with-param name="replace" select="$replace"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="$subject"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
<xsl:template name="escape">
|
||||
<xsl:param name="subject" required="yes"/>
|
||||
<xsl:call-template name="string-replace">
|
||||
<xsl:with-param name="subject">
|
||||
<xsl:call-template name="string-replace">
|
||||
<xsl:with-param name="subject">
|
||||
<xsl:call-template name="string-replace">
|
||||
<xsl:with-param name="subject" select="$subject"/>
|
||||
<xsl:with-param name="search" select="'\'"/>
|
||||
<xsl:with-param name="replace" select="'\\'"/>
|
||||
</xsl:call-template>
|
||||
</xsl:with-param>
|
||||
<xsl:with-param name="search" select="'"'"/>
|
||||
<xsl:with-param name="replace" select="'\"'"/>
|
||||
</xsl:call-template>
|
||||
</xsl:with-param>
|
||||
<xsl:with-param name="search" select="' '"/>
|
||||
<xsl:with-param name="replace" select="'\n'"/>
|
||||
</xsl:call-template>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="string-replace">
|
||||
<xsl:param name="subject"/>
|
||||
<xsl:param name="search"/>
|
||||
<xsl:param name="replace"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="contains($subject, $search)">
|
||||
<xsl:variable name="before" select="substring-before($subject, $search)"/>
|
||||
<xsl:variable name="after" select="substring-after($subject, $search)"/>
|
||||
<xsl:value-of select="$before"/>
|
||||
<xsl:value-of select="$replace"/>
|
||||
<xsl:call-template name="string-replace">
|
||||
<xsl:with-param name="subject" select="$after"/>
|
||||
<xsl:with-param name="search" select="$search"/>
|
||||
<xsl:with-param name="replace" select="$replace"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="$subject"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
||||
|
||||
@@ -25,8 +25,10 @@
|
||||
-->
|
||||
|
||||
<xsl:stylesheet version="1.0"
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
||||
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
xmlns:bison="http://www.gnu.org/software/bison/">
|
||||
|
||||
<xsl:import href="bison.xsl"/>
|
||||
<xsl:output method="text" encoding="UTF-8" indent="no"/>
|
||||
|
||||
<xsl:template match="/">
|
||||
@@ -36,7 +38,7 @@
|
||||
<xsl:template match="bison-xml-report">
|
||||
<xsl:apply-templates select="reductions"/>
|
||||
<xsl:apply-templates select="rules-never-reduced"/>
|
||||
<xsl:apply-templates select="conflicts"/>
|
||||
<xsl:apply-templates select="automaton" mode="conflicts"/>
|
||||
<xsl:apply-templates select="grammar"/>
|
||||
<xsl:apply-templates select="automaton"/>
|
||||
</xsl:template>
|
||||
@@ -91,23 +93,6 @@
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="conflicts">
|
||||
<xsl:if test="conflict">
|
||||
<xsl:apply-templates select="conflict"/>
|
||||
<xsl:text> </xsl:text>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="conflict">
|
||||
<xsl:text>State </xsl:text>
|
||||
<xsl:value-of select="@state"/>
|
||||
<xsl:text> conflicts: </xsl:text>
|
||||
<xsl:value-of select="@num"/>
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:value-of select="@type"/>
|
||||
<xsl:text> </xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="grammar">
|
||||
<xsl:text>Grammar </xsl:text>
|
||||
<xsl:apply-templates select="rules/rule">
|
||||
@@ -131,9 +116,16 @@
|
||||
|
||||
<xsl:template match="terminal">
|
||||
<xsl:value-of select="@symbol"/>
|
||||
<xsl:value-of select="concat(' (', @type, ')')"/>
|
||||
<xsl:apply-templates select="rule"/>
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:call-template name="line-wrap">
|
||||
<xsl:with-param
|
||||
name="first-line-length" select="66 - string-length(@symbol)"
|
||||
/>
|
||||
<xsl:with-param name="line-length" select="66" />
|
||||
<xsl:with-param name="text">
|
||||
<xsl:value-of select="concat(' (', @type, ')')"/>
|
||||
<xsl:apply-templates select="rule" />
|
||||
</xsl:with-param>
|
||||
</xsl:call-template>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="terminal/rule">
|
||||
@@ -144,19 +136,27 @@
|
||||
<xsl:template match="nonterminal">
|
||||
<xsl:value-of select="@symbol"/>
|
||||
<xsl:value-of select="concat(' (', @type, ')')"/>
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:if test="left/rule">
|
||||
<xsl:text>on left:</xsl:text>
|
||||
</xsl:if>
|
||||
<xsl:apply-templates select="left/rule"/>
|
||||
<xsl:if test="left/rule and right/rule">
|
||||
<xsl:text>, </xsl:text>
|
||||
</xsl:if>
|
||||
<xsl:if test="right/rule">
|
||||
<xsl:text>on right:</xsl:text>
|
||||
</xsl:if>
|
||||
<xsl:apply-templates select="right/rule"/>
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:variable name="output">
|
||||
<xsl:call-template name="line-wrap">
|
||||
<xsl:with-param name="line-length" select="66" />
|
||||
<xsl:with-param name="text">
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:if test="left/rule">
|
||||
<xsl:text>on@left:</xsl:text>
|
||||
</xsl:if>
|
||||
<xsl:apply-templates select="left/rule"/>
|
||||
<xsl:if test="left/rule and right/rule">
|
||||
<xsl:text>, </xsl:text>
|
||||
</xsl:if>
|
||||
<xsl:if test="right/rule">
|
||||
<xsl:text>on@right:</xsl:text>
|
||||
</xsl:if>
|
||||
<xsl:apply-templates select="right/rule"/>
|
||||
</xsl:with-param>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:value-of select="translate($output, '@', ' ')" />
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="nonterminal/left/rule|nonterminal/right/rule">
|
||||
@@ -164,6 +164,41 @@
|
||||
<xsl:value-of select="."/>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="automaton" mode="conflicts">
|
||||
<xsl:variable name="conflict-report">
|
||||
<xsl:apply-templates select="state" mode="conflicts"/>
|
||||
</xsl:variable>
|
||||
<xsl:if test="string-length($conflict-report) != 0">
|
||||
<xsl:value-of select="$conflict-report"/>
|
||||
<xsl:text> </xsl:text>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="state" mode="conflicts">
|
||||
<xsl:variable name="conflict-counts">
|
||||
<xsl:apply-templates select="." mode="bison:count-conflicts" />
|
||||
</xsl:variable>
|
||||
<xsl:variable
|
||||
name="sr-count" select="substring-before($conflict-counts, ',')"
|
||||
/>
|
||||
<xsl:variable
|
||||
name="rr-count" select="substring-after($conflict-counts, ',')"
|
||||
/>
|
||||
<xsl:if test="$sr-count > 0 or $rr-count > 0">
|
||||
<xsl:value-of select="concat('State ', @number, ' conflicts:')"/>
|
||||
<xsl:if test="$sr-count > 0">
|
||||
<xsl:value-of select="concat(' ', $sr-count, ' shift/reduce')"/>
|
||||
<xsl:if test="$rr-count > 0">
|
||||
<xsl:value-of select="(',')"/>
|
||||
</xsl:if>
|
||||
</xsl:if>
|
||||
<xsl:if test="$rr-count > 0">
|
||||
<xsl:value-of select="concat(' ', $rr-count, ' reduce/reduce')"/>
|
||||
</xsl:if>
|
||||
<xsl:value-of select="' '"/>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="automaton">
|
||||
<xsl:apply-templates select="state">
|
||||
<xsl:with-param name="pad" select="'3'"/>
|
||||
@@ -429,4 +464,50 @@
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="line-wrap">
|
||||
<xsl:param name="line-length" required="yes" />
|
||||
<xsl:param name="first-line-length" select="$line-length" />
|
||||
<xsl:param name="text" required="yes" />
|
||||
<xsl:choose>
|
||||
<xsl:when test="string-length($text) = 0 or normalize-space($text) = ''" />
|
||||
<xsl:when test="string-length($text) <= $first-line-length">
|
||||
<xsl:value-of select="concat($text, ' ')" />
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:variable name="break-pos">
|
||||
<xsl:call-template name="ws-search">
|
||||
<xsl:with-param name="text" select="$text" />
|
||||
<xsl:with-param name="pos" select="$first-line-length+1" />
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:value-of select="substring($text, 1, $break-pos - 1)" />
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:call-template name="line-wrap">
|
||||
<xsl:with-param name="line-length" select="$line-length" />
|
||||
<xsl:with-param
|
||||
name="text" select="concat(' ', substring($text, $break-pos+1))"
|
||||
/>
|
||||
</xsl:call-template>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="ws-search">
|
||||
<xsl:param name="text" required="yes" />
|
||||
<xsl:param name="pos" required="yes" />
|
||||
<xsl:choose>
|
||||
<xsl:when
|
||||
test="$pos > string-length($text) or substring($text, $pos, 1) = ' '"
|
||||
>
|
||||
<xsl:value-of select="$pos" />
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:call-template name="ws-search">
|
||||
<xsl:with-param name="text" select="$text" />
|
||||
<xsl:with-param name="pos" select="$pos+1" />
|
||||
</xsl:call-template>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
||||
|
||||
@@ -26,7 +26,10 @@
|
||||
|
||||
<xsl:stylesheet version="1.0"
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
xmlns="http://www.w3.org/1999/xhtml">
|
||||
xmlns="http://www.w3.org/1999/xhtml"
|
||||
xmlns:bison="http://www.gnu.org/software/bison/">
|
||||
|
||||
<xsl:import href="bison.xsl"/>
|
||||
|
||||
<xsl:output method="xml" encoding="UTF-8"
|
||||
doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
@@ -123,7 +126,7 @@
|
||||
</ul>
|
||||
<xsl:apply-templates select="reductions"/>
|
||||
<xsl:apply-templates select="rules-never-reduced"/>
|
||||
<xsl:apply-templates select="conflicts"/>
|
||||
<xsl:apply-templates select="automaton" mode="conflicts"/>
|
||||
<xsl:apply-templates select="grammar"/>
|
||||
<xsl:apply-templates select="automaton"/>
|
||||
</xsl:template>
|
||||
@@ -206,32 +209,52 @@
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="conflicts">
|
||||
<xsl:template match="automaton" mode="conflicts">
|
||||
<h2>
|
||||
<a name="conflicts"/>
|
||||
<xsl:text> Conflicts</xsl:text>
|
||||
</h2>
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:if test="conflict">
|
||||
<xsl:variable name="conflict-report">
|
||||
<xsl:apply-templates select="state" mode="conflicts"/>
|
||||
</xsl:variable>
|
||||
<xsl:if test="string-length($conflict-report) != 0">
|
||||
<p class="pre">
|
||||
<xsl:apply-templates select="conflict"/>
|
||||
<xsl:copy-of select="$conflict-report"/>
|
||||
<xsl:text> </xsl:text>
|
||||
</p>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="conflict">
|
||||
<a>
|
||||
<xsl:attribute name="href">
|
||||
<xsl:value-of select="concat('#state_', @state)"/>
|
||||
</xsl:attribute>
|
||||
<xsl:value-of select="concat('State ', @state)"/>
|
||||
</a>
|
||||
<xsl:text> conflicts: </xsl:text>
|
||||
<xsl:value-of select="@num"/>
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:value-of select="@type"/>
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:template match="state" mode="conflicts">
|
||||
<xsl:variable name="conflict-counts">
|
||||
<xsl:apply-templates select="." mode="bison:count-conflicts" />
|
||||
</xsl:variable>
|
||||
<xsl:variable
|
||||
name="sr-count" select="substring-before($conflict-counts, ',')"
|
||||
/>
|
||||
<xsl:variable
|
||||
name="rr-count" select="substring-after($conflict-counts, ',')"
|
||||
/>
|
||||
<xsl:if test="$sr-count > 0 or $rr-count > 0">
|
||||
<a>
|
||||
<xsl:attribute name="href">
|
||||
<xsl:value-of select="concat('#state_', @number)"/>
|
||||
</xsl:attribute>
|
||||
<xsl:value-of select="concat('State ', @number)"/>
|
||||
</a>
|
||||
<xsl:text> conflicts:</xsl:text>
|
||||
<xsl:if test="$sr-count > 0">
|
||||
<xsl:value-of select="concat(' ', $sr-count, ' shift/reduce')"/>
|
||||
<xsl:if test="$rr-count > 0">
|
||||
<xsl:value-of select="(',')"/>
|
||||
</xsl:if>
|
||||
</xsl:if>
|
||||
<xsl:if test="$rr-count > 0">
|
||||
<xsl:value-of select="concat(' ', $rr-count, ' reduce/reduce')"/>
|
||||
</xsl:if>
|
||||
<xsl:value-of select="' '"/>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="grammar">
|
||||
|
||||
@@ -522,47 +522,6 @@ conflicts_output (FILE *out)
|
||||
fputs ("\n\n", out);
|
||||
}
|
||||
|
||||
void
|
||||
conflicts_output_xml (FILE *out, int level)
|
||||
{
|
||||
bool printed_sth = false;
|
||||
state_number i;
|
||||
int src_num;
|
||||
int rrc_num;
|
||||
|
||||
for (i = 0; i < nstates; i++)
|
||||
{
|
||||
state *s = states[i];
|
||||
if (conflicts[i])
|
||||
{
|
||||
if (!printed_sth) {
|
||||
fputc ('\n', out);
|
||||
xml_puts (out, level, "<conflicts>");
|
||||
}
|
||||
|
||||
src_num = count_sr_conflicts (s);
|
||||
rrc_num = count_rr_conflicts (s, true);
|
||||
|
||||
if (src_num)
|
||||
xml_printf (out, level + 1,
|
||||
"<conflict state=\"%d\" num=\"%d\""
|
||||
" type=\"shift/reduce\"/>",
|
||||
i, src_num);
|
||||
if (rrc_num)
|
||||
xml_printf (out, level + 1,
|
||||
"<conflict state=\"%d\" num=\"%d\""
|
||||
" type=\"reduce/reduce\"/>",
|
||||
i, rrc_num);
|
||||
|
||||
printed_sth = true;
|
||||
}
|
||||
}
|
||||
if (printed_sth)
|
||||
xml_puts (out, level, "</conflicts>");
|
||||
else
|
||||
xml_puts (out, level, "<conflicts/>");
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------.
|
||||
| Total the number of S/R and R/R conflicts. Unlike the |
|
||||
| code in conflicts_output, however, count EACH pair of |
|
||||
|
||||
@@ -37,7 +37,6 @@ void conflicts_update_state_numbers (state_number old_to_new[],
|
||||
void conflicts_print (void);
|
||||
int conflicts_total_count (void);
|
||||
void conflicts_output (FILE *out);
|
||||
void conflicts_output_xml (FILE *out, int level);
|
||||
void conflicts_free (void);
|
||||
|
||||
/* Were there conflicts? */
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Output Graphviz specification of a state machine generated by Bison.
|
||||
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
Copyright (C) 2006, 2007 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of Bison, the GNU Compiler Compiler.
|
||||
|
||||
@@ -38,20 +38,20 @@ quote (char const *name)
|
||||
void
|
||||
start_graph (FILE *fout)
|
||||
{
|
||||
fputs ("digraph Automaton{\n", fout);
|
||||
fputs ("digraph Automaton {\n", fout);
|
||||
}
|
||||
|
||||
void
|
||||
output_node (int id, char const *label, FILE *fout)
|
||||
{
|
||||
fprintf (fout, "%d[label=%s]\n", id, quote (label));
|
||||
fprintf (fout, " %d [label=%s]\n", id, quote (label));
|
||||
}
|
||||
|
||||
void
|
||||
output_edge (int source, int destination, char const *label,
|
||||
char const *style, FILE *fout)
|
||||
{
|
||||
fprintf (fout, "%d->%d[style=%s", source, destination, style);
|
||||
fprintf (fout, " %d -> %d [style=%s", source, destination, style);
|
||||
if (label)
|
||||
fprintf (fout, " label=%s", quote (label));
|
||||
fputs ("]\n", fout);
|
||||
|
||||
@@ -584,9 +584,6 @@ print_xml (void)
|
||||
/* print rules never reduced */
|
||||
print_rules_never_reduced (out, level + 1);
|
||||
|
||||
/* print conflicts */
|
||||
conflicts_output_xml (out, level + 1);
|
||||
|
||||
/* print grammar */
|
||||
print_grammar (out, level + 1);
|
||||
|
||||
|
||||
12
src/print.c
12
src/print.c
@@ -401,7 +401,7 @@ print_grammar (FILE *out)
|
||||
buffer[0] = 0;
|
||||
column = strlen (tag);
|
||||
fputs (tag, out);
|
||||
END_TEST (50);
|
||||
END_TEST (65);
|
||||
sprintf (buffer, " (%d)", i);
|
||||
|
||||
for (r = 0; r < nrules; r++)
|
||||
@@ -445,14 +445,16 @@ print_grammar (FILE *out)
|
||||
|
||||
if (left_count > 0)
|
||||
{
|
||||
END_TEST (50);
|
||||
END_TEST (65);
|
||||
sprintf (buffer + strlen (buffer), _(" on left:"));
|
||||
|
||||
for (r = 0; r < nrules; r++)
|
||||
{
|
||||
END_TEST (65);
|
||||
if (rules[r].lhs->number == i)
|
||||
sprintf (buffer + strlen (buffer), " %d", r);
|
||||
{
|
||||
END_TEST (65);
|
||||
sprintf (buffer + strlen (buffer), " %d", r);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -460,7 +462,7 @@ print_grammar (FILE *out)
|
||||
{
|
||||
if (left_count > 0)
|
||||
sprintf (buffer + strlen (buffer), ",");
|
||||
END_TEST (50);
|
||||
END_TEST (65);
|
||||
sprintf (buffer + strlen (buffer), _(" on right:"));
|
||||
for (r = 0; r < nrules; r++)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user